1 // Copyright (C) 2007-2011 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_IVector.hxx>
37 #include <GEOMImpl_VectorDriver.hxx>
38 #include <GEOMImpl_CopyDriver.hxx>
40 #include <Basics_OCCTVersion.hxx>
42 #include "utilities.h"
44 #include <Utils_ExceptHandlers.hxx>
46 #include <ShHealOper_ShapeProcess.hxx>
48 #include <ShapeAnalysis_FreeBounds.hxx>
50 #include <TopoDS_Compound.hxx>
51 #include <TopExp_Explorer.hxx>
53 #include <TColStd_HArray1OfExtendedString.hxx>
54 #include <TColStd_HSequenceOfTransient.hxx>
55 #include <TCollection_AsciiString.hxx>
57 #include <TDF_Tool.hxx>
59 #include <Standard_Failure.hxx>
60 #include <Standard_ErrorHandler.hxx> // CAREFUL ! position of this file is critic : see Lucien PIGNOLONI / OCC
62 //=============================================================================
66 //=============================================================================
67 GEOMImpl_IHealingOperations::GEOMImpl_IHealingOperations (GEOM_Engine* theEngine, int theDocID)
68 : GEOM_IOperations(theEngine, theDocID)
70 MESSAGE("GEOMImpl_IHealingOperations::GEOMImpl_IHealingOperations");
73 //=============================================================================
77 //=============================================================================
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_LARGE > 0x06010000
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 (std::list<std::string>& theOperations,
195 std::list<std::string>& theParams,
196 std::list<std::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 std::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 std::string theOperation,
230 std::list<std::string>& theParams,
231 std::list<std::string>& theValues )
233 ShHealOper_ShapeProcess aHealer;
234 int nbParamValueErrors( 0 );
235 std::list<std::string> aParams;
236 if ( GetParameters( theOperation, aParams ) ) {
237 for ( std::list<std::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 std::string theOperation,
266 std::list<std::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_LARGE > 0x06010000
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 ) ? ", " : "])");
381 //=============================================================================
385 //=============================================================================
386 Handle(GEOM_Object) GEOMImpl_IHealingOperations::CloseContour
387 (Handle(GEOM_Object) theObject,
388 const Handle(TColStd_HArray1OfInteger)& theWires,
391 // set error code, check parameters
394 if (theObject.IsNull())
396 SetErrorCode("NULL object given");
400 Handle(GEOM_Function) aFunction, aLastFunction = theObject->GetLastFunction();
401 if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be processed
404 Handle(GEOM_Object) aNewObject = GetEngine()->AddObject( GetDocID(), GEOM_COPY );
407 aFunction = aNewObject->AddFunction(GEOMImpl_HealingDriver::GetID(), CLOSE_CONTOUR);
409 if (aFunction.IsNull()) return NULL;
411 //Check if the function is set correctly
412 if(aFunction->GetDriverGUID() != GEOMImpl_HealingDriver::GetID()) return NULL;
414 // prepare "data container" class IHealing
415 GEOMImpl_IHealing HI(aFunction);
416 HI.SetWires( theWires );
417 HI.SetIsCommonVertex( isCommonVertex );
418 HI.SetOriginal( aLastFunction );
420 //Compute the translation
422 #if OCC_VERSION_LARGE > 0x06010000
425 if (!GetSolver()->ComputeFunction(aFunction))
427 SetErrorCode("Healing driver failed");
431 catch (Standard_Failure)
433 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
434 SetErrorCode(aFail->GetMessageString());
438 //Make a Python command
439 GEOM::TPythonDump pd (aFunction);
440 pd << aNewObject << " = geompy.CloseContour(" << theObject << ", [";
443 if (!theWires.IsNull())
445 int i = theWires->Lower(), nb = theWires->Upper();
446 pd << theWires->Value(i++);
448 pd << ", " << theWires->Value(i++);
450 pd << "], " << (int)isCommonVertex << ")";
456 //=============================================================================
460 //=============================================================================
461 Handle(GEOM_Object) GEOMImpl_IHealingOperations::RemoveIntWires
462 (Handle(GEOM_Object) theObject, const Handle(TColStd_HArray1OfInteger)& theWires)
464 // set error code, check parameters
467 if (theObject.IsNull()) // if theWires is NULL it's OK, it means that ALL wires must be removed
470 Handle(GEOM_Function) aFunction, aLastFunction = theObject->GetLastFunction();
471 if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be processed
474 Handle(GEOM_Object) aNewObject = GetEngine()->AddObject( GetDocID(), GEOM_COPY );
477 aFunction = aNewObject->AddFunction(GEOMImpl_HealingDriver::GetID(), REMOVE_INT_WIRES);
479 if (aFunction.IsNull()) return NULL;
481 //Check if the function is set correctly
482 if (aFunction->GetDriverGUID() != GEOMImpl_HealingDriver::GetID()) return NULL;
484 // prepare "data container" class IHealing
485 GEOMImpl_IHealing HI(aFunction);
486 HI.SetWires( theWires );
487 HI.SetOriginal( aLastFunction );
489 //Compute the translation
491 #if OCC_VERSION_LARGE > 0x06010000
494 if (!GetSolver()->ComputeFunction(aFunction))
496 SetErrorCode("Healing driver failed");
500 catch (Standard_Failure)
502 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
503 SetErrorCode(aFail->GetMessageString());
507 //Make a Python command
508 GEOM::TPythonDump pd (aFunction);
509 pd << aNewObject << " = geompy.SuppressInternalWires(" << theObject << ", [";
512 if (!theWires.IsNull()) {
513 int i = theWires->Lower(), nb = theWires->Upper();
514 for ( ; i <= nb; i++)
515 pd << theWires->Value( i ) << (( i < nb ) ? ", " : "])");
524 //=============================================================================
528 //=============================================================================
529 Handle(GEOM_Object) GEOMImpl_IHealingOperations::FillHoles (Handle(GEOM_Object) theObject,
530 const Handle(TColStd_HArray1OfInteger)& theWires)
532 // set error code, check parameters
535 if (theObject.IsNull()) // if theWires is NULL it's OK, it means that ALL holes must be removed
538 Handle(GEOM_Function) aFunction, aLastFunction = theObject->GetLastFunction();
539 if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be processed
542 Handle(GEOM_Object) aNewObject = GetEngine()->AddObject( GetDocID(), GEOM_COPY );
545 aFunction = aNewObject->AddFunction(GEOMImpl_HealingDriver::GetID(), FILL_HOLES);
547 if (aFunction.IsNull()) return NULL;
549 //Check if the function is set correctly
550 if (aFunction->GetDriverGUID() != GEOMImpl_HealingDriver::GetID()) return NULL;
552 // prepare "data container" class IHealing
553 GEOMImpl_IHealing HI(aFunction);
554 HI.SetWires( theWires );
555 HI.SetOriginal( aLastFunction );
557 //Compute the translation
559 #if OCC_VERSION_LARGE > 0x06010000
562 if (!GetSolver()->ComputeFunction(aFunction))
564 SetErrorCode("Healing driver failed");
568 catch (Standard_Failure)
570 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
571 SetErrorCode(aFail->GetMessageString());
575 //Make a Python command
576 GEOM::TPythonDump pd (aFunction);
577 pd << aNewObject << " = geompy.SuppressHoles(" << theObject << ", [";
580 if ( theWires.IsNull() )
583 int i = theWires->Lower(), nb = theWires->Upper();
584 for ( ; i <= nb; i++)
585 pd << theWires->Value( i ) << (( i < nb ) ? ", " : "])");
592 //=============================================================================
596 //=============================================================================
597 Handle(GEOM_Object) GEOMImpl_IHealingOperations::Sew (Handle(GEOM_Object) theObject,
600 // set error code, check parameters
603 if (theObject.IsNull())
606 Handle(GEOM_Function) aFunction, aLastFunction = theObject->GetLastFunction();
607 if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be processed
610 Handle(GEOM_Object) aNewObject = GetEngine()->AddObject( GetDocID(), GEOM_COPY );
613 aFunction = aNewObject->AddFunction(GEOMImpl_HealingDriver::GetID(), SEWING);
615 if (aFunction.IsNull()) return NULL;
617 //Check if the function is set correctly
618 if (aFunction->GetDriverGUID() != GEOMImpl_HealingDriver::GetID()) return NULL;
620 // prepare "data container" class IHealing
621 GEOMImpl_IHealing HI(aFunction);
622 HI.SetTolerance( theTolerance );
623 HI.SetOriginal( aLastFunction );
625 //Compute the translation
627 #if OCC_VERSION_LARGE > 0x06010000
630 if (!GetSolver()->ComputeFunction(aFunction))
632 SetErrorCode("Healing driver failed");
636 catch (Standard_Failure)
638 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
639 SetErrorCode(aFail->GetMessageString());
643 //Make a Python command
644 GEOM::TPythonDump(aFunction) << aNewObject << " = geompy.Sew("
645 << theObject << ", " << theTolerance << ")";
651 //=============================================================================
655 //=============================================================================
656 Handle(GEOM_Object) GEOMImpl_IHealingOperations::DivideEdge (Handle(GEOM_Object) theObject,
661 // set error code, check parameters
664 if (theObject.IsNull())
667 Handle(GEOM_Function) aFunction, aLastFunction = theObject->GetLastFunction();
668 if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be processed
671 Handle(GEOM_Object) aNewObject = GetEngine()->AddObject( GetDocID(), GEOM_COPY );
674 aFunction = aNewObject->AddFunction(GEOMImpl_HealingDriver::GetID(), DIVIDE_EDGE);
676 if (aFunction.IsNull()) return NULL;
678 //Check if the function is set correctly
679 if (aFunction->GetDriverGUID() != GEOMImpl_HealingDriver::GetID()) return NULL;
681 // prepare "data container" class IHealing
682 GEOMImpl_IHealing HI(aFunction);
683 HI.SetIndex( theIndex );
684 HI.SetDevideEdgeValue( theValue );
685 HI.SetIsByParameter( isByParameter );
686 HI.SetOriginal( aLastFunction );
688 //Compute the translation
690 #if OCC_VERSION_LARGE > 0x06010000
693 if (!GetSolver()->ComputeFunction(aFunction))
695 SetErrorCode("Healing driver failed");
699 catch (Standard_Failure)
701 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
702 SetErrorCode(aFail->GetMessageString());
706 //Make a Python command
707 GEOM::TPythonDump(aFunction) << aNewObject << " = geompy.DivideEdge(" << theObject
708 << ", " << theIndex << ", " << theValue << ", " << (int)isByParameter << ")";
714 //=============================================================================
718 //=============================================================================
719 bool GEOMImpl_IHealingOperations::GetFreeBoundary (Handle(GEOM_Object) theObject,
720 Handle(TColStd_HSequenceOfTransient)& theClosed,
721 Handle(TColStd_HSequenceOfTransient)& theOpen )
723 // set error code, check parameters
726 if ( theObject.IsNull() || theClosed.IsNull() || theOpen.IsNull() )
729 TopoDS_Shape aShape = theObject->GetValue();
730 if ( aShape.IsNull() )
733 // get free boundary shapes
735 #if OCC_VERSION_LARGE > 0x06030008
736 ShapeAnalysis_FreeBounds anAnalizer(aShape, Standard_False,
737 Standard_True, Standard_True);
739 ShapeAnalysis_FreeBounds anAnalizer(aShape);
741 TopoDS_Compound aClosed = anAnalizer.GetClosedWires();
742 TopoDS_Compound anOpen = anAnalizer.GetOpenWires();
744 // iterate through shapes and append them to the return sequence
745 Handle(GEOM_Object) anObj;
746 Handle(GEOM_Function) aFunction;
747 TopExp_Explorer anExp;
748 for ( anExp.Init( aClosed, TopAbs_WIRE ); anExp.More(); anExp.Next() )
750 anObj = GetEngine()->AddObject( GetDocID(), GEOM_FREE_BOUNDS );
751 aFunction = anObj->AddFunction( GEOMImpl_CopyDriver::GetID(), COPY_WITHOUT_REF );
752 TopoDS_Shape aValueShape = anExp.Current();
753 aFunction->SetValue( aValueShape );
754 theClosed->Append(anObj);
756 for ( anExp.Init( anOpen, TopAbs_WIRE ); anExp.More(); anExp.Next() )
758 anObj = GetEngine()->AddObject( GetDocID(), GEOM_FREE_BOUNDS );
759 aFunction = anObj->AddFunction( GEOMImpl_CopyDriver::GetID(), COPY_WITHOUT_REF );
760 TopoDS_Shape aValueShape = anExp.Current();
761 aFunction->SetValue( aValueShape );
762 theOpen->Append(anObj);
765 if(!aFunction.IsNull()) {
767 //Make a Python command
768 GEOM::TPythonDump pd (aFunction);
770 Standard_Integer i, aLen = theClosed->Length();
773 for (i = 1; i <= aLen; i++) {
774 Handle(GEOM_Object) anObj_i = Handle(GEOM_Object)::DownCast(theClosed->Value(i));
775 pd << anObj_i << ((i < aLen) ? ", " : "");
779 pd << "(isDone, empty_list, ";
782 aLen = theOpen->Length();
785 for (i = 1; i <= aLen; i++) {
786 Handle(GEOM_Object) anObj_i = Handle(GEOM_Object)::DownCast(theOpen->Value(i));
787 pd << anObj_i << ((i < aLen) ? ", " : "");
794 pd << ") = geompy.GetFreeBoundary(" << theObject << ")";
802 //=============================================================================
806 //=============================================================================
807 Handle(GEOM_Object) GEOMImpl_IHealingOperations::ChangeOrientation (Handle(GEOM_Object) theObject)
809 // set error code, check parameters
812 if (theObject.IsNull())
815 if (!theObject->IsMainShape()) {
816 SetErrorCode("Sub shape cannot be transformed - need to create a copy");
820 Handle(GEOM_Function) aFunction, aLastFunction = theObject->GetLastFunction();
821 if (aLastFunction.IsNull())
822 return NULL; //There is no function which creates an object to be processed
824 if (theObject->GetType() == GEOM_VECTOR) { // Mantis issue 21066
826 aFunction = theObject->AddFunction(GEOMImpl_VectorDriver::GetID(), VECTOR_REVERSE);
828 //Check if the function is set correctly
829 if (aFunction.IsNull()) return NULL;
830 if (aFunction->GetDriverGUID() != GEOMImpl_VectorDriver::GetID()) return NULL;
832 // prepare "data container" class IVector
833 GEOMImpl_IVector aVI (aFunction);
834 aVI.SetCurve(aLastFunction);
838 aFunction = theObject->AddFunction(GEOMImpl_HealingDriver::GetID(), CHANGE_ORIENTATION);
840 //Check if the function is set correctly
841 if (aFunction.IsNull()) return NULL;
842 if (aFunction->GetDriverGUID() != GEOMImpl_HealingDriver::GetID()) return NULL;
844 // prepare "data container" class IHealing
845 GEOMImpl_IHealing HI (aFunction);
846 HI.SetOriginal(aLastFunction);
849 //Compute the translation
851 #if OCC_VERSION_LARGE > 0x06010000
854 if (!GetSolver()->ComputeFunction(aFunction)) {
855 SetErrorCode("Healing driver failed");
859 catch (Standard_Failure) {
860 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
861 SetErrorCode(aFail->GetMessageString());
865 //Make a Python command
866 GEOM::TPythonDump(aFunction) << "geompy.ChangeOrientationShell("
873 //=============================================================================
875 * ChangeOrientationCopy
877 //=============================================================================
878 Handle(GEOM_Object) GEOMImpl_IHealingOperations::ChangeOrientationCopy (Handle(GEOM_Object) theObject)
880 // set error code, check parameters
883 if (theObject.IsNull())
886 Handle(GEOM_Function) aFunction, aLastFunction = theObject->GetLastFunction();
887 if (aLastFunction.IsNull())
888 return NULL; //There is no function which creates an object to be processed
891 Handle(GEOM_Object) aNewObject = GetEngine()->AddObject(GetDocID(), theObject->GetType());
893 if (theObject->GetType() == GEOM_VECTOR) { // Mantis issue 21066
895 aFunction = aNewObject->AddFunction(GEOMImpl_VectorDriver::GetID(), VECTOR_REVERSE);
897 //Check if the function is set correctly
898 if (aFunction.IsNull()) return NULL;
899 if (aFunction->GetDriverGUID() != GEOMImpl_VectorDriver::GetID()) return NULL;
901 // prepare "data container" class IVector
902 GEOMImpl_IVector aVI (aFunction);
903 aVI.SetCurve(aLastFunction);
907 aFunction = aNewObject->AddFunction(GEOMImpl_HealingDriver::GetID(), CHANGE_ORIENTATION);
909 //Check if the function is set correctly
910 if (aFunction.IsNull()) return NULL;
911 if (aFunction->GetDriverGUID() != GEOMImpl_HealingDriver::GetID()) return NULL;
913 // prepare "data container" class IHealing
914 GEOMImpl_IHealing aHI (aFunction);
915 aHI.SetOriginal(aLastFunction);
918 // Compute the result
920 #if OCC_VERSION_LARGE > 0x06010000
923 if (!GetSolver()->ComputeFunction(aFunction)) {
924 SetErrorCode("Healing driver failed");
928 catch (Standard_Failure) {
929 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
930 SetErrorCode(aFail->GetMessageString());
934 //Make a Python command
935 GEOM::TPythonDump(aFunction) << aNewObject << " = geompy.ChangeOrientationShellCopy("
942 //=============================================================================
946 //=============================================================================
947 Handle(GEOM_Object) GEOMImpl_IHealingOperations::LimitTolerance (Handle(GEOM_Object) theObject,
950 // Set error code, check parameters
953 if (theObject.IsNull())
956 Handle(GEOM_Function) aFunction, aLastFunction = theObject->GetLastFunction();
957 if (aLastFunction.IsNull())
958 return NULL; // There is no function which creates an object to be processed
961 Handle(GEOM_Object) aNewObject = GetEngine()->AddObject(GetDocID(), theObject->GetType());
964 aFunction = aNewObject->AddFunction(GEOMImpl_HealingDriver::GetID(), LIMIT_TOLERANCE);
966 if (aFunction.IsNull())
969 // Check if the function is set correctly
970 if (aFunction->GetDriverGUID() != GEOMImpl_HealingDriver::GetID()) return NULL;
972 // Prepare "data container" class IHealing
973 GEOMImpl_IHealing HI (aFunction);
974 HI.SetOriginal(aLastFunction);
975 HI.SetTolerance(theTolerance);
979 #if OCC_VERSION_LARGE > 0x06010000
982 if (!GetSolver()->ComputeFunction(aFunction)) {
983 SetErrorCode("Healing driver failed");
987 catch (Standard_Failure) {
988 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
989 SetErrorCode(aFail->GetMessageString());
993 // Make a Python command
994 GEOM::TPythonDump(aFunction) << aNewObject << " = geompy.LimitTolerance("
995 << theObject << ", " << theTolerance << ")";