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
58 //=============================================================================
62 //=============================================================================
64 GEOMImpl_IHealingOperations::GEOMImpl_IHealingOperations (GEOM_Engine* theEngine, int theDocID)
65 : GEOM_IOperations(theEngine, theDocID)
67 MESSAGE("GEOMImpl_IHealingOperations::GEOMImpl_IHealingOperations");
70 //=============================================================================
74 //=============================================================================
76 GEOMImpl_IHealingOperations::~GEOMImpl_IHealingOperations()
78 MESSAGE("GEOMImpl_IHealingOperations::~GEOMImpl_IHealingOperations");
82 //=============================================================================
86 //=============================================================================
87 Handle(GEOM_Object) GEOMImpl_IHealingOperations::ShapeProcess (Handle(GEOM_Object) theObject,
88 const Handle(TColStd_HArray1OfExtendedString)& theOperators,
89 const Handle(TColStd_HArray1OfExtendedString)& theParams,
90 const Handle(TColStd_HArray1OfExtendedString)& theValues)
92 // set error code, check parameters
95 if (theObject.IsNull())
98 if (theOperators.IsNull() || theOperators->Length() <= 0) {
99 SetErrorCode("No operators requested");
103 Standard_Integer nbParams = 0, nbValues = 0;
104 if (!theParams.IsNull()) {
105 nbParams = theParams->Length();
107 if (!theValues.IsNull()) {
108 nbValues = theValues->Length();
111 if (nbParams != nbValues) {
112 SetErrorCode("Number of parameter values must be equal to the number of parameters");
116 Handle(GEOM_Function) aFunction, aLastFunction = theObject->GetLastFunction();
117 if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be processed
120 Handle(GEOM_Object) aNewObject = GetEngine()->AddObject( GetDocID(), GEOM_COPY );
123 aFunction = aNewObject->AddFunction(GEOMImpl_HealingDriver::GetID(), SHAPE_PROCESS);
125 if (aFunction.IsNull()) return NULL;
127 //Check if the function is set correctly
128 if (aFunction->GetDriverGUID() != GEOMImpl_HealingDriver::GetID()) return NULL;
130 // prepare "data container" class IHealing
131 GEOMImpl_IHealing HI(aFunction);
132 HI.SetOriginal(aLastFunction);
133 HI.SetOperators( theOperators );
135 HI.SetParameters( theParams );
136 HI.SetValues( theValues );
139 //Compute the translation
141 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
144 if (!GetSolver()->ComputeFunction(aFunction))
146 SetErrorCode("Shape Healing algorithm failed");
150 catch (Standard_Failure)
152 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
153 SetErrorCode(aFail->GetMessageString());
157 //Make a Python command
158 GEOM::TPythonDump pd (aFunction);
159 pd << aNewObject << " = geompy.ProcessShape(" << theObject << ", [";
162 int i = theOperators->Lower(), nb = theOperators->Upper();
163 for ( ; i <= nb; i++) {
164 pd << "\"" << TCollection_AsciiString(theOperators->Value( i )).ToCString()
165 << (( i < nb ) ? "\", " : "\"");
168 // list of parameters
169 i = theParams->Lower(); nb = theParams->Upper();
170 for ( ; i <= nb; i++) {
171 pd << "\"" << TCollection_AsciiString(theParams->Value( i )).ToCString()
172 << (( i < nb ) ? "\", " : "\"");
176 i = theValues->Lower(); nb = theValues->Upper();
177 for ( ; i <= nb; i++) {
178 pd << "\"" << TCollection_AsciiString(theValues->Value( i )).ToCString()
179 << (( i < nb ) ? "\", " : "\"");
187 //=============================================================================
191 //=============================================================================
192 void GEOMImpl_IHealingOperations::GetShapeProcessParameters (std::list<std::string>& theOperations,
193 std::list<std::string>& theParams,
194 std::list<std::string>& theValues)
196 ShHealOper_ShapeProcess aHealer;
197 TColStd_SequenceOfAsciiString anOperators;
198 int nbOperatorErrors( 0 );
199 if ( aHealer.GetOperators( anOperators ) )
201 for ( Standard_Integer i = 1; i <= anOperators.Length(); i++ )
203 std::string anOperation = anOperators.Value( i ).ToCString();
204 if ( GetOperatorParameters( anOperation, theParams, theValues ) )
205 theOperations.push_back( anOperation );
212 SetErrorCode("ERROR retrieving operators (GEOMImpl_IHealingOperations)");
215 if ( nbOperatorErrors ) {
216 TCollection_AsciiString aMsg ("ERRORS retrieving ShapeProcess parameters (GEOMImpl_IHealingOperations): nbOperatorErrors = ");
217 aMsg += TCollection_AsciiString( nbOperatorErrors );
218 MESSAGE(aMsg.ToCString());
222 //=============================================================================
224 * GetOperatorParameters
226 //=============================================================================
227 bool GEOMImpl_IHealingOperations::GetOperatorParameters( const std::string theOperation,
228 std::list<std::string>& theParams,
229 std::list<std::string>& theValues )
231 ShHealOper_ShapeProcess aHealer;
232 int nbParamValueErrors( 0 );
233 std::list<std::string> aParams;
234 if ( GetParameters( theOperation, aParams ) ) {
235 for ( std::list<std::string>::iterator it = aParams.begin(); it != aParams.end(); ++it ) {
236 TCollection_AsciiString aParam( (Standard_CString)(*it).c_str() );
237 TCollection_AsciiString aValue;
238 if ( aHealer.GetParameter( aParam, aValue ) ) {
239 theParams.push_back( aParam.ToCString() );
240 theValues.push_back( aValue.ToCString() );
243 nbParamValueErrors++;
249 if ( nbParamValueErrors ) {
250 TCollection_AsciiString aMsg ("ERRORS retrieving ShapeProcess parameter values (GEOMImpl_IHealingOperations): nbParamValueErrors = ");
251 aMsg += TCollection_AsciiString( nbParamValueErrors );
252 MESSAGE(aMsg.ToCString());
258 //=============================================================================
262 //=============================================================================
263 bool GEOMImpl_IHealingOperations::GetParameters (const std::string theOperation,
264 std::list<std::string>& theParams)
266 if ( theOperation == "SplitAngle" ) {
267 theParams.push_back( "SplitAngle.Angle" );
268 theParams.push_back( "SplitAngle.MaxTolerance" );
270 } else if ( theOperation == "SplitClosedFaces" ) {
271 theParams.push_back( "SplitClosedFaces.NbSplitPoints" );
273 } else if ( theOperation == "FixFaceSize" ) {
274 theParams.push_back( "FixFaceSize.Tolerance" );
276 } else if( theOperation == "DropSmallEdges" ) {
277 theParams.push_back( "DropSmallEdges.Tolerance3d" );
279 } else if( theOperation == "BSplineRestriction" ) {
280 theParams.push_back( "BSplineRestriction.SurfaceMode" );
281 theParams.push_back( "BSplineRestriction.Curve3dMode" );
282 theParams.push_back( "BSplineRestriction.Curve2dMode" );
283 theParams.push_back( "BSplineRestriction.Tolerance3d" );
284 theParams.push_back( "BSplineRestriction.Tolerance2d" );
285 theParams.push_back( "BSplineRestriction.RequiredDegree" );
286 theParams.push_back( "BSplineRestriction.RequiredNbSegments" );
287 theParams.push_back( "BSplineRestriction.Continuity3d" );
288 theParams.push_back( "BSplineRestriction.Continuity2d" );
290 } else if( theOperation == "SplitContinuity" ) {
291 theParams.push_back( "SplitContinuity.Tolerance3d" );
292 theParams.push_back( "SplitContinuity.SurfaceContinuity" );
293 theParams.push_back( "SplitContinuity.CurveContinuity" );
295 } else if( theOperation == "ToBezier" ) {
296 theParams.push_back( "ToBezier.SurfaceMode" );
297 theParams.push_back( "ToBezier.Curve3dMode" );
298 theParams.push_back( "ToBezier.Curve2dMode" );
299 theParams.push_back( "ToBezier.MaxTolerance" );
301 } else if( theOperation == "SameParameter" ) {
302 theParams.push_back( "SameParameter.Tolerance3d" );
304 } else if( theOperation == "FixShape" ) {
305 theParams.push_back( "FixShape.Tolerance3d" );
306 theParams.push_back( "FixShape.MaxTolerance3d" );
315 //=============================================================================
319 //=============================================================================
320 Handle(GEOM_Object) GEOMImpl_IHealingOperations::SuppressFaces
321 (Handle(GEOM_Object) theObject, const Handle(TColStd_HArray1OfInteger)& theFaces)
323 // set error code, check parameters
326 if (theObject.IsNull()) // if theFaces.IsNull() - it's OK, it means that ALL faces must be removed..
329 Handle(GEOM_Function) aFunction, aLastFunction = theObject->GetLastFunction();
330 if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be processed
333 Handle(GEOM_Object) aNewObject = GetEngine()->AddObject(GetDocID(), GEOM_COPY);
336 aFunction = aNewObject->AddFunction(GEOMImpl_HealingDriver::GetID(), SUPPRESS_FACES);
338 if (aFunction.IsNull()) return NULL;
340 //Check if the function is set correctly
341 if (aFunction->GetDriverGUID() != GEOMImpl_HealingDriver::GetID()) return NULL;
343 // prepare "data container" class IHealing
344 GEOMImpl_IHealing HI (aFunction);
345 HI.SetFaces(theFaces);
346 HI.SetOriginal(aLastFunction);
348 //Compute the translation
350 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
353 if (!GetSolver()->ComputeFunction(aFunction))
355 SetErrorCode("Healing driver failed");
359 catch (Standard_Failure)
361 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
362 SetErrorCode(aFail->GetMessageString());
366 //Make a Python command
367 GEOM::TPythonDump pd (aFunction);
368 pd << aNewObject << " = geompy.SuppressFaces(" << theObject << ", [";
371 int i = theFaces->Lower(), nb = theFaces->Upper();
372 for ( ; i <= nb; i++)
373 pd << theFaces->Value( i ) << (( i < nb ) ? ", " : "])");
379 //=============================================================================
383 //=============================================================================
384 Handle(GEOM_Object) GEOMImpl_IHealingOperations::CloseContour
385 (Handle(GEOM_Object) theObject,
386 const Handle(TColStd_HArray1OfInteger)& theWires,
389 // set error code, check parameters
392 if (theObject.IsNull())
394 SetErrorCode("NULL object given");
398 Handle(GEOM_Function) aFunction, aLastFunction = theObject->GetLastFunction();
399 if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be processed
402 Handle(GEOM_Object) aNewObject = GetEngine()->AddObject( GetDocID(), GEOM_COPY );
405 aFunction = aNewObject->AddFunction(GEOMImpl_HealingDriver::GetID(), CLOSE_CONTOUR);
407 if (aFunction.IsNull()) return NULL;
409 //Check if the function is set correctly
410 if(aFunction->GetDriverGUID() != GEOMImpl_HealingDriver::GetID()) return NULL;
412 // prepare "data container" class IHealing
413 GEOMImpl_IHealing HI(aFunction);
414 HI.SetWires( theWires );
415 HI.SetIsCommonVertex( isCommonVertex );
416 HI.SetOriginal( aLastFunction );
418 //Compute the translation
420 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
423 if (!GetSolver()->ComputeFunction(aFunction))
425 SetErrorCode("Healing driver failed");
429 catch (Standard_Failure)
431 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
432 SetErrorCode(aFail->GetMessageString());
436 //Make a Python command
437 GEOM::TPythonDump pd (aFunction);
438 pd << aNewObject << " = geompy.CloseContour(" << theObject << ", [";
441 if (!theWires.IsNull())
443 int i = theWires->Lower(), nb = theWires->Upper();
444 pd << theWires->Value(i++);
446 pd << ", " << theWires->Value(i++);
448 pd << "], " << (int)isCommonVertex << ")";
454 //=============================================================================
458 //=============================================================================
459 Handle(GEOM_Object) GEOMImpl_IHealingOperations::RemoveIntWires
460 (Handle(GEOM_Object) theObject, const Handle(TColStd_HArray1OfInteger)& theWires)
462 // set error code, check parameters
465 if (theObject.IsNull()) // if theWires is NULL it's OK, it means that ALL wires must be removed
468 Handle(GEOM_Function) aFunction, aLastFunction = theObject->GetLastFunction();
469 if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be processed
472 Handle(GEOM_Object) aNewObject = GetEngine()->AddObject( GetDocID(), GEOM_COPY );
475 aFunction = aNewObject->AddFunction(GEOMImpl_HealingDriver::GetID(), REMOVE_INT_WIRES);
477 if (aFunction.IsNull()) return NULL;
479 //Check if the function is set correctly
480 if (aFunction->GetDriverGUID() != GEOMImpl_HealingDriver::GetID()) return NULL;
482 // prepare "data container" class IHealing
483 GEOMImpl_IHealing HI(aFunction);
484 HI.SetWires( theWires );
485 HI.SetOriginal( aLastFunction );
487 //Compute the translation
489 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
492 if (!GetSolver()->ComputeFunction(aFunction))
494 SetErrorCode("Healing driver failed");
498 catch (Standard_Failure)
500 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
501 SetErrorCode(aFail->GetMessageString());
505 //Make a Python command
506 GEOM::TPythonDump pd (aFunction);
507 pd << aNewObject << " = geompy.SuppressInternalWires(" << theObject << ", [";
510 if (!theWires.IsNull()) {
511 int i = theWires->Lower(), nb = theWires->Upper();
512 for ( ; i <= nb; i++)
513 pd << theWires->Value( i ) << (( i < nb ) ? ", " : "])");
522 //=============================================================================
526 //=============================================================================
527 Handle(GEOM_Object) GEOMImpl_IHealingOperations::FillHoles (Handle(GEOM_Object) theObject,
528 const Handle(TColStd_HArray1OfInteger)& theWires)
530 // set error code, check parameters
533 if (theObject.IsNull()) // if theWires is NULL it's OK, it means that ALL holes must be removed
536 Handle(GEOM_Function) aFunction, aLastFunction = theObject->GetLastFunction();
537 if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be processed
540 Handle(GEOM_Object) aNewObject = GetEngine()->AddObject( GetDocID(), GEOM_COPY );
543 aFunction = aNewObject->AddFunction(GEOMImpl_HealingDriver::GetID(), FILL_HOLES);
545 if (aFunction.IsNull()) return NULL;
547 //Check if the function is set correctly
548 if (aFunction->GetDriverGUID() != GEOMImpl_HealingDriver::GetID()) return NULL;
550 // prepare "data container" class IHealing
551 GEOMImpl_IHealing HI(aFunction);
552 HI.SetWires( theWires );
553 HI.SetOriginal( aLastFunction );
555 //Compute the translation
557 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
560 if (!GetSolver()->ComputeFunction(aFunction))
562 SetErrorCode("Healing driver failed");
566 catch (Standard_Failure)
568 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
569 SetErrorCode(aFail->GetMessageString());
573 //Make a Python command
574 GEOM::TPythonDump pd (aFunction);
575 pd << aNewObject << " = geompy.SuppressHoles(" << theObject << ", [";
578 if ( theWires.IsNull() )
581 int i = theWires->Lower(), nb = theWires->Upper();
582 for ( ; i <= nb; i++)
583 pd << theWires->Value( i ) << (( i < nb ) ? ", " : "])");
590 //=============================================================================
594 //=============================================================================
595 Handle(GEOM_Object) GEOMImpl_IHealingOperations::Sew (Handle(GEOM_Object) theObject,
598 // set error code, check parameters
601 if (theObject.IsNull())
604 Handle(GEOM_Function) aFunction, aLastFunction = theObject->GetLastFunction();
605 if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be processed
608 Handle(GEOM_Object) aNewObject = GetEngine()->AddObject( GetDocID(), GEOM_COPY );
611 aFunction = aNewObject->AddFunction(GEOMImpl_HealingDriver::GetID(), SEWING);
613 if (aFunction.IsNull()) return NULL;
615 //Check if the function is set correctly
616 if (aFunction->GetDriverGUID() != GEOMImpl_HealingDriver::GetID()) return NULL;
618 // prepare "data container" class IHealing
619 GEOMImpl_IHealing HI(aFunction);
620 HI.SetTolerance( theTolerance );
621 HI.SetOriginal( aLastFunction );
623 //Compute the translation
625 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
628 if (!GetSolver()->ComputeFunction(aFunction))
630 SetErrorCode("Healing driver failed");
634 catch (Standard_Failure)
636 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
637 SetErrorCode(aFail->GetMessageString());
641 //Make a Python command
642 GEOM::TPythonDump(aFunction) << aNewObject << " = geompy.Sew("
643 << theObject << ", " << theTolerance << ")";
649 //=============================================================================
653 //=============================================================================
654 Handle(GEOM_Object) GEOMImpl_IHealingOperations::DivideEdge (Handle(GEOM_Object) theObject,
659 // set error code, check parameters
662 if (theObject.IsNull())
665 Handle(GEOM_Function) aFunction, aLastFunction = theObject->GetLastFunction();
666 if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be processed
669 Handle(GEOM_Object) aNewObject = GetEngine()->AddObject( GetDocID(), GEOM_COPY );
672 aFunction = aNewObject->AddFunction(GEOMImpl_HealingDriver::GetID(), DIVIDE_EDGE);
674 if (aFunction.IsNull()) return NULL;
676 //Check if the function is set correctly
677 if (aFunction->GetDriverGUID() != GEOMImpl_HealingDriver::GetID()) return NULL;
679 // prepare "data container" class IHealing
680 GEOMImpl_IHealing HI(aFunction);
681 HI.SetIndex( theIndex );
682 HI.SetDevideEdgeValue( theValue );
683 HI.SetIsByParameter( isByParameter );
684 HI.SetOriginal( aLastFunction );
686 //Compute the translation
688 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
691 if (!GetSolver()->ComputeFunction(aFunction))
693 SetErrorCode("Healing driver failed");
697 catch (Standard_Failure)
699 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
700 SetErrorCode(aFail->GetMessageString());
704 //Make a Python command
705 GEOM::TPythonDump(aFunction) << aNewObject << " = geompy.DivideEdge(" << theObject
706 << ", " << theIndex << ", " << theValue << ", " << (int)isByParameter << ")";
712 //=============================================================================
716 //=============================================================================
717 bool GEOMImpl_IHealingOperations::GetFreeBoundary (Handle(GEOM_Object) theObject,
718 Handle(TColStd_HSequenceOfTransient)& theClosed,
719 Handle(TColStd_HSequenceOfTransient)& theOpen )
721 // set error code, check parameters
724 if ( theObject.IsNull() || theClosed.IsNull() || theOpen.IsNull() )
727 TopoDS_Shape aShape = theObject->GetValue();
728 if ( aShape.IsNull() )
731 // get free boundary shapes
732 ShapeAnalysis_FreeBounds anAnalizer(aShape, Standard_False,
733 Standard_True, Standard_True);
734 TopoDS_Compound aClosed = anAnalizer.GetClosedWires();
735 TopoDS_Compound anOpen = anAnalizer.GetOpenWires();
737 // iterate through shapes and append them to the return sequence
738 Handle(GEOM_Object) anObj;
739 Handle(GEOM_Function) aFunction;
740 TopExp_Explorer anExp;
741 for ( anExp.Init( aClosed, TopAbs_WIRE ); anExp.More(); anExp.Next() )
743 anObj = GetEngine()->AddObject( GetDocID(), GEOM_FREE_BOUNDS );
744 aFunction = anObj->AddFunction( GEOMImpl_CopyDriver::GetID(), COPY_WITHOUT_REF );
745 TopoDS_Shape aValueShape = anExp.Current();
746 aFunction->SetValue( aValueShape );
747 theClosed->Append(anObj);
749 for ( anExp.Init( anOpen, TopAbs_WIRE ); anExp.More(); anExp.Next() )
751 anObj = GetEngine()->AddObject( GetDocID(), GEOM_FREE_BOUNDS );
752 aFunction = anObj->AddFunction( GEOMImpl_CopyDriver::GetID(), COPY_WITHOUT_REF );
753 TopoDS_Shape aValueShape = anExp.Current();
754 aFunction->SetValue( aValueShape );
755 theOpen->Append(anObj);
758 if(!aFunction.IsNull()) {
760 //Make a Python command
761 GEOM::TPythonDump pd (aFunction);
763 Standard_Integer i, aLen = theClosed->Length();
766 for (i = 1; i <= aLen; i++) {
767 Handle(GEOM_Object) anObj_i = Handle(GEOM_Object)::DownCast(theClosed->Value(i));
768 pd << anObj_i << ((i < aLen) ? ", " : "");
772 pd << "(isDone, empty_list, ";
775 aLen = theOpen->Length();
778 for (i = 1; i <= aLen; i++) {
779 Handle(GEOM_Object) anObj_i = Handle(GEOM_Object)::DownCast(theOpen->Value(i));
780 pd << anObj_i << ((i < aLen) ? ", " : "");
787 pd << ") = geompy.GetFreeBoundary(" << theObject << ")";
795 //=============================================================================
799 //=============================================================================
800 Handle(GEOM_Object) GEOMImpl_IHealingOperations::ChangeOrientation (Handle(GEOM_Object) theObject)
802 // set error code, check parameters
805 if (theObject.IsNull())
808 if (!theObject->IsMainShape()) {
809 SetErrorCode("Sub shape cannot be transformed - need to create a copy");
813 Handle(GEOM_Function) aFunction, aLastFunction = theObject->GetLastFunction();
814 if (aLastFunction.IsNull())
815 return NULL; //There is no function which creates an object to be processed
818 aFunction = theObject->AddFunction(GEOMImpl_HealingDriver::GetID(), CHANGE_ORIENTATION);
820 if (aFunction.IsNull())
823 //Check if the function is set correctly
824 if (aFunction->GetDriverGUID() != GEOMImpl_HealingDriver::GetID()) return NULL;
826 // prepare "data container" class IHealing
827 GEOMImpl_IHealing HI(aFunction);
828 HI.SetOriginal( aLastFunction );
830 //Compute the translation
832 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
835 if (!GetSolver()->ComputeFunction(aFunction)) {
836 SetErrorCode("Healing driver failed");
840 catch (Standard_Failure) {
841 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
842 SetErrorCode(aFail->GetMessageString());
846 //Make a Python command
847 GEOM::TPythonDump(aFunction) << "geompy.ChangeOrientationShell("
855 //=============================================================================
857 * ChangeOrientationCopy
859 //=============================================================================
860 Handle(GEOM_Object) GEOMImpl_IHealingOperations::ChangeOrientationCopy (Handle(GEOM_Object) theObject)
862 // set error code, check parameters
865 if (theObject.IsNull())
868 Handle(GEOM_Function) aFunction, aLastFunction = theObject->GetLastFunction();
869 if (aLastFunction.IsNull())
870 return NULL; //There is no function which creates an object to be processed
873 Handle(GEOM_Object) aNewObject = GetEngine()->AddObject( GetDocID(), theObject->GetType() );
876 aFunction = aNewObject->AddFunction(GEOMImpl_HealingDriver::GetID(), CHANGE_ORIENTATION);
878 if (aFunction.IsNull())
881 //Check if the function is set correctly
882 if (aFunction->GetDriverGUID() != GEOMImpl_HealingDriver::GetID()) return NULL;
884 // prepare "data container" class IHealing
885 GEOMImpl_IHealing HI(aFunction);
886 HI.SetOriginal( aLastFunction );
888 //Compute the translation
890 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
893 if (!GetSolver()->ComputeFunction(aFunction)) {
894 SetErrorCode("Healing driver failed");
898 catch (Standard_Failure) {
899 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
900 SetErrorCode(aFail->GetMessageString());
904 //Make a Python command
905 GEOM::TPythonDump(aFunction) << aNewObject << " = geompy.ChangeOrientationShellCopy("