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
23 #include <Standard_Stream.hxx>
25 #include <GEOMImpl_ILocalOperations.hxx>
27 #include <GEOM_Function.hxx>
28 #include <GEOM_PythonDump.hxx>
30 #include <GEOMImpl_Types.hxx>
32 #include <GEOMImpl_FilletDriver.hxx>
33 #include <GEOMImpl_ChamferDriver.hxx>
35 #include <GEOMImpl_IFillet.hxx>
36 #include <GEOMImpl_IChamfer.hxx>
38 #include <GEOMImpl_IArchimede.hxx>
39 #include <GEOMImpl_ArchimedeDriver.hxx>
41 #include <GEOMImpl_Gen.hxx>
42 #include <GEOMImpl_IShapesOperations.hxx>
44 #include "utilities.h"
46 #include <Utils_ExceptHandlers.hxx>
48 #include <TFunction_DriverTable.hxx>
49 #include <TFunction_Driver.hxx>
50 #include <TFunction_Logbook.hxx>
51 #include <TDF_Tool.hxx>
54 #include <TopoDS_TShape.hxx>
55 #include <TopTools_IndexedMapOfShape.hxx>
57 #include <Standard_Failure.hxx>
58 #include <Standard_ErrorHandler.hxx> // CAREFUL ! position of this file is critic : see Lucien PIGNOLONI / OCC
60 //=============================================================================
64 //=============================================================================
65 GEOMImpl_ILocalOperations::GEOMImpl_ILocalOperations (GEOM_Engine* theEngine, int theDocID)
66 : GEOM_IOperations(theEngine, theDocID)
68 MESSAGE("GEOMImpl_ILocalOperations::GEOMImpl_ILocalOperations");
71 //=============================================================================
75 //=============================================================================
76 GEOMImpl_ILocalOperations::~GEOMImpl_ILocalOperations()
78 MESSAGE("GEOMImpl_ILocalOperations::~GEOMImpl_ILocalOperations");
82 //=============================================================================
86 //=============================================================================
87 Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeFilletAll
88 (Handle(GEOM_Object) theShape, double theR)
92 //Add a new Fillet object
93 Handle(GEOM_Object) aFillet = GetEngine()->AddObject(GetDocID(), GEOM_FILLET);
95 //Add a new Fillet function
96 Handle(GEOM_Function) aFunction =
97 aFillet->AddFunction(GEOMImpl_FilletDriver::GetID(), FILLET_SHAPE_ALL);
98 if (aFunction.IsNull()) return NULL;
100 //Check if the function is set correctly
101 if (aFunction->GetDriverGUID() != GEOMImpl_FilletDriver::GetID()) return NULL;
103 GEOMImpl_IFillet aCI (aFunction);
105 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
106 if (aRefShape.IsNull()) return NULL;
108 aCI.SetShape(aRefShape);
111 //Compute the Fillet value
113 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
116 if (!GetSolver()->ComputeFunction(aFunction)) {
117 SetErrorCode("Fillet driver failed");
121 catch (Standard_Failure) {
122 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
123 SetErrorCode(aFail->GetMessageString());
127 //Make a Python command
128 GEOM::TPythonDump(aFunction) << aFillet << " = geompy.MakeFilletAll("
129 << theShape << ", " << theR << ")";
135 //=============================================================================
139 //=============================================================================
140 Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeFilletEdges
141 (Handle(GEOM_Object) theShape, double theR, list<int> theEdges)
145 //Add a new Fillet object
146 Handle(GEOM_Object) aFillet = GetEngine()->AddObject(GetDocID(), GEOM_FILLET);
148 //Add a new Fillet function
149 Handle(GEOM_Function) aFunction =
150 aFillet->AddFunction(GEOMImpl_FilletDriver::GetID(), FILLET_SHAPE_EDGES);
151 if (aFunction.IsNull()) return NULL;
153 //Check if the function is set correctly
154 if (aFunction->GetDriverGUID() != GEOMImpl_FilletDriver::GetID()) return NULL;
156 GEOMImpl_IFillet aCI (aFunction);
158 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
159 if (aRefShape.IsNull()) return NULL;
161 aCI.SetShape(aRefShape);
163 int aLen = theEdges.size();
167 list<int>::iterator it = theEdges.begin();
168 for (; it != theEdges.end(); it++, ind++) {
169 aCI.SetEdge(ind, (*it));
172 //Compute the Fillet value
174 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
177 if (!GetSolver()->ComputeFunction(aFunction)) {
178 SetErrorCode("Fillet driver failed");
182 catch (Standard_Failure) {
183 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
184 SetErrorCode(aFail->GetMessageString());
188 //Make a Python command
189 GEOM::TPythonDump pd (aFunction);
190 pd << aFillet << " = geompy.MakeFillet(" << theShape
191 << ", " << theR << ", geompy.ShapeType[\"EDGE\"], [";
193 it = theEdges.begin();
195 while (it != theEdges.end()) {
196 pd << ", " << (*it++);
204 //=============================================================================
206 * MakeFilletEdges R1 R2
208 //=============================================================================
209 Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeFilletEdgesR1R2
210 (Handle(GEOM_Object) theShape, double theR1, double theR2, list<int> theEdges)
214 //Add a new Fillet object
215 Handle(GEOM_Object) aFillet = GetEngine()->AddObject(GetDocID(), GEOM_FILLET);
217 //Add a new Fillet function
218 Handle(GEOM_Function) aFunction =
219 aFillet->AddFunction(GEOMImpl_FilletDriver::GetID(), FILLET_SHAPE_EDGES_2R);
220 if (aFunction.IsNull()) return NULL;
222 //Check if the function is set correctly
223 if (aFunction->GetDriverGUID() != GEOMImpl_FilletDriver::GetID()) return NULL;
225 GEOMImpl_IFillet aCI (aFunction);
227 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
228 if (aRefShape.IsNull()) return NULL;
230 aCI.SetShape(aRefShape);
233 int aLen = theEdges.size();
237 list<int>::iterator it = theEdges.begin();
238 for (; it != theEdges.end(); it++, ind++) {
239 aCI.SetEdge(ind, (*it));
242 //Compute the Fillet value
244 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
247 if (!GetSolver()->ComputeFunction(aFunction)) {
248 SetErrorCode("Fillet driver failed");
252 catch (Standard_Failure) {
253 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
254 SetErrorCode(aFail->GetMessageString());
258 //Make a Python command
259 GEOM::TPythonDump pd (aFunction);
260 pd << aFillet << " = geompy.MakeFilletR1R2(" << theShape
261 << ", " << theR1 << ", " <<theR2 << ", geompy.ShapeType[\"EDGE\"], [";
263 it = theEdges.begin();
265 while (it != theEdges.end()) {
266 pd << ", " << (*it++);
275 //=============================================================================
279 //=============================================================================
280 Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeFilletFaces
281 (Handle(GEOM_Object) theShape, double theR, list<int> theFaces)
285 //Add a new Fillet object
286 Handle(GEOM_Object) aFillet = GetEngine()->AddObject(GetDocID(), GEOM_FILLET);
288 //Add a new Fillet function
289 Handle(GEOM_Function) aFunction =
290 aFillet->AddFunction(GEOMImpl_FilletDriver::GetID(), FILLET_SHAPE_FACES);
291 if (aFunction.IsNull()) return NULL;
293 //Check if the function is set correctly
294 if (aFunction->GetDriverGUID() != GEOMImpl_FilletDriver::GetID()) return NULL;
296 GEOMImpl_IFillet aCI (aFunction);
298 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
299 if (aRefShape.IsNull()) return NULL;
301 aCI.SetShape(aRefShape);
303 int aLen = theFaces.size();
307 list<int>::iterator it = theFaces.begin();
308 for (; it != theFaces.end(); it++, ind++) {
309 aCI.SetFace(ind, (*it));
312 //Compute the Fillet value
314 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
317 if (!GetSolver()->ComputeFunction(aFunction)) {
318 SetErrorCode("Fillet driver failed");
322 catch (Standard_Failure) {
323 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
324 SetErrorCode(aFail->GetMessageString());
328 //Make a Python command
329 GEOM::TPythonDump pd (aFunction);
330 pd << aFillet << " = geompy.MakeFillet(" << theShape
331 << ", " << theR << ", geompy.ShapeType[\"FACE\"], [";
333 it = theFaces.begin();
335 while (it != theFaces.end()) {
336 pd << ", " << (*it++);
344 //=============================================================================
346 * MakeFilletFaces R1 R2
348 //=============================================================================
349 Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeFilletFacesR1R2
350 (Handle(GEOM_Object) theShape, double theR1, double theR2, list<int> theFaces)
354 //Add a new Fillet object
355 Handle(GEOM_Object) aFillet = GetEngine()->AddObject(GetDocID(), GEOM_FILLET);
357 //Add a new Fillet function
358 Handle(GEOM_Function) aFunction =
359 aFillet->AddFunction(GEOMImpl_FilletDriver::GetID(), FILLET_SHAPE_FACES_2R);
360 if (aFunction.IsNull()) return NULL;
362 //Check if the function is set correctly
363 if (aFunction->GetDriverGUID() != GEOMImpl_FilletDriver::GetID()) return NULL;
365 GEOMImpl_IFillet aCI (aFunction);
367 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
368 if (aRefShape.IsNull()) return NULL;
370 aCI.SetShape(aRefShape);
373 int aLen = theFaces.size();
377 list<int>::iterator it = theFaces.begin();
378 for (; it != theFaces.end(); it++, ind++) {
379 aCI.SetFace(ind, (*it));
382 //Compute the Fillet value
384 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
387 if (!GetSolver()->ComputeFunction(aFunction)) {
388 SetErrorCode("Fillet driver failed");
392 catch (Standard_Failure) {
393 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
394 SetErrorCode(aFail->GetMessageString());
398 //Make a Python command
399 GEOM::TPythonDump pd (aFunction);
400 pd << aFillet << " = geompy.MakeFilletR1R2(" << theShape
401 << ", " << theR1 << ", " << theR2 << ", geompy.ShapeType[\"FACE\"], [";
403 it = theFaces.begin();
405 while (it != theFaces.end()) {
406 pd << ", " << (*it++);
414 //=============================================================================
418 //=============================================================================
419 Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeChamferAll (Handle(GEOM_Object) theShape, double theD)
423 //Add a new Chamfer object
424 Handle(GEOM_Object) aChamfer = GetEngine()->AddObject(GetDocID(), GEOM_CHAMFER);
426 //Add a new Chamfer function
427 Handle(GEOM_Function) aFunction =
428 aChamfer->AddFunction(GEOMImpl_ChamferDriver::GetID(), CHAMFER_SHAPE_ALL);
429 if (aFunction.IsNull()) return NULL;
431 //Check if the function is set correctly
432 if (aFunction->GetDriverGUID() != GEOMImpl_ChamferDriver::GetID()) return NULL;
434 GEOMImpl_IChamfer aCI (aFunction);
436 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
437 if (aRefShape.IsNull()) return NULL;
439 aCI.SetShape(aRefShape);
442 //Compute the Chamfer value
444 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
447 if (!GetSolver()->ComputeFunction(aFunction)) {
448 SetErrorCode("Chamfer driver failed");
452 catch (Standard_Failure) {
453 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
454 SetErrorCode(aFail->GetMessageString());
458 //Make a Python command
459 GEOM::TPythonDump(aFunction) << aChamfer << " = geompy.MakeChamferAll("
460 << theShape << ", " << theD << ")";
466 //=============================================================================
470 //=============================================================================
471 Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeChamferEdge
472 (Handle(GEOM_Object) theShape, double theD1, double theD2,
473 int theFace1, int theFace2)
477 //Add a new Chamfer object
478 Handle(GEOM_Object) aChamfer = GetEngine()->AddObject(GetDocID(), GEOM_CHAMFER);
480 //Add a new Chamfer function
481 Handle(GEOM_Function) aFunction =
482 aChamfer->AddFunction(GEOMImpl_ChamferDriver::GetID(), CHAMFER_SHAPE_EDGE);
483 if (aFunction.IsNull()) return NULL;
485 //Check if the function is set correctly
486 if (aFunction->GetDriverGUID() != GEOMImpl_ChamferDriver::GetID()) return NULL;
488 GEOMImpl_IChamfer aCI (aFunction);
490 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
491 if (aRefShape.IsNull()) return NULL;
493 aCI.SetShape(aRefShape);
496 aCI.SetFace1(theFace1);
497 aCI.SetFace2(theFace2);
499 //Compute the Chamfer value
501 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
504 if (!GetSolver()->ComputeFunction(aFunction)) {
505 SetErrorCode("Chamfer driver failed");
509 catch (Standard_Failure) {
510 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
511 SetErrorCode(aFail->GetMessageString());
515 //Make a Python command
516 GEOM::TPythonDump(aFunction) << aChamfer
517 << " = geompy.MakeChamferEdge(" << theShape << ", " << theD1
518 << ", " << theD2 << ", " << theFace1 << ", " << theFace2 << ")";
524 //=============================================================================
528 //=============================================================================
529 Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeChamferEdgeAD
530 (Handle(GEOM_Object) theShape, double theD, double theAngle,
531 int theFace1, int theFace2)
535 //Add a new Chamfer object
536 Handle(GEOM_Object) aChamfer = GetEngine()->AddObject(GetDocID(), GEOM_CHAMFER);
538 //Add a new Chamfer function
539 Handle(GEOM_Function) aFunction =
540 aChamfer->AddFunction(GEOMImpl_ChamferDriver::GetID(), CHAMFER_SHAPE_EDGE_AD);
541 if (aFunction.IsNull()) return NULL;
543 //Check if the function is set correctly
544 if (aFunction->GetDriverGUID() != GEOMImpl_ChamferDriver::GetID()) return NULL;
546 GEOMImpl_IChamfer aCI (aFunction);
548 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
549 if (aRefShape.IsNull()) return NULL;
551 aCI.SetShape(aRefShape);
553 aCI.SetAngle(theAngle);
554 aCI.SetFace1(theFace1);
555 aCI.SetFace2(theFace2);
557 //Compute the Chamfer value
559 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
562 if (!GetSolver()->ComputeFunction(aFunction)) {
563 SetErrorCode("Chamfer driver failed");
567 catch (Standard_Failure) {
568 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
569 SetErrorCode(aFail->GetMessageString());
573 //Make a Python command
574 GEOM::TPythonDump(aFunction) << aChamfer
575 << " = geompy.MakeChamferEdgeAD(" << theShape << ", " << theD
576 << ", " << theAngle << ", " << theFace1 << ", " << theFace2 << ")";
581 //=============================================================================
585 //=============================================================================
586 Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeChamferFaces
587 (Handle(GEOM_Object) theShape, double theD1, double theD2,
592 //Add a new Chamfer object
593 Handle(GEOM_Object) aChamfer = GetEngine()->AddObject(GetDocID(), GEOM_CHAMFER);
595 //Add a new Chamfer function
596 Handle(GEOM_Function) aFunction =
597 aChamfer->AddFunction(GEOMImpl_ChamferDriver::GetID(), CHAMFER_SHAPE_FACES);
598 if (aFunction.IsNull()) return NULL;
600 //Check if the function is set correctly
601 if (aFunction->GetDriverGUID() != GEOMImpl_ChamferDriver::GetID()) return NULL;
603 GEOMImpl_IChamfer aCI (aFunction);
605 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
606 if (aRefShape.IsNull()) return NULL;
608 aCI.SetShape(aRefShape);
611 int aLen = theFaces.size();
615 list<int>::iterator it = theFaces.begin();
616 for (; it != theFaces.end(); it++, ind++) {
617 aCI.SetFace(ind, (*it));
620 //Compute the Chamfer value
622 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
625 if (!GetSolver()->ComputeFunction(aFunction)) {
626 SetErrorCode("Chamfer driver failed");
630 catch (Standard_Failure) {
631 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
632 SetErrorCode(aFail->GetMessageString());
636 //Make a Python command
637 GEOM::TPythonDump pd (aFunction);
638 pd << aChamfer << " = geompy.MakeChamferFaces(" << theShape
639 << ", " << theD1 << ", " << theD2 << ", [";
641 it = theFaces.begin();
643 while (it != theFaces.end()) {
644 pd << ", " << (*it++);
652 //=============================================================================
656 //=============================================================================
657 Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeChamferFacesAD
658 (Handle(GEOM_Object) theShape, double theD, double theAngle,
663 //Add a new Chamfer object
664 Handle(GEOM_Object) aChamfer = GetEngine()->AddObject(GetDocID(), GEOM_CHAMFER);
666 //Add a new Chamfer function
667 Handle(GEOM_Function) aFunction =
668 aChamfer->AddFunction(GEOMImpl_ChamferDriver::GetID(), CHAMFER_SHAPE_FACES_AD);
669 if (aFunction.IsNull()) return NULL;
671 //Check if the function is set correctly
672 if (aFunction->GetDriverGUID() != GEOMImpl_ChamferDriver::GetID()) return NULL;
674 GEOMImpl_IChamfer aCI (aFunction);
676 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
677 if (aRefShape.IsNull()) return NULL;
679 aCI.SetShape(aRefShape);
681 aCI.SetAngle(theAngle);
682 int aLen = theFaces.size();
686 list<int>::iterator it = theFaces.begin();
687 for (; it != theFaces.end(); it++, ind++) {
688 aCI.SetFace(ind, (*it));
691 //Compute the Chamfer value
693 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
696 if (!GetSolver()->ComputeFunction(aFunction)) {
697 SetErrorCode("Chamfer driver failed");
701 catch (Standard_Failure) {
702 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
703 SetErrorCode(aFail->GetMessageString());
707 //Make a Python command
708 GEOM::TPythonDump pd (aFunction);
709 pd << aChamfer << " = geompy.MakeChamferFacesAD(" << theShape
710 << ", " << theD << ", " << theAngle << ", [";
712 it = theFaces.begin();
714 while (it != theFaces.end()) {
715 pd << ", " << (*it++);
723 //=============================================================================
727 //=============================================================================
728 Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeChamferEdges
729 (Handle(GEOM_Object) theShape, double theD1, double theD2,
734 //Add a new Chamfer object
735 Handle(GEOM_Object) aChamfer = GetEngine()->AddObject(GetDocID(), GEOM_CHAMFER);
737 //Add a new Chamfer function
738 Handle(GEOM_Function) aFunction =
739 aChamfer->AddFunction(GEOMImpl_ChamferDriver::GetID(), CHAMFER_SHAPE_EDGES);
740 if (aFunction.IsNull()) { MESSAGE ( "Edges Function is NULL!!!" ); return NULL;}
742 //Check if the function is set correctly
743 if (aFunction->GetDriverGUID() != GEOMImpl_ChamferDriver::GetID())
744 { MESSAGE ( "Chamfer Driver is NULL!!!" ); return NULL; }
746 GEOMImpl_IChamfer aCI (aFunction);
748 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
749 if (aRefShape.IsNull()) { MESSAGE ("Shape is NULL!!!"); return NULL;}
751 aCI.SetShape(aRefShape);
754 int aLen = theEdges.size();
758 list<int>::iterator it = theEdges.begin();
759 for (; it != theEdges.end(); it++, ind++) {
760 aCI.SetEdge(ind, (*it));
763 //Compute the Chamfer value
765 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
768 if (!GetSolver()->ComputeFunction(aFunction)) {
769 SetErrorCode("Chamfer driver failed");
773 catch (Standard_Failure) {
774 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
775 SetErrorCode(aFail->GetMessageString());
779 //Make a Python command
780 GEOM::TPythonDump pd (aFunction);
781 pd << aChamfer << " = geompy.MakeChamferEdges(" << theShape
782 << ", " << theD1 << ", " << theD2 << ", [";
784 it = theEdges.begin();
786 while (it != theEdges.end()) {
787 pd << ", " << (*it++);
795 //=============================================================================
799 //=============================================================================
800 Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeChamferEdgesAD
801 (Handle(GEOM_Object) theShape, double theD, double theAngle,
806 //Add a new Chamfer object
807 Handle(GEOM_Object) aChamfer = GetEngine()->AddObject(GetDocID(), GEOM_CHAMFER);
809 //Add a new Chamfer function
810 Handle(GEOM_Function) aFunction =
811 aChamfer->AddFunction(GEOMImpl_ChamferDriver::GetID(), CHAMFER_SHAPE_EDGES_AD);
812 if (aFunction.IsNull()) { MESSAGE ( "Edges Function is NULL!!!" ); return NULL; }
814 //Check if the function is set correctly
815 if (aFunction->GetDriverGUID() != GEOMImpl_ChamferDriver::GetID())
816 { MESSAGE("Chamfer Driver is NULL!!!"); return NULL;}
818 GEOMImpl_IChamfer aCI (aFunction);
820 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
821 if (aRefShape.IsNull()) { MESSAGE ("Shape is NULL!!!"); return NULL;}
823 aCI.SetShape(aRefShape);
825 aCI.SetAngle(theAngle);
826 int aLen = theEdges.size();
830 list<int>::iterator it = theEdges.begin();
831 for (; it != theEdges.end(); it++, ind++) {
832 aCI.SetEdge(ind, (*it));
835 //Compute the Chamfer value
837 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
840 if (!GetSolver()->ComputeFunction(aFunction)) {
841 SetErrorCode("Chamfer driver failed");
845 catch (Standard_Failure) {
846 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
847 SetErrorCode(aFail->GetMessageString());
851 //Make a Python command
852 GEOM::TPythonDump pd (aFunction);
853 pd << aChamfer << " = geompy.MakeChamferEdgesAD(" << theShape
854 << ", " << theD << ", " << theAngle << ", [";
856 it = theEdges.begin();
858 while (it != theEdges.end()) {
859 pd << ", " << (*it++);
867 //=============================================================================
871 //=============================================================================
872 Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeArchimede (Handle(GEOM_Object) theShape,
874 double theWaterDensity,
875 double theMeshingDeflection)
879 //Add a new Archimede object
880 Handle(GEOM_Object) aChamfer = GetEngine()->AddObject(GetDocID(), GEOM_ARCHIMEDE);
882 //Add a new Archimede function
883 Handle(GEOM_Function) aFunction = aChamfer->AddFunction(GEOMImpl_ArchimedeDriver::GetID(), ARCHIMEDE_TYPE);
884 if (aFunction.IsNull()) return NULL;
886 //Check if the function is set correctly
887 if (aFunction->GetDriverGUID() != GEOMImpl_ArchimedeDriver::GetID()) return NULL;
889 GEOMImpl_IArchimede aAI (aFunction);
891 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
892 if (aRefShape.IsNull()) return NULL;
894 aAI.SetBasicShape(aRefShape);
895 aAI.SetWeight(theWeight);
896 aAI.SetDensity(theWaterDensity);
897 aAI.SetDeflection(theMeshingDeflection);
899 //Compute the Archimede value
901 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
904 if (!GetSolver()->ComputeFunction(aFunction)) {
905 SetErrorCode("Archimede driver failed");
909 catch (Standard_Failure) {
910 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
911 SetErrorCode(aFail->GetMessageString());
915 //Make a Python command
916 GEOM::TPythonDump(aFunction) << aChamfer
917 << " = geompy.Archimede(" << theShape << ", " << theWeight << ", "
918 << theWaterDensity << ", " << theMeshingDeflection << ")";
924 //=============================================================================
928 //=============================================================================
929 bool GEOMImpl_ILocalOperations::GetSubShape (const TopoDS_Shape& theShape, const int theIndex,
930 TopoDS_Shape& theSubShape)
932 if (theShape.IsNull() || theIndex < 1)
935 TopTools_IndexedMapOfShape anIndices;
936 TopExp::MapShapes(theShape, anIndices);
937 if (theIndex > anIndices.Extent()) return false;
938 theSubShape = anIndices.FindKey(theIndex);
943 //=============================================================================
947 //=============================================================================
948 Standard_Integer GEOMImpl_ILocalOperations::GetSubShapeIndex (Handle(GEOM_Object) theShape,
949 Handle(GEOM_Object) theSubShape)
953 Standard_Integer anInd = -1;
954 GEOM_Engine* anEngine = GetEngine();
955 //GEOMImpl_Gen* aGen = dynamic_cast<GEOMImpl_Gen*>(anEngine);
956 GEOMImpl_Gen* aGen = (GEOMImpl_Gen*)anEngine;
959 GEOMImpl_IShapesOperations* anIShapesOperations =
960 aGen->GetIShapesOperations(GetDocID());
961 anInd = anIShapesOperations->GetSubShapeIndex(theShape, theSubShape);
962 SetErrorCode(anIShapesOperations->GetErrorCode());