1 // Copyright (C) 2007-2013 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,
496 std::list<int> theVertexes, bool doIgnoreSecantVertices)
500 //Add a new Fillet object
501 Handle(GEOM_Object) aFillet1D = GetEngine()->AddObject(GetDocID(), GEOM_FILLET_1D);
503 //Add a new Fillet function
504 Handle(GEOM_Function) aFunction =
505 aFillet1D->AddFunction(GEOMImpl_Fillet1dDriver::GetID(), FILLET_1D_SHAPE_VERTEXES);
506 if (aFunction.IsNull()) return NULL;
508 //Check if the function is set correctly
509 if (aFunction->GetDriverGUID() != GEOMImpl_Fillet1dDriver::GetID()) return NULL;
511 GEOMImpl_IFillet1d aCI (aFunction);
513 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
514 if (aRefShape.IsNull()) return NULL;
516 aCI.SetShape(aRefShape);
518 aCI.SetFlag(doIgnoreSecantVertices);
519 int aLen = theVertexes.size();
523 std::list<int>::iterator it = theVertexes.begin();
524 for (; it != theVertexes.end(); it++, ind++) {
525 aCI.SetVertex(ind, (*it));
528 //Compute the Fillet value
530 #if OCC_VERSION_LARGE > 0x06010000
533 if (!GetSolver()->ComputeFunction(aFunction)) {
534 SetErrorCode("1D Fillet driver failed");
538 catch (Standard_Failure) {
539 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
540 SetErrorCode(aFail->GetMessageString());
544 //Make a Python command
545 GEOM::TPythonDump pd (aFunction);
546 pd << aFillet1D << " = geompy.MakeFillet1D(" << theShape
547 << ", " << theR << ", [";
549 it = theVertexes.begin();
550 if (it != theVertexes.end()) {
552 while (it != theVertexes.end())
553 pd << ", " << (*it++);
561 //=============================================================================
565 //=============================================================================
566 Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeChamferAll (Handle(GEOM_Object) theShape, double theD)
570 //Add a new Chamfer object
571 Handle(GEOM_Object) aChamfer = GetEngine()->AddObject(GetDocID(), GEOM_CHAMFER);
573 //Add a new Chamfer function
574 Handle(GEOM_Function) aFunction =
575 aChamfer->AddFunction(GEOMImpl_ChamferDriver::GetID(), CHAMFER_SHAPE_ALL);
576 if (aFunction.IsNull()) return NULL;
578 //Check if the function is set correctly
579 if (aFunction->GetDriverGUID() != GEOMImpl_ChamferDriver::GetID()) return NULL;
581 GEOMImpl_IChamfer aCI (aFunction);
583 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
584 if (aRefShape.IsNull()) return NULL;
586 aCI.SetShape(aRefShape);
589 //Compute the Chamfer value
591 #if OCC_VERSION_LARGE > 0x06010000
594 if (!GetSolver()->ComputeFunction(aFunction)) {
595 SetErrorCode("Chamfer driver failed");
599 catch (Standard_Failure) {
600 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
601 SetErrorCode(aFail->GetMessageString());
605 //Make a Python command
606 GEOM::TPythonDump(aFunction) << aChamfer << " = geompy.MakeChamferAll("
607 << theShape << ", " << theD << ")";
613 //=============================================================================
617 //=============================================================================
618 Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeChamferEdge
619 (Handle(GEOM_Object) theShape, double theD1, double theD2,
620 int theFace1, int theFace2)
624 //Add a new Chamfer object
625 Handle(GEOM_Object) aChamfer = GetEngine()->AddObject(GetDocID(), GEOM_CHAMFER);
627 //Add a new Chamfer function
628 Handle(GEOM_Function) aFunction =
629 aChamfer->AddFunction(GEOMImpl_ChamferDriver::GetID(), CHAMFER_SHAPE_EDGE);
630 if (aFunction.IsNull()) return NULL;
632 //Check if the function is set correctly
633 if (aFunction->GetDriverGUID() != GEOMImpl_ChamferDriver::GetID()) return NULL;
635 GEOMImpl_IChamfer aCI (aFunction);
637 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
638 if (aRefShape.IsNull()) return NULL;
640 aCI.SetShape(aRefShape);
643 aCI.SetFace1(theFace1);
644 aCI.SetFace2(theFace2);
646 //Compute the Chamfer value
648 #if OCC_VERSION_LARGE > 0x06010000
651 if (!GetSolver()->ComputeFunction(aFunction)) {
652 SetErrorCode("Chamfer driver failed");
656 catch (Standard_Failure) {
657 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
658 SetErrorCode(aFail->GetMessageString());
662 //Make a Python command
663 GEOM::TPythonDump(aFunction) << aChamfer
664 << " = geompy.MakeChamferEdge(" << theShape << ", " << theD1
665 << ", " << theD2 << ", " << theFace1 << ", " << theFace2 << ")";
671 //=============================================================================
675 //=============================================================================
676 Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeChamferEdgeAD
677 (Handle(GEOM_Object) theShape, double theD, double theAngle,
678 int theFace1, int theFace2)
682 //Add a new Chamfer object
683 Handle(GEOM_Object) aChamfer = GetEngine()->AddObject(GetDocID(), GEOM_CHAMFER);
685 //Add a new Chamfer function
686 Handle(GEOM_Function) aFunction =
687 aChamfer->AddFunction(GEOMImpl_ChamferDriver::GetID(), CHAMFER_SHAPE_EDGE_AD);
688 if (aFunction.IsNull()) return NULL;
690 //Check if the function is set correctly
691 if (aFunction->GetDriverGUID() != GEOMImpl_ChamferDriver::GetID()) return NULL;
693 GEOMImpl_IChamfer aCI (aFunction);
695 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
696 if (aRefShape.IsNull()) return NULL;
698 aCI.SetShape(aRefShape);
700 aCI.SetAngle(theAngle);
701 aCI.SetFace1(theFace1);
702 aCI.SetFace2(theFace2);
704 //Compute the Chamfer value
706 #if OCC_VERSION_LARGE > 0x06010000
709 if (!GetSolver()->ComputeFunction(aFunction)) {
710 SetErrorCode("Chamfer driver failed");
714 catch (Standard_Failure) {
715 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
716 SetErrorCode(aFail->GetMessageString());
720 //Make a Python command
721 GEOM::TPythonDump(aFunction) << aChamfer
722 << " = geompy.MakeChamferEdgeAD(" << theShape << ", " << theD
723 << ", " << theAngle << ", " << theFace1 << ", " << theFace2 << ")";
728 //=============================================================================
732 //=============================================================================
733 Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeChamferFaces
734 (Handle(GEOM_Object) theShape, double theD1, double theD2,
735 std::list<int> theFaces)
739 //Add a new Chamfer object
740 Handle(GEOM_Object) aChamfer = GetEngine()->AddObject(GetDocID(), GEOM_CHAMFER);
742 //Add a new Chamfer function
743 Handle(GEOM_Function) aFunction =
744 aChamfer->AddFunction(GEOMImpl_ChamferDriver::GetID(), CHAMFER_SHAPE_FACES);
745 if (aFunction.IsNull()) return NULL;
747 //Check if the function is set correctly
748 if (aFunction->GetDriverGUID() != GEOMImpl_ChamferDriver::GetID()) return NULL;
750 GEOMImpl_IChamfer aCI (aFunction);
752 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
753 if (aRefShape.IsNull()) return NULL;
755 aCI.SetShape(aRefShape);
758 int aLen = theFaces.size();
762 std::list<int>::iterator it = theFaces.begin();
763 for (; it != theFaces.end(); it++, ind++) {
764 aCI.SetFace(ind, (*it));
767 //Compute the Chamfer value
769 #if OCC_VERSION_LARGE > 0x06010000
772 if (!GetSolver()->ComputeFunction(aFunction)) {
773 SetErrorCode("Chamfer driver failed");
777 catch (Standard_Failure) {
778 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
779 SetErrorCode(aFail->GetMessageString());
783 //Make a Python command
784 GEOM::TPythonDump pd (aFunction);
785 pd << aChamfer << " = geompy.MakeChamferFaces(" << theShape
786 << ", " << theD1 << ", " << theD2 << ", [";
788 it = theFaces.begin();
790 while (it != theFaces.end()) {
791 pd << ", " << (*it++);
799 //=============================================================================
803 //=============================================================================
804 Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeChamferFacesAD
805 (Handle(GEOM_Object) theShape, double theD, double theAngle,
806 std::list<int> theFaces)
810 //Add a new Chamfer object
811 Handle(GEOM_Object) aChamfer = GetEngine()->AddObject(GetDocID(), GEOM_CHAMFER);
813 //Add a new Chamfer function
814 Handle(GEOM_Function) aFunction =
815 aChamfer->AddFunction(GEOMImpl_ChamferDriver::GetID(), CHAMFER_SHAPE_FACES_AD);
816 if (aFunction.IsNull()) return NULL;
818 //Check if the function is set correctly
819 if (aFunction->GetDriverGUID() != GEOMImpl_ChamferDriver::GetID()) return NULL;
821 GEOMImpl_IChamfer aCI (aFunction);
823 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
824 if (aRefShape.IsNull()) return NULL;
826 aCI.SetShape(aRefShape);
828 aCI.SetAngle(theAngle);
829 int aLen = theFaces.size();
833 std::list<int>::iterator it = theFaces.begin();
834 for (; it != theFaces.end(); it++, ind++) {
835 aCI.SetFace(ind, (*it));
838 //Compute the Chamfer value
840 #if OCC_VERSION_LARGE > 0x06010000
843 if (!GetSolver()->ComputeFunction(aFunction)) {
844 SetErrorCode("Chamfer driver failed");
848 catch (Standard_Failure) {
849 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
850 SetErrorCode(aFail->GetMessageString());
854 //Make a Python command
855 GEOM::TPythonDump pd (aFunction);
856 pd << aChamfer << " = geompy.MakeChamferFacesAD(" << theShape
857 << ", " << theD << ", " << theAngle << ", [";
859 it = theFaces.begin();
861 while (it != theFaces.end()) {
862 pd << ", " << (*it++);
870 //=============================================================================
874 //=============================================================================
875 Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeChamferEdges
876 (Handle(GEOM_Object) theShape, double theD1, double theD2,
877 std::list<int> theEdges)
881 //Add a new Chamfer object
882 Handle(GEOM_Object) aChamfer = GetEngine()->AddObject(GetDocID(), GEOM_CHAMFER);
884 //Add a new Chamfer function
885 Handle(GEOM_Function) aFunction =
886 aChamfer->AddFunction(GEOMImpl_ChamferDriver::GetID(), CHAMFER_SHAPE_EDGES);
887 if (aFunction.IsNull()) { MESSAGE ( "Edges Function is NULL!!!" ); return NULL;}
889 //Check if the function is set correctly
890 if (aFunction->GetDriverGUID() != GEOMImpl_ChamferDriver::GetID())
891 { MESSAGE ( "Chamfer Driver is NULL!!!" ); return NULL; }
893 GEOMImpl_IChamfer aCI (aFunction);
895 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
896 if (aRefShape.IsNull()) { MESSAGE ("Shape is NULL!!!"); return NULL;}
898 aCI.SetShape(aRefShape);
901 int aLen = theEdges.size();
905 std::list<int>::iterator it = theEdges.begin();
906 for (; it != theEdges.end(); it++, ind++) {
907 aCI.SetEdge(ind, (*it));
910 //Compute the Chamfer value
912 #if OCC_VERSION_LARGE > 0x06010000
915 if (!GetSolver()->ComputeFunction(aFunction)) {
916 SetErrorCode("Chamfer driver failed");
920 catch (Standard_Failure) {
921 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
922 SetErrorCode(aFail->GetMessageString());
926 //Make a Python command
927 GEOM::TPythonDump pd (aFunction);
928 pd << aChamfer << " = geompy.MakeChamferEdges(" << theShape
929 << ", " << theD1 << ", " << theD2 << ", [";
931 it = theEdges.begin();
933 while (it != theEdges.end()) {
934 pd << ", " << (*it++);
942 //=============================================================================
946 //=============================================================================
947 Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeChamferEdgesAD
948 (Handle(GEOM_Object) theShape, double theD, double theAngle,
949 std::list<int> theEdges)
953 //Add a new Chamfer object
954 Handle(GEOM_Object) aChamfer = GetEngine()->AddObject(GetDocID(), GEOM_CHAMFER);
956 //Add a new Chamfer function
957 Handle(GEOM_Function) aFunction =
958 aChamfer->AddFunction(GEOMImpl_ChamferDriver::GetID(), CHAMFER_SHAPE_EDGES_AD);
959 if (aFunction.IsNull()) { MESSAGE ( "Edges Function is NULL!!!" ); return NULL; }
961 //Check if the function is set correctly
962 if (aFunction->GetDriverGUID() != GEOMImpl_ChamferDriver::GetID())
963 { MESSAGE("Chamfer Driver is NULL!!!"); return NULL;}
965 GEOMImpl_IChamfer aCI (aFunction);
967 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
968 if (aRefShape.IsNull()) { MESSAGE ("Shape is NULL!!!"); return NULL;}
970 aCI.SetShape(aRefShape);
972 aCI.SetAngle(theAngle);
973 int aLen = theEdges.size();
977 std::list<int>::iterator it = theEdges.begin();
978 for (; it != theEdges.end(); it++, ind++) {
979 aCI.SetEdge(ind, (*it));
982 //Compute the Chamfer value
984 #if OCC_VERSION_LARGE > 0x06010000
987 if (!GetSolver()->ComputeFunction(aFunction)) {
988 SetErrorCode("Chamfer driver failed");
992 catch (Standard_Failure) {
993 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
994 SetErrorCode(aFail->GetMessageString());
998 //Make a Python command
999 GEOM::TPythonDump pd (aFunction);
1000 pd << aChamfer << " = geompy.MakeChamferEdgesAD(" << theShape
1001 << ", " << theD << ", " << theAngle << ", [";
1003 it = theEdges.begin();
1005 while (it != theEdges.end()) {
1006 pd << ", " << (*it++);
1014 //=============================================================================
1018 //=============================================================================
1019 Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeArchimede (Handle(GEOM_Object) theShape,
1021 double theWaterDensity,
1022 double theMeshingDeflection)
1026 //Add a new Archimede object
1027 Handle(GEOM_Object) aChamfer = GetEngine()->AddObject(GetDocID(), GEOM_ARCHIMEDE);
1029 //Add a new Archimede function
1030 Handle(GEOM_Function) aFunction = aChamfer->AddFunction(GEOMImpl_ArchimedeDriver::GetID(), ARCHIMEDE_TYPE);
1031 if (aFunction.IsNull()) return NULL;
1033 //Check if the function is set correctly
1034 if (aFunction->GetDriverGUID() != GEOMImpl_ArchimedeDriver::GetID()) return NULL;
1036 GEOMImpl_IArchimede aAI (aFunction);
1038 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
1039 if (aRefShape.IsNull()) return NULL;
1041 aAI.SetBasicShape(aRefShape);
1042 aAI.SetWeight(theWeight);
1043 aAI.SetDensity(theWaterDensity);
1044 aAI.SetDeflection(theMeshingDeflection);
1046 //Compute the Archimede value
1048 #if OCC_VERSION_LARGE > 0x06010000
1051 if (!GetSolver()->ComputeFunction(aFunction)) {
1052 SetErrorCode("Archimede driver failed");
1056 catch (Standard_Failure) {
1057 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1058 SetErrorCode(aFail->GetMessageString());
1062 //Make a Python command
1063 GEOM::TPythonDump(aFunction) << aChamfer
1064 << " = geompy.Archimede(" << theShape << ", " << theWeight << ", "
1065 << theWaterDensity << ", " << theMeshingDeflection << ")";
1071 //=============================================================================
1075 //=============================================================================
1076 bool GEOMImpl_ILocalOperations::GetSubShape (const TopoDS_Shape& theShape, const int theIndex,
1077 TopoDS_Shape& theSubShape)
1079 if (theShape.IsNull() || theIndex < 1)
1082 TopTools_IndexedMapOfShape anIndices;
1083 TopExp::MapShapes(theShape, anIndices);
1084 if (theIndex > anIndices.Extent()) return false;
1085 theSubShape = anIndices.FindKey(theIndex);
1090 //=============================================================================
1094 //=============================================================================
1095 Standard_Integer GEOMImpl_ILocalOperations::GetSubShapeIndex (Handle(GEOM_Object) theShape,
1096 Handle(GEOM_Object) theSubShape)
1100 Standard_Integer anInd = -1;
1101 GEOM_Engine* anEngine = GetEngine();
1102 //GEOMImpl_Gen* aGen = dynamic_cast<GEOMImpl_Gen*>(anEngine);
1103 GEOMImpl_Gen* aGen = (GEOMImpl_Gen*)anEngine;
1106 GEOMImpl_IShapesOperations* anIShapesOperations =
1107 aGen->GetIShapesOperations(GetDocID());
1108 anInd = anIShapesOperations->GetSubShapeIndex(theShape, theSubShape);
1109 SetErrorCode(anIShapesOperations->GetErrorCode());