1 // Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
22 #include <Standard_Stream.hxx>
24 #include <GEOMImpl_ILocalOperations.hxx>
26 #include <GEOM_Function.hxx>
27 #include <GEOM_PythonDump.hxx>
29 #include <GEOMImpl_Types.hxx>
31 #include <GEOMImpl_FilletDriver.hxx>
32 #include <GEOMImpl_ChamferDriver.hxx>
34 #include <GEOMImpl_IFillet.hxx>
35 #include <GEOMImpl_IChamfer.hxx>
37 #include <GEOMImpl_IArchimede.hxx>
38 #include <GEOMImpl_ArchimedeDriver.hxx>
40 #include <GEOMImpl_Gen.hxx>
41 #include <GEOMImpl_IShapesOperations.hxx>
43 #include "utilities.h"
45 #include <Utils_ExceptHandlers.hxx>
47 #include <TFunction_DriverTable.hxx>
48 #include <TFunction_Driver.hxx>
49 #include <TFunction_Logbook.hxx>
50 #include <TDF_Tool.hxx>
53 #include <TopoDS_TShape.hxx>
54 #include <TopTools_IndexedMapOfShape.hxx>
56 #include <Standard_Failure.hxx>
57 #include <Standard_ErrorHandler.hxx> // CAREFUL ! position of this file is critic : see Lucien PIGNOLONI / OCC
61 //=============================================================================
65 //=============================================================================
66 GEOMImpl_ILocalOperations::GEOMImpl_ILocalOperations (GEOM_Engine* theEngine, int theDocID)
67 : GEOM_IOperations(theEngine, theDocID)
69 MESSAGE("GEOMImpl_ILocalOperations::GEOMImpl_ILocalOperations");
72 //=============================================================================
76 //=============================================================================
77 GEOMImpl_ILocalOperations::~GEOMImpl_ILocalOperations()
79 MESSAGE("GEOMImpl_ILocalOperations::~GEOMImpl_ILocalOperations");
83 //=============================================================================
87 //=============================================================================
88 Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeFilletAll
89 (Handle(GEOM_Object) theShape, double theR)
93 //Add a new Fillet object
94 Handle(GEOM_Object) aFillet = GetEngine()->AddObject(GetDocID(), GEOM_FILLET);
96 //Add a new Fillet function
97 Handle(GEOM_Function) aFunction =
98 aFillet->AddFunction(GEOMImpl_FilletDriver::GetID(), FILLET_SHAPE_ALL);
99 if (aFunction.IsNull()) return NULL;
101 //Check if the function is set correctly
102 if (aFunction->GetDriverGUID() != GEOMImpl_FilletDriver::GetID()) return NULL;
104 GEOMImpl_IFillet aCI (aFunction);
106 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
107 if (aRefShape.IsNull()) return NULL;
109 aCI.SetShape(aRefShape);
112 //Compute the Fillet value
114 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
117 if (!GetSolver()->ComputeFunction(aFunction)) {
118 SetErrorCode("Fillet driver failed");
122 catch (Standard_Failure) {
123 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
124 SetErrorCode(aFail->GetMessageString());
128 //Make a Python command
129 GEOM::TPythonDump(aFunction) << aFillet << " = geompy.MakeFilletAll("
130 << theShape << ", " << theR << ")";
136 //=============================================================================
140 //=============================================================================
141 Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeFilletEdges
142 (Handle(GEOM_Object) theShape, double theR, list<int> theEdges)
146 //Add a new Fillet object
147 Handle(GEOM_Object) aFillet = GetEngine()->AddObject(GetDocID(), GEOM_FILLET);
149 //Add a new Fillet function
150 Handle(GEOM_Function) aFunction =
151 aFillet->AddFunction(GEOMImpl_FilletDriver::GetID(), FILLET_SHAPE_EDGES);
152 if (aFunction.IsNull()) return NULL;
154 //Check if the function is set correctly
155 if (aFunction->GetDriverGUID() != GEOMImpl_FilletDriver::GetID()) return NULL;
157 GEOMImpl_IFillet aCI (aFunction);
159 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
160 if (aRefShape.IsNull()) return NULL;
162 aCI.SetShape(aRefShape);
164 int aLen = theEdges.size();
168 list<int>::iterator it = theEdges.begin();
169 for (; it != theEdges.end(); it++, ind++) {
170 aCI.SetEdge(ind, (*it));
173 //Compute the Fillet value
175 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
178 if (!GetSolver()->ComputeFunction(aFunction)) {
179 SetErrorCode("Fillet driver failed");
183 catch (Standard_Failure) {
184 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
185 SetErrorCode(aFail->GetMessageString());
189 //Make a Python command
190 GEOM::TPythonDump pd (aFunction);
191 pd << aFillet << " = geompy.MakeFillet(" << theShape
192 << ", " << theR << ", geompy.ShapeType[\"EDGE\"], [";
194 it = theEdges.begin();
196 while (it != theEdges.end()) {
197 pd << ", " << (*it++);
205 //=============================================================================
207 * MakeFilletEdges R1 R2
209 //=============================================================================
210 Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeFilletEdgesR1R2
211 (Handle(GEOM_Object) theShape, double theR1, double theR2, list<int> theEdges)
215 //Add a new Fillet object
216 Handle(GEOM_Object) aFillet = GetEngine()->AddObject(GetDocID(), GEOM_FILLET);
218 //Add a new Fillet function
219 Handle(GEOM_Function) aFunction =
220 aFillet->AddFunction(GEOMImpl_FilletDriver::GetID(), FILLET_SHAPE_EDGES_2R);
221 if (aFunction.IsNull()) return NULL;
223 //Check if the function is set correctly
224 if (aFunction->GetDriverGUID() != GEOMImpl_FilletDriver::GetID()) return NULL;
226 GEOMImpl_IFillet aCI (aFunction);
228 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
229 if (aRefShape.IsNull()) return NULL;
231 aCI.SetShape(aRefShape);
234 int aLen = theEdges.size();
238 list<int>::iterator it = theEdges.begin();
239 for (; it != theEdges.end(); it++, ind++) {
240 aCI.SetEdge(ind, (*it));
243 //Compute the Fillet value
245 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
248 if (!GetSolver()->ComputeFunction(aFunction)) {
249 SetErrorCode("Fillet driver failed");
253 catch (Standard_Failure) {
254 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
255 SetErrorCode(aFail->GetMessageString());
259 //Make a Python command
260 GEOM::TPythonDump pd (aFunction);
261 pd << aFillet << " = geompy.MakeFilletR1R2(" << theShape
262 << ", " << theR1 << ", " <<theR2 << ", geompy.ShapeType[\"EDGE\"], [";
264 it = theEdges.begin();
266 while (it != theEdges.end()) {
267 pd << ", " << (*it++);
276 //=============================================================================
280 //=============================================================================
281 Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeFilletFaces
282 (Handle(GEOM_Object) theShape, double theR, list<int> theFaces)
286 //Add a new Fillet object
287 Handle(GEOM_Object) aFillet = GetEngine()->AddObject(GetDocID(), GEOM_FILLET);
289 //Add a new Fillet function
290 Handle(GEOM_Function) aFunction =
291 aFillet->AddFunction(GEOMImpl_FilletDriver::GetID(), FILLET_SHAPE_FACES);
292 if (aFunction.IsNull()) return NULL;
294 //Check if the function is set correctly
295 if (aFunction->GetDriverGUID() != GEOMImpl_FilletDriver::GetID()) return NULL;
297 GEOMImpl_IFillet aCI (aFunction);
299 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
300 if (aRefShape.IsNull()) return NULL;
302 aCI.SetShape(aRefShape);
304 int aLen = theFaces.size();
308 list<int>::iterator it = theFaces.begin();
309 for (; it != theFaces.end(); it++, ind++) {
310 aCI.SetFace(ind, (*it));
313 //Compute the Fillet value
315 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
318 if (!GetSolver()->ComputeFunction(aFunction)) {
319 SetErrorCode("Fillet driver failed");
323 catch (Standard_Failure) {
324 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
325 SetErrorCode(aFail->GetMessageString());
329 //Make a Python command
330 GEOM::TPythonDump pd (aFunction);
331 pd << aFillet << " = geompy.MakeFillet(" << theShape
332 << ", " << theR << ", geompy.ShapeType[\"FACE\"], [";
334 it = theFaces.begin();
336 while (it != theFaces.end()) {
337 pd << ", " << (*it++);
345 //=============================================================================
347 * MakeFilletFaces R1 R2
349 //=============================================================================
350 Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeFilletFacesR1R2
351 (Handle(GEOM_Object) theShape, double theR1, double theR2, list<int> theFaces)
355 //Add a new Fillet object
356 Handle(GEOM_Object) aFillet = GetEngine()->AddObject(GetDocID(), GEOM_FILLET);
358 //Add a new Fillet function
359 Handle(GEOM_Function) aFunction =
360 aFillet->AddFunction(GEOMImpl_FilletDriver::GetID(), FILLET_SHAPE_FACES_2R);
361 if (aFunction.IsNull()) return NULL;
363 //Check if the function is set correctly
364 if (aFunction->GetDriverGUID() != GEOMImpl_FilletDriver::GetID()) return NULL;
366 GEOMImpl_IFillet aCI (aFunction);
368 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
369 if (aRefShape.IsNull()) return NULL;
371 aCI.SetShape(aRefShape);
374 int aLen = theFaces.size();
378 list<int>::iterator it = theFaces.begin();
379 for (; it != theFaces.end(); it++, ind++) {
380 aCI.SetFace(ind, (*it));
383 //Compute the Fillet value
385 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
388 if (!GetSolver()->ComputeFunction(aFunction)) {
389 SetErrorCode("Fillet driver failed");
393 catch (Standard_Failure) {
394 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
395 SetErrorCode(aFail->GetMessageString());
399 //Make a Python command
400 GEOM::TPythonDump pd (aFunction);
401 pd << aFillet << " = geompy.MakeFilletR1R2(" << theShape
402 << ", " << theR1 << ", " << theR2 << ", geompy.ShapeType[\"FACE\"], [";
404 it = theFaces.begin();
406 while (it != theFaces.end()) {
407 pd << ", " << (*it++);
415 //=============================================================================
419 //=============================================================================
420 Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeChamferAll (Handle(GEOM_Object) theShape, double theD)
424 //Add a new Chamfer object
425 Handle(GEOM_Object) aChamfer = GetEngine()->AddObject(GetDocID(), GEOM_CHAMFER);
427 //Add a new Chamfer function
428 Handle(GEOM_Function) aFunction =
429 aChamfer->AddFunction(GEOMImpl_ChamferDriver::GetID(), CHAMFER_SHAPE_ALL);
430 if (aFunction.IsNull()) return NULL;
432 //Check if the function is set correctly
433 if (aFunction->GetDriverGUID() != GEOMImpl_ChamferDriver::GetID()) return NULL;
435 GEOMImpl_IChamfer aCI (aFunction);
437 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
438 if (aRefShape.IsNull()) return NULL;
440 aCI.SetShape(aRefShape);
443 //Compute the Chamfer value
445 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
448 if (!GetSolver()->ComputeFunction(aFunction)) {
449 SetErrorCode("Chamfer driver failed");
453 catch (Standard_Failure) {
454 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
455 SetErrorCode(aFail->GetMessageString());
459 //Make a Python command
460 GEOM::TPythonDump(aFunction) << aChamfer << " = geompy.MakeChamferAll("
461 << theShape << ", " << theD << ")";
467 //=============================================================================
471 //=============================================================================
472 Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeChamferEdge
473 (Handle(GEOM_Object) theShape, double theD1, double theD2,
474 int theFace1, int theFace2)
478 //Add a new Chamfer object
479 Handle(GEOM_Object) aChamfer = GetEngine()->AddObject(GetDocID(), GEOM_CHAMFER);
481 //Add a new Chamfer function
482 Handle(GEOM_Function) aFunction =
483 aChamfer->AddFunction(GEOMImpl_ChamferDriver::GetID(), CHAMFER_SHAPE_EDGE);
484 if (aFunction.IsNull()) return NULL;
486 //Check if the function is set correctly
487 if (aFunction->GetDriverGUID() != GEOMImpl_ChamferDriver::GetID()) return NULL;
489 GEOMImpl_IChamfer aCI (aFunction);
491 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
492 if (aRefShape.IsNull()) return NULL;
494 aCI.SetShape(aRefShape);
497 aCI.SetFace1(theFace1);
498 aCI.SetFace2(theFace2);
500 //Compute the Chamfer value
502 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
505 if (!GetSolver()->ComputeFunction(aFunction)) {
506 SetErrorCode("Chamfer driver failed");
510 catch (Standard_Failure) {
511 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
512 SetErrorCode(aFail->GetMessageString());
516 //Make a Python command
517 GEOM::TPythonDump(aFunction) << aChamfer
518 << " = geompy.MakeChamferEdge(" << theShape << ", " << theD1
519 << ", " << theD2 << ", " << theFace1 << ", " << theFace2 << ")";
525 //=============================================================================
529 //=============================================================================
530 Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeChamferEdgeAD
531 (Handle(GEOM_Object) theShape, double theD, double theAngle,
532 int theFace1, int theFace2)
536 //Add a new Chamfer object
537 Handle(GEOM_Object) aChamfer = GetEngine()->AddObject(GetDocID(), GEOM_CHAMFER);
539 //Add a new Chamfer function
540 Handle(GEOM_Function) aFunction =
541 aChamfer->AddFunction(GEOMImpl_ChamferDriver::GetID(), CHAMFER_SHAPE_EDGE_AD);
542 if (aFunction.IsNull()) return NULL;
544 //Check if the function is set correctly
545 if (aFunction->GetDriverGUID() != GEOMImpl_ChamferDriver::GetID()) return NULL;
547 GEOMImpl_IChamfer aCI (aFunction);
549 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
550 if (aRefShape.IsNull()) return NULL;
552 aCI.SetShape(aRefShape);
554 aCI.SetAngle(theAngle);
555 aCI.SetFace1(theFace1);
556 aCI.SetFace2(theFace2);
558 //Compute the Chamfer value
560 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
563 if (!GetSolver()->ComputeFunction(aFunction)) {
564 SetErrorCode("Chamfer driver failed");
568 catch (Standard_Failure) {
569 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
570 SetErrorCode(aFail->GetMessageString());
574 //Make a Python command
575 GEOM::TPythonDump(aFunction) << aChamfer
576 << " = geompy.MakeChamferEdgeAD(" << theShape << ", " << theD
577 << ", " << theAngle << ", " << theFace1 << ", " << theFace2 << ")";
582 //=============================================================================
586 //=============================================================================
587 Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeChamferFaces
588 (Handle(GEOM_Object) theShape, double theD1, double theD2,
593 //Add a new Chamfer object
594 Handle(GEOM_Object) aChamfer = GetEngine()->AddObject(GetDocID(), GEOM_CHAMFER);
596 //Add a new Chamfer function
597 Handle(GEOM_Function) aFunction =
598 aChamfer->AddFunction(GEOMImpl_ChamferDriver::GetID(), CHAMFER_SHAPE_FACES);
599 if (aFunction.IsNull()) return NULL;
601 //Check if the function is set correctly
602 if (aFunction->GetDriverGUID() != GEOMImpl_ChamferDriver::GetID()) return NULL;
604 GEOMImpl_IChamfer aCI (aFunction);
606 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
607 if (aRefShape.IsNull()) return NULL;
609 aCI.SetShape(aRefShape);
612 int aLen = theFaces.size();
616 list<int>::iterator it = theFaces.begin();
617 for (; it != theFaces.end(); it++, ind++) {
618 aCI.SetFace(ind, (*it));
621 //Compute the Chamfer value
623 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
626 if (!GetSolver()->ComputeFunction(aFunction)) {
627 SetErrorCode("Chamfer driver failed");
631 catch (Standard_Failure) {
632 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
633 SetErrorCode(aFail->GetMessageString());
637 //Make a Python command
638 GEOM::TPythonDump pd (aFunction);
639 pd << aChamfer << " = geompy.MakeChamferFaces(" << theShape
640 << ", " << theD1 << ", " << theD2 << ", [";
642 it = theFaces.begin();
644 while (it != theFaces.end()) {
645 pd << ", " << (*it++);
653 //=============================================================================
657 //=============================================================================
658 Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeChamferFacesAD
659 (Handle(GEOM_Object) theShape, double theD, double theAngle,
664 //Add a new Chamfer object
665 Handle(GEOM_Object) aChamfer = GetEngine()->AddObject(GetDocID(), GEOM_CHAMFER);
667 //Add a new Chamfer function
668 Handle(GEOM_Function) aFunction =
669 aChamfer->AddFunction(GEOMImpl_ChamferDriver::GetID(), CHAMFER_SHAPE_FACES_AD);
670 if (aFunction.IsNull()) return NULL;
672 //Check if the function is set correctly
673 if (aFunction->GetDriverGUID() != GEOMImpl_ChamferDriver::GetID()) return NULL;
675 GEOMImpl_IChamfer aCI (aFunction);
677 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
678 if (aRefShape.IsNull()) return NULL;
680 aCI.SetShape(aRefShape);
682 aCI.SetAngle(theAngle);
683 int aLen = theFaces.size();
687 list<int>::iterator it = theFaces.begin();
688 for (; it != theFaces.end(); it++, ind++) {
689 aCI.SetFace(ind, (*it));
692 //Compute the Chamfer value
694 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
697 if (!GetSolver()->ComputeFunction(aFunction)) {
698 SetErrorCode("Chamfer driver failed");
702 catch (Standard_Failure) {
703 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
704 SetErrorCode(aFail->GetMessageString());
708 //Make a Python command
709 GEOM::TPythonDump pd (aFunction);
710 pd << aChamfer << " = geompy.MakeChamferFacesAD(" << theShape
711 << ", " << theD << ", " << theAngle << ", [";
713 it = theFaces.begin();
715 while (it != theFaces.end()) {
716 pd << ", " << (*it++);
724 //=============================================================================
728 //=============================================================================
729 Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeChamferEdges
730 (Handle(GEOM_Object) theShape, double theD1, double theD2,
735 //Add a new Chamfer object
736 Handle(GEOM_Object) aChamfer = GetEngine()->AddObject(GetDocID(), GEOM_CHAMFER);
738 //Add a new Chamfer function
739 Handle(GEOM_Function) aFunction =
740 aChamfer->AddFunction(GEOMImpl_ChamferDriver::GetID(), CHAMFER_SHAPE_EDGES);
741 if (aFunction.IsNull()) { MESSAGE ( "Edges Function is NULL!!!" ); return NULL;}
743 //Check if the function is set correctly
744 if (aFunction->GetDriverGUID() != GEOMImpl_ChamferDriver::GetID())
745 { MESSAGE ( "Chamfer Driver is NULL!!!" ); return NULL; }
747 GEOMImpl_IChamfer aCI (aFunction);
749 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
750 if (aRefShape.IsNull()) { MESSAGE ("Shape is NULL!!!"); return NULL;}
752 aCI.SetShape(aRefShape);
755 int aLen = theEdges.size();
759 list<int>::iterator it = theEdges.begin();
760 for (; it != theEdges.end(); it++, ind++) {
761 aCI.SetEdge(ind, (*it));
764 //Compute the Chamfer value
766 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
769 if (!GetSolver()->ComputeFunction(aFunction)) {
770 SetErrorCode("Chamfer driver failed");
774 catch (Standard_Failure) {
775 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
776 SetErrorCode(aFail->GetMessageString());
780 //Make a Python command
781 GEOM::TPythonDump pd (aFunction);
782 pd << aChamfer << " = geompy.MakeChamferEdges(" << theShape
783 << ", " << theD1 << ", " << theD2 << ", [";
785 it = theEdges.begin();
787 while (it != theEdges.end()) {
788 pd << ", " << (*it++);
796 //=============================================================================
800 //=============================================================================
801 Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeChamferEdgesAD
802 (Handle(GEOM_Object) theShape, double theD, double theAngle,
807 //Add a new Chamfer object
808 Handle(GEOM_Object) aChamfer = GetEngine()->AddObject(GetDocID(), GEOM_CHAMFER);
810 //Add a new Chamfer function
811 Handle(GEOM_Function) aFunction =
812 aChamfer->AddFunction(GEOMImpl_ChamferDriver::GetID(), CHAMFER_SHAPE_EDGES_AD);
813 if (aFunction.IsNull()) { MESSAGE ( "Edges Function is NULL!!!" ); return NULL; }
815 //Check if the function is set correctly
816 if (aFunction->GetDriverGUID() != GEOMImpl_ChamferDriver::GetID())
817 { MESSAGE("Chamfer Driver is NULL!!!"); return NULL;}
819 GEOMImpl_IChamfer aCI (aFunction);
821 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
822 if (aRefShape.IsNull()) { MESSAGE ("Shape is NULL!!!"); return NULL;}
824 aCI.SetShape(aRefShape);
826 aCI.SetAngle(theAngle);
827 int aLen = theEdges.size();
831 list<int>::iterator it = theEdges.begin();
832 for (; it != theEdges.end(); it++, ind++) {
833 aCI.SetEdge(ind, (*it));
836 //Compute the Chamfer value
838 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
841 if (!GetSolver()->ComputeFunction(aFunction)) {
842 SetErrorCode("Chamfer driver failed");
846 catch (Standard_Failure) {
847 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
848 SetErrorCode(aFail->GetMessageString());
852 //Make a Python command
853 GEOM::TPythonDump pd (aFunction);
854 pd << aChamfer << " = geompy.MakeChamferEdgesAD(" << theShape
855 << ", " << theD << ", " << theAngle << ", [";
857 it = theEdges.begin();
859 while (it != theEdges.end()) {
860 pd << ", " << (*it++);
868 //=============================================================================
872 //=============================================================================
873 Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeArchimede (Handle(GEOM_Object) theShape,
875 double theWaterDensity,
876 double theMeshingDeflection)
880 //Add a new Archimede object
881 Handle(GEOM_Object) aChamfer = GetEngine()->AddObject(GetDocID(), GEOM_ARCHIMEDE);
883 //Add a new Archimede function
884 Handle(GEOM_Function) aFunction = aChamfer->AddFunction(GEOMImpl_ArchimedeDriver::GetID(), ARCHIMEDE_TYPE);
885 if (aFunction.IsNull()) return NULL;
887 //Check if the function is set correctly
888 if (aFunction->GetDriverGUID() != GEOMImpl_ArchimedeDriver::GetID()) return NULL;
890 GEOMImpl_IArchimede aAI (aFunction);
892 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
893 if (aRefShape.IsNull()) return NULL;
895 aAI.SetBasicShape(aRefShape);
896 aAI.SetWeight(theWeight);
897 aAI.SetDensity(theWaterDensity);
898 aAI.SetDeflection(theMeshingDeflection);
900 //Compute the Archimede value
902 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
905 if (!GetSolver()->ComputeFunction(aFunction)) {
906 SetErrorCode("Archimede driver failed");
910 catch (Standard_Failure) {
911 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
912 SetErrorCode(aFail->GetMessageString());
916 //Make a Python command
917 GEOM::TPythonDump(aFunction) << aChamfer
918 << " = geompy.Archimede(" << theShape << ", " << theWeight << ", "
919 << theWaterDensity << ", " << theMeshingDeflection << ")";
925 //=============================================================================
929 //=============================================================================
930 bool GEOMImpl_ILocalOperations::GetSubShape (const TopoDS_Shape& theShape, const int theIndex,
931 TopoDS_Shape& theSubShape)
933 if (theShape.IsNull() || theIndex < 1)
936 TopTools_IndexedMapOfShape anIndices;
937 TopExp::MapShapes(theShape, anIndices);
938 if (theIndex > anIndices.Extent()) return false;
939 theSubShape = anIndices.FindKey(theIndex);
944 //=============================================================================
948 //=============================================================================
949 Standard_Integer GEOMImpl_ILocalOperations::GetSubShapeIndex (Handle(GEOM_Object) theShape,
950 Handle(GEOM_Object) theSubShape)
954 Standard_Integer anInd = -1;
955 GEOM_Engine* anEngine = GetEngine();
956 //GEOMImpl_Gen* aGen = dynamic_cast<GEOMImpl_Gen*>(anEngine);
957 GEOMImpl_Gen* aGen = (GEOMImpl_Gen*)anEngine;
960 GEOMImpl_IShapesOperations* anIShapesOperations =
961 aGen->GetIShapesOperations(GetDocID());
962 anInd = anIShapesOperations->GetSubShapeIndex(theShape, theSubShape);
963 SetErrorCode(anIShapesOperations->GetErrorCode());