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
60 //=============================================================================
64 //=============================================================================
66 GEOMImpl_IHealingOperations::GEOMImpl_IHealingOperations (GEOM_Engine* theEngine, int theDocID)
67 : GEOM_IOperations(theEngine, theDocID)
69 MESSAGE("GEOMImpl_IHealingOperations::GEOMImpl_IHealingOperations");
72 //=============================================================================
76 //=============================================================================
78 GEOMImpl_IHealingOperations::~GEOMImpl_IHealingOperations()
80 MESSAGE("GEOMImpl_IHealingOperations::~GEOMImpl_IHealingOperations");
84 //=============================================================================
88 //=============================================================================
89 Handle(GEOM_Object) GEOMImpl_IHealingOperations::ShapeProcess (Handle(GEOM_Object) theObject,
90 const Handle(TColStd_HArray1OfExtendedString)& theOperators,
91 const Handle(TColStd_HArray1OfExtendedString)& theParams,
92 const Handle(TColStd_HArray1OfExtendedString)& theValues)
94 // set error code, check parameters
97 if (theObject.IsNull())
100 if (theOperators.IsNull() || theOperators->Length() <= 0) {
101 SetErrorCode("No operators requested");
105 Standard_Integer nbParams = 0, nbValues = 0;
106 if (!theParams.IsNull()) {
107 nbParams = theParams->Length();
109 if (!theValues.IsNull()) {
110 nbValues = theValues->Length();
113 if (nbParams != nbValues) {
114 SetErrorCode("Number of parameter values must be equal to the number of parameters");
118 Handle(GEOM_Function) aFunction, aLastFunction = theObject->GetLastFunction();
119 if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be processed
122 Handle(GEOM_Object) aNewObject = GetEngine()->AddObject( GetDocID(), GEOM_COPY );
125 aFunction = aNewObject->AddFunction(GEOMImpl_HealingDriver::GetID(), SHAPE_PROCESS);
127 if (aFunction.IsNull()) return NULL;
129 //Check if the function is set correctly
130 if (aFunction->GetDriverGUID() != GEOMImpl_HealingDriver::GetID()) return NULL;
132 // prepare "data container" class IHealing
133 GEOMImpl_IHealing HI(aFunction);
134 HI.SetOriginal(aLastFunction);
135 HI.SetOperators( theOperators );
137 HI.SetParameters( theParams );
138 HI.SetValues( theValues );
141 //Compute the translation
143 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
146 if (!GetSolver()->ComputeFunction(aFunction))
148 SetErrorCode("Shape Healing algorithm failed");
152 catch (Standard_Failure)
154 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
155 SetErrorCode(aFail->GetMessageString());
159 //Make a Python command
160 GEOM::TPythonDump pd (aFunction);
161 pd << aNewObject << " = geompy.ProcessShape(" << theObject << ", [";
164 int i = theOperators->Lower(), nb = theOperators->Upper();
165 for ( ; i <= nb; i++) {
166 pd << "\"" << TCollection_AsciiString(theOperators->Value( i )).ToCString()
167 << (( i < nb ) ? "\", " : "\"");
170 // list of parameters
171 i = theParams->Lower(); nb = theParams->Upper();
172 for ( ; i <= nb; i++) {
173 pd << "\"" << TCollection_AsciiString(theParams->Value( i )).ToCString()
174 << (( i < nb ) ? "\", " : "\"");
178 i = theValues->Lower(); nb = theValues->Upper();
179 for ( ; i <= nb; i++) {
180 pd << "\"" << TCollection_AsciiString(theValues->Value( i )).ToCString()
181 << (( i < nb ) ? "\", " : "\"");
189 //=============================================================================
193 //=============================================================================
194 void GEOMImpl_IHealingOperations::GetShapeProcessParameters (list<string>& theOperations,
195 list<string>& theParams,
196 list<string>& theValues)
198 ShHealOper_ShapeProcess aHealer;
199 TColStd_SequenceOfAsciiString anOperators;
200 int nbOperatorErrors( 0 );
201 if ( aHealer.GetOperators( anOperators ) )
203 for ( Standard_Integer i = 1; i <= anOperators.Length(); i++ )
205 string anOperation = anOperators.Value( i ).ToCString();
206 if ( GetOperatorParameters( anOperation, theParams, theValues ) )
207 theOperations.push_back( anOperation );
214 SetErrorCode("ERROR retrieving operators (GEOMImpl_IHealingOperations)");
217 if ( nbOperatorErrors ) {
218 TCollection_AsciiString aMsg ("ERRORS retrieving ShapeProcess parameters (GEOMImpl_IHealingOperations): nbOperatorErrors = ");
219 aMsg += TCollection_AsciiString( nbOperatorErrors );
220 MESSAGE(aMsg.ToCString());
224 //=============================================================================
226 * GetOperatorParameters
228 //=============================================================================
229 bool GEOMImpl_IHealingOperations::GetOperatorParameters( const string theOperation,
230 list<string>& theParams,
231 list<string>& theValues )
233 ShHealOper_ShapeProcess aHealer;
234 int nbParamValueErrors( 0 );
235 list<string> aParams;
236 if ( GetParameters( theOperation, aParams ) ) {
237 for ( list<string>::iterator it = aParams.begin(); it != aParams.end(); ++it ) {
238 TCollection_AsciiString aParam( (Standard_CString)(*it).c_str() );
239 TCollection_AsciiString aValue;
240 if ( aHealer.GetParameter( aParam, aValue ) ) {
241 theParams.push_back( aParam.ToCString() );
242 theValues.push_back( aValue.ToCString() );
245 nbParamValueErrors++;
251 if ( nbParamValueErrors ) {
252 TCollection_AsciiString aMsg ("ERRORS retrieving ShapeProcess parameter values (GEOMImpl_IHealingOperations): nbParamValueErrors = ");
253 aMsg += TCollection_AsciiString( nbParamValueErrors );
254 MESSAGE(aMsg.ToCString());
260 //=============================================================================
264 //=============================================================================
265 bool GEOMImpl_IHealingOperations::GetParameters (const string theOperation,
266 list<string>& theParams)
268 if ( theOperation == "SplitAngle" ) {
269 theParams.push_back( "SplitAngle.Angle" );
270 theParams.push_back( "SplitAngle.MaxTolerance" );
272 } else if ( theOperation == "SplitClosedFaces" ) {
273 theParams.push_back( "SplitClosedFaces.NbSplitPoints" );
275 } else if ( theOperation == "FixFaceSize" ) {
276 theParams.push_back( "FixFaceSize.Tolerance" );
278 } else if( theOperation == "DropSmallEdges" ) {
279 theParams.push_back( "DropSmallEdges.Tolerance3d" );
281 } else if( theOperation == "BSplineRestriction" ) {
282 theParams.push_back( "BSplineRestriction.SurfaceMode" );
283 theParams.push_back( "BSplineRestriction.Curve3dMode" );
284 theParams.push_back( "BSplineRestriction.Curve2dMode" );
285 theParams.push_back( "BSplineRestriction.Tolerance3d" );
286 theParams.push_back( "BSplineRestriction.Tolerance2d" );
287 theParams.push_back( "BSplineRestriction.RequiredDegree" );
288 theParams.push_back( "BSplineRestriction.RequiredNbSegments" );
289 theParams.push_back( "BSplineRestriction.Continuity3d" );
290 theParams.push_back( "BSplineRestriction.Continuity2d" );
292 } else if( theOperation == "SplitContinuity" ) {
293 theParams.push_back( "SplitContinuity.Tolerance3d" );
294 theParams.push_back( "SplitContinuity.SurfaceContinuity" );
295 theParams.push_back( "SplitContinuity.CurveContinuity" );
297 } else if( theOperation == "ToBezier" ) {
298 theParams.push_back( "ToBezier.SurfaceMode" );
299 theParams.push_back( "ToBezier.Curve3dMode" );
300 theParams.push_back( "ToBezier.Curve2dMode" );
301 theParams.push_back( "ToBezier.MaxTolerance" );
303 } else if( theOperation == "SameParameter" ) {
304 theParams.push_back( "SameParameter.Tolerance3d" );
306 } else if( theOperation == "FixShape" ) {
307 theParams.push_back( "FixShape.Tolerance3d" );
308 theParams.push_back( "FixShape.MaxTolerance3d" );
317 //=============================================================================
321 //=============================================================================
322 Handle(GEOM_Object) GEOMImpl_IHealingOperations::SuppressFaces
323 (Handle(GEOM_Object) theObject, const Handle(TColStd_HArray1OfInteger)& theFaces)
325 // set error code, check parameters
328 if ( theObject.IsNull() ) // if theFaces.IsNull() - it's OK, it means that ALL faces must be removed..
331 Handle(GEOM_Function) aFunction, aLastFunction = theObject->GetLastFunction();
332 if(aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be processed
335 Handle(GEOM_Object) aNewObject = GetEngine()->AddObject( GetDocID(), GEOM_COPY );
338 aFunction = aNewObject->AddFunction(GEOMImpl_HealingDriver::GetID(), SUPPRESS_FACES);
340 if(aFunction.IsNull()) return NULL;
342 //Check if the function is set correctly
343 if(aFunction->GetDriverGUID() != GEOMImpl_HealingDriver::GetID()) return NULL;
345 // prepare "data container" class IHealing
346 GEOMImpl_IHealing HI(aFunction);
347 HI.SetFaces( theFaces );
348 HI.SetOriginal( aLastFunction );
350 //Compute the translation
352 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
355 if (!GetSolver()->ComputeFunction(aFunction))
357 SetErrorCode("Healing driver failed");
361 catch (Standard_Failure)
363 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
364 SetErrorCode(aFail->GetMessageString());
368 //Make a Python command
369 GEOM::TPythonDump pd (aFunction);
370 pd << aNewObject << " = geompy.SuppressFaces(" << theObject << ", [";
373 int i = theFaces->Lower(), nb = theFaces->Upper();
374 for ( ; i <= nb; i++)
375 pd << theFaces->Value( i ) << (( i < nb ) ? ", " : "])");
382 //=============================================================================
386 //=============================================================================
387 Handle(GEOM_Object) GEOMImpl_IHealingOperations::CloseContour
388 (Handle(GEOM_Object) theObject,
389 const Handle(TColStd_HArray1OfInteger)& theWires,
392 // set error code, check parameters
395 if (theObject.IsNull())
397 SetErrorCode("NULL object given");
401 Handle(GEOM_Function) aFunction, aLastFunction = theObject->GetLastFunction();
402 if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be processed
405 Handle(GEOM_Object) aNewObject = GetEngine()->AddObject( GetDocID(), GEOM_COPY );
408 aFunction = aNewObject->AddFunction(GEOMImpl_HealingDriver::GetID(), CLOSE_CONTOUR);
410 if (aFunction.IsNull()) return NULL;
412 //Check if the function is set correctly
413 if(aFunction->GetDriverGUID() != GEOMImpl_HealingDriver::GetID()) return NULL;
415 // prepare "data container" class IHealing
416 GEOMImpl_IHealing HI(aFunction);
417 HI.SetWires( theWires );
418 HI.SetIsCommonVertex( isCommonVertex );
419 HI.SetOriginal( aLastFunction );
421 //Compute the translation
423 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
426 if (!GetSolver()->ComputeFunction(aFunction))
428 SetErrorCode("Healing driver failed");
432 catch (Standard_Failure)
434 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
435 SetErrorCode(aFail->GetMessageString());
439 //Make a Python command
440 GEOM::TPythonDump pd (aFunction);
441 pd << aNewObject << " = geompy.CloseContour(" << theObject << ", [";
444 if (!theWires.IsNull())
446 int i = theWires->Lower(), nb = theWires->Upper();
447 pd << theWires->Value(i++);
449 pd << ", " << theWires->Value(i++);
451 pd << "], " << (int)isCommonVertex << ")";
457 //=============================================================================
461 //=============================================================================
462 Handle(GEOM_Object) GEOMImpl_IHealingOperations::RemoveIntWires
463 (Handle(GEOM_Object) theObject, const Handle(TColStd_HArray1OfInteger)& theWires)
465 // set error code, check parameters
468 if (theObject.IsNull()) // if theWires is NULL it's OK, it means that ALL wires must be removed
471 Handle(GEOM_Function) aFunction, aLastFunction = theObject->GetLastFunction();
472 if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be processed
475 Handle(GEOM_Object) aNewObject = GetEngine()->AddObject( GetDocID(), GEOM_COPY );
478 aFunction = aNewObject->AddFunction(GEOMImpl_HealingDriver::GetID(), REMOVE_INT_WIRES);
480 if (aFunction.IsNull()) return NULL;
482 //Check if the function is set correctly
483 if (aFunction->GetDriverGUID() != GEOMImpl_HealingDriver::GetID()) return NULL;
485 // prepare "data container" class IHealing
486 GEOMImpl_IHealing HI(aFunction);
487 HI.SetWires( theWires );
488 HI.SetOriginal( aLastFunction );
490 //Compute the translation
492 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
495 if (!GetSolver()->ComputeFunction(aFunction))
497 SetErrorCode("Healing driver failed");
501 catch (Standard_Failure)
503 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
504 SetErrorCode(aFail->GetMessageString());
508 //Make a Python command
509 GEOM::TPythonDump pd (aFunction);
510 pd << aNewObject << " = geompy.SuppressInternalWires(" << theObject << ", [";
513 if (!theWires.IsNull()) {
514 int i = theWires->Lower(), nb = theWires->Upper();
515 for ( ; i <= nb; i++)
516 pd << theWires->Value( i ) << (( i < nb ) ? ", " : "])");
525 //=============================================================================
529 //=============================================================================
530 Handle(GEOM_Object) GEOMImpl_IHealingOperations::FillHoles (Handle(GEOM_Object) theObject,
531 const Handle(TColStd_HArray1OfInteger)& theWires)
533 // set error code, check parameters
536 if (theObject.IsNull()) // if theWires is NULL it's OK, it means that ALL holes must be removed
539 Handle(GEOM_Function) aFunction, aLastFunction = theObject->GetLastFunction();
540 if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be processed
543 Handle(GEOM_Object) aNewObject = GetEngine()->AddObject( GetDocID(), GEOM_COPY );
546 aFunction = aNewObject->AddFunction(GEOMImpl_HealingDriver::GetID(), FILL_HOLES);
548 if (aFunction.IsNull()) return NULL;
550 //Check if the function is set correctly
551 if (aFunction->GetDriverGUID() != GEOMImpl_HealingDriver::GetID()) return NULL;
553 // prepare "data container" class IHealing
554 GEOMImpl_IHealing HI(aFunction);
555 HI.SetWires( theWires );
556 HI.SetOriginal( aLastFunction );
558 //Compute the translation
560 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
563 if (!GetSolver()->ComputeFunction(aFunction))
565 SetErrorCode("Healing driver failed");
569 catch (Standard_Failure)
571 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
572 SetErrorCode(aFail->GetMessageString());
576 //Make a Python command
577 GEOM::TPythonDump pd (aFunction);
578 pd << aNewObject << " = geompy.SuppressHoles(" << theObject << ", [";
581 if ( theWires.IsNull() )
584 int i = theWires->Lower(), nb = theWires->Upper();
585 for ( ; i <= nb; i++)
586 pd << theWires->Value( i ) << (( i < nb ) ? ", " : "])");
593 //=============================================================================
597 //=============================================================================
598 Handle(GEOM_Object) GEOMImpl_IHealingOperations::Sew (Handle(GEOM_Object) theObject,
601 // set error code, check parameters
604 if (theObject.IsNull())
607 Handle(GEOM_Function) aFunction, aLastFunction = theObject->GetLastFunction();
608 if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be processed
611 Handle(GEOM_Object) aNewObject = GetEngine()->AddObject( GetDocID(), GEOM_COPY );
614 aFunction = aNewObject->AddFunction(GEOMImpl_HealingDriver::GetID(), SEWING);
616 if (aFunction.IsNull()) return NULL;
618 //Check if the function is set correctly
619 if (aFunction->GetDriverGUID() != GEOMImpl_HealingDriver::GetID()) return NULL;
621 // prepare "data container" class IHealing
622 GEOMImpl_IHealing HI(aFunction);
623 HI.SetTolerance( theTolerance );
624 HI.SetOriginal( aLastFunction );
626 //Compute the translation
628 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
631 if (!GetSolver()->ComputeFunction(aFunction))
633 SetErrorCode("Healing driver failed");
637 catch (Standard_Failure)
639 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
640 SetErrorCode(aFail->GetMessageString());
644 //Make a Python command
645 GEOM::TPythonDump(aFunction) << aNewObject << " = geompy.Sew("
646 << theObject << ", " << theTolerance << ")";
652 //=============================================================================
656 //=============================================================================
657 Handle(GEOM_Object) GEOMImpl_IHealingOperations::DivideEdge (Handle(GEOM_Object) theObject,
662 // set error code, check parameters
665 if (theObject.IsNull())
668 Handle(GEOM_Function) aFunction, aLastFunction = theObject->GetLastFunction();
669 if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be processed
672 Handle(GEOM_Object) aNewObject = GetEngine()->AddObject( GetDocID(), GEOM_COPY );
675 aFunction = aNewObject->AddFunction(GEOMImpl_HealingDriver::GetID(), DIVIDE_EDGE);
677 if (aFunction.IsNull()) return NULL;
679 //Check if the function is set correctly
680 if (aFunction->GetDriverGUID() != GEOMImpl_HealingDriver::GetID()) return NULL;
682 // prepare "data container" class IHealing
683 GEOMImpl_IHealing HI(aFunction);
684 HI.SetIndex( theIndex );
685 HI.SetDevideEdgeValue( theValue );
686 HI.SetIsByParameter( isByParameter );
687 HI.SetOriginal( aLastFunction );
689 //Compute the translation
691 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
694 if (!GetSolver()->ComputeFunction(aFunction))
696 SetErrorCode("Healing driver failed");
700 catch (Standard_Failure)
702 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
703 SetErrorCode(aFail->GetMessageString());
707 //Make a Python command
708 GEOM::TPythonDump(aFunction) << aNewObject << " = geompy.DivideEdge(" << theObject
709 << ", " << theIndex << ", " << theValue << ", " << (int)isByParameter << ")";
715 //=============================================================================
719 //=============================================================================
720 bool GEOMImpl_IHealingOperations::GetFreeBoundary (Handle(GEOM_Object) theObject,
721 Handle(TColStd_HSequenceOfTransient)& theClosed,
722 Handle(TColStd_HSequenceOfTransient)& theOpen )
724 // set error code, check parameters
727 if ( theObject.IsNull() || theClosed.IsNull() || theOpen.IsNull() )
730 TopoDS_Shape aShape = theObject->GetValue();
731 if ( aShape.IsNull() )
734 // get free boundary shapes
735 ShapeAnalysis_FreeBounds anAnalizer( aShape );
736 TopoDS_Compound aClosed = anAnalizer.GetClosedWires();
737 TopoDS_Compound anOpen = anAnalizer.GetOpenWires();
739 // iterate through shapes and append them to the return sequence
740 Handle(GEOM_Object) anObj;
741 Handle(GEOM_Function) aFunction;
742 TopExp_Explorer anExp;
743 for ( anExp.Init( aClosed, TopAbs_WIRE ); anExp.More(); anExp.Next() )
745 anObj = GetEngine()->AddObject( GetDocID(), GEOM_FREE_BOUNDS );
746 aFunction = anObj->AddFunction( GEOMImpl_CopyDriver::GetID(), COPY_WITHOUT_REF );
747 TopoDS_Shape aValueShape = anExp.Current();
748 aFunction->SetValue( aValueShape );
749 theClosed->Append(anObj);
751 for ( anExp.Init( anOpen, TopAbs_WIRE ); anExp.More(); anExp.Next() )
753 anObj = GetEngine()->AddObject( GetDocID(), GEOM_FREE_BOUNDS );
754 aFunction = anObj->AddFunction( GEOMImpl_CopyDriver::GetID(), COPY_WITHOUT_REF );
755 TopoDS_Shape aValueShape = anExp.Current();
756 aFunction->SetValue( aValueShape );
757 theOpen->Append(anObj);
760 if(!aFunction.IsNull()) {
762 //Make a Python command
763 GEOM::TPythonDump pd (aFunction);
765 Standard_Integer i, aLen = theClosed->Length();
768 for (i = 1; i <= aLen; i++) {
769 Handle(GEOM_Object) anObj_i = Handle(GEOM_Object)::DownCast(theClosed->Value(i));
770 pd << anObj_i << ((i < aLen) ? ", " : "");
774 pd << "(isDone, empty_list, ";
777 aLen = theOpen->Length();
780 for (i = 1; i <= aLen; i++) {
781 Handle(GEOM_Object) anObj_i = Handle(GEOM_Object)::DownCast(theOpen->Value(i));
782 pd << anObj_i << ((i < aLen) ? ", " : "");
789 pd << ") = geompy.GetFreeBoundary(" << theObject << ")";
797 //=============================================================================
801 //=============================================================================
802 Handle(GEOM_Object) GEOMImpl_IHealingOperations::ChangeOrientation (Handle(GEOM_Object) theObject)
804 // set error code, check parameters
807 if (theObject.IsNull())
810 if (!theObject->IsMainShape()) {
811 SetErrorCode("Sub shape cannot be transformed - need to create a copy");
815 Handle(GEOM_Function) aFunction, aLastFunction = theObject->GetLastFunction();
816 if (aLastFunction.IsNull())
817 return NULL; //There is no function which creates an object to be processed
820 aFunction = theObject->AddFunction(GEOMImpl_HealingDriver::GetID(), CHANGE_ORIENTATION);
822 if (aFunction.IsNull())
825 //Check if the function is set correctly
826 if (aFunction->GetDriverGUID() != GEOMImpl_HealingDriver::GetID()) return NULL;
828 // prepare "data container" class IHealing
829 GEOMImpl_IHealing HI(aFunction);
830 HI.SetOriginal( aLastFunction );
832 //Compute the translation
834 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
837 if (!GetSolver()->ComputeFunction(aFunction)) {
838 SetErrorCode("Healing driver failed");
842 catch (Standard_Failure) {
843 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
844 SetErrorCode(aFail->GetMessageString());
848 //Make a Python command
849 GEOM::TPythonDump(aFunction) << "geompy.ChangeOrientationShell("
857 //=============================================================================
859 * ChangeOrientationCopy
861 //=============================================================================
862 Handle(GEOM_Object) GEOMImpl_IHealingOperations::ChangeOrientationCopy (Handle(GEOM_Object) theObject)
864 // set error code, check parameters
867 if (theObject.IsNull())
870 Handle(GEOM_Function) aFunction, aLastFunction = theObject->GetLastFunction();
871 if (aLastFunction.IsNull())
872 return NULL; //There is no function which creates an object to be processed
875 Handle(GEOM_Object) aNewObject = GetEngine()->AddObject( GetDocID(), GEOM_COPY );
878 aFunction = aNewObject->AddFunction(GEOMImpl_HealingDriver::GetID(), CHANGE_ORIENTATION);
880 if (aFunction.IsNull())
883 //Check if the function is set correctly
884 if (aFunction->GetDriverGUID() != GEOMImpl_HealingDriver::GetID()) return NULL;
886 // prepare "data container" class IHealing
887 GEOMImpl_IHealing HI(aFunction);
888 HI.SetOriginal( aLastFunction );
890 //Compute the translation
892 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
895 if (!GetSolver()->ComputeFunction(aFunction)) {
896 SetErrorCode("Healing driver failed");
900 catch (Standard_Failure) {
901 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
902 SetErrorCode(aFail->GetMessageString());
906 //Make a Python command
907 GEOM::TPythonDump(aFunction) << aNewObject << " = geompy.ChangeOrientationShellCopy("