1 // Copyright (C) 2007-2010 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
24 #pragma warning( disable:4786 )
27 #include <Standard_Version.hxx>
28 #include <Standard_Stream.hxx>
30 #include <GEOMImpl_IHealingOperations.hxx>
32 #include <GEOM_PythonDump.hxx>
34 #include <GEOMImpl_HealingDriver.hxx>
35 #include <GEOMImpl_Types.hxx>
36 #include <GEOMImpl_IHealing.hxx>
37 #include <GEOMImpl_CopyDriver.hxx>
39 #include <ShHealOper_ShapeProcess.hxx>
41 #include "utilities.h"
43 #include <Utils_ExceptHandlers.hxx>
45 #include <ShapeAnalysis_FreeBounds.hxx>
47 #include <TopoDS_Compound.hxx>
48 #include <TopExp_Explorer.hxx>
50 #include <TColStd_HArray1OfExtendedString.hxx>
51 #include <TColStd_HSequenceOfTransient.hxx>
52 #include <TCollection_AsciiString.hxx>
54 #include <TDF_Tool.hxx>
56 #include <Standard_Failure.hxx>
57 #include <Standard_ErrorHandler.hxx> // CAREFUL ! position of this file is critic : see Lucien PIGNOLONI / OCC
59 #ifdef OCC_VERSION_SERVICEPACK
60 #define OCC_VERSION_LARGE (OCC_VERSION_MAJOR << 24 | OCC_VERSION_MINOR << 16 | OCC_VERSION_MAINTENANCE << 8 | OCC_VERSION_SERVICEPACK)
62 #define OCC_VERSION_LARGE (OCC_VERSION_MAJOR << 24 | OCC_VERSION_MINOR << 16 | OCC_VERSION_MAINTENANCE << 8)
66 //=============================================================================
70 //=============================================================================
72 GEOMImpl_IHealingOperations::GEOMImpl_IHealingOperations (GEOM_Engine* theEngine, int theDocID)
73 : GEOM_IOperations(theEngine, theDocID)
75 MESSAGE("GEOMImpl_IHealingOperations::GEOMImpl_IHealingOperations");
78 //=============================================================================
82 //=============================================================================
84 GEOMImpl_IHealingOperations::~GEOMImpl_IHealingOperations()
86 MESSAGE("GEOMImpl_IHealingOperations::~GEOMImpl_IHealingOperations");
90 //=============================================================================
94 //=============================================================================
95 Handle(GEOM_Object) GEOMImpl_IHealingOperations::ShapeProcess (Handle(GEOM_Object) theObject,
96 const Handle(TColStd_HArray1OfExtendedString)& theOperators,
97 const Handle(TColStd_HArray1OfExtendedString)& theParams,
98 const Handle(TColStd_HArray1OfExtendedString)& theValues)
100 // set error code, check parameters
103 if (theObject.IsNull())
106 if (theOperators.IsNull() || theOperators->Length() <= 0) {
107 SetErrorCode("No operators requested");
111 Standard_Integer nbParams = 0, nbValues = 0;
112 if (!theParams.IsNull()) {
113 nbParams = theParams->Length();
115 if (!theValues.IsNull()) {
116 nbValues = theValues->Length();
119 if (nbParams != nbValues) {
120 SetErrorCode("Number of parameter values must be equal to the number of parameters");
124 Handle(GEOM_Function) aFunction, aLastFunction = theObject->GetLastFunction();
125 if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be processed
128 Handle(GEOM_Object) aNewObject = GetEngine()->AddObject( GetDocID(), GEOM_COPY );
131 aFunction = aNewObject->AddFunction(GEOMImpl_HealingDriver::GetID(), SHAPE_PROCESS);
133 if (aFunction.IsNull()) return NULL;
135 //Check if the function is set correctly
136 if (aFunction->GetDriverGUID() != GEOMImpl_HealingDriver::GetID()) return NULL;
138 // prepare "data container" class IHealing
139 GEOMImpl_IHealing HI(aFunction);
140 HI.SetOriginal(aLastFunction);
141 HI.SetOperators( theOperators );
143 HI.SetParameters( theParams );
144 HI.SetValues( theValues );
147 //Compute the translation
149 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
152 if (!GetSolver()->ComputeFunction(aFunction))
154 SetErrorCode("Shape Healing algorithm failed");
158 catch (Standard_Failure)
160 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
161 SetErrorCode(aFail->GetMessageString());
165 //Make a Python command
166 GEOM::TPythonDump pd (aFunction);
167 pd << aNewObject << " = geompy.ProcessShape(" << theObject << ", [";
170 int i = theOperators->Lower(), nb = theOperators->Upper();
171 for ( ; i <= nb; i++) {
172 pd << "\"" << TCollection_AsciiString(theOperators->Value( i )).ToCString()
173 << (( i < nb ) ? "\", " : "\"");
176 // list of parameters
177 i = theParams->Lower(); nb = theParams->Upper();
178 for ( ; i <= nb; i++) {
179 pd << "\"" << TCollection_AsciiString(theParams->Value( i )).ToCString()
180 << (( i < nb ) ? "\", " : "\"");
184 i = theValues->Lower(); nb = theValues->Upper();
185 for ( ; i <= nb; i++) {
186 pd << "\"" << TCollection_AsciiString(theValues->Value( i )).ToCString()
187 << (( i < nb ) ? "\", " : "\"");
195 //=============================================================================
199 //=============================================================================
200 void GEOMImpl_IHealingOperations::GetShapeProcessParameters (std::list<std::string>& theOperations,
201 std::list<std::string>& theParams,
202 std::list<std::string>& theValues)
204 ShHealOper_ShapeProcess aHealer;
205 TColStd_SequenceOfAsciiString anOperators;
206 int nbOperatorErrors( 0 );
207 if ( aHealer.GetOperators( anOperators ) )
209 for ( Standard_Integer i = 1; i <= anOperators.Length(); i++ )
211 std::string anOperation = anOperators.Value( i ).ToCString();
212 if ( GetOperatorParameters( anOperation, theParams, theValues ) )
213 theOperations.push_back( anOperation );
220 SetErrorCode("ERROR retrieving operators (GEOMImpl_IHealingOperations)");
223 if ( nbOperatorErrors ) {
224 TCollection_AsciiString aMsg ("ERRORS retrieving ShapeProcess parameters (GEOMImpl_IHealingOperations): nbOperatorErrors = ");
225 aMsg += TCollection_AsciiString( nbOperatorErrors );
226 MESSAGE(aMsg.ToCString());
230 //=============================================================================
232 * GetOperatorParameters
234 //=============================================================================
235 bool GEOMImpl_IHealingOperations::GetOperatorParameters( const std::string theOperation,
236 std::list<std::string>& theParams,
237 std::list<std::string>& theValues )
239 ShHealOper_ShapeProcess aHealer;
240 int nbParamValueErrors( 0 );
241 std::list<std::string> aParams;
242 if ( GetParameters( theOperation, aParams ) ) {
243 for ( std::list<std::string>::iterator it = aParams.begin(); it != aParams.end(); ++it ) {
244 TCollection_AsciiString aParam( (Standard_CString)(*it).c_str() );
245 TCollection_AsciiString aValue;
246 if ( aHealer.GetParameter( aParam, aValue ) ) {
247 theParams.push_back( aParam.ToCString() );
248 theValues.push_back( aValue.ToCString() );
251 nbParamValueErrors++;
257 if ( nbParamValueErrors ) {
258 TCollection_AsciiString aMsg ("ERRORS retrieving ShapeProcess parameter values (GEOMImpl_IHealingOperations): nbParamValueErrors = ");
259 aMsg += TCollection_AsciiString( nbParamValueErrors );
260 MESSAGE(aMsg.ToCString());
266 //=============================================================================
270 //=============================================================================
271 bool GEOMImpl_IHealingOperations::GetParameters (const std::string theOperation,
272 std::list<std::string>& theParams)
274 if ( theOperation == "SplitAngle" ) {
275 theParams.push_back( "SplitAngle.Angle" );
276 theParams.push_back( "SplitAngle.MaxTolerance" );
278 } else if ( theOperation == "SplitClosedFaces" ) {
279 theParams.push_back( "SplitClosedFaces.NbSplitPoints" );
281 } else if ( theOperation == "FixFaceSize" ) {
282 theParams.push_back( "FixFaceSize.Tolerance" );
284 } else if( theOperation == "DropSmallEdges" ) {
285 theParams.push_back( "DropSmallEdges.Tolerance3d" );
287 } else if( theOperation == "BSplineRestriction" ) {
288 theParams.push_back( "BSplineRestriction.SurfaceMode" );
289 theParams.push_back( "BSplineRestriction.Curve3dMode" );
290 theParams.push_back( "BSplineRestriction.Curve2dMode" );
291 theParams.push_back( "BSplineRestriction.Tolerance3d" );
292 theParams.push_back( "BSplineRestriction.Tolerance2d" );
293 theParams.push_back( "BSplineRestriction.RequiredDegree" );
294 theParams.push_back( "BSplineRestriction.RequiredNbSegments" );
295 theParams.push_back( "BSplineRestriction.Continuity3d" );
296 theParams.push_back( "BSplineRestriction.Continuity2d" );
298 } else if( theOperation == "SplitContinuity" ) {
299 theParams.push_back( "SplitContinuity.Tolerance3d" );
300 theParams.push_back( "SplitContinuity.SurfaceContinuity" );
301 theParams.push_back( "SplitContinuity.CurveContinuity" );
303 } else if( theOperation == "ToBezier" ) {
304 theParams.push_back( "ToBezier.SurfaceMode" );
305 theParams.push_back( "ToBezier.Curve3dMode" );
306 theParams.push_back( "ToBezier.Curve2dMode" );
307 theParams.push_back( "ToBezier.MaxTolerance" );
309 } else if( theOperation == "SameParameter" ) {
310 theParams.push_back( "SameParameter.Tolerance3d" );
312 } else if( theOperation == "FixShape" ) {
313 theParams.push_back( "FixShape.Tolerance3d" );
314 theParams.push_back( "FixShape.MaxTolerance3d" );
323 //=============================================================================
327 //=============================================================================
328 Handle(GEOM_Object) GEOMImpl_IHealingOperations::SuppressFaces
329 (Handle(GEOM_Object) theObject, const Handle(TColStd_HArray1OfInteger)& theFaces)
331 // set error code, check parameters
334 if (theObject.IsNull()) // if theFaces.IsNull() - it's OK, it means that ALL faces must be removed..
337 Handle(GEOM_Function) aFunction, aLastFunction = theObject->GetLastFunction();
338 if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be processed
341 Handle(GEOM_Object) aNewObject = GetEngine()->AddObject(GetDocID(), GEOM_COPY);
344 aFunction = aNewObject->AddFunction(GEOMImpl_HealingDriver::GetID(), SUPPRESS_FACES);
346 if (aFunction.IsNull()) return NULL;
348 //Check if the function is set correctly
349 if (aFunction->GetDriverGUID() != GEOMImpl_HealingDriver::GetID()) return NULL;
351 // prepare "data container" class IHealing
352 GEOMImpl_IHealing HI (aFunction);
353 HI.SetFaces(theFaces);
354 HI.SetOriginal(aLastFunction);
356 //Compute the translation
358 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
361 if (!GetSolver()->ComputeFunction(aFunction))
363 SetErrorCode("Healing driver failed");
367 catch (Standard_Failure)
369 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
370 SetErrorCode(aFail->GetMessageString());
374 //Make a Python command
375 GEOM::TPythonDump pd (aFunction);
376 pd << aNewObject << " = geompy.SuppressFaces(" << theObject << ", [";
379 int i = theFaces->Lower(), nb = theFaces->Upper();
380 for ( ; i <= nb; i++)
381 pd << theFaces->Value( i ) << (( i < nb ) ? ", " : "])");
387 //=============================================================================
391 //=============================================================================
392 Handle(GEOM_Object) GEOMImpl_IHealingOperations::CloseContour
393 (Handle(GEOM_Object) theObject,
394 const Handle(TColStd_HArray1OfInteger)& theWires,
397 // set error code, check parameters
400 if (theObject.IsNull())
402 SetErrorCode("NULL object given");
406 Handle(GEOM_Function) aFunction, aLastFunction = theObject->GetLastFunction();
407 if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be processed
410 Handle(GEOM_Object) aNewObject = GetEngine()->AddObject( GetDocID(), GEOM_COPY );
413 aFunction = aNewObject->AddFunction(GEOMImpl_HealingDriver::GetID(), CLOSE_CONTOUR);
415 if (aFunction.IsNull()) return NULL;
417 //Check if the function is set correctly
418 if(aFunction->GetDriverGUID() != GEOMImpl_HealingDriver::GetID()) return NULL;
420 // prepare "data container" class IHealing
421 GEOMImpl_IHealing HI(aFunction);
422 HI.SetWires( theWires );
423 HI.SetIsCommonVertex( isCommonVertex );
424 HI.SetOriginal( aLastFunction );
426 //Compute the translation
428 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
431 if (!GetSolver()->ComputeFunction(aFunction))
433 SetErrorCode("Healing driver failed");
437 catch (Standard_Failure)
439 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
440 SetErrorCode(aFail->GetMessageString());
444 //Make a Python command
445 GEOM::TPythonDump pd (aFunction);
446 pd << aNewObject << " = geompy.CloseContour(" << theObject << ", [";
449 if (!theWires.IsNull())
451 int i = theWires->Lower(), nb = theWires->Upper();
452 pd << theWires->Value(i++);
454 pd << ", " << theWires->Value(i++);
456 pd << "], " << (int)isCommonVertex << ")";
462 //=============================================================================
466 //=============================================================================
467 Handle(GEOM_Object) GEOMImpl_IHealingOperations::RemoveIntWires
468 (Handle(GEOM_Object) theObject, const Handle(TColStd_HArray1OfInteger)& theWires)
470 // set error code, check parameters
473 if (theObject.IsNull()) // if theWires is NULL it's OK, it means that ALL wires must be removed
476 Handle(GEOM_Function) aFunction, aLastFunction = theObject->GetLastFunction();
477 if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be processed
480 Handle(GEOM_Object) aNewObject = GetEngine()->AddObject( GetDocID(), GEOM_COPY );
483 aFunction = aNewObject->AddFunction(GEOMImpl_HealingDriver::GetID(), REMOVE_INT_WIRES);
485 if (aFunction.IsNull()) return NULL;
487 //Check if the function is set correctly
488 if (aFunction->GetDriverGUID() != GEOMImpl_HealingDriver::GetID()) return NULL;
490 // prepare "data container" class IHealing
491 GEOMImpl_IHealing HI(aFunction);
492 HI.SetWires( theWires );
493 HI.SetOriginal( aLastFunction );
495 //Compute the translation
497 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
500 if (!GetSolver()->ComputeFunction(aFunction))
502 SetErrorCode("Healing driver failed");
506 catch (Standard_Failure)
508 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
509 SetErrorCode(aFail->GetMessageString());
513 //Make a Python command
514 GEOM::TPythonDump pd (aFunction);
515 pd << aNewObject << " = geompy.SuppressInternalWires(" << theObject << ", [";
518 if (!theWires.IsNull()) {
519 int i = theWires->Lower(), nb = theWires->Upper();
520 for ( ; i <= nb; i++)
521 pd << theWires->Value( i ) << (( i < nb ) ? ", " : "])");
530 //=============================================================================
534 //=============================================================================
535 Handle(GEOM_Object) GEOMImpl_IHealingOperations::FillHoles (Handle(GEOM_Object) theObject,
536 const Handle(TColStd_HArray1OfInteger)& theWires)
538 // set error code, check parameters
541 if (theObject.IsNull()) // if theWires is NULL it's OK, it means that ALL holes must be removed
544 Handle(GEOM_Function) aFunction, aLastFunction = theObject->GetLastFunction();
545 if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be processed
548 Handle(GEOM_Object) aNewObject = GetEngine()->AddObject( GetDocID(), GEOM_COPY );
551 aFunction = aNewObject->AddFunction(GEOMImpl_HealingDriver::GetID(), FILL_HOLES);
553 if (aFunction.IsNull()) return NULL;
555 //Check if the function is set correctly
556 if (aFunction->GetDriverGUID() != GEOMImpl_HealingDriver::GetID()) return NULL;
558 // prepare "data container" class IHealing
559 GEOMImpl_IHealing HI(aFunction);
560 HI.SetWires( theWires );
561 HI.SetOriginal( aLastFunction );
563 //Compute the translation
565 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
568 if (!GetSolver()->ComputeFunction(aFunction))
570 SetErrorCode("Healing driver failed");
574 catch (Standard_Failure)
576 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
577 SetErrorCode(aFail->GetMessageString());
581 //Make a Python command
582 GEOM::TPythonDump pd (aFunction);
583 pd << aNewObject << " = geompy.SuppressHoles(" << theObject << ", [";
586 if ( theWires.IsNull() )
589 int i = theWires->Lower(), nb = theWires->Upper();
590 for ( ; i <= nb; i++)
591 pd << theWires->Value( i ) << (( i < nb ) ? ", " : "])");
598 //=============================================================================
602 //=============================================================================
603 Handle(GEOM_Object) GEOMImpl_IHealingOperations::Sew (Handle(GEOM_Object) theObject,
606 // set error code, check parameters
609 if (theObject.IsNull())
612 Handle(GEOM_Function) aFunction, aLastFunction = theObject->GetLastFunction();
613 if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be processed
616 Handle(GEOM_Object) aNewObject = GetEngine()->AddObject( GetDocID(), GEOM_COPY );
619 aFunction = aNewObject->AddFunction(GEOMImpl_HealingDriver::GetID(), SEWING);
621 if (aFunction.IsNull()) return NULL;
623 //Check if the function is set correctly
624 if (aFunction->GetDriverGUID() != GEOMImpl_HealingDriver::GetID()) return NULL;
626 // prepare "data container" class IHealing
627 GEOMImpl_IHealing HI(aFunction);
628 HI.SetTolerance( theTolerance );
629 HI.SetOriginal( aLastFunction );
631 //Compute the translation
633 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
636 if (!GetSolver()->ComputeFunction(aFunction))
638 SetErrorCode("Healing driver failed");
642 catch (Standard_Failure)
644 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
645 SetErrorCode(aFail->GetMessageString());
649 //Make a Python command
650 GEOM::TPythonDump(aFunction) << aNewObject << " = geompy.Sew("
651 << theObject << ", " << theTolerance << ")";
657 //=============================================================================
661 //=============================================================================
662 Handle(GEOM_Object) GEOMImpl_IHealingOperations::DivideEdge (Handle(GEOM_Object) theObject,
667 // set error code, check parameters
670 if (theObject.IsNull())
673 Handle(GEOM_Function) aFunction, aLastFunction = theObject->GetLastFunction();
674 if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be processed
677 Handle(GEOM_Object) aNewObject = GetEngine()->AddObject( GetDocID(), GEOM_COPY );
680 aFunction = aNewObject->AddFunction(GEOMImpl_HealingDriver::GetID(), DIVIDE_EDGE);
682 if (aFunction.IsNull()) return NULL;
684 //Check if the function is set correctly
685 if (aFunction->GetDriverGUID() != GEOMImpl_HealingDriver::GetID()) return NULL;
687 // prepare "data container" class IHealing
688 GEOMImpl_IHealing HI(aFunction);
689 HI.SetIndex( theIndex );
690 HI.SetDevideEdgeValue( theValue );
691 HI.SetIsByParameter( isByParameter );
692 HI.SetOriginal( aLastFunction );
694 //Compute the translation
696 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
699 if (!GetSolver()->ComputeFunction(aFunction))
701 SetErrorCode("Healing driver failed");
705 catch (Standard_Failure)
707 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
708 SetErrorCode(aFail->GetMessageString());
712 //Make a Python command
713 GEOM::TPythonDump(aFunction) << aNewObject << " = geompy.DivideEdge(" << theObject
714 << ", " << theIndex << ", " << theValue << ", " << (int)isByParameter << ")";
720 //=============================================================================
724 //=============================================================================
725 bool GEOMImpl_IHealingOperations::GetFreeBoundary (Handle(GEOM_Object) theObject,
726 Handle(TColStd_HSequenceOfTransient)& theClosed,
727 Handle(TColStd_HSequenceOfTransient)& theOpen )
729 // set error code, check parameters
732 if ( theObject.IsNull() || theClosed.IsNull() || theOpen.IsNull() )
735 TopoDS_Shape aShape = theObject->GetValue();
736 if ( aShape.IsNull() )
739 // get free boundary shapes
741 #if OCC_VERSION_LARGE > 0x06030008
742 ShapeAnalysis_FreeBounds anAnalizer(aShape, Standard_False,
743 Standard_True, Standard_True);
745 ShapeAnalysis_FreeBounds anAnalizer(aShape);
747 TopoDS_Compound aClosed = anAnalizer.GetClosedWires();
748 TopoDS_Compound anOpen = anAnalizer.GetOpenWires();
750 // iterate through shapes and append them to the return sequence
751 Handle(GEOM_Object) anObj;
752 Handle(GEOM_Function) aFunction;
753 TopExp_Explorer anExp;
754 for ( anExp.Init( aClosed, TopAbs_WIRE ); anExp.More(); anExp.Next() )
756 anObj = GetEngine()->AddObject( GetDocID(), GEOM_FREE_BOUNDS );
757 aFunction = anObj->AddFunction( GEOMImpl_CopyDriver::GetID(), COPY_WITHOUT_REF );
758 TopoDS_Shape aValueShape = anExp.Current();
759 aFunction->SetValue( aValueShape );
760 theClosed->Append(anObj);
762 for ( anExp.Init( anOpen, TopAbs_WIRE ); anExp.More(); anExp.Next() )
764 anObj = GetEngine()->AddObject( GetDocID(), GEOM_FREE_BOUNDS );
765 aFunction = anObj->AddFunction( GEOMImpl_CopyDriver::GetID(), COPY_WITHOUT_REF );
766 TopoDS_Shape aValueShape = anExp.Current();
767 aFunction->SetValue( aValueShape );
768 theOpen->Append(anObj);
771 if(!aFunction.IsNull()) {
773 //Make a Python command
774 GEOM::TPythonDump pd (aFunction);
776 Standard_Integer i, aLen = theClosed->Length();
779 for (i = 1; i <= aLen; i++) {
780 Handle(GEOM_Object) anObj_i = Handle(GEOM_Object)::DownCast(theClosed->Value(i));
781 pd << anObj_i << ((i < aLen) ? ", " : "");
785 pd << "(isDone, empty_list, ";
788 aLen = theOpen->Length();
791 for (i = 1; i <= aLen; i++) {
792 Handle(GEOM_Object) anObj_i = Handle(GEOM_Object)::DownCast(theOpen->Value(i));
793 pd << anObj_i << ((i < aLen) ? ", " : "");
800 pd << ") = geompy.GetFreeBoundary(" << theObject << ")";
808 //=============================================================================
812 //=============================================================================
813 Handle(GEOM_Object) GEOMImpl_IHealingOperations::ChangeOrientation (Handle(GEOM_Object) theObject)
815 // set error code, check parameters
818 if (theObject.IsNull())
821 if (!theObject->IsMainShape()) {
822 SetErrorCode("Sub shape cannot be transformed - need to create a copy");
826 Handle(GEOM_Function) aFunction, aLastFunction = theObject->GetLastFunction();
827 if (aLastFunction.IsNull())
828 return NULL; //There is no function which creates an object to be processed
831 aFunction = theObject->AddFunction(GEOMImpl_HealingDriver::GetID(), CHANGE_ORIENTATION);
833 if (aFunction.IsNull())
836 //Check if the function is set correctly
837 if (aFunction->GetDriverGUID() != GEOMImpl_HealingDriver::GetID()) return NULL;
839 // prepare "data container" class IHealing
840 GEOMImpl_IHealing HI(aFunction);
841 HI.SetOriginal( aLastFunction );
843 //Compute the translation
845 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
848 if (!GetSolver()->ComputeFunction(aFunction)) {
849 SetErrorCode("Healing driver failed");
853 catch (Standard_Failure) {
854 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
855 SetErrorCode(aFail->GetMessageString());
859 //Make a Python command
860 GEOM::TPythonDump(aFunction) << "geompy.ChangeOrientationShell("
868 //=============================================================================
870 * ChangeOrientationCopy
872 //=============================================================================
873 Handle(GEOM_Object) GEOMImpl_IHealingOperations::ChangeOrientationCopy (Handle(GEOM_Object) theObject)
875 // set error code, check parameters
878 if (theObject.IsNull())
881 Handle(GEOM_Function) aFunction, aLastFunction = theObject->GetLastFunction();
882 if (aLastFunction.IsNull())
883 return NULL; //There is no function which creates an object to be processed
886 Handle(GEOM_Object) aNewObject = GetEngine()->AddObject( GetDocID(), theObject->GetType() );
889 aFunction = aNewObject->AddFunction(GEOMImpl_HealingDriver::GetID(), CHANGE_ORIENTATION);
891 if (aFunction.IsNull())
894 //Check if the function is set correctly
895 if (aFunction->GetDriverGUID() != GEOMImpl_HealingDriver::GetID()) return NULL;
897 // prepare "data container" class IHealing
898 GEOMImpl_IHealing HI(aFunction);
899 HI.SetOriginal( aLastFunction );
901 //Compute the translation
903 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
906 if (!GetSolver()->ComputeFunction(aFunction)) {
907 SetErrorCode("Healing driver failed");
911 catch (Standard_Failure) {
912 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
913 SetErrorCode(aFail->GetMessageString());
917 //Make a Python command
918 GEOM::TPythonDump(aFunction) << aNewObject << " = geompy.ChangeOrientationShellCopy("