1 // Copyright (C) 2007-2010 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
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_Fillet1dDriver.hxx>
34 #include <GEOMImpl_Fillet2dDriver.hxx>
35 #include <GEOMImpl_ChamferDriver.hxx>
37 #include <GEOMImpl_IFillet.hxx>
38 #include <GEOMImpl_IFillet1d.hxx>
39 #include <GEOMImpl_IFillet2d.hxx>
40 #include <GEOMImpl_IChamfer.hxx>
42 #include <GEOMImpl_IArchimede.hxx>
43 #include <GEOMImpl_ArchimedeDriver.hxx>
45 #include <GEOMImpl_Gen.hxx>
46 #include <GEOMImpl_IShapesOperations.hxx>
48 #include "utilities.h"
50 #include <Utils_ExceptHandlers.hxx>
52 #include <TFunction_DriverTable.hxx>
53 #include <TFunction_Driver.hxx>
54 #include <TFunction_Logbook.hxx>
55 #include <TDF_Tool.hxx>
58 #include <TopoDS_TShape.hxx>
59 #include <TopTools_IndexedMapOfShape.hxx>
61 #include <Standard_Failure.hxx>
62 #include <Standard_ErrorHandler.hxx> // CAREFUL ! position of this file is critic : see Lucien PIGNOLONI / OCC
64 //=============================================================================
68 //=============================================================================
69 GEOMImpl_ILocalOperations::GEOMImpl_ILocalOperations (GEOM_Engine* theEngine, int theDocID)
70 : GEOM_IOperations(theEngine, theDocID)
72 MESSAGE("GEOMImpl_ILocalOperations::GEOMImpl_ILocalOperations");
75 //=============================================================================
79 //=============================================================================
80 GEOMImpl_ILocalOperations::~GEOMImpl_ILocalOperations()
82 MESSAGE("GEOMImpl_ILocalOperations::~GEOMImpl_ILocalOperations");
86 //=============================================================================
90 //=============================================================================
91 Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeFilletAll
92 (Handle(GEOM_Object) theShape, double theR)
96 //Add a new Fillet object
97 Handle(GEOM_Object) aFillet = GetEngine()->AddObject(GetDocID(), GEOM_FILLET);
99 //Add a new Fillet function
100 Handle(GEOM_Function) aFunction =
101 aFillet->AddFunction(GEOMImpl_FilletDriver::GetID(), FILLET_SHAPE_ALL);
102 if (aFunction.IsNull()) return NULL;
104 //Check if the function is set correctly
105 if (aFunction->GetDriverGUID() != GEOMImpl_FilletDriver::GetID()) return NULL;
107 GEOMImpl_IFillet aCI (aFunction);
109 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
110 if (aRefShape.IsNull()) return NULL;
112 aCI.SetShape(aRefShape);
115 //Compute the Fillet value
117 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
120 if (!GetSolver()->ComputeFunction(aFunction)) {
121 SetErrorCode("Fillet driver failed");
125 catch (Standard_Failure) {
126 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
127 SetErrorCode(aFail->GetMessageString());
131 //Make a Python command
132 GEOM::TPythonDump(aFunction) << aFillet << " = geompy.MakeFilletAll("
133 << theShape << ", " << theR << ")";
139 //=============================================================================
143 //=============================================================================
144 Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeFilletEdges
145 (Handle(GEOM_Object) theShape, double theR, std::list<int> theEdges)
149 //Add a new Fillet object
150 Handle(GEOM_Object) aFillet = GetEngine()->AddObject(GetDocID(), GEOM_FILLET);
152 //Add a new Fillet function
153 Handle(GEOM_Function) aFunction =
154 aFillet->AddFunction(GEOMImpl_FilletDriver::GetID(), FILLET_SHAPE_EDGES);
155 if (aFunction.IsNull()) return NULL;
157 //Check if the function is set correctly
158 if (aFunction->GetDriverGUID() != GEOMImpl_FilletDriver::GetID()) return NULL;
160 GEOMImpl_IFillet aCI (aFunction);
162 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
163 if (aRefShape.IsNull()) return NULL;
165 aCI.SetShape(aRefShape);
167 int aLen = theEdges.size();
171 std::list<int>::iterator it = theEdges.begin();
172 for (; it != theEdges.end(); it++, ind++) {
173 aCI.SetEdge(ind, (*it));
176 //Compute the Fillet value
178 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
181 if (!GetSolver()->ComputeFunction(aFunction)) {
182 SetErrorCode("Fillet driver failed");
186 catch (Standard_Failure) {
187 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
188 SetErrorCode(aFail->GetMessageString());
192 //Make a Python command
193 GEOM::TPythonDump pd (aFunction);
194 pd << aFillet << " = geompy.MakeFillet(" << theShape
195 << ", " << theR << ", geompy.ShapeType[\"EDGE\"], [";
197 it = theEdges.begin();
199 while (it != theEdges.end()) {
200 pd << ", " << (*it++);
208 //=============================================================================
210 * MakeFilletEdges R1 R2
212 //=============================================================================
213 Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeFilletEdgesR1R2
214 (Handle(GEOM_Object) theShape, double theR1, double theR2, std::list<int> theEdges)
218 //Add a new Fillet object
219 Handle(GEOM_Object) aFillet = GetEngine()->AddObject(GetDocID(), GEOM_FILLET);
221 //Add a new Fillet function
222 Handle(GEOM_Function) aFunction =
223 aFillet->AddFunction(GEOMImpl_FilletDriver::GetID(), FILLET_SHAPE_EDGES_2R);
224 if (aFunction.IsNull()) return NULL;
226 //Check if the function is set correctly
227 if (aFunction->GetDriverGUID() != GEOMImpl_FilletDriver::GetID()) return NULL;
229 GEOMImpl_IFillet aCI (aFunction);
231 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
232 if (aRefShape.IsNull()) return NULL;
234 aCI.SetShape(aRefShape);
237 int aLen = theEdges.size();
241 std::list<int>::iterator it = theEdges.begin();
242 for (; it != theEdges.end(); it++, ind++) {
243 aCI.SetEdge(ind, (*it));
246 //Compute the Fillet value
248 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
251 if (!GetSolver()->ComputeFunction(aFunction)) {
252 SetErrorCode("Fillet driver failed");
256 catch (Standard_Failure) {
257 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
258 SetErrorCode(aFail->GetMessageString());
262 //Make a Python command
263 GEOM::TPythonDump pd (aFunction);
264 pd << aFillet << " = geompy.MakeFilletR1R2(" << theShape
265 << ", " << theR1 << ", " <<theR2 << ", geompy.ShapeType[\"EDGE\"], [";
267 it = theEdges.begin();
269 while (it != theEdges.end()) {
270 pd << ", " << (*it++);
279 //=============================================================================
283 //=============================================================================
284 Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeFilletFaces
285 (Handle(GEOM_Object) theShape, double theR, std::list<int> theFaces)
289 //Add a new Fillet object
290 Handle(GEOM_Object) aFillet = GetEngine()->AddObject(GetDocID(), GEOM_FILLET);
292 //Add a new Fillet function
293 Handle(GEOM_Function) aFunction =
294 aFillet->AddFunction(GEOMImpl_FilletDriver::GetID(), FILLET_SHAPE_FACES);
295 if (aFunction.IsNull()) return NULL;
297 //Check if the function is set correctly
298 if (aFunction->GetDriverGUID() != GEOMImpl_FilletDriver::GetID()) return NULL;
300 GEOMImpl_IFillet aCI (aFunction);
302 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
303 if (aRefShape.IsNull()) return NULL;
305 aCI.SetShape(aRefShape);
307 int aLen = theFaces.size();
311 std::list<int>::iterator it = theFaces.begin();
312 for (; it != theFaces.end(); it++, ind++) {
313 aCI.SetFace(ind, (*it));
316 //Compute the Fillet value
318 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
321 if (!GetSolver()->ComputeFunction(aFunction)) {
322 SetErrorCode("Fillet driver failed");
326 catch (Standard_Failure) {
327 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
328 SetErrorCode(aFail->GetMessageString());
332 //Make a Python command
333 GEOM::TPythonDump pd (aFunction);
334 pd << aFillet << " = geompy.MakeFillet(" << theShape
335 << ", " << theR << ", geompy.ShapeType[\"FACE\"], [";
337 it = theFaces.begin();
339 while (it != theFaces.end()) {
340 pd << ", " << (*it++);
348 //=============================================================================
350 * MakeFilletFaces R1 R2
352 //=============================================================================
353 Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeFilletFacesR1R2
354 (Handle(GEOM_Object) theShape, double theR1, double theR2, std::list<int> theFaces)
358 //Add a new Fillet object
359 Handle(GEOM_Object) aFillet = GetEngine()->AddObject(GetDocID(), GEOM_FILLET);
361 //Add a new Fillet function
362 Handle(GEOM_Function) aFunction =
363 aFillet->AddFunction(GEOMImpl_FilletDriver::GetID(), FILLET_SHAPE_FACES_2R);
364 if (aFunction.IsNull()) return NULL;
366 //Check if the function is set correctly
367 if (aFunction->GetDriverGUID() != GEOMImpl_FilletDriver::GetID()) return NULL;
369 GEOMImpl_IFillet aCI (aFunction);
371 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
372 if (aRefShape.IsNull()) return NULL;
374 aCI.SetShape(aRefShape);
377 int aLen = theFaces.size();
381 std::list<int>::iterator it = theFaces.begin();
382 for (; it != theFaces.end(); it++, ind++) {
383 aCI.SetFace(ind, (*it));
386 //Compute the Fillet value
388 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
391 if (!GetSolver()->ComputeFunction(aFunction)) {
392 SetErrorCode("Fillet driver failed");
396 catch (Standard_Failure) {
397 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
398 SetErrorCode(aFail->GetMessageString());
402 //Make a Python command
403 GEOM::TPythonDump pd (aFunction);
404 pd << aFillet << " = geompy.MakeFilletR1R2(" << theShape
405 << ", " << theR1 << ", " << theR2 << ", geompy.ShapeType[\"FACE\"], [";
407 it = theFaces.begin();
409 while (it != theFaces.end()) {
410 pd << ", " << (*it++);
418 //=============================================================================
422 //=============================================================================
423 Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeFillet2D
424 (Handle(GEOM_Object) theShape, double theR, std::list<int> theVertexes)
428 //Add a new Fillet object
429 Handle(GEOM_Object) aFillet2D = GetEngine()->AddObject(GetDocID(), GEOM_FILLET_2D);
431 //Add a new Fillet function
432 Handle(GEOM_Function) aFunction =
433 aFillet2D->AddFunction(GEOMImpl_Fillet2dDriver::GetID(), FILLET_2D_SHAPE_VERTEXES);
434 if (aFunction.IsNull()) return NULL;
436 //Check if the function is set correctly
437 if (aFunction->GetDriverGUID() != GEOMImpl_Fillet2dDriver::GetID()) return NULL;
439 GEOMImpl_IFillet2d aCI (aFunction);
441 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
442 if (aRefShape.IsNull()) return NULL;
444 aCI.SetShape(aRefShape);
446 int aLen = theVertexes.size();
450 std::list<int>::iterator it = theVertexes.begin();
451 for (; it != theVertexes.end(); it++, ind++) {
452 aCI.SetVertex(ind, (*it));
455 //Compute the Fillet value
457 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
460 if (!GetSolver()->ComputeFunction(aFunction)) {
461 SetErrorCode("2D Fillet driver failed");
465 catch (Standard_Failure) {
466 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
467 SetErrorCode(aFail->GetMessageString());
471 //Make a Python command
472 GEOM::TPythonDump pd (aFunction);
473 pd << aFillet2D << " = geompy.MakeFillet2D(" << theShape
474 << ", " << theR << ", [";
476 it = theVertexes.begin();
478 while (it != theVertexes.end()) {
479 pd << ", " << (*it++);
487 //=============================================================================
491 //=============================================================================
492 Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeFillet1D
493 (Handle(GEOM_Object) theShape, double theR, std::list<int> theVertexes)
497 //Add a new Fillet object
498 Handle(GEOM_Object) aFillet1D = GetEngine()->AddObject(GetDocID(), GEOM_FILLET_1D);
500 //Add a new Fillet function
501 Handle(GEOM_Function) aFunction =
502 aFillet1D->AddFunction(GEOMImpl_Fillet1dDriver::GetID(), FILLET_1D_SHAPE_VERTEXES);
503 if (aFunction.IsNull()) return NULL;
505 //Check if the function is set correctly
506 if (aFunction->GetDriverGUID() != GEOMImpl_Fillet1dDriver::GetID()) return NULL;
508 GEOMImpl_IFillet1d aCI (aFunction);
510 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
511 if (aRefShape.IsNull()) return NULL;
513 aCI.SetShape(aRefShape);
515 int aLen = theVertexes.size();
519 std::list<int>::iterator it = theVertexes.begin();
520 for (; it != theVertexes.end(); it++, ind++) {
521 aCI.SetVertex(ind, (*it));
524 //Compute the Fillet value
526 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
529 if (!GetSolver()->ComputeFunction(aFunction)) {
530 SetErrorCode("1D Fillet driver failed");
534 catch (Standard_Failure) {
535 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
536 SetErrorCode(aFail->GetMessageString());
540 //Make a Python command
541 GEOM::TPythonDump pd (aFunction);
542 pd << aFillet1D << " = geompy.MakeFillet1D(" << theShape
543 << ", " << theR << ", [";
545 it = theVertexes.begin();
546 if (it != theVertexes.end()) {
548 while (it != theVertexes.end())
549 pd << ", " << (*it++);
557 //=============================================================================
561 //=============================================================================
562 Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeChamferAll (Handle(GEOM_Object) theShape, double theD)
566 //Add a new Chamfer object
567 Handle(GEOM_Object) aChamfer = GetEngine()->AddObject(GetDocID(), GEOM_CHAMFER);
569 //Add a new Chamfer function
570 Handle(GEOM_Function) aFunction =
571 aChamfer->AddFunction(GEOMImpl_ChamferDriver::GetID(), CHAMFER_SHAPE_ALL);
572 if (aFunction.IsNull()) return NULL;
574 //Check if the function is set correctly
575 if (aFunction->GetDriverGUID() != GEOMImpl_ChamferDriver::GetID()) return NULL;
577 GEOMImpl_IChamfer aCI (aFunction);
579 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
580 if (aRefShape.IsNull()) return NULL;
582 aCI.SetShape(aRefShape);
585 //Compute the Chamfer value
587 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
590 if (!GetSolver()->ComputeFunction(aFunction)) {
591 SetErrorCode("Chamfer driver failed");
595 catch (Standard_Failure) {
596 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
597 SetErrorCode(aFail->GetMessageString());
601 //Make a Python command
602 GEOM::TPythonDump(aFunction) << aChamfer << " = geompy.MakeChamferAll("
603 << theShape << ", " << theD << ")";
609 //=============================================================================
613 //=============================================================================
614 Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeChamferEdge
615 (Handle(GEOM_Object) theShape, double theD1, double theD2,
616 int theFace1, int theFace2)
620 //Add a new Chamfer object
621 Handle(GEOM_Object) aChamfer = GetEngine()->AddObject(GetDocID(), GEOM_CHAMFER);
623 //Add a new Chamfer function
624 Handle(GEOM_Function) aFunction =
625 aChamfer->AddFunction(GEOMImpl_ChamferDriver::GetID(), CHAMFER_SHAPE_EDGE);
626 if (aFunction.IsNull()) return NULL;
628 //Check if the function is set correctly
629 if (aFunction->GetDriverGUID() != GEOMImpl_ChamferDriver::GetID()) return NULL;
631 GEOMImpl_IChamfer aCI (aFunction);
633 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
634 if (aRefShape.IsNull()) return NULL;
636 aCI.SetShape(aRefShape);
639 aCI.SetFace1(theFace1);
640 aCI.SetFace2(theFace2);
642 //Compute the Chamfer value
644 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
647 if (!GetSolver()->ComputeFunction(aFunction)) {
648 SetErrorCode("Chamfer driver failed");
652 catch (Standard_Failure) {
653 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
654 SetErrorCode(aFail->GetMessageString());
658 //Make a Python command
659 GEOM::TPythonDump(aFunction) << aChamfer
660 << " = geompy.MakeChamferEdge(" << theShape << ", " << theD1
661 << ", " << theD2 << ", " << theFace1 << ", " << theFace2 << ")";
667 //=============================================================================
671 //=============================================================================
672 Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeChamferEdgeAD
673 (Handle(GEOM_Object) theShape, double theD, double theAngle,
674 int theFace1, int theFace2)
678 //Add a new Chamfer object
679 Handle(GEOM_Object) aChamfer = GetEngine()->AddObject(GetDocID(), GEOM_CHAMFER);
681 //Add a new Chamfer function
682 Handle(GEOM_Function) aFunction =
683 aChamfer->AddFunction(GEOMImpl_ChamferDriver::GetID(), CHAMFER_SHAPE_EDGE_AD);
684 if (aFunction.IsNull()) return NULL;
686 //Check if the function is set correctly
687 if (aFunction->GetDriverGUID() != GEOMImpl_ChamferDriver::GetID()) return NULL;
689 GEOMImpl_IChamfer aCI (aFunction);
691 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
692 if (aRefShape.IsNull()) return NULL;
694 aCI.SetShape(aRefShape);
696 aCI.SetAngle(theAngle);
697 aCI.SetFace1(theFace1);
698 aCI.SetFace2(theFace2);
700 //Compute the Chamfer value
702 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
705 if (!GetSolver()->ComputeFunction(aFunction)) {
706 SetErrorCode("Chamfer driver failed");
710 catch (Standard_Failure) {
711 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
712 SetErrorCode(aFail->GetMessageString());
716 //Make a Python command
717 GEOM::TPythonDump(aFunction) << aChamfer
718 << " = geompy.MakeChamferEdgeAD(" << theShape << ", " << theD
719 << ", " << theAngle << ", " << theFace1 << ", " << theFace2 << ")";
724 //=============================================================================
728 //=============================================================================
729 Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeChamferFaces
730 (Handle(GEOM_Object) theShape, double theD1, double theD2,
731 std::list<int> theFaces)
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_FACES);
741 if (aFunction.IsNull()) return NULL;
743 //Check if the function is set correctly
744 if (aFunction->GetDriverGUID() != GEOMImpl_ChamferDriver::GetID()) return NULL;
746 GEOMImpl_IChamfer aCI (aFunction);
748 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
749 if (aRefShape.IsNull()) return NULL;
751 aCI.SetShape(aRefShape);
754 int aLen = theFaces.size();
758 std::list<int>::iterator it = theFaces.begin();
759 for (; it != theFaces.end(); it++, ind++) {
760 aCI.SetFace(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.MakeChamferFaces(" << theShape
782 << ", " << theD1 << ", " << theD2 << ", [";
784 it = theFaces.begin();
786 while (it != theFaces.end()) {
787 pd << ", " << (*it++);
795 //=============================================================================
799 //=============================================================================
800 Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeChamferFacesAD
801 (Handle(GEOM_Object) theShape, double theD, double theAngle,
802 std::list<int> theFaces)
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_FACES_AD);
812 if (aFunction.IsNull()) return NULL;
814 //Check if the function is set correctly
815 if (aFunction->GetDriverGUID() != GEOMImpl_ChamferDriver::GetID()) return NULL;
817 GEOMImpl_IChamfer aCI (aFunction);
819 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
820 if (aRefShape.IsNull()) return NULL;
822 aCI.SetShape(aRefShape);
824 aCI.SetAngle(theAngle);
825 int aLen = theFaces.size();
829 std::list<int>::iterator it = theFaces.begin();
830 for (; it != theFaces.end(); it++, ind++) {
831 aCI.SetFace(ind, (*it));
834 //Compute the Chamfer value
836 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
839 if (!GetSolver()->ComputeFunction(aFunction)) {
840 SetErrorCode("Chamfer driver failed");
844 catch (Standard_Failure) {
845 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
846 SetErrorCode(aFail->GetMessageString());
850 //Make a Python command
851 GEOM::TPythonDump pd (aFunction);
852 pd << aChamfer << " = geompy.MakeChamferFacesAD(" << theShape
853 << ", " << theD << ", " << theAngle << ", [";
855 it = theFaces.begin();
857 while (it != theFaces.end()) {
858 pd << ", " << (*it++);
866 //=============================================================================
870 //=============================================================================
871 Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeChamferEdges
872 (Handle(GEOM_Object) theShape, double theD1, double theD2,
873 std::list<int> theEdges)
877 //Add a new Chamfer object
878 Handle(GEOM_Object) aChamfer = GetEngine()->AddObject(GetDocID(), GEOM_CHAMFER);
880 //Add a new Chamfer function
881 Handle(GEOM_Function) aFunction =
882 aChamfer->AddFunction(GEOMImpl_ChamferDriver::GetID(), CHAMFER_SHAPE_EDGES);
883 if (aFunction.IsNull()) { MESSAGE ( "Edges Function is NULL!!!" ); return NULL;}
885 //Check if the function is set correctly
886 if (aFunction->GetDriverGUID() != GEOMImpl_ChamferDriver::GetID())
887 { MESSAGE ( "Chamfer Driver is NULL!!!" ); return NULL; }
889 GEOMImpl_IChamfer aCI (aFunction);
891 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
892 if (aRefShape.IsNull()) { MESSAGE ("Shape is NULL!!!"); return NULL;}
894 aCI.SetShape(aRefShape);
897 int aLen = theEdges.size();
901 std::list<int>::iterator it = theEdges.begin();
902 for (; it != theEdges.end(); it++, ind++) {
903 aCI.SetEdge(ind, (*it));
906 //Compute the Chamfer value
908 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
911 if (!GetSolver()->ComputeFunction(aFunction)) {
912 SetErrorCode("Chamfer driver failed");
916 catch (Standard_Failure) {
917 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
918 SetErrorCode(aFail->GetMessageString());
922 //Make a Python command
923 GEOM::TPythonDump pd (aFunction);
924 pd << aChamfer << " = geompy.MakeChamferEdges(" << theShape
925 << ", " << theD1 << ", " << theD2 << ", [";
927 it = theEdges.begin();
929 while (it != theEdges.end()) {
930 pd << ", " << (*it++);
938 //=============================================================================
942 //=============================================================================
943 Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeChamferEdgesAD
944 (Handle(GEOM_Object) theShape, double theD, double theAngle,
945 std::list<int> theEdges)
949 //Add a new Chamfer object
950 Handle(GEOM_Object) aChamfer = GetEngine()->AddObject(GetDocID(), GEOM_CHAMFER);
952 //Add a new Chamfer function
953 Handle(GEOM_Function) aFunction =
954 aChamfer->AddFunction(GEOMImpl_ChamferDriver::GetID(), CHAMFER_SHAPE_EDGES_AD);
955 if (aFunction.IsNull()) { MESSAGE ( "Edges Function is NULL!!!" ); return NULL; }
957 //Check if the function is set correctly
958 if (aFunction->GetDriverGUID() != GEOMImpl_ChamferDriver::GetID())
959 { MESSAGE("Chamfer Driver is NULL!!!"); return NULL;}
961 GEOMImpl_IChamfer aCI (aFunction);
963 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
964 if (aRefShape.IsNull()) { MESSAGE ("Shape is NULL!!!"); return NULL;}
966 aCI.SetShape(aRefShape);
968 aCI.SetAngle(theAngle);
969 int aLen = theEdges.size();
973 std::list<int>::iterator it = theEdges.begin();
974 for (; it != theEdges.end(); it++, ind++) {
975 aCI.SetEdge(ind, (*it));
978 //Compute the Chamfer value
980 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
983 if (!GetSolver()->ComputeFunction(aFunction)) {
984 SetErrorCode("Chamfer driver failed");
988 catch (Standard_Failure) {
989 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
990 SetErrorCode(aFail->GetMessageString());
994 //Make a Python command
995 GEOM::TPythonDump pd (aFunction);
996 pd << aChamfer << " = geompy.MakeChamferEdgesAD(" << theShape
997 << ", " << theD << ", " << theAngle << ", [";
999 it = theEdges.begin();
1001 while (it != theEdges.end()) {
1002 pd << ", " << (*it++);
1010 //=============================================================================
1014 //=============================================================================
1015 Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeArchimede (Handle(GEOM_Object) theShape,
1017 double theWaterDensity,
1018 double theMeshingDeflection)
1022 //Add a new Archimede object
1023 Handle(GEOM_Object) aChamfer = GetEngine()->AddObject(GetDocID(), GEOM_ARCHIMEDE);
1025 //Add a new Archimede function
1026 Handle(GEOM_Function) aFunction = aChamfer->AddFunction(GEOMImpl_ArchimedeDriver::GetID(), ARCHIMEDE_TYPE);
1027 if (aFunction.IsNull()) return NULL;
1029 //Check if the function is set correctly
1030 if (aFunction->GetDriverGUID() != GEOMImpl_ArchimedeDriver::GetID()) return NULL;
1032 GEOMImpl_IArchimede aAI (aFunction);
1034 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
1035 if (aRefShape.IsNull()) return NULL;
1037 aAI.SetBasicShape(aRefShape);
1038 aAI.SetWeight(theWeight);
1039 aAI.SetDensity(theWaterDensity);
1040 aAI.SetDeflection(theMeshingDeflection);
1042 //Compute the Archimede value
1044 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1047 if (!GetSolver()->ComputeFunction(aFunction)) {
1048 SetErrorCode("Archimede driver failed");
1052 catch (Standard_Failure) {
1053 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1054 SetErrorCode(aFail->GetMessageString());
1058 //Make a Python command
1059 GEOM::TPythonDump(aFunction) << aChamfer
1060 << " = geompy.Archimede(" << theShape << ", " << theWeight << ", "
1061 << theWaterDensity << ", " << theMeshingDeflection << ")";
1067 //=============================================================================
1071 //=============================================================================
1072 bool GEOMImpl_ILocalOperations::GetSubShape (const TopoDS_Shape& theShape, const int theIndex,
1073 TopoDS_Shape& theSubShape)
1075 if (theShape.IsNull() || theIndex < 1)
1078 TopTools_IndexedMapOfShape anIndices;
1079 TopExp::MapShapes(theShape, anIndices);
1080 if (theIndex > anIndices.Extent()) return false;
1081 theSubShape = anIndices.FindKey(theIndex);
1086 //=============================================================================
1090 //=============================================================================
1091 Standard_Integer GEOMImpl_ILocalOperations::GetSubShapeIndex (Handle(GEOM_Object) theShape,
1092 Handle(GEOM_Object) theSubShape)
1096 Standard_Integer anInd = -1;
1097 GEOM_Engine* anEngine = GetEngine();
1098 //GEOMImpl_Gen* aGen = dynamic_cast<GEOMImpl_Gen*>(anEngine);
1099 GEOMImpl_Gen* aGen = (GEOMImpl_Gen*)anEngine;
1102 GEOMImpl_IShapesOperations* anIShapesOperations =
1103 aGen->GetIShapesOperations(GetDocID());
1104 anInd = anIShapesOperations->GetSubShapeIndex(theShape, theSubShape);
1105 SetErrorCode(anIShapesOperations->GetErrorCode());