1 // Copyright (C) 2005 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
2 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
4 // This library is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU Lesser General Public
6 // License as published by the Free Software Foundation; either
7 // version 2.1 of the License.
9 // This library is distributed in the hope that it will be useful
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 // Lesser General Public License for more details.
14 // You should have received a copy of the GNU Lesser General Public
15 // License along with this library; if not, write to the Free Software
16 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 #pragma warning( disable:4786 )
24 #include <Standard_Stream.hxx>
26 #include <GEOMImpl_IHealingOperations.hxx>
28 #include <GEOM_PythonDump.hxx>
30 #include <GEOMImpl_HealingDriver.hxx>
31 #include <GEOMImpl_Types.hxx>
32 #include <GEOMImpl_IHealing.hxx>
33 #include <GEOMImpl_CopyDriver.hxx>
35 #include <ShHealOper_ShapeProcess.hxx>
37 #include "utilities.h"
39 #include <Utils_ExceptHandlers.hxx>
41 #include <ShapeAnalysis_FreeBounds.hxx>
43 #include <TopoDS_Compound.hxx>
44 #include <TopExp_Explorer.hxx>
46 #include <TColStd_HArray1OfExtendedString.hxx>
47 #include <TColStd_HSequenceOfTransient.hxx>
48 #include <TCollection_AsciiString.hxx>
50 #include <TDF_Tool.hxx>
52 #include <Standard_Failure.hxx>
53 #include <Standard_ErrorHandler.hxx> // CAREFUL ! position of this file is critic : see Lucien PIGNOLONI / OCC
56 //=============================================================================
60 //=============================================================================
62 GEOMImpl_IHealingOperations::GEOMImpl_IHealingOperations (GEOM_Engine* theEngine, int theDocID)
63 : GEOM_IOperations(theEngine, theDocID)
65 MESSAGE("GEOMImpl_IHealingOperations::GEOMImpl_IHealingOperations");
68 //=============================================================================
72 //=============================================================================
74 GEOMImpl_IHealingOperations::~GEOMImpl_IHealingOperations()
76 MESSAGE("GEOMImpl_IHealingOperations::~GEOMImpl_IHealingOperations");
80 //=============================================================================
84 //=============================================================================
85 Handle(GEOM_Object) GEOMImpl_IHealingOperations::ShapeProcess (Handle(GEOM_Object) theObject,
86 const Handle(TColStd_HArray1OfExtendedString)& theOperators,
87 const Handle(TColStd_HArray1OfExtendedString)& theParams,
88 const Handle(TColStd_HArray1OfExtendedString)& theValues)
90 // set error code, check parameters
93 if (theObject.IsNull())
96 if (theOperators.IsNull() || theOperators->Length() <= 0) {
97 SetErrorCode("No operators requested");
101 Standard_Integer nbParams = 0, nbValues = 0;
102 if (!theParams.IsNull()) {
103 nbParams = theParams->Length();
105 if (!theValues.IsNull()) {
106 nbValues = theValues->Length();
109 if (nbParams != nbValues) {
110 SetErrorCode("Number of parameter values must be equal to the number of parameters");
114 Handle(GEOM_Function) aFunction, aLastFunction = theObject->GetLastFunction();
115 if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be processed
118 Handle(GEOM_Object) aNewObject = GetEngine()->AddObject( GetDocID(), GEOM_COPY );
121 aFunction = aNewObject->AddFunction(GEOMImpl_HealingDriver::GetID(), SHAPE_PROCESS);
123 if (aFunction.IsNull()) return NULL;
125 //Check if the function is set correctly
126 if (aFunction->GetDriverGUID() != GEOMImpl_HealingDriver::GetID()) return NULL;
128 // prepare "data container" class IHealing
129 GEOMImpl_IHealing HI(aFunction);
130 HI.SetOriginal(aLastFunction);
131 HI.SetOperators( theOperators );
133 HI.SetParameters( theParams );
134 HI.SetValues( theValues );
137 //Compute the translation
139 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
142 if (!GetSolver()->ComputeFunction(aFunction))
144 SetErrorCode("Shape Healing algorithm failed");
148 catch (Standard_Failure)
150 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
151 SetErrorCode(aFail->GetMessageString());
155 //Make a Python command
156 GEOM::TPythonDump pd (aFunction);
157 pd << aNewObject << " = geompy.ProcessShape(" << theObject << ", [";
160 int i = theOperators->Lower(), nb = theOperators->Upper();
161 for ( ; i <= nb; i++) {
162 pd << "\"" << TCollection_AsciiString(theOperators->Value( i )).ToCString()
163 << (( i < nb ) ? "\", " : "\"");
166 // list of parameters
167 i = theParams->Lower(); nb = theParams->Upper();
168 for ( ; i <= nb; i++) {
169 pd << "\"" << TCollection_AsciiString(theParams->Value( i )).ToCString()
170 << (( i < nb ) ? "\", " : "\"");
174 i = theValues->Lower(); nb = theValues->Upper();
175 for ( ; i <= nb; i++) {
176 pd << "\"" << TCollection_AsciiString(theValues->Value( i )).ToCString()
177 << (( i < nb ) ? "\", " : "\"");
185 //=============================================================================
189 //=============================================================================
190 void GEOMImpl_IHealingOperations::GetShapeProcessParameters (std::list<std::string>& theOperations,
191 std::list<std::string>& theParams,
192 std::list<std::string>& theValues)
194 ShHealOper_ShapeProcess aHealer;
195 TColStd_SequenceOfAsciiString anOperators;
196 int nbOperatorErrors( 0 );
197 if ( aHealer.GetOperators( anOperators ) )
199 for ( Standard_Integer i = 1; i <= anOperators.Length(); i++ )
201 std::string anOperation = anOperators.Value( i ).ToCString();
202 if ( GetOperatorParameters( anOperation, theParams, theValues ) )
203 theOperations.push_back( anOperation );
210 SetErrorCode("ERROR retrieving operators (GEOMImpl_IHealingOperations)");
213 if ( nbOperatorErrors ) {
214 TCollection_AsciiString aMsg ("ERRORS retrieving ShapeProcess parameters (GEOMImpl_IHealingOperations): nbOperatorErrors = ");
215 aMsg += TCollection_AsciiString( nbOperatorErrors );
216 MESSAGE(aMsg.ToCString());
220 //=============================================================================
222 * GetOperatorParameters
224 //=============================================================================
225 bool GEOMImpl_IHealingOperations::GetOperatorParameters( const std::string theOperation,
226 std::list<std::string>& theParams,
227 std::list<std::string>& theValues )
229 ShHealOper_ShapeProcess aHealer;
230 int nbParamValueErrors( 0 );
231 std::list<std::string> aParams;
232 if ( GetParameters( theOperation, aParams ) ) {
233 for ( std::list<std::string>::iterator it = aParams.begin(); it != aParams.end(); ++it ) {
234 TCollection_AsciiString aParam( (Standard_CString)(*it).c_str() );
235 TCollection_AsciiString aValue;
236 if ( aHealer.GetParameter( aParam, aValue ) ) {
237 theParams.push_back( aParam.ToCString() );
238 theValues.push_back( aValue.ToCString() );
241 nbParamValueErrors++;
247 if ( nbParamValueErrors ) {
248 TCollection_AsciiString aMsg ("ERRORS retrieving ShapeProcess parameter values (GEOMImpl_IHealingOperations): nbParamValueErrors = ");
249 aMsg += TCollection_AsciiString( nbParamValueErrors );
250 MESSAGE(aMsg.ToCString());
256 //=============================================================================
260 //=============================================================================
261 bool GEOMImpl_IHealingOperations::GetParameters (const std::string theOperation,
262 std::list<std::string>& theParams)
264 if ( theOperation == "SplitAngle" ) {
265 theParams.push_back( "SplitAngle.Angle" );
266 theParams.push_back( "SplitAngle.MaxTolerance" );
268 } else if ( theOperation == "SplitClosedFaces" ) {
269 theParams.push_back( "SplitClosedFaces.NbSplitPoints" );
271 } else if ( theOperation == "FixFaceSize" ) {
272 theParams.push_back( "FixFaceSize.Tolerance" );
274 } else if( theOperation == "DropSmallEdges" ) {
275 theParams.push_back( "DropSmallEdges.Tolerance3d" );
277 } else if( theOperation == "BSplineRestriction" ) {
278 theParams.push_back( "BSplineRestriction.SurfaceMode" );
279 theParams.push_back( "BSplineRestriction.Curve3dMode" );
280 theParams.push_back( "BSplineRestriction.Curve2dMode" );
281 theParams.push_back( "BSplineRestriction.Tolerance3d" );
282 theParams.push_back( "BSplineRestriction.Tolerance2d" );
283 theParams.push_back( "BSplineRestriction.RequiredDegree" );
284 theParams.push_back( "BSplineRestriction.RequiredNbSegments" );
285 theParams.push_back( "BSplineRestriction.Continuity3d" );
286 theParams.push_back( "BSplineRestriction.Continuity2d" );
288 } else if( theOperation == "SplitContinuity" ) {
289 theParams.push_back( "SplitContinuity.Tolerance3d" );
290 theParams.push_back( "SplitContinuity.SurfaceContinuity" );
291 theParams.push_back( "SplitContinuity.CurveContinuity" );
293 } else if( theOperation == "ToBezier" ) {
294 theParams.push_back( "ToBezier.SurfaceMode" );
295 theParams.push_back( "ToBezier.Curve3dMode" );
296 theParams.push_back( "ToBezier.Curve2dMode" );
297 theParams.push_back( "ToBezier.MaxTolerance" );
299 } else if( theOperation == "SameParameter" ) {
300 theParams.push_back( "SameParameter.Tolerance3d" );
302 } else if( theOperation == "FixShape" ) {
303 theParams.push_back( "FixShape.Tolerance3d" );
304 theParams.push_back( "FixShape.MaxTolerance3d" );
313 //=============================================================================
317 //=============================================================================
318 Handle(GEOM_Object) GEOMImpl_IHealingOperations::SuppressFaces
319 (Handle(GEOM_Object) theObject, const Handle(TColStd_HArray1OfInteger)& theFaces)
321 // set error code, check parameters
324 if ( theObject.IsNull() ) // if theFaces.IsNull() - it's OK, it means that ALL faces must be removed..
327 Handle(GEOM_Function) aFunction, aLastFunction = theObject->GetLastFunction();
328 if(aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be processed
331 Handle(GEOM_Object) aNewObject = GetEngine()->AddObject( GetDocID(), GEOM_COPY );
334 aFunction = aNewObject->AddFunction(GEOMImpl_HealingDriver::GetID(), SUPPRESS_FACES);
336 if(aFunction.IsNull()) return NULL;
338 //Check if the function is set correctly
339 if(aFunction->GetDriverGUID() != GEOMImpl_HealingDriver::GetID()) return NULL;
341 // prepare "data container" class IHealing
342 GEOMImpl_IHealing HI(aFunction);
343 HI.SetFaces( theFaces );
344 HI.SetOriginal( aLastFunction );
346 //Compute the translation
348 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
351 if (!GetSolver()->ComputeFunction(aFunction))
353 SetErrorCode("Healing driver failed");
357 catch (Standard_Failure)
359 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
360 SetErrorCode(aFail->GetMessageString());
364 //Make a Python command
365 GEOM::TPythonDump pd (aFunction);
366 pd << aNewObject << " = geompy.SuppressFaces(" << theObject << ", [";
369 int i = theFaces->Lower(), nb = theFaces->Upper();
370 for ( ; i <= nb; i++)
371 pd << theFaces->Value( i ) << (( i < nb ) ? ", " : "])");
378 //=============================================================================
382 //=============================================================================
383 Handle(GEOM_Object) GEOMImpl_IHealingOperations::CloseContour
384 (Handle(GEOM_Object) theObject,
385 const Handle(TColStd_HArray1OfInteger)& theWires,
388 // set error code, check parameters
391 if (theObject.IsNull())
393 SetErrorCode("NULL object given");
397 Handle(GEOM_Function) aFunction, aLastFunction = theObject->GetLastFunction();
398 if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be processed
401 Handle(GEOM_Object) aNewObject = GetEngine()->AddObject( GetDocID(), GEOM_COPY );
404 aFunction = aNewObject->AddFunction(GEOMImpl_HealingDriver::GetID(), CLOSE_CONTOUR);
406 if (aFunction.IsNull()) return NULL;
408 //Check if the function is set correctly
409 if(aFunction->GetDriverGUID() != GEOMImpl_HealingDriver::GetID()) return NULL;
411 // prepare "data container" class IHealing
412 GEOMImpl_IHealing HI(aFunction);
413 HI.SetWires( theWires );
414 HI.SetIsCommonVertex( isCommonVertex );
415 HI.SetOriginal( aLastFunction );
417 //Compute the translation
419 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
422 if (!GetSolver()->ComputeFunction(aFunction))
424 SetErrorCode("Healing driver failed");
428 catch (Standard_Failure)
430 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
431 SetErrorCode(aFail->GetMessageString());
435 //Make a Python command
436 GEOM::TPythonDump pd (aFunction);
437 pd << aNewObject << " = geompy.CloseContour(" << theObject << ", [";
440 if (!theWires.IsNull())
442 int i = theWires->Lower(), nb = theWires->Upper();
443 pd << theWires->Value(i++);
445 pd << ", " << theWires->Value(i++);
447 pd << "], " << (int)isCommonVertex << ")";
453 //=============================================================================
457 //=============================================================================
458 Handle(GEOM_Object) GEOMImpl_IHealingOperations::RemoveIntWires
459 (Handle(GEOM_Object) theObject, const Handle(TColStd_HArray1OfInteger)& theWires)
461 // set error code, check parameters
464 if (theObject.IsNull()) // if theWires is NULL it's OK, it means that ALL wires must be removed
467 Handle(GEOM_Function) aFunction, aLastFunction = theObject->GetLastFunction();
468 if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be processed
471 Handle(GEOM_Object) aNewObject = GetEngine()->AddObject( GetDocID(), GEOM_COPY );
474 aFunction = aNewObject->AddFunction(GEOMImpl_HealingDriver::GetID(), REMOVE_INT_WIRES);
476 if (aFunction.IsNull()) return NULL;
478 //Check if the function is set correctly
479 if (aFunction->GetDriverGUID() != GEOMImpl_HealingDriver::GetID()) return NULL;
481 // prepare "data container" class IHealing
482 GEOMImpl_IHealing HI(aFunction);
483 HI.SetWires( theWires );
484 HI.SetOriginal( aLastFunction );
486 //Compute the translation
488 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
491 if (!GetSolver()->ComputeFunction(aFunction))
493 SetErrorCode("Healing driver failed");
497 catch (Standard_Failure)
499 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
500 SetErrorCode(aFail->GetMessageString());
504 //Make a Python command
505 GEOM::TPythonDump pd (aFunction);
506 pd << aNewObject << " = geompy.SuppressInternalWires(" << theObject << ", [";
509 if (!theWires.IsNull()) {
510 int i = theWires->Lower(), nb = theWires->Upper();
511 for ( ; i <= nb; i++)
512 pd << theWires->Value( i ) << (( i < nb ) ? ", " : "])");
521 //=============================================================================
525 //=============================================================================
526 Handle(GEOM_Object) GEOMImpl_IHealingOperations::FillHoles (Handle(GEOM_Object) theObject,
527 const Handle(TColStd_HArray1OfInteger)& theWires)
529 // set error code, check parameters
532 if (theObject.IsNull()) // if theWires is NULL it's OK, it means that ALL holes must be removed
535 Handle(GEOM_Function) aFunction, aLastFunction = theObject->GetLastFunction();
536 if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be processed
539 Handle(GEOM_Object) aNewObject = GetEngine()->AddObject( GetDocID(), GEOM_COPY );
542 aFunction = aNewObject->AddFunction(GEOMImpl_HealingDriver::GetID(), FILL_HOLES);
544 if (aFunction.IsNull()) return NULL;
546 //Check if the function is set correctly
547 if (aFunction->GetDriverGUID() != GEOMImpl_HealingDriver::GetID()) return NULL;
549 // prepare "data container" class IHealing
550 GEOMImpl_IHealing HI(aFunction);
551 HI.SetWires( theWires );
552 HI.SetOriginal( aLastFunction );
554 //Compute the translation
556 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
559 if (!GetSolver()->ComputeFunction(aFunction))
561 SetErrorCode("Healing driver failed");
565 catch (Standard_Failure)
567 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
568 SetErrorCode(aFail->GetMessageString());
572 //Make a Python command
573 GEOM::TPythonDump pd (aFunction);
574 pd << aNewObject << " = geompy.SuppressHoles(" << theObject << ", [";
577 if ( theWires.IsNull() )
580 int i = theWires->Lower(), nb = theWires->Upper();
581 for ( ; i <= nb; i++)
582 pd << theWires->Value( i ) << (( i < nb ) ? ", " : "])");
589 //=============================================================================
593 //=============================================================================
594 Handle(GEOM_Object) GEOMImpl_IHealingOperations::Sew (Handle(GEOM_Object) theObject,
597 // set error code, check parameters
600 if (theObject.IsNull())
603 Handle(GEOM_Function) aFunction, aLastFunction = theObject->GetLastFunction();
604 if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be processed
607 Handle(GEOM_Object) aNewObject = GetEngine()->AddObject( GetDocID(), GEOM_COPY );
610 aFunction = aNewObject->AddFunction(GEOMImpl_HealingDriver::GetID(), SEWING);
612 if (aFunction.IsNull()) return NULL;
614 //Check if the function is set correctly
615 if (aFunction->GetDriverGUID() != GEOMImpl_HealingDriver::GetID()) return NULL;
617 // prepare "data container" class IHealing
618 GEOMImpl_IHealing HI(aFunction);
619 HI.SetTolerance( theTolerance );
620 HI.SetOriginal( aLastFunction );
622 //Compute the translation
624 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
627 if (!GetSolver()->ComputeFunction(aFunction))
629 SetErrorCode("Healing driver failed");
633 catch (Standard_Failure)
635 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
636 SetErrorCode(aFail->GetMessageString());
640 //Make a Python command
641 GEOM::TPythonDump(aFunction) << aNewObject << " = geompy.Sew("
642 << theObject << ", " << theTolerance << ")";
648 //=============================================================================
652 //=============================================================================
653 Handle(GEOM_Object) GEOMImpl_IHealingOperations::DivideEdge (Handle(GEOM_Object) theObject,
658 // set error code, check parameters
661 if (theObject.IsNull())
664 Handle(GEOM_Function) aFunction, aLastFunction = theObject->GetLastFunction();
665 if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be processed
668 Handle(GEOM_Object) aNewObject = GetEngine()->AddObject( GetDocID(), GEOM_COPY );
671 aFunction = aNewObject->AddFunction(GEOMImpl_HealingDriver::GetID(), DIVIDE_EDGE);
673 if (aFunction.IsNull()) return NULL;
675 //Check if the function is set correctly
676 if (aFunction->GetDriverGUID() != GEOMImpl_HealingDriver::GetID()) return NULL;
678 // prepare "data container" class IHealing
679 GEOMImpl_IHealing HI(aFunction);
680 HI.SetIndex( theIndex );
681 HI.SetDevideEdgeValue( theValue );
682 HI.SetIsByParameter( isByParameter );
683 HI.SetOriginal( aLastFunction );
685 //Compute the translation
687 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
690 if (!GetSolver()->ComputeFunction(aFunction))
692 SetErrorCode("Healing driver failed");
696 catch (Standard_Failure)
698 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
699 SetErrorCode(aFail->GetMessageString());
703 //Make a Python command
704 GEOM::TPythonDump(aFunction) << aNewObject << " = geompy.DivideEdge(" << theObject
705 << ", " << theIndex << ", " << theValue << ", " << (int)isByParameter << ")";
711 //=============================================================================
715 //=============================================================================
716 bool GEOMImpl_IHealingOperations::GetFreeBoundary (Handle(GEOM_Object) theObject,
717 Handle(TColStd_HSequenceOfTransient)& theClosed,
718 Handle(TColStd_HSequenceOfTransient)& theOpen )
720 // set error code, check parameters
723 if ( theObject.IsNull() || theClosed.IsNull() || theOpen.IsNull() )
726 TopoDS_Shape aShape = theObject->GetValue();
727 if ( aShape.IsNull() )
730 // get free boundary shapes
731 ShapeAnalysis_FreeBounds anAnalizer( aShape );
732 TopoDS_Compound aClosed = anAnalizer.GetClosedWires();
733 TopoDS_Compound anOpen = anAnalizer.GetOpenWires();
735 // iterate through shapes and append them to the return sequence
736 Handle(GEOM_Object) anObj;
737 Handle(GEOM_Function) aFunction;
738 TopExp_Explorer anExp;
739 for ( anExp.Init( aClosed, TopAbs_WIRE ); anExp.More(); anExp.Next() )
741 anObj = GetEngine()->AddObject( GetDocID(), GEOM_FREE_BOUNDS );
742 aFunction = anObj->AddFunction( GEOMImpl_CopyDriver::GetID(), COPY_WITHOUT_REF );
743 TopoDS_Shape aValueShape = anExp.Current();
744 aFunction->SetValue( aValueShape );
745 theClosed->Append(anObj);
747 for ( anExp.Init( anOpen, TopAbs_WIRE ); anExp.More(); anExp.Next() )
749 anObj = GetEngine()->AddObject( GetDocID(), GEOM_FREE_BOUNDS );
750 aFunction = anObj->AddFunction( GEOMImpl_CopyDriver::GetID(), COPY_WITHOUT_REF );
751 TopoDS_Shape aValueShape = anExp.Current();
752 aFunction->SetValue( aValueShape );
753 theOpen->Append(anObj);
756 if(!aFunction.IsNull()) {
758 //Make a Python command
759 GEOM::TPythonDump pd (aFunction);
761 Standard_Integer i, aLen = theClosed->Length();
764 for (i = 1; i <= aLen; i++) {
765 Handle(GEOM_Object) anObj_i = Handle(GEOM_Object)::DownCast(theClosed->Value(i));
766 pd << anObj_i << ((i < aLen) ? ", " : "");
770 pd << "(isDone, empty_list, ";
773 aLen = theOpen->Length();
776 for (i = 1; i <= aLen; i++) {
777 Handle(GEOM_Object) anObj_i = Handle(GEOM_Object)::DownCast(theOpen->Value(i));
778 pd << anObj_i << ((i < aLen) ? ", " : "");
785 pd << ") = geompy.GetFreeBoundary(" << theObject << ")";
793 //=============================================================================
797 //=============================================================================
798 Handle(GEOM_Object) GEOMImpl_IHealingOperations::ChangeOrientation (Handle(GEOM_Object) theObject)
800 // set error code, check parameters
803 if (theObject.IsNull())
806 if (!theObject->IsMainShape()) {
807 SetErrorCode("Sub shape cannot be transformed - need to create a copy");
811 Handle(GEOM_Function) aFunction, aLastFunction = theObject->GetLastFunction();
812 if (aLastFunction.IsNull())
813 return NULL; //There is no function which creates an object to be processed
816 aFunction = theObject->AddFunction(GEOMImpl_HealingDriver::GetID(), CHANGE_ORIENTATION);
818 if (aFunction.IsNull())
821 //Check if the function is set correctly
822 if (aFunction->GetDriverGUID() != GEOMImpl_HealingDriver::GetID()) return NULL;
824 // prepare "data container" class IHealing
825 GEOMImpl_IHealing HI(aFunction);
826 HI.SetOriginal( aLastFunction );
828 //Compute the translation
830 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
833 if (!GetSolver()->ComputeFunction(aFunction)) {
834 SetErrorCode("Healing driver failed");
838 catch (Standard_Failure) {
839 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
840 SetErrorCode(aFail->GetMessageString());
844 //Make a Python command
845 GEOM::TPythonDump(aFunction) << "geompy.ChangeOrientationShell("
853 //=============================================================================
855 * ChangeOrientationCopy
857 //=============================================================================
858 Handle(GEOM_Object) GEOMImpl_IHealingOperations::ChangeOrientationCopy (Handle(GEOM_Object) theObject)
860 // set error code, check parameters
863 if (theObject.IsNull())
866 Handle(GEOM_Function) aFunction, aLastFunction = theObject->GetLastFunction();
867 if (aLastFunction.IsNull())
868 return NULL; //There is no function which creates an object to be processed
871 Handle(GEOM_Object) aNewObject = GetEngine()->AddObject( GetDocID(), GEOM_COPY );
874 aFunction = aNewObject->AddFunction(GEOMImpl_HealingDriver::GetID(), CHANGE_ORIENTATION);
876 if (aFunction.IsNull())
879 //Check if the function is set correctly
880 if (aFunction->GetDriverGUID() != GEOMImpl_HealingDriver::GetID()) return NULL;
882 // prepare "data container" class IHealing
883 GEOMImpl_IHealing HI(aFunction);
884 HI.SetOriginal( aLastFunction );
886 //Compute the translation
888 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
891 if (!GetSolver()->ComputeFunction(aFunction)) {
892 SetErrorCode("Healing driver failed");
896 catch (Standard_Failure) {
897 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
898 SetErrorCode(aFail->GetMessageString());
902 //Make a Python command
903 GEOM::TPythonDump(aFunction) << aNewObject << " = geompy.ChangeOrientationShellCopy("