1 // Copyright (C) 2007-2014 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, or (at your option) any later version.
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 <GEOMImpl_Types.hxx>
29 #include <GEOMImpl_FilletDriver.hxx>
30 #include <GEOMImpl_Fillet1dDriver.hxx>
31 #include <GEOMImpl_Fillet2dDriver.hxx>
32 #include <GEOMImpl_ChamferDriver.hxx>
34 #include <GEOMImpl_IFillet.hxx>
35 #include <GEOMImpl_IFillet1d.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 <GEOM_Function.hxx>
46 #include <GEOM_PythonDump.hxx>
48 #include <Basics_OCCTVersion.hxx>
50 #include "utilities.h"
52 #include <Utils_ExceptHandlers.hxx>
54 #include <TFunction_DriverTable.hxx>
55 #include <TFunction_Driver.hxx>
56 #include <TFunction_Logbook.hxx>
57 #include <TDF_Tool.hxx>
60 #include <TopoDS_TShape.hxx>
61 #include <TopTools_IndexedMapOfShape.hxx>
63 #include <Standard_Failure.hxx>
64 #include <Standard_ErrorHandler.hxx> // CAREFUL ! position of this file is critic : see Lucien PIGNOLONI / OCC
66 //=============================================================================
70 //=============================================================================
71 GEOMImpl_ILocalOperations::GEOMImpl_ILocalOperations (GEOM_Engine* theEngine, int theDocID)
72 : GEOM_IOperations(theEngine, theDocID)
74 MESSAGE("GEOMImpl_ILocalOperations::GEOMImpl_ILocalOperations");
77 //=============================================================================
81 //=============================================================================
82 GEOMImpl_ILocalOperations::~GEOMImpl_ILocalOperations()
84 MESSAGE("GEOMImpl_ILocalOperations::~GEOMImpl_ILocalOperations");
88 //=============================================================================
92 //=============================================================================
93 Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeFilletAll
94 (Handle(GEOM_Object) theShape, double theR)
98 //Add a new Fillet object
99 Handle(GEOM_Object) aFillet = GetEngine()->AddObject(GetDocID(), GEOM_FILLET);
101 //Add a new Fillet function
102 Handle(GEOM_Function) aFunction =
103 aFillet->AddFunction(GEOMImpl_FilletDriver::GetID(), FILLET_SHAPE_ALL);
104 if (aFunction.IsNull()) return NULL;
106 //Check if the function is set correctly
107 if (aFunction->GetDriverGUID() != GEOMImpl_FilletDriver::GetID()) return NULL;
109 GEOMImpl_IFillet aCI (aFunction);
111 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
112 if (aRefShape.IsNull()) return NULL;
114 aCI.SetShape(aRefShape);
117 //Compute the Fillet value
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
179 if (!GetSolver()->ComputeFunction(aFunction)) {
180 SetErrorCode("Fillet driver failed");
184 catch (Standard_Failure) {
185 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
186 SetErrorCode(aFail->GetMessageString());
190 //Make a Python command
191 GEOM::TPythonDump pd (aFunction);
192 pd << aFillet << " = geompy.MakeFillet(" << theShape
193 << ", " << theR << ", geompy.ShapeType[\"EDGE\"], [";
195 it = theEdges.begin();
197 while (it != theEdges.end()) {
198 pd << ", " << (*it++);
206 //=============================================================================
208 * MakeFilletEdges R1 R2
210 //=============================================================================
211 Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeFilletEdgesR1R2
212 (Handle(GEOM_Object) theShape, double theR1, double theR2, std::list<int> theEdges)
216 //Add a new Fillet object
217 Handle(GEOM_Object) aFillet = GetEngine()->AddObject(GetDocID(), GEOM_FILLET);
219 //Add a new Fillet function
220 Handle(GEOM_Function) aFunction =
221 aFillet->AddFunction(GEOMImpl_FilletDriver::GetID(), FILLET_SHAPE_EDGES_2R);
222 if (aFunction.IsNull()) return NULL;
224 //Check if the function is set correctly
225 if (aFunction->GetDriverGUID() != GEOMImpl_FilletDriver::GetID()) return NULL;
227 GEOMImpl_IFillet aCI (aFunction);
229 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
230 if (aRefShape.IsNull()) return NULL;
232 aCI.SetShape(aRefShape);
235 int aLen = theEdges.size();
239 std::list<int>::iterator it = theEdges.begin();
240 for (; it != theEdges.end(); it++, ind++) {
241 aCI.SetEdge(ind, (*it));
244 //Compute the Fillet value
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, std::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 std::list<int>::iterator it = theFaces.begin();
308 for (; it != theFaces.end(); it++, ind++) {
309 aCI.SetFace(ind, (*it));
312 //Compute the Fillet value
315 if (!GetSolver()->ComputeFunction(aFunction)) {
316 SetErrorCode("Fillet driver failed");
320 catch (Standard_Failure) {
321 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
322 SetErrorCode(aFail->GetMessageString());
326 //Make a Python command
327 GEOM::TPythonDump pd (aFunction);
328 pd << aFillet << " = geompy.MakeFillet(" << theShape
329 << ", " << theR << ", geompy.ShapeType[\"FACE\"], [";
331 it = theFaces.begin();
333 while (it != theFaces.end()) {
334 pd << ", " << (*it++);
342 //=============================================================================
344 * MakeFilletFaces R1 R2
346 //=============================================================================
347 Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeFilletFacesR1R2
348 (Handle(GEOM_Object) theShape, double theR1, double theR2, std::list<int> theFaces)
352 //Add a new Fillet object
353 Handle(GEOM_Object) aFillet = GetEngine()->AddObject(GetDocID(), GEOM_FILLET);
355 //Add a new Fillet function
356 Handle(GEOM_Function) aFunction =
357 aFillet->AddFunction(GEOMImpl_FilletDriver::GetID(), FILLET_SHAPE_FACES_2R);
358 if (aFunction.IsNull()) return NULL;
360 //Check if the function is set correctly
361 if (aFunction->GetDriverGUID() != GEOMImpl_FilletDriver::GetID()) return NULL;
363 GEOMImpl_IFillet aCI (aFunction);
365 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
366 if (aRefShape.IsNull()) return NULL;
368 aCI.SetShape(aRefShape);
371 int aLen = theFaces.size();
375 std::list<int>::iterator it = theFaces.begin();
376 for (; it != theFaces.end(); it++, ind++) {
377 aCI.SetFace(ind, (*it));
380 //Compute the Fillet value
383 if (!GetSolver()->ComputeFunction(aFunction)) {
384 SetErrorCode("Fillet driver failed");
388 catch (Standard_Failure) {
389 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
390 SetErrorCode(aFail->GetMessageString());
394 //Make a Python command
395 GEOM::TPythonDump pd (aFunction);
396 pd << aFillet << " = geompy.MakeFilletR1R2(" << theShape
397 << ", " << theR1 << ", " << theR2 << ", geompy.ShapeType[\"FACE\"], [";
399 it = theFaces.begin();
401 while (it != theFaces.end()) {
402 pd << ", " << (*it++);
410 //=============================================================================
414 //=============================================================================
415 Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeFillet2D
416 (Handle(GEOM_Object) theShape, double theR, std::list<int> theVertexes)
420 //Add a new Fillet object
421 Handle(GEOM_Object) aFillet2D = GetEngine()->AddObject(GetDocID(), GEOM_FILLET_2D);
423 //Add a new Fillet function
424 Handle(GEOM_Function) aFunction =
425 aFillet2D->AddFunction(GEOMImpl_Fillet2dDriver::GetID(), FILLET_2D_SHAPE_VERTEXES);
426 if (aFunction.IsNull()) return NULL;
428 //Check if the function is set correctly
429 if (aFunction->GetDriverGUID() != GEOMImpl_Fillet2dDriver::GetID()) return NULL;
431 GEOMImpl_IFillet2d aCI (aFunction);
433 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
434 if (aRefShape.IsNull()) return NULL;
436 aCI.SetShape(aRefShape);
438 int aLen = theVertexes.size();
442 std::list<int>::iterator it = theVertexes.begin();
443 for (; it != theVertexes.end(); it++, ind++) {
444 aCI.SetVertex(ind, (*it));
447 //Compute the Fillet value
450 if (!GetSolver()->ComputeFunction(aFunction)) {
451 SetErrorCode("2D Fillet driver failed");
455 catch (Standard_Failure) {
456 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
457 SetErrorCode(aFail->GetMessageString());
461 //Make a Python command
462 GEOM::TPythonDump pd (aFunction);
463 pd << aFillet2D << " = geompy.MakeFillet2D(" << theShape
464 << ", " << theR << ", [";
466 it = theVertexes.begin();
468 while (it != theVertexes.end()) {
469 pd << ", " << (*it++);
477 //=============================================================================
481 //=============================================================================
482 Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeFillet1D
483 (Handle(GEOM_Object) theShape, double theR,
484 std::list<int> theVertexes, bool doIgnoreSecantVertices)
488 //Add a new Fillet object
489 Handle(GEOM_Object) aFillet1D = GetEngine()->AddObject(GetDocID(), GEOM_FILLET_1D);
491 //Add a new Fillet function
492 Handle(GEOM_Function) aFunction =
493 aFillet1D->AddFunction(GEOMImpl_Fillet1dDriver::GetID(), FILLET_1D_SHAPE_VERTEXES);
494 if (aFunction.IsNull()) return NULL;
496 //Check if the function is set correctly
497 if (aFunction->GetDriverGUID() != GEOMImpl_Fillet1dDriver::GetID()) return NULL;
499 GEOMImpl_IFillet1d aCI (aFunction);
501 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
502 if (aRefShape.IsNull()) return NULL;
504 aCI.SetShape(aRefShape);
506 aCI.SetFlag(doIgnoreSecantVertices);
507 int aLen = theVertexes.size();
511 std::list<int>::iterator it = theVertexes.begin();
512 for (; it != theVertexes.end(); it++, ind++) {
513 aCI.SetVertex(ind, (*it));
516 //Compute the Fillet value
519 if (!GetSolver()->ComputeFunction(aFunction)) {
520 SetErrorCode("1D Fillet driver failed");
524 catch (Standard_Failure) {
525 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
526 SetErrorCode(aFail->GetMessageString());
530 //Make a Python command
531 GEOM::TPythonDump pd (aFunction);
532 pd << aFillet1D << " = geompy.MakeFillet1D(" << theShape
533 << ", " << theR << ", [";
535 it = theVertexes.begin();
536 if (it != theVertexes.end()) {
538 while (it != theVertexes.end())
539 pd << ", " << (*it++);
547 //=============================================================================
551 //=============================================================================
552 Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeChamferAll (Handle(GEOM_Object) theShape, double theD)
556 //Add a new Chamfer object
557 Handle(GEOM_Object) aChamfer = GetEngine()->AddObject(GetDocID(), GEOM_CHAMFER);
559 //Add a new Chamfer function
560 Handle(GEOM_Function) aFunction =
561 aChamfer->AddFunction(GEOMImpl_ChamferDriver::GetID(), CHAMFER_SHAPE_ALL);
562 if (aFunction.IsNull()) return NULL;
564 //Check if the function is set correctly
565 if (aFunction->GetDriverGUID() != GEOMImpl_ChamferDriver::GetID()) return NULL;
567 GEOMImpl_IChamfer aCI (aFunction);
569 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
570 if (aRefShape.IsNull()) return NULL;
572 aCI.SetShape(aRefShape);
575 //Compute the Chamfer value
578 if (!GetSolver()->ComputeFunction(aFunction)) {
579 SetErrorCode("Chamfer driver failed");
583 catch (Standard_Failure) {
584 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
585 SetErrorCode(aFail->GetMessageString());
589 //Make a Python command
590 GEOM::TPythonDump(aFunction) << aChamfer << " = geompy.MakeChamferAll("
591 << theShape << ", " << theD << ")";
597 //=============================================================================
601 //=============================================================================
602 Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeChamferEdge
603 (Handle(GEOM_Object) theShape, double theD1, double theD2,
604 int theFace1, int theFace2)
608 //Add a new Chamfer object
609 Handle(GEOM_Object) aChamfer = GetEngine()->AddObject(GetDocID(), GEOM_CHAMFER);
611 //Add a new Chamfer function
612 Handle(GEOM_Function) aFunction =
613 aChamfer->AddFunction(GEOMImpl_ChamferDriver::GetID(), CHAMFER_SHAPE_EDGE);
614 if (aFunction.IsNull()) return NULL;
616 //Check if the function is set correctly
617 if (aFunction->GetDriverGUID() != GEOMImpl_ChamferDriver::GetID()) return NULL;
619 GEOMImpl_IChamfer aCI (aFunction);
621 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
622 if (aRefShape.IsNull()) return NULL;
624 aCI.SetShape(aRefShape);
627 aCI.SetFace1(theFace1);
628 aCI.SetFace2(theFace2);
630 //Compute the Chamfer value
633 if (!GetSolver()->ComputeFunction(aFunction)) {
634 SetErrorCode("Chamfer driver failed");
638 catch (Standard_Failure) {
639 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
640 SetErrorCode(aFail->GetMessageString());
644 //Make a Python command
645 GEOM::TPythonDump(aFunction) << aChamfer
646 << " = geompy.MakeChamferEdge(" << theShape << ", " << theD1
647 << ", " << theD2 << ", " << theFace1 << ", " << theFace2 << ")";
653 //=============================================================================
657 //=============================================================================
658 Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeChamferEdgeAD
659 (Handle(GEOM_Object) theShape, double theD, double theAngle,
660 int theFace1, int theFace2)
664 //Add a new Chamfer object
665 Handle(GEOM_Object) aChamfer = GetEngine()->AddObject(GetDocID(), GEOM_CHAMFER);
667 //Add a new Chamfer function
668 Handle(GEOM_Function) aFunction =
669 aChamfer->AddFunction(GEOMImpl_ChamferDriver::GetID(), CHAMFER_SHAPE_EDGE_AD);
670 if (aFunction.IsNull()) return NULL;
672 //Check if the function is set correctly
673 if (aFunction->GetDriverGUID() != GEOMImpl_ChamferDriver::GetID()) return NULL;
675 GEOMImpl_IChamfer aCI (aFunction);
677 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
678 if (aRefShape.IsNull()) return NULL;
680 aCI.SetShape(aRefShape);
682 aCI.SetAngle(theAngle);
683 aCI.SetFace1(theFace1);
684 aCI.SetFace2(theFace2);
686 //Compute the Chamfer value
689 if (!GetSolver()->ComputeFunction(aFunction)) {
690 SetErrorCode("Chamfer driver failed");
694 catch (Standard_Failure) {
695 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
696 SetErrorCode(aFail->GetMessageString());
700 //Make a Python command
701 GEOM::TPythonDump(aFunction) << aChamfer
702 << " = geompy.MakeChamferEdgeAD(" << theShape << ", " << theD
703 << ", " << theAngle << ", " << theFace1 << ", " << theFace2 << ")";
708 //=============================================================================
712 //=============================================================================
713 Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeChamferFaces
714 (Handle(GEOM_Object) theShape, double theD1, double theD2,
715 std::list<int> theFaces)
719 //Add a new Chamfer object
720 Handle(GEOM_Object) aChamfer = GetEngine()->AddObject(GetDocID(), GEOM_CHAMFER);
722 //Add a new Chamfer function
723 Handle(GEOM_Function) aFunction =
724 aChamfer->AddFunction(GEOMImpl_ChamferDriver::GetID(), CHAMFER_SHAPE_FACES);
725 if (aFunction.IsNull()) return NULL;
727 //Check if the function is set correctly
728 if (aFunction->GetDriverGUID() != GEOMImpl_ChamferDriver::GetID()) return NULL;
730 GEOMImpl_IChamfer aCI (aFunction);
732 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
733 if (aRefShape.IsNull()) return NULL;
735 aCI.SetShape(aRefShape);
738 int aLen = theFaces.size();
742 std::list<int>::iterator it = theFaces.begin();
743 for (; it != theFaces.end(); it++, ind++) {
744 aCI.SetFace(ind, (*it));
747 //Compute the Chamfer value
750 if (!GetSolver()->ComputeFunction(aFunction)) {
751 SetErrorCode("Chamfer driver failed");
755 catch (Standard_Failure) {
756 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
757 SetErrorCode(aFail->GetMessageString());
761 //Make a Python command
762 GEOM::TPythonDump pd (aFunction);
763 pd << aChamfer << " = geompy.MakeChamferFaces(" << theShape
764 << ", " << theD1 << ", " << theD2 << ", [";
766 it = theFaces.begin();
768 while (it != theFaces.end()) {
769 pd << ", " << (*it++);
777 //=============================================================================
781 //=============================================================================
782 Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeChamferFacesAD
783 (Handle(GEOM_Object) theShape, double theD, double theAngle,
784 std::list<int> theFaces)
788 //Add a new Chamfer object
789 Handle(GEOM_Object) aChamfer = GetEngine()->AddObject(GetDocID(), GEOM_CHAMFER);
791 //Add a new Chamfer function
792 Handle(GEOM_Function) aFunction =
793 aChamfer->AddFunction(GEOMImpl_ChamferDriver::GetID(), CHAMFER_SHAPE_FACES_AD);
794 if (aFunction.IsNull()) return NULL;
796 //Check if the function is set correctly
797 if (aFunction->GetDriverGUID() != GEOMImpl_ChamferDriver::GetID()) return NULL;
799 GEOMImpl_IChamfer aCI (aFunction);
801 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
802 if (aRefShape.IsNull()) return NULL;
804 aCI.SetShape(aRefShape);
806 aCI.SetAngle(theAngle);
807 int aLen = theFaces.size();
811 std::list<int>::iterator it = theFaces.begin();
812 for (; it != theFaces.end(); it++, ind++) {
813 aCI.SetFace(ind, (*it));
816 //Compute the Chamfer value
819 if (!GetSolver()->ComputeFunction(aFunction)) {
820 SetErrorCode("Chamfer driver failed");
824 catch (Standard_Failure) {
825 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
826 SetErrorCode(aFail->GetMessageString());
830 //Make a Python command
831 GEOM::TPythonDump pd (aFunction);
832 pd << aChamfer << " = geompy.MakeChamferFacesAD(" << theShape
833 << ", " << theD << ", " << theAngle << ", [";
835 it = theFaces.begin();
837 while (it != theFaces.end()) {
838 pd << ", " << (*it++);
846 //=============================================================================
850 //=============================================================================
851 Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeChamferEdges
852 (Handle(GEOM_Object) theShape, double theD1, double theD2,
853 std::list<int> theEdges)
857 //Add a new Chamfer object
858 Handle(GEOM_Object) aChamfer = GetEngine()->AddObject(GetDocID(), GEOM_CHAMFER);
860 //Add a new Chamfer function
861 Handle(GEOM_Function) aFunction =
862 aChamfer->AddFunction(GEOMImpl_ChamferDriver::GetID(), CHAMFER_SHAPE_EDGES);
863 if (aFunction.IsNull()) { MESSAGE ( "Edges Function is NULL!!!" ); return NULL;}
865 //Check if the function is set correctly
866 if (aFunction->GetDriverGUID() != GEOMImpl_ChamferDriver::GetID())
867 { MESSAGE ( "Chamfer Driver is NULL!!!" ); return NULL; }
869 GEOMImpl_IChamfer aCI (aFunction);
871 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
872 if (aRefShape.IsNull()) { MESSAGE ("Shape is NULL!!!"); return NULL;}
874 aCI.SetShape(aRefShape);
877 int aLen = theEdges.size();
881 std::list<int>::iterator it = theEdges.begin();
882 for (; it != theEdges.end(); it++, ind++) {
883 aCI.SetEdge(ind, (*it));
886 //Compute the Chamfer value
889 if (!GetSolver()->ComputeFunction(aFunction)) {
890 SetErrorCode("Chamfer driver failed");
894 catch (Standard_Failure) {
895 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
896 SetErrorCode(aFail->GetMessageString());
900 //Make a Python command
901 GEOM::TPythonDump pd (aFunction);
902 pd << aChamfer << " = geompy.MakeChamferEdges(" << theShape
903 << ", " << theD1 << ", " << theD2 << ", [";
905 it = theEdges.begin();
907 while (it != theEdges.end()) {
908 pd << ", " << (*it++);
916 //=============================================================================
920 //=============================================================================
921 Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeChamferEdgesAD
922 (Handle(GEOM_Object) theShape, double theD, double theAngle,
923 std::list<int> theEdges)
927 //Add a new Chamfer object
928 Handle(GEOM_Object) aChamfer = GetEngine()->AddObject(GetDocID(), GEOM_CHAMFER);
930 //Add a new Chamfer function
931 Handle(GEOM_Function) aFunction =
932 aChamfer->AddFunction(GEOMImpl_ChamferDriver::GetID(), CHAMFER_SHAPE_EDGES_AD);
933 if (aFunction.IsNull()) { MESSAGE ( "Edges Function is NULL!!!" ); return NULL; }
935 //Check if the function is set correctly
936 if (aFunction->GetDriverGUID() != GEOMImpl_ChamferDriver::GetID())
937 { MESSAGE("Chamfer Driver is NULL!!!"); return NULL;}
939 GEOMImpl_IChamfer aCI (aFunction);
941 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
942 if (aRefShape.IsNull()) { MESSAGE ("Shape is NULL!!!"); return NULL;}
944 aCI.SetShape(aRefShape);
946 aCI.SetAngle(theAngle);
947 int aLen = theEdges.size();
951 std::list<int>::iterator it = theEdges.begin();
952 for (; it != theEdges.end(); it++, ind++) {
953 aCI.SetEdge(ind, (*it));
956 //Compute the Chamfer value
959 if (!GetSolver()->ComputeFunction(aFunction)) {
960 SetErrorCode("Chamfer driver failed");
964 catch (Standard_Failure) {
965 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
966 SetErrorCode(aFail->GetMessageString());
970 //Make a Python command
971 GEOM::TPythonDump pd (aFunction);
972 pd << aChamfer << " = geompy.MakeChamferEdgesAD(" << theShape
973 << ", " << theD << ", " << theAngle << ", [";
975 it = theEdges.begin();
977 while (it != theEdges.end()) {
978 pd << ", " << (*it++);
986 //=============================================================================
990 //=============================================================================
991 Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeArchimede (Handle(GEOM_Object) theShape,
993 double theWaterDensity,
994 double theMeshingDeflection)
998 //Add a new Archimede object
999 Handle(GEOM_Object) aChamfer = GetEngine()->AddObject(GetDocID(), GEOM_ARCHIMEDE);
1001 //Add a new Archimede function
1002 Handle(GEOM_Function) aFunction = aChamfer->AddFunction(GEOMImpl_ArchimedeDriver::GetID(), ARCHIMEDE_TYPE);
1003 if (aFunction.IsNull()) return NULL;
1005 //Check if the function is set correctly
1006 if (aFunction->GetDriverGUID() != GEOMImpl_ArchimedeDriver::GetID()) return NULL;
1008 GEOMImpl_IArchimede aAI (aFunction);
1010 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
1011 if (aRefShape.IsNull()) return NULL;
1013 aAI.SetBasicShape(aRefShape);
1014 aAI.SetWeight(theWeight);
1015 aAI.SetDensity(theWaterDensity);
1016 aAI.SetDeflection(theMeshingDeflection);
1018 //Compute the Archimede value
1021 if (!GetSolver()->ComputeFunction(aFunction)) {
1022 SetErrorCode("Archimede driver failed");
1026 catch (Standard_Failure) {
1027 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1028 SetErrorCode(aFail->GetMessageString());
1032 //Make a Python command
1033 GEOM::TPythonDump(aFunction) << aChamfer
1034 << " = geompy.Archimede(" << theShape << ", " << theWeight << ", "
1035 << theWaterDensity << ", " << theMeshingDeflection << ")";
1041 //=============================================================================
1045 //=============================================================================
1046 bool GEOMImpl_ILocalOperations::GetSubShape (const TopoDS_Shape& theShape, const int theIndex,
1047 TopoDS_Shape& theSubShape)
1049 if (theShape.IsNull() || theIndex < 1)
1052 TopTools_IndexedMapOfShape anIndices;
1053 TopExp::MapShapes(theShape, anIndices);
1054 if (theIndex > anIndices.Extent()) return false;
1055 theSubShape = anIndices.FindKey(theIndex);
1060 //=============================================================================
1064 //=============================================================================
1065 Standard_Integer GEOMImpl_ILocalOperations::GetSubShapeIndex (Handle(GEOM_Object) theShape,
1066 Handle(GEOM_Object) theSubShape)
1070 Standard_Integer anInd = -1;
1071 GEOM_Engine* anEngine = GetEngine();
1072 //GEOMImpl_Gen* aGen = dynamic_cast<GEOMImpl_Gen*>(anEngine);
1073 GEOMImpl_Gen* aGen = (GEOMImpl_Gen*)anEngine;
1076 GEOMImpl_IShapesOperations* anIShapesOperations =
1077 aGen->GetIShapesOperations(GetDocID());
1078 anInd = anIShapesOperations->GetSubShapeIndex(theShape, theSubShape);
1079 SetErrorCode(anIShapesOperations->GetErrorCode());