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 <GEOMImpl_I3DPrimOperations.hxx>
27 #include "utilities.h"
29 #include <Utils_ExceptHandlers.hxx>
31 #include <TFunction_DriverTable.hxx>
32 #include <TFunction_Driver.hxx>
33 #include <TDF_Tool.hxx>
35 #include <GEOM_Function.hxx>
36 #include <GEOM_PythonDump.hxx>
38 #include <GEOMImpl_Types.hxx>
40 #include <GEOMImpl_BoxDriver.hxx>
41 #include <GEOMImpl_FaceDriver.hxx>
42 #include <GEOMImpl_DiskDriver.hxx>
43 #include <GEOMImpl_CylinderDriver.hxx>
44 #include <GEOMImpl_ConeDriver.hxx>
45 #include <GEOMImpl_SphereDriver.hxx>
46 #include <GEOMImpl_TorusDriver.hxx>
47 #include <GEOMImpl_PrismDriver.hxx>
48 #include <GEOMImpl_PipeDriver.hxx>
49 #include <GEOMImpl_PipePathDriver.hxx>
50 #include <GEOMImpl_RevolutionDriver.hxx>
51 #include <GEOMImpl_ShapeDriver.hxx>
52 #include <GEOMImpl_FillingDriver.hxx>
53 #include <GEOMImpl_ThruSectionsDriver.hxx>
54 #include <GEOMImpl_OffsetDriver.hxx>
56 #include <GEOMImpl_IBox.hxx>
57 #include <GEOMImpl_IFace.hxx>
58 #include <GEOMImpl_IDisk.hxx>
59 #include <GEOMImpl_ICylinder.hxx>
60 #include <GEOMImpl_ICone.hxx>
61 #include <GEOMImpl_IGroupOperations.hxx>
62 #include <GEOMImpl_ISphere.hxx>
63 #include <GEOMImpl_ITorus.hxx>
64 #include <GEOMImpl_IPrism.hxx>
65 #include <GEOMImpl_IPipe.hxx>
66 #include <GEOMImpl_IRevolution.hxx>
67 #include <GEOMImpl_IFilling.hxx>
68 #include <GEOMImpl_IThruSections.hxx>
69 #include <GEOMImpl_IPipeDiffSect.hxx>
70 #include <GEOMImpl_IPipeShellSect.hxx>
71 #include <GEOMImpl_IPipeBiNormal.hxx>
72 #include <GEOMImpl_IOffset.hxx>
73 #include <GEOMImpl_IPipePath.hxx>
75 #include <Precision.hxx>
78 #include <Standard_Failure.hxx>
79 #include <Standard_ErrorHandler.hxx> // CAREFUL ! position of this file is critic : see Lucien PIGNOLONI / OCC
81 //=============================================================================
85 //=============================================================================
86 GEOMImpl_I3DPrimOperations::GEOMImpl_I3DPrimOperations (GEOM_Engine* theEngine, int theDocID)
87 : GEOM_IOperations(theEngine, theDocID)
89 MESSAGE("GEOMImpl_I3DPrimOperations::GEOMImpl_I3DPrimOperations");
90 myGroupOperations = new GEOMImpl_IGroupOperations(GetEngine(), GetDocID());
93 //=============================================================================
97 //=============================================================================
98 GEOMImpl_I3DPrimOperations::~GEOMImpl_I3DPrimOperations()
100 MESSAGE("GEOMImpl_I3DPrimOperations::~GEOMImpl_I3DPrimOperations");
101 delete myGroupOperations;
105 //=============================================================================
109 //=============================================================================
110 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeBoxDXDYDZ (double theDX, double theDY, double theDZ)
114 //Add a new Box object
115 Handle(GEOM_Object) aBox = GetEngine()->AddObject(GetDocID(), GEOM_BOX);
117 //Add a new Box function with DX_DY_DZ parameters
118 Handle(GEOM_Function) aFunction = aBox->AddFunction(GEOMImpl_BoxDriver::GetID(), BOX_DX_DY_DZ);
119 if (aFunction.IsNull()) return NULL;
121 //Check if the function is set correctly
122 if (aFunction->GetDriverGUID() != GEOMImpl_BoxDriver::GetID()) return NULL;
124 GEOMImpl_IBox aBI (aFunction);
130 //Compute the box value
133 if (!GetSolver()->ComputeFunction(aFunction)) {
134 SetErrorCode("Box driver failed");
138 catch (Standard_Failure) {
139 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
140 SetErrorCode(aFail->GetMessageString());
144 //Make a Python command
145 GEOM::TPythonDump(aFunction) << aBox << " = geompy.MakeBoxDXDYDZ("
146 << theDX << ", " << theDY << ", " << theDZ << ")";
153 //=============================================================================
157 //=============================================================================
158 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeBoxTwoPnt (Handle(GEOM_Object) thePnt1,
159 Handle(GEOM_Object) thePnt2)
163 if (thePnt1.IsNull() || thePnt2.IsNull()) return NULL;
165 //Add a new Box object
166 Handle(GEOM_Object) aBox = GetEngine()->AddObject(GetDocID(), GEOM_BOX);
168 //Add a new Box function for creation a box relatively to two points
169 Handle(GEOM_Function) aFunction = aBox->AddFunction(GEOMImpl_BoxDriver::GetID(), BOX_TWO_PNT);
170 if (aFunction.IsNull()) return NULL;
172 //Check if the function is set correctly
173 if (aFunction->GetDriverGUID() != GEOMImpl_BoxDriver::GetID()) return aBox;
175 GEOMImpl_IBox aBI (aFunction);
177 Handle(GEOM_Function) aRefFunction1 = thePnt1->GetLastFunction();
178 Handle(GEOM_Function) aRefFunction2 = thePnt2->GetLastFunction();
180 if (aRefFunction1.IsNull() || aRefFunction2.IsNull()) return aBox;
182 aBI.SetRef1(aRefFunction1);
183 aBI.SetRef2(aRefFunction2);
185 //Compute the Box value
188 if (!GetSolver()->ComputeFunction(aFunction)) {
189 SetErrorCode("Box driver failed");
193 catch (Standard_Failure) {
194 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
195 SetErrorCode(aFail->GetMessageString());
199 //Make a Python command
200 GEOM::TPythonDump(aFunction) << aBox << " = geompy.MakeBoxTwoPnt("
201 << thePnt1 << ", " << thePnt2 << ")";
207 //=============================================================================
211 //=============================================================================
212 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeFaceHW (double theH, double theW, int theOrientation)
216 if (theH == 0 || theW == 0) return NULL;
218 //Add a new Face object
219 Handle(GEOM_Object) aFace = GetEngine()->AddObject(GetDocID(), GEOM_FACE);
221 //Add a new Box function for creation a box relatively to two points
222 Handle(GEOM_Function) aFunction = aFace->AddFunction(GEOMImpl_FaceDriver::GetID(), FACE_H_W);
223 if (aFunction.IsNull()) return NULL;
225 //Check if the function is set correctly
226 if (aFunction->GetDriverGUID() != GEOMImpl_FaceDriver::GetID()) return aFace;
228 GEOMImpl_IFace aFI (aFunction);
232 aFI.SetOrientation(theOrientation);
237 if (!GetSolver()->ComputeFunction(aFunction)) {
238 SetErrorCode("Face driver failed");
242 catch (Standard_Failure) {
243 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
244 SetErrorCode(aFail->GetMessageString());
248 //Make a Python command
249 GEOM::TPythonDump(aFunction) << aFace << " = geompy.MakeFaceHW("
250 << theH << ", " << theW << ", " << theOrientation << ")";
256 //=============================================================================
260 //=============================================================================
261 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeFaceObjHW (Handle(GEOM_Object) theObj,
262 double theH, double theW)
266 if (theObj.IsNull()) return NULL;
268 //Add a new Face object
269 Handle(GEOM_Object) aFace = GetEngine()->AddObject(GetDocID(), GEOM_FACE);
271 //Add a new Box function for creation a box relatively to two points
272 Handle(GEOM_Function) aFunction = aFace->AddFunction(GEOMImpl_FaceDriver::GetID(), FACE_OBJ_H_W);
273 if (aFunction.IsNull()) return NULL;
275 //Check if the function is set correctly
276 if (aFunction->GetDriverGUID() != GEOMImpl_FaceDriver::GetID()) return aFace;
278 GEOMImpl_IFace aFI (aFunction);
280 Handle(GEOM_Function) aRefFunction1 = theObj->GetLastFunction();
282 if (aRefFunction1.IsNull())
285 aFI.SetRef1(aRefFunction1);
292 if (!GetSolver()->ComputeFunction(aFunction)) {
293 SetErrorCode("Face driver failed");
297 catch (Standard_Failure) {
298 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
299 SetErrorCode(aFail->GetMessageString());
303 //Make a Python command
304 GEOM::TPythonDump(aFunction) << aFace << " = geompy.MakeFaceObjHW("
305 << theObj << ", " << theH << ", " << theW << ")";
311 //=============================================================================
315 //=============================================================================
316 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeDiskPntVecR
317 (Handle(GEOM_Object) thePnt, Handle(GEOM_Object) theVec, double theR)
321 if (thePnt.IsNull() || theVec.IsNull()) return NULL;
323 //Add a new Disk object
324 Handle(GEOM_Object) aDisk = GetEngine()->AddObject(GetDocID(), GEOM_FACE);
326 //Add a new Disk function for creation a disk relatively to point and vector
327 Handle(GEOM_Function) aFunction =
328 aDisk->AddFunction(GEOMImpl_DiskDriver::GetID(), DISK_PNT_VEC_R);
329 if (aFunction.IsNull()) return NULL;
331 //Check if the function is set correctly
332 if (aFunction->GetDriverGUID() != GEOMImpl_DiskDriver::GetID()) return NULL;
334 GEOMImpl_IDisk aCI (aFunction);
336 Handle(GEOM_Function) aRefPnt = thePnt->GetLastFunction();
337 Handle(GEOM_Function) aRefVec = theVec->GetLastFunction();
339 if (aRefPnt.IsNull() || aRefVec.IsNull()) return NULL;
341 aCI.SetCenter(aRefPnt);
342 aCI.SetVector(aRefVec);
345 //Compute the Disk value
348 if (!GetSolver()->ComputeFunction(aFunction)) {
349 SetErrorCode("Disk driver failed");
353 catch (Standard_Failure) {
354 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
355 SetErrorCode(aFail->GetMessageString());
359 //Make a Python command
360 GEOM::TPythonDump(aFunction) << aDisk << " = geompy.MakeDiskPntVecR("
361 << thePnt << ", " << theVec << ", " << theR << ")";
367 //=============================================================================
371 //=============================================================================
372 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeDiskThreePnt (Handle(GEOM_Object) thePnt1,
373 Handle(GEOM_Object) thePnt2,
374 Handle(GEOM_Object) thePnt3)
378 if (thePnt1.IsNull() || thePnt2.IsNull() || thePnt3.IsNull()) return NULL;
380 //Add a new Disk object
381 Handle(GEOM_Object) aDisk = GetEngine()->AddObject(GetDocID(), GEOM_FACE);
383 //Add a new Disk function for creation a disk relatively to three points
384 Handle(GEOM_Function) aFunction =
385 aDisk->AddFunction(GEOMImpl_DiskDriver::GetID(), DISK_THREE_PNT);
386 if (aFunction.IsNull()) return NULL;
388 //Check if the function is set correctly
389 if (aFunction->GetDriverGUID() != GEOMImpl_DiskDriver::GetID()) return NULL;
391 GEOMImpl_IDisk aCI (aFunction);
393 Handle(GEOM_Function) aRefPnt1 = thePnt1->GetLastFunction();
394 Handle(GEOM_Function) aRefPnt2 = thePnt2->GetLastFunction();
395 Handle(GEOM_Function) aRefPnt3 = thePnt3->GetLastFunction();
397 if (aRefPnt1.IsNull() || aRefPnt2.IsNull() || aRefPnt3.IsNull()) return NULL;
399 aCI.SetPoint1(aRefPnt1);
400 aCI.SetPoint2(aRefPnt2);
401 aCI.SetPoint3(aRefPnt3);
403 //Compute the Disk value
406 if (!GetSolver()->ComputeFunction(aFunction)) {
407 SetErrorCode("Disk driver failed");
411 catch (Standard_Failure) {
412 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
413 SetErrorCode(aFail->GetMessageString());
417 //Make a Python command
418 GEOM::TPythonDump(aFunction) << aDisk << " = geompy.MakeDiskThreePnt("
419 << thePnt1 << ", " << thePnt2 << ", " << thePnt3 << ")";
425 //=============================================================================
429 //=============================================================================
430 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeDiskR (double theR, int theOrientation)
434 if (theR == 0 ) return NULL;
436 //Add a new Disk object
437 Handle(GEOM_Object) aDisk = GetEngine()->AddObject(GetDocID(), GEOM_FACE);
439 //Add a new Box function for creation a box relatively to two points
440 Handle(GEOM_Function) aFunction = aDisk->AddFunction(GEOMImpl_DiskDriver::GetID(), DISK_R);
441 if (aFunction.IsNull()) return NULL;
443 //Check if the function is set correctly
444 if (aFunction->GetDriverGUID() != GEOMImpl_DiskDriver::GetID()) return aDisk;
446 GEOMImpl_IDisk aDI (aFunction);
449 aDI.SetOrientation(theOrientation);
454 if (!GetSolver()->ComputeFunction(aFunction)) {
455 SetErrorCode("Disk driver failed");
459 catch (Standard_Failure) {
460 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
461 SetErrorCode(aFail->GetMessageString());
465 //Make a Python command
466 GEOM::TPythonDump(aFunction) << aDisk << " = geompy.MakeDiskR("
467 << theR << ", " << theOrientation << ")";
473 //=============================================================================
477 //=============================================================================
478 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeCylinderRH (double theR, double theH)
482 //Add a new Cylinder object
483 Handle(GEOM_Object) aCylinder = GetEngine()->AddObject(GetDocID(), GEOM_CYLINDER);
485 //Add a new Cylinder function with R and H parameters
486 Handle(GEOM_Function) aFunction = aCylinder->AddFunction(GEOMImpl_CylinderDriver::GetID(), CYLINDER_R_H);
487 if (aFunction.IsNull()) return NULL;
489 //Check if the function is set correctly
490 if (aFunction->GetDriverGUID() != GEOMImpl_CylinderDriver::GetID()) return NULL;
492 GEOMImpl_ICylinder aCI (aFunction);
497 //Compute the Cylinder value
500 if (!GetSolver()->ComputeFunction(aFunction)) {
501 SetErrorCode("Cylinder driver failed");
505 catch (Standard_Failure) {
506 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
507 SetErrorCode(aFail->GetMessageString());
511 //Make a Python command
512 GEOM::TPythonDump(aFunction) << aCylinder
513 << " = geompy.MakeCylinderRH(" << theR << ", " << theH << ")";
519 //=============================================================================
523 //=============================================================================
524 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeCylinderRHA (double theR, double theH, double theA)
528 //Add a new Cylinder object
529 Handle(GEOM_Object) aCylinder = GetEngine()->AddObject(GetDocID(), GEOM_CYLINDER);
531 //Add a new Cylinder function with R and H parameters
532 Handle(GEOM_Function) aFunction = aCylinder->AddFunction(GEOMImpl_CylinderDriver::GetID(), CYLINDER_R_H_A);
533 if (aFunction.IsNull()) return NULL;
535 //Check if the function is set correctly
536 if (aFunction->GetDriverGUID() != GEOMImpl_CylinderDriver::GetID()) return NULL;
538 GEOMImpl_ICylinder aCI (aFunction);
544 //Compute the Cylinder value
547 if (!GetSolver()->ComputeFunction(aFunction)) {
548 SetErrorCode("Cylinder driver failed");
552 catch (Standard_Failure) {
553 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
554 SetErrorCode(aFail->GetMessageString());
558 //Make a Python command
559 GEOM::TPythonDump(aFunction) << aCylinder
560 << " = geompy.MakeCylinderRHA(" << theR << ", " << theH << ", " << theA*180./M_PI << "*math.pi/180.)";
566 //=============================================================================
568 * MakeCylinderPntVecRH
570 //=============================================================================
571 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeCylinderPntVecRH (Handle(GEOM_Object) thePnt,
572 Handle(GEOM_Object) theVec,
573 double theR, double theH)
577 if (thePnt.IsNull() || theVec.IsNull()) return NULL;
579 //Add a new Cylinder object
580 Handle(GEOM_Object) aCylinder = GetEngine()->AddObject(GetDocID(), GEOM_CYLINDER);
582 //Add a new Cylinder function for creation a cylinder relatively to point and vector
583 Handle(GEOM_Function) aFunction =
584 aCylinder->AddFunction(GEOMImpl_CylinderDriver::GetID(), CYLINDER_PNT_VEC_R_H);
585 if (aFunction.IsNull()) return NULL;
587 //Check if the function is set correctly
588 if (aFunction->GetDriverGUID() != GEOMImpl_CylinderDriver::GetID()) return NULL;
590 GEOMImpl_ICylinder aCI (aFunction);
592 Handle(GEOM_Function) aRefPnt = thePnt->GetLastFunction();
593 Handle(GEOM_Function) aRefVec = theVec->GetLastFunction();
595 if (aRefPnt.IsNull() || aRefVec.IsNull()) return NULL;
597 aCI.SetPoint(aRefPnt);
598 aCI.SetVector(aRefVec);
602 //Compute the Cylinder value
605 if (!GetSolver()->ComputeFunction(aFunction)) {
606 SetErrorCode("Cylinder driver failed");
610 catch (Standard_Failure) {
611 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
612 SetErrorCode(aFail->GetMessageString());
616 //Make a Python command
617 GEOM::TPythonDump(aFunction) << aCylinder << " = geompy.MakeCylinder("
618 << thePnt << ", " << theVec << ", " << theR << ", " << theH << ")";
624 //=============================================================================
626 * MakeCylinderPntVecRHA
628 //=============================================================================
629 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeCylinderPntVecRHA (Handle(GEOM_Object) thePnt,
630 Handle(GEOM_Object) theVec,
631 double theR, double theH, double theA)
635 if (thePnt.IsNull() || theVec.IsNull()) return NULL;
637 //Add a new Cylinder object
638 Handle(GEOM_Object) aCylinder = GetEngine()->AddObject(GetDocID(), GEOM_CYLINDER);
640 //Add a new Cylinder function for creation a cylinder relatively to point and vector
641 Handle(GEOM_Function) aFunction =
642 aCylinder->AddFunction(GEOMImpl_CylinderDriver::GetID(), CYLINDER_PNT_VEC_R_H_A);
643 if (aFunction.IsNull()) return NULL;
645 //Check if the function is set correctly
646 if (aFunction->GetDriverGUID() != GEOMImpl_CylinderDriver::GetID()) return NULL;
648 GEOMImpl_ICylinder aCI (aFunction);
650 Handle(GEOM_Function) aRefPnt = thePnt->GetLastFunction();
651 Handle(GEOM_Function) aRefVec = theVec->GetLastFunction();
653 if (aRefPnt.IsNull() || aRefVec.IsNull()) return NULL;
655 aCI.SetPoint(aRefPnt);
656 aCI.SetVector(aRefVec);
661 //Compute the Cylinder value
664 if (!GetSolver()->ComputeFunction(aFunction)) {
665 SetErrorCode("Cylinder driver failed");
669 catch (Standard_Failure) {
670 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
671 SetErrorCode(aFail->GetMessageString());
675 //Make a Python command
676 GEOM::TPythonDump(aFunction) << aCylinder << " = geompy.MakeCylinderA("
677 << thePnt << ", " << theVec << ", " << theR << ", " << theH << ", " << theA*180./M_PI << "*math.pi/180.)";
684 //=============================================================================
688 //=============================================================================
689 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeConeR1R2H (double theR1, double theR2,
694 //Add a new Cone object
695 Handle(GEOM_Object) aCone = GetEngine()->AddObject(GetDocID(), GEOM_CONE);
697 //Add a new Cone function with R and H parameters
698 Handle(GEOM_Function) aFunction =
699 aCone->AddFunction(GEOMImpl_ConeDriver::GetID(), CONE_R1_R2_H);
700 if (aFunction.IsNull()) return NULL;
702 //Check if the function is set correctly
703 if (aFunction->GetDriverGUID() != GEOMImpl_ConeDriver::GetID()) return NULL;
705 GEOMImpl_ICone aCI (aFunction);
711 //Compute the Cone value
714 if (!GetSolver()->ComputeFunction(aFunction)) {
715 SetErrorCode("Cone driver failed");
719 catch (Standard_Failure) {
720 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
721 SetErrorCode(aFail->GetMessageString());
725 //Make a Python command
726 GEOM::TPythonDump(aFunction) << aCone << " = geompy.MakeConeR1R2H("
727 << theR1 << ", " << theR2 << ", " << theH << ")";
734 //=============================================================================
736 * MakeConePntVecR1R2H
738 //=============================================================================
739 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeConePntVecR1R2H (Handle(GEOM_Object) thePnt,
740 Handle(GEOM_Object) theVec,
741 double theR1, double theR2,
746 if (thePnt.IsNull() || theVec.IsNull()) return NULL;
748 //Add a new Cone object
749 Handle(GEOM_Object) aCone = GetEngine()->AddObject(GetDocID(), GEOM_CONE);
751 //Add a new Cone function for creation a cone relatively to point and vector
752 Handle(GEOM_Function) aFunction =
753 aCone->AddFunction(GEOMImpl_ConeDriver::GetID(), CONE_PNT_VEC_R1_R2_H);
754 if (aFunction.IsNull()) return NULL;
756 //Check if the function is set correctly
757 if (aFunction->GetDriverGUID() != GEOMImpl_ConeDriver::GetID()) return NULL;
759 GEOMImpl_ICone aCI (aFunction);
761 Handle(GEOM_Function) aRefPnt = thePnt->GetLastFunction();
762 Handle(GEOM_Function) aRefVec = theVec->GetLastFunction();
764 if (aRefPnt.IsNull() || aRefVec.IsNull()) return NULL;
766 aCI.SetPoint(aRefPnt);
767 aCI.SetVector(aRefVec);
772 //Compute the Cone value
775 if (!GetSolver()->ComputeFunction(aFunction)) {
776 SetErrorCode("Cone driver failed");
780 catch (Standard_Failure) {
781 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
782 SetErrorCode(aFail->GetMessageString());
786 //Make a Python command
787 GEOM::TPythonDump(aFunction) << aCone << " = geompy.MakeCone(" << thePnt
788 << ", " << theVec << ", " << theR1 << ", " << theR2 << ", " << theH << ")";
795 //=============================================================================
799 //=============================================================================
800 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeSphereR (double theR)
804 //Add a new Sphere object
805 Handle(GEOM_Object) aSphere = GetEngine()->AddObject(GetDocID(), GEOM_SPHERE);
807 //Add a new Sphere function with R parameter
808 Handle(GEOM_Function) aFunction = aSphere->AddFunction(GEOMImpl_SphereDriver::GetID(), SPHERE_R);
809 if (aFunction.IsNull()) return NULL;
811 //Check if the function is set correctly
812 if (aFunction->GetDriverGUID() != GEOMImpl_SphereDriver::GetID()) return NULL;
814 GEOMImpl_ISphere aCI (aFunction);
818 //Compute the Sphere value
821 if (!GetSolver()->ComputeFunction(aFunction)) {
822 SetErrorCode("Sphere driver failed");
826 catch (Standard_Failure) {
827 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
828 SetErrorCode(aFail->GetMessageString());
832 //Make a Python command
833 GEOM::TPythonDump(aFunction) << aSphere << " = geompy.MakeSphereR(" << theR << ")";
840 //=============================================================================
844 //=============================================================================
845 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeSpherePntR (Handle(GEOM_Object) thePnt,
850 if (thePnt.IsNull()) return NULL;
852 //Add a new Point object
853 Handle(GEOM_Object) aSphere = GetEngine()->AddObject(GetDocID(), GEOM_SPHERE);
855 //Add a new Sphere function for creation a sphere relatively to point
856 Handle(GEOM_Function) aFunction = aSphere->AddFunction(GEOMImpl_SphereDriver::GetID(), SPHERE_PNT_R);
857 if (aFunction.IsNull()) return NULL;
859 //Check if the function is set correctly
860 if (aFunction->GetDriverGUID() != GEOMImpl_SphereDriver::GetID()) return NULL;
862 GEOMImpl_ISphere aCI (aFunction);
864 Handle(GEOM_Function) aRefPnt = thePnt->GetLastFunction();
866 if (aRefPnt.IsNull()) return NULL;
868 aCI.SetPoint(aRefPnt);
871 //Compute the Sphere value
874 if (!GetSolver()->ComputeFunction(aFunction)) {
875 SetErrorCode("Sphere driver failed");
879 catch (Standard_Failure) {
880 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
881 SetErrorCode(aFail->GetMessageString());
885 //Make a Python command
886 GEOM::TPythonDump(aFunction) << aSphere
887 << " = geompy.MakeSpherePntR(" << thePnt << ", " << theR << ")";
894 //=============================================================================
898 //=============================================================================
899 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeTorusRR
900 (double theRMajor, double theRMinor)
904 //Add a new Torus object
905 Handle(GEOM_Object) anEll = GetEngine()->AddObject(GetDocID(), GEOM_TORUS);
907 //Add a new Torus function
908 Handle(GEOM_Function) aFunction =
909 anEll->AddFunction(GEOMImpl_TorusDriver::GetID(), TORUS_RR);
910 if (aFunction.IsNull()) return NULL;
912 //Check if the function is set correctly
913 if (aFunction->GetDriverGUID() != GEOMImpl_TorusDriver::GetID()) return NULL;
915 GEOMImpl_ITorus aCI (aFunction);
917 aCI.SetRMajor(theRMajor);
918 aCI.SetRMinor(theRMinor);
920 //Compute the Torus value
923 if (!GetSolver()->ComputeFunction(aFunction)) {
924 SetErrorCode("Torus driver failed");
928 catch (Standard_Failure) {
929 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
930 SetErrorCode(aFail->GetMessageString());
934 //Make a Python command
935 GEOM::TPythonDump(aFunction) << anEll << " = geompy.MakeTorusRR("
936 << theRMajor << ", " << theRMinor << ")";
942 //=============================================================================
946 //=============================================================================
947 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeTorusPntVecRR
948 (Handle(GEOM_Object) thePnt, Handle(GEOM_Object) theVec,
949 double theRMajor, double theRMinor)
953 if (thePnt.IsNull() || theVec.IsNull()) return NULL;
955 //Add a new Torus object
956 Handle(GEOM_Object) anEll = GetEngine()->AddObject(GetDocID(), GEOM_TORUS);
958 //Add a new Torus function
959 Handle(GEOM_Function) aFunction =
960 anEll->AddFunction(GEOMImpl_TorusDriver::GetID(), TORUS_PNT_VEC_RR);
961 if (aFunction.IsNull()) return NULL;
963 //Check if the function is set correctly
964 if (aFunction->GetDriverGUID() != GEOMImpl_TorusDriver::GetID()) return NULL;
966 GEOMImpl_ITorus aCI (aFunction);
968 Handle(GEOM_Function) aRefPnt = thePnt->GetLastFunction();
969 Handle(GEOM_Function) aRefVec = theVec->GetLastFunction();
971 if (aRefPnt.IsNull() || aRefVec.IsNull()) return NULL;
973 aCI.SetCenter(aRefPnt);
974 aCI.SetVector(aRefVec);
975 aCI.SetRMajor(theRMajor);
976 aCI.SetRMinor(theRMinor);
978 //Compute the Torus value
981 if (!GetSolver()->ComputeFunction(aFunction)) {
982 SetErrorCode("Torus driver failed");
986 catch (Standard_Failure) {
987 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
988 SetErrorCode(aFail->GetMessageString());
992 //Make a Python command
993 GEOM::TPythonDump(aFunction) << anEll << " = geompy.MakeTorus(" << thePnt
994 << ", " << theVec << ", " << theRMajor << ", " << theRMinor << ")";
1001 //=============================================================================
1005 //=============================================================================
1006 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePrismVecH (Handle(GEOM_Object) theBase,
1007 Handle(GEOM_Object) theVec,
1008 double theH, double theScaleFactor)
1012 if (theBase.IsNull() || theVec.IsNull()) return NULL;
1014 //Add a new Prism object
1015 Handle(GEOM_Object) aPrism = GetEngine()->AddObject(GetDocID(), GEOM_PRISM);
1017 //Add a new Prism function for creation a Prism relatively to vector
1018 Handle(GEOM_Function) aFunction =
1019 aPrism->AddFunction(GEOMImpl_PrismDriver::GetID(), PRISM_BASE_VEC_H);
1020 if (aFunction.IsNull()) return NULL;
1022 //Check if the function is set correctly
1023 if (aFunction->GetDriverGUID() != GEOMImpl_PrismDriver::GetID()) return NULL;
1025 GEOMImpl_IPrism aCI (aFunction);
1027 Handle(GEOM_Function) aRefBase = theBase->GetLastFunction();
1028 Handle(GEOM_Function) aRefVec = theVec->GetLastFunction();
1030 if (aRefBase.IsNull() || aRefVec.IsNull()) return NULL;
1032 aCI.SetBase(aRefBase);
1033 aCI.SetVector(aRefVec);
1035 aCI.SetScale(theScaleFactor);
1037 //Compute the Prism value
1040 if (!GetSolver()->ComputeFunction(aFunction)) {
1041 //SetErrorCode("Prism driver failed");
1042 SetErrorCode("Extrusion can not be created, check input data");
1046 catch (Standard_Failure) {
1047 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1048 SetErrorCode(aFail->GetMessageString());
1052 //Make a Python command
1053 GEOM::TPythonDump pd (aFunction);
1054 pd << aPrism << " = geompy.MakePrismVecH(" << theBase << ", " << theVec << ", " << theH;
1055 if (theScaleFactor > Precision::Confusion())
1056 pd << ", " << theScaleFactor << ")";
1064 //=============================================================================
1066 * MakePrismVecH2Ways
1068 //=============================================================================
1069 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePrismVecH2Ways (Handle(GEOM_Object) theBase,
1070 Handle(GEOM_Object) theVec,
1075 if (theBase.IsNull() || theVec.IsNull()) return NULL;
1077 //Add a new Prism object
1078 Handle(GEOM_Object) aPrism = GetEngine()->AddObject(GetDocID(), GEOM_PRISM);
1080 //Add a new Prism function for creation a Prism relatively to vector
1081 Handle(GEOM_Function) aFunction =
1082 aPrism->AddFunction(GEOMImpl_PrismDriver::GetID(), PRISM_BASE_VEC_H_2WAYS);
1083 if (aFunction.IsNull()) return NULL;
1085 //Check if the function is set correctly
1086 if (aFunction->GetDriverGUID() != GEOMImpl_PrismDriver::GetID()) return NULL;
1088 GEOMImpl_IPrism aCI (aFunction);
1090 Handle(GEOM_Function) aRefBase = theBase->GetLastFunction();
1091 Handle(GEOM_Function) aRefVec = theVec->GetLastFunction();
1093 if (aRefBase.IsNull() || aRefVec.IsNull()) return NULL;
1095 aCI.SetBase(aRefBase);
1096 aCI.SetVector(aRefVec);
1099 //Compute the Prism value
1102 if (!GetSolver()->ComputeFunction(aFunction)) {
1103 //SetErrorCode("Prism driver failed");
1104 SetErrorCode("Extrusion can not be created, check input data");
1108 catch (Standard_Failure) {
1109 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1110 SetErrorCode(aFail->GetMessageString());
1114 //Make a Python command
1115 GEOM::TPythonDump(aFunction) << aPrism << " = geompy.MakePrismVecH2Ways("
1116 << theBase << ", " << theVec << ", " << theH << ")";
1122 //=============================================================================
1126 //=============================================================================
1127 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePrismTwoPnt
1128 (Handle(GEOM_Object) theBase,
1129 Handle(GEOM_Object) thePoint1, Handle(GEOM_Object) thePoint2,
1130 double theScaleFactor)
1134 if (theBase.IsNull() || thePoint1.IsNull() || thePoint2.IsNull()) return NULL;
1136 //Add a new Prism object
1137 Handle(GEOM_Object) aPrism = GetEngine()->AddObject(GetDocID(), GEOM_PRISM);
1139 //Add a new Prism function for creation a Prism relatively to two points
1140 Handle(GEOM_Function) aFunction =
1141 aPrism->AddFunction(GEOMImpl_PrismDriver::GetID(), PRISM_BASE_TWO_PNT);
1142 if (aFunction.IsNull()) return NULL;
1144 //Check if the function is set correctly
1145 if (aFunction->GetDriverGUID() != GEOMImpl_PrismDriver::GetID()) return NULL;
1147 GEOMImpl_IPrism aCI (aFunction);
1149 Handle(GEOM_Function) aRefBase = theBase->GetLastFunction();
1150 Handle(GEOM_Function) aRefPnt1 = thePoint1->GetLastFunction();
1151 Handle(GEOM_Function) aRefPnt2 = thePoint2->GetLastFunction();
1153 if (aRefBase.IsNull() || aRefPnt1.IsNull() || aRefPnt2.IsNull()) return NULL;
1155 aCI.SetBase(aRefBase);
1156 aCI.SetFirstPoint(aRefPnt1);
1157 aCI.SetLastPoint(aRefPnt2);
1158 aCI.SetScale(theScaleFactor);
1160 //Compute the Prism value
1163 if (!GetSolver()->ComputeFunction(aFunction)) {
1164 //SetErrorCode("Prism driver failed");
1165 SetErrorCode("Extrusion can not be created, check input data");
1169 catch (Standard_Failure) {
1170 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1171 SetErrorCode(aFail->GetMessageString());
1175 //Make a Python command
1176 GEOM::TPythonDump pd (aFunction);
1177 pd << aPrism << " = geompy.MakePrism(" << theBase << ", " << thePoint1 << ", " << thePoint2;
1178 if (theScaleFactor > Precision::Confusion())
1179 pd << ", " << theScaleFactor << ")";
1187 //=============================================================================
1189 * MakePrismTwoPnt2Ways
1191 //=============================================================================
1192 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePrismTwoPnt2Ways
1193 (Handle(GEOM_Object) theBase,
1194 Handle(GEOM_Object) thePoint1, Handle(GEOM_Object) thePoint2)
1198 if (theBase.IsNull() || thePoint1.IsNull() || thePoint2.IsNull()) return NULL;
1200 //Add a new Prism object
1201 Handle(GEOM_Object) aPrism = GetEngine()->AddObject(GetDocID(), GEOM_PRISM);
1203 //Add a new Prism function for creation a Prism relatively to two points
1204 Handle(GEOM_Function) aFunction =
1205 aPrism->AddFunction(GEOMImpl_PrismDriver::GetID(), PRISM_BASE_TWO_PNT_2WAYS);
1206 if (aFunction.IsNull()) return NULL;
1208 //Check if the function is set correctly
1209 if (aFunction->GetDriverGUID() != GEOMImpl_PrismDriver::GetID()) return NULL;
1211 GEOMImpl_IPrism aCI (aFunction);
1213 Handle(GEOM_Function) aRefBase = theBase->GetLastFunction();
1214 Handle(GEOM_Function) aRefPnt1 = thePoint1->GetLastFunction();
1215 Handle(GEOM_Function) aRefPnt2 = thePoint2->GetLastFunction();
1217 if (aRefBase.IsNull() || aRefPnt1.IsNull() || aRefPnt2.IsNull()) return NULL;
1219 aCI.SetBase(aRefBase);
1220 aCI.SetFirstPoint(aRefPnt1);
1221 aCI.SetLastPoint(aRefPnt2);
1223 //Compute the Prism value
1226 if (!GetSolver()->ComputeFunction(aFunction)) {
1227 //SetErrorCode("Prism driver failed");
1228 SetErrorCode("Extrusion can not be created, check input data");
1232 catch (Standard_Failure) {
1233 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1234 SetErrorCode(aFail->GetMessageString());
1238 //Make a Python command
1239 GEOM::TPythonDump(aFunction) << aPrism << " = geompy.MakePrism2Ways("
1240 << theBase << ", " << thePoint1 << ", " << thePoint2 << ")";
1246 //=============================================================================
1250 //=============================================================================
1251 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePrismDXDYDZ
1252 (Handle(GEOM_Object) theBase, double theDX, double theDY, double theDZ,
1253 double theScaleFactor)
1257 if (theBase.IsNull()) return NULL;
1259 //Add a new Prism object
1260 Handle(GEOM_Object) aPrism = GetEngine()->AddObject(GetDocID(), GEOM_PRISM);
1262 //Add a new Prism function for creation a Prism by DXDYDZ
1263 Handle(GEOM_Function) aFunction =
1264 aPrism->AddFunction(GEOMImpl_PrismDriver::GetID(), PRISM_BASE_DXDYDZ);
1265 if (aFunction.IsNull()) return NULL;
1267 //Check if the function is set correctly
1268 if (aFunction->GetDriverGUID() != GEOMImpl_PrismDriver::GetID()) return NULL;
1270 GEOMImpl_IPrism aCI (aFunction);
1272 Handle(GEOM_Function) aRefBase = theBase->GetLastFunction();
1274 if (aRefBase.IsNull()) return NULL;
1276 aCI.SetBase(aRefBase);
1280 aCI.SetScale(theScaleFactor);
1282 //Compute the Prism value
1285 if (!GetSolver()->ComputeFunction(aFunction)) {
1286 SetErrorCode("Extrusion can not be created, check input data");
1290 catch (Standard_Failure) {
1291 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1292 SetErrorCode(aFail->GetMessageString());
1296 //Make a Python command
1297 GEOM::TPythonDump pd (aFunction);
1298 pd << aPrism << " = geompy.MakePrismDXDYDZ("
1299 << theBase << ", " << theDX << ", " << theDY << ", " << theDZ;
1300 if (theScaleFactor > Precision::Confusion())
1301 pd << ", " << theScaleFactor << ")";
1309 //=============================================================================
1311 * MakePrismDXDYDZ_2WAYS
1313 //=============================================================================
1314 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePrismDXDYDZ2Ways
1315 (Handle(GEOM_Object) theBase, double theDX, double theDY, double theDZ)
1319 if (theBase.IsNull()) return NULL;
1321 //Add a new Prism object
1322 Handle(GEOM_Object) aPrism = GetEngine()->AddObject(GetDocID(), GEOM_PRISM);
1324 //Add a new Prism function for creation a Prism by DXDYDZ
1325 Handle(GEOM_Function) aFunction =
1326 aPrism->AddFunction(GEOMImpl_PrismDriver::GetID(), PRISM_BASE_DXDYDZ_2WAYS);
1327 if (aFunction.IsNull()) return NULL;
1329 //Check if the function is set correctly
1330 if (aFunction->GetDriverGUID() != GEOMImpl_PrismDriver::GetID()) return NULL;
1332 GEOMImpl_IPrism aCI (aFunction);
1334 Handle(GEOM_Function) aRefBase = theBase->GetLastFunction();
1336 if (aRefBase.IsNull()) return NULL;
1338 aCI.SetBase(aRefBase);
1343 //Compute the Prism value
1346 if (!GetSolver()->ComputeFunction(aFunction)) {
1347 SetErrorCode("Extrusion can not be created, check input data");
1351 catch (Standard_Failure) {
1352 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1353 SetErrorCode(aFail->GetMessageString());
1357 //Make a Python command
1358 GEOM::TPythonDump(aFunction) << aPrism << " = geompy.MakePrismDXDYDZ2Ways("
1359 << theBase << ", " << theDX << ", " << theDY << ", " << theDZ << ")";
1365 //=============================================================================
1369 //=============================================================================
1370 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeDraftPrism
1371 (Handle(GEOM_Object) theInitShape ,Handle(GEOM_Object) theBase, double theHeight, double theAngle, bool theFuse, bool theInvert)
1375 if (theBase.IsNull() || theInitShape.IsNull()) return NULL;
1377 Handle(GEOM_Object) aPrism = NULL;
1381 //Add a new Extruded Boss object
1382 aPrism = GetEngine()->AddObject(GetDocID(), GEOM_EXTRUDED_BOSS);
1386 //Add a new Extruded Cut object
1387 aPrism = GetEngine()->AddObject(GetDocID(), GEOM_EXTRUDED_CUT);
1390 //Add a new Prism function for the creation of a Draft Prism feature
1391 Handle(GEOM_Function) aFunction =
1392 aPrism->AddFunction(GEOMImpl_PrismDriver::GetID(), DRAFT_PRISM_FEATURE);
1393 if (aFunction.IsNull()) return NULL;
1395 //Check if the function is set correctly
1396 if (aFunction->GetDriverGUID() != GEOMImpl_PrismDriver::GetID()) return NULL;
1398 GEOMImpl_IPrism aCI (aFunction);
1400 Handle(GEOM_Function) aRefInit = theInitShape->GetLastFunction();
1401 Handle(GEOM_Function) aRefBase = theBase->GetLastFunction();
1403 if (aRefBase.IsNull() || aRefInit.IsNull()) return NULL;
1406 aCI.SetBase(aRefBase);
1407 aCI.SetInitShape(aRefInit);
1408 aCI.SetH(theHeight);
1409 aCI.SetDraftAngle(theAngle);
1414 aCI.SetInvertFlag(theInvert);
1416 //Compute the Draft Prism Feature value
1419 if (!GetSolver()->ComputeFunction(aFunction)) {
1420 SetErrorCode("Extrusion can not be created, check input data");
1424 catch (Standard_Failure) {
1425 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1426 SetErrorCode(aFail->GetMessageString());
1430 //Make a Python command
1431 GEOM::TPythonDump pd (aFunction);
1434 pd << aPrism << " = geompy.MakeExtrudedBoss(" << theInitShape << ", " << theBase << ", "
1435 << theHeight << ", " << theAngle;
1439 pd << aPrism << " = geompy.MakeExtrudedCut(" << theInitShape << ", " << theBase << ", "
1440 << theHeight << ", " << theAngle;
1443 pd << ", " << theInvert;
1450 //=============================================================================
1454 //=============================================================================
1455 Handle(TColStd_HSequenceOfTransient) GEOMImpl_I3DPrimOperations::MakePipe
1456 (const Handle(GEOM_Object) &theBase,
1457 const Handle(GEOM_Object) &thePath,
1458 const bool IsGenerateGroups)
1462 if (theBase.IsNull() || thePath.IsNull()) return NULL;
1464 //Add a new Pipe object
1465 Handle(GEOM_Object) aPipe = GetEngine()->AddObject(GetDocID(), GEOM_PIPE);
1467 //Add a new Pipe function
1468 Handle(GEOM_Function) aFunction =
1469 aPipe->AddFunction(GEOMImpl_PipeDriver::GetID(), PIPE_BASE_PATH);
1470 if (aFunction.IsNull()) return NULL;
1472 //Check if the function is set correctly
1473 if (aFunction->GetDriverGUID() != GEOMImpl_PipeDriver::GetID()) return NULL;
1475 GEOMImpl_IPipe aCI (aFunction);
1477 Handle(GEOM_Function) aRefBase = theBase->GetLastFunction();
1478 Handle(GEOM_Function) aRefPath = thePath->GetLastFunction();
1480 if (aRefBase.IsNull() || aRefPath.IsNull()) return NULL;
1482 aCI.SetBase(aRefBase);
1483 aCI.SetPath(aRefPath);
1484 aCI.SetGenerateGroups(IsGenerateGroups);
1486 //Compute the Pipe value
1489 if (!GetSolver()->ComputeFunction(aFunction)) {
1490 SetErrorCode("Pipe driver failed");
1494 catch (Standard_Failure) {
1495 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1496 SetErrorCode(aFail->GetMessageString());
1500 // Create the sequence of objects.
1501 Handle(TColStd_HSequenceOfTransient) aSeq = new TColStd_HSequenceOfTransient;
1503 aSeq->Append(aPipe);
1504 createGroups(aPipe, &aCI, aSeq);
1506 //Make a Python command
1507 GEOM::TPythonDump pyDump(aFunction);
1509 if (IsGenerateGroups) {
1515 pyDump << " = geompy.MakePipe(" << theBase << ", " << thePath;
1517 if (IsGenerateGroups) {
1528 //=============================================================================
1530 * MakeRevolutionAxisAngle
1532 //=============================================================================
1533 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeRevolutionAxisAngle (Handle(GEOM_Object) theBase,
1534 Handle(GEOM_Object) theAxis,
1539 if (theBase.IsNull() || theAxis.IsNull()) return NULL;
1541 //Add a new Revolution object
1542 Handle(GEOM_Object) aRevolution = GetEngine()->AddObject(GetDocID(), GEOM_REVOLUTION);
1544 //Add a new Revolution function for creation a revolution relatively to axis
1545 Handle(GEOM_Function) aFunction =
1546 aRevolution->AddFunction(GEOMImpl_RevolutionDriver::GetID(), REVOLUTION_BASE_AXIS_ANGLE);
1547 if (aFunction.IsNull()) return NULL;
1549 //Check if the function is set correctly
1550 if (aFunction->GetDriverGUID() != GEOMImpl_RevolutionDriver::GetID()) return NULL;
1552 GEOMImpl_IRevolution aCI (aFunction);
1554 Handle(GEOM_Function) aRefBase = theBase->GetLastFunction();
1555 Handle(GEOM_Function) aRefAxis = theAxis->GetLastFunction();
1557 if (aRefBase.IsNull() || aRefAxis.IsNull()) return NULL;
1559 aCI.SetBase(aRefBase);
1560 aCI.SetAxis(aRefAxis);
1561 aCI.SetAngle(theAngle);
1563 //Compute the Revolution value
1566 if (!GetSolver()->ComputeFunction(aFunction)) {
1567 SetErrorCode("Revolution driver failed");
1571 catch (Standard_Failure) {
1572 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1573 SetErrorCode(aFail->GetMessageString());
1577 //Make a Python command
1578 GEOM::TPythonDump(aFunction) << aRevolution << " = geompy.MakeRevolution("
1579 << theBase << ", " << theAxis << ", " << theAngle * 180.0 / M_PI << "*math.pi/180.0)";
1585 //=============================================================================
1587 * MakeRevolutionAxisAngle2Ways
1589 //=============================================================================
1590 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeRevolutionAxisAngle2Ways
1591 (Handle(GEOM_Object) theBase, Handle(GEOM_Object) theAxis, double theAngle)
1595 if (theBase.IsNull() || theAxis.IsNull()) return NULL;
1597 //Add a new Revolution object
1598 Handle(GEOM_Object) aRevolution = GetEngine()->AddObject(GetDocID(), GEOM_REVOLUTION);
1600 //Add a new Revolution function for creation a revolution relatively to axis
1601 Handle(GEOM_Function) aFunction =
1602 aRevolution->AddFunction(GEOMImpl_RevolutionDriver::GetID(), REVOLUTION_BASE_AXIS_ANGLE_2WAYS);
1603 if (aFunction.IsNull()) return NULL;
1605 //Check if the function is set correctly
1606 if (aFunction->GetDriverGUID() != GEOMImpl_RevolutionDriver::GetID()) return NULL;
1608 GEOMImpl_IRevolution aCI (aFunction);
1610 Handle(GEOM_Function) aRefBase = theBase->GetLastFunction();
1611 Handle(GEOM_Function) aRefAxis = theAxis->GetLastFunction();
1613 if (aRefBase.IsNull() || aRefAxis.IsNull()) return NULL;
1615 aCI.SetBase(aRefBase);
1616 aCI.SetAxis(aRefAxis);
1617 aCI.SetAngle(theAngle);
1619 //Compute the Revolution value
1622 if (!GetSolver()->ComputeFunction(aFunction)) {
1623 SetErrorCode("Revolution driver failed");
1627 catch (Standard_Failure) {
1628 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1629 SetErrorCode(aFail->GetMessageString());
1633 //Make a Python command
1634 GEOM::TPythonDump(aFunction) << aRevolution << " = geompy.MakeRevolution2Ways("
1635 << theBase << ", " << theAxis << ", " << theAngle * 180.0 / M_PI << "*math.pi/180.0)";
1641 //=============================================================================
1645 //=============================================================================
1647 GEOMImpl_I3DPrimOperations::MakeFilling (std::list< Handle(GEOM_Object)> & theContours,
1648 int theMinDeg, int theMaxDeg,
1649 double theTol2D, double theTol3D, int theNbIter,
1650 int theMethod, bool isApprox)
1654 Handle(TColStd_HSequenceOfTransient) contours = GEOM_Object::GetLastFunctions( theContours );
1655 if ( contours.IsNull() || contours->IsEmpty() ) {
1656 SetErrorCode("NULL argument shape");
1659 //Add a new Filling object
1660 Handle(GEOM_Object) aFilling = GetEngine()->AddObject(GetDocID(), GEOM_FILLING);
1662 //Add a new Filling function for creation a filling from a compound
1663 Handle(GEOM_Function) aFunction = aFilling->AddFunction(GEOMImpl_FillingDriver::GetID(), BASIC_FILLING);
1664 if (aFunction.IsNull()) return NULL;
1666 //Check if the function is set correctly
1667 if (aFunction->GetDriverGUID() != GEOMImpl_FillingDriver::GetID()) return NULL;
1669 GEOMImpl_IFilling aFI (aFunction);
1670 aFI.SetShapes(contours);
1671 aFI.SetMinDeg(theMinDeg);
1672 aFI.SetMaxDeg(theMaxDeg);
1673 aFI.SetTol2D(theTol2D);
1674 aFI.SetTol3D(theTol3D);
1675 aFI.SetNbIter(theNbIter);
1676 aFI.SetApprox(isApprox);
1677 aFI.SetMethod(theMethod);
1679 //Compute the Solid value
1682 if (!GetSolver()->ComputeFunction(aFunction)) {
1683 SetErrorCode("Filling driver failed");
1687 catch (Standard_Failure) {
1688 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1689 if (strcmp(aFail->GetMessageString(), "Geom_BSplineSurface") == 0)
1690 SetErrorCode("B-Spline surface construction failed");
1692 SetErrorCode(aFail->GetMessageString());
1696 //Make a Python command
1697 GEOM::TPythonDump pd (aFunction);
1698 pd << aFilling << " = geompy.MakeFilling(" << theContours ;
1699 if ( theMinDeg != 2 ) pd << ", theMinDeg=" << theMinDeg ;
1700 if ( theMaxDeg != 5 ) pd << ", theMaxDeg=" << theMaxDeg ;
1701 if ( fabs(theTol2D-0.0001) > Precision::Confusion() )
1702 { pd << ", theTol2D=" << theTol2D ; }
1703 if ( fabs(theTol3D-0.0001) > Precision::Confusion() )
1704 { pd << ", theTol3D=" << theTol3D ; }
1705 if ( theNbIter != 0 ) pd << ", theNbIter=" << theNbIter ;
1706 if ( theMethod==1 ) pd << ", theMethod=GEOM.FOM_UseOri";
1707 else if( theMethod==2 ) pd << ", theMethod=GEOM.FOM_AutoCorrect";
1708 if ( isApprox ) pd << ", isApprox=" << isApprox ;
1715 //=============================================================================
1719 //=============================================================================
1720 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeThruSections(
1721 const Handle(TColStd_HSequenceOfTransient)& theSeqSections,
1726 Handle(GEOM_Object) anObj;
1728 if(theSeqSections.IsNull())
1731 Standard_Integer nbObj = theSeqSections->Length();
1735 //Add a new ThruSections object
1736 Handle(GEOM_Object) aThruSect = GetEngine()->AddObject(GetDocID(), GEOM_THRUSECTIONS);
1739 //Add a new ThruSections function
1741 int aTypeFunc = (theRuled ? THRUSECTIONS_RULED : THRUSECTIONS_SMOOTHED);
1742 Handle(GEOM_Function) aFunction =
1743 aThruSect->AddFunction(GEOMImpl_ThruSectionsDriver::GetID(), aTypeFunc);
1744 if (aFunction.IsNull()) return anObj;
1746 //Check if the function is set correctly
1747 if (aFunction->GetDriverGUID() != GEOMImpl_ThruSectionsDriver::GetID()) return NULL;
1749 GEOMImpl_IThruSections aCI (aFunction);
1751 Handle(TColStd_HSequenceOfTransient) aSeqSections = new TColStd_HSequenceOfTransient;
1753 Standard_Integer i =1;
1754 for( ; i <= nbObj; i++) {
1756 Handle(Standard_Transient) anItem = theSeqSections->Value(i);
1760 Handle(GEOM_Object) aSectObj = Handle(GEOM_Object)::DownCast(anItem);
1761 if(!aSectObj.IsNull())
1763 Handle(GEOM_Function) aRefSect = aSectObj->GetLastFunction();
1764 if(!aRefSect.IsNull())
1765 aSeqSections->Append(aRefSect);
1769 if(!aSeqSections->Length())
1772 aCI.SetSections(aSeqSections);
1773 aCI.SetSolidMode(theModeSolid);
1774 aCI.SetPrecision(thePreci);
1776 //Compute the ThruSections value
1779 if (!GetSolver()->ComputeFunction(aFunction)) {
1780 SetErrorCode("ThruSections driver failed");
1784 catch (Standard_Failure) {
1785 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1786 SetErrorCode(aFail->GetMessageString());
1790 //Make a Python command
1791 GEOM::TPythonDump pyDump(aFunction);
1792 pyDump << aThruSect << " = geompy.MakeThruSections([";
1794 for(i =1 ; i <= nbObj; i++) {
1796 Handle(Standard_Transient) anItem = theSeqSections->Value(i);
1800 Handle(GEOM_Object) aSectObj = Handle(GEOM_Object)::DownCast(anItem);
1801 if(!aSectObj.IsNull()) {
1808 pyDump<< "],"<<theModeSolid << "," << thePreci <<","<< theRuled <<")";
1815 //=============================================================================
1817 * MakePipeWithDifferentSections
1819 //=============================================================================
1820 Handle(TColStd_HSequenceOfTransient)
1821 GEOMImpl_I3DPrimOperations::MakePipeWithDifferentSections
1822 (const Handle(TColStd_HSequenceOfTransient) &theBases,
1823 const Handle(TColStd_HSequenceOfTransient) &theLocations,
1824 const Handle(GEOM_Object) &thePath,
1825 const bool theWithContact,
1826 const bool theWithCorrections,
1827 const bool IsBySteps,
1828 const bool IsGenerateGroups)
1831 if(theBases.IsNull())
1834 Standard_Integer nbBases = theBases->Length();
1839 Standard_Integer nbLocs = (theLocations.IsNull() ? 0 :theLocations->Length());
1840 //Add a new Pipe object
1841 Handle(GEOM_Object) aPipeDS = GetEngine()->AddObject(GetDocID(), GEOM_PIPE);
1843 //Add a new Pipe function
1845 Handle(GEOM_Function) aFunction =
1846 aPipeDS->AddFunction(GEOMImpl_PipeDriver::GetID(), PIPE_DIFFERENT_SECTIONS);
1847 if (aFunction.IsNull()) return NULL;
1849 //Check if the function is set correctly
1850 if (aFunction->GetDriverGUID() != GEOMImpl_PipeDriver::GetID()) return NULL;
1852 GEOMImpl_IPipeDiffSect aCI (aFunction);
1854 Handle(GEOM_Function) aRefPath = thePath->GetLastFunction();
1855 if(aRefPath.IsNull())
1858 Handle(TColStd_HSequenceOfTransient) aSeqBases = new TColStd_HSequenceOfTransient;
1859 Handle(TColStd_HSequenceOfTransient) aSeqLocs = new TColStd_HSequenceOfTransient;
1861 Standard_Integer i =1;
1862 for( ; i <= nbBases; i++) {
1864 Handle(Standard_Transient) anItem = theBases->Value(i);
1868 Handle(GEOM_Object) aBase = Handle(GEOM_Object)::DownCast(anItem);
1871 Handle(GEOM_Function) aRefBase = aBase->GetLastFunction();
1872 if(aRefBase.IsNull())
1876 Handle(Standard_Transient) anItemLoc = theLocations->Value(i);
1877 if(anItemLoc.IsNull())
1880 Handle(GEOM_Object) aLoc = Handle(GEOM_Object)::DownCast(anItemLoc);
1883 Handle(GEOM_Function) aRefLoc = aLoc->GetLastFunction();
1884 if(aRefLoc.IsNull())
1886 aSeqLocs->Append(aRefLoc);
1888 aSeqBases->Append(aRefBase);
1891 if(!aSeqBases->Length())
1894 aCI.SetBases(aSeqBases);
1895 aCI.SetLocations(aSeqLocs);
1896 aCI.SetPath(aRefPath);
1899 aCI.SetWithContactMode(theWithContact);
1900 aCI.SetWithCorrectionMode(theWithCorrections);
1903 aCI.SetIsBySteps(IsBySteps);
1904 aCI.SetGenerateGroups(IsGenerateGroups);
1906 //Compute the Pipe value
1909 if (!GetSolver()->ComputeFunction(aFunction)) {
1910 SetErrorCode("Pipe with defferent section driver failed");
1914 catch (Standard_Failure) {
1915 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1916 SetErrorCode(aFail->GetMessageString());
1920 // Create the sequence of objects.
1921 Handle(TColStd_HSequenceOfTransient) aSeq = new TColStd_HSequenceOfTransient;
1923 aSeq->Append(aPipeDS);
1924 createGroups(aPipeDS, &aCI, aSeq);
1926 //Make a Python command
1927 GEOM::TPythonDump pyDump(aFunction);
1929 if (IsGenerateGroups) {
1936 pyDump << " = geompy.MakePipeWithDifferentSectionsBySteps([";
1938 pyDump << " = geompy.MakePipeWithDifferentSections([";
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 <= nbLocs; i++) {
1959 Handle(Standard_Transient) anItem = theLocations->Value(i);
1963 Handle(GEOM_Object) anObj = Handle(GEOM_Object)::DownCast(anItem);
1964 if(!anObj.IsNull()) {
1971 pyDump<< "], "<<thePath;
1974 pyDump<<","<<theWithContact << "," << theWithCorrections;
1977 if (IsGenerateGroups) {
1988 //=============================================================================
1990 * MakePipeWithShellSections
1992 //=============================================================================
1993 Handle(TColStd_HSequenceOfTransient)
1994 GEOMImpl_I3DPrimOperations::MakePipeWithShellSections
1995 (const Handle(TColStd_HSequenceOfTransient) &theBases,
1996 const Handle(TColStd_HSequenceOfTransient) &theSubBases,
1997 const Handle(TColStd_HSequenceOfTransient) &theLocations,
1998 const Handle(GEOM_Object) &thePath,
1999 const bool theWithContact,
2000 const bool theWithCorrections,
2001 const bool IsGenerateGroups)
2004 if(theBases.IsNull())
2007 Standard_Integer nbBases = theBases->Length();
2012 Standard_Integer nbSubBases = (theSubBases.IsNull() ? 0 :theSubBases->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_SHELL_SECTIONS);
2023 if (aFunction.IsNull()) return NULL;
2025 //Check if the function is set correctly
2026 if (aFunction->GetDriverGUID() != GEOMImpl_PipeDriver::GetID()) return NULL;
2028 //GEOMImpl_IPipeDiffSect aCI (aFunction);
2029 GEOMImpl_IPipeShellSect aCI (aFunction);
2031 Handle(GEOM_Function) aRefPath = thePath->GetLastFunction();
2032 if(aRefPath.IsNull())
2035 Handle(TColStd_HSequenceOfTransient) aSeqBases = new TColStd_HSequenceOfTransient;
2036 Handle(TColStd_HSequenceOfTransient) aSeqSubBases = new TColStd_HSequenceOfTransient;
2037 Handle(TColStd_HSequenceOfTransient) aSeqLocs = new TColStd_HSequenceOfTransient;
2039 Standard_Integer i =1;
2040 for( ; i <= nbBases; i++) {
2042 Handle(Standard_Transient) anItem = theBases->Value(i);
2045 Handle(GEOM_Object) aBase = Handle(GEOM_Object)::DownCast(anItem);
2048 Handle(GEOM_Function) aRefBase = aBase->GetLastFunction();
2049 if(aRefBase.IsNull())
2052 if( nbSubBases >= nbBases ) {
2053 Handle(Standard_Transient) aSubItem = theSubBases->Value(i);
2054 if(aSubItem.IsNull())
2056 Handle(GEOM_Object) aSubBase = Handle(GEOM_Object)::DownCast(aSubItem);
2057 if(aSubBase.IsNull())
2059 Handle(GEOM_Function) aRefSubBase = aSubBase->GetLastFunction();
2060 if(aRefSubBase.IsNull())
2062 aSeqSubBases->Append(aRefSubBase);
2066 Handle(Standard_Transient) anItemLoc = theLocations->Value(i);
2067 if(anItemLoc.IsNull())
2069 Handle(GEOM_Object) aLoc = Handle(GEOM_Object)::DownCast(anItemLoc);
2072 Handle(GEOM_Function) aRefLoc = aLoc->GetLastFunction();
2073 if(aRefLoc.IsNull())
2075 aSeqLocs->Append(aRefLoc);
2078 aSeqBases->Append(aRefBase);
2081 if(!aSeqBases->Length())
2084 aCI.SetBases(aSeqBases);
2085 aCI.SetSubBases(aSeqSubBases);
2086 aCI.SetLocations(aSeqLocs);
2087 aCI.SetPath(aRefPath);
2088 aCI.SetWithContactMode(theWithContact);
2089 aCI.SetWithCorrectionMode(theWithCorrections);
2090 aCI.SetGenerateGroups(IsGenerateGroups);
2092 //Compute the Pipe value
2095 if (!GetSolver()->ComputeFunction(aFunction)) {
2096 SetErrorCode("Pipe with shell sections driver failed");
2100 catch (Standard_Failure) {
2101 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
2102 SetErrorCode(aFail->GetMessageString());
2106 // Create the sequence of objects.
2107 Handle(TColStd_HSequenceOfTransient) aSeq = new TColStd_HSequenceOfTransient;
2109 aSeq->Append(aPipeDS);
2110 createGroups(aPipeDS, &aCI, aSeq);
2112 //Make a Python command
2113 GEOM::TPythonDump pyDump(aFunction);
2115 if (IsGenerateGroups) {
2121 pyDump << " = geompy.MakePipeWithShellSections([";
2123 for(i =1 ; i <= nbBases; i++) {
2125 Handle(Standard_Transient) anItem = theBases->Value(i);
2129 Handle(GEOM_Object) anObj = Handle(GEOM_Object)::DownCast(anItem);
2130 if(!anObj.IsNull()) {
2139 for(i =1 ; i <= nbSubBases; i++) {
2141 Handle(Standard_Transient) anItem = theSubBases->Value(i);
2145 Handle(GEOM_Object) anObj = Handle(GEOM_Object)::DownCast(anItem);
2146 if(!anObj.IsNull()) {
2155 for(i =1 ; i <= nbLocs; i++) {
2157 Handle(Standard_Transient) anItem = theLocations->Value(i);
2161 Handle(GEOM_Object) anObj = Handle(GEOM_Object)::DownCast(anItem);
2162 if(!anObj.IsNull()) {
2169 pyDump<< "], "<<thePath<<","<<theWithContact << "," << theWithCorrections;
2171 if (IsGenerateGroups) {
2183 //=============================================================================
2185 * MakePipeShellsWithoutPath
2187 //=============================================================================
2188 Handle(TColStd_HSequenceOfTransient)
2189 GEOMImpl_I3DPrimOperations::MakePipeShellsWithoutPath
2190 (const Handle(TColStd_HSequenceOfTransient) &theBases,
2191 const Handle(TColStd_HSequenceOfTransient) &theLocations,
2192 const bool IsGenerateGroups)
2195 if(theBases.IsNull())
2198 Standard_Integer nbBases = theBases->Length();
2203 Standard_Integer nbLocs = (theLocations.IsNull() ? 0 :theLocations->Length());
2205 //Add a new Pipe object
2206 Handle(GEOM_Object) aPipeDS = GetEngine()->AddObject(GetDocID(), GEOM_PIPE);
2208 //Add a new Pipe function
2210 Handle(GEOM_Function) aFunction =
2211 aPipeDS->AddFunction(GEOMImpl_PipeDriver::GetID(), PIPE_SHELLS_WITHOUT_PATH);
2212 if (aFunction.IsNull()) return NULL;
2214 //Check if the function is set correctly
2215 if (aFunction->GetDriverGUID() != GEOMImpl_PipeDriver::GetID()) return NULL;
2217 GEOMImpl_IPipeShellSect aCI (aFunction);
2219 Handle(TColStd_HSequenceOfTransient) aSeqBases = new TColStd_HSequenceOfTransient;
2220 Handle(TColStd_HSequenceOfTransient) aSeqLocs = new TColStd_HSequenceOfTransient;
2222 Standard_Integer i =1;
2223 for( ; i <= nbBases; i++) {
2225 Handle(Standard_Transient) anItem = theBases->Value(i);
2228 Handle(GEOM_Object) aBase = Handle(GEOM_Object)::DownCast(anItem);
2231 Handle(GEOM_Function) aRefBase = aBase->GetLastFunction();
2232 if(aRefBase.IsNull())
2236 Handle(Standard_Transient) anItemLoc = theLocations->Value(i);
2237 if(anItemLoc.IsNull())
2239 Handle(GEOM_Object) aLoc = Handle(GEOM_Object)::DownCast(anItemLoc);
2242 Handle(GEOM_Function) aRefLoc = aLoc->GetLastFunction();
2243 if(aRefLoc.IsNull())
2245 aSeqLocs->Append(aRefLoc);
2248 aSeqBases->Append(aRefBase);
2251 if(!aSeqBases->Length())
2254 aCI.SetBases(aSeqBases);
2255 aCI.SetLocations(aSeqLocs);
2256 aCI.SetGenerateGroups(IsGenerateGroups);
2258 //Compute the Pipe value
2261 if (!GetSolver()->ComputeFunction(aFunction)) {
2262 SetErrorCode("Pipe with shell sections without path driver failed");
2266 catch (Standard_Failure) {
2267 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
2268 SetErrorCode(aFail->GetMessageString());
2272 // Create the sequence of objects.
2273 Handle(TColStd_HSequenceOfTransient) aSeq = new TColStd_HSequenceOfTransient;
2275 aSeq->Append(aPipeDS);
2276 createGroups(aPipeDS, &aCI, aSeq);
2278 //Make a Python command
2279 GEOM::TPythonDump pyDump(aFunction);
2281 if (IsGenerateGroups) {
2287 pyDump << " = geompy.MakePipeShellsWithoutPath([";
2289 for(i =1 ; i <= nbBases; i++) {
2291 Handle(Standard_Transient) anItem = theBases->Value(i);
2295 Handle(GEOM_Object) anObj = Handle(GEOM_Object)::DownCast(anItem);
2296 if(!anObj.IsNull()) {
2305 for(i =1 ; i <= nbLocs; i++) {
2307 Handle(Standard_Transient) anItem = theLocations->Value(i);
2311 Handle(GEOM_Object) anObj = Handle(GEOM_Object)::DownCast(anItem);
2312 if(!anObj.IsNull()) {
2321 if (IsGenerateGroups) {
2332 //=============================================================================
2334 * MakePipeBiNormalAlongVector
2336 //=============================================================================
2337 Handle(TColStd_HSequenceOfTransient)
2338 GEOMImpl_I3DPrimOperations::MakePipeBiNormalAlongVector
2339 (const Handle(GEOM_Object) &theBase,
2340 const Handle(GEOM_Object) &thePath,
2341 const Handle(GEOM_Object) &theVec,
2342 const bool IsGenerateGroups)
2346 if (theBase.IsNull() || thePath.IsNull() || theVec.IsNull()) return NULL;
2348 //Add a new Pipe object
2349 Handle(GEOM_Object) aPipe = GetEngine()->AddObject(GetDocID(), GEOM_PIPE);
2351 //Add a new Pipe function
2352 Handle(GEOM_Function) aFunction =
2353 aPipe->AddFunction(GEOMImpl_PipeDriver::GetID(), PIPE_BI_NORMAL_ALONG_VECTOR);
2354 if (aFunction.IsNull()) return NULL;
2356 //Check if the function is set correctly
2357 if (aFunction->GetDriverGUID() != GEOMImpl_PipeDriver::GetID()) return NULL;
2359 GEOMImpl_IPipeBiNormal aCI (aFunction);
2361 Handle(GEOM_Function) aRefBase = theBase->GetLastFunction();
2362 Handle(GEOM_Function) aRefPath = thePath->GetLastFunction();
2363 Handle(GEOM_Function) aRefVec = theVec->GetLastFunction();
2365 if (aRefBase.IsNull() || aRefPath.IsNull() || aRefVec.IsNull()) return NULL;
2367 aCI.SetBase(aRefBase);
2368 aCI.SetPath(aRefPath);
2369 aCI.SetVector(aRefVec);
2370 aCI.SetGenerateGroups(IsGenerateGroups);
2372 //Compute the Pipe value
2375 if (!GetSolver()->ComputeFunction(aFunction)) {
2376 SetErrorCode("Pipe driver failed");
2380 catch (Standard_Failure) {
2381 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
2382 SetErrorCode(aFail->GetMessageString());
2386 // Create the sequence of objects.
2387 Handle(TColStd_HSequenceOfTransient) aSeq = new TColStd_HSequenceOfTransient;
2389 aSeq->Append(aPipe);
2390 createGroups(aPipe, &aCI, aSeq);
2392 //Make a Python command
2393 GEOM::TPythonDump pyDump(aFunction);
2395 if (IsGenerateGroups) {
2401 pyDump << " = geompy.MakePipeBiNormalAlongVector("
2402 << theBase << ", " << thePath << ", " << theVec;
2404 if (IsGenerateGroups) {
2414 //=============================================================================
2418 //=============================================================================
2419 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeThickening
2420 (Handle(GEOM_Object) theObject,
2421 const Handle(TColStd_HArray1OfInteger) &theFacesIDs,
2428 if (theObject.IsNull()) return NULL;
2430 Handle(GEOM_Function) anOriginal = theObject->GetLastFunction();
2431 if (anOriginal.IsNull()) return NULL; //There is no function which creates an object to be offset
2433 //Add a new Offset function
2434 Handle(GEOM_Function) aFunction;
2435 Handle(GEOM_Object) aCopy;
2438 //Add a new Copy object
2439 aCopy = GetEngine()->AddObject(GetDocID(), theObject->GetType());
2440 aFunction = aCopy->AddFunction(GEOMImpl_OffsetDriver::GetID(), OFFSET_THICKENING_COPY);
2443 aFunction = theObject->AddFunction(GEOMImpl_OffsetDriver::GetID(), OFFSET_THICKENING);
2445 if (aFunction.IsNull()) return NULL;
2447 //Check if the function is set correctly
2448 if (aFunction->GetDriverGUID() != GEOMImpl_OffsetDriver::GetID()) return NULL;
2450 GEOMImpl_IOffset aTI (aFunction);
2451 aTI.SetShape(anOriginal);
2452 aTI.SetValue(theOffset);
2453 aTI.SetParam(theInside);
2455 if (theFacesIDs.IsNull() == Standard_False) {
2456 aTI.SetFaceIDs(theFacesIDs);
2459 //Compute the offset
2462 if (!GetSolver()->ComputeFunction(aFunction)) {
2463 SetErrorCode("Offset driver failed");
2467 catch (Standard_Failure) {
2468 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
2469 SetErrorCode(aFail->GetMessageString());
2473 //Make a Python command
2474 GEOM::TPythonDump pd (aFunction);
2475 Handle(GEOM_Object) aResult;
2478 pd << aCopy << " = geompy.MakeThickSolid("
2479 << theObject << ", " << theOffset;
2482 pd << "geompy.Thicken(" << theObject << ", " << theOffset;
2483 aResult = theObject;
2487 if (theFacesIDs.IsNull() == Standard_False) {
2491 for (i = theFacesIDs->Lower(); i < theFacesIDs->Upper(); ++i) {
2492 pd << theFacesIDs->Value(i) << ", ";
2494 // Dump the last value.
2495 pd << theFacesIDs->Value(i);
2500 pd << ", " << theInside;
2508 //=============================================================================
2512 //=============================================================================
2513 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::RestorePath (Handle(GEOM_Object) theShape,
2514 Handle(GEOM_Object) theBase1,
2515 Handle(GEOM_Object) theBase2)
2519 if (theShape.IsNull() || theBase1.IsNull() || theBase2.IsNull()) return NULL;
2521 // Add a new Path object
2522 Handle(GEOM_Object) aPath = GetEngine()->AddObject(GetDocID(), GEOM_PIPE_PATH);
2524 // Add a new Path function
2525 Handle(GEOM_Function) aFunction =
2526 aPath->AddFunction(GEOMImpl_PipePathDriver::GetID(), PIPE_PATH_TWO_BASES);
2527 if (aFunction.IsNull()) return NULL;
2529 // Check if the function is set correctly
2530 if (aFunction->GetDriverGUID() != GEOMImpl_PipePathDriver::GetID()) return NULL;
2532 GEOMImpl_IPipePath aCI (aFunction);
2534 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
2535 Handle(GEOM_Function) aRefBase1 = theBase1->GetLastFunction();
2536 Handle(GEOM_Function) aRefBase2 = theBase2->GetLastFunction();
2538 if (aRefShape.IsNull() || aRefBase1.IsNull() || aRefBase2.IsNull()) return NULL;
2540 aCI.SetShape(aRefShape);
2541 aCI.SetBase1(aRefBase1);
2542 aCI.SetBase2(aRefBase2);
2544 // Compute the Path value
2547 if (!GetSolver()->ComputeFunction(aFunction)) {
2548 SetErrorCode("PipePath driver failed");
2552 catch (Standard_Failure) {
2553 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
2554 SetErrorCode("RestorePath: inappropriate arguments given");
2558 // Make a Python command
2559 GEOM::TPythonDump(aFunction) << aPath << " = geompy.RestorePath("
2560 << theShape << ", " << theBase1 << ", " << theBase2 << ")";
2566 //=============================================================================
2570 //=============================================================================
2571 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::RestorePath
2572 (Handle(GEOM_Object) theShape,
2573 const Handle(TColStd_HSequenceOfTransient)& theBase1,
2574 const Handle(TColStd_HSequenceOfTransient)& theBase2)
2578 if (theShape.IsNull() || theBase1.IsNull() || theBase2.IsNull()) return NULL;
2580 Standard_Integer nbBases1 = theBase1->Length();
2581 Standard_Integer nbBases2 = theBase2->Length();
2583 if (!nbBases1 || !nbBases2)
2586 // Add a new Path object
2587 Handle(GEOM_Object) aPath = GetEngine()->AddObject(GetDocID(), GEOM_PIPE_PATH);
2589 // Add a new Path function
2590 Handle(GEOM_Function) aFunction =
2591 aPath->AddFunction(GEOMImpl_PipePathDriver::GetID(), PIPE_PATH_TWO_SEQS);
2592 if (aFunction.IsNull()) return NULL;
2594 // Check if the function is set correctly
2595 if (aFunction->GetDriverGUID() != GEOMImpl_PipePathDriver::GetID()) return NULL;
2597 GEOMImpl_IPipePath aCI (aFunction);
2599 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
2600 if (aRefShape.IsNull()) return NULL;
2602 Handle(TColStd_HSequenceOfTransient) aSeqBases1 = new TColStd_HSequenceOfTransient;
2603 Handle(TColStd_HSequenceOfTransient) aSeqBases2 = new TColStd_HSequenceOfTransient;
2606 for (i = 1; i <= nbBases1; i++) {
2607 Handle(Standard_Transient) anItem = theBase1->Value(i);
2608 if (!anItem.IsNull()) {
2609 Handle(GEOM_Object) aBase = Handle(GEOM_Object)::DownCast(anItem);
2610 if (!aBase.IsNull()) {
2611 Handle(GEOM_Function) aRefBase = aBase->GetLastFunction();
2612 if (!aRefBase.IsNull())
2613 aSeqBases1->Append(aRefBase);
2617 for (i = 1; i <= nbBases2; i++) {
2618 Handle(Standard_Transient) anItem = theBase2->Value(i);
2619 if (!anItem.IsNull()) {
2620 Handle(GEOM_Object) aBase = Handle(GEOM_Object)::DownCast(anItem);
2621 if (!aBase.IsNull()) {
2622 Handle(GEOM_Function) aRefBase = aBase->GetLastFunction();
2623 if (!aRefBase.IsNull())
2624 aSeqBases2->Append(aRefBase);
2628 if (!aSeqBases1->Length() || !aSeqBases2->Length()) return NULL;
2630 aCI.SetShape(aRefShape);
2631 aCI.SetBaseSeq1(aSeqBases1);
2632 aCI.SetBaseSeq2(aSeqBases2);
2634 // Compute the Path value
2637 if (!GetSolver()->ComputeFunction(aFunction)) {
2638 SetErrorCode("PipePath driver failed");
2642 catch (Standard_Failure) {
2643 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
2644 SetErrorCode("RestorePath: inappropriate arguments given");
2648 // Make a Python command
2649 GEOM::TPythonDump pyDump (aFunction);
2650 pyDump << aPath << " = geompy.RestorePathEdges(" << theShape << ", [";
2651 for (i = 1; i <= nbBases1; i++) {
2652 Handle(GEOM_Object) anObj = Handle(GEOM_Object)::DownCast(theBase1->Value(i));
2653 if (!anObj.IsNull()) {
2660 for (i = 1; i <= nbBases2; i++) {
2661 Handle(GEOM_Object) anObj = Handle(GEOM_Object)::DownCast(theBase2->Value(i));
2662 if (!anObj.IsNull()) {
2674 //=============================================================================
2678 //=============================================================================
2679 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::createGroup
2680 (const Handle(GEOM_Object) &theBaseObject,
2681 const Handle(TColStd_HArray1OfInteger) &theGroupIDs,
2682 const TCollection_AsciiString &theName,
2683 const TopTools_IndexedMapOfShape &theIndices)
2685 if (theBaseObject.IsNull() || theGroupIDs.IsNull()) {
2689 // Get the Shape type.
2690 const Standard_Integer anID = theGroupIDs->Value(theGroupIDs->Lower());
2691 const Standard_Integer aNbShapes = theIndices.Extent();
2693 if (anID < 1 || anID > aNbShapes) {
2697 const TopoDS_Shape aSubShape = theIndices.FindKey(anID);
2699 if (aSubShape.IsNull()) {
2704 const TopAbs_ShapeEnum aGroupType = aSubShape.ShapeType();
2705 Handle(GEOM_Object) aGroup =
2706 myGroupOperations->CreateGroup(theBaseObject, aGroupType);
2708 if (aGroup.IsNull() == Standard_False) {
2709 aGroup->GetLastFunction()->SetDescription("");
2710 aGroup->SetName(theName.ToCString());
2712 Handle(TColStd_HSequenceOfInteger) aSeqIDs = new TColStd_HSequenceOfInteger;
2715 for (i = theGroupIDs->Lower(); i <= theGroupIDs->Upper(); ++i) {
2716 // Get and check the index.
2717 const Standard_Integer anIndex = theGroupIDs->Value(i);
2719 if (anIndex < 1 || anIndex > aNbShapes) {
2723 // Get and check the sub-shape.
2724 const TopoDS_Shape aSubShape = theIndices.FindKey(anIndex);
2726 if (aSubShape.IsNull()) {
2730 // Check the shape type.
2731 if (aSubShape.ShapeType() != aGroupType) {
2735 aSeqIDs->Append(anIndex);
2738 myGroupOperations->UnionIDs(aGroup, aSeqIDs);
2739 aGroup->GetLastFunction()->SetDescription("");
2745 //=============================================================================
2749 //=============================================================================
2750 void GEOMImpl_I3DPrimOperations::createGroups
2751 (const Handle(GEOM_Object) &theBaseObject,
2752 GEOMImpl_IPipe *thePipe,
2753 Handle(TColStd_HSequenceOfTransient) &theSequence)
2755 if (theBaseObject.IsNull() || thePipe == NULL || theSequence.IsNull()) {
2759 TopoDS_Shape aShape = theBaseObject->GetValue();
2761 if (aShape.IsNull()) {
2765 TopTools_IndexedMapOfShape anIndices;
2766 Handle(TColStd_HArray1OfInteger) aGroupIDs;
2767 TopoDS_Shape aShapeType;
2768 const Standard_Integer aNbGroups = 5;
2769 Handle(GEOM_Object) aGrps[aNbGroups];
2772 TopExp::MapShapes(aShape, anIndices);
2775 aGroupIDs = thePipe->GetGroupDown();
2776 aGrps[0] = createGroup(theBaseObject, aGroupIDs, "GROUP_DOWN", anIndices);
2777 aGroupIDs = thePipe->GetGroupUp();
2778 aGrps[1] = createGroup(theBaseObject, aGroupIDs, "GROUP_UP", anIndices);
2779 aGroupIDs = thePipe->GetGroupSide1();
2780 aGrps[2] = createGroup(theBaseObject, aGroupIDs, "GROUP_SIDE1", anIndices);
2781 aGroupIDs = thePipe->GetGroupSide2();
2782 aGrps[3] = createGroup(theBaseObject, aGroupIDs, "GROUP_SIDE2", anIndices);
2783 aGroupIDs = thePipe->GetGroupOther();
2784 aGrps[4] = createGroup(theBaseObject, aGroupIDs, "GROUP_OTHER", anIndices);
2786 for (i = 0; i < aNbGroups; ++i) {
2787 if (aGrps[i].IsNull() == Standard_False) {
2788 theSequence->Append(aGrps[i]);