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
23 #pragma warning( disable:4786 )
26 #include <Standard_Version.hxx>
27 #include <Standard_Stream.hxx>
29 #include <GEOMImpl_IHealingOperations.hxx>
31 #include <GEOM_PythonDump.hxx>
33 #include <GEOMImpl_HealingDriver.hxx>
34 #include <GEOMImpl_Types.hxx>
35 #include <GEOMImpl_IHealing.hxx>
36 #include <GEOMImpl_CopyDriver.hxx>
38 #include <ShHealOper_ShapeProcess.hxx>
40 #include "utilities.h"
42 #include <Utils_ExceptHandlers.hxx>
44 #include <ShapeAnalysis_FreeBounds.hxx>
46 #include <TopoDS_Compound.hxx>
47 #include <TopExp_Explorer.hxx>
49 #include <TColStd_HArray1OfExtendedString.hxx>
50 #include <TColStd_HSequenceOfTransient.hxx>
51 #include <TCollection_AsciiString.hxx>
53 #include <TDF_Tool.hxx>
55 #include <Standard_Failure.hxx>
56 #include <Standard_ErrorHandler.hxx> // CAREFUL ! position of this file is critic : see Lucien PIGNOLONI / OCC
58 #ifdef OCC_VERSION_SERVICEPACK
59 #define OCC_VERSION_LARGE (OCC_VERSION_MAJOR << 24 | OCC_VERSION_MINOR << 16 | OCC_VERSION_MAINTENANCE << 8 | OCC_VERSION_SERVICEPACK)
61 #define OCC_VERSION_LARGE (OCC_VERSION_MAJOR << 24 | OCC_VERSION_MINOR << 16 | OCC_VERSION_MAINTENANCE << 8)
65 //=============================================================================
69 //=============================================================================
71 GEOMImpl_IHealingOperations::GEOMImpl_IHealingOperations (GEOM_Engine* theEngine, int theDocID)
72 : GEOM_IOperations(theEngine, theDocID)
74 MESSAGE("GEOMImpl_IHealingOperations::GEOMImpl_IHealingOperations");
77 //=============================================================================
81 //=============================================================================
83 GEOMImpl_IHealingOperations::~GEOMImpl_IHealingOperations()
85 MESSAGE("GEOMImpl_IHealingOperations::~GEOMImpl_IHealingOperations");
89 //=============================================================================
93 //=============================================================================
94 Handle(GEOM_Object) GEOMImpl_IHealingOperations::ShapeProcess (Handle(GEOM_Object) theObject,
95 const Handle(TColStd_HArray1OfExtendedString)& theOperators,
96 const Handle(TColStd_HArray1OfExtendedString)& theParams,
97 const Handle(TColStd_HArray1OfExtendedString)& theValues)
99 // set error code, check parameters
102 if (theObject.IsNull())
105 if (theOperators.IsNull() || theOperators->Length() <= 0) {
106 SetErrorCode("No operators requested");
110 Standard_Integer nbParams = 0, nbValues = 0;
111 if (!theParams.IsNull()) {
112 nbParams = theParams->Length();
114 if (!theValues.IsNull()) {
115 nbValues = theValues->Length();
118 if (nbParams != nbValues) {
119 SetErrorCode("Number of parameter values must be equal to the number of parameters");
123 Handle(GEOM_Function) aFunction, aLastFunction = theObject->GetLastFunction();
124 if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be processed
127 Handle(GEOM_Object) aNewObject = GetEngine()->AddObject( GetDocID(), GEOM_COPY );
130 aFunction = aNewObject->AddFunction(GEOMImpl_HealingDriver::GetID(), SHAPE_PROCESS);
132 if (aFunction.IsNull()) return NULL;
134 //Check if the function is set correctly
135 if (aFunction->GetDriverGUID() != GEOMImpl_HealingDriver::GetID()) return NULL;
137 // prepare "data container" class IHealing
138 GEOMImpl_IHealing HI(aFunction);
139 HI.SetOriginal(aLastFunction);
140 HI.SetOperators( theOperators );
142 HI.SetParameters( theParams );
143 HI.SetValues( theValues );
146 //Compute the translation
148 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
151 if (!GetSolver()->ComputeFunction(aFunction))
153 SetErrorCode("Shape Healing algorithm failed");
157 catch (Standard_Failure)
159 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
160 SetErrorCode(aFail->GetMessageString());
164 //Make a Python command
165 GEOM::TPythonDump pd (aFunction);
166 pd << aNewObject << " = geompy.ProcessShape(" << theObject << ", [";
169 int i = theOperators->Lower(), nb = theOperators->Upper();
170 for ( ; i <= nb; i++) {
171 pd << "\"" << TCollection_AsciiString(theOperators->Value( i )).ToCString()
172 << (( i < nb ) ? "\", " : "\"");
175 // list of parameters
176 i = theParams->Lower(); nb = theParams->Upper();
177 for ( ; i <= nb; i++) {
178 pd << "\"" << TCollection_AsciiString(theParams->Value( i )).ToCString()
179 << (( i < nb ) ? "\", " : "\"");
183 i = theValues->Lower(); nb = theValues->Upper();
184 for ( ; i <= nb; i++) {
185 pd << "\"" << TCollection_AsciiString(theValues->Value( i )).ToCString()
186 << (( i < nb ) ? "\", " : "\"");
194 //=============================================================================
198 //=============================================================================
199 void GEOMImpl_IHealingOperations::GetShapeProcessParameters (std::list<std::string>& theOperations,
200 std::list<std::string>& theParams,
201 std::list<std::string>& theValues)
203 ShHealOper_ShapeProcess aHealer;
204 TColStd_SequenceOfAsciiString anOperators;
205 int nbOperatorErrors( 0 );
206 if ( aHealer.GetOperators( anOperators ) )
208 for ( Standard_Integer i = 1; i <= anOperators.Length(); i++ )
210 std::string anOperation = anOperators.Value( i ).ToCString();
211 if ( GetOperatorParameters( anOperation, theParams, theValues ) )
212 theOperations.push_back( anOperation );
219 SetErrorCode("ERROR retrieving operators (GEOMImpl_IHealingOperations)");
222 if ( nbOperatorErrors ) {
223 TCollection_AsciiString aMsg ("ERRORS retrieving ShapeProcess parameters (GEOMImpl_IHealingOperations): nbOperatorErrors = ");
224 aMsg += TCollection_AsciiString( nbOperatorErrors );
225 MESSAGE(aMsg.ToCString());
229 //=============================================================================
231 * GetOperatorParameters
233 //=============================================================================
234 bool GEOMImpl_IHealingOperations::GetOperatorParameters( const std::string theOperation,
235 std::list<std::string>& theParams,
236 std::list<std::string>& theValues )
238 ShHealOper_ShapeProcess aHealer;
239 int nbParamValueErrors( 0 );
240 std::list<std::string> aParams;
241 if ( GetParameters( theOperation, aParams ) ) {
242 for ( std::list<std::string>::iterator it = aParams.begin(); it != aParams.end(); ++it ) {
243 TCollection_AsciiString aParam( (Standard_CString)(*it).c_str() );
244 TCollection_AsciiString aValue;
245 if ( aHealer.GetParameter( aParam, aValue ) ) {
246 theParams.push_back( aParam.ToCString() );
247 theValues.push_back( aValue.ToCString() );
250 nbParamValueErrors++;
256 if ( nbParamValueErrors ) {
257 TCollection_AsciiString aMsg ("ERRORS retrieving ShapeProcess parameter values (GEOMImpl_IHealingOperations): nbParamValueErrors = ");
258 aMsg += TCollection_AsciiString( nbParamValueErrors );
259 MESSAGE(aMsg.ToCString());
265 //=============================================================================
269 //=============================================================================
270 bool GEOMImpl_IHealingOperations::GetParameters (const std::string theOperation,
271 std::list<std::string>& theParams)
273 if ( theOperation == "SplitAngle" ) {
274 theParams.push_back( "SplitAngle.Angle" );
275 theParams.push_back( "SplitAngle.MaxTolerance" );
277 } else if ( theOperation == "SplitClosedFaces" ) {
278 theParams.push_back( "SplitClosedFaces.NbSplitPoints" );
280 } else if ( theOperation == "FixFaceSize" ) {
281 theParams.push_back( "FixFaceSize.Tolerance" );
283 } else if( theOperation == "DropSmallEdges" ) {
284 theParams.push_back( "DropSmallEdges.Tolerance3d" );
286 } else if( theOperation == "BSplineRestriction" ) {
287 theParams.push_back( "BSplineRestriction.SurfaceMode" );
288 theParams.push_back( "BSplineRestriction.Curve3dMode" );
289 theParams.push_back( "BSplineRestriction.Curve2dMode" );
290 theParams.push_back( "BSplineRestriction.Tolerance3d" );
291 theParams.push_back( "BSplineRestriction.Tolerance2d" );
292 theParams.push_back( "BSplineRestriction.RequiredDegree" );
293 theParams.push_back( "BSplineRestriction.RequiredNbSegments" );
294 theParams.push_back( "BSplineRestriction.Continuity3d" );
295 theParams.push_back( "BSplineRestriction.Continuity2d" );
297 } else if( theOperation == "SplitContinuity" ) {
298 theParams.push_back( "SplitContinuity.Tolerance3d" );
299 theParams.push_back( "SplitContinuity.SurfaceContinuity" );
300 theParams.push_back( "SplitContinuity.CurveContinuity" );
302 } else if( theOperation == "ToBezier" ) {
303 theParams.push_back( "ToBezier.SurfaceMode" );
304 theParams.push_back( "ToBezier.Curve3dMode" );
305 theParams.push_back( "ToBezier.Curve2dMode" );
306 theParams.push_back( "ToBezier.MaxTolerance" );
308 } else if( theOperation == "SameParameter" ) {
309 theParams.push_back( "SameParameter.Tolerance3d" );
311 } else if( theOperation == "FixShape" ) {
312 theParams.push_back( "FixShape.Tolerance3d" );
313 theParams.push_back( "FixShape.MaxTolerance3d" );
322 //=============================================================================
326 //=============================================================================
327 Handle(GEOM_Object) GEOMImpl_IHealingOperations::SuppressFaces
328 (Handle(GEOM_Object) theObject, const Handle(TColStd_HArray1OfInteger)& theFaces)
330 // set error code, check parameters
333 if (theObject.IsNull()) // if theFaces.IsNull() - it's OK, it means that ALL faces must be removed..
336 Handle(GEOM_Function) aFunction, aLastFunction = theObject->GetLastFunction();
337 if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be processed
340 Handle(GEOM_Object) aNewObject = GetEngine()->AddObject(GetDocID(), GEOM_COPY);
343 aFunction = aNewObject->AddFunction(GEOMImpl_HealingDriver::GetID(), SUPPRESS_FACES);
345 if (aFunction.IsNull()) return NULL;
347 //Check if the function is set correctly
348 if (aFunction->GetDriverGUID() != GEOMImpl_HealingDriver::GetID()) return NULL;
350 // prepare "data container" class IHealing
351 GEOMImpl_IHealing HI (aFunction);
352 HI.SetFaces(theFaces);
353 HI.SetOriginal(aLastFunction);
355 //Compute the translation
357 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
360 if (!GetSolver()->ComputeFunction(aFunction))
362 SetErrorCode("Healing driver failed");
366 catch (Standard_Failure)
368 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
369 SetErrorCode(aFail->GetMessageString());
373 //Make a Python command
374 GEOM::TPythonDump pd (aFunction);
375 pd << aNewObject << " = geompy.SuppressFaces(" << theObject << ", [";
378 int i = theFaces->Lower(), nb = theFaces->Upper();
379 for ( ; i <= nb; i++)
380 pd << theFaces->Value( i ) << (( i < nb ) ? ", " : "])");
386 //=============================================================================
390 //=============================================================================
391 Handle(GEOM_Object) GEOMImpl_IHealingOperations::CloseContour
392 (Handle(GEOM_Object) theObject,
393 const Handle(TColStd_HArray1OfInteger)& theWires,
396 // set error code, check parameters
399 if (theObject.IsNull())
401 SetErrorCode("NULL object given");
405 Handle(GEOM_Function) aFunction, aLastFunction = theObject->GetLastFunction();
406 if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be processed
409 Handle(GEOM_Object) aNewObject = GetEngine()->AddObject( GetDocID(), GEOM_COPY );
412 aFunction = aNewObject->AddFunction(GEOMImpl_HealingDriver::GetID(), CLOSE_CONTOUR);
414 if (aFunction.IsNull()) return NULL;
416 //Check if the function is set correctly
417 if(aFunction->GetDriverGUID() != GEOMImpl_HealingDriver::GetID()) return NULL;
419 // prepare "data container" class IHealing
420 GEOMImpl_IHealing HI(aFunction);
421 HI.SetWires( theWires );
422 HI.SetIsCommonVertex( isCommonVertex );
423 HI.SetOriginal( aLastFunction );
425 //Compute the translation
427 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
430 if (!GetSolver()->ComputeFunction(aFunction))
432 SetErrorCode("Healing driver failed");
436 catch (Standard_Failure)
438 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
439 SetErrorCode(aFail->GetMessageString());
443 //Make a Python command
444 GEOM::TPythonDump pd (aFunction);
445 pd << aNewObject << " = geompy.CloseContour(" << theObject << ", [";
448 if (!theWires.IsNull())
450 int i = theWires->Lower(), nb = theWires->Upper();
451 pd << theWires->Value(i++);
453 pd << ", " << theWires->Value(i++);
455 pd << "], " << (int)isCommonVertex << ")";
461 //=============================================================================
465 //=============================================================================
466 Handle(GEOM_Object) GEOMImpl_IHealingOperations::RemoveIntWires
467 (Handle(GEOM_Object) theObject, const Handle(TColStd_HArray1OfInteger)& theWires)
469 // set error code, check parameters
472 if (theObject.IsNull()) // if theWires is NULL it's OK, it means that ALL wires must be removed
475 Handle(GEOM_Function) aFunction, aLastFunction = theObject->GetLastFunction();
476 if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be processed
479 Handle(GEOM_Object) aNewObject = GetEngine()->AddObject( GetDocID(), GEOM_COPY );
482 aFunction = aNewObject->AddFunction(GEOMImpl_HealingDriver::GetID(), REMOVE_INT_WIRES);
484 if (aFunction.IsNull()) return NULL;
486 //Check if the function is set correctly
487 if (aFunction->GetDriverGUID() != GEOMImpl_HealingDriver::GetID()) return NULL;
489 // prepare "data container" class IHealing
490 GEOMImpl_IHealing HI(aFunction);
491 HI.SetWires( theWires );
492 HI.SetOriginal( aLastFunction );
494 //Compute the translation
496 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
499 if (!GetSolver()->ComputeFunction(aFunction))
501 SetErrorCode("Healing driver failed");
505 catch (Standard_Failure)
507 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
508 SetErrorCode(aFail->GetMessageString());
512 //Make a Python command
513 GEOM::TPythonDump pd (aFunction);
514 pd << aNewObject << " = geompy.SuppressInternalWires(" << theObject << ", [";
517 if (!theWires.IsNull()) {
518 int i = theWires->Lower(), nb = theWires->Upper();
519 for ( ; i <= nb; i++)
520 pd << theWires->Value( i ) << (( i < nb ) ? ", " : "])");
529 //=============================================================================
533 //=============================================================================
534 Handle(GEOM_Object) GEOMImpl_IHealingOperations::FillHoles (Handle(GEOM_Object) theObject,
535 const Handle(TColStd_HArray1OfInteger)& theWires)
537 // set error code, check parameters
540 if (theObject.IsNull()) // if theWires is NULL it's OK, it means that ALL holes must be removed
543 Handle(GEOM_Function) aFunction, aLastFunction = theObject->GetLastFunction();
544 if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be processed
547 Handle(GEOM_Object) aNewObject = GetEngine()->AddObject( GetDocID(), GEOM_COPY );
550 aFunction = aNewObject->AddFunction(GEOMImpl_HealingDriver::GetID(), FILL_HOLES);
552 if (aFunction.IsNull()) return NULL;
554 //Check if the function is set correctly
555 if (aFunction->GetDriverGUID() != GEOMImpl_HealingDriver::GetID()) return NULL;
557 // prepare "data container" class IHealing
558 GEOMImpl_IHealing HI(aFunction);
559 HI.SetWires( theWires );
560 HI.SetOriginal( aLastFunction );
562 //Compute the translation
564 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
567 if (!GetSolver()->ComputeFunction(aFunction))
569 SetErrorCode("Healing driver failed");
573 catch (Standard_Failure)
575 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
576 SetErrorCode(aFail->GetMessageString());
580 //Make a Python command
581 GEOM::TPythonDump pd (aFunction);
582 pd << aNewObject << " = geompy.SuppressHoles(" << theObject << ", [";
585 if ( theWires.IsNull() )
588 int i = theWires->Lower(), nb = theWires->Upper();
589 for ( ; i <= nb; i++)
590 pd << theWires->Value( i ) << (( i < nb ) ? ", " : "])");
597 //=============================================================================
601 //=============================================================================
602 Handle(GEOM_Object) GEOMImpl_IHealingOperations::Sew (Handle(GEOM_Object) theObject,
605 // set error code, check parameters
608 if (theObject.IsNull())
611 Handle(GEOM_Function) aFunction, aLastFunction = theObject->GetLastFunction();
612 if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be processed
615 Handle(GEOM_Object) aNewObject = GetEngine()->AddObject( GetDocID(), GEOM_COPY );
618 aFunction = aNewObject->AddFunction(GEOMImpl_HealingDriver::GetID(), SEWING);
620 if (aFunction.IsNull()) return NULL;
622 //Check if the function is set correctly
623 if (aFunction->GetDriverGUID() != GEOMImpl_HealingDriver::GetID()) return NULL;
625 // prepare "data container" class IHealing
626 GEOMImpl_IHealing HI(aFunction);
627 HI.SetTolerance( theTolerance );
628 HI.SetOriginal( aLastFunction );
630 //Compute the translation
632 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
635 if (!GetSolver()->ComputeFunction(aFunction))
637 SetErrorCode("Healing driver failed");
641 catch (Standard_Failure)
643 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
644 SetErrorCode(aFail->GetMessageString());
648 //Make a Python command
649 GEOM::TPythonDump(aFunction) << aNewObject << " = geompy.Sew("
650 << theObject << ", " << theTolerance << ")";
656 //=============================================================================
660 //=============================================================================
661 Handle(GEOM_Object) GEOMImpl_IHealingOperations::DivideEdge (Handle(GEOM_Object) theObject,
666 // set error code, check parameters
669 if (theObject.IsNull())
672 Handle(GEOM_Function) aFunction, aLastFunction = theObject->GetLastFunction();
673 if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be processed
676 Handle(GEOM_Object) aNewObject = GetEngine()->AddObject( GetDocID(), GEOM_COPY );
679 aFunction = aNewObject->AddFunction(GEOMImpl_HealingDriver::GetID(), DIVIDE_EDGE);
681 if (aFunction.IsNull()) return NULL;
683 //Check if the function is set correctly
684 if (aFunction->GetDriverGUID() != GEOMImpl_HealingDriver::GetID()) return NULL;
686 // prepare "data container" class IHealing
687 GEOMImpl_IHealing HI(aFunction);
688 HI.SetIndex( theIndex );
689 HI.SetDevideEdgeValue( theValue );
690 HI.SetIsByParameter( isByParameter );
691 HI.SetOriginal( aLastFunction );
693 //Compute the translation
695 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
698 if (!GetSolver()->ComputeFunction(aFunction))
700 SetErrorCode("Healing driver failed");
704 catch (Standard_Failure)
706 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
707 SetErrorCode(aFail->GetMessageString());
711 //Make a Python command
712 GEOM::TPythonDump(aFunction) << aNewObject << " = geompy.DivideEdge(" << theObject
713 << ", " << theIndex << ", " << theValue << ", " << (int)isByParameter << ")";
719 //=============================================================================
723 //=============================================================================
724 bool GEOMImpl_IHealingOperations::GetFreeBoundary (Handle(GEOM_Object) theObject,
725 Handle(TColStd_HSequenceOfTransient)& theClosed,
726 Handle(TColStd_HSequenceOfTransient)& theOpen )
728 // set error code, check parameters
731 if ( theObject.IsNull() || theClosed.IsNull() || theOpen.IsNull() )
734 TopoDS_Shape aShape = theObject->GetValue();
735 if ( aShape.IsNull() )
738 // get free boundary shapes
740 #if OCC_VERSION_LARGE > 0x06030008
741 ShapeAnalysis_FreeBounds anAnalizer(aShape, Standard_False,
742 Standard_True, Standard_True);
744 ShapeAnalysis_FreeBounds anAnalizer(aShape);
746 TopoDS_Compound aClosed = anAnalizer.GetClosedWires();
747 TopoDS_Compound anOpen = anAnalizer.GetOpenWires();
749 // iterate through shapes and append them to the return sequence
750 Handle(GEOM_Object) anObj;
751 Handle(GEOM_Function) aFunction;
752 TopExp_Explorer anExp;
753 for ( anExp.Init( aClosed, TopAbs_WIRE ); anExp.More(); anExp.Next() )
755 anObj = GetEngine()->AddObject( GetDocID(), GEOM_FREE_BOUNDS );
756 aFunction = anObj->AddFunction( GEOMImpl_CopyDriver::GetID(), COPY_WITHOUT_REF );
757 TopoDS_Shape aValueShape = anExp.Current();
758 aFunction->SetValue( aValueShape );
759 theClosed->Append(anObj);
761 for ( anExp.Init( anOpen, TopAbs_WIRE ); anExp.More(); anExp.Next() )
763 anObj = GetEngine()->AddObject( GetDocID(), GEOM_FREE_BOUNDS );
764 aFunction = anObj->AddFunction( GEOMImpl_CopyDriver::GetID(), COPY_WITHOUT_REF );
765 TopoDS_Shape aValueShape = anExp.Current();
766 aFunction->SetValue( aValueShape );
767 theOpen->Append(anObj);
770 if(!aFunction.IsNull()) {
772 //Make a Python command
773 GEOM::TPythonDump pd (aFunction);
775 Standard_Integer i, aLen = theClosed->Length();
778 for (i = 1; i <= aLen; i++) {
779 Handle(GEOM_Object) anObj_i = Handle(GEOM_Object)::DownCast(theClosed->Value(i));
780 pd << anObj_i << ((i < aLen) ? ", " : "");
784 pd << "(isDone, empty_list, ";
787 aLen = theOpen->Length();
790 for (i = 1; i <= aLen; i++) {
791 Handle(GEOM_Object) anObj_i = Handle(GEOM_Object)::DownCast(theOpen->Value(i));
792 pd << anObj_i << ((i < aLen) ? ", " : "");
799 pd << ") = geompy.GetFreeBoundary(" << theObject << ")";
807 //=============================================================================
811 //=============================================================================
812 Handle(GEOM_Object) GEOMImpl_IHealingOperations::ChangeOrientation (Handle(GEOM_Object) theObject)
814 // set error code, check parameters
817 if (theObject.IsNull())
820 if (!theObject->IsMainShape()) {
821 SetErrorCode("Sub shape cannot be transformed - need to create a copy");
825 Handle(GEOM_Function) aFunction, aLastFunction = theObject->GetLastFunction();
826 if (aLastFunction.IsNull())
827 return NULL; //There is no function which creates an object to be processed
830 aFunction = theObject->AddFunction(GEOMImpl_HealingDriver::GetID(), CHANGE_ORIENTATION);
832 if (aFunction.IsNull())
835 //Check if the function is set correctly
836 if (aFunction->GetDriverGUID() != GEOMImpl_HealingDriver::GetID()) return NULL;
838 // prepare "data container" class IHealing
839 GEOMImpl_IHealing HI(aFunction);
840 HI.SetOriginal( aLastFunction );
842 //Compute the translation
844 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
847 if (!GetSolver()->ComputeFunction(aFunction)) {
848 SetErrorCode("Healing driver failed");
852 catch (Standard_Failure) {
853 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
854 SetErrorCode(aFail->GetMessageString());
858 //Make a Python command
859 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("
923 //=============================================================================
927 //=============================================================================
928 Handle(GEOM_Object) GEOMImpl_IHealingOperations::LimitTolerance (Handle(GEOM_Object) theObject,
931 // Set error code, check parameters
934 if (theObject.IsNull())
937 Handle(GEOM_Function) aFunction, aLastFunction = theObject->GetLastFunction();
938 if (aLastFunction.IsNull())
939 return NULL; // There is no function which creates an object to be processed
942 Handle(GEOM_Object) aNewObject = GetEngine()->AddObject(GetDocID(), theObject->GetType());
945 aFunction = aNewObject->AddFunction(GEOMImpl_HealingDriver::GetID(), LIMIT_TOLERANCE);
947 if (aFunction.IsNull())
950 // Check if the function is set correctly
951 if (aFunction->GetDriverGUID() != GEOMImpl_HealingDriver::GetID()) return NULL;
953 // Prepare "data container" class IHealing
954 GEOMImpl_IHealing HI (aFunction);
955 HI.SetOriginal(aLastFunction);
956 HI.SetTolerance(theTolerance);
960 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
963 if (!GetSolver()->ComputeFunction(aFunction)) {
964 SetErrorCode("Healing driver failed");
968 catch (Standard_Failure) {
969 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
970 SetErrorCode(aFail->GetMessageString());
974 // Make a Python command
975 GEOM::TPythonDump(aFunction) << aNewObject << " = geompy.LimitTolerance("
976 << theObject << ", " << theTolerance << ")";