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 << ")";
574 cout << "ANGLE = " << theAngle << endl;
579 //=============================================================================
583 //=============================================================================
584 Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeChamferFaces
585 (Handle(GEOM_Object) theShape, double theD1, double theD2,
590 //Add a new Chamfer object
591 Handle(GEOM_Object) aChamfer = GetEngine()->AddObject(GetDocID(), GEOM_CHAMFER);
593 //Add a new Chamfer function
594 Handle(GEOM_Function) aFunction =
595 aChamfer->AddFunction(GEOMImpl_ChamferDriver::GetID(), CHAMFER_SHAPE_FACES);
596 if (aFunction.IsNull()) return NULL;
598 //Check if the function is set correctly
599 if (aFunction->GetDriverGUID() != GEOMImpl_ChamferDriver::GetID()) return NULL;
601 GEOMImpl_IChamfer aCI (aFunction);
603 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
604 if (aRefShape.IsNull()) return NULL;
606 aCI.SetShape(aRefShape);
609 int aLen = theFaces.size();
613 list<int>::iterator it = theFaces.begin();
614 for (; it != theFaces.end(); it++, ind++) {
615 aCI.SetFace(ind, (*it));
618 //Compute the Chamfer value
620 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
623 if (!GetSolver()->ComputeFunction(aFunction)) {
624 SetErrorCode("Chamfer driver failed");
628 catch (Standard_Failure) {
629 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
630 SetErrorCode(aFail->GetMessageString());
634 //Make a Python command
635 GEOM::TPythonDump pd (aFunction);
636 pd << aChamfer << " = geompy.MakeChamferFaces(" << theShape
637 << ", " << theD1 << ", " << theD2 << ", [";
639 it = theFaces.begin();
641 while (it != theFaces.end()) {
642 pd << ", " << (*it++);
650 //=============================================================================
654 //=============================================================================
655 Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeChamferFacesAD
656 (Handle(GEOM_Object) theShape, double theD, double theAngle,
661 //Add a new Chamfer object
662 Handle(GEOM_Object) aChamfer = GetEngine()->AddObject(GetDocID(), GEOM_CHAMFER);
664 //Add a new Chamfer function
665 Handle(GEOM_Function) aFunction =
666 aChamfer->AddFunction(GEOMImpl_ChamferDriver::GetID(), CHAMFER_SHAPE_FACES_AD);
667 if (aFunction.IsNull()) return NULL;
669 //Check if the function is set correctly
670 if (aFunction->GetDriverGUID() != GEOMImpl_ChamferDriver::GetID()) return NULL;
672 GEOMImpl_IChamfer aCI (aFunction);
674 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
675 if (aRefShape.IsNull()) return NULL;
677 aCI.SetShape(aRefShape);
679 aCI.SetAngle(theAngle);
680 int aLen = theFaces.size();
684 list<int>::iterator it = theFaces.begin();
685 for (; it != theFaces.end(); it++, ind++) {
686 aCI.SetFace(ind, (*it));
689 //Compute the Chamfer value
691 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
694 if (!GetSolver()->ComputeFunction(aFunction)) {
695 SetErrorCode("Chamfer driver failed");
699 catch (Standard_Failure) {
700 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
701 SetErrorCode(aFail->GetMessageString());
705 //Make a Python command
706 GEOM::TPythonDump pd (aFunction);
707 pd << aChamfer << " = geompy.MakeChamferFacesAD(" << theShape
708 << ", " << theD << ", " << theAngle << ", [";
710 it = theFaces.begin();
712 while (it != theFaces.end()) {
713 pd << ", " << (*it++);
721 //=============================================================================
725 //=============================================================================
726 Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeChamferEdges
727 (Handle(GEOM_Object) theShape, double theD1, double theD2,
732 //Add a new Chamfer object
733 Handle(GEOM_Object) aChamfer = GetEngine()->AddObject(GetDocID(), GEOM_CHAMFER);
735 //Add a new Chamfer function
736 Handle(GEOM_Function) aFunction =
737 aChamfer->AddFunction(GEOMImpl_ChamferDriver::GetID(), CHAMFER_SHAPE_EDGES);
738 if (aFunction.IsNull()) { return NULL; cout << "Edges Function is NULL!!!" << endl; }
740 //Check if the function is set correctly
741 if (aFunction->GetDriverGUID() != GEOMImpl_ChamferDriver::GetID())
742 { return NULL; cout << "Chamfer Driver is NULL!!!" << endl; }
744 GEOMImpl_IChamfer aCI (aFunction);
746 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
747 if (aRefShape.IsNull()) { return NULL; cout << "Shape is NULL!!!" << endl; }
749 aCI.SetShape(aRefShape);
752 int aLen = theEdges.size();
756 list<int>::iterator it = theEdges.begin();
757 for (; it != theEdges.end(); it++, ind++) {
758 aCI.SetEdge(ind, (*it));
761 //Compute the Chamfer value
763 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
766 if (!GetSolver()->ComputeFunction(aFunction)) {
767 SetErrorCode("Chamfer driver failed");
771 catch (Standard_Failure) {
772 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
773 SetErrorCode(aFail->GetMessageString());
777 //Make a Python command
778 GEOM::TPythonDump pd (aFunction);
779 pd << aChamfer << " = geompy.MakeChamferEdges(" << theShape
780 << ", " << theD1 << ", " << theD2 << ", [";
782 it = theEdges.begin();
784 while (it != theEdges.end()) {
785 pd << ", " << (*it++);
793 //=============================================================================
797 //=============================================================================
798 Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeChamferEdgesAD
799 (Handle(GEOM_Object) theShape, double theD, double theAngle,
804 //Add a new Chamfer object
805 Handle(GEOM_Object) aChamfer = GetEngine()->AddObject(GetDocID(), GEOM_CHAMFER);
807 //Add a new Chamfer function
808 Handle(GEOM_Function) aFunction =
809 aChamfer->AddFunction(GEOMImpl_ChamferDriver::GetID(), CHAMFER_SHAPE_EDGES_AD);
810 if (aFunction.IsNull()) { return NULL; cout << "Edges Function is NULL!!!" << endl; }
812 //Check if the function is set correctly
813 if (aFunction->GetDriverGUID() != GEOMImpl_ChamferDriver::GetID())
814 { return NULL; cout << "Chamfer Driver is NULL!!!" << endl; }
816 GEOMImpl_IChamfer aCI (aFunction);
818 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
819 if (aRefShape.IsNull()) { return NULL; cout << "Shape is NULL!!!" << endl; }
821 aCI.SetShape(aRefShape);
823 aCI.SetAngle(theAngle);
824 int aLen = theEdges.size();
828 list<int>::iterator it = theEdges.begin();
829 for (; it != theEdges.end(); it++, ind++) {
830 aCI.SetEdge(ind, (*it));
833 //Compute the Chamfer value
835 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
838 if (!GetSolver()->ComputeFunction(aFunction)) {
839 SetErrorCode("Chamfer driver failed");
843 catch (Standard_Failure) {
844 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
845 SetErrorCode(aFail->GetMessageString());
849 //Make a Python command
850 GEOM::TPythonDump pd (aFunction);
851 pd << aChamfer << " = geompy.MakeChamferEdgesAD(" << theShape
852 << ", " << theD << ", " << theAngle << ", [";
854 it = theEdges.begin();
856 while (it != theEdges.end()) {
857 pd << ", " << (*it++);
865 //=============================================================================
869 //=============================================================================
870 Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeArchimede (Handle(GEOM_Object) theShape,
872 double theWaterDensity,
873 double theMeshingDeflection)
877 //Add a new Archimede object
878 Handle(GEOM_Object) aChamfer = GetEngine()->AddObject(GetDocID(), GEOM_ARCHIMEDE);
880 //Add a new Archimede function
881 Handle(GEOM_Function) aFunction = aChamfer->AddFunction(GEOMImpl_ArchimedeDriver::GetID(), ARCHIMEDE_TYPE);
882 if (aFunction.IsNull()) return NULL;
884 //Check if the function is set correctly
885 if (aFunction->GetDriverGUID() != GEOMImpl_ArchimedeDriver::GetID()) return NULL;
887 GEOMImpl_IArchimede aAI (aFunction);
889 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
890 if (aRefShape.IsNull()) return NULL;
892 aAI.SetBasicShape(aRefShape);
893 aAI.SetWeight(theWeight);
894 aAI.SetDensity(theWaterDensity);
895 aAI.SetDeflection(theMeshingDeflection);
897 //Compute the Archimede value
899 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
902 if (!GetSolver()->ComputeFunction(aFunction)) {
903 SetErrorCode("Archimede driver failed");
907 catch (Standard_Failure) {
908 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
909 SetErrorCode(aFail->GetMessageString());
913 //Make a Python command
914 GEOM::TPythonDump(aFunction) << aChamfer
915 << " = geompy.Archimede(" << theShape << ", " << theWeight << ", "
916 << theWaterDensity << ", " << theMeshingDeflection << ")";
922 //=============================================================================
926 //=============================================================================
927 bool GEOMImpl_ILocalOperations::GetSubShape (const TopoDS_Shape& theShape, const int theIndex,
928 TopoDS_Shape& theSubShape)
930 if (theShape.IsNull() || theIndex < 1)
933 TopTools_IndexedMapOfShape anIndices;
934 TopExp::MapShapes(theShape, anIndices);
935 if (theIndex > anIndices.Extent()) return false;
936 theSubShape = anIndices.FindKey(theIndex);
941 //=============================================================================
945 //=============================================================================
946 Standard_Integer GEOMImpl_ILocalOperations::GetSubShapeIndex (Handle(GEOM_Object) theShape,
947 Handle(GEOM_Object) theSubShape)
951 Standard_Integer anInd = -1;
952 GEOM_Engine* anEngine = GetEngine();
953 //GEOMImpl_Gen* aGen = dynamic_cast<GEOMImpl_Gen*>(anEngine);
954 GEOMImpl_Gen* aGen = (GEOMImpl_Gen*)anEngine;
957 GEOMImpl_IShapesOperations* anIShapesOperations =
958 aGen->GetIShapesOperations(GetDocID());
959 anInd = anIShapesOperations->GetSubShapeIndex(theShape, theSubShape);
960 SetErrorCode(anIShapesOperations->GetErrorCode());