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_Fillet2dDriver.hxx>
33 #include <GEOMImpl_ChamferDriver.hxx>
35 #include <GEOMImpl_IFillet.hxx>
36 #include <GEOMImpl_IFillet2d.hxx>
37 #include <GEOMImpl_IChamfer.hxx>
39 #include <GEOMImpl_IArchimede.hxx>
40 #include <GEOMImpl_ArchimedeDriver.hxx>
42 #include <GEOMImpl_Gen.hxx>
43 #include <GEOMImpl_IShapesOperations.hxx>
45 #include "utilities.h"
47 #include <Utils_ExceptHandlers.hxx>
49 #include <TFunction_DriverTable.hxx>
50 #include <TFunction_Driver.hxx>
51 #include <TFunction_Logbook.hxx>
52 #include <TDF_Tool.hxx>
55 #include <TopoDS_TShape.hxx>
56 #include <TopTools_IndexedMapOfShape.hxx>
58 #include <Standard_Failure.hxx>
59 #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, std::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 std::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, std::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 std::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, std::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 std::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, std::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 std::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::MakeFillet2D
421 (Handle(GEOM_Object) theShape, double theR, std::list<int> theVertexes)
425 //Add a new Fillet object
426 Handle(GEOM_Object) aFillet2D = GetEngine()->AddObject(GetDocID(), GEOM_FILLET_2D);
428 //Add a new Fillet function
429 Handle(GEOM_Function) aFunction =
430 aFillet2D->AddFunction(GEOMImpl_Fillet2dDriver::GetID(), FILLET_2D_SHAPE_VERTEXES);
431 if (aFunction.IsNull()) return NULL;
433 //Check if the function is set correctly
434 if (aFunction->GetDriverGUID() != GEOMImpl_Fillet2dDriver::GetID()) return NULL;
436 GEOMImpl_IFillet2d aCI (aFunction);
438 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
439 if (aRefShape.IsNull()) return NULL;
441 aCI.SetShape(aRefShape);
443 int aLen = theVertexes.size();
447 std::list<int>::iterator it = theVertexes.begin();
448 for (; it != theVertexes.end(); it++, ind++) {
449 aCI.SetVertex(ind, (*it));
452 //Compute the Fillet value
454 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
457 if (!GetSolver()->ComputeFunction(aFunction)) {
458 SetErrorCode("2D Fillet driver failed");
462 catch (Standard_Failure) {
463 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
464 SetErrorCode(aFail->GetMessageString());
468 //Make a Python command
469 GEOM::TPythonDump pd (aFunction);
470 pd << aFillet2D << " = geompy.MakeFillet2D(" << theShape
471 << ", " << theR << ", [";
473 it = theVertexes.begin();
475 while (it != theVertexes.end()) {
476 pd << ", " << (*it++);
484 //=============================================================================
488 //=============================================================================
489 Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeChamferAll (Handle(GEOM_Object) theShape, double theD)
493 //Add a new Chamfer object
494 Handle(GEOM_Object) aChamfer = GetEngine()->AddObject(GetDocID(), GEOM_CHAMFER);
496 //Add a new Chamfer function
497 Handle(GEOM_Function) aFunction =
498 aChamfer->AddFunction(GEOMImpl_ChamferDriver::GetID(), CHAMFER_SHAPE_ALL);
499 if (aFunction.IsNull()) return NULL;
501 //Check if the function is set correctly
502 if (aFunction->GetDriverGUID() != GEOMImpl_ChamferDriver::GetID()) return NULL;
504 GEOMImpl_IChamfer aCI (aFunction);
506 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
507 if (aRefShape.IsNull()) return NULL;
509 aCI.SetShape(aRefShape);
512 //Compute the Chamfer value
514 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
517 if (!GetSolver()->ComputeFunction(aFunction)) {
518 SetErrorCode("Chamfer driver failed");
522 catch (Standard_Failure) {
523 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
524 SetErrorCode(aFail->GetMessageString());
528 //Make a Python command
529 GEOM::TPythonDump(aFunction) << aChamfer << " = geompy.MakeChamferAll("
530 << theShape << ", " << theD << ")";
536 //=============================================================================
540 //=============================================================================
541 Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeChamferEdge
542 (Handle(GEOM_Object) theShape, double theD1, double theD2,
543 int theFace1, int theFace2)
547 //Add a new Chamfer object
548 Handle(GEOM_Object) aChamfer = GetEngine()->AddObject(GetDocID(), GEOM_CHAMFER);
550 //Add a new Chamfer function
551 Handle(GEOM_Function) aFunction =
552 aChamfer->AddFunction(GEOMImpl_ChamferDriver::GetID(), CHAMFER_SHAPE_EDGE);
553 if (aFunction.IsNull()) return NULL;
555 //Check if the function is set correctly
556 if (aFunction->GetDriverGUID() != GEOMImpl_ChamferDriver::GetID()) return NULL;
558 GEOMImpl_IChamfer aCI (aFunction);
560 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
561 if (aRefShape.IsNull()) return NULL;
563 aCI.SetShape(aRefShape);
566 aCI.SetFace1(theFace1);
567 aCI.SetFace2(theFace2);
569 //Compute the Chamfer value
571 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
574 if (!GetSolver()->ComputeFunction(aFunction)) {
575 SetErrorCode("Chamfer driver failed");
579 catch (Standard_Failure) {
580 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
581 SetErrorCode(aFail->GetMessageString());
585 //Make a Python command
586 GEOM::TPythonDump(aFunction) << aChamfer
587 << " = geompy.MakeChamferEdge(" << theShape << ", " << theD1
588 << ", " << theD2 << ", " << theFace1 << ", " << theFace2 << ")";
594 //=============================================================================
598 //=============================================================================
599 Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeChamferEdgeAD
600 (Handle(GEOM_Object) theShape, double theD, double theAngle,
601 int theFace1, int theFace2)
605 //Add a new Chamfer object
606 Handle(GEOM_Object) aChamfer = GetEngine()->AddObject(GetDocID(), GEOM_CHAMFER);
608 //Add a new Chamfer function
609 Handle(GEOM_Function) aFunction =
610 aChamfer->AddFunction(GEOMImpl_ChamferDriver::GetID(), CHAMFER_SHAPE_EDGE_AD);
611 if (aFunction.IsNull()) return NULL;
613 //Check if the function is set correctly
614 if (aFunction->GetDriverGUID() != GEOMImpl_ChamferDriver::GetID()) return NULL;
616 GEOMImpl_IChamfer aCI (aFunction);
618 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
619 if (aRefShape.IsNull()) return NULL;
621 aCI.SetShape(aRefShape);
623 aCI.SetAngle(theAngle);
624 aCI.SetFace1(theFace1);
625 aCI.SetFace2(theFace2);
627 //Compute the Chamfer value
629 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
632 if (!GetSolver()->ComputeFunction(aFunction)) {
633 SetErrorCode("Chamfer driver failed");
637 catch (Standard_Failure) {
638 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
639 SetErrorCode(aFail->GetMessageString());
643 //Make a Python command
644 GEOM::TPythonDump(aFunction) << aChamfer
645 << " = geompy.MakeChamferEdgeAD(" << theShape << ", " << theD
646 << ", " << theAngle << ", " << theFace1 << ", " << theFace2 << ")";
651 //=============================================================================
655 //=============================================================================
656 Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeChamferFaces
657 (Handle(GEOM_Object) theShape, double theD1, double theD2,
658 std::list<int> theFaces)
662 //Add a new Chamfer object
663 Handle(GEOM_Object) aChamfer = GetEngine()->AddObject(GetDocID(), GEOM_CHAMFER);
665 //Add a new Chamfer function
666 Handle(GEOM_Function) aFunction =
667 aChamfer->AddFunction(GEOMImpl_ChamferDriver::GetID(), CHAMFER_SHAPE_FACES);
668 if (aFunction.IsNull()) return NULL;
670 //Check if the function is set correctly
671 if (aFunction->GetDriverGUID() != GEOMImpl_ChamferDriver::GetID()) return NULL;
673 GEOMImpl_IChamfer aCI (aFunction);
675 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
676 if (aRefShape.IsNull()) return NULL;
678 aCI.SetShape(aRefShape);
681 int aLen = theFaces.size();
685 std::list<int>::iterator it = theFaces.begin();
686 for (; it != theFaces.end(); it++, ind++) {
687 aCI.SetFace(ind, (*it));
690 //Compute the Chamfer value
692 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
695 if (!GetSolver()->ComputeFunction(aFunction)) {
696 SetErrorCode("Chamfer driver failed");
700 catch (Standard_Failure) {
701 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
702 SetErrorCode(aFail->GetMessageString());
706 //Make a Python command
707 GEOM::TPythonDump pd (aFunction);
708 pd << aChamfer << " = geompy.MakeChamferFaces(" << theShape
709 << ", " << theD1 << ", " << theD2 << ", [";
711 it = theFaces.begin();
713 while (it != theFaces.end()) {
714 pd << ", " << (*it++);
722 //=============================================================================
726 //=============================================================================
727 Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeChamferFacesAD
728 (Handle(GEOM_Object) theShape, double theD, double theAngle,
729 std::list<int> theFaces)
733 //Add a new Chamfer object
734 Handle(GEOM_Object) aChamfer = GetEngine()->AddObject(GetDocID(), GEOM_CHAMFER);
736 //Add a new Chamfer function
737 Handle(GEOM_Function) aFunction =
738 aChamfer->AddFunction(GEOMImpl_ChamferDriver::GetID(), CHAMFER_SHAPE_FACES_AD);
739 if (aFunction.IsNull()) return NULL;
741 //Check if the function is set correctly
742 if (aFunction->GetDriverGUID() != GEOMImpl_ChamferDriver::GetID()) return NULL;
744 GEOMImpl_IChamfer aCI (aFunction);
746 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
747 if (aRefShape.IsNull()) return NULL;
749 aCI.SetShape(aRefShape);
751 aCI.SetAngle(theAngle);
752 int aLen = theFaces.size();
756 std::list<int>::iterator it = theFaces.begin();
757 for (; it != theFaces.end(); it++, ind++) {
758 aCI.SetFace(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.MakeChamferFacesAD(" << theShape
780 << ", " << theD << ", " << theAngle << ", [";
782 it = theFaces.begin();
784 while (it != theFaces.end()) {
785 pd << ", " << (*it++);
793 //=============================================================================
797 //=============================================================================
798 Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeChamferEdges
799 (Handle(GEOM_Object) theShape, double theD1, double theD2,
800 std::list<int> theEdges)
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);
810 if (aFunction.IsNull()) { MESSAGE ( "Edges Function is NULL!!!" ); return NULL;}
812 //Check if the function is set correctly
813 if (aFunction->GetDriverGUID() != GEOMImpl_ChamferDriver::GetID())
814 { MESSAGE ( "Chamfer Driver is NULL!!!" ); return NULL; }
816 GEOMImpl_IChamfer aCI (aFunction);
818 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
819 if (aRefShape.IsNull()) { MESSAGE ("Shape is NULL!!!"); return NULL;}
821 aCI.SetShape(aRefShape);
824 int aLen = theEdges.size();
828 std::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.MakeChamferEdges(" << theShape
852 << ", " << theD1 << ", " << theD2 << ", [";
854 it = theEdges.begin();
856 while (it != theEdges.end()) {
857 pd << ", " << (*it++);
865 //=============================================================================
869 //=============================================================================
870 Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeChamferEdgesAD
871 (Handle(GEOM_Object) theShape, double theD, double theAngle,
872 std::list<int> theEdges)
876 //Add a new Chamfer object
877 Handle(GEOM_Object) aChamfer = GetEngine()->AddObject(GetDocID(), GEOM_CHAMFER);
879 //Add a new Chamfer function
880 Handle(GEOM_Function) aFunction =
881 aChamfer->AddFunction(GEOMImpl_ChamferDriver::GetID(), CHAMFER_SHAPE_EDGES_AD);
882 if (aFunction.IsNull()) { MESSAGE ( "Edges Function is NULL!!!" ); return NULL; }
884 //Check if the function is set correctly
885 if (aFunction->GetDriverGUID() != GEOMImpl_ChamferDriver::GetID())
886 { MESSAGE("Chamfer Driver is NULL!!!"); return NULL;}
888 GEOMImpl_IChamfer aCI (aFunction);
890 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
891 if (aRefShape.IsNull()) { MESSAGE ("Shape is NULL!!!"); return NULL;}
893 aCI.SetShape(aRefShape);
895 aCI.SetAngle(theAngle);
896 int aLen = theEdges.size();
900 std::list<int>::iterator it = theEdges.begin();
901 for (; it != theEdges.end(); it++, ind++) {
902 aCI.SetEdge(ind, (*it));
905 //Compute the Chamfer value
907 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
910 if (!GetSolver()->ComputeFunction(aFunction)) {
911 SetErrorCode("Chamfer driver failed");
915 catch (Standard_Failure) {
916 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
917 SetErrorCode(aFail->GetMessageString());
921 //Make a Python command
922 GEOM::TPythonDump pd (aFunction);
923 pd << aChamfer << " = geompy.MakeChamferEdgesAD(" << theShape
924 << ", " << theD << ", " << theAngle << ", [";
926 it = theEdges.begin();
928 while (it != theEdges.end()) {
929 pd << ", " << (*it++);
937 //=============================================================================
941 //=============================================================================
942 Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeArchimede (Handle(GEOM_Object) theShape,
944 double theWaterDensity,
945 double theMeshingDeflection)
949 //Add a new Archimede object
950 Handle(GEOM_Object) aChamfer = GetEngine()->AddObject(GetDocID(), GEOM_ARCHIMEDE);
952 //Add a new Archimede function
953 Handle(GEOM_Function) aFunction = aChamfer->AddFunction(GEOMImpl_ArchimedeDriver::GetID(), ARCHIMEDE_TYPE);
954 if (aFunction.IsNull()) return NULL;
956 //Check if the function is set correctly
957 if (aFunction->GetDriverGUID() != GEOMImpl_ArchimedeDriver::GetID()) return NULL;
959 GEOMImpl_IArchimede aAI (aFunction);
961 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
962 if (aRefShape.IsNull()) return NULL;
964 aAI.SetBasicShape(aRefShape);
965 aAI.SetWeight(theWeight);
966 aAI.SetDensity(theWaterDensity);
967 aAI.SetDeflection(theMeshingDeflection);
969 //Compute the Archimede value
971 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
974 if (!GetSolver()->ComputeFunction(aFunction)) {
975 SetErrorCode("Archimede driver failed");
979 catch (Standard_Failure) {
980 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
981 SetErrorCode(aFail->GetMessageString());
985 //Make a Python command
986 GEOM::TPythonDump(aFunction) << aChamfer
987 << " = geompy.Archimede(" << theShape << ", " << theWeight << ", "
988 << theWaterDensity << ", " << theMeshingDeflection << ")";
994 //=============================================================================
998 //=============================================================================
999 bool GEOMImpl_ILocalOperations::GetSubShape (const TopoDS_Shape& theShape, const int theIndex,
1000 TopoDS_Shape& theSubShape)
1002 if (theShape.IsNull() || theIndex < 1)
1005 TopTools_IndexedMapOfShape anIndices;
1006 TopExp::MapShapes(theShape, anIndices);
1007 if (theIndex > anIndices.Extent()) return false;
1008 theSubShape = anIndices.FindKey(theIndex);
1013 //=============================================================================
1017 //=============================================================================
1018 Standard_Integer GEOMImpl_ILocalOperations::GetSubShapeIndex (Handle(GEOM_Object) theShape,
1019 Handle(GEOM_Object) theSubShape)
1023 Standard_Integer anInd = -1;
1024 GEOM_Engine* anEngine = GetEngine();
1025 //GEOMImpl_Gen* aGen = dynamic_cast<GEOMImpl_Gen*>(anEngine);
1026 GEOMImpl_Gen* aGen = (GEOMImpl_Gen*)anEngine;
1029 GEOMImpl_IShapesOperations* anIShapesOperations =
1030 aGen->GetIShapesOperations(GetDocID());
1031 anInd = anIShapesOperations->GetSubShapeIndex(theShape, theSubShape);
1032 SetErrorCode(anIShapesOperations->GetErrorCode());