1 // Copyright (C) 2007-2021 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 "utilities.h"
50 #include <Utils_ExceptHandlers.hxx>
52 #include <TFunction_DriverTable.hxx>
53 #include <TFunction_Driver.hxx>
54 #include <TDF_Tool.hxx>
57 #include <TopoDS_TShape.hxx>
58 #include <TopTools_IndexedMapOfShape.hxx>
60 #include <Standard_Failure.hxx>
61 #include <Standard_ErrorHandler.hxx> // CAREFUL ! position of this file is critic : see Lucien PIGNOLONI / OCC
63 //=============================================================================
67 //=============================================================================
68 GEOMImpl_ILocalOperations::GEOMImpl_ILocalOperations (GEOM_Engine* theEngine)
69 : GEOM_IOperations(theEngine)
71 MESSAGE("GEOMImpl_ILocalOperations::GEOMImpl_ILocalOperations");
74 //=============================================================================
78 //=============================================================================
79 GEOMImpl_ILocalOperations::~GEOMImpl_ILocalOperations()
81 MESSAGE("GEOMImpl_ILocalOperations::~GEOMImpl_ILocalOperations");
85 //=============================================================================
89 //=============================================================================
90 Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeFilletAll
91 (Handle(GEOM_Object) theShape, double theR)
95 //Add a new Fillet object
96 Handle(GEOM_Object) aFillet = GetEngine()->AddObject(GEOM_FILLET);
98 //Add a new Fillet function
99 Handle(GEOM_Function) aFunction =
100 aFillet->AddFunction(GEOMImpl_FilletDriver::GetID(), FILLET_SHAPE_ALL);
101 if (aFunction.IsNull()) return NULL;
103 //Check if the function is set correctly
104 if (aFunction->GetDriverGUID() != GEOMImpl_FilletDriver::GetID()) return NULL;
106 GEOMImpl_IFillet aCI (aFunction);
108 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
109 if (aRefShape.IsNull()) return NULL;
111 aCI.SetShape(aRefShape);
114 //Compute the Fillet value
117 if (!GetSolver()->ComputeFunction(aFunction)) {
118 SetErrorCode("Fillet driver failed");
122 catch (Standard_Failure& aFail) {
123 SetErrorCode(aFail.GetMessageString());
127 //Make a Python command
128 GEOM::TPythonDump(aFunction) << aFillet << " = geompy.MakeFilletAll("
129 << theShape << ", " << theR << ")";
135 //=============================================================================
139 //=============================================================================
140 Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeFilletEdges
141 (Handle(GEOM_Object) theShape, double theR, std::list<int> theEdges)
145 //Add a new Fillet object
146 Handle(GEOM_Object) aFillet = GetEngine()->AddObject(GEOM_FILLET);
148 //Add a new Fillet function
149 Handle(GEOM_Function) aFunction =
150 aFillet->AddFunction(GEOMImpl_FilletDriver::GetID(), FILLET_SHAPE_EDGES);
151 if (aFunction.IsNull()) return NULL;
153 //Check if the function is set correctly
154 if (aFunction->GetDriverGUID() != GEOMImpl_FilletDriver::GetID()) return NULL;
156 GEOMImpl_IFillet aCI (aFunction);
158 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
159 if (aRefShape.IsNull()) return NULL;
161 aCI.SetShape(aRefShape);
163 int aLen = theEdges.size();
167 std::list<int>::iterator it = theEdges.begin();
168 for (; it != theEdges.end(); it++, ind++) {
169 aCI.SetEdge(ind, (*it));
172 //Compute the Fillet value
175 if (!GetSolver()->ComputeFunction(aFunction)) {
176 SetErrorCode("Fillet driver failed");
180 catch (Standard_Failure& aFail) {
181 SetErrorCode(aFail.GetMessageString());
185 //Make a Python command
186 GEOM::TPythonDump pd (aFunction);
187 pd << aFillet << " = geompy.MakeFillet(" << theShape
188 << ", " << theR << ", geompy.ShapeType[\"EDGE\"], [";
190 it = theEdges.begin();
192 while (it != theEdges.end()) {
193 pd << ", " << (*it++);
201 //=============================================================================
203 * MakeFilletEdges R1 R2
205 //=============================================================================
206 Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeFilletEdgesR1R2
207 (Handle(GEOM_Object) theShape, double theR1, double theR2, std::list<int> theEdges)
211 //Add a new Fillet object
212 Handle(GEOM_Object) aFillet = GetEngine()->AddObject(GEOM_FILLET);
214 //Add a new Fillet function
215 Handle(GEOM_Function) aFunction =
216 aFillet->AddFunction(GEOMImpl_FilletDriver::GetID(), FILLET_SHAPE_EDGES_2R);
217 if (aFunction.IsNull()) return NULL;
219 //Check if the function is set correctly
220 if (aFunction->GetDriverGUID() != GEOMImpl_FilletDriver::GetID()) return NULL;
222 GEOMImpl_IFillet aCI (aFunction);
224 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
225 if (aRefShape.IsNull()) return NULL;
227 aCI.SetShape(aRefShape);
230 int aLen = theEdges.size();
234 std::list<int>::iterator it = theEdges.begin();
235 for (; it != theEdges.end(); it++, ind++) {
236 aCI.SetEdge(ind, (*it));
239 //Compute the Fillet value
242 if (!GetSolver()->ComputeFunction(aFunction)) {
243 SetErrorCode("Fillet driver failed");
247 catch (Standard_Failure& aFail) {
248 SetErrorCode(aFail.GetMessageString());
252 //Make a Python command
253 GEOM::TPythonDump pd (aFunction);
254 pd << aFillet << " = geompy.MakeFilletR1R2(" << theShape
255 << ", " << theR1 << ", " <<theR2 << ", geompy.ShapeType[\"EDGE\"], [";
257 it = theEdges.begin();
259 while (it != theEdges.end()) {
260 pd << ", " << (*it++);
269 //=============================================================================
273 //=============================================================================
274 Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeFilletFaces
275 (Handle(GEOM_Object) theShape, double theR, std::list<int> theFaces)
279 //Add a new Fillet object
280 Handle(GEOM_Object) aFillet = GetEngine()->AddObject(GEOM_FILLET);
282 //Add a new Fillet function
283 Handle(GEOM_Function) aFunction =
284 aFillet->AddFunction(GEOMImpl_FilletDriver::GetID(), FILLET_SHAPE_FACES);
285 if (aFunction.IsNull()) return NULL;
287 //Check if the function is set correctly
288 if (aFunction->GetDriverGUID() != GEOMImpl_FilletDriver::GetID()) return NULL;
290 GEOMImpl_IFillet aCI (aFunction);
292 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
293 if (aRefShape.IsNull()) return NULL;
295 aCI.SetShape(aRefShape);
297 int aLen = theFaces.size();
301 std::list<int>::iterator it = theFaces.begin();
302 for (; it != theFaces.end(); it++, ind++) {
303 aCI.SetFace(ind, (*it));
306 //Compute the Fillet value
309 if (!GetSolver()->ComputeFunction(aFunction)) {
310 SetErrorCode("Fillet driver failed");
314 catch (Standard_Failure& aFail) {
315 SetErrorCode(aFail.GetMessageString());
319 //Make a Python command
320 GEOM::TPythonDump pd (aFunction);
321 pd << aFillet << " = geompy.MakeFillet(" << theShape
322 << ", " << theR << ", geompy.ShapeType[\"FACE\"], [";
324 it = theFaces.begin();
326 while (it != theFaces.end()) {
327 pd << ", " << (*it++);
335 //=============================================================================
337 * MakeFilletFaces R1 R2
339 //=============================================================================
340 Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeFilletFacesR1R2
341 (Handle(GEOM_Object) theShape, double theR1, double theR2, std::list<int> theFaces)
345 //Add a new Fillet object
346 Handle(GEOM_Object) aFillet = GetEngine()->AddObject(GEOM_FILLET);
348 //Add a new Fillet function
349 Handle(GEOM_Function) aFunction =
350 aFillet->AddFunction(GEOMImpl_FilletDriver::GetID(), FILLET_SHAPE_FACES_2R);
351 if (aFunction.IsNull()) return NULL;
353 //Check if the function is set correctly
354 if (aFunction->GetDriverGUID() != GEOMImpl_FilletDriver::GetID()) return NULL;
356 GEOMImpl_IFillet aCI (aFunction);
358 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
359 if (aRefShape.IsNull()) return NULL;
361 aCI.SetShape(aRefShape);
364 int aLen = theFaces.size();
368 std::list<int>::iterator it = theFaces.begin();
369 for (; it != theFaces.end(); it++, ind++) {
370 aCI.SetFace(ind, (*it));
373 //Compute the Fillet value
376 if (!GetSolver()->ComputeFunction(aFunction)) {
377 SetErrorCode("Fillet driver failed");
381 catch (Standard_Failure& aFail) {
382 SetErrorCode(aFail.GetMessageString());
386 //Make a Python command
387 GEOM::TPythonDump pd (aFunction);
388 pd << aFillet << " = geompy.MakeFilletR1R2(" << theShape
389 << ", " << theR1 << ", " << theR2 << ", geompy.ShapeType[\"FACE\"], [";
391 it = theFaces.begin();
393 while (it != theFaces.end()) {
394 pd << ", " << (*it++);
402 //=============================================================================
406 //=============================================================================
407 Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeFillet2D
408 (Handle(GEOM_Object) theShape, double theR, std::list<int> theVertexes)
412 //Add a new Fillet object
413 Handle(GEOM_Object) aFillet2D = GetEngine()->AddObject(GEOM_FILLET_2D);
415 //Add a new Fillet function
416 Handle(GEOM_Function) aFunction =
417 aFillet2D->AddFunction(GEOMImpl_Fillet2dDriver::GetID(), FILLET_2D_SHAPE_VERTEXES);
418 if (aFunction.IsNull()) return NULL;
420 //Check if the function is set correctly
421 if (aFunction->GetDriverGUID() != GEOMImpl_Fillet2dDriver::GetID()) return NULL;
423 GEOMImpl_IFillet2d aCI (aFunction);
425 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
426 if (aRefShape.IsNull()) return NULL;
428 aCI.SetShape(aRefShape);
430 int aLen = theVertexes.size();
434 std::list<int>::iterator it = theVertexes.begin();
435 for (; it != theVertexes.end(); it++, ind++) {
436 aCI.SetVertex(ind, (*it));
439 //Compute the Fillet value
442 if (!GetSolver()->ComputeFunction(aFunction)) {
443 SetErrorCode("2D Fillet driver failed");
447 catch (Standard_Failure& aFail) {
448 SetErrorCode(aFail.GetMessageString());
452 //Make a Python command
453 GEOM::TPythonDump pd (aFunction);
454 pd << aFillet2D << " = geompy.MakeFillet2D(" << theShape
455 << ", " << theR << ", [";
457 it = theVertexes.begin();
459 while (it != theVertexes.end()) {
460 pd << ", " << (*it++);
468 //=============================================================================
472 //=============================================================================
473 Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeFillet1D
474 (Handle(GEOM_Object) theShape, double theR,
475 std::list<int> theVertexes, bool doIgnoreSecantVertices)
479 //Add a new Fillet object
480 Handle(GEOM_Object) aFillet1D = GetEngine()->AddObject(GEOM_FILLET_1D);
482 //Add a new Fillet function
483 Handle(GEOM_Function) aFunction =
484 aFillet1D->AddFunction(GEOMImpl_Fillet1dDriver::GetID(), FILLET_1D_SHAPE_VERTEXES);
485 if (aFunction.IsNull()) return NULL;
487 //Check if the function is set correctly
488 if (aFunction->GetDriverGUID() != GEOMImpl_Fillet1dDriver::GetID()) return NULL;
490 GEOMImpl_IFillet1d aCI (aFunction);
492 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
493 if (aRefShape.IsNull()) return NULL;
495 aCI.SetShape(aRefShape);
497 aCI.SetFlag(doIgnoreSecantVertices);
498 int aLen = theVertexes.size();
502 std::list<int>::iterator it = theVertexes.begin();
503 for (; it != theVertexes.end(); it++, ind++) {
504 aCI.SetVertex(ind, (*it));
507 //Compute the Fillet value
510 if (!GetSolver()->ComputeFunction(aFunction)) {
511 SetErrorCode("1D Fillet driver failed");
515 catch (Standard_Failure& aFail) {
516 SetErrorCode(aFail.GetMessageString());
520 //Make a Python command
521 GEOM::TPythonDump pd (aFunction);
522 pd << aFillet1D << " = geompy.MakeFillet1D(" << theShape
523 << ", " << theR << ", [";
525 it = theVertexes.begin();
526 if (it != theVertexes.end()) {
528 while (it != theVertexes.end())
529 pd << ", " << (*it++);
537 //=============================================================================
541 //=============================================================================
542 Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeChamferAll (Handle(GEOM_Object) theShape, double theD)
546 //Add a new Chamfer object
547 Handle(GEOM_Object) aChamfer = GetEngine()->AddObject(GEOM_CHAMFER);
549 //Add a new Chamfer function
550 Handle(GEOM_Function) aFunction =
551 aChamfer->AddFunction(GEOMImpl_ChamferDriver::GetID(), CHAMFER_SHAPE_ALL);
552 if (aFunction.IsNull()) return NULL;
554 //Check if the function is set correctly
555 if (aFunction->GetDriverGUID() != GEOMImpl_ChamferDriver::GetID()) return NULL;
557 GEOMImpl_IChamfer aCI (aFunction);
559 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
560 if (aRefShape.IsNull()) return NULL;
562 aCI.SetShape(aRefShape);
565 //Compute the Chamfer value
568 if (!GetSolver()->ComputeFunction(aFunction)) {
569 SetErrorCode("Chamfer driver failed");
573 catch (Standard_Failure& aFail) {
574 SetErrorCode(aFail.GetMessageString());
578 //Make a Python command
579 GEOM::TPythonDump(aFunction) << aChamfer << " = geompy.MakeChamferAll("
580 << theShape << ", " << theD << ")";
586 //=============================================================================
590 //=============================================================================
591 Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeChamferEdge
592 (Handle(GEOM_Object) theShape, double theD1, double theD2,
593 int theFace1, int theFace2)
597 //Add a new Chamfer object
598 Handle(GEOM_Object) aChamfer = GetEngine()->AddObject(GEOM_CHAMFER);
600 //Add a new Chamfer function
601 Handle(GEOM_Function) aFunction =
602 aChamfer->AddFunction(GEOMImpl_ChamferDriver::GetID(), CHAMFER_SHAPE_EDGE);
603 if (aFunction.IsNull()) return NULL;
605 //Check if the function is set correctly
606 if (aFunction->GetDriverGUID() != GEOMImpl_ChamferDriver::GetID()) return NULL;
608 GEOMImpl_IChamfer aCI (aFunction);
610 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
611 if (aRefShape.IsNull()) return NULL;
613 aCI.SetShape(aRefShape);
616 aCI.SetFace1(theFace1);
617 aCI.SetFace2(theFace2);
619 //Compute the Chamfer value
622 if (!GetSolver()->ComputeFunction(aFunction)) {
623 SetErrorCode("Chamfer driver failed");
627 catch (Standard_Failure& aFail) {
628 SetErrorCode(aFail.GetMessageString());
632 //Make a Python command
633 GEOM::TPythonDump(aFunction) << aChamfer
634 << " = geompy.MakeChamferEdge(" << theShape << ", " << theD1
635 << ", " << theD2 << ", " << theFace1 << ", " << theFace2 << ")";
641 //=============================================================================
645 //=============================================================================
646 Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeChamferEdgeAD
647 (Handle(GEOM_Object) theShape, double theD, double theAngle,
648 int theFace1, int theFace2)
652 //Add a new Chamfer object
653 Handle(GEOM_Object) aChamfer = GetEngine()->AddObject(GEOM_CHAMFER);
655 //Add a new Chamfer function
656 Handle(GEOM_Function) aFunction =
657 aChamfer->AddFunction(GEOMImpl_ChamferDriver::GetID(), CHAMFER_SHAPE_EDGE_AD);
658 if (aFunction.IsNull()) return NULL;
660 //Check if the function is set correctly
661 if (aFunction->GetDriverGUID() != GEOMImpl_ChamferDriver::GetID()) return NULL;
663 GEOMImpl_IChamfer aCI (aFunction);
665 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
666 if (aRefShape.IsNull()) return NULL;
668 aCI.SetShape(aRefShape);
670 aCI.SetAngle(theAngle);
671 aCI.SetFace1(theFace1);
672 aCI.SetFace2(theFace2);
674 //Compute the Chamfer value
677 if (!GetSolver()->ComputeFunction(aFunction)) {
678 SetErrorCode("Chamfer driver failed");
682 catch (Standard_Failure& aFail) {
683 SetErrorCode(aFail.GetMessageString());
687 //Make a Python command
688 GEOM::TPythonDump(aFunction) << aChamfer
689 << " = geompy.MakeChamferEdgeAD(" << theShape << ", " << theD
690 << ", " << theAngle << ", " << theFace1 << ", " << theFace2 << ")";
695 //=============================================================================
699 //=============================================================================
700 Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeChamferFaces
701 (Handle(GEOM_Object) theShape, double theD1, double theD2,
702 std::list<int> theFaces)
706 //Add a new Chamfer object
707 Handle(GEOM_Object) aChamfer = GetEngine()->AddObject(GEOM_CHAMFER);
709 //Add a new Chamfer function
710 Handle(GEOM_Function) aFunction =
711 aChamfer->AddFunction(GEOMImpl_ChamferDriver::GetID(), CHAMFER_SHAPE_FACES);
712 if (aFunction.IsNull()) return NULL;
714 //Check if the function is set correctly
715 if (aFunction->GetDriverGUID() != GEOMImpl_ChamferDriver::GetID()) return NULL;
717 GEOMImpl_IChamfer aCI (aFunction);
719 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
720 if (aRefShape.IsNull()) return NULL;
722 aCI.SetShape(aRefShape);
725 int aLen = theFaces.size();
729 std::list<int>::iterator it = theFaces.begin();
730 for (; it != theFaces.end(); it++, ind++) {
731 aCI.SetFace(ind, (*it));
734 //Compute the Chamfer value
737 if (!GetSolver()->ComputeFunction(aFunction)) {
738 SetErrorCode("Chamfer driver failed");
742 catch (Standard_Failure& aFail) {
743 SetErrorCode(aFail.GetMessageString());
747 //Make a Python command
748 GEOM::TPythonDump pd (aFunction);
749 pd << aChamfer << " = geompy.MakeChamferFaces(" << theShape
750 << ", " << theD1 << ", " << theD2 << ", [";
752 it = theFaces.begin();
754 while (it != theFaces.end()) {
755 pd << ", " << (*it++);
763 //=============================================================================
767 //=============================================================================
768 Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeChamferFacesAD
769 (Handle(GEOM_Object) theShape, double theD, double theAngle,
770 std::list<int> theFaces)
774 //Add a new Chamfer object
775 Handle(GEOM_Object) aChamfer = GetEngine()->AddObject(GEOM_CHAMFER);
777 //Add a new Chamfer function
778 Handle(GEOM_Function) aFunction =
779 aChamfer->AddFunction(GEOMImpl_ChamferDriver::GetID(), CHAMFER_SHAPE_FACES_AD);
780 if (aFunction.IsNull()) return NULL;
782 //Check if the function is set correctly
783 if (aFunction->GetDriverGUID() != GEOMImpl_ChamferDriver::GetID()) return NULL;
785 GEOMImpl_IChamfer aCI (aFunction);
787 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
788 if (aRefShape.IsNull()) return NULL;
790 aCI.SetShape(aRefShape);
792 aCI.SetAngle(theAngle);
793 int aLen = theFaces.size();
797 std::list<int>::iterator it = theFaces.begin();
798 for (; it != theFaces.end(); it++, ind++) {
799 aCI.SetFace(ind, (*it));
802 //Compute the Chamfer value
805 if (!GetSolver()->ComputeFunction(aFunction)) {
806 SetErrorCode("Chamfer driver failed");
810 catch (Standard_Failure& aFail) {
811 SetErrorCode(aFail.GetMessageString());
815 //Make a Python command
816 GEOM::TPythonDump pd (aFunction);
817 pd << aChamfer << " = geompy.MakeChamferFacesAD(" << theShape
818 << ", " << theD << ", " << theAngle << ", [";
820 it = theFaces.begin();
822 while (it != theFaces.end()) {
823 pd << ", " << (*it++);
831 //=============================================================================
835 //=============================================================================
836 Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeChamferEdges
837 (Handle(GEOM_Object) theShape, double theD1, double theD2,
838 std::list<int> theEdges)
842 //Add a new Chamfer object
843 Handle(GEOM_Object) aChamfer = GetEngine()->AddObject(GEOM_CHAMFER);
845 //Add a new Chamfer function
846 Handle(GEOM_Function) aFunction =
847 aChamfer->AddFunction(GEOMImpl_ChamferDriver::GetID(), CHAMFER_SHAPE_EDGES);
848 if (aFunction.IsNull()) { MESSAGE ( "Edges Function is NULL!!!" ); return NULL;}
850 //Check if the function is set correctly
851 if (aFunction->GetDriverGUID() != GEOMImpl_ChamferDriver::GetID())
852 { MESSAGE ( "Chamfer Driver is NULL!!!" ); return NULL; }
854 GEOMImpl_IChamfer aCI (aFunction);
856 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
857 if (aRefShape.IsNull()) { MESSAGE ("Shape is NULL!!!"); return NULL;}
859 aCI.SetShape(aRefShape);
862 int aLen = theEdges.size();
866 std::list<int>::iterator it = theEdges.begin();
867 for (; it != theEdges.end(); it++, ind++) {
868 aCI.SetEdge(ind, (*it));
871 //Compute the Chamfer value
874 if (!GetSolver()->ComputeFunction(aFunction)) {
875 SetErrorCode("Chamfer driver failed");
879 catch (Standard_Failure& aFail) {
880 SetErrorCode(aFail.GetMessageString());
884 //Make a Python command
885 GEOM::TPythonDump pd (aFunction);
886 pd << aChamfer << " = geompy.MakeChamferEdges(" << theShape
887 << ", " << theD1 << ", " << theD2 << ", [";
889 it = theEdges.begin();
891 while (it != theEdges.end()) {
892 pd << ", " << (*it++);
900 //=============================================================================
904 //=============================================================================
905 Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeChamferEdgesAD
906 (Handle(GEOM_Object) theShape, double theD, double theAngle,
907 std::list<int> theEdges)
911 //Add a new Chamfer object
912 Handle(GEOM_Object) aChamfer = GetEngine()->AddObject(GEOM_CHAMFER);
914 //Add a new Chamfer function
915 Handle(GEOM_Function) aFunction =
916 aChamfer->AddFunction(GEOMImpl_ChamferDriver::GetID(), CHAMFER_SHAPE_EDGES_AD);
917 if (aFunction.IsNull()) { MESSAGE ( "Edges Function is NULL!!!" ); return NULL; }
919 //Check if the function is set correctly
920 if (aFunction->GetDriverGUID() != GEOMImpl_ChamferDriver::GetID())
921 { MESSAGE("Chamfer Driver is NULL!!!"); return NULL;}
923 GEOMImpl_IChamfer aCI (aFunction);
925 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
926 if (aRefShape.IsNull()) { MESSAGE ("Shape is NULL!!!"); return NULL;}
928 aCI.SetShape(aRefShape);
930 aCI.SetAngle(theAngle);
931 int aLen = theEdges.size();
935 std::list<int>::iterator it = theEdges.begin();
936 for (; it != theEdges.end(); it++, ind++) {
937 aCI.SetEdge(ind, (*it));
940 //Compute the Chamfer value
943 if (!GetSolver()->ComputeFunction(aFunction)) {
944 SetErrorCode("Chamfer driver failed");
948 catch (Standard_Failure& aFail) {
949 SetErrorCode(aFail.GetMessageString());
953 //Make a Python command
954 GEOM::TPythonDump pd (aFunction);
955 pd << aChamfer << " = geompy.MakeChamferEdgesAD(" << theShape
956 << ", " << theD << ", " << theAngle << ", [";
958 it = theEdges.begin();
960 while (it != theEdges.end()) {
961 pd << ", " << (*it++);
969 //=============================================================================
973 //=============================================================================
974 Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeArchimede (Handle(GEOM_Object) theShape,
976 double theWaterDensity,
977 double theMeshingDeflection)
981 //Add a new Archimede object
982 Handle(GEOM_Object) aChamfer = GetEngine()->AddObject(GEOM_ARCHIMEDE);
984 //Add a new Archimede function
985 Handle(GEOM_Function) aFunction = aChamfer->AddFunction(GEOMImpl_ArchimedeDriver::GetID(), ARCHIMEDE_TYPE);
986 if (aFunction.IsNull()) return NULL;
988 //Check if the function is set correctly
989 if (aFunction->GetDriverGUID() != GEOMImpl_ArchimedeDriver::GetID()) return NULL;
991 GEOMImpl_IArchimede aAI (aFunction);
993 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
994 if (aRefShape.IsNull()) return NULL;
996 aAI.SetBasicShape(aRefShape);
997 aAI.SetWeight(theWeight);
998 aAI.SetDensity(theWaterDensity);
999 aAI.SetDeflection(theMeshingDeflection);
1001 //Compute the Archimede value
1004 if (!GetSolver()->ComputeFunction(aFunction)) {
1005 SetErrorCode("Archimede driver failed");
1009 catch (Standard_Failure& aFail) {
1010 SetErrorCode(aFail.GetMessageString());
1014 //Make a Python command
1015 GEOM::TPythonDump(aFunction) << aChamfer
1016 << " = geompy.Archimede(" << theShape << ", " << theWeight << ", "
1017 << theWaterDensity << ", " << theMeshingDeflection << ")";
1023 //=============================================================================
1027 //=============================================================================
1028 bool GEOMImpl_ILocalOperations::GetSubShape (const TopoDS_Shape& theShape, const int theIndex,
1029 TopoDS_Shape& theSubShape)
1031 if (theShape.IsNull() || theIndex < 1)
1034 TopTools_IndexedMapOfShape anIndices;
1035 TopExp::MapShapes(theShape, anIndices);
1036 if (theIndex > anIndices.Extent()) return false;
1037 theSubShape = anIndices.FindKey(theIndex);
1042 //=============================================================================
1046 //=============================================================================
1047 Standard_Integer GEOMImpl_ILocalOperations::GetSubShapeIndex (Handle(GEOM_Object) theShape,
1048 Handle(GEOM_Object) theSubShape)
1052 Standard_Integer anInd = -1;
1053 GEOM_Engine* anEngine = GetEngine();
1054 //GEOMImpl_Gen* aGen = dynamic_cast<GEOMImpl_Gen*>(anEngine);
1055 GEOMImpl_Gen* aGen = (GEOMImpl_Gen*)anEngine;
1058 GEOMImpl_IShapesOperations* anIShapesOperations =
1059 aGen->GetIShapesOperations();
1060 anInd = anIShapesOperations->GetSubShapeIndex(theShape, theSubShape);
1061 SetErrorCode(anIShapesOperations->GetErrorCode());