1 // Copyright (C) 2007-2016 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 <TDF_Tool.hxx>
37 #include <GEOM_Function.hxx>
38 #include <GEOM_PythonDump.hxx>
40 #include <GEOMImpl_Types.hxx>
42 #include <GEOMImpl_BoxDriver.hxx>
43 #include <GEOMImpl_FaceDriver.hxx>
44 #include <GEOMImpl_DiskDriver.hxx>
45 #include <GEOMImpl_CylinderDriver.hxx>
46 #include <GEOMImpl_ConeDriver.hxx>
47 #include <GEOMImpl_SphereDriver.hxx>
48 #include <GEOMImpl_TorusDriver.hxx>
49 #include <GEOMImpl_PrismDriver.hxx>
50 #include <GEOMImpl_PipeDriver.hxx>
51 #include <GEOMImpl_PipePathDriver.hxx>
52 #include <GEOMImpl_RevolutionDriver.hxx>
53 #include <GEOMImpl_ShapeDriver.hxx>
54 #include <GEOMImpl_FillingDriver.hxx>
55 #include <GEOMImpl_ThruSectionsDriver.hxx>
56 #include <GEOMImpl_OffsetDriver.hxx>
58 #include <GEOMImpl_IBox.hxx>
59 #include <GEOMImpl_IFace.hxx>
60 #include <GEOMImpl_IDisk.hxx>
61 #include <GEOMImpl_ICylinder.hxx>
62 #include <GEOMImpl_ICone.hxx>
63 #include <GEOMImpl_IGroupOperations.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>
80 #include <Standard_Failure.hxx>
81 #include <Standard_ErrorHandler.hxx> // CAREFUL ! position of this file is critic : see Lucien PIGNOLONI / OCC
83 //=============================================================================
87 //=============================================================================
88 GEOMImpl_I3DPrimOperations::GEOMImpl_I3DPrimOperations (GEOM_Engine* theEngine, int theDocID)
89 : GEOM_IOperations(theEngine, theDocID)
91 MESSAGE("GEOMImpl_I3DPrimOperations::GEOMImpl_I3DPrimOperations");
92 myGroupOperations = new GEOMImpl_IGroupOperations(GetEngine(), GetDocID());
95 //=============================================================================
99 //=============================================================================
100 GEOMImpl_I3DPrimOperations::~GEOMImpl_I3DPrimOperations()
102 MESSAGE("GEOMImpl_I3DPrimOperations::~GEOMImpl_I3DPrimOperations");
103 delete myGroupOperations;
107 //=============================================================================
111 //=============================================================================
112 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeBoxDXDYDZ (double theDX, double theDY, double theDZ)
116 //Add a new Box object
117 Handle(GEOM_Object) aBox = GetEngine()->AddObject(GetDocID(), GEOM_BOX);
119 //Add a new Box function with DX_DY_DZ parameters
120 Handle(GEOM_Function) aFunction = aBox->AddFunction(GEOMImpl_BoxDriver::GetID(), BOX_DX_DY_DZ);
121 if (aFunction.IsNull()) return NULL;
123 //Check if the function is set correctly
124 if (aFunction->GetDriverGUID() != GEOMImpl_BoxDriver::GetID()) return NULL;
126 GEOMImpl_IBox aBI (aFunction);
132 //Compute the box value
135 if (!GetSolver()->ComputeFunction(aFunction)) {
136 SetErrorCode("Box driver failed");
140 catch (Standard_Failure) {
141 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
142 SetErrorCode(aFail->GetMessageString());
146 //Make a Python command
147 GEOM::TPythonDump(aFunction) << aBox << " = geompy.MakeBoxDXDYDZ("
148 << theDX << ", " << theDY << ", " << theDZ << ")";
155 //=============================================================================
159 //=============================================================================
160 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeBoxTwoPnt (Handle(GEOM_Object) thePnt1,
161 Handle(GEOM_Object) thePnt2)
165 if (thePnt1.IsNull() || thePnt2.IsNull()) return NULL;
167 //Add a new Box object
168 Handle(GEOM_Object) aBox = GetEngine()->AddObject(GetDocID(), GEOM_BOX);
170 //Add a new Box function for creation a box relatively to two points
171 Handle(GEOM_Function) aFunction = aBox->AddFunction(GEOMImpl_BoxDriver::GetID(), BOX_TWO_PNT);
172 if (aFunction.IsNull()) return NULL;
174 //Check if the function is set correctly
175 if (aFunction->GetDriverGUID() != GEOMImpl_BoxDriver::GetID()) return aBox;
177 GEOMImpl_IBox aBI (aFunction);
179 Handle(GEOM_Function) aRefFunction1 = thePnt1->GetLastFunction();
180 Handle(GEOM_Function) aRefFunction2 = thePnt2->GetLastFunction();
182 if (aRefFunction1.IsNull() || aRefFunction2.IsNull()) return aBox;
184 aBI.SetRef1(aRefFunction1);
185 aBI.SetRef2(aRefFunction2);
187 //Compute the Box value
190 if (!GetSolver()->ComputeFunction(aFunction)) {
191 SetErrorCode("Box driver failed");
195 catch (Standard_Failure) {
196 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
197 SetErrorCode(aFail->GetMessageString());
201 //Make a Python command
202 GEOM::TPythonDump(aFunction) << aBox << " = geompy.MakeBoxTwoPnt("
203 << thePnt1 << ", " << thePnt2 << ")";
209 //=============================================================================
213 //=============================================================================
214 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeFaceHW (double theH, double theW, int theOrientation)
218 if (theH == 0 || theW == 0) return NULL;
220 //Add a new Face object
221 Handle(GEOM_Object) aFace = GetEngine()->AddObject(GetDocID(), GEOM_FACE);
223 //Add a new Box function for creation a box relatively to two points
224 Handle(GEOM_Function) aFunction = aFace->AddFunction(GEOMImpl_FaceDriver::GetID(), FACE_H_W);
225 if (aFunction.IsNull()) return NULL;
227 //Check if the function is set correctly
228 if (aFunction->GetDriverGUID() != GEOMImpl_FaceDriver::GetID()) return aFace;
230 GEOMImpl_IFace aFI (aFunction);
234 aFI.SetOrientation(theOrientation);
239 if (!GetSolver()->ComputeFunction(aFunction)) {
240 SetErrorCode("Face driver failed");
244 catch (Standard_Failure) {
245 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
246 SetErrorCode(aFail->GetMessageString());
250 //Make a Python command
251 GEOM::TPythonDump(aFunction) << aFace << " = geompy.MakeFaceHW("
252 << theH << ", " << theW << ", " << theOrientation << ")";
258 //=============================================================================
262 //=============================================================================
263 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeFaceObjHW (Handle(GEOM_Object) theObj,
264 double theH, double theW)
268 if (theObj.IsNull()) return NULL;
270 //Add a new Face object
271 Handle(GEOM_Object) aFace = GetEngine()->AddObject(GetDocID(), GEOM_FACE);
273 //Add a new Box function for creation a box relatively to two points
274 Handle(GEOM_Function) aFunction = aFace->AddFunction(GEOMImpl_FaceDriver::GetID(), FACE_OBJ_H_W);
275 if (aFunction.IsNull()) return NULL;
277 //Check if the function is set correctly
278 if (aFunction->GetDriverGUID() != GEOMImpl_FaceDriver::GetID()) return aFace;
280 GEOMImpl_IFace aFI (aFunction);
282 Handle(GEOM_Function) aRefFunction1 = theObj->GetLastFunction();
284 if (aRefFunction1.IsNull())
287 aFI.SetRef1(aRefFunction1);
294 if (!GetSolver()->ComputeFunction(aFunction)) {
295 SetErrorCode("Face driver failed");
299 catch (Standard_Failure) {
300 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
301 SetErrorCode(aFail->GetMessageString());
305 //Make a Python command
306 GEOM::TPythonDump(aFunction) << aFace << " = geompy.MakeFaceObjHW("
307 << theObj << ", " << theH << ", " << theW << ")";
313 //=============================================================================
317 //=============================================================================
318 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeDiskPntVecR
319 (Handle(GEOM_Object) thePnt, Handle(GEOM_Object) theVec, double theR)
323 if (thePnt.IsNull() || theVec.IsNull()) return NULL;
325 //Add a new Disk object
326 Handle(GEOM_Object) aDisk = GetEngine()->AddObject(GetDocID(), GEOM_FACE);
328 //Add a new Disk function for creation a disk relatively to point and vector
329 Handle(GEOM_Function) aFunction =
330 aDisk->AddFunction(GEOMImpl_DiskDriver::GetID(), DISK_PNT_VEC_R);
331 if (aFunction.IsNull()) return NULL;
333 //Check if the function is set correctly
334 if (aFunction->GetDriverGUID() != GEOMImpl_DiskDriver::GetID()) return NULL;
336 GEOMImpl_IDisk aCI (aFunction);
338 Handle(GEOM_Function) aRefPnt = thePnt->GetLastFunction();
339 Handle(GEOM_Function) aRefVec = theVec->GetLastFunction();
341 if (aRefPnt.IsNull() || aRefVec.IsNull()) return NULL;
343 aCI.SetCenter(aRefPnt);
344 aCI.SetVector(aRefVec);
347 //Compute the Disk value
350 if (!GetSolver()->ComputeFunction(aFunction)) {
351 SetErrorCode("Disk driver failed");
355 catch (Standard_Failure) {
356 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
357 SetErrorCode(aFail->GetMessageString());
361 //Make a Python command
362 GEOM::TPythonDump(aFunction) << aDisk << " = geompy.MakeDiskPntVecR("
363 << thePnt << ", " << theVec << ", " << theR << ")";
369 //=============================================================================
373 //=============================================================================
374 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeDiskThreePnt (Handle(GEOM_Object) thePnt1,
375 Handle(GEOM_Object) thePnt2,
376 Handle(GEOM_Object) thePnt3)
380 if (thePnt1.IsNull() || thePnt2.IsNull() || thePnt3.IsNull()) return NULL;
382 //Add a new Disk object
383 Handle(GEOM_Object) aDisk = GetEngine()->AddObject(GetDocID(), GEOM_FACE);
385 //Add a new Disk function for creation a disk relatively to three points
386 Handle(GEOM_Function) aFunction =
387 aDisk->AddFunction(GEOMImpl_DiskDriver::GetID(), DISK_THREE_PNT);
388 if (aFunction.IsNull()) return NULL;
390 //Check if the function is set correctly
391 if (aFunction->GetDriverGUID() != GEOMImpl_DiskDriver::GetID()) return NULL;
393 GEOMImpl_IDisk aCI (aFunction);
395 Handle(GEOM_Function) aRefPnt1 = thePnt1->GetLastFunction();
396 Handle(GEOM_Function) aRefPnt2 = thePnt2->GetLastFunction();
397 Handle(GEOM_Function) aRefPnt3 = thePnt3->GetLastFunction();
399 if (aRefPnt1.IsNull() || aRefPnt2.IsNull() || aRefPnt3.IsNull()) return NULL;
401 aCI.SetPoint1(aRefPnt1);
402 aCI.SetPoint2(aRefPnt2);
403 aCI.SetPoint3(aRefPnt3);
405 //Compute the Disk value
408 if (!GetSolver()->ComputeFunction(aFunction)) {
409 SetErrorCode("Disk driver failed");
413 catch (Standard_Failure) {
414 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
415 SetErrorCode(aFail->GetMessageString());
419 //Make a Python command
420 GEOM::TPythonDump(aFunction) << aDisk << " = geompy.MakeDiskThreePnt("
421 << thePnt1 << ", " << thePnt2 << ", " << thePnt3 << ")";
427 //=============================================================================
431 //=============================================================================
432 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeDiskR (double theR, int theOrientation)
436 if (theR == 0 ) return NULL;
438 //Add a new Disk object
439 Handle(GEOM_Object) aDisk = GetEngine()->AddObject(GetDocID(), GEOM_FACE);
441 //Add a new Box function for creation a box relatively to two points
442 Handle(GEOM_Function) aFunction = aDisk->AddFunction(GEOMImpl_DiskDriver::GetID(), DISK_R);
443 if (aFunction.IsNull()) return NULL;
445 //Check if the function is set correctly
446 if (aFunction->GetDriverGUID() != GEOMImpl_DiskDriver::GetID()) return aDisk;
448 GEOMImpl_IDisk aDI (aFunction);
451 aDI.SetOrientation(theOrientation);
456 if (!GetSolver()->ComputeFunction(aFunction)) {
457 SetErrorCode("Disk driver failed");
461 catch (Standard_Failure) {
462 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
463 SetErrorCode(aFail->GetMessageString());
467 //Make a Python command
468 GEOM::TPythonDump(aFunction) << aDisk << " = geompy.MakeDiskR("
469 << theR << ", " << theOrientation << ")";
475 //=============================================================================
479 //=============================================================================
480 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeCylinderRH (double theR, double theH)
484 //Add a new Cylinder object
485 Handle(GEOM_Object) aCylinder = GetEngine()->AddObject(GetDocID(), GEOM_CYLINDER);
487 //Add a new Cylinder function with R and H parameters
488 Handle(GEOM_Function) aFunction = aCylinder->AddFunction(GEOMImpl_CylinderDriver::GetID(), CYLINDER_R_H);
489 if (aFunction.IsNull()) return NULL;
491 //Check if the function is set correctly
492 if (aFunction->GetDriverGUID() != GEOMImpl_CylinderDriver::GetID()) return NULL;
494 GEOMImpl_ICylinder aCI (aFunction);
499 //Compute the Cylinder value
502 if (!GetSolver()->ComputeFunction(aFunction)) {
503 SetErrorCode("Cylinder driver failed");
507 catch (Standard_Failure) {
508 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
509 SetErrorCode(aFail->GetMessageString());
513 //Make a Python command
514 GEOM::TPythonDump(aFunction) << aCylinder
515 << " = geompy.MakeCylinderRH(" << theR << ", " << theH << ")";
521 //=============================================================================
525 //=============================================================================
526 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeCylinderRHA (double theR, double theH, double theA)
530 //Add a new Cylinder object
531 Handle(GEOM_Object) aCylinder = GetEngine()->AddObject(GetDocID(), GEOM_CYLINDER);
533 //Add a new Cylinder function with R and H parameters
534 Handle(GEOM_Function) aFunction = aCylinder->AddFunction(GEOMImpl_CylinderDriver::GetID(), CYLINDER_R_H_A);
535 if (aFunction.IsNull()) return NULL;
537 //Check if the function is set correctly
538 if (aFunction->GetDriverGUID() != GEOMImpl_CylinderDriver::GetID()) return NULL;
540 GEOMImpl_ICylinder aCI (aFunction);
546 //Compute the Cylinder value
549 if (!GetSolver()->ComputeFunction(aFunction)) {
550 SetErrorCode("Cylinder driver failed");
554 catch (Standard_Failure) {
555 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
556 SetErrorCode(aFail->GetMessageString());
560 //Make a Python command
561 GEOM::TPythonDump(aFunction) << aCylinder
562 << " = geompy.MakeCylinderRHA(" << theR << ", " << theH << ", " << theA*180./M_PI << "*math.pi/180.)";
568 //=============================================================================
570 * MakeCylinderPntVecRH
572 //=============================================================================
573 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeCylinderPntVecRH (Handle(GEOM_Object) thePnt,
574 Handle(GEOM_Object) theVec,
575 double theR, double theH)
579 if (thePnt.IsNull() || theVec.IsNull()) return NULL;
581 //Add a new Cylinder object
582 Handle(GEOM_Object) aCylinder = GetEngine()->AddObject(GetDocID(), GEOM_CYLINDER);
584 //Add a new Cylinder function for creation a cylinder relatively to point and vector
585 Handle(GEOM_Function) aFunction =
586 aCylinder->AddFunction(GEOMImpl_CylinderDriver::GetID(), CYLINDER_PNT_VEC_R_H);
587 if (aFunction.IsNull()) return NULL;
589 //Check if the function is set correctly
590 if (aFunction->GetDriverGUID() != GEOMImpl_CylinderDriver::GetID()) return NULL;
592 GEOMImpl_ICylinder aCI (aFunction);
594 Handle(GEOM_Function) aRefPnt = thePnt->GetLastFunction();
595 Handle(GEOM_Function) aRefVec = theVec->GetLastFunction();
597 if (aRefPnt.IsNull() || aRefVec.IsNull()) return NULL;
599 aCI.SetPoint(aRefPnt);
600 aCI.SetVector(aRefVec);
604 //Compute the Cylinder value
607 if (!GetSolver()->ComputeFunction(aFunction)) {
608 SetErrorCode("Cylinder driver failed");
612 catch (Standard_Failure) {
613 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
614 SetErrorCode(aFail->GetMessageString());
618 //Make a Python command
619 GEOM::TPythonDump(aFunction) << aCylinder << " = geompy.MakeCylinder("
620 << thePnt << ", " << theVec << ", " << theR << ", " << theH << ")";
626 //=============================================================================
628 * MakeCylinderPntVecRHA
630 //=============================================================================
631 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeCylinderPntVecRHA (Handle(GEOM_Object) thePnt,
632 Handle(GEOM_Object) theVec,
633 double theR, double theH, double theA)
637 if (thePnt.IsNull() || theVec.IsNull()) return NULL;
639 //Add a new Cylinder object
640 Handle(GEOM_Object) aCylinder = GetEngine()->AddObject(GetDocID(), GEOM_CYLINDER);
642 //Add a new Cylinder function for creation a cylinder relatively to point and vector
643 Handle(GEOM_Function) aFunction =
644 aCylinder->AddFunction(GEOMImpl_CylinderDriver::GetID(), CYLINDER_PNT_VEC_R_H_A);
645 if (aFunction.IsNull()) return NULL;
647 //Check if the function is set correctly
648 if (aFunction->GetDriverGUID() != GEOMImpl_CylinderDriver::GetID()) return NULL;
650 GEOMImpl_ICylinder aCI (aFunction);
652 Handle(GEOM_Function) aRefPnt = thePnt->GetLastFunction();
653 Handle(GEOM_Function) aRefVec = theVec->GetLastFunction();
655 if (aRefPnt.IsNull() || aRefVec.IsNull()) return NULL;
657 aCI.SetPoint(aRefPnt);
658 aCI.SetVector(aRefVec);
663 //Compute the Cylinder value
666 if (!GetSolver()->ComputeFunction(aFunction)) {
667 SetErrorCode("Cylinder driver failed");
671 catch (Standard_Failure) {
672 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
673 SetErrorCode(aFail->GetMessageString());
677 //Make a Python command
678 GEOM::TPythonDump(aFunction) << aCylinder << " = geompy.MakeCylinderA("
679 << thePnt << ", " << theVec << ", " << theR << ", " << theH << ", " << theA*180./M_PI << "*math.pi/180.)";
686 //=============================================================================
690 //=============================================================================
691 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeConeR1R2H (double theR1, double theR2,
696 //Add a new Cone object
697 Handle(GEOM_Object) aCone = GetEngine()->AddObject(GetDocID(), GEOM_CONE);
699 //Add a new Cone function with R and H parameters
700 Handle(GEOM_Function) aFunction =
701 aCone->AddFunction(GEOMImpl_ConeDriver::GetID(), CONE_R1_R2_H);
702 if (aFunction.IsNull()) return NULL;
704 //Check if the function is set correctly
705 if (aFunction->GetDriverGUID() != GEOMImpl_ConeDriver::GetID()) return NULL;
707 GEOMImpl_ICone aCI (aFunction);
713 //Compute the Cone value
716 if (!GetSolver()->ComputeFunction(aFunction)) {
717 SetErrorCode("Cone driver failed");
721 catch (Standard_Failure) {
722 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
723 SetErrorCode(aFail->GetMessageString());
727 //Make a Python command
728 GEOM::TPythonDump(aFunction) << aCone << " = geompy.MakeConeR1R2H("
729 << theR1 << ", " << theR2 << ", " << theH << ")";
736 //=============================================================================
738 * MakeConePntVecR1R2H
740 //=============================================================================
741 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeConePntVecR1R2H (Handle(GEOM_Object) thePnt,
742 Handle(GEOM_Object) theVec,
743 double theR1, double theR2,
748 if (thePnt.IsNull() || theVec.IsNull()) return NULL;
750 //Add a new Cone object
751 Handle(GEOM_Object) aCone = GetEngine()->AddObject(GetDocID(), GEOM_CONE);
753 //Add a new Cone function for creation a cone relatively to point and vector
754 Handle(GEOM_Function) aFunction =
755 aCone->AddFunction(GEOMImpl_ConeDriver::GetID(), CONE_PNT_VEC_R1_R2_H);
756 if (aFunction.IsNull()) return NULL;
758 //Check if the function is set correctly
759 if (aFunction->GetDriverGUID() != GEOMImpl_ConeDriver::GetID()) return NULL;
761 GEOMImpl_ICone aCI (aFunction);
763 Handle(GEOM_Function) aRefPnt = thePnt->GetLastFunction();
764 Handle(GEOM_Function) aRefVec = theVec->GetLastFunction();
766 if (aRefPnt.IsNull() || aRefVec.IsNull()) return NULL;
768 aCI.SetPoint(aRefPnt);
769 aCI.SetVector(aRefVec);
774 //Compute the Cone value
777 if (!GetSolver()->ComputeFunction(aFunction)) {
778 SetErrorCode("Cone driver failed");
782 catch (Standard_Failure) {
783 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
784 SetErrorCode(aFail->GetMessageString());
788 //Make a Python command
789 GEOM::TPythonDump(aFunction) << aCone << " = geompy.MakeCone(" << thePnt
790 << ", " << theVec << ", " << theR1 << ", " << theR2 << ", " << theH << ")";
797 //=============================================================================
801 //=============================================================================
802 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeSphereR (double theR)
806 //Add a new Sphere object
807 Handle(GEOM_Object) aSphere = GetEngine()->AddObject(GetDocID(), GEOM_SPHERE);
809 //Add a new Sphere function with R parameter
810 Handle(GEOM_Function) aFunction = aSphere->AddFunction(GEOMImpl_SphereDriver::GetID(), SPHERE_R);
811 if (aFunction.IsNull()) return NULL;
813 //Check if the function is set correctly
814 if (aFunction->GetDriverGUID() != GEOMImpl_SphereDriver::GetID()) return NULL;
816 GEOMImpl_ISphere aCI (aFunction);
820 //Compute the Sphere value
823 if (!GetSolver()->ComputeFunction(aFunction)) {
824 SetErrorCode("Sphere driver failed");
828 catch (Standard_Failure) {
829 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
830 SetErrorCode(aFail->GetMessageString());
834 //Make a Python command
835 GEOM::TPythonDump(aFunction) << aSphere << " = geompy.MakeSphereR(" << theR << ")";
842 //=============================================================================
846 //=============================================================================
847 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeSpherePntR (Handle(GEOM_Object) thePnt,
852 if (thePnt.IsNull()) return NULL;
854 //Add a new Point object
855 Handle(GEOM_Object) aSphere = GetEngine()->AddObject(GetDocID(), GEOM_SPHERE);
857 //Add a new Sphere function for creation a sphere relatively to point
858 Handle(GEOM_Function) aFunction = aSphere->AddFunction(GEOMImpl_SphereDriver::GetID(), SPHERE_PNT_R);
859 if (aFunction.IsNull()) return NULL;
861 //Check if the function is set correctly
862 if (aFunction->GetDriverGUID() != GEOMImpl_SphereDriver::GetID()) return NULL;
864 GEOMImpl_ISphere aCI (aFunction);
866 Handle(GEOM_Function) aRefPnt = thePnt->GetLastFunction();
868 if (aRefPnt.IsNull()) return NULL;
870 aCI.SetPoint(aRefPnt);
873 //Compute the Sphere value
876 if (!GetSolver()->ComputeFunction(aFunction)) {
877 SetErrorCode("Sphere driver failed");
881 catch (Standard_Failure) {
882 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
883 SetErrorCode(aFail->GetMessageString());
887 //Make a Python command
888 GEOM::TPythonDump(aFunction) << aSphere
889 << " = geompy.MakeSpherePntR(" << thePnt << ", " << theR << ")";
896 //=============================================================================
900 //=============================================================================
901 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeTorusRR
902 (double theRMajor, double theRMinor)
906 //Add a new Torus object
907 Handle(GEOM_Object) anEll = GetEngine()->AddObject(GetDocID(), GEOM_TORUS);
909 //Add a new Torus function
910 Handle(GEOM_Function) aFunction =
911 anEll->AddFunction(GEOMImpl_TorusDriver::GetID(), TORUS_RR);
912 if (aFunction.IsNull()) return NULL;
914 //Check if the function is set correctly
915 if (aFunction->GetDriverGUID() != GEOMImpl_TorusDriver::GetID()) return NULL;
917 GEOMImpl_ITorus aCI (aFunction);
919 aCI.SetRMajor(theRMajor);
920 aCI.SetRMinor(theRMinor);
922 //Compute the Torus value
925 if (!GetSolver()->ComputeFunction(aFunction)) {
926 SetErrorCode("Torus driver failed");
930 catch (Standard_Failure) {
931 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
932 SetErrorCode(aFail->GetMessageString());
936 //Make a Python command
937 GEOM::TPythonDump(aFunction) << anEll << " = geompy.MakeTorusRR("
938 << theRMajor << ", " << theRMinor << ")";
944 //=============================================================================
948 //=============================================================================
949 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeTorusPntVecRR
950 (Handle(GEOM_Object) thePnt, Handle(GEOM_Object) theVec,
951 double theRMajor, double theRMinor)
955 if (thePnt.IsNull() || theVec.IsNull()) return NULL;
957 //Add a new Torus object
958 Handle(GEOM_Object) anEll = GetEngine()->AddObject(GetDocID(), GEOM_TORUS);
960 //Add a new Torus function
961 Handle(GEOM_Function) aFunction =
962 anEll->AddFunction(GEOMImpl_TorusDriver::GetID(), TORUS_PNT_VEC_RR);
963 if (aFunction.IsNull()) return NULL;
965 //Check if the function is set correctly
966 if (aFunction->GetDriverGUID() != GEOMImpl_TorusDriver::GetID()) return NULL;
968 GEOMImpl_ITorus aCI (aFunction);
970 Handle(GEOM_Function) aRefPnt = thePnt->GetLastFunction();
971 Handle(GEOM_Function) aRefVec = theVec->GetLastFunction();
973 if (aRefPnt.IsNull() || aRefVec.IsNull()) return NULL;
975 aCI.SetCenter(aRefPnt);
976 aCI.SetVector(aRefVec);
977 aCI.SetRMajor(theRMajor);
978 aCI.SetRMinor(theRMinor);
980 //Compute the Torus value
983 if (!GetSolver()->ComputeFunction(aFunction)) {
984 SetErrorCode("Torus driver failed");
988 catch (Standard_Failure) {
989 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
990 SetErrorCode(aFail->GetMessageString());
994 //Make a Python command
995 GEOM::TPythonDump(aFunction) << anEll << " = geompy.MakeTorus(" << thePnt
996 << ", " << theVec << ", " << theRMajor << ", " << theRMinor << ")";
1003 //=============================================================================
1007 //=============================================================================
1008 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePrismVecH (Handle(GEOM_Object) theBase,
1009 Handle(GEOM_Object) theVec,
1010 double theH, double theScaleFactor)
1014 if (theBase.IsNull() || theVec.IsNull()) return NULL;
1016 //Add a new Prism object
1017 Handle(GEOM_Object) aPrism = GetEngine()->AddObject(GetDocID(), GEOM_PRISM);
1019 //Add a new Prism function for creation a Prism relatively to vector
1020 Handle(GEOM_Function) aFunction =
1021 aPrism->AddFunction(GEOMImpl_PrismDriver::GetID(), PRISM_BASE_VEC_H);
1022 if (aFunction.IsNull()) return NULL;
1024 //Check if the function is set correctly
1025 if (aFunction->GetDriverGUID() != GEOMImpl_PrismDriver::GetID()) return NULL;
1027 GEOMImpl_IPrism aCI (aFunction);
1029 Handle(GEOM_Function) aRefBase = theBase->GetLastFunction();
1030 Handle(GEOM_Function) aRefVec = theVec->GetLastFunction();
1032 if (aRefBase.IsNull() || aRefVec.IsNull()) return NULL;
1034 aCI.SetBase(aRefBase);
1035 aCI.SetVector(aRefVec);
1037 aCI.SetScale(theScaleFactor);
1039 //Compute the Prism value
1042 if (!GetSolver()->ComputeFunction(aFunction)) {
1043 //SetErrorCode("Prism driver failed");
1044 SetErrorCode("Extrusion can not be created, check input data");
1048 catch (Standard_Failure) {
1049 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1050 SetErrorCode(aFail->GetMessageString());
1054 //Make a Python command
1055 GEOM::TPythonDump pd (aFunction);
1056 pd << aPrism << " = geompy.MakePrismVecH(" << theBase << ", " << theVec << ", " << theH;
1057 if (theScaleFactor > Precision::Confusion())
1058 pd << ", " << theScaleFactor << ")";
1066 //=============================================================================
1068 * MakePrismVecH2Ways
1070 //=============================================================================
1071 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePrismVecH2Ways (Handle(GEOM_Object) theBase,
1072 Handle(GEOM_Object) theVec,
1077 if (theBase.IsNull() || theVec.IsNull()) return NULL;
1079 //Add a new Prism object
1080 Handle(GEOM_Object) aPrism = GetEngine()->AddObject(GetDocID(), GEOM_PRISM);
1082 //Add a new Prism function for creation a Prism relatively to vector
1083 Handle(GEOM_Function) aFunction =
1084 aPrism->AddFunction(GEOMImpl_PrismDriver::GetID(), PRISM_BASE_VEC_H_2WAYS);
1085 if (aFunction.IsNull()) return NULL;
1087 //Check if the function is set correctly
1088 if (aFunction->GetDriverGUID() != GEOMImpl_PrismDriver::GetID()) return NULL;
1090 GEOMImpl_IPrism aCI (aFunction);
1092 Handle(GEOM_Function) aRefBase = theBase->GetLastFunction();
1093 Handle(GEOM_Function) aRefVec = theVec->GetLastFunction();
1095 if (aRefBase.IsNull() || aRefVec.IsNull()) return NULL;
1097 aCI.SetBase(aRefBase);
1098 aCI.SetVector(aRefVec);
1101 //Compute the Prism value
1104 if (!GetSolver()->ComputeFunction(aFunction)) {
1105 //SetErrorCode("Prism driver failed");
1106 SetErrorCode("Extrusion can not be created, check input data");
1110 catch (Standard_Failure) {
1111 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1112 SetErrorCode(aFail->GetMessageString());
1116 //Make a Python command
1117 GEOM::TPythonDump(aFunction) << aPrism << " = geompy.MakePrismVecH2Ways("
1118 << theBase << ", " << theVec << ", " << theH << ")";
1124 //=============================================================================
1128 //=============================================================================
1129 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePrismTwoPnt
1130 (Handle(GEOM_Object) theBase,
1131 Handle(GEOM_Object) thePoint1, Handle(GEOM_Object) thePoint2,
1132 double theScaleFactor)
1136 if (theBase.IsNull() || thePoint1.IsNull() || thePoint2.IsNull()) return NULL;
1138 //Add a new Prism object
1139 Handle(GEOM_Object) aPrism = GetEngine()->AddObject(GetDocID(), GEOM_PRISM);
1141 //Add a new Prism function for creation a Prism relatively to two points
1142 Handle(GEOM_Function) aFunction =
1143 aPrism->AddFunction(GEOMImpl_PrismDriver::GetID(), PRISM_BASE_TWO_PNT);
1144 if (aFunction.IsNull()) return NULL;
1146 //Check if the function is set correctly
1147 if (aFunction->GetDriverGUID() != GEOMImpl_PrismDriver::GetID()) return NULL;
1149 GEOMImpl_IPrism aCI (aFunction);
1151 Handle(GEOM_Function) aRefBase = theBase->GetLastFunction();
1152 Handle(GEOM_Function) aRefPnt1 = thePoint1->GetLastFunction();
1153 Handle(GEOM_Function) aRefPnt2 = thePoint2->GetLastFunction();
1155 if (aRefBase.IsNull() || aRefPnt1.IsNull() || aRefPnt2.IsNull()) return NULL;
1157 aCI.SetBase(aRefBase);
1158 aCI.SetFirstPoint(aRefPnt1);
1159 aCI.SetLastPoint(aRefPnt2);
1160 aCI.SetScale(theScaleFactor);
1162 //Compute the Prism value
1165 if (!GetSolver()->ComputeFunction(aFunction)) {
1166 //SetErrorCode("Prism driver failed");
1167 SetErrorCode("Extrusion can not be created, check input data");
1171 catch (Standard_Failure) {
1172 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1173 SetErrorCode(aFail->GetMessageString());
1177 //Make a Python command
1178 GEOM::TPythonDump pd (aFunction);
1179 pd << aPrism << " = geompy.MakePrism(" << theBase << ", " << thePoint1 << ", " << thePoint2;
1180 if (theScaleFactor > Precision::Confusion())
1181 pd << ", " << theScaleFactor << ")";
1189 //=============================================================================
1191 * MakePrismTwoPnt2Ways
1193 //=============================================================================
1194 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePrismTwoPnt2Ways
1195 (Handle(GEOM_Object) theBase,
1196 Handle(GEOM_Object) thePoint1, Handle(GEOM_Object) thePoint2)
1200 if (theBase.IsNull() || thePoint1.IsNull() || thePoint2.IsNull()) return NULL;
1202 //Add a new Prism object
1203 Handle(GEOM_Object) aPrism = GetEngine()->AddObject(GetDocID(), GEOM_PRISM);
1205 //Add a new Prism function for creation a Prism relatively to two points
1206 Handle(GEOM_Function) aFunction =
1207 aPrism->AddFunction(GEOMImpl_PrismDriver::GetID(), PRISM_BASE_TWO_PNT_2WAYS);
1208 if (aFunction.IsNull()) return NULL;
1210 //Check if the function is set correctly
1211 if (aFunction->GetDriverGUID() != GEOMImpl_PrismDriver::GetID()) return NULL;
1213 GEOMImpl_IPrism aCI (aFunction);
1215 Handle(GEOM_Function) aRefBase = theBase->GetLastFunction();
1216 Handle(GEOM_Function) aRefPnt1 = thePoint1->GetLastFunction();
1217 Handle(GEOM_Function) aRefPnt2 = thePoint2->GetLastFunction();
1219 if (aRefBase.IsNull() || aRefPnt1.IsNull() || aRefPnt2.IsNull()) return NULL;
1221 aCI.SetBase(aRefBase);
1222 aCI.SetFirstPoint(aRefPnt1);
1223 aCI.SetLastPoint(aRefPnt2);
1225 //Compute the Prism value
1228 if (!GetSolver()->ComputeFunction(aFunction)) {
1229 //SetErrorCode("Prism driver failed");
1230 SetErrorCode("Extrusion can not be created, check input data");
1234 catch (Standard_Failure) {
1235 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1236 SetErrorCode(aFail->GetMessageString());
1240 //Make a Python command
1241 GEOM::TPythonDump(aFunction) << aPrism << " = geompy.MakePrism2Ways("
1242 << theBase << ", " << thePoint1 << ", " << thePoint2 << ")";
1248 //=============================================================================
1252 //=============================================================================
1253 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePrismDXDYDZ
1254 (Handle(GEOM_Object) theBase, double theDX, double theDY, double theDZ,
1255 double theScaleFactor)
1259 if (theBase.IsNull()) return NULL;
1261 //Add a new Prism object
1262 Handle(GEOM_Object) aPrism = GetEngine()->AddObject(GetDocID(), GEOM_PRISM);
1264 //Add a new Prism function for creation a Prism by DXDYDZ
1265 Handle(GEOM_Function) aFunction =
1266 aPrism->AddFunction(GEOMImpl_PrismDriver::GetID(), PRISM_BASE_DXDYDZ);
1267 if (aFunction.IsNull()) return NULL;
1269 //Check if the function is set correctly
1270 if (aFunction->GetDriverGUID() != GEOMImpl_PrismDriver::GetID()) return NULL;
1272 GEOMImpl_IPrism aCI (aFunction);
1274 Handle(GEOM_Function) aRefBase = theBase->GetLastFunction();
1276 if (aRefBase.IsNull()) return NULL;
1278 aCI.SetBase(aRefBase);
1282 aCI.SetScale(theScaleFactor);
1284 //Compute the Prism value
1287 if (!GetSolver()->ComputeFunction(aFunction)) {
1288 SetErrorCode("Extrusion can not be created, check input data");
1292 catch (Standard_Failure) {
1293 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1294 SetErrorCode(aFail->GetMessageString());
1298 //Make a Python command
1299 GEOM::TPythonDump pd (aFunction);
1300 pd << aPrism << " = geompy.MakePrismDXDYDZ("
1301 << theBase << ", " << theDX << ", " << theDY << ", " << theDZ;
1302 if (theScaleFactor > Precision::Confusion())
1303 pd << ", " << theScaleFactor << ")";
1311 //=============================================================================
1313 * MakePrismDXDYDZ_2WAYS
1315 //=============================================================================
1316 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePrismDXDYDZ2Ways
1317 (Handle(GEOM_Object) theBase, double theDX, double theDY, double theDZ)
1321 if (theBase.IsNull()) return NULL;
1323 //Add a new Prism object
1324 Handle(GEOM_Object) aPrism = GetEngine()->AddObject(GetDocID(), GEOM_PRISM);
1326 //Add a new Prism function for creation a Prism by DXDYDZ
1327 Handle(GEOM_Function) aFunction =
1328 aPrism->AddFunction(GEOMImpl_PrismDriver::GetID(), PRISM_BASE_DXDYDZ_2WAYS);
1329 if (aFunction.IsNull()) return NULL;
1331 //Check if the function is set correctly
1332 if (aFunction->GetDriverGUID() != GEOMImpl_PrismDriver::GetID()) return NULL;
1334 GEOMImpl_IPrism aCI (aFunction);
1336 Handle(GEOM_Function) aRefBase = theBase->GetLastFunction();
1338 if (aRefBase.IsNull()) return NULL;
1340 aCI.SetBase(aRefBase);
1345 //Compute the Prism value
1348 if (!GetSolver()->ComputeFunction(aFunction)) {
1349 SetErrorCode("Extrusion can not be created, check input data");
1353 catch (Standard_Failure) {
1354 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1355 SetErrorCode(aFail->GetMessageString());
1359 //Make a Python command
1360 GEOM::TPythonDump(aFunction) << aPrism << " = geompy.MakePrismDXDYDZ2Ways("
1361 << theBase << ", " << theDX << ", " << theDY << ", " << theDZ << ")";
1367 //=============================================================================
1371 //=============================================================================
1372 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeDraftPrism
1373 (Handle(GEOM_Object) theInitShape ,Handle(GEOM_Object) theBase, double theHeight, double theAngle, bool theFuse, bool theInvert)
1377 if (theBase.IsNull() || theInitShape.IsNull()) return NULL;
1379 Handle(GEOM_Object) aPrism = NULL;
1383 //Add a new Extruded Boss object
1384 aPrism = GetEngine()->AddObject(GetDocID(), GEOM_EXTRUDED_BOSS);
1388 //Add a new Extruded Cut object
1389 aPrism = GetEngine()->AddObject(GetDocID(), GEOM_EXTRUDED_CUT);
1392 //Add a new Prism function for the creation of a Draft Prism feature
1393 Handle(GEOM_Function) aFunction =
1394 aPrism->AddFunction(GEOMImpl_PrismDriver::GetID(), DRAFT_PRISM_FEATURE);
1395 if (aFunction.IsNull()) return NULL;
1397 //Check if the function is set correctly
1398 if (aFunction->GetDriverGUID() != GEOMImpl_PrismDriver::GetID()) return NULL;
1400 GEOMImpl_IPrism aCI (aFunction);
1402 Handle(GEOM_Function) aRefInit = theInitShape->GetLastFunction();
1403 Handle(GEOM_Function) aRefBase = theBase->GetLastFunction();
1405 if (aRefBase.IsNull() || aRefInit.IsNull()) return NULL;
1408 aCI.SetBase(aRefBase);
1409 aCI.SetInitShape(aRefInit);
1410 aCI.SetH(theHeight);
1411 aCI.SetDraftAngle(theAngle);
1416 aCI.SetInvertFlag(theInvert);
1418 //Compute the Draft Prism Feature value
1421 if (!GetSolver()->ComputeFunction(aFunction)) {
1422 SetErrorCode("Extrusion can not be created, check input data");
1426 catch (Standard_Failure) {
1427 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1428 SetErrorCode(aFail->GetMessageString());
1432 //Make a Python command
1433 GEOM::TPythonDump pd (aFunction);
1436 pd << aPrism << " = geompy.MakeExtrudedBoss(" << theInitShape << ", " << theBase << ", "
1437 << theHeight << ", " << theAngle;
1441 pd << aPrism << " = geompy.MakeExtrudedCut(" << theInitShape << ", " << theBase << ", "
1442 << theHeight << ", " << theAngle;
1445 pd << ", " << theInvert;
1452 //=============================================================================
1456 //=============================================================================
1457 Handle(TColStd_HSequenceOfTransient) GEOMImpl_I3DPrimOperations::MakePipe
1458 (const Handle(GEOM_Object) &theBase,
1459 const Handle(GEOM_Object) &thePath,
1460 const bool IsGenerateGroups)
1464 if (theBase.IsNull() || thePath.IsNull()) return NULL;
1466 //Add a new Pipe object
1467 Handle(GEOM_Object) aPipe = GetEngine()->AddObject(GetDocID(), GEOM_PIPE);
1469 //Add a new Pipe function
1470 Handle(GEOM_Function) aFunction =
1471 aPipe->AddFunction(GEOMImpl_PipeDriver::GetID(), PIPE_BASE_PATH);
1472 if (aFunction.IsNull()) return NULL;
1474 //Check if the function is set correctly
1475 if (aFunction->GetDriverGUID() != GEOMImpl_PipeDriver::GetID()) return NULL;
1477 GEOMImpl_IPipe aCI (aFunction);
1479 Handle(GEOM_Function) aRefBase = theBase->GetLastFunction();
1480 Handle(GEOM_Function) aRefPath = thePath->GetLastFunction();
1482 if (aRefBase.IsNull() || aRefPath.IsNull()) return NULL;
1484 aCI.SetBase(aRefBase);
1485 aCI.SetPath(aRefPath);
1486 aCI.SetGenerateGroups(IsGenerateGroups);
1488 //Compute the Pipe value
1491 if (!GetSolver()->ComputeFunction(aFunction)) {
1492 SetErrorCode("Pipe driver failed");
1496 catch (Standard_Failure) {
1497 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1498 SetErrorCode(aFail->GetMessageString());
1502 // Create the sequence of objects.
1503 Handle(TColStd_HSequenceOfTransient) aSeq = new TColStd_HSequenceOfTransient;
1505 aSeq->Append(aPipe);
1506 createGroups(aPipe, &aCI, aSeq);
1508 //Make a Python command
1509 GEOM::TPythonDump pyDump(aFunction);
1511 if (IsGenerateGroups) {
1517 pyDump << " = geompy.MakePipe(" << theBase << ", " << thePath;
1519 if (IsGenerateGroups) {
1530 //=============================================================================
1532 * MakeRevolutionAxisAngle
1534 //=============================================================================
1535 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeRevolutionAxisAngle (Handle(GEOM_Object) theBase,
1536 Handle(GEOM_Object) theAxis,
1541 if (theBase.IsNull() || theAxis.IsNull()) return NULL;
1543 //Add a new Revolution object
1544 Handle(GEOM_Object) aRevolution = GetEngine()->AddObject(GetDocID(), GEOM_REVOLUTION);
1546 //Add a new Revolution function for creation a revolution relatively to axis
1547 Handle(GEOM_Function) aFunction =
1548 aRevolution->AddFunction(GEOMImpl_RevolutionDriver::GetID(), REVOLUTION_BASE_AXIS_ANGLE);
1549 if (aFunction.IsNull()) return NULL;
1551 //Check if the function is set correctly
1552 if (aFunction->GetDriverGUID() != GEOMImpl_RevolutionDriver::GetID()) return NULL;
1554 GEOMImpl_IRevolution aCI (aFunction);
1556 Handle(GEOM_Function) aRefBase = theBase->GetLastFunction();
1557 Handle(GEOM_Function) aRefAxis = theAxis->GetLastFunction();
1559 if (aRefBase.IsNull() || aRefAxis.IsNull()) return NULL;
1561 aCI.SetBase(aRefBase);
1562 aCI.SetAxis(aRefAxis);
1563 aCI.SetAngle(theAngle);
1565 //Compute the Revolution value
1568 if (!GetSolver()->ComputeFunction(aFunction)) {
1569 SetErrorCode("Revolution driver failed");
1573 catch (Standard_Failure) {
1574 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1575 SetErrorCode(aFail->GetMessageString());
1579 //Make a Python command
1580 GEOM::TPythonDump(aFunction) << aRevolution << " = geompy.MakeRevolution("
1581 << theBase << ", " << theAxis << ", " << theAngle * 180.0 / M_PI << "*math.pi/180.0)";
1587 //=============================================================================
1589 * MakeRevolutionAxisAngle2Ways
1591 //=============================================================================
1592 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeRevolutionAxisAngle2Ways
1593 (Handle(GEOM_Object) theBase, Handle(GEOM_Object) theAxis, double theAngle)
1597 if (theBase.IsNull() || theAxis.IsNull()) return NULL;
1599 //Add a new Revolution object
1600 Handle(GEOM_Object) aRevolution = GetEngine()->AddObject(GetDocID(), GEOM_REVOLUTION);
1602 //Add a new Revolution function for creation a revolution relatively to axis
1603 Handle(GEOM_Function) aFunction =
1604 aRevolution->AddFunction(GEOMImpl_RevolutionDriver::GetID(), REVOLUTION_BASE_AXIS_ANGLE_2WAYS);
1605 if (aFunction.IsNull()) return NULL;
1607 //Check if the function is set correctly
1608 if (aFunction->GetDriverGUID() != GEOMImpl_RevolutionDriver::GetID()) return NULL;
1610 GEOMImpl_IRevolution aCI (aFunction);
1612 Handle(GEOM_Function) aRefBase = theBase->GetLastFunction();
1613 Handle(GEOM_Function) aRefAxis = theAxis->GetLastFunction();
1615 if (aRefBase.IsNull() || aRefAxis.IsNull()) return NULL;
1617 aCI.SetBase(aRefBase);
1618 aCI.SetAxis(aRefAxis);
1619 aCI.SetAngle(theAngle);
1621 //Compute the Revolution value
1624 if (!GetSolver()->ComputeFunction(aFunction)) {
1625 SetErrorCode("Revolution driver failed");
1629 catch (Standard_Failure) {
1630 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1631 SetErrorCode(aFail->GetMessageString());
1635 //Make a Python command
1636 GEOM::TPythonDump(aFunction) << aRevolution << " = geompy.MakeRevolution2Ways("
1637 << theBase << ", " << theAxis << ", " << theAngle * 180.0 / M_PI << "*math.pi/180.0)";
1643 //=============================================================================
1647 //=============================================================================
1649 GEOMImpl_I3DPrimOperations::MakeFilling (std::list< Handle(GEOM_Object)> & theContours,
1650 int theMinDeg, int theMaxDeg,
1651 double theTol2D, double theTol3D, int theNbIter,
1652 int theMethod, bool isApprox)
1656 Handle(TColStd_HSequenceOfTransient) contours = GEOM_Object::GetLastFunctions( theContours );
1657 if ( contours.IsNull() || contours->IsEmpty() ) {
1658 SetErrorCode("NULL argument shape");
1661 //Add a new Filling object
1662 Handle(GEOM_Object) aFilling = GetEngine()->AddObject(GetDocID(), GEOM_FILLING);
1664 //Add a new Filling function for creation a filling from a compound
1665 Handle(GEOM_Function) aFunction = aFilling->AddFunction(GEOMImpl_FillingDriver::GetID(), BASIC_FILLING);
1666 if (aFunction.IsNull()) return NULL;
1668 //Check if the function is set correctly
1669 if (aFunction->GetDriverGUID() != GEOMImpl_FillingDriver::GetID()) return NULL;
1671 GEOMImpl_IFilling aFI (aFunction);
1672 aFI.SetShapes(contours);
1673 aFI.SetMinDeg(theMinDeg);
1674 aFI.SetMaxDeg(theMaxDeg);
1675 aFI.SetTol2D(theTol2D);
1676 aFI.SetTol3D(theTol3D);
1677 aFI.SetNbIter(theNbIter);
1678 aFI.SetApprox(isApprox);
1679 aFI.SetMethod(theMethod);
1681 //Compute the Solid value
1684 if (!GetSolver()->ComputeFunction(aFunction)) {
1685 SetErrorCode("Filling driver failed");
1689 catch (Standard_Failure) {
1690 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1691 if (strcmp(aFail->GetMessageString(), "Geom_BSplineSurface") == 0)
1692 SetErrorCode("B-Spline surface construction failed");
1694 SetErrorCode(aFail->GetMessageString());
1698 //Make a Python command
1699 GEOM::TPythonDump pd (aFunction);
1700 pd << aFilling << " = geompy.MakeFilling(" << theContours ;
1701 if ( theMinDeg != 2 ) pd << ", theMinDeg=" << theMinDeg ;
1702 if ( theMaxDeg != 5 ) pd << ", theMaxDeg=" << theMaxDeg ;
1703 if ( fabs(theTol2D-0.0001) > Precision::Confusion() )
1704 { pd << ", theTol2D=" << theTol2D ; }
1705 if ( fabs(theTol3D-0.0001) > Precision::Confusion() )
1706 { pd << ", theTol3D=" << theTol3D ; }
1707 if ( theNbIter != 0 ) pd << ", theNbIter=" << theNbIter ;
1708 if ( theMethod==1 ) pd << ", theMethod=GEOM.FOM_UseOri";
1709 else if( theMethod==2 ) pd << ", theMethod=GEOM.FOM_AutoCorrect";
1710 if ( isApprox ) pd << ", isApprox=" << isApprox ;
1717 //=============================================================================
1721 //=============================================================================
1722 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeThruSections(
1723 const Handle(TColStd_HSequenceOfTransient)& theSeqSections,
1728 Handle(GEOM_Object) anObj;
1730 if(theSeqSections.IsNull())
1733 Standard_Integer nbObj = theSeqSections->Length();
1737 //Add a new ThruSections object
1738 Handle(GEOM_Object) aThruSect = GetEngine()->AddObject(GetDocID(), GEOM_THRUSECTIONS);
1741 //Add a new ThruSections function
1743 int aTypeFunc = (theRuled ? THRUSECTIONS_RULED : THRUSECTIONS_SMOOTHED);
1744 Handle(GEOM_Function) aFunction =
1745 aThruSect->AddFunction(GEOMImpl_ThruSectionsDriver::GetID(), aTypeFunc);
1746 if (aFunction.IsNull()) return anObj;
1748 //Check if the function is set correctly
1749 if (aFunction->GetDriverGUID() != GEOMImpl_ThruSectionsDriver::GetID()) return NULL;
1751 GEOMImpl_IThruSections aCI (aFunction);
1753 Handle(TColStd_HSequenceOfTransient) aSeqSections = new TColStd_HSequenceOfTransient;
1755 Standard_Integer i =1;
1756 for( ; i <= nbObj; i++) {
1758 Handle(Standard_Transient) anItem = theSeqSections->Value(i);
1762 Handle(GEOM_Object) aSectObj = Handle(GEOM_Object)::DownCast(anItem);
1763 if(!aSectObj.IsNull())
1765 Handle(GEOM_Function) aRefSect = aSectObj->GetLastFunction();
1766 if(!aRefSect.IsNull())
1767 aSeqSections->Append(aRefSect);
1771 if(!aSeqSections->Length())
1774 aCI.SetSections(aSeqSections);
1775 aCI.SetSolidMode(theModeSolid);
1776 aCI.SetPrecision(thePreci);
1778 //Compute the ThruSections value
1781 if (!GetSolver()->ComputeFunction(aFunction)) {
1782 SetErrorCode("ThruSections driver failed");
1786 catch (Standard_Failure) {
1787 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1788 SetErrorCode(aFail->GetMessageString());
1792 //Make a Python command
1793 GEOM::TPythonDump pyDump(aFunction);
1794 pyDump << aThruSect << " = geompy.MakeThruSections([";
1796 for(i =1 ; i <= nbObj; i++) {
1798 Handle(Standard_Transient) anItem = theSeqSections->Value(i);
1802 Handle(GEOM_Object) aSectObj = Handle(GEOM_Object)::DownCast(anItem);
1803 if(!aSectObj.IsNull()) {
1810 pyDump<< "],"<<theModeSolid << "," << thePreci <<","<< theRuled <<")";
1817 //=============================================================================
1819 * MakePipeWithDifferentSections
1821 //=============================================================================
1822 Handle(TColStd_HSequenceOfTransient)
1823 GEOMImpl_I3DPrimOperations::MakePipeWithDifferentSections
1824 (const Handle(TColStd_HSequenceOfTransient) &theBases,
1825 const Handle(TColStd_HSequenceOfTransient) &theLocations,
1826 const Handle(GEOM_Object) &thePath,
1827 const bool theWithContact,
1828 const bool theWithCorrections,
1829 const bool IsBySteps,
1830 const bool IsGenerateGroups)
1833 if(theBases.IsNull())
1836 Standard_Integer nbBases = theBases->Length();
1841 Standard_Integer nbLocs = (theLocations.IsNull() ? 0 :theLocations->Length());
1842 //Add a new Pipe object
1843 Handle(GEOM_Object) aPipeDS = GetEngine()->AddObject(GetDocID(), GEOM_PIPE);
1845 //Add a new Pipe function
1847 Handle(GEOM_Function) aFunction =
1848 aPipeDS->AddFunction(GEOMImpl_PipeDriver::GetID(), PIPE_DIFFERENT_SECTIONS);
1849 if (aFunction.IsNull()) return NULL;
1851 //Check if the function is set correctly
1852 if (aFunction->GetDriverGUID() != GEOMImpl_PipeDriver::GetID()) return NULL;
1854 GEOMImpl_IPipeDiffSect aCI (aFunction);
1856 Handle(GEOM_Function) aRefPath = thePath->GetLastFunction();
1857 if(aRefPath.IsNull())
1860 Handle(TColStd_HSequenceOfTransient) aSeqBases = new TColStd_HSequenceOfTransient;
1861 Handle(TColStd_HSequenceOfTransient) aSeqLocs = new TColStd_HSequenceOfTransient;
1863 Standard_Integer i =1;
1864 for( ; i <= nbBases; i++) {
1866 Handle(Standard_Transient) anItem = theBases->Value(i);
1870 Handle(GEOM_Object) aBase = Handle(GEOM_Object)::DownCast(anItem);
1873 Handle(GEOM_Function) aRefBase = aBase->GetLastFunction();
1874 if(aRefBase.IsNull())
1878 Handle(Standard_Transient) anItemLoc = theLocations->Value(i);
1879 if(anItemLoc.IsNull())
1882 Handle(GEOM_Object) aLoc = Handle(GEOM_Object)::DownCast(anItemLoc);
1885 Handle(GEOM_Function) aRefLoc = aLoc->GetLastFunction();
1886 if(aRefLoc.IsNull())
1888 aSeqLocs->Append(aRefLoc);
1890 aSeqBases->Append(aRefBase);
1893 if(!aSeqBases->Length())
1896 aCI.SetBases(aSeqBases);
1897 aCI.SetLocations(aSeqLocs);
1898 aCI.SetPath(aRefPath);
1901 aCI.SetWithContactMode(theWithContact);
1902 aCI.SetWithCorrectionMode(theWithCorrections);
1905 aCI.SetIsBySteps(IsBySteps);
1906 aCI.SetGenerateGroups(IsGenerateGroups);
1908 //Compute the Pipe value
1911 if (!GetSolver()->ComputeFunction(aFunction)) {
1912 SetErrorCode("Pipe with defferent section driver failed");
1916 catch (Standard_Failure) {
1917 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1918 SetErrorCode(aFail->GetMessageString());
1922 // Create the sequence of objects.
1923 Handle(TColStd_HSequenceOfTransient) aSeq = new TColStd_HSequenceOfTransient;
1925 aSeq->Append(aPipeDS);
1926 createGroups(aPipeDS, &aCI, aSeq);
1928 //Make a Python command
1929 GEOM::TPythonDump pyDump(aFunction);
1931 if (IsGenerateGroups) {
1938 pyDump << " = geompy.MakePipeWithDifferentSectionsBySteps([";
1940 pyDump << " = geompy.MakePipeWithDifferentSections([";
1943 for(i =1 ; i <= nbBases; i++) {
1945 Handle(Standard_Transient) anItem = theBases->Value(i);
1949 Handle(GEOM_Object) anObj = Handle(GEOM_Object)::DownCast(anItem);
1950 if(!anObj.IsNull()) {
1959 for(i =1 ; i <= nbLocs; i++) {
1961 Handle(Standard_Transient) anItem = theLocations->Value(i);
1965 Handle(GEOM_Object) anObj = Handle(GEOM_Object)::DownCast(anItem);
1966 if(!anObj.IsNull()) {
1973 pyDump<< "], "<<thePath;
1976 pyDump<<","<<theWithContact << "," << theWithCorrections;
1979 if (IsGenerateGroups) {
1990 //=============================================================================
1992 * MakePipeWithShellSections
1994 //=============================================================================
1995 Handle(TColStd_HSequenceOfTransient)
1996 GEOMImpl_I3DPrimOperations::MakePipeWithShellSections
1997 (const Handle(TColStd_HSequenceOfTransient) &theBases,
1998 const Handle(TColStd_HSequenceOfTransient) &theSubBases,
1999 const Handle(TColStd_HSequenceOfTransient) &theLocations,
2000 const Handle(GEOM_Object) &thePath,
2001 const bool theWithContact,
2002 const bool theWithCorrections,
2003 const bool IsGenerateGroups)
2006 if(theBases.IsNull())
2009 Standard_Integer nbBases = theBases->Length();
2014 Standard_Integer nbSubBases = (theSubBases.IsNull() ? 0 :theSubBases->Length());
2016 Standard_Integer nbLocs = (theLocations.IsNull() ? 0 :theLocations->Length());
2018 //Add a new Pipe object
2019 Handle(GEOM_Object) aPipeDS = GetEngine()->AddObject(GetDocID(), GEOM_PIPE);
2021 //Add a new Pipe function
2023 Handle(GEOM_Function) aFunction =
2024 aPipeDS->AddFunction(GEOMImpl_PipeDriver::GetID(), PIPE_SHELL_SECTIONS);
2025 if (aFunction.IsNull()) return NULL;
2027 //Check if the function is set correctly
2028 if (aFunction->GetDriverGUID() != GEOMImpl_PipeDriver::GetID()) return NULL;
2030 //GEOMImpl_IPipeDiffSect aCI (aFunction);
2031 GEOMImpl_IPipeShellSect aCI (aFunction);
2033 Handle(GEOM_Function) aRefPath = thePath->GetLastFunction();
2034 if(aRefPath.IsNull())
2037 Handle(TColStd_HSequenceOfTransient) aSeqBases = new TColStd_HSequenceOfTransient;
2038 Handle(TColStd_HSequenceOfTransient) aSeqSubBases = new TColStd_HSequenceOfTransient;
2039 Handle(TColStd_HSequenceOfTransient) aSeqLocs = new TColStd_HSequenceOfTransient;
2041 Standard_Integer i =1;
2042 for( ; i <= nbBases; i++) {
2044 Handle(Standard_Transient) anItem = theBases->Value(i);
2047 Handle(GEOM_Object) aBase = Handle(GEOM_Object)::DownCast(anItem);
2050 Handle(GEOM_Function) aRefBase = aBase->GetLastFunction();
2051 if(aRefBase.IsNull())
2054 if( nbSubBases >= nbBases ) {
2055 Handle(Standard_Transient) aSubItem = theSubBases->Value(i);
2056 if(aSubItem.IsNull())
2058 Handle(GEOM_Object) aSubBase = Handle(GEOM_Object)::DownCast(aSubItem);
2059 if(aSubBase.IsNull())
2061 Handle(GEOM_Function) aRefSubBase = aSubBase->GetLastFunction();
2062 if(aRefSubBase.IsNull())
2064 aSeqSubBases->Append(aRefSubBase);
2068 Handle(Standard_Transient) anItemLoc = theLocations->Value(i);
2069 if(anItemLoc.IsNull())
2071 Handle(GEOM_Object) aLoc = Handle(GEOM_Object)::DownCast(anItemLoc);
2074 Handle(GEOM_Function) aRefLoc = aLoc->GetLastFunction();
2075 if(aRefLoc.IsNull())
2077 aSeqLocs->Append(aRefLoc);
2080 aSeqBases->Append(aRefBase);
2083 if(!aSeqBases->Length())
2086 aCI.SetBases(aSeqBases);
2087 aCI.SetSubBases(aSeqSubBases);
2088 aCI.SetLocations(aSeqLocs);
2089 aCI.SetPath(aRefPath);
2090 aCI.SetWithContactMode(theWithContact);
2091 aCI.SetWithCorrectionMode(theWithCorrections);
2092 aCI.SetGenerateGroups(IsGenerateGroups);
2094 //Compute the Pipe value
2097 if (!GetSolver()->ComputeFunction(aFunction)) {
2098 SetErrorCode("Pipe with shell sections driver failed");
2102 catch (Standard_Failure) {
2103 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
2104 SetErrorCode(aFail->GetMessageString());
2108 // Create the sequence of objects.
2109 Handle(TColStd_HSequenceOfTransient) aSeq = new TColStd_HSequenceOfTransient;
2111 aSeq->Append(aPipeDS);
2112 createGroups(aPipeDS, &aCI, aSeq);
2114 //Make a Python command
2115 GEOM::TPythonDump pyDump(aFunction);
2117 if (IsGenerateGroups) {
2123 pyDump << " = geompy.MakePipeWithShellSections([";
2125 for(i =1 ; i <= nbBases; i++) {
2127 Handle(Standard_Transient) anItem = theBases->Value(i);
2131 Handle(GEOM_Object) anObj = Handle(GEOM_Object)::DownCast(anItem);
2132 if(!anObj.IsNull()) {
2141 for(i =1 ; i <= nbSubBases; i++) {
2143 Handle(Standard_Transient) anItem = theSubBases->Value(i);
2147 Handle(GEOM_Object) anObj = Handle(GEOM_Object)::DownCast(anItem);
2148 if(!anObj.IsNull()) {
2157 for(i =1 ; i <= nbLocs; i++) {
2159 Handle(Standard_Transient) anItem = theLocations->Value(i);
2163 Handle(GEOM_Object) anObj = Handle(GEOM_Object)::DownCast(anItem);
2164 if(!anObj.IsNull()) {
2171 pyDump<< "], "<<thePath<<","<<theWithContact << "," << theWithCorrections;
2173 if (IsGenerateGroups) {
2185 //=============================================================================
2187 * MakePipeShellsWithoutPath
2189 //=============================================================================
2190 Handle(TColStd_HSequenceOfTransient)
2191 GEOMImpl_I3DPrimOperations::MakePipeShellsWithoutPath
2192 (const Handle(TColStd_HSequenceOfTransient) &theBases,
2193 const Handle(TColStd_HSequenceOfTransient) &theLocations,
2194 const bool IsGenerateGroups)
2197 if(theBases.IsNull())
2200 Standard_Integer nbBases = theBases->Length();
2205 Standard_Integer nbLocs = (theLocations.IsNull() ? 0 :theLocations->Length());
2207 //Add a new Pipe object
2208 Handle(GEOM_Object) aPipeDS = GetEngine()->AddObject(GetDocID(), GEOM_PIPE);
2210 //Add a new Pipe function
2212 Handle(GEOM_Function) aFunction =
2213 aPipeDS->AddFunction(GEOMImpl_PipeDriver::GetID(), PIPE_SHELLS_WITHOUT_PATH);
2214 if (aFunction.IsNull()) return NULL;
2216 //Check if the function is set correctly
2217 if (aFunction->GetDriverGUID() != GEOMImpl_PipeDriver::GetID()) return NULL;
2219 GEOMImpl_IPipeShellSect aCI (aFunction);
2221 Handle(TColStd_HSequenceOfTransient) aSeqBases = new TColStd_HSequenceOfTransient;
2222 Handle(TColStd_HSequenceOfTransient) aSeqLocs = new TColStd_HSequenceOfTransient;
2224 Standard_Integer i =1;
2225 for( ; i <= nbBases; i++) {
2227 Handle(Standard_Transient) anItem = theBases->Value(i);
2230 Handle(GEOM_Object) aBase = Handle(GEOM_Object)::DownCast(anItem);
2233 Handle(GEOM_Function) aRefBase = aBase->GetLastFunction();
2234 if(aRefBase.IsNull())
2238 Handle(Standard_Transient) anItemLoc = theLocations->Value(i);
2239 if(anItemLoc.IsNull())
2241 Handle(GEOM_Object) aLoc = Handle(GEOM_Object)::DownCast(anItemLoc);
2244 Handle(GEOM_Function) aRefLoc = aLoc->GetLastFunction();
2245 if(aRefLoc.IsNull())
2247 aSeqLocs->Append(aRefLoc);
2250 aSeqBases->Append(aRefBase);
2253 if(!aSeqBases->Length())
2256 aCI.SetBases(aSeqBases);
2257 aCI.SetLocations(aSeqLocs);
2258 aCI.SetGenerateGroups(IsGenerateGroups);
2260 //Compute the Pipe value
2263 if (!GetSolver()->ComputeFunction(aFunction)) {
2264 SetErrorCode("Pipe with shell sections without path driver failed");
2268 catch (Standard_Failure) {
2269 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
2270 SetErrorCode(aFail->GetMessageString());
2274 // Create the sequence of objects.
2275 Handle(TColStd_HSequenceOfTransient) aSeq = new TColStd_HSequenceOfTransient;
2277 aSeq->Append(aPipeDS);
2278 createGroups(aPipeDS, &aCI, aSeq);
2280 //Make a Python command
2281 GEOM::TPythonDump pyDump(aFunction);
2283 if (IsGenerateGroups) {
2289 pyDump << " = geompy.MakePipeShellsWithoutPath([";
2291 for(i =1 ; i <= nbBases; i++) {
2293 Handle(Standard_Transient) anItem = theBases->Value(i);
2297 Handle(GEOM_Object) anObj = Handle(GEOM_Object)::DownCast(anItem);
2298 if(!anObj.IsNull()) {
2307 for(i =1 ; i <= nbLocs; i++) {
2309 Handle(Standard_Transient) anItem = theLocations->Value(i);
2313 Handle(GEOM_Object) anObj = Handle(GEOM_Object)::DownCast(anItem);
2314 if(!anObj.IsNull()) {
2323 if (IsGenerateGroups) {
2334 //=============================================================================
2336 * MakePipeBiNormalAlongVector
2338 //=============================================================================
2339 Handle(TColStd_HSequenceOfTransient)
2340 GEOMImpl_I3DPrimOperations::MakePipeBiNormalAlongVector
2341 (const Handle(GEOM_Object) &theBase,
2342 const Handle(GEOM_Object) &thePath,
2343 const Handle(GEOM_Object) &theVec,
2344 const bool IsGenerateGroups)
2348 if (theBase.IsNull() || thePath.IsNull() || theVec.IsNull()) return NULL;
2350 //Add a new Pipe object
2351 Handle(GEOM_Object) aPipe = GetEngine()->AddObject(GetDocID(), GEOM_PIPE);
2353 //Add a new Pipe function
2354 Handle(GEOM_Function) aFunction =
2355 aPipe->AddFunction(GEOMImpl_PipeDriver::GetID(), PIPE_BI_NORMAL_ALONG_VECTOR);
2356 if (aFunction.IsNull()) return NULL;
2358 //Check if the function is set correctly
2359 if (aFunction->GetDriverGUID() != GEOMImpl_PipeDriver::GetID()) return NULL;
2361 GEOMImpl_IPipeBiNormal aCI (aFunction);
2363 Handle(GEOM_Function) aRefBase = theBase->GetLastFunction();
2364 Handle(GEOM_Function) aRefPath = thePath->GetLastFunction();
2365 Handle(GEOM_Function) aRefVec = theVec->GetLastFunction();
2367 if (aRefBase.IsNull() || aRefPath.IsNull() || aRefVec.IsNull()) return NULL;
2369 aCI.SetBase(aRefBase);
2370 aCI.SetPath(aRefPath);
2371 aCI.SetVector(aRefVec);
2372 aCI.SetGenerateGroups(IsGenerateGroups);
2374 //Compute the Pipe value
2377 if (!GetSolver()->ComputeFunction(aFunction)) {
2378 SetErrorCode("Pipe driver failed");
2382 catch (Standard_Failure) {
2383 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
2384 SetErrorCode(aFail->GetMessageString());
2388 // Create the sequence of objects.
2389 Handle(TColStd_HSequenceOfTransient) aSeq = new TColStd_HSequenceOfTransient;
2391 aSeq->Append(aPipe);
2392 createGroups(aPipe, &aCI, aSeq);
2394 //Make a Python command
2395 GEOM::TPythonDump pyDump(aFunction);
2397 if (IsGenerateGroups) {
2403 pyDump << " = geompy.MakePipeBiNormalAlongVector("
2404 << theBase << ", " << thePath << ", " << theVec;
2406 if (IsGenerateGroups) {
2416 //=============================================================================
2420 //=============================================================================
2421 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeThickening
2422 (Handle(GEOM_Object) theObject,
2423 const Handle(TColStd_HArray1OfInteger) &theFacesIDs,
2430 if (theObject.IsNull()) return NULL;
2432 Handle(GEOM_Function) anOriginal = theObject->GetLastFunction();
2433 if (anOriginal.IsNull()) return NULL; //There is no function which creates an object to be offset
2435 //Add a new Offset function
2436 Handle(GEOM_Function) aFunction;
2437 Handle(GEOM_Object) aCopy;
2440 //Add a new Copy object
2441 aCopy = GetEngine()->AddObject(GetDocID(), theObject->GetType());
2442 aFunction = aCopy->AddFunction(GEOMImpl_OffsetDriver::GetID(), OFFSET_THICKENING_COPY);
2445 aFunction = theObject->AddFunction(GEOMImpl_OffsetDriver::GetID(), OFFSET_THICKENING);
2447 if (aFunction.IsNull()) return NULL;
2449 //Check if the function is set correctly
2450 if (aFunction->GetDriverGUID() != GEOMImpl_OffsetDriver::GetID()) return NULL;
2452 GEOMImpl_IOffset aTI (aFunction);
2453 aTI.SetShape(anOriginal);
2454 aTI.SetValue(theOffset);
2455 aTI.SetParam(theInside);
2457 if (theFacesIDs.IsNull() == Standard_False) {
2458 aTI.SetFaceIDs(theFacesIDs);
2461 //Compute the offset
2464 if (!GetSolver()->ComputeFunction(aFunction)) {
2465 SetErrorCode("Offset driver failed");
2469 catch (Standard_Failure) {
2470 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
2471 SetErrorCode(aFail->GetMessageString());
2475 //Make a Python command
2476 GEOM::TPythonDump pd (aFunction);
2477 Handle(GEOM_Object) aResult;
2480 pd << aCopy << " = geompy.MakeThickSolid("
2481 << theObject << ", " << theOffset;
2484 pd << "geompy.Thicken(" << theObject << ", " << theOffset;
2485 aResult = theObject;
2489 if (theFacesIDs.IsNull() == Standard_False) {
2493 for (i = theFacesIDs->Lower(); i < theFacesIDs->Upper(); ++i) {
2494 pd << theFacesIDs->Value(i) << ", ";
2496 // Dump the last value.
2497 pd << theFacesIDs->Value(i);
2502 pd << ", " << theInside;
2510 //=============================================================================
2514 //=============================================================================
2515 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::RestorePath (Handle(GEOM_Object) theShape,
2516 Handle(GEOM_Object) theBase1,
2517 Handle(GEOM_Object) theBase2)
2521 if (theShape.IsNull() || theBase1.IsNull() || theBase2.IsNull()) return NULL;
2523 // Add a new Path object
2524 Handle(GEOM_Object) aPath = GetEngine()->AddObject(GetDocID(), GEOM_PIPE_PATH);
2526 // Add a new Path function
2527 Handle(GEOM_Function) aFunction =
2528 aPath->AddFunction(GEOMImpl_PipePathDriver::GetID(), PIPE_PATH_TWO_BASES);
2529 if (aFunction.IsNull()) return NULL;
2531 // Check if the function is set correctly
2532 if (aFunction->GetDriverGUID() != GEOMImpl_PipePathDriver::GetID()) return NULL;
2534 GEOMImpl_IPipePath aCI (aFunction);
2536 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
2537 Handle(GEOM_Function) aRefBase1 = theBase1->GetLastFunction();
2538 Handle(GEOM_Function) aRefBase2 = theBase2->GetLastFunction();
2540 if (aRefShape.IsNull() || aRefBase1.IsNull() || aRefBase2.IsNull()) return NULL;
2542 aCI.SetShape(aRefShape);
2543 aCI.SetBase1(aRefBase1);
2544 aCI.SetBase2(aRefBase2);
2546 // Compute the Path value
2549 if (!GetSolver()->ComputeFunction(aFunction)) {
2550 SetErrorCode("PipePath driver failed");
2554 catch (Standard_Failure) {
2555 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
2556 SetErrorCode("RestorePath: inappropriate arguments given");
2560 // Make a Python command
2561 GEOM::TPythonDump(aFunction) << aPath << " = geompy.RestorePath("
2562 << theShape << ", " << theBase1 << ", " << theBase2 << ")";
2568 //=============================================================================
2572 //=============================================================================
2573 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::RestorePath
2574 (Handle(GEOM_Object) theShape,
2575 const Handle(TColStd_HSequenceOfTransient)& theBase1,
2576 const Handle(TColStd_HSequenceOfTransient)& theBase2)
2580 if (theShape.IsNull() || theBase1.IsNull() || theBase2.IsNull()) return NULL;
2582 Standard_Integer nbBases1 = theBase1->Length();
2583 Standard_Integer nbBases2 = theBase2->Length();
2585 if (!nbBases1 || !nbBases2)
2588 // Add a new Path object
2589 Handle(GEOM_Object) aPath = GetEngine()->AddObject(GetDocID(), GEOM_PIPE_PATH);
2591 // Add a new Path function
2592 Handle(GEOM_Function) aFunction =
2593 aPath->AddFunction(GEOMImpl_PipePathDriver::GetID(), PIPE_PATH_TWO_SEQS);
2594 if (aFunction.IsNull()) return NULL;
2596 // Check if the function is set correctly
2597 if (aFunction->GetDriverGUID() != GEOMImpl_PipePathDriver::GetID()) return NULL;
2599 GEOMImpl_IPipePath aCI (aFunction);
2601 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
2602 if (aRefShape.IsNull()) return NULL;
2604 Handle(TColStd_HSequenceOfTransient) aSeqBases1 = new TColStd_HSequenceOfTransient;
2605 Handle(TColStd_HSequenceOfTransient) aSeqBases2 = new TColStd_HSequenceOfTransient;
2608 for (i = 1; i <= nbBases1; i++) {
2609 Handle(Standard_Transient) anItem = theBase1->Value(i);
2610 if (!anItem.IsNull()) {
2611 Handle(GEOM_Object) aBase = Handle(GEOM_Object)::DownCast(anItem);
2612 if (!aBase.IsNull()) {
2613 Handle(GEOM_Function) aRefBase = aBase->GetLastFunction();
2614 if (!aRefBase.IsNull())
2615 aSeqBases1->Append(aRefBase);
2619 for (i = 1; i <= nbBases2; i++) {
2620 Handle(Standard_Transient) anItem = theBase2->Value(i);
2621 if (!anItem.IsNull()) {
2622 Handle(GEOM_Object) aBase = Handle(GEOM_Object)::DownCast(anItem);
2623 if (!aBase.IsNull()) {
2624 Handle(GEOM_Function) aRefBase = aBase->GetLastFunction();
2625 if (!aRefBase.IsNull())
2626 aSeqBases2->Append(aRefBase);
2630 if (!aSeqBases1->Length() || !aSeqBases2->Length()) return NULL;
2632 aCI.SetShape(aRefShape);
2633 aCI.SetBaseSeq1(aSeqBases1);
2634 aCI.SetBaseSeq2(aSeqBases2);
2636 // Compute the Path value
2639 if (!GetSolver()->ComputeFunction(aFunction)) {
2640 SetErrorCode("PipePath driver failed");
2644 catch (Standard_Failure) {
2645 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
2646 SetErrorCode("RestorePath: inappropriate arguments given");
2650 // Make a Python command
2651 GEOM::TPythonDump pyDump (aFunction);
2652 pyDump << aPath << " = geompy.RestorePathEdges(" << theShape << ", [";
2653 for (i = 1; i <= nbBases1; i++) {
2654 Handle(GEOM_Object) anObj = Handle(GEOM_Object)::DownCast(theBase1->Value(i));
2655 if (!anObj.IsNull()) {
2662 for (i = 1; i <= nbBases2; i++) {
2663 Handle(GEOM_Object) anObj = Handle(GEOM_Object)::DownCast(theBase2->Value(i));
2664 if (!anObj.IsNull()) {
2676 //=============================================================================
2680 //=============================================================================
2681 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::createGroup
2682 (const Handle(GEOM_Object) &theBaseObject,
2683 const Handle(TColStd_HArray1OfInteger) &theGroupIDs,
2684 const TCollection_AsciiString &theName,
2685 const TopTools_IndexedMapOfShape &theIndices)
2687 if (theBaseObject.IsNull() || theGroupIDs.IsNull()) {
2691 // Get the Shape type.
2692 const Standard_Integer anID = theGroupIDs->Value(theGroupIDs->Lower());
2693 const Standard_Integer aNbShapes = theIndices.Extent();
2695 if (anID < 1 || anID > aNbShapes) {
2699 const TopoDS_Shape aSubShape = theIndices.FindKey(anID);
2701 if (aSubShape.IsNull()) {
2706 const TopAbs_ShapeEnum aGroupType = aSubShape.ShapeType();
2707 Handle(GEOM_Object) aGroup =
2708 myGroupOperations->CreateGroup(theBaseObject, aGroupType);
2710 if (aGroup.IsNull() == Standard_False) {
2711 aGroup->GetLastFunction()->SetDescription("");
2712 aGroup->SetName(theName.ToCString());
2714 Handle(TColStd_HSequenceOfInteger) aSeqIDs = new TColStd_HSequenceOfInteger;
2717 for (i = theGroupIDs->Lower(); i <= theGroupIDs->Upper(); ++i) {
2718 // Get and check the index.
2719 const Standard_Integer anIndex = theGroupIDs->Value(i);
2721 if (anIndex < 1 || anIndex > aNbShapes) {
2725 // Get and check the sub-shape.
2726 const TopoDS_Shape aSubShape = theIndices.FindKey(anIndex);
2728 if (aSubShape.IsNull()) {
2732 // Check the shape type.
2733 if (aSubShape.ShapeType() != aGroupType) {
2737 aSeqIDs->Append(anIndex);
2740 myGroupOperations->UnionIDs(aGroup, aSeqIDs);
2741 aGroup->GetLastFunction()->SetDescription("");
2747 //=============================================================================
2751 //=============================================================================
2752 void GEOMImpl_I3DPrimOperations::createGroups
2753 (const Handle(GEOM_Object) &theBaseObject,
2754 GEOMImpl_IPipe *thePipe,
2755 Handle(TColStd_HSequenceOfTransient) &theSequence)
2757 if (theBaseObject.IsNull() || thePipe == NULL || theSequence.IsNull()) {
2761 TopoDS_Shape aShape = theBaseObject->GetValue();
2763 if (aShape.IsNull()) {
2767 TopTools_IndexedMapOfShape anIndices;
2768 Handle(TColStd_HArray1OfInteger) aGroupIDs;
2769 TopoDS_Shape aShapeType;
2770 const Standard_Integer aNbGroups = 5;
2771 Handle(GEOM_Object) aGrps[aNbGroups];
2774 TopExp::MapShapes(aShape, anIndices);
2777 aGroupIDs = thePipe->GetGroupDown();
2778 aGrps[0] = createGroup(theBaseObject, aGroupIDs, "GROUP_DOWN", anIndices);
2779 aGroupIDs = thePipe->GetGroupUp();
2780 aGrps[1] = createGroup(theBaseObject, aGroupIDs, "GROUP_UP", anIndices);
2781 aGroupIDs = thePipe->GetGroupSide1();
2782 aGrps[2] = createGroup(theBaseObject, aGroupIDs, "GROUP_SIDE1", anIndices);
2783 aGroupIDs = thePipe->GetGroupSide2();
2784 aGrps[3] = createGroup(theBaseObject, aGroupIDs, "GROUP_SIDE2", anIndices);
2785 aGroupIDs = thePipe->GetGroupOther();
2786 aGrps[4] = createGroup(theBaseObject, aGroupIDs, "GROUP_OTHER", anIndices);
2788 for (i = 0; i < aNbGroups; ++i) {
2789 if (aGrps[i].IsNull() == Standard_False) {
2790 theSequence->Append(aGrps[i]);