1 // Copyright (C) 2005 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
2 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
4 // This library is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU Lesser General Public
6 // License as published by the Free Software Foundation; either
7 // version 2.1 of the License.
9 // This library is distributed in the hope that it will be useful
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 // Lesser General Public License for more details.
14 // You should have received a copy of the GNU Lesser General Public
15 // License along with this library; if not, write to the Free Software
16 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 #include <Standard_Stream.hxx>
22 #include <GEOMImpl_ILocalOperations.hxx>
24 #include <GEOM_Function.hxx>
25 #include <GEOM_PythonDump.hxx>
27 #include <GEOMImpl_Types.hxx>
29 #include <GEOMImpl_FilletDriver.hxx>
30 #include <GEOMImpl_ChamferDriver.hxx>
32 #include <GEOMImpl_IFillet.hxx>
33 #include <GEOMImpl_IChamfer.hxx>
35 #include <GEOMImpl_IArchimede.hxx>
36 #include <GEOMImpl_ArchimedeDriver.hxx>
38 #include <GEOMImpl_Gen.hxx>
39 #include <GEOMImpl_IShapesOperations.hxx>
41 #include "utilities.h"
43 #include <Utils_ExceptHandlers.hxx>
45 #include <TFunction_DriverTable.hxx>
46 #include <TFunction_Driver.hxx>
47 #include <TFunction_Logbook.hxx>
48 #include <TDF_Tool.hxx>
51 #include <TopoDS_TShape.hxx>
52 #include <TopTools_IndexedMapOfShape.hxx>
54 #include <Standard_Failure.hxx>
55 #include <Standard_ErrorHandler.hxx> // CAREFUL ! position of this file is critic : see Lucien PIGNOLONI / OCC
57 //=============================================================================
61 //=============================================================================
62 GEOMImpl_ILocalOperations::GEOMImpl_ILocalOperations (GEOM_Engine* theEngine, int theDocID)
63 : GEOM_IOperations(theEngine, theDocID)
65 MESSAGE("GEOMImpl_ILocalOperations::GEOMImpl_ILocalOperations");
68 //=============================================================================
72 //=============================================================================
73 GEOMImpl_ILocalOperations::~GEOMImpl_ILocalOperations()
75 MESSAGE("GEOMImpl_ILocalOperations::~GEOMImpl_ILocalOperations");
79 //=============================================================================
83 //=============================================================================
84 Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeFilletAll
85 (Handle(GEOM_Object) theShape, double theR)
89 //Add a new Fillet object
90 Handle(GEOM_Object) aFillet = GetEngine()->AddObject(GetDocID(), GEOM_FILLET);
92 //Add a new Fillet function
93 Handle(GEOM_Function) aFunction =
94 aFillet->AddFunction(GEOMImpl_FilletDriver::GetID(), FILLET_SHAPE_ALL);
95 if (aFunction.IsNull()) return NULL;
97 //Check if the function is set correctly
98 if (aFunction->GetDriverGUID() != GEOMImpl_FilletDriver::GetID()) return NULL;
100 GEOMImpl_IFillet aCI (aFunction);
102 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
103 if (aRefShape.IsNull()) return NULL;
105 aCI.SetShape(aRefShape);
108 //Compute the Fillet value
110 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
113 if (!GetSolver()->ComputeFunction(aFunction)) {
114 SetErrorCode("Fillet driver failed");
118 catch (Standard_Failure) {
119 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
120 SetErrorCode(aFail->GetMessageString());
124 //Make a Python command
125 GEOM::TPythonDump(aFunction) << aFillet << " = geompy.MakeFilletAll("
126 << theShape << ", " << theR << ")";
132 //=============================================================================
136 //=============================================================================
137 Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeFilletEdges
138 (Handle(GEOM_Object) theShape, double theR, list<int> theEdges)
142 //Add a new Fillet object
143 Handle(GEOM_Object) aFillet = GetEngine()->AddObject(GetDocID(), GEOM_FILLET);
145 //Add a new Fillet function
146 Handle(GEOM_Function) aFunction =
147 aFillet->AddFunction(GEOMImpl_FilletDriver::GetID(), FILLET_SHAPE_EDGES);
148 if (aFunction.IsNull()) return NULL;
150 //Check if the function is set correctly
151 if (aFunction->GetDriverGUID() != GEOMImpl_FilletDriver::GetID()) return NULL;
153 GEOMImpl_IFillet aCI (aFunction);
155 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
156 if (aRefShape.IsNull()) return NULL;
158 aCI.SetShape(aRefShape);
160 int aLen = theEdges.size();
164 list<int>::iterator it = theEdges.begin();
165 for (; it != theEdges.end(); it++, ind++) {
166 aCI.SetEdge(ind, (*it));
169 //Compute the Fillet value
171 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
174 if (!GetSolver()->ComputeFunction(aFunction)) {
175 SetErrorCode("Fillet driver failed");
179 catch (Standard_Failure) {
180 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
181 SetErrorCode(aFail->GetMessageString());
185 //Make a Python command
186 GEOM::TPythonDump pd (aFunction);
187 pd << aFillet << " = geompy.MakeFillet(" << theShape
188 << ", " << theR << ", geompy.ShapeType[\"EDGE\"], [";
190 it = theEdges.begin();
192 while (it != theEdges.end()) {
193 pd << ", " << (*it++);
201 //=============================================================================
203 * MakeFilletEdges R1 R2
205 //=============================================================================
206 Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeFilletEdgesR1R2
207 (Handle(GEOM_Object) theShape, double theR1, double theR2, list<int> theEdges)
211 //Add a new Fillet object
212 Handle(GEOM_Object) aFillet = GetEngine()->AddObject(GetDocID(), GEOM_FILLET);
214 //Add a new Fillet function
215 Handle(GEOM_Function) aFunction =
216 aFillet->AddFunction(GEOMImpl_FilletDriver::GetID(), FILLET_SHAPE_EDGES_2R);
217 if (aFunction.IsNull()) return NULL;
219 //Check if the function is set correctly
220 if (aFunction->GetDriverGUID() != GEOMImpl_FilletDriver::GetID()) return NULL;
222 GEOMImpl_IFillet aCI (aFunction);
224 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
225 if (aRefShape.IsNull()) return NULL;
227 aCI.SetShape(aRefShape);
230 int aLen = theEdges.size();
234 list<int>::iterator it = theEdges.begin();
235 for (; it != theEdges.end(); it++, ind++) {
236 aCI.SetEdge(ind, (*it));
239 //Compute the Fillet value
241 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
244 if (!GetSolver()->ComputeFunction(aFunction)) {
245 SetErrorCode("Fillet driver failed");
249 catch (Standard_Failure) {
250 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
251 SetErrorCode(aFail->GetMessageString());
255 //Make a Python command
256 GEOM::TPythonDump pd (aFunction);
257 pd << aFillet << " = geompy.MakeFilletR1R2(" << theShape
258 << ", " << theR1 << ", " <<theR2 << ", geompy.ShapeType[\"EDGE\"], [";
260 it = theEdges.begin();
262 while (it != theEdges.end()) {
263 pd << ", " << (*it++);
272 //=============================================================================
276 //=============================================================================
277 Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeFilletFaces
278 (Handle(GEOM_Object) theShape, double theR, list<int> theFaces)
282 //Add a new Fillet object
283 Handle(GEOM_Object) aFillet = GetEngine()->AddObject(GetDocID(), GEOM_FILLET);
285 //Add a new Fillet function
286 Handle(GEOM_Function) aFunction =
287 aFillet->AddFunction(GEOMImpl_FilletDriver::GetID(), FILLET_SHAPE_FACES);
288 if (aFunction.IsNull()) return NULL;
290 //Check if the function is set correctly
291 if (aFunction->GetDriverGUID() != GEOMImpl_FilletDriver::GetID()) return NULL;
293 GEOMImpl_IFillet aCI (aFunction);
295 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
296 if (aRefShape.IsNull()) return NULL;
298 aCI.SetShape(aRefShape);
300 int aLen = theFaces.size();
304 list<int>::iterator it = theFaces.begin();
305 for (; it != theFaces.end(); it++, ind++) {
306 aCI.SetFace(ind, (*it));
309 //Compute the Fillet value
311 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
314 if (!GetSolver()->ComputeFunction(aFunction)) {
315 SetErrorCode("Fillet driver failed");
319 catch (Standard_Failure) {
320 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
321 SetErrorCode(aFail->GetMessageString());
325 //Make a Python command
326 GEOM::TPythonDump pd (aFunction);
327 pd << aFillet << " = geompy.MakeFillet(" << theShape
328 << ", " << theR << ", geompy.ShapeType[\"FACE\"], [";
330 it = theFaces.begin();
332 while (it != theFaces.end()) {
333 pd << ", " << (*it++);
341 //=============================================================================
343 * MakeFilletFaces R1 R2
345 //=============================================================================
346 Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeFilletFacesR1R2
347 (Handle(GEOM_Object) theShape, double theR1, double theR2, list<int> theFaces)
351 //Add a new Fillet object
352 Handle(GEOM_Object) aFillet = GetEngine()->AddObject(GetDocID(), GEOM_FILLET);
354 //Add a new Fillet function
355 Handle(GEOM_Function) aFunction =
356 aFillet->AddFunction(GEOMImpl_FilletDriver::GetID(), FILLET_SHAPE_FACES_2R);
357 if (aFunction.IsNull()) return NULL;
359 //Check if the function is set correctly
360 if (aFunction->GetDriverGUID() != GEOMImpl_FilletDriver::GetID()) return NULL;
362 GEOMImpl_IFillet aCI (aFunction);
364 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
365 if (aRefShape.IsNull()) return NULL;
367 aCI.SetShape(aRefShape);
370 int aLen = theFaces.size();
374 list<int>::iterator it = theFaces.begin();
375 for (; it != theFaces.end(); it++, ind++) {
376 aCI.SetFace(ind, (*it));
379 //Compute the Fillet value
381 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
384 if (!GetSolver()->ComputeFunction(aFunction)) {
385 SetErrorCode("Fillet driver failed");
389 catch (Standard_Failure) {
390 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
391 SetErrorCode(aFail->GetMessageString());
395 //Make a Python command
396 GEOM::TPythonDump pd (aFunction);
397 pd << aFillet << " = geompy.MakeFilletR1R2(" << theShape
398 << ", " << theR1 << ", " << theR2 << ", geompy.ShapeType[\"FACE\"], [";
400 it = theFaces.begin();
402 while (it != theFaces.end()) {
403 pd << ", " << (*it++);
411 //=============================================================================
415 //=============================================================================
416 Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeChamferAll (Handle(GEOM_Object) theShape, double theD)
420 //Add a new Chamfer object
421 Handle(GEOM_Object) aChamfer = GetEngine()->AddObject(GetDocID(), GEOM_CHAMFER);
423 //Add a new Chamfer function
424 Handle(GEOM_Function) aFunction =
425 aChamfer->AddFunction(GEOMImpl_ChamferDriver::GetID(), CHAMFER_SHAPE_ALL);
426 if (aFunction.IsNull()) return NULL;
428 //Check if the function is set correctly
429 if (aFunction->GetDriverGUID() != GEOMImpl_ChamferDriver::GetID()) return NULL;
431 GEOMImpl_IChamfer aCI (aFunction);
433 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
434 if (aRefShape.IsNull()) return NULL;
436 aCI.SetShape(aRefShape);
439 //Compute the Chamfer value
441 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
444 if (!GetSolver()->ComputeFunction(aFunction)) {
445 SetErrorCode("Chamfer driver failed");
449 catch (Standard_Failure) {
450 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
451 SetErrorCode(aFail->GetMessageString());
455 //Make a Python command
456 GEOM::TPythonDump(aFunction) << aChamfer << " = geompy.MakeChamferAll("
457 << theShape << ", " << theD << ")";
463 //=============================================================================
467 //=============================================================================
468 Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeChamferEdge
469 (Handle(GEOM_Object) theShape, double theD1, double theD2,
470 int theFace1, int theFace2)
474 //Add a new Chamfer object
475 Handle(GEOM_Object) aChamfer = GetEngine()->AddObject(GetDocID(), GEOM_CHAMFER);
477 //Add a new Chamfer function
478 Handle(GEOM_Function) aFunction =
479 aChamfer->AddFunction(GEOMImpl_ChamferDriver::GetID(), CHAMFER_SHAPE_EDGE);
480 if (aFunction.IsNull()) return NULL;
482 //Check if the function is set correctly
483 if (aFunction->GetDriverGUID() != GEOMImpl_ChamferDriver::GetID()) return NULL;
485 GEOMImpl_IChamfer aCI (aFunction);
487 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
488 if (aRefShape.IsNull()) return NULL;
490 aCI.SetShape(aRefShape);
493 aCI.SetFace1(theFace1);
494 aCI.SetFace2(theFace2);
496 //Compute the Chamfer value
498 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
501 if (!GetSolver()->ComputeFunction(aFunction)) {
502 SetErrorCode("Chamfer driver failed");
506 catch (Standard_Failure) {
507 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
508 SetErrorCode(aFail->GetMessageString());
512 //Make a Python command
513 GEOM::TPythonDump(aFunction) << aChamfer
514 << " = geompy.MakeChamferEdge(" << theShape << ", " << theD1
515 << ", " << theD2 << ", " << theFace1 << ", " << theFace2 << ")";
521 //=============================================================================
525 //=============================================================================
526 Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeChamferEdgeAD
527 (Handle(GEOM_Object) theShape, double theD, double theAngle,
528 int theFace1, int theFace2)
532 //Add a new Chamfer object
533 Handle(GEOM_Object) aChamfer = GetEngine()->AddObject(GetDocID(), GEOM_CHAMFER);
535 //Add a new Chamfer function
536 Handle(GEOM_Function) aFunction =
537 aChamfer->AddFunction(GEOMImpl_ChamferDriver::GetID(), CHAMFER_SHAPE_EDGE_AD);
538 if (aFunction.IsNull()) return NULL;
540 //Check if the function is set correctly
541 if (aFunction->GetDriverGUID() != GEOMImpl_ChamferDriver::GetID()) return NULL;
543 GEOMImpl_IChamfer aCI (aFunction);
545 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
546 if (aRefShape.IsNull()) return NULL;
548 aCI.SetShape(aRefShape);
550 aCI.SetAngle(theAngle);
551 aCI.SetFace1(theFace1);
552 aCI.SetFace2(theFace2);
554 //Compute the Chamfer value
556 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
559 if (!GetSolver()->ComputeFunction(aFunction)) {
560 SetErrorCode("Chamfer driver failed");
564 catch (Standard_Failure) {
565 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
566 SetErrorCode(aFail->GetMessageString());
570 //Make a Python command
571 GEOM::TPythonDump(aFunction) << aChamfer
572 << " = geompy.MakeChamferEdgeAD(" << theShape << ", " << theD
573 << ", " << theAngle << ", " << theFace1 << ", " << theFace2 << ")";
578 //=============================================================================
582 //=============================================================================
583 Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeChamferFaces
584 (Handle(GEOM_Object) theShape, double theD1, double theD2,
589 //Add a new Chamfer object
590 Handle(GEOM_Object) aChamfer = GetEngine()->AddObject(GetDocID(), GEOM_CHAMFER);
592 //Add a new Chamfer function
593 Handle(GEOM_Function) aFunction =
594 aChamfer->AddFunction(GEOMImpl_ChamferDriver::GetID(), CHAMFER_SHAPE_FACES);
595 if (aFunction.IsNull()) return NULL;
597 //Check if the function is set correctly
598 if (aFunction->GetDriverGUID() != GEOMImpl_ChamferDriver::GetID()) return NULL;
600 GEOMImpl_IChamfer aCI (aFunction);
602 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
603 if (aRefShape.IsNull()) return NULL;
605 aCI.SetShape(aRefShape);
608 int aLen = theFaces.size();
612 list<int>::iterator it = theFaces.begin();
613 for (; it != theFaces.end(); it++, ind++) {
614 aCI.SetFace(ind, (*it));
617 //Compute the Chamfer value
619 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
622 if (!GetSolver()->ComputeFunction(aFunction)) {
623 SetErrorCode("Chamfer driver failed");
627 catch (Standard_Failure) {
628 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
629 SetErrorCode(aFail->GetMessageString());
633 //Make a Python command
634 GEOM::TPythonDump pd (aFunction);
635 pd << aChamfer << " = geompy.MakeChamferFaces(" << theShape
636 << ", " << theD1 << ", " << theD2 << ", [";
638 it = theFaces.begin();
640 while (it != theFaces.end()) {
641 pd << ", " << (*it++);
649 //=============================================================================
653 //=============================================================================
654 Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeChamferFacesAD
655 (Handle(GEOM_Object) theShape, double theD, double theAngle,
660 //Add a new Chamfer object
661 Handle(GEOM_Object) aChamfer = GetEngine()->AddObject(GetDocID(), GEOM_CHAMFER);
663 //Add a new Chamfer function
664 Handle(GEOM_Function) aFunction =
665 aChamfer->AddFunction(GEOMImpl_ChamferDriver::GetID(), CHAMFER_SHAPE_FACES_AD);
666 if (aFunction.IsNull()) return NULL;
668 //Check if the function is set correctly
669 if (aFunction->GetDriverGUID() != GEOMImpl_ChamferDriver::GetID()) return NULL;
671 GEOMImpl_IChamfer aCI (aFunction);
673 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
674 if (aRefShape.IsNull()) return NULL;
676 aCI.SetShape(aRefShape);
678 aCI.SetAngle(theAngle);
679 int aLen = theFaces.size();
683 list<int>::iterator it = theFaces.begin();
684 for (; it != theFaces.end(); it++, ind++) {
685 aCI.SetFace(ind, (*it));
688 //Compute the Chamfer value
690 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
693 if (!GetSolver()->ComputeFunction(aFunction)) {
694 SetErrorCode("Chamfer driver failed");
698 catch (Standard_Failure) {
699 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
700 SetErrorCode(aFail->GetMessageString());
704 //Make a Python command
705 GEOM::TPythonDump pd (aFunction);
706 pd << aChamfer << " = geompy.MakeChamferFacesAD(" << theShape
707 << ", " << theD << ", " << theAngle << ", [";
709 it = theFaces.begin();
711 while (it != theFaces.end()) {
712 pd << ", " << (*it++);
720 //=============================================================================
724 //=============================================================================
725 Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeChamferEdges
726 (Handle(GEOM_Object) theShape, double theD1, double theD2,
731 //Add a new Chamfer object
732 Handle(GEOM_Object) aChamfer = GetEngine()->AddObject(GetDocID(), GEOM_CHAMFER);
734 //Add a new Chamfer function
735 Handle(GEOM_Function) aFunction =
736 aChamfer->AddFunction(GEOMImpl_ChamferDriver::GetID(), CHAMFER_SHAPE_EDGES);
737 if (aFunction.IsNull()) { return NULL; cout << "Edges Function is NULL!!!" << endl; }
739 //Check if the function is set correctly
740 if (aFunction->GetDriverGUID() != GEOMImpl_ChamferDriver::GetID())
741 { return NULL; cout << "Chamfer Driver is NULL!!!" << endl; }
743 GEOMImpl_IChamfer aCI (aFunction);
745 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
746 if (aRefShape.IsNull()) { return NULL; cout << "Shape is NULL!!!" << endl; }
748 aCI.SetShape(aRefShape);
751 int aLen = theEdges.size();
755 list<int>::iterator it = theEdges.begin();
756 for (; it != theEdges.end(); it++, ind++) {
757 aCI.SetEdge(ind, (*it));
760 //Compute the Chamfer value
762 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
765 if (!GetSolver()->ComputeFunction(aFunction)) {
766 SetErrorCode("Chamfer driver failed");
770 catch (Standard_Failure) {
771 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
772 SetErrorCode(aFail->GetMessageString());
776 //Make a Python command
777 GEOM::TPythonDump pd (aFunction);
778 pd << aChamfer << " = geompy.MakeChamferEdges(" << theShape
779 << ", " << theD1 << ", " << theD2 << ", [";
781 it = theEdges.begin();
783 while (it != theEdges.end()) {
784 pd << ", " << (*it++);
792 //=============================================================================
796 //=============================================================================
797 Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeChamferEdgesAD
798 (Handle(GEOM_Object) theShape, double theD, double theAngle,
803 //Add a new Chamfer object
804 Handle(GEOM_Object) aChamfer = GetEngine()->AddObject(GetDocID(), GEOM_CHAMFER);
806 //Add a new Chamfer function
807 Handle(GEOM_Function) aFunction =
808 aChamfer->AddFunction(GEOMImpl_ChamferDriver::GetID(), CHAMFER_SHAPE_EDGES_AD);
809 if (aFunction.IsNull()) { return NULL; cout << "Edges Function is NULL!!!" << endl; }
811 //Check if the function is set correctly
812 if (aFunction->GetDriverGUID() != GEOMImpl_ChamferDriver::GetID())
813 { return NULL; cout << "Chamfer Driver is NULL!!!" << endl; }
815 GEOMImpl_IChamfer aCI (aFunction);
817 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
818 if (aRefShape.IsNull()) { return NULL; cout << "Shape is NULL!!!" << endl; }
820 aCI.SetShape(aRefShape);
822 aCI.SetAngle(theAngle);
823 int aLen = theEdges.size();
827 list<int>::iterator it = theEdges.begin();
828 for (; it != theEdges.end(); it++, ind++) {
829 aCI.SetEdge(ind, (*it));
832 //Compute the Chamfer value
834 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
837 if (!GetSolver()->ComputeFunction(aFunction)) {
838 SetErrorCode("Chamfer driver failed");
842 catch (Standard_Failure) {
843 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
844 SetErrorCode(aFail->GetMessageString());
848 //Make a Python command
849 GEOM::TPythonDump pd (aFunction);
850 pd << aChamfer << " = geompy.MakeChamferEdgesAD(" << theShape
851 << ", " << theD << ", " << theAngle << ", [";
853 it = theEdges.begin();
855 while (it != theEdges.end()) {
856 pd << ", " << (*it++);
864 //=============================================================================
868 //=============================================================================
869 Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeArchimede (Handle(GEOM_Object) theShape,
871 double theWaterDensity,
872 double theMeshingDeflection)
876 //Add a new Archimede object
877 Handle(GEOM_Object) aChamfer = GetEngine()->AddObject(GetDocID(), GEOM_ARCHIMEDE);
879 //Add a new Archimede function
880 Handle(GEOM_Function) aFunction = aChamfer->AddFunction(GEOMImpl_ArchimedeDriver::GetID(), ARCHIMEDE_TYPE);
881 if (aFunction.IsNull()) return NULL;
883 //Check if the function is set correctly
884 if (aFunction->GetDriverGUID() != GEOMImpl_ArchimedeDriver::GetID()) return NULL;
886 GEOMImpl_IArchimede aAI (aFunction);
888 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
889 if (aRefShape.IsNull()) return NULL;
891 aAI.SetBasicShape(aRefShape);
892 aAI.SetWeight(theWeight);
893 aAI.SetDensity(theWaterDensity);
894 aAI.SetDeflection(theMeshingDeflection);
896 //Compute the Archimede value
898 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
901 if (!GetSolver()->ComputeFunction(aFunction)) {
902 SetErrorCode("Archimede driver failed");
906 catch (Standard_Failure) {
907 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
908 SetErrorCode(aFail->GetMessageString());
912 //Make a Python command
913 GEOM::TPythonDump(aFunction) << aChamfer
914 << " = geompy.Archimede(" << theShape << ", " << theWeight << ", "
915 << theWaterDensity << ", " << theMeshingDeflection << ")";
921 //=============================================================================
925 //=============================================================================
926 bool GEOMImpl_ILocalOperations::GetSubShape (const TopoDS_Shape& theShape, const int theIndex,
927 TopoDS_Shape& theSubShape)
929 if (theShape.IsNull() || theIndex < 1)
932 TopTools_IndexedMapOfShape anIndices;
933 TopExp::MapShapes(theShape, anIndices);
934 if (theIndex > anIndices.Extent()) return false;
935 theSubShape = anIndices.FindKey(theIndex);
940 //=============================================================================
944 //=============================================================================
945 Standard_Integer GEOMImpl_ILocalOperations::GetSubShapeIndex (Handle(GEOM_Object) theShape,
946 Handle(GEOM_Object) theSubShape)
950 Standard_Integer anInd = -1;
951 GEOM_Engine* anEngine = GetEngine();
952 //GEOMImpl_Gen* aGen = dynamic_cast<GEOMImpl_Gen*>(anEngine);
953 GEOMImpl_Gen* aGen = (GEOMImpl_Gen*)anEngine;
956 GEOMImpl_IShapesOperations* anIShapesOperations =
957 aGen->GetIShapesOperations(GetDocID());
958 anInd = anIShapesOperations->GetSubShapeIndex(theShape, theSubShape);
959 SetErrorCode(anIShapesOperations->GetErrorCode());