1 // Copyright (C) 2007-2012 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 <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
119 #if OCC_VERSION_LARGE > 0x06010000
122 if (!GetSolver()->ComputeFunction(aFunction)) {
123 SetErrorCode("Fillet driver failed");
127 catch (Standard_Failure) {
128 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
129 SetErrorCode(aFail->GetMessageString());
133 //Make a Python command
134 GEOM::TPythonDump(aFunction) << aFillet << " = geompy.MakeFilletAll("
135 << theShape << ", " << theR << ")";
141 //=============================================================================
145 //=============================================================================
146 Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeFilletEdges
147 (Handle(GEOM_Object) theShape, double theR, std::list<int> theEdges)
151 //Add a new Fillet object
152 Handle(GEOM_Object) aFillet = GetEngine()->AddObject(GetDocID(), GEOM_FILLET);
154 //Add a new Fillet function
155 Handle(GEOM_Function) aFunction =
156 aFillet->AddFunction(GEOMImpl_FilletDriver::GetID(), FILLET_SHAPE_EDGES);
157 if (aFunction.IsNull()) return NULL;
159 //Check if the function is set correctly
160 if (aFunction->GetDriverGUID() != GEOMImpl_FilletDriver::GetID()) return NULL;
162 GEOMImpl_IFillet aCI (aFunction);
164 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
165 if (aRefShape.IsNull()) return NULL;
167 aCI.SetShape(aRefShape);
169 int aLen = theEdges.size();
173 std::list<int>::iterator it = theEdges.begin();
174 for (; it != theEdges.end(); it++, ind++) {
175 aCI.SetEdge(ind, (*it));
178 //Compute the Fillet value
180 #if OCC_VERSION_LARGE > 0x06010000
183 if (!GetSolver()->ComputeFunction(aFunction)) {
184 SetErrorCode("Fillet driver failed");
188 catch (Standard_Failure) {
189 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
190 SetErrorCode(aFail->GetMessageString());
194 //Make a Python command
195 GEOM::TPythonDump pd (aFunction);
196 pd << aFillet << " = geompy.MakeFillet(" << theShape
197 << ", " << theR << ", geompy.ShapeType[\"EDGE\"], [";
199 it = theEdges.begin();
201 while (it != theEdges.end()) {
202 pd << ", " << (*it++);
210 //=============================================================================
212 * MakeFilletEdges R1 R2
214 //=============================================================================
215 Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeFilletEdgesR1R2
216 (Handle(GEOM_Object) theShape, double theR1, double theR2, std::list<int> theEdges)
220 //Add a new Fillet object
221 Handle(GEOM_Object) aFillet = GetEngine()->AddObject(GetDocID(), GEOM_FILLET);
223 //Add a new Fillet function
224 Handle(GEOM_Function) aFunction =
225 aFillet->AddFunction(GEOMImpl_FilletDriver::GetID(), FILLET_SHAPE_EDGES_2R);
226 if (aFunction.IsNull()) return NULL;
228 //Check if the function is set correctly
229 if (aFunction->GetDriverGUID() != GEOMImpl_FilletDriver::GetID()) return NULL;
231 GEOMImpl_IFillet aCI (aFunction);
233 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
234 if (aRefShape.IsNull()) return NULL;
236 aCI.SetShape(aRefShape);
239 int aLen = theEdges.size();
243 std::list<int>::iterator it = theEdges.begin();
244 for (; it != theEdges.end(); it++, ind++) {
245 aCI.SetEdge(ind, (*it));
248 //Compute the Fillet value
250 #if OCC_VERSION_LARGE > 0x06010000
253 if (!GetSolver()->ComputeFunction(aFunction)) {
254 SetErrorCode("Fillet driver failed");
258 catch (Standard_Failure) {
259 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
260 SetErrorCode(aFail->GetMessageString());
264 //Make a Python command
265 GEOM::TPythonDump pd (aFunction);
266 pd << aFillet << " = geompy.MakeFilletR1R2(" << theShape
267 << ", " << theR1 << ", " <<theR2 << ", geompy.ShapeType[\"EDGE\"], [";
269 it = theEdges.begin();
271 while (it != theEdges.end()) {
272 pd << ", " << (*it++);
281 //=============================================================================
285 //=============================================================================
286 Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeFilletFaces
287 (Handle(GEOM_Object) theShape, double theR, std::list<int> theFaces)
291 //Add a new Fillet object
292 Handle(GEOM_Object) aFillet = GetEngine()->AddObject(GetDocID(), GEOM_FILLET);
294 //Add a new Fillet function
295 Handle(GEOM_Function) aFunction =
296 aFillet->AddFunction(GEOMImpl_FilletDriver::GetID(), FILLET_SHAPE_FACES);
297 if (aFunction.IsNull()) return NULL;
299 //Check if the function is set correctly
300 if (aFunction->GetDriverGUID() != GEOMImpl_FilletDriver::GetID()) return NULL;
302 GEOMImpl_IFillet aCI (aFunction);
304 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
305 if (aRefShape.IsNull()) return NULL;
307 aCI.SetShape(aRefShape);
309 int aLen = theFaces.size();
313 std::list<int>::iterator it = theFaces.begin();
314 for (; it != theFaces.end(); it++, ind++) {
315 aCI.SetFace(ind, (*it));
318 //Compute the Fillet value
320 #if OCC_VERSION_LARGE > 0x06010000
323 if (!GetSolver()->ComputeFunction(aFunction)) {
324 SetErrorCode("Fillet driver failed");
328 catch (Standard_Failure) {
329 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
330 SetErrorCode(aFail->GetMessageString());
334 //Make a Python command
335 GEOM::TPythonDump pd (aFunction);
336 pd << aFillet << " = geompy.MakeFillet(" << theShape
337 << ", " << theR << ", geompy.ShapeType[\"FACE\"], [";
339 it = theFaces.begin();
341 while (it != theFaces.end()) {
342 pd << ", " << (*it++);
350 //=============================================================================
352 * MakeFilletFaces R1 R2
354 //=============================================================================
355 Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeFilletFacesR1R2
356 (Handle(GEOM_Object) theShape, double theR1, double theR2, std::list<int> theFaces)
360 //Add a new Fillet object
361 Handle(GEOM_Object) aFillet = GetEngine()->AddObject(GetDocID(), GEOM_FILLET);
363 //Add a new Fillet function
364 Handle(GEOM_Function) aFunction =
365 aFillet->AddFunction(GEOMImpl_FilletDriver::GetID(), FILLET_SHAPE_FACES_2R);
366 if (aFunction.IsNull()) return NULL;
368 //Check if the function is set correctly
369 if (aFunction->GetDriverGUID() != GEOMImpl_FilletDriver::GetID()) return NULL;
371 GEOMImpl_IFillet aCI (aFunction);
373 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
374 if (aRefShape.IsNull()) return NULL;
376 aCI.SetShape(aRefShape);
379 int aLen = theFaces.size();
383 std::list<int>::iterator it = theFaces.begin();
384 for (; it != theFaces.end(); it++, ind++) {
385 aCI.SetFace(ind, (*it));
388 //Compute the Fillet value
390 #if OCC_VERSION_LARGE > 0x06010000
393 if (!GetSolver()->ComputeFunction(aFunction)) {
394 SetErrorCode("Fillet driver failed");
398 catch (Standard_Failure) {
399 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
400 SetErrorCode(aFail->GetMessageString());
404 //Make a Python command
405 GEOM::TPythonDump pd (aFunction);
406 pd << aFillet << " = geompy.MakeFilletR1R2(" << theShape
407 << ", " << theR1 << ", " << theR2 << ", geompy.ShapeType[\"FACE\"], [";
409 it = theFaces.begin();
411 while (it != theFaces.end()) {
412 pd << ", " << (*it++);
420 //=============================================================================
424 //=============================================================================
425 Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeFillet2D
426 (Handle(GEOM_Object) theShape, double theR, std::list<int> theVertexes)
430 //Add a new Fillet object
431 Handle(GEOM_Object) aFillet2D = GetEngine()->AddObject(GetDocID(), GEOM_FILLET_2D);
433 //Add a new Fillet function
434 Handle(GEOM_Function) aFunction =
435 aFillet2D->AddFunction(GEOMImpl_Fillet2dDriver::GetID(), FILLET_2D_SHAPE_VERTEXES);
436 if (aFunction.IsNull()) return NULL;
438 //Check if the function is set correctly
439 if (aFunction->GetDriverGUID() != GEOMImpl_Fillet2dDriver::GetID()) return NULL;
441 GEOMImpl_IFillet2d aCI (aFunction);
443 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
444 if (aRefShape.IsNull()) return NULL;
446 aCI.SetShape(aRefShape);
448 int aLen = theVertexes.size();
452 std::list<int>::iterator it = theVertexes.begin();
453 for (; it != theVertexes.end(); it++, ind++) {
454 aCI.SetVertex(ind, (*it));
457 //Compute the Fillet value
459 #if OCC_VERSION_LARGE > 0x06010000
462 if (!GetSolver()->ComputeFunction(aFunction)) {
463 SetErrorCode("2D Fillet driver failed");
467 catch (Standard_Failure) {
468 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
469 SetErrorCode(aFail->GetMessageString());
473 //Make a Python command
474 GEOM::TPythonDump pd (aFunction);
475 pd << aFillet2D << " = geompy.MakeFillet2D(" << theShape
476 << ", " << theR << ", [";
478 it = theVertexes.begin();
480 while (it != theVertexes.end()) {
481 pd << ", " << (*it++);
489 //=============================================================================
493 //=============================================================================
494 Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeFillet1D
495 (Handle(GEOM_Object) theShape, double theR, std::list<int> theVertexes)
499 //Add a new Fillet object
500 Handle(GEOM_Object) aFillet1D = GetEngine()->AddObject(GetDocID(), GEOM_FILLET_1D);
502 //Add a new Fillet function
503 Handle(GEOM_Function) aFunction =
504 aFillet1D->AddFunction(GEOMImpl_Fillet1dDriver::GetID(), FILLET_1D_SHAPE_VERTEXES);
505 if (aFunction.IsNull()) return NULL;
507 //Check if the function is set correctly
508 if (aFunction->GetDriverGUID() != GEOMImpl_Fillet1dDriver::GetID()) return NULL;
510 GEOMImpl_IFillet1d aCI (aFunction);
512 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
513 if (aRefShape.IsNull()) return NULL;
515 aCI.SetShape(aRefShape);
517 int aLen = theVertexes.size();
521 std::list<int>::iterator it = theVertexes.begin();
522 for (; it != theVertexes.end(); it++, ind++) {
523 aCI.SetVertex(ind, (*it));
526 //Compute the Fillet value
528 #if OCC_VERSION_LARGE > 0x06010000
531 if (!GetSolver()->ComputeFunction(aFunction)) {
532 SetErrorCode("1D Fillet driver failed");
536 catch (Standard_Failure) {
537 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
538 SetErrorCode(aFail->GetMessageString());
542 //Make a Python command
543 GEOM::TPythonDump pd (aFunction);
544 pd << aFillet1D << " = geompy.MakeFillet1D(" << theShape
545 << ", " << theR << ", [";
547 it = theVertexes.begin();
548 if (it != theVertexes.end()) {
550 while (it != theVertexes.end())
551 pd << ", " << (*it++);
559 //=============================================================================
563 //=============================================================================
564 Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeChamferAll (Handle(GEOM_Object) theShape, double theD)
568 //Add a new Chamfer object
569 Handle(GEOM_Object) aChamfer = GetEngine()->AddObject(GetDocID(), GEOM_CHAMFER);
571 //Add a new Chamfer function
572 Handle(GEOM_Function) aFunction =
573 aChamfer->AddFunction(GEOMImpl_ChamferDriver::GetID(), CHAMFER_SHAPE_ALL);
574 if (aFunction.IsNull()) return NULL;
576 //Check if the function is set correctly
577 if (aFunction->GetDriverGUID() != GEOMImpl_ChamferDriver::GetID()) return NULL;
579 GEOMImpl_IChamfer aCI (aFunction);
581 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
582 if (aRefShape.IsNull()) return NULL;
584 aCI.SetShape(aRefShape);
587 //Compute the Chamfer value
589 #if OCC_VERSION_LARGE > 0x06010000
592 if (!GetSolver()->ComputeFunction(aFunction)) {
593 SetErrorCode("Chamfer driver failed");
597 catch (Standard_Failure) {
598 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
599 SetErrorCode(aFail->GetMessageString());
603 //Make a Python command
604 GEOM::TPythonDump(aFunction) << aChamfer << " = geompy.MakeChamferAll("
605 << theShape << ", " << theD << ")";
611 //=============================================================================
615 //=============================================================================
616 Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeChamferEdge
617 (Handle(GEOM_Object) theShape, double theD1, double theD2,
618 int theFace1, int theFace2)
622 //Add a new Chamfer object
623 Handle(GEOM_Object) aChamfer = GetEngine()->AddObject(GetDocID(), GEOM_CHAMFER);
625 //Add a new Chamfer function
626 Handle(GEOM_Function) aFunction =
627 aChamfer->AddFunction(GEOMImpl_ChamferDriver::GetID(), CHAMFER_SHAPE_EDGE);
628 if (aFunction.IsNull()) return NULL;
630 //Check if the function is set correctly
631 if (aFunction->GetDriverGUID() != GEOMImpl_ChamferDriver::GetID()) return NULL;
633 GEOMImpl_IChamfer aCI (aFunction);
635 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
636 if (aRefShape.IsNull()) return NULL;
638 aCI.SetShape(aRefShape);
641 aCI.SetFace1(theFace1);
642 aCI.SetFace2(theFace2);
644 //Compute the Chamfer value
646 #if OCC_VERSION_LARGE > 0x06010000
649 if (!GetSolver()->ComputeFunction(aFunction)) {
650 SetErrorCode("Chamfer driver failed");
654 catch (Standard_Failure) {
655 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
656 SetErrorCode(aFail->GetMessageString());
660 //Make a Python command
661 GEOM::TPythonDump(aFunction) << aChamfer
662 << " = geompy.MakeChamferEdge(" << theShape << ", " << theD1
663 << ", " << theD2 << ", " << theFace1 << ", " << theFace2 << ")";
669 //=============================================================================
673 //=============================================================================
674 Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeChamferEdgeAD
675 (Handle(GEOM_Object) theShape, double theD, double theAngle,
676 int theFace1, int theFace2)
680 //Add a new Chamfer object
681 Handle(GEOM_Object) aChamfer = GetEngine()->AddObject(GetDocID(), GEOM_CHAMFER);
683 //Add a new Chamfer function
684 Handle(GEOM_Function) aFunction =
685 aChamfer->AddFunction(GEOMImpl_ChamferDriver::GetID(), CHAMFER_SHAPE_EDGE_AD);
686 if (aFunction.IsNull()) return NULL;
688 //Check if the function is set correctly
689 if (aFunction->GetDriverGUID() != GEOMImpl_ChamferDriver::GetID()) return NULL;
691 GEOMImpl_IChamfer aCI (aFunction);
693 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
694 if (aRefShape.IsNull()) return NULL;
696 aCI.SetShape(aRefShape);
698 aCI.SetAngle(theAngle);
699 aCI.SetFace1(theFace1);
700 aCI.SetFace2(theFace2);
702 //Compute the Chamfer value
704 #if OCC_VERSION_LARGE > 0x06010000
707 if (!GetSolver()->ComputeFunction(aFunction)) {
708 SetErrorCode("Chamfer driver failed");
712 catch (Standard_Failure) {
713 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
714 SetErrorCode(aFail->GetMessageString());
718 //Make a Python command
719 GEOM::TPythonDump(aFunction) << aChamfer
720 << " = geompy.MakeChamferEdgeAD(" << theShape << ", " << theD
721 << ", " << theAngle << ", " << theFace1 << ", " << theFace2 << ")";
726 //=============================================================================
730 //=============================================================================
731 Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeChamferFaces
732 (Handle(GEOM_Object) theShape, double theD1, double theD2,
733 std::list<int> theFaces)
737 //Add a new Chamfer object
738 Handle(GEOM_Object) aChamfer = GetEngine()->AddObject(GetDocID(), GEOM_CHAMFER);
740 //Add a new Chamfer function
741 Handle(GEOM_Function) aFunction =
742 aChamfer->AddFunction(GEOMImpl_ChamferDriver::GetID(), CHAMFER_SHAPE_FACES);
743 if (aFunction.IsNull()) return NULL;
745 //Check if the function is set correctly
746 if (aFunction->GetDriverGUID() != GEOMImpl_ChamferDriver::GetID()) return NULL;
748 GEOMImpl_IChamfer aCI (aFunction);
750 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
751 if (aRefShape.IsNull()) return NULL;
753 aCI.SetShape(aRefShape);
756 int aLen = theFaces.size();
760 std::list<int>::iterator it = theFaces.begin();
761 for (; it != theFaces.end(); it++, ind++) {
762 aCI.SetFace(ind, (*it));
765 //Compute the Chamfer value
767 #if OCC_VERSION_LARGE > 0x06010000
770 if (!GetSolver()->ComputeFunction(aFunction)) {
771 SetErrorCode("Chamfer driver failed");
775 catch (Standard_Failure) {
776 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
777 SetErrorCode(aFail->GetMessageString());
781 //Make a Python command
782 GEOM::TPythonDump pd (aFunction);
783 pd << aChamfer << " = geompy.MakeChamferFaces(" << theShape
784 << ", " << theD1 << ", " << theD2 << ", [";
786 it = theFaces.begin();
788 while (it != theFaces.end()) {
789 pd << ", " << (*it++);
797 //=============================================================================
801 //=============================================================================
802 Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeChamferFacesAD
803 (Handle(GEOM_Object) theShape, double theD, double theAngle,
804 std::list<int> theFaces)
808 //Add a new Chamfer object
809 Handle(GEOM_Object) aChamfer = GetEngine()->AddObject(GetDocID(), GEOM_CHAMFER);
811 //Add a new Chamfer function
812 Handle(GEOM_Function) aFunction =
813 aChamfer->AddFunction(GEOMImpl_ChamferDriver::GetID(), CHAMFER_SHAPE_FACES_AD);
814 if (aFunction.IsNull()) return NULL;
816 //Check if the function is set correctly
817 if (aFunction->GetDriverGUID() != GEOMImpl_ChamferDriver::GetID()) return NULL;
819 GEOMImpl_IChamfer aCI (aFunction);
821 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
822 if (aRefShape.IsNull()) return NULL;
824 aCI.SetShape(aRefShape);
826 aCI.SetAngle(theAngle);
827 int aLen = theFaces.size();
831 std::list<int>::iterator it = theFaces.begin();
832 for (; it != theFaces.end(); it++, ind++) {
833 aCI.SetFace(ind, (*it));
836 //Compute the Chamfer value
838 #if OCC_VERSION_LARGE > 0x06010000
841 if (!GetSolver()->ComputeFunction(aFunction)) {
842 SetErrorCode("Chamfer driver failed");
846 catch (Standard_Failure) {
847 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
848 SetErrorCode(aFail->GetMessageString());
852 //Make a Python command
853 GEOM::TPythonDump pd (aFunction);
854 pd << aChamfer << " = geompy.MakeChamferFacesAD(" << theShape
855 << ", " << theD << ", " << theAngle << ", [";
857 it = theFaces.begin();
859 while (it != theFaces.end()) {
860 pd << ", " << (*it++);
868 //=============================================================================
872 //=============================================================================
873 Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeChamferEdges
874 (Handle(GEOM_Object) theShape, double theD1, double theD2,
875 std::list<int> theEdges)
879 //Add a new Chamfer object
880 Handle(GEOM_Object) aChamfer = GetEngine()->AddObject(GetDocID(), GEOM_CHAMFER);
882 //Add a new Chamfer function
883 Handle(GEOM_Function) aFunction =
884 aChamfer->AddFunction(GEOMImpl_ChamferDriver::GetID(), CHAMFER_SHAPE_EDGES);
885 if (aFunction.IsNull()) { MESSAGE ( "Edges Function is NULL!!!" ); return NULL;}
887 //Check if the function is set correctly
888 if (aFunction->GetDriverGUID() != GEOMImpl_ChamferDriver::GetID())
889 { MESSAGE ( "Chamfer Driver is NULL!!!" ); return NULL; }
891 GEOMImpl_IChamfer aCI (aFunction);
893 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
894 if (aRefShape.IsNull()) { MESSAGE ("Shape is NULL!!!"); return NULL;}
896 aCI.SetShape(aRefShape);
899 int aLen = theEdges.size();
903 std::list<int>::iterator it = theEdges.begin();
904 for (; it != theEdges.end(); it++, ind++) {
905 aCI.SetEdge(ind, (*it));
908 //Compute the Chamfer value
910 #if OCC_VERSION_LARGE > 0x06010000
913 if (!GetSolver()->ComputeFunction(aFunction)) {
914 SetErrorCode("Chamfer driver failed");
918 catch (Standard_Failure) {
919 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
920 SetErrorCode(aFail->GetMessageString());
924 //Make a Python command
925 GEOM::TPythonDump pd (aFunction);
926 pd << aChamfer << " = geompy.MakeChamferEdges(" << theShape
927 << ", " << theD1 << ", " << theD2 << ", [";
929 it = theEdges.begin();
931 while (it != theEdges.end()) {
932 pd << ", " << (*it++);
940 //=============================================================================
944 //=============================================================================
945 Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeChamferEdgesAD
946 (Handle(GEOM_Object) theShape, double theD, double theAngle,
947 std::list<int> theEdges)
951 //Add a new Chamfer object
952 Handle(GEOM_Object) aChamfer = GetEngine()->AddObject(GetDocID(), GEOM_CHAMFER);
954 //Add a new Chamfer function
955 Handle(GEOM_Function) aFunction =
956 aChamfer->AddFunction(GEOMImpl_ChamferDriver::GetID(), CHAMFER_SHAPE_EDGES_AD);
957 if (aFunction.IsNull()) { MESSAGE ( "Edges Function is NULL!!!" ); return NULL; }
959 //Check if the function is set correctly
960 if (aFunction->GetDriverGUID() != GEOMImpl_ChamferDriver::GetID())
961 { MESSAGE("Chamfer Driver is NULL!!!"); return NULL;}
963 GEOMImpl_IChamfer aCI (aFunction);
965 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
966 if (aRefShape.IsNull()) { MESSAGE ("Shape is NULL!!!"); return NULL;}
968 aCI.SetShape(aRefShape);
970 aCI.SetAngle(theAngle);
971 int aLen = theEdges.size();
975 std::list<int>::iterator it = theEdges.begin();
976 for (; it != theEdges.end(); it++, ind++) {
977 aCI.SetEdge(ind, (*it));
980 //Compute the Chamfer value
982 #if OCC_VERSION_LARGE > 0x06010000
985 if (!GetSolver()->ComputeFunction(aFunction)) {
986 SetErrorCode("Chamfer driver failed");
990 catch (Standard_Failure) {
991 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
992 SetErrorCode(aFail->GetMessageString());
996 //Make a Python command
997 GEOM::TPythonDump pd (aFunction);
998 pd << aChamfer << " = geompy.MakeChamferEdgesAD(" << theShape
999 << ", " << theD << ", " << theAngle << ", [";
1001 it = theEdges.begin();
1003 while (it != theEdges.end()) {
1004 pd << ", " << (*it++);
1012 //=============================================================================
1016 //=============================================================================
1017 Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeArchimede (Handle(GEOM_Object) theShape,
1019 double theWaterDensity,
1020 double theMeshingDeflection)
1024 //Add a new Archimede object
1025 Handle(GEOM_Object) aChamfer = GetEngine()->AddObject(GetDocID(), GEOM_ARCHIMEDE);
1027 //Add a new Archimede function
1028 Handle(GEOM_Function) aFunction = aChamfer->AddFunction(GEOMImpl_ArchimedeDriver::GetID(), ARCHIMEDE_TYPE);
1029 if (aFunction.IsNull()) return NULL;
1031 //Check if the function is set correctly
1032 if (aFunction->GetDriverGUID() != GEOMImpl_ArchimedeDriver::GetID()) return NULL;
1034 GEOMImpl_IArchimede aAI (aFunction);
1036 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
1037 if (aRefShape.IsNull()) return NULL;
1039 aAI.SetBasicShape(aRefShape);
1040 aAI.SetWeight(theWeight);
1041 aAI.SetDensity(theWaterDensity);
1042 aAI.SetDeflection(theMeshingDeflection);
1044 //Compute the Archimede value
1046 #if OCC_VERSION_LARGE > 0x06010000
1049 if (!GetSolver()->ComputeFunction(aFunction)) {
1050 SetErrorCode("Archimede driver failed");
1054 catch (Standard_Failure) {
1055 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1056 SetErrorCode(aFail->GetMessageString());
1060 //Make a Python command
1061 GEOM::TPythonDump(aFunction) << aChamfer
1062 << " = geompy.Archimede(" << theShape << ", " << theWeight << ", "
1063 << theWaterDensity << ", " << theMeshingDeflection << ")";
1069 //=============================================================================
1073 //=============================================================================
1074 bool GEOMImpl_ILocalOperations::GetSubShape (const TopoDS_Shape& theShape, const int theIndex,
1075 TopoDS_Shape& theSubShape)
1077 if (theShape.IsNull() || theIndex < 1)
1080 TopTools_IndexedMapOfShape anIndices;
1081 TopExp::MapShapes(theShape, anIndices);
1082 if (theIndex > anIndices.Extent()) return false;
1083 theSubShape = anIndices.FindKey(theIndex);
1088 //=============================================================================
1092 //=============================================================================
1093 Standard_Integer GEOMImpl_ILocalOperations::GetSubShapeIndex (Handle(GEOM_Object) theShape,
1094 Handle(GEOM_Object) theSubShape)
1098 Standard_Integer anInd = -1;
1099 GEOM_Engine* anEngine = GetEngine();
1100 //GEOMImpl_Gen* aGen = dynamic_cast<GEOMImpl_Gen*>(anEngine);
1101 GEOMImpl_Gen* aGen = (GEOMImpl_Gen*)anEngine;
1104 GEOMImpl_IShapesOperations* anIShapesOperations =
1105 aGen->GetIShapesOperations(GetDocID());
1106 anInd = anIShapesOperations->GetSubShapeIndex(theShape, theSubShape);
1107 SetErrorCode(anIShapesOperations->GetErrorCode());