1 // Copyright (C) 2007-2014 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, or (at your option) any later version.
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 #include <Standard_Stream.hxx>
25 #include <Basics_OCCTVersion.hxx>
27 #include <GEOMImpl_I3DPrimOperations.hxx>
29 #include "utilities.h"
31 #include <Utils_ExceptHandlers.hxx>
33 #include <TFunction_DriverTable.hxx>
34 #include <TFunction_Driver.hxx>
35 #include <TFunction_Logbook.hxx>
36 #include <TDF_Tool.hxx>
38 #include <GEOM_Function.hxx>
39 #include <GEOM_PythonDump.hxx>
41 #include <GEOMImpl_Types.hxx>
43 #include <GEOMImpl_BoxDriver.hxx>
44 #include <GEOMImpl_FaceDriver.hxx>
45 #include <GEOMImpl_DiskDriver.hxx>
46 #include <GEOMImpl_CylinderDriver.hxx>
47 #include <GEOMImpl_ConeDriver.hxx>
48 #include <GEOMImpl_SphereDriver.hxx>
49 #include <GEOMImpl_TorusDriver.hxx>
50 #include <GEOMImpl_PrismDriver.hxx>
51 #include <GEOMImpl_PipeDriver.hxx>
52 #include <GEOMImpl_PipePathDriver.hxx>
53 #include <GEOMImpl_RevolutionDriver.hxx>
54 #include <GEOMImpl_ShapeDriver.hxx>
55 #include <GEOMImpl_FillingDriver.hxx>
56 #include <GEOMImpl_ThruSectionsDriver.hxx>
57 #include <GEOMImpl_OffsetDriver.hxx>
59 #include <GEOMImpl_IBox.hxx>
60 #include <GEOMImpl_IFace.hxx>
61 #include <GEOMImpl_IDisk.hxx>
62 #include <GEOMImpl_ICylinder.hxx>
63 #include <GEOMImpl_ICone.hxx>
64 #include <GEOMImpl_ISphere.hxx>
65 #include <GEOMImpl_ITorus.hxx>
66 #include <GEOMImpl_IPrism.hxx>
67 #include <GEOMImpl_IPipe.hxx>
68 #include <GEOMImpl_IRevolution.hxx>
69 #include <GEOMImpl_IFilling.hxx>
70 #include <GEOMImpl_IThruSections.hxx>
71 #include <GEOMImpl_IPipeDiffSect.hxx>
72 #include <GEOMImpl_IPipeShellSect.hxx>
73 #include <GEOMImpl_IPipeBiNormal.hxx>
74 #include <GEOMImpl_IOffset.hxx>
75 #include <GEOMImpl_IPipePath.hxx>
77 #include <Precision.hxx>
79 #include <Standard_Failure.hxx>
80 #include <Standard_ErrorHandler.hxx> // CAREFUL ! position of this file is critic : see Lucien PIGNOLONI / OCC
82 //=============================================================================
86 //=============================================================================
87 GEOMImpl_I3DPrimOperations::GEOMImpl_I3DPrimOperations (GEOM_Engine* theEngine, int theDocID)
88 : GEOM_IOperations(theEngine, theDocID)
90 MESSAGE("GEOMImpl_I3DPrimOperations::GEOMImpl_I3DPrimOperations");
93 //=============================================================================
97 //=============================================================================
98 GEOMImpl_I3DPrimOperations::~GEOMImpl_I3DPrimOperations()
100 MESSAGE("GEOMImpl_I3DPrimOperations::~GEOMImpl_I3DPrimOperations");
104 //=============================================================================
108 //=============================================================================
109 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeBoxDXDYDZ (double theDX, double theDY, double theDZ)
113 //Add a new Box object
114 Handle(GEOM_Object) aBox = GetEngine()->AddObject(GetDocID(), GEOM_BOX);
116 //Add a new Box function with DX_DY_DZ parameters
117 Handle(GEOM_Function) aFunction = aBox->AddFunction(GEOMImpl_BoxDriver::GetID(), BOX_DX_DY_DZ);
118 if (aFunction.IsNull()) return NULL;
120 //Check if the function is set correctly
121 if (aFunction->GetDriverGUID() != GEOMImpl_BoxDriver::GetID()) return NULL;
123 GEOMImpl_IBox aBI (aFunction);
129 //Compute the box value
132 if (!GetSolver()->ComputeFunction(aFunction)) {
133 SetErrorCode("Box driver failed");
137 catch (Standard_Failure) {
138 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
139 SetErrorCode(aFail->GetMessageString());
143 //Make a Python command
144 GEOM::TPythonDump(aFunction) << aBox << " = geompy.MakeBoxDXDYDZ("
145 << theDX << ", " << theDY << ", " << theDZ << ")";
152 //=============================================================================
156 //=============================================================================
157 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeBoxTwoPnt (Handle(GEOM_Object) thePnt1,
158 Handle(GEOM_Object) thePnt2)
162 if (thePnt1.IsNull() || thePnt2.IsNull()) return NULL;
164 //Add a new Box object
165 Handle(GEOM_Object) aBox = GetEngine()->AddObject(GetDocID(), GEOM_BOX);
167 //Add a new Box function for creation a box relatively to two points
168 Handle(GEOM_Function) aFunction = aBox->AddFunction(GEOMImpl_BoxDriver::GetID(), BOX_TWO_PNT);
169 if (aFunction.IsNull()) return NULL;
171 //Check if the function is set correctly
172 if (aFunction->GetDriverGUID() != GEOMImpl_BoxDriver::GetID()) return aBox;
174 GEOMImpl_IBox aBI (aFunction);
176 Handle(GEOM_Function) aRefFunction1 = thePnt1->GetLastFunction();
177 Handle(GEOM_Function) aRefFunction2 = thePnt2->GetLastFunction();
179 if (aRefFunction1.IsNull() || aRefFunction2.IsNull()) return aBox;
181 aBI.SetRef1(aRefFunction1);
182 aBI.SetRef2(aRefFunction2);
184 //Compute the Box value
187 if (!GetSolver()->ComputeFunction(aFunction)) {
188 SetErrorCode("Box driver failed");
192 catch (Standard_Failure) {
193 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
194 SetErrorCode(aFail->GetMessageString());
198 //Make a Python command
199 GEOM::TPythonDump(aFunction) << aBox << " = geompy.MakeBoxTwoPnt("
200 << thePnt1 << ", " << thePnt2 << ")";
206 //=============================================================================
210 //=============================================================================
211 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeFaceHW (double theH, double theW, int theOrientation)
215 if (theH == 0 || theW == 0) return NULL;
217 //Add a new Face object
218 Handle(GEOM_Object) aFace = GetEngine()->AddObject(GetDocID(), GEOM_FACE);
220 //Add a new Box function for creation a box relatively to two points
221 Handle(GEOM_Function) aFunction = aFace->AddFunction(GEOMImpl_FaceDriver::GetID(), FACE_H_W);
222 if (aFunction.IsNull()) return NULL;
224 //Check if the function is set correctly
225 if (aFunction->GetDriverGUID() != GEOMImpl_FaceDriver::GetID()) return aFace;
227 GEOMImpl_IFace aFI (aFunction);
231 aFI.SetOrientation(theOrientation);
236 if (!GetSolver()->ComputeFunction(aFunction)) {
237 SetErrorCode("Face driver failed");
241 catch (Standard_Failure) {
242 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
243 SetErrorCode(aFail->GetMessageString());
247 //Make a Python command
248 GEOM::TPythonDump(aFunction) << aFace << " = geompy.MakeFaceHW("
249 << theH << ", " << theW << ", " << theOrientation << ")";
255 //=============================================================================
259 //=============================================================================
260 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeFaceObjHW (Handle(GEOM_Object) theObj,
261 double theH, double theW)
265 if (theObj.IsNull()) return NULL;
267 //Add a new Face object
268 Handle(GEOM_Object) aFace = GetEngine()->AddObject(GetDocID(), GEOM_FACE);
270 //Add a new Box function for creation a box relatively to two points
271 Handle(GEOM_Function) aFunction = aFace->AddFunction(GEOMImpl_FaceDriver::GetID(), FACE_OBJ_H_W);
272 if (aFunction.IsNull()) return NULL;
274 //Check if the function is set correctly
275 if (aFunction->GetDriverGUID() != GEOMImpl_FaceDriver::GetID()) return aFace;
277 GEOMImpl_IFace aFI (aFunction);
279 Handle(GEOM_Function) aRefFunction1 = theObj->GetLastFunction();
281 if (aRefFunction1.IsNull())
284 aFI.SetRef1(aRefFunction1);
291 if (!GetSolver()->ComputeFunction(aFunction)) {
292 SetErrorCode("Face driver failed");
296 catch (Standard_Failure) {
297 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
298 SetErrorCode(aFail->GetMessageString());
302 //Make a Python command
303 GEOM::TPythonDump(aFunction) << aFace << " = geompy.MakeFaceObjHW("
304 << theObj << ", " << theH << ", " << theW << ")";
310 //=============================================================================
314 //=============================================================================
315 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeDiskPntVecR
316 (Handle(GEOM_Object) thePnt, Handle(GEOM_Object) theVec, double theR)
320 if (thePnt.IsNull() || theVec.IsNull()) return NULL;
322 //Add a new Disk object
323 Handle(GEOM_Object) aDisk = GetEngine()->AddObject(GetDocID(), GEOM_FACE);
325 //Add a new Disk function for creation a disk relatively to point and vector
326 Handle(GEOM_Function) aFunction =
327 aDisk->AddFunction(GEOMImpl_DiskDriver::GetID(), DISK_PNT_VEC_R);
328 if (aFunction.IsNull()) return NULL;
330 //Check if the function is set correctly
331 if (aFunction->GetDriverGUID() != GEOMImpl_DiskDriver::GetID()) return NULL;
333 GEOMImpl_IDisk aCI (aFunction);
335 Handle(GEOM_Function) aRefPnt = thePnt->GetLastFunction();
336 Handle(GEOM_Function) aRefVec = theVec->GetLastFunction();
338 if (aRefPnt.IsNull() || aRefVec.IsNull()) return NULL;
340 aCI.SetCenter(aRefPnt);
341 aCI.SetVector(aRefVec);
344 //Compute the Disk value
347 if (!GetSolver()->ComputeFunction(aFunction)) {
348 SetErrorCode("Disk driver failed");
352 catch (Standard_Failure) {
353 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
354 SetErrorCode(aFail->GetMessageString());
358 //Make a Python command
359 GEOM::TPythonDump(aFunction) << aDisk << " = geompy.MakeDiskPntVecR("
360 << thePnt << ", " << theVec << ", " << theR << ")";
366 //=============================================================================
370 //=============================================================================
371 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeDiskThreePnt (Handle(GEOM_Object) thePnt1,
372 Handle(GEOM_Object) thePnt2,
373 Handle(GEOM_Object) thePnt3)
377 if (thePnt1.IsNull() || thePnt2.IsNull() || thePnt3.IsNull()) return NULL;
379 //Add a new Disk object
380 Handle(GEOM_Object) aDisk = GetEngine()->AddObject(GetDocID(), GEOM_FACE);
382 //Add a new Disk function for creation a disk relatively to three points
383 Handle(GEOM_Function) aFunction =
384 aDisk->AddFunction(GEOMImpl_DiskDriver::GetID(), DISK_THREE_PNT);
385 if (aFunction.IsNull()) return NULL;
387 //Check if the function is set correctly
388 if (aFunction->GetDriverGUID() != GEOMImpl_DiskDriver::GetID()) return NULL;
390 GEOMImpl_IDisk aCI (aFunction);
392 Handle(GEOM_Function) aRefPnt1 = thePnt1->GetLastFunction();
393 Handle(GEOM_Function) aRefPnt2 = thePnt2->GetLastFunction();
394 Handle(GEOM_Function) aRefPnt3 = thePnt3->GetLastFunction();
396 if (aRefPnt1.IsNull() || aRefPnt2.IsNull() || aRefPnt3.IsNull()) return NULL;
398 aCI.SetPoint1(aRefPnt1);
399 aCI.SetPoint2(aRefPnt2);
400 aCI.SetPoint3(aRefPnt3);
402 //Compute the Disk value
405 if (!GetSolver()->ComputeFunction(aFunction)) {
406 SetErrorCode("Disk driver failed");
410 catch (Standard_Failure) {
411 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
412 SetErrorCode(aFail->GetMessageString());
416 //Make a Python command
417 GEOM::TPythonDump(aFunction) << aDisk << " = geompy.MakeDiskThreePnt("
418 << thePnt1 << ", " << thePnt2 << ", " << thePnt3 << ")";
424 //=============================================================================
428 //=============================================================================
429 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeDiskR (double theR, int theOrientation)
433 if (theR == 0 ) return NULL;
435 //Add a new Disk object
436 Handle(GEOM_Object) aDisk = GetEngine()->AddObject(GetDocID(), GEOM_FACE);
438 //Add a new Box function for creation a box relatively to two points
439 Handle(GEOM_Function) aFunction = aDisk->AddFunction(GEOMImpl_DiskDriver::GetID(), DISK_R);
440 if (aFunction.IsNull()) return NULL;
442 //Check if the function is set correctly
443 if (aFunction->GetDriverGUID() != GEOMImpl_DiskDriver::GetID()) return aDisk;
445 GEOMImpl_IDisk aDI (aFunction);
448 aDI.SetOrientation(theOrientation);
453 if (!GetSolver()->ComputeFunction(aFunction)) {
454 SetErrorCode("Disk driver failed");
458 catch (Standard_Failure) {
459 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
460 SetErrorCode(aFail->GetMessageString());
464 //Make a Python command
465 GEOM::TPythonDump(aFunction) << aDisk << " = geompy.MakeDiskR("
466 << theR << ", " << theOrientation << ")";
472 //=============================================================================
476 //=============================================================================
477 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeCylinderRH (double theR, double theH)
481 //Add a new Cylinder object
482 Handle(GEOM_Object) aCylinder = GetEngine()->AddObject(GetDocID(), GEOM_CYLINDER);
484 //Add a new Cylinder function with R and H parameters
485 Handle(GEOM_Function) aFunction = aCylinder->AddFunction(GEOMImpl_CylinderDriver::GetID(), CYLINDER_R_H);
486 if (aFunction.IsNull()) return NULL;
488 //Check if the function is set correctly
489 if (aFunction->GetDriverGUID() != GEOMImpl_CylinderDriver::GetID()) return NULL;
491 GEOMImpl_ICylinder aCI (aFunction);
496 //Compute the Cylinder value
499 if (!GetSolver()->ComputeFunction(aFunction)) {
500 SetErrorCode("Cylinder driver failed");
504 catch (Standard_Failure) {
505 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
506 SetErrorCode(aFail->GetMessageString());
510 //Make a Python command
511 GEOM::TPythonDump(aFunction) << aCylinder
512 << " = geompy.MakeCylinderRH(" << theR << ", " << theH << ")";
519 //=============================================================================
521 * MakeCylinderPntVecRH
523 //=============================================================================
524 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeCylinderPntVecRH (Handle(GEOM_Object) thePnt,
525 Handle(GEOM_Object) theVec,
526 double theR, double theH)
530 if (thePnt.IsNull() || theVec.IsNull()) return NULL;
532 //Add a new Cylinder object
533 Handle(GEOM_Object) aCylinder = GetEngine()->AddObject(GetDocID(), GEOM_CYLINDER);
535 //Add a new Cylinder function for creation a cylinder relatively to point and vector
536 Handle(GEOM_Function) aFunction =
537 aCylinder->AddFunction(GEOMImpl_CylinderDriver::GetID(), CYLINDER_PNT_VEC_R_H);
538 if (aFunction.IsNull()) return NULL;
540 //Check if the function is set correctly
541 if (aFunction->GetDriverGUID() != GEOMImpl_CylinderDriver::GetID()) return NULL;
543 GEOMImpl_ICylinder aCI (aFunction);
545 Handle(GEOM_Function) aRefPnt = thePnt->GetLastFunction();
546 Handle(GEOM_Function) aRefVec = theVec->GetLastFunction();
548 if (aRefPnt.IsNull() || aRefVec.IsNull()) return NULL;
550 aCI.SetPoint(aRefPnt);
551 aCI.SetVector(aRefVec);
555 //Compute the Cylinder value
558 if (!GetSolver()->ComputeFunction(aFunction)) {
559 SetErrorCode("Cylinder driver failed");
563 catch (Standard_Failure) {
564 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
565 SetErrorCode(aFail->GetMessageString());
569 //Make a Python command
570 GEOM::TPythonDump(aFunction) << aCylinder << " = geompy.MakeCylinder("
571 << thePnt << ", " << theVec << ", " << theR << ", " << theH << ")";
578 //=============================================================================
582 //=============================================================================
583 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeConeR1R2H (double theR1, double theR2,
588 //Add a new Cone object
589 Handle(GEOM_Object) aCone = GetEngine()->AddObject(GetDocID(), GEOM_CONE);
591 //Add a new Cone function with R and H parameters
592 Handle(GEOM_Function) aFunction =
593 aCone->AddFunction(GEOMImpl_ConeDriver::GetID(), CONE_R1_R2_H);
594 if (aFunction.IsNull()) return NULL;
596 //Check if the function is set correctly
597 if (aFunction->GetDriverGUID() != GEOMImpl_ConeDriver::GetID()) return NULL;
599 GEOMImpl_ICone aCI (aFunction);
605 //Compute the Cone value
608 if (!GetSolver()->ComputeFunction(aFunction)) {
609 SetErrorCode("Cone driver failed");
613 catch (Standard_Failure) {
614 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
615 SetErrorCode(aFail->GetMessageString());
619 //Make a Python command
620 GEOM::TPythonDump(aFunction) << aCone << " = geompy.MakeConeR1R2H("
621 << theR1 << ", " << theR2 << ", " << theH << ")";
628 //=============================================================================
630 * MakeConePntVecR1R2H
632 //=============================================================================
633 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeConePntVecR1R2H (Handle(GEOM_Object) thePnt,
634 Handle(GEOM_Object) theVec,
635 double theR1, double theR2,
640 if (thePnt.IsNull() || theVec.IsNull()) return NULL;
642 //Add a new Cone object
643 Handle(GEOM_Object) aCone = GetEngine()->AddObject(GetDocID(), GEOM_CONE);
645 //Add a new Cone function for creation a cone relatively to point and vector
646 Handle(GEOM_Function) aFunction =
647 aCone->AddFunction(GEOMImpl_ConeDriver::GetID(), CONE_PNT_VEC_R1_R2_H);
648 if (aFunction.IsNull()) return NULL;
650 //Check if the function is set correctly
651 if (aFunction->GetDriverGUID() != GEOMImpl_ConeDriver::GetID()) return NULL;
653 GEOMImpl_ICone aCI (aFunction);
655 Handle(GEOM_Function) aRefPnt = thePnt->GetLastFunction();
656 Handle(GEOM_Function) aRefVec = theVec->GetLastFunction();
658 if (aRefPnt.IsNull() || aRefVec.IsNull()) return NULL;
660 aCI.SetPoint(aRefPnt);
661 aCI.SetVector(aRefVec);
666 //Compute the Cone value
669 if (!GetSolver()->ComputeFunction(aFunction)) {
670 SetErrorCode("Cone driver failed");
674 catch (Standard_Failure) {
675 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
676 SetErrorCode(aFail->GetMessageString());
680 //Make a Python command
681 GEOM::TPythonDump(aFunction) << aCone << " = geompy.MakeCone(" << thePnt
682 << ", " << theVec << ", " << theR1 << ", " << theR2 << ", " << theH << ")";
689 //=============================================================================
693 //=============================================================================
694 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeSphereR (double theR)
698 //Add a new Sphere object
699 Handle(GEOM_Object) aSphere = GetEngine()->AddObject(GetDocID(), GEOM_SPHERE);
701 //Add a new Sphere function with R parameter
702 Handle(GEOM_Function) aFunction = aSphere->AddFunction(GEOMImpl_SphereDriver::GetID(), SPHERE_R);
703 if (aFunction.IsNull()) return NULL;
705 //Check if the function is set correctly
706 if (aFunction->GetDriverGUID() != GEOMImpl_SphereDriver::GetID()) return NULL;
708 GEOMImpl_ISphere aCI (aFunction);
712 //Compute the Sphere value
715 if (!GetSolver()->ComputeFunction(aFunction)) {
716 SetErrorCode("Sphere driver failed");
720 catch (Standard_Failure) {
721 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
722 SetErrorCode(aFail->GetMessageString());
726 //Make a Python command
727 GEOM::TPythonDump(aFunction) << aSphere << " = geompy.MakeSphereR(" << theR << ")";
734 //=============================================================================
738 //=============================================================================
739 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeSpherePntR (Handle(GEOM_Object) thePnt,
744 if (thePnt.IsNull()) return NULL;
746 //Add a new Point object
747 Handle(GEOM_Object) aSphere = GetEngine()->AddObject(GetDocID(), GEOM_SPHERE);
749 //Add a new Sphere function for creation a sphere relatively to point
750 Handle(GEOM_Function) aFunction = aSphere->AddFunction(GEOMImpl_SphereDriver::GetID(), SPHERE_PNT_R);
751 if (aFunction.IsNull()) return NULL;
753 //Check if the function is set correctly
754 if (aFunction->GetDriverGUID() != GEOMImpl_SphereDriver::GetID()) return NULL;
756 GEOMImpl_ISphere aCI (aFunction);
758 Handle(GEOM_Function) aRefPnt = thePnt->GetLastFunction();
760 if (aRefPnt.IsNull()) return NULL;
762 aCI.SetPoint(aRefPnt);
765 //Compute the Sphere value
768 if (!GetSolver()->ComputeFunction(aFunction)) {
769 SetErrorCode("Sphere driver failed");
773 catch (Standard_Failure) {
774 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
775 SetErrorCode(aFail->GetMessageString());
779 //Make a Python command
780 GEOM::TPythonDump(aFunction) << aSphere
781 << " = geompy.MakeSpherePntR(" << thePnt << ", " << theR << ")";
788 //=============================================================================
792 //=============================================================================
793 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeTorusRR
794 (double theRMajor, double theRMinor)
798 //Add a new Torus object
799 Handle(GEOM_Object) anEll = GetEngine()->AddObject(GetDocID(), GEOM_TORUS);
801 //Add a new Torus function
802 Handle(GEOM_Function) aFunction =
803 anEll->AddFunction(GEOMImpl_TorusDriver::GetID(), TORUS_RR);
804 if (aFunction.IsNull()) return NULL;
806 //Check if the function is set correctly
807 if (aFunction->GetDriverGUID() != GEOMImpl_TorusDriver::GetID()) return NULL;
809 GEOMImpl_ITorus aCI (aFunction);
811 aCI.SetRMajor(theRMajor);
812 aCI.SetRMinor(theRMinor);
814 //Compute the Torus value
817 if (!GetSolver()->ComputeFunction(aFunction)) {
818 SetErrorCode("Torus driver failed");
822 catch (Standard_Failure) {
823 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
824 SetErrorCode(aFail->GetMessageString());
828 //Make a Python command
829 GEOM::TPythonDump(aFunction) << anEll << " = geompy.MakeTorusRR("
830 << theRMajor << ", " << theRMinor << ")";
836 //=============================================================================
840 //=============================================================================
841 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeTorusPntVecRR
842 (Handle(GEOM_Object) thePnt, Handle(GEOM_Object) theVec,
843 double theRMajor, double theRMinor)
847 if (thePnt.IsNull() || theVec.IsNull()) return NULL;
849 //Add a new Torus object
850 Handle(GEOM_Object) anEll = GetEngine()->AddObject(GetDocID(), GEOM_TORUS);
852 //Add a new Torus function
853 Handle(GEOM_Function) aFunction =
854 anEll->AddFunction(GEOMImpl_TorusDriver::GetID(), TORUS_PNT_VEC_RR);
855 if (aFunction.IsNull()) return NULL;
857 //Check if the function is set correctly
858 if (aFunction->GetDriverGUID() != GEOMImpl_TorusDriver::GetID()) return NULL;
860 GEOMImpl_ITorus aCI (aFunction);
862 Handle(GEOM_Function) aRefPnt = thePnt->GetLastFunction();
863 Handle(GEOM_Function) aRefVec = theVec->GetLastFunction();
865 if (aRefPnt.IsNull() || aRefVec.IsNull()) return NULL;
867 aCI.SetCenter(aRefPnt);
868 aCI.SetVector(aRefVec);
869 aCI.SetRMajor(theRMajor);
870 aCI.SetRMinor(theRMinor);
872 //Compute the Torus value
875 if (!GetSolver()->ComputeFunction(aFunction)) {
876 SetErrorCode("Torus driver failed");
880 catch (Standard_Failure) {
881 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
882 SetErrorCode(aFail->GetMessageString());
886 //Make a Python command
887 GEOM::TPythonDump(aFunction) << anEll << " = geompy.MakeTorus(" << thePnt
888 << ", " << theVec << ", " << theRMajor << ", " << theRMinor << ")";
895 //=============================================================================
899 //=============================================================================
900 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePrismVecH (Handle(GEOM_Object) theBase,
901 Handle(GEOM_Object) theVec,
902 double theH, double theScaleFactor)
906 if (theBase.IsNull() || theVec.IsNull()) return NULL;
908 //Add a new Prism object
909 Handle(GEOM_Object) aPrism = GetEngine()->AddObject(GetDocID(), GEOM_PRISM);
911 //Add a new Prism function for creation a Prism relatively to vector
912 Handle(GEOM_Function) aFunction =
913 aPrism->AddFunction(GEOMImpl_PrismDriver::GetID(), PRISM_BASE_VEC_H);
914 if (aFunction.IsNull()) return NULL;
916 //Check if the function is set correctly
917 if (aFunction->GetDriverGUID() != GEOMImpl_PrismDriver::GetID()) return NULL;
919 GEOMImpl_IPrism aCI (aFunction);
921 Handle(GEOM_Function) aRefBase = theBase->GetLastFunction();
922 Handle(GEOM_Function) aRefVec = theVec->GetLastFunction();
924 if (aRefBase.IsNull() || aRefVec.IsNull()) return NULL;
926 aCI.SetBase(aRefBase);
927 aCI.SetVector(aRefVec);
929 aCI.SetScale(theScaleFactor);
931 //Compute the Prism value
934 if (!GetSolver()->ComputeFunction(aFunction)) {
935 //SetErrorCode("Prism driver failed");
936 SetErrorCode("Extrusion can not be created, check input data");
940 catch (Standard_Failure) {
941 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
942 SetErrorCode(aFail->GetMessageString());
946 //Make a Python command
947 GEOM::TPythonDump pd (aFunction);
948 pd << aPrism << " = geompy.MakePrismVecH(" << theBase << ", " << theVec << ", " << theH;
949 if (theScaleFactor > Precision::Confusion())
950 pd << ", " << theScaleFactor << ")";
958 //=============================================================================
962 //=============================================================================
963 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePrismVecH2Ways (Handle(GEOM_Object) theBase,
964 Handle(GEOM_Object) theVec,
969 if (theBase.IsNull() || theVec.IsNull()) return NULL;
971 //Add a new Prism object
972 Handle(GEOM_Object) aPrism = GetEngine()->AddObject(GetDocID(), GEOM_PRISM);
974 //Add a new Prism function for creation a Prism relatively to vector
975 Handle(GEOM_Function) aFunction =
976 aPrism->AddFunction(GEOMImpl_PrismDriver::GetID(), PRISM_BASE_VEC_H_2WAYS);
977 if (aFunction.IsNull()) return NULL;
979 //Check if the function is set correctly
980 if (aFunction->GetDriverGUID() != GEOMImpl_PrismDriver::GetID()) return NULL;
982 GEOMImpl_IPrism aCI (aFunction);
984 Handle(GEOM_Function) aRefBase = theBase->GetLastFunction();
985 Handle(GEOM_Function) aRefVec = theVec->GetLastFunction();
987 if (aRefBase.IsNull() || aRefVec.IsNull()) return NULL;
989 aCI.SetBase(aRefBase);
990 aCI.SetVector(aRefVec);
993 //Compute the Prism value
996 if (!GetSolver()->ComputeFunction(aFunction)) {
997 //SetErrorCode("Prism driver failed");
998 SetErrorCode("Extrusion can not be created, check input data");
1002 catch (Standard_Failure) {
1003 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1004 SetErrorCode(aFail->GetMessageString());
1008 //Make a Python command
1009 GEOM::TPythonDump(aFunction) << aPrism << " = geompy.MakePrismVecH2Ways("
1010 << theBase << ", " << theVec << ", " << theH << ")";
1016 //=============================================================================
1020 //=============================================================================
1021 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePrismTwoPnt
1022 (Handle(GEOM_Object) theBase,
1023 Handle(GEOM_Object) thePoint1, Handle(GEOM_Object) thePoint2,
1024 double theScaleFactor)
1028 if (theBase.IsNull() || thePoint1.IsNull() || thePoint2.IsNull()) return NULL;
1030 //Add a new Prism object
1031 Handle(GEOM_Object) aPrism = GetEngine()->AddObject(GetDocID(), GEOM_PRISM);
1033 //Add a new Prism function for creation a Prism relatively to two points
1034 Handle(GEOM_Function) aFunction =
1035 aPrism->AddFunction(GEOMImpl_PrismDriver::GetID(), PRISM_BASE_TWO_PNT);
1036 if (aFunction.IsNull()) return NULL;
1038 //Check if the function is set correctly
1039 if (aFunction->GetDriverGUID() != GEOMImpl_PrismDriver::GetID()) return NULL;
1041 GEOMImpl_IPrism aCI (aFunction);
1043 Handle(GEOM_Function) aRefBase = theBase->GetLastFunction();
1044 Handle(GEOM_Function) aRefPnt1 = thePoint1->GetLastFunction();
1045 Handle(GEOM_Function) aRefPnt2 = thePoint2->GetLastFunction();
1047 if (aRefBase.IsNull() || aRefPnt1.IsNull() || aRefPnt2.IsNull()) return NULL;
1049 aCI.SetBase(aRefBase);
1050 aCI.SetFirstPoint(aRefPnt1);
1051 aCI.SetLastPoint(aRefPnt2);
1052 aCI.SetScale(theScaleFactor);
1054 //Compute the Prism value
1057 if (!GetSolver()->ComputeFunction(aFunction)) {
1058 //SetErrorCode("Prism driver failed");
1059 SetErrorCode("Extrusion can not be created, check input data");
1063 catch (Standard_Failure) {
1064 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1065 SetErrorCode(aFail->GetMessageString());
1069 //Make a Python command
1070 GEOM::TPythonDump pd (aFunction);
1071 pd << aPrism << " = geompy.MakePrism(" << theBase << ", " << thePoint1 << ", " << thePoint2;
1072 if (theScaleFactor > Precision::Confusion())
1073 pd << ", " << theScaleFactor << ")";
1081 //=============================================================================
1083 * MakePrismTwoPnt2Ways
1085 //=============================================================================
1086 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePrismTwoPnt2Ways
1087 (Handle(GEOM_Object) theBase,
1088 Handle(GEOM_Object) thePoint1, Handle(GEOM_Object) thePoint2)
1092 if (theBase.IsNull() || thePoint1.IsNull() || thePoint2.IsNull()) return NULL;
1094 //Add a new Prism object
1095 Handle(GEOM_Object) aPrism = GetEngine()->AddObject(GetDocID(), GEOM_PRISM);
1097 //Add a new Prism function for creation a Prism relatively to two points
1098 Handle(GEOM_Function) aFunction =
1099 aPrism->AddFunction(GEOMImpl_PrismDriver::GetID(), PRISM_BASE_TWO_PNT_2WAYS);
1100 if (aFunction.IsNull()) return NULL;
1102 //Check if the function is set correctly
1103 if (aFunction->GetDriverGUID() != GEOMImpl_PrismDriver::GetID()) return NULL;
1105 GEOMImpl_IPrism aCI (aFunction);
1107 Handle(GEOM_Function) aRefBase = theBase->GetLastFunction();
1108 Handle(GEOM_Function) aRefPnt1 = thePoint1->GetLastFunction();
1109 Handle(GEOM_Function) aRefPnt2 = thePoint2->GetLastFunction();
1111 if (aRefBase.IsNull() || aRefPnt1.IsNull() || aRefPnt2.IsNull()) return NULL;
1113 aCI.SetBase(aRefBase);
1114 aCI.SetFirstPoint(aRefPnt1);
1115 aCI.SetLastPoint(aRefPnt2);
1117 //Compute the Prism value
1120 if (!GetSolver()->ComputeFunction(aFunction)) {
1121 //SetErrorCode("Prism driver failed");
1122 SetErrorCode("Extrusion can not be created, check input data");
1126 catch (Standard_Failure) {
1127 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1128 SetErrorCode(aFail->GetMessageString());
1132 //Make a Python command
1133 GEOM::TPythonDump(aFunction) << aPrism << " = geompy.MakePrism2Ways("
1134 << theBase << ", " << thePoint1 << ", " << thePoint2 << ")";
1140 //=============================================================================
1144 //=============================================================================
1145 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePrismDXDYDZ
1146 (Handle(GEOM_Object) theBase, double theDX, double theDY, double theDZ,
1147 double theScaleFactor)
1151 if (theBase.IsNull()) return NULL;
1153 //Add a new Prism object
1154 Handle(GEOM_Object) aPrism = GetEngine()->AddObject(GetDocID(), GEOM_PRISM);
1156 //Add a new Prism function for creation a Prism by DXDYDZ
1157 Handle(GEOM_Function) aFunction =
1158 aPrism->AddFunction(GEOMImpl_PrismDriver::GetID(), PRISM_BASE_DXDYDZ);
1159 if (aFunction.IsNull()) return NULL;
1161 //Check if the function is set correctly
1162 if (aFunction->GetDriverGUID() != GEOMImpl_PrismDriver::GetID()) return NULL;
1164 GEOMImpl_IPrism aCI (aFunction);
1166 Handle(GEOM_Function) aRefBase = theBase->GetLastFunction();
1168 if (aRefBase.IsNull()) return NULL;
1170 aCI.SetBase(aRefBase);
1174 aCI.SetScale(theScaleFactor);
1176 //Compute the Prism value
1179 if (!GetSolver()->ComputeFunction(aFunction)) {
1180 SetErrorCode("Extrusion can not be created, check input data");
1184 catch (Standard_Failure) {
1185 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1186 SetErrorCode(aFail->GetMessageString());
1190 //Make a Python command
1191 GEOM::TPythonDump pd (aFunction);
1192 pd << aPrism << " = geompy.MakePrismDXDYDZ("
1193 << theBase << ", " << theDX << ", " << theDY << ", " << theDZ;
1194 if (theScaleFactor > Precision::Confusion())
1195 pd << ", " << theScaleFactor << ")";
1203 //=============================================================================
1205 * MakePrismDXDYDZ_2WAYS
1207 //=============================================================================
1208 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePrismDXDYDZ2Ways
1209 (Handle(GEOM_Object) theBase, double theDX, double theDY, double theDZ)
1213 if (theBase.IsNull()) return NULL;
1215 //Add a new Prism object
1216 Handle(GEOM_Object) aPrism = GetEngine()->AddObject(GetDocID(), GEOM_PRISM);
1218 //Add a new Prism function for creation a Prism by DXDYDZ
1219 Handle(GEOM_Function) aFunction =
1220 aPrism->AddFunction(GEOMImpl_PrismDriver::GetID(), PRISM_BASE_DXDYDZ_2WAYS);
1221 if (aFunction.IsNull()) return NULL;
1223 //Check if the function is set correctly
1224 if (aFunction->GetDriverGUID() != GEOMImpl_PrismDriver::GetID()) return NULL;
1226 GEOMImpl_IPrism aCI (aFunction);
1228 Handle(GEOM_Function) aRefBase = theBase->GetLastFunction();
1230 if (aRefBase.IsNull()) return NULL;
1232 aCI.SetBase(aRefBase);
1237 //Compute the Prism value
1240 if (!GetSolver()->ComputeFunction(aFunction)) {
1241 SetErrorCode("Extrusion can not be created, check input data");
1245 catch (Standard_Failure) {
1246 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1247 SetErrorCode(aFail->GetMessageString());
1251 //Make a Python command
1252 GEOM::TPythonDump(aFunction) << aPrism << " = geompy.MakePrismDXDYDZ2Ways("
1253 << theBase << ", " << theDX << ", " << theDY << ", " << theDZ << ")";
1259 //=============================================================================
1263 //=============================================================================
1264 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeDraftPrism
1265 (Handle(GEOM_Object) theInitShape ,Handle(GEOM_Object) theBase, double theHeight, double theAngle, bool theFuse)
1269 if (theBase.IsNull() || theInitShape.IsNull()) return NULL;
1271 Handle(GEOM_Object) aPrism = NULL;
1275 //Add a new Extruded Boss object
1276 aPrism = GetEngine()->AddObject(GetDocID(), GEOM_EXTRUDED_BOSS);
1280 //Add a new Extruded Cut object
1281 aPrism = GetEngine()->AddObject(GetDocID(), GEOM_EXTRUDED_CUT);
1284 //Add a new Prism function for the creation of a Draft Prism feature
1285 Handle(GEOM_Function) aFunction =
1286 aPrism->AddFunction(GEOMImpl_PrismDriver::GetID(), DRAFT_PRISM_FEATURE);
1287 if (aFunction.IsNull()) return NULL;
1289 //Check if the function is set correctly
1290 if (aFunction->GetDriverGUID() != GEOMImpl_PrismDriver::GetID()) return NULL;
1292 GEOMImpl_IPrism aCI (aFunction);
1294 Handle(GEOM_Function) aRefInit = theInitShape->GetLastFunction();
1295 Handle(GEOM_Function) aRefBase = theBase->GetLastFunction();
1297 if (aRefBase.IsNull() || aRefInit.IsNull()) return NULL;
1300 aCI.SetBase(aRefBase);
1301 aCI.SetInitShape(aRefInit);
1302 aCI.SetH(theHeight);
1303 aCI.SetDraftAngle(theAngle);
1309 //Compute the Draft Prism Feature value
1312 if (!GetSolver()->ComputeFunction(aFunction)) {
1313 SetErrorCode("Extrusion can not be created, check input data");
1317 catch (Standard_Failure) {
1318 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1319 SetErrorCode(aFail->GetMessageString());
1323 //Make a Python command
1326 GEOM::TPythonDump(aFunction) << aPrism << " = geompy.MakeExtrudedBoss("
1327 << theInitShape << ", " << theBase << ", " << theHeight << ", " << theAngle << ")";
1331 GEOM::TPythonDump(aFunction) << aPrism << " = geompy.MakeExtrudedCut("
1332 << theInitShape << ", " << theBase << ", " << theHeight << ", " << theAngle << ")";
1339 //=============================================================================
1343 //=============================================================================
1344 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePipe (Handle(GEOM_Object) theBase,
1345 Handle(GEOM_Object) thePath)
1349 if (theBase.IsNull() || thePath.IsNull()) return NULL;
1351 //Add a new Pipe object
1352 Handle(GEOM_Object) aPipe = GetEngine()->AddObject(GetDocID(), GEOM_PIPE);
1354 //Add a new Pipe function
1355 Handle(GEOM_Function) aFunction =
1356 aPipe->AddFunction(GEOMImpl_PipeDriver::GetID(), PIPE_BASE_PATH);
1357 if (aFunction.IsNull()) return NULL;
1359 //Check if the function is set correctly
1360 if (aFunction->GetDriverGUID() != GEOMImpl_PipeDriver::GetID()) return NULL;
1362 GEOMImpl_IPipe aCI (aFunction);
1364 Handle(GEOM_Function) aRefBase = theBase->GetLastFunction();
1365 Handle(GEOM_Function) aRefPath = thePath->GetLastFunction();
1367 if (aRefBase.IsNull() || aRefPath.IsNull()) return NULL;
1369 aCI.SetBase(aRefBase);
1370 aCI.SetPath(aRefPath);
1372 //Compute the Pipe value
1375 if (!GetSolver()->ComputeFunction(aFunction)) {
1376 SetErrorCode("Pipe driver failed");
1380 catch (Standard_Failure) {
1381 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1382 SetErrorCode(aFail->GetMessageString());
1386 //Make a Python command
1387 GEOM::TPythonDump(aFunction) << aPipe << " = geompy.MakePipe("
1388 << theBase << ", " << thePath << ")";
1395 //=============================================================================
1397 * MakeRevolutionAxisAngle
1399 //=============================================================================
1400 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeRevolutionAxisAngle (Handle(GEOM_Object) theBase,
1401 Handle(GEOM_Object) theAxis,
1406 if (theBase.IsNull() || theAxis.IsNull()) return NULL;
1408 //Add a new Revolution object
1409 Handle(GEOM_Object) aRevolution = GetEngine()->AddObject(GetDocID(), GEOM_REVOLUTION);
1411 //Add a new Revolution function for creation a revolution relatively to axis
1412 Handle(GEOM_Function) aFunction =
1413 aRevolution->AddFunction(GEOMImpl_RevolutionDriver::GetID(), REVOLUTION_BASE_AXIS_ANGLE);
1414 if (aFunction.IsNull()) return NULL;
1416 //Check if the function is set correctly
1417 if (aFunction->GetDriverGUID() != GEOMImpl_RevolutionDriver::GetID()) return NULL;
1419 GEOMImpl_IRevolution aCI (aFunction);
1421 Handle(GEOM_Function) aRefBase = theBase->GetLastFunction();
1422 Handle(GEOM_Function) aRefAxis = theAxis->GetLastFunction();
1424 if (aRefBase.IsNull() || aRefAxis.IsNull()) return NULL;
1426 aCI.SetBase(aRefBase);
1427 aCI.SetAxis(aRefAxis);
1428 aCI.SetAngle(theAngle);
1430 //Compute the Revolution value
1433 if (!GetSolver()->ComputeFunction(aFunction)) {
1434 SetErrorCode("Revolution driver failed");
1438 catch (Standard_Failure) {
1439 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1440 SetErrorCode(aFail->GetMessageString());
1444 //Make a Python command
1445 GEOM::TPythonDump(aFunction) << aRevolution << " = geompy.MakeRevolution("
1446 << theBase << ", " << theAxis << ", " << theAngle * 180.0 / M_PI << "*math.pi/180.0)";
1452 //=============================================================================
1454 * MakeRevolutionAxisAngle2Ways
1456 //=============================================================================
1457 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeRevolutionAxisAngle2Ways
1458 (Handle(GEOM_Object) theBase, Handle(GEOM_Object) theAxis, double theAngle)
1462 if (theBase.IsNull() || theAxis.IsNull()) return NULL;
1464 //Add a new Revolution object
1465 Handle(GEOM_Object) aRevolution = GetEngine()->AddObject(GetDocID(), GEOM_REVOLUTION);
1467 //Add a new Revolution function for creation a revolution relatively to axis
1468 Handle(GEOM_Function) aFunction =
1469 aRevolution->AddFunction(GEOMImpl_RevolutionDriver::GetID(), REVOLUTION_BASE_AXIS_ANGLE_2WAYS);
1470 if (aFunction.IsNull()) return NULL;
1472 //Check if the function is set correctly
1473 if (aFunction->GetDriverGUID() != GEOMImpl_RevolutionDriver::GetID()) return NULL;
1475 GEOMImpl_IRevolution aCI (aFunction);
1477 Handle(GEOM_Function) aRefBase = theBase->GetLastFunction();
1478 Handle(GEOM_Function) aRefAxis = theAxis->GetLastFunction();
1480 if (aRefBase.IsNull() || aRefAxis.IsNull()) return NULL;
1482 aCI.SetBase(aRefBase);
1483 aCI.SetAxis(aRefAxis);
1484 aCI.SetAngle(theAngle);
1486 //Compute the Revolution value
1489 if (!GetSolver()->ComputeFunction(aFunction)) {
1490 SetErrorCode("Revolution driver failed");
1494 catch (Standard_Failure) {
1495 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1496 SetErrorCode(aFail->GetMessageString());
1500 //Make a Python command
1501 GEOM::TPythonDump(aFunction) << aRevolution << " = geompy.MakeRevolution2Ways("
1502 << theBase << ", " << theAxis << ", " << theAngle * 180.0 / M_PI << "*math.pi/180.0)";
1508 //=============================================================================
1512 //=============================================================================
1513 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeFilling
1514 (Handle(GEOM_Object) theShape, int theMinDeg, int theMaxDeg,
1515 double theTol2D, double theTol3D, int theNbIter,
1516 int theMethod, bool isApprox)
1520 if (theShape.IsNull()) return NULL;
1522 //Add a new Filling object
1523 Handle(GEOM_Object) aFilling = GetEngine()->AddObject(GetDocID(), GEOM_FILLING);
1525 //Add a new Filling function for creation a filling from a compound
1526 Handle(GEOM_Function) aFunction = aFilling->AddFunction(GEOMImpl_FillingDriver::GetID(), BASIC_FILLING);
1527 if (aFunction.IsNull()) return NULL;
1529 //Check if the function is set correctly
1530 if (aFunction->GetDriverGUID() != GEOMImpl_FillingDriver::GetID()) return NULL;
1532 GEOMImpl_IFilling aFI (aFunction);
1534 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
1536 if (aRefShape.IsNull()) return NULL;
1538 aFI.SetShape(aRefShape);
1539 aFI.SetMinDeg(theMinDeg);
1540 aFI.SetMaxDeg(theMaxDeg);
1541 aFI.SetTol2D(theTol2D);
1542 aFI.SetTol3D(theTol3D);
1543 aFI.SetNbIter(theNbIter);
1544 aFI.SetApprox(isApprox);
1545 aFI.SetMethod(theMethod);
1547 //Compute the Solid value
1550 if (!GetSolver()->ComputeFunction(aFunction)) {
1551 SetErrorCode("Filling driver failed");
1555 catch (Standard_Failure) {
1556 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1557 if (strcmp(aFail->GetMessageString(), "Geom_BSplineSurface") == 0)
1558 SetErrorCode("B-Spline surface construction failed");
1560 SetErrorCode(aFail->GetMessageString());
1564 //Make a Python command
1565 GEOM::TPythonDump pd (aFunction);
1566 pd << aFilling << " = geompy.MakeFilling(" << theShape ;
1567 if ( theMinDeg != 2 ) pd << ", theMinDeg=" << theMinDeg ;
1568 if ( theMaxDeg != 5 ) pd << ", theMaxDeg=" << theMaxDeg ;
1569 if ( fabs(theTol2D-0.0001) > Precision::Confusion() )
1570 pd << ", theTol2D=" << theTol2D ;
1571 if ( fabs(theTol3D-0.0001) > Precision::Confusion() )
1572 pd << ", theTol3D=" << theTol3D ;
1573 if ( theNbIter != 0 ) pd << ", theNbIter=" << theNbIter ;
1574 if ( theMethod==1 ) pd << ", theMethod=GEOM.FOM_UseOri";
1575 else if( theMethod==2 ) pd << ", theMethod=GEOM.FOM_AutoCorrect";
1576 if(isApprox) pd << ", isApprox=" << isApprox ;
1583 //=============================================================================
1587 //=============================================================================
1588 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeThruSections(
1589 const Handle(TColStd_HSequenceOfTransient)& theSeqSections,
1594 Handle(GEOM_Object) anObj;
1596 if(theSeqSections.IsNull())
1599 Standard_Integer nbObj = theSeqSections->Length();
1603 //Add a new ThruSections object
1604 Handle(GEOM_Object) aThruSect = GetEngine()->AddObject(GetDocID(), GEOM_THRUSECTIONS);
1607 //Add a new ThruSections function
1609 int aTypeFunc = (theRuled ? THRUSECTIONS_RULED : THRUSECTIONS_SMOOTHED);
1610 Handle(GEOM_Function) aFunction =
1611 aThruSect->AddFunction(GEOMImpl_ThruSectionsDriver::GetID(), aTypeFunc);
1612 if (aFunction.IsNull()) return anObj;
1614 //Check if the function is set correctly
1615 if (aFunction->GetDriverGUID() != GEOMImpl_ThruSectionsDriver::GetID()) return NULL;
1617 GEOMImpl_IThruSections aCI (aFunction);
1619 Handle(TColStd_HSequenceOfTransient) aSeqSections = new TColStd_HSequenceOfTransient;
1621 Standard_Integer i =1;
1622 for( ; i <= nbObj; i++) {
1624 Handle(Standard_Transient) anItem = theSeqSections->Value(i);
1628 Handle(GEOM_Object) aSectObj = Handle(GEOM_Object)::DownCast(anItem);
1629 if(!aSectObj.IsNull())
1631 Handle(GEOM_Function) aRefSect = aSectObj->GetLastFunction();
1632 if(!aRefSect.IsNull())
1633 aSeqSections->Append(aRefSect);
1637 if(!aSeqSections->Length())
1640 aCI.SetSections(aSeqSections);
1641 aCI.SetSolidMode(theModeSolid);
1642 aCI.SetPrecision(thePreci);
1644 //Compute the ThruSections value
1647 if (!GetSolver()->ComputeFunction(aFunction)) {
1648 SetErrorCode("ThruSections driver failed");
1652 catch (Standard_Failure) {
1653 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1654 SetErrorCode(aFail->GetMessageString());
1658 //Make a Python command
1659 GEOM::TPythonDump pyDump(aFunction);
1660 pyDump << aThruSect << " = geompy.MakeThruSections([";
1662 for(i =1 ; i <= nbObj; i++) {
1664 Handle(Standard_Transient) anItem = theSeqSections->Value(i);
1668 Handle(GEOM_Object) aSectObj = Handle(GEOM_Object)::DownCast(anItem);
1669 if(!aSectObj.IsNull()) {
1676 pyDump<< "],"<<theModeSolid << "," << thePreci <<","<< theRuled <<")";
1683 //=============================================================================
1685 * MakePipeWithDifferentSections
1687 //=============================================================================
1688 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePipeWithDifferentSections(
1689 const Handle(TColStd_HSequenceOfTransient)& theBases,
1690 const Handle(TColStd_HSequenceOfTransient)& theLocations,
1691 const Handle(GEOM_Object)& thePath,
1692 bool theWithContact,
1693 bool theWithCorrections)
1695 Handle(GEOM_Object) anObj;
1697 if(theBases.IsNull())
1700 Standard_Integer nbBases = theBases->Length();
1705 Standard_Integer nbLocs = (theLocations.IsNull() ? 0 :theLocations->Length());
1706 //Add a new Pipe object
1707 Handle(GEOM_Object) aPipeDS = GetEngine()->AddObject(GetDocID(), GEOM_PIPE);
1709 //Add a new Pipe function
1711 Handle(GEOM_Function) aFunction =
1712 aPipeDS->AddFunction(GEOMImpl_PipeDriver::GetID(), PIPE_DIFFERENT_SECTIONS);
1713 if (aFunction.IsNull()) return anObj;
1715 //Check if the function is set correctly
1716 if (aFunction->GetDriverGUID() != GEOMImpl_PipeDriver::GetID()) return anObj;
1718 GEOMImpl_IPipeDiffSect aCI (aFunction);
1720 Handle(GEOM_Function) aRefPath = thePath->GetLastFunction();
1721 if(aRefPath.IsNull())
1724 Handle(TColStd_HSequenceOfTransient) aSeqBases = new TColStd_HSequenceOfTransient;
1725 Handle(TColStd_HSequenceOfTransient) aSeqLocs = new TColStd_HSequenceOfTransient;
1727 Standard_Integer i =1;
1728 for( ; i <= nbBases; i++) {
1730 Handle(Standard_Transient) anItem = theBases->Value(i);
1734 Handle(GEOM_Object) aBase = Handle(GEOM_Object)::DownCast(anItem);
1737 Handle(GEOM_Function) aRefBase = aBase->GetLastFunction();
1738 if(aRefBase.IsNull())
1742 Handle(Standard_Transient) anItemLoc = theLocations->Value(i);
1743 if(anItemLoc.IsNull())
1746 Handle(GEOM_Object) aLoc = Handle(GEOM_Object)::DownCast(anItemLoc);
1749 Handle(GEOM_Function) aRefLoc = aLoc->GetLastFunction();
1750 if(aRefLoc.IsNull())
1752 aSeqLocs->Append(aRefLoc);
1754 aSeqBases->Append(aRefBase);
1757 if(!aSeqBases->Length())
1760 aCI.SetBases(aSeqBases);
1761 aCI.SetLocations(aSeqLocs);
1762 aCI.SetPath(aRefPath);
1763 aCI.SetWithContactMode(theWithContact);
1764 aCI.SetWithCorrectionMode(theWithCorrections);
1766 //Compute the Pipe value
1769 if (!GetSolver()->ComputeFunction(aFunction)) {
1770 SetErrorCode("Pipe with defferent section driver failed");
1774 catch (Standard_Failure) {
1775 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1776 SetErrorCode(aFail->GetMessageString());
1780 //Make a Python command
1781 GEOM::TPythonDump pyDump(aFunction);
1782 pyDump << aPipeDS << " = geompy.MakePipeWithDifferentSections([";
1784 for(i =1 ; i <= nbBases; i++) {
1786 Handle(Standard_Transient) anItem = theBases->Value(i);
1790 Handle(GEOM_Object) anObj = Handle(GEOM_Object)::DownCast(anItem);
1791 if(!anObj.IsNull()) {
1800 for(i =1 ; i <= nbLocs; i++) {
1802 Handle(Standard_Transient) anItem = theLocations->Value(i);
1806 Handle(GEOM_Object) anObj = Handle(GEOM_Object)::DownCast(anItem);
1807 if(!anObj.IsNull()) {
1814 pyDump<< "], "<<thePath<<","<<theWithContact << "," << theWithCorrections<<")";
1821 //=============================================================================
1823 * MakePipeWithShellSections
1825 //=============================================================================
1826 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePipeWithShellSections(
1827 const Handle(TColStd_HSequenceOfTransient)& theBases,
1828 const Handle(TColStd_HSequenceOfTransient)& theSubBases,
1829 const Handle(TColStd_HSequenceOfTransient)& theLocations,
1830 const Handle(GEOM_Object)& thePath,
1831 bool theWithContact,
1832 bool theWithCorrections)
1834 Handle(GEOM_Object) anObj;
1836 if(theBases.IsNull())
1839 Standard_Integer nbBases = theBases->Length();
1844 Standard_Integer nbSubBases = (theSubBases.IsNull() ? 0 :theSubBases->Length());
1846 Standard_Integer nbLocs = (theLocations.IsNull() ? 0 :theLocations->Length());
1848 //Add a new Pipe object
1849 Handle(GEOM_Object) aPipeDS = GetEngine()->AddObject(GetDocID(), GEOM_PIPE);
1851 //Add a new Pipe function
1853 Handle(GEOM_Function) aFunction =
1854 aPipeDS->AddFunction(GEOMImpl_PipeDriver::GetID(), PIPE_SHELL_SECTIONS);
1855 if (aFunction.IsNull()) return anObj;
1857 //Check if the function is set correctly
1858 if (aFunction->GetDriverGUID() != GEOMImpl_PipeDriver::GetID()) return anObj;
1860 //GEOMImpl_IPipeDiffSect aCI (aFunction);
1861 GEOMImpl_IPipeShellSect aCI (aFunction);
1863 Handle(GEOM_Function) aRefPath = thePath->GetLastFunction();
1864 if(aRefPath.IsNull())
1867 Handle(TColStd_HSequenceOfTransient) aSeqBases = new TColStd_HSequenceOfTransient;
1868 Handle(TColStd_HSequenceOfTransient) aSeqSubBases = new TColStd_HSequenceOfTransient;
1869 Handle(TColStd_HSequenceOfTransient) aSeqLocs = new TColStd_HSequenceOfTransient;
1871 Standard_Integer i =1;
1872 for( ; i <= nbBases; i++) {
1874 Handle(Standard_Transient) anItem = theBases->Value(i);
1877 Handle(GEOM_Object) aBase = Handle(GEOM_Object)::DownCast(anItem);
1880 Handle(GEOM_Function) aRefBase = aBase->GetLastFunction();
1881 if(aRefBase.IsNull())
1884 if( nbSubBases >= nbBases ) {
1885 Handle(Standard_Transient) aSubItem = theSubBases->Value(i);
1886 if(aSubItem.IsNull())
1888 Handle(GEOM_Object) aSubBase = Handle(GEOM_Object)::DownCast(aSubItem);
1889 if(aSubBase.IsNull())
1891 Handle(GEOM_Function) aRefSubBase = aSubBase->GetLastFunction();
1892 if(aRefSubBase.IsNull())
1894 aSeqSubBases->Append(aRefSubBase);
1898 Handle(Standard_Transient) anItemLoc = theLocations->Value(i);
1899 if(anItemLoc.IsNull())
1901 Handle(GEOM_Object) aLoc = Handle(GEOM_Object)::DownCast(anItemLoc);
1904 Handle(GEOM_Function) aRefLoc = aLoc->GetLastFunction();
1905 if(aRefLoc.IsNull())
1907 aSeqLocs->Append(aRefLoc);
1910 aSeqBases->Append(aRefBase);
1913 if(!aSeqBases->Length())
1916 aCI.SetBases(aSeqBases);
1917 aCI.SetSubBases(aSeqSubBases);
1918 aCI.SetLocations(aSeqLocs);
1919 aCI.SetPath(aRefPath);
1920 aCI.SetWithContactMode(theWithContact);
1921 aCI.SetWithCorrectionMode(theWithCorrections);
1923 //Compute the Pipe value
1926 if (!GetSolver()->ComputeFunction(aFunction)) {
1927 SetErrorCode("Pipe with shell sections driver failed");
1931 catch (Standard_Failure) {
1932 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1933 SetErrorCode(aFail->GetMessageString());
1937 //Make a Python command
1938 GEOM::TPythonDump pyDump(aFunction);
1939 pyDump << aPipeDS << " = geompy.MakePipeWithShellSections([";
1941 for(i =1 ; i <= nbBases; i++) {
1943 Handle(Standard_Transient) anItem = theBases->Value(i);
1947 Handle(GEOM_Object) anObj = Handle(GEOM_Object)::DownCast(anItem);
1948 if(!anObj.IsNull()) {
1957 for(i =1 ; i <= nbSubBases; i++) {
1959 Handle(Standard_Transient) anItem = theSubBases->Value(i);
1963 Handle(GEOM_Object) anObj = Handle(GEOM_Object)::DownCast(anItem);
1964 if(!anObj.IsNull()) {
1973 for(i =1 ; i <= nbLocs; i++) {
1975 Handle(Standard_Transient) anItem = theLocations->Value(i);
1979 Handle(GEOM_Object) anObj = Handle(GEOM_Object)::DownCast(anItem);
1980 if(!anObj.IsNull()) {
1987 pyDump<< "], "<<thePath<<","<<theWithContact << "," << theWithCorrections<<")";
1995 //=============================================================================
1997 * MakePipeShellsWithoutPath
1999 //=============================================================================
2000 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePipeShellsWithoutPath(
2001 const Handle(TColStd_HSequenceOfTransient)& theBases,
2002 const Handle(TColStd_HSequenceOfTransient)& theLocations)
2004 Handle(GEOM_Object) anObj;
2006 if(theBases.IsNull())
2009 Standard_Integer nbBases = theBases->Length();
2014 Standard_Integer nbLocs = (theLocations.IsNull() ? 0 :theLocations->Length());
2016 //Add a new Pipe object
2017 Handle(GEOM_Object) aPipeDS = GetEngine()->AddObject(GetDocID(), GEOM_PIPE);
2019 //Add a new Pipe function
2021 Handle(GEOM_Function) aFunction =
2022 aPipeDS->AddFunction(GEOMImpl_PipeDriver::GetID(), PIPE_SHELLS_WITHOUT_PATH);
2023 if (aFunction.IsNull()) return anObj;
2025 //Check if the function is set correctly
2026 if (aFunction->GetDriverGUID() != GEOMImpl_PipeDriver::GetID()) return anObj;
2028 GEOMImpl_IPipeShellSect aCI (aFunction);
2030 Handle(TColStd_HSequenceOfTransient) aSeqBases = new TColStd_HSequenceOfTransient;
2031 Handle(TColStd_HSequenceOfTransient) aSeqLocs = new TColStd_HSequenceOfTransient;
2033 Standard_Integer i =1;
2034 for( ; i <= nbBases; i++) {
2036 Handle(Standard_Transient) anItem = theBases->Value(i);
2039 Handle(GEOM_Object) aBase = Handle(GEOM_Object)::DownCast(anItem);
2042 Handle(GEOM_Function) aRefBase = aBase->GetLastFunction();
2043 if(aRefBase.IsNull())
2047 Handle(Standard_Transient) anItemLoc = theLocations->Value(i);
2048 if(anItemLoc.IsNull())
2050 Handle(GEOM_Object) aLoc = Handle(GEOM_Object)::DownCast(anItemLoc);
2053 Handle(GEOM_Function) aRefLoc = aLoc->GetLastFunction();
2054 if(aRefLoc.IsNull())
2056 aSeqLocs->Append(aRefLoc);
2059 aSeqBases->Append(aRefBase);
2062 if(!aSeqBases->Length())
2065 aCI.SetBases(aSeqBases);
2066 aCI.SetLocations(aSeqLocs);
2068 //Compute the Pipe value
2071 if (!GetSolver()->ComputeFunction(aFunction)) {
2072 SetErrorCode("Pipe with shell sections without path driver failed");
2076 catch (Standard_Failure) {
2077 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
2078 SetErrorCode(aFail->GetMessageString());
2082 //Make a Python command
2083 GEOM::TPythonDump pyDump(aFunction);
2084 pyDump << aPipeDS << " = geompy.MakePipeShellsWithoutPath([";
2086 for(i =1 ; i <= nbBases; i++) {
2088 Handle(Standard_Transient) anItem = theBases->Value(i);
2092 Handle(GEOM_Object) anObj = Handle(GEOM_Object)::DownCast(anItem);
2093 if(!anObj.IsNull()) {
2102 for(i =1 ; i <= nbLocs; i++) {
2104 Handle(Standard_Transient) anItem = theLocations->Value(i);
2108 Handle(GEOM_Object) anObj = Handle(GEOM_Object)::DownCast(anItem);
2109 if(!anObj.IsNull()) {
2123 //=============================================================================
2125 * MakePipeBiNormalAlongVector
2127 //=============================================================================
2128 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePipeBiNormalAlongVector (Handle(GEOM_Object) theBase,
2129 Handle(GEOM_Object) thePath,
2130 Handle(GEOM_Object) theVec)
2134 if (theBase.IsNull() || thePath.IsNull() || theVec.IsNull()) return NULL;
2136 //Add a new Pipe object
2137 Handle(GEOM_Object) aPipe = GetEngine()->AddObject(GetDocID(), GEOM_PIPE);
2139 //Add a new Pipe function
2140 Handle(GEOM_Function) aFunction =
2141 aPipe->AddFunction(GEOMImpl_PipeDriver::GetID(), PIPE_BI_NORMAL_ALONG_VECTOR);
2142 if (aFunction.IsNull()) return NULL;
2144 //Check if the function is set correctly
2145 if (aFunction->GetDriverGUID() != GEOMImpl_PipeDriver::GetID()) return NULL;
2147 GEOMImpl_IPipeBiNormal aCI (aFunction);
2149 Handle(GEOM_Function) aRefBase = theBase->GetLastFunction();
2150 Handle(GEOM_Function) aRefPath = thePath->GetLastFunction();
2151 Handle(GEOM_Function) aRefVec = theVec->GetLastFunction();
2153 if (aRefBase.IsNull() || aRefPath.IsNull() || aRefVec.IsNull()) return NULL;
2155 aCI.SetBase(aRefBase);
2156 aCI.SetPath(aRefPath);
2157 aCI.SetVector(aRefVec);
2159 //Compute the Pipe value
2162 if (!GetSolver()->ComputeFunction(aFunction)) {
2163 SetErrorCode("Pipe driver failed");
2167 catch (Standard_Failure) {
2168 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
2169 SetErrorCode(aFail->GetMessageString());
2173 //Make a Python command
2174 GEOM::TPythonDump(aFunction) << aPipe << " = geompy.MakePipeBiNormalAlongVector("
2175 << theBase << ", " << thePath << ", " << theVec << ")";
2181 //=============================================================================
2185 //=============================================================================
2186 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeThickening(Handle(GEOM_Object) theObject,
2192 if (theObject.IsNull()) return NULL;
2194 Handle(GEOM_Function) anOriginal = theObject->GetLastFunction();
2195 if (anOriginal.IsNull()) return NULL; //There is no function which creates an object to be offset
2197 //Add a new Offset function
2198 Handle(GEOM_Function) aFunction;
2199 Handle(GEOM_Object) aCopy;
2202 //Add a new Copy object
2203 aCopy = GetEngine()->AddObject(GetDocID(), theObject->GetType());
2204 aFunction = aCopy->AddFunction(GEOMImpl_OffsetDriver::GetID(), OFFSET_THICKENING_COPY);
2207 aFunction = theObject->AddFunction(GEOMImpl_OffsetDriver::GetID(), OFFSET_THICKENING);
2209 if (aFunction.IsNull()) return NULL;
2211 //Check if the function is set correctly
2212 if (aFunction->GetDriverGUID() != GEOMImpl_OffsetDriver::GetID()) return NULL;
2214 GEOMImpl_IOffset aTI (aFunction);
2215 aTI.SetShape(anOriginal);
2216 aTI.SetValue(theOffset);
2218 //Compute the offset
2221 if (!GetSolver()->ComputeFunction(aFunction)) {
2222 SetErrorCode("Offset driver failed");
2226 catch (Standard_Failure) {
2227 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
2228 SetErrorCode(aFail->GetMessageString());
2232 //Make a Python command
2235 GEOM::TPythonDump(aFunction) << aCopy << " = geompy.MakeThickSolid("
2236 << theObject << ", " << theOffset << ")";
2242 GEOM::TPythonDump(aFunction) << "geompy.Thicken("
2243 << theObject << ", " << theOffset << ")";
2249 //=============================================================================
2253 //=============================================================================
2254 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::RestorePath (Handle(GEOM_Object) theShape,
2255 Handle(GEOM_Object) theBase1,
2256 Handle(GEOM_Object) theBase2)
2260 if (theShape.IsNull() || theBase1.IsNull() || theBase2.IsNull()) return NULL;
2262 // Add a new Path object
2263 Handle(GEOM_Object) aPath = GetEngine()->AddObject(GetDocID(), GEOM_PIPE_PATH);
2265 // Add a new Path function
2266 Handle(GEOM_Function) aFunction =
2267 aPath->AddFunction(GEOMImpl_PipePathDriver::GetID(), PIPE_PATH_TWO_BASES);
2268 if (aFunction.IsNull()) return NULL;
2270 // Check if the function is set correctly
2271 if (aFunction->GetDriverGUID() != GEOMImpl_PipePathDriver::GetID()) return NULL;
2273 GEOMImpl_IPipePath aCI (aFunction);
2275 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
2276 Handle(GEOM_Function) aRefBase1 = theBase1->GetLastFunction();
2277 Handle(GEOM_Function) aRefBase2 = theBase2->GetLastFunction();
2279 if (aRefShape.IsNull() || aRefBase1.IsNull() || aRefBase2.IsNull()) return NULL;
2281 aCI.SetShape(aRefShape);
2282 aCI.SetBase1(aRefBase1);
2283 aCI.SetBase2(aRefBase2);
2285 // Compute the Path value
2288 if (!GetSolver()->ComputeFunction(aFunction)) {
2289 SetErrorCode("PipePath driver failed");
2293 catch (Standard_Failure) {
2294 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
2295 SetErrorCode("RestorePath: inappropriate arguments given");
2299 // Make a Python command
2300 GEOM::TPythonDump(aFunction) << aPath << " = geompy.RestorePath("
2301 << theShape << ", " << theBase1 << ", " << theBase2 << ")";
2307 //=============================================================================
2311 //=============================================================================
2312 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::RestorePath
2313 (Handle(GEOM_Object) theShape,
2314 const Handle(TColStd_HSequenceOfTransient)& theBase1,
2315 const Handle(TColStd_HSequenceOfTransient)& theBase2)
2319 if (theShape.IsNull() || theBase1.IsNull() || theBase2.IsNull()) return NULL;
2321 Standard_Integer nbBases1 = theBase1->Length();
2322 Standard_Integer nbBases2 = theBase2->Length();
2324 if (!nbBases1 || !nbBases2)
2327 // Add a new Path object
2328 Handle(GEOM_Object) aPath = GetEngine()->AddObject(GetDocID(), GEOM_PIPE_PATH);
2330 // Add a new Path function
2331 Handle(GEOM_Function) aFunction =
2332 aPath->AddFunction(GEOMImpl_PipePathDriver::GetID(), PIPE_PATH_TWO_SEQS);
2333 if (aFunction.IsNull()) return NULL;
2335 // Check if the function is set correctly
2336 if (aFunction->GetDriverGUID() != GEOMImpl_PipePathDriver::GetID()) return NULL;
2338 GEOMImpl_IPipePath aCI (aFunction);
2340 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
2341 if (aRefShape.IsNull()) return NULL;
2343 Handle(TColStd_HSequenceOfTransient) aSeqBases1 = new TColStd_HSequenceOfTransient;
2344 Handle(TColStd_HSequenceOfTransient) aSeqBases2 = new TColStd_HSequenceOfTransient;
2347 for (i = 1; i <= nbBases1; i++) {
2348 Handle(Standard_Transient) anItem = theBase1->Value(i);
2349 if (!anItem.IsNull()) {
2350 Handle(GEOM_Object) aBase = Handle(GEOM_Object)::DownCast(anItem);
2351 if (!aBase.IsNull()) {
2352 Handle(GEOM_Function) aRefBase = aBase->GetLastFunction();
2353 if (!aRefBase.IsNull())
2354 aSeqBases1->Append(aRefBase);
2358 for (i = 1; i <= nbBases2; i++) {
2359 Handle(Standard_Transient) anItem = theBase2->Value(i);
2360 if (!anItem.IsNull()) {
2361 Handle(GEOM_Object) aBase = Handle(GEOM_Object)::DownCast(anItem);
2362 if (!aBase.IsNull()) {
2363 Handle(GEOM_Function) aRefBase = aBase->GetLastFunction();
2364 if (!aRefBase.IsNull())
2365 aSeqBases2->Append(aRefBase);
2369 if (!aSeqBases1->Length() || !aSeqBases2->Length()) return NULL;
2371 aCI.SetShape(aRefShape);
2372 aCI.SetBaseSeq1(aSeqBases1);
2373 aCI.SetBaseSeq2(aSeqBases2);
2375 // Compute the Path value
2378 if (!GetSolver()->ComputeFunction(aFunction)) {
2379 SetErrorCode("PipePath driver failed");
2383 catch (Standard_Failure) {
2384 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
2385 SetErrorCode("RestorePath: inappropriate arguments given");
2389 // Make a Python command
2390 GEOM::TPythonDump pyDump (aFunction);
2391 pyDump << aPath << " = geompy.RestorePathEdges(" << theShape << ", [";
2392 for (i = 1; i <= nbBases1; i++) {
2393 Handle(GEOM_Object) anObj = Handle(GEOM_Object)::DownCast(theBase1->Value(i));
2394 if (!anObj.IsNull()) {
2401 for (i = 1; i <= nbBases2; i++) {
2402 Handle(GEOM_Object) anObj = Handle(GEOM_Object)::DownCast(theBase2->Value(i));
2403 if (!anObj.IsNull()) {