1 // Copyright (C) 2007-2024 CEA, EDF, 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"
49 #include <Utils_ExceptHandlers.hxx>
51 #include <TFunction_DriverTable.hxx>
52 #include <TFunction_Driver.hxx>
53 #include <TDF_Tool.hxx>
56 #include <TopoDS_TShape.hxx>
57 #include <TopTools_IndexedMapOfShape.hxx>
59 #include <Standard_Failure.hxx>
60 #include <Standard_ErrorHandler.hxx> // CAREFUL ! position of this file is critic : see Lucien PIGNOLONI / OCC
62 //=============================================================================
66 //=============================================================================
67 GEOMImpl_ILocalOperations::GEOMImpl_ILocalOperations (GEOM_Engine* theEngine)
68 : GEOM_IOperations(theEngine)
70 MESSAGE("GEOMImpl_ILocalOperations::GEOMImpl_ILocalOperations");
73 //=============================================================================
77 //=============================================================================
78 GEOMImpl_ILocalOperations::~GEOMImpl_ILocalOperations()
80 MESSAGE("GEOMImpl_ILocalOperations::~GEOMImpl_ILocalOperations");
84 //=============================================================================
88 //=============================================================================
89 Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeFilletAll
90 (Handle(GEOM_Object) theShape, double theR)
94 //Add a new Fillet object
95 Handle(GEOM_Object) aFillet = GetEngine()->AddObject(GEOM_FILLET);
97 //Add a new Fillet function
98 Handle(GEOM_Function) aFunction =
99 aFillet->AddFunction(GEOMImpl_FilletDriver::GetID(), FILLET_SHAPE_ALL);
100 if (aFunction.IsNull()) return NULL;
102 //Check if the function is set correctly
103 if (aFunction->GetDriverGUID() != GEOMImpl_FilletDriver::GetID()) return NULL;
105 GEOMImpl_IFillet aCI (aFunction);
107 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
108 if (aRefShape.IsNull()) return NULL;
110 aCI.SetShape(aRefShape);
113 //Compute the Fillet value
116 if (!GetSolver()->ComputeFunction(aFunction)) {
117 SetErrorCode("Fillet driver failed");
121 catch (Standard_Failure& aFail) {
122 SetErrorCode(aFail.GetMessageString());
126 //Make a Python command
127 GEOM::TPythonDump(aFunction) << aFillet << " = geompy.MakeFilletAll("
128 << theShape << ", " << theR << ")";
134 //=============================================================================
138 //=============================================================================
139 Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeFilletEdges
140 (Handle(GEOM_Object) theShape, double theR, std::list<int> theEdges)
144 //Add a new Fillet object
145 Handle(GEOM_Object) aFillet = GetEngine()->AddObject(GEOM_FILLET);
147 //Add a new Fillet function
148 Handle(GEOM_Function) aFunction =
149 aFillet->AddFunction(GEOMImpl_FilletDriver::GetID(), FILLET_SHAPE_EDGES);
150 if (aFunction.IsNull()) return NULL;
152 //Check if the function is set correctly
153 if (aFunction->GetDriverGUID() != GEOMImpl_FilletDriver::GetID()) return NULL;
155 GEOMImpl_IFillet aCI (aFunction);
157 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
158 if (aRefShape.IsNull()) return NULL;
160 aCI.SetShape(aRefShape);
162 int aLen = theEdges.size();
166 std::list<int>::iterator it = theEdges.begin();
167 for (; it != theEdges.end(); it++, ind++) {
168 aCI.SetEdge(ind, (*it));
171 //Compute the Fillet value
174 if (!GetSolver()->ComputeFunction(aFunction)) {
175 SetErrorCode("Fillet driver failed");
179 catch (Standard_Failure& aFail) {
180 SetErrorCode(aFail.GetMessageString());
184 //Make a Python command
185 GEOM::TPythonDump pd (aFunction);
186 pd << aFillet << " = geompy.MakeFillet(" << theShape
187 << ", " << theR << ", geompy.ShapeType[\"EDGE\"], [";
189 it = theEdges.begin();
191 while (it != theEdges.end()) {
192 pd << ", " << (*it++);
200 //=============================================================================
202 * MakeFilletEdges R1 R2
204 //=============================================================================
205 Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeFilletEdgesR1R2
206 (Handle(GEOM_Object) theShape, double theR1, double theR2, std::list<int> theEdges)
210 //Add a new Fillet object
211 Handle(GEOM_Object) aFillet = GetEngine()->AddObject(GEOM_FILLET);
213 //Add a new Fillet function
214 Handle(GEOM_Function) aFunction =
215 aFillet->AddFunction(GEOMImpl_FilletDriver::GetID(), FILLET_SHAPE_EDGES_2R);
216 if (aFunction.IsNull()) return NULL;
218 //Check if the function is set correctly
219 if (aFunction->GetDriverGUID() != GEOMImpl_FilletDriver::GetID()) return NULL;
221 GEOMImpl_IFillet aCI (aFunction);
223 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
224 if (aRefShape.IsNull()) return NULL;
226 aCI.SetShape(aRefShape);
229 int aLen = theEdges.size();
233 std::list<int>::iterator it = theEdges.begin();
234 for (; it != theEdges.end(); it++, ind++) {
235 aCI.SetEdge(ind, (*it));
238 //Compute the Fillet value
241 if (!GetSolver()->ComputeFunction(aFunction)) {
242 SetErrorCode("Fillet driver failed");
246 catch (Standard_Failure& aFail) {
247 SetErrorCode(aFail.GetMessageString());
251 //Make a Python command
252 GEOM::TPythonDump pd (aFunction);
253 pd << aFillet << " = geompy.MakeFilletR1R2(" << theShape
254 << ", " << theR1 << ", " <<theR2 << ", geompy.ShapeType[\"EDGE\"], [";
256 it = theEdges.begin();
258 while (it != theEdges.end()) {
259 pd << ", " << (*it++);
268 //=============================================================================
272 //=============================================================================
273 Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeFilletFaces
274 (Handle(GEOM_Object) theShape, double theR, std::list<int> theFaces)
278 //Add a new Fillet object
279 Handle(GEOM_Object) aFillet = GetEngine()->AddObject(GEOM_FILLET);
281 //Add a new Fillet function
282 Handle(GEOM_Function) aFunction =
283 aFillet->AddFunction(GEOMImpl_FilletDriver::GetID(), FILLET_SHAPE_FACES);
284 if (aFunction.IsNull()) return NULL;
286 //Check if the function is set correctly
287 if (aFunction->GetDriverGUID() != GEOMImpl_FilletDriver::GetID()) return NULL;
289 GEOMImpl_IFillet aCI (aFunction);
291 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
292 if (aRefShape.IsNull()) return NULL;
294 aCI.SetShape(aRefShape);
296 int aLen = theFaces.size();
300 std::list<int>::iterator it = theFaces.begin();
301 for (; it != theFaces.end(); it++, ind++) {
302 aCI.SetFace(ind, (*it));
305 //Compute the Fillet value
308 if (!GetSolver()->ComputeFunction(aFunction)) {
309 SetErrorCode("Fillet driver failed");
313 catch (Standard_Failure& aFail) {
314 SetErrorCode(aFail.GetMessageString());
318 //Make a Python command
319 GEOM::TPythonDump pd (aFunction);
320 pd << aFillet << " = geompy.MakeFillet(" << theShape
321 << ", " << theR << ", geompy.ShapeType[\"FACE\"], [";
323 it = theFaces.begin();
325 while (it != theFaces.end()) {
326 pd << ", " << (*it++);
334 //=============================================================================
336 * MakeFilletFaces R1 R2
338 //=============================================================================
339 Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeFilletFacesR1R2
340 (Handle(GEOM_Object) theShape, double theR1, double theR2, std::list<int> theFaces)
344 //Add a new Fillet object
345 Handle(GEOM_Object) aFillet = GetEngine()->AddObject(GEOM_FILLET);
347 //Add a new Fillet function
348 Handle(GEOM_Function) aFunction =
349 aFillet->AddFunction(GEOMImpl_FilletDriver::GetID(), FILLET_SHAPE_FACES_2R);
350 if (aFunction.IsNull()) return NULL;
352 //Check if the function is set correctly
353 if (aFunction->GetDriverGUID() != GEOMImpl_FilletDriver::GetID()) return NULL;
355 GEOMImpl_IFillet aCI (aFunction);
357 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
358 if (aRefShape.IsNull()) return NULL;
360 aCI.SetShape(aRefShape);
363 int aLen = theFaces.size();
367 std::list<int>::iterator it = theFaces.begin();
368 for (; it != theFaces.end(); it++, ind++) {
369 aCI.SetFace(ind, (*it));
372 //Compute the Fillet value
375 if (!GetSolver()->ComputeFunction(aFunction)) {
376 SetErrorCode("Fillet driver failed");
380 catch (Standard_Failure& aFail) {
381 SetErrorCode(aFail.GetMessageString());
385 //Make a Python command
386 GEOM::TPythonDump pd (aFunction);
387 pd << aFillet << " = geompy.MakeFilletR1R2(" << theShape
388 << ", " << theR1 << ", " << theR2 << ", geompy.ShapeType[\"FACE\"], [";
390 it = theFaces.begin();
392 while (it != theFaces.end()) {
393 pd << ", " << (*it++);
401 //=============================================================================
405 //=============================================================================
406 Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeFillet2D
407 (Handle(GEOM_Object) theShape, double theR, std::list<int> theVertexes)
411 //Add a new Fillet object
412 Handle(GEOM_Object) aFillet2D = GetEngine()->AddObject(GEOM_FILLET_2D);
414 //Add a new Fillet function
415 Handle(GEOM_Function) aFunction =
416 aFillet2D->AddFunction(GEOMImpl_Fillet2dDriver::GetID(), FILLET_2D_SHAPE_VERTEXES);
417 if (aFunction.IsNull()) return NULL;
419 //Check if the function is set correctly
420 if (aFunction->GetDriverGUID() != GEOMImpl_Fillet2dDriver::GetID()) return NULL;
422 GEOMImpl_IFillet2d aCI (aFunction);
424 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
425 if (aRefShape.IsNull()) return NULL;
427 aCI.SetShape(aRefShape);
429 int aLen = theVertexes.size();
433 std::list<int>::iterator it = theVertexes.begin();
434 for (; it != theVertexes.end(); it++, ind++) {
435 aCI.SetVertex(ind, (*it));
438 //Compute the Fillet value
441 if (!GetSolver()->ComputeFunction(aFunction)) {
442 SetErrorCode("2D Fillet driver failed");
446 catch (Standard_Failure& aFail) {
447 SetErrorCode(aFail.GetMessageString());
451 //Make a Python command
452 GEOM::TPythonDump pd (aFunction);
453 pd << aFillet2D << " = geompy.MakeFillet2D(" << theShape
454 << ", " << theR << ", [";
456 it = theVertexes.begin();
458 while (it != theVertexes.end()) {
459 pd << ", " << (*it++);
467 //=============================================================================
471 //=============================================================================
472 Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeFillet1D
473 (Handle(GEOM_Object) theShape, double theR,
474 std::list<int> theVertexes, bool doIgnoreSecantVertices)
478 //Add a new Fillet object
479 Handle(GEOM_Object) aFillet1D = GetEngine()->AddObject(GEOM_FILLET_1D);
481 //Add a new Fillet function
482 Handle(GEOM_Function) aFunction =
483 aFillet1D->AddFunction(GEOMImpl_Fillet1dDriver::GetID(), FILLET_1D_SHAPE_VERTEXES);
484 if (aFunction.IsNull()) return NULL;
486 //Check if the function is set correctly
487 if (aFunction->GetDriverGUID() != GEOMImpl_Fillet1dDriver::GetID()) return NULL;
489 GEOMImpl_IFillet1d aCI (aFunction);
491 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
492 if (aRefShape.IsNull()) return NULL;
494 aCI.SetShape(aRefShape);
496 aCI.SetFlag(doIgnoreSecantVertices);
497 int aLen = theVertexes.size();
501 std::list<int>::iterator it = theVertexes.begin();
502 for (; it != theVertexes.end(); it++, ind++) {
503 aCI.SetVertex(ind, (*it));
506 //Compute the Fillet value
509 if (!GetSolver()->ComputeFunction(aFunction)) {
510 SetErrorCode("1D Fillet driver failed");
514 catch (Standard_Failure& aFail) {
515 SetErrorCode(aFail.GetMessageString());
519 //Make a Python command
520 GEOM::TPythonDump pd (aFunction);
521 pd << aFillet1D << " = geompy.MakeFillet1D(" << theShape
522 << ", " << theR << ", [";
524 it = theVertexes.begin();
525 if (it != theVertexes.end()) {
527 while (it != theVertexes.end())
528 pd << ", " << (*it++);
536 //=============================================================================
540 //=============================================================================
541 Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeChamferAll (Handle(GEOM_Object) theShape, double theD)
545 //Add a new Chamfer object
546 Handle(GEOM_Object) aChamfer = GetEngine()->AddObject(GEOM_CHAMFER);
548 //Add a new Chamfer function
549 Handle(GEOM_Function) aFunction =
550 aChamfer->AddFunction(GEOMImpl_ChamferDriver::GetID(), CHAMFER_SHAPE_ALL);
551 if (aFunction.IsNull()) return NULL;
553 //Check if the function is set correctly
554 if (aFunction->GetDriverGUID() != GEOMImpl_ChamferDriver::GetID()) return NULL;
556 GEOMImpl_IChamfer aCI (aFunction);
558 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
559 if (aRefShape.IsNull()) return NULL;
561 aCI.SetShape(aRefShape);
564 //Compute the Chamfer value
567 if (!GetSolver()->ComputeFunction(aFunction)) {
568 SetErrorCode("Chamfer driver failed");
572 catch (Standard_Failure& aFail) {
573 SetErrorCode(aFail.GetMessageString());
577 //Make a Python command
578 GEOM::TPythonDump(aFunction) << aChamfer << " = geompy.MakeChamferAll("
579 << theShape << ", " << theD << ")";
585 //=============================================================================
589 //=============================================================================
590 Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeChamferEdge
591 (Handle(GEOM_Object) theShape, double theD1, double theD2,
592 int theFace1, int theFace2)
596 //Add a new Chamfer object
597 Handle(GEOM_Object) aChamfer = GetEngine()->AddObject(GEOM_CHAMFER);
599 //Add a new Chamfer function
600 Handle(GEOM_Function) aFunction =
601 aChamfer->AddFunction(GEOMImpl_ChamferDriver::GetID(), CHAMFER_SHAPE_EDGE);
602 if (aFunction.IsNull()) return NULL;
604 //Check if the function is set correctly
605 if (aFunction->GetDriverGUID() != GEOMImpl_ChamferDriver::GetID()) return NULL;
607 GEOMImpl_IChamfer aCI (aFunction);
609 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
610 if (aRefShape.IsNull()) return NULL;
612 aCI.SetShape(aRefShape);
615 aCI.SetFace1(theFace1);
616 aCI.SetFace2(theFace2);
618 //Compute the Chamfer value
621 if (!GetSolver()->ComputeFunction(aFunction)) {
622 SetErrorCode("Chamfer driver failed");
626 catch (Standard_Failure& aFail) {
627 SetErrorCode(aFail.GetMessageString());
631 //Make a Python command
632 GEOM::TPythonDump(aFunction) << aChamfer
633 << " = geompy.MakeChamferEdge(" << theShape << ", " << theD1
634 << ", " << theD2 << ", " << theFace1 << ", " << theFace2 << ")";
640 //=============================================================================
644 //=============================================================================
645 Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeChamferEdgeAD
646 (Handle(GEOM_Object) theShape, double theD, double theAngle,
647 int theFace1, int theFace2)
651 //Add a new Chamfer object
652 Handle(GEOM_Object) aChamfer = GetEngine()->AddObject(GEOM_CHAMFER);
654 //Add a new Chamfer function
655 Handle(GEOM_Function) aFunction =
656 aChamfer->AddFunction(GEOMImpl_ChamferDriver::GetID(), CHAMFER_SHAPE_EDGE_AD);
657 if (aFunction.IsNull()) return NULL;
659 //Check if the function is set correctly
660 if (aFunction->GetDriverGUID() != GEOMImpl_ChamferDriver::GetID()) return NULL;
662 GEOMImpl_IChamfer aCI (aFunction);
664 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
665 if (aRefShape.IsNull()) return NULL;
667 aCI.SetShape(aRefShape);
669 aCI.SetAngle(theAngle);
670 aCI.SetFace1(theFace1);
671 aCI.SetFace2(theFace2);
673 //Compute the Chamfer value
676 if (!GetSolver()->ComputeFunction(aFunction)) {
677 SetErrorCode("Chamfer driver failed");
681 catch (Standard_Failure& aFail) {
682 SetErrorCode(aFail.GetMessageString());
686 //Make a Python command
687 GEOM::TPythonDump(aFunction) << aChamfer
688 << " = geompy.MakeChamferEdgeAD(" << theShape << ", " << theD
689 << ", " << theAngle << ", " << theFace1 << ", " << theFace2 << ")";
694 //=============================================================================
698 //=============================================================================
699 Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeChamferFaces
700 (Handle(GEOM_Object) theShape, double theD1, double theD2,
701 std::list<int> theFaces)
705 //Add a new Chamfer object
706 Handle(GEOM_Object) aChamfer = GetEngine()->AddObject(GEOM_CHAMFER);
708 //Add a new Chamfer function
709 Handle(GEOM_Function) aFunction =
710 aChamfer->AddFunction(GEOMImpl_ChamferDriver::GetID(), CHAMFER_SHAPE_FACES);
711 if (aFunction.IsNull()) return NULL;
713 //Check if the function is set correctly
714 if (aFunction->GetDriverGUID() != GEOMImpl_ChamferDriver::GetID()) return NULL;
716 GEOMImpl_IChamfer aCI (aFunction);
718 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
719 if (aRefShape.IsNull()) return NULL;
721 aCI.SetShape(aRefShape);
724 int aLen = theFaces.size();
728 std::list<int>::iterator it = theFaces.begin();
729 for (; it != theFaces.end(); it++, ind++) {
730 aCI.SetFace(ind, (*it));
733 //Compute the Chamfer value
736 if (!GetSolver()->ComputeFunction(aFunction)) {
737 SetErrorCode("Chamfer driver failed");
741 catch (Standard_Failure& aFail) {
742 SetErrorCode(aFail.GetMessageString());
746 //Make a Python command
747 GEOM::TPythonDump pd (aFunction);
748 pd << aChamfer << " = geompy.MakeChamferFaces(" << theShape
749 << ", " << theD1 << ", " << theD2 << ", [";
751 it = theFaces.begin();
753 while (it != theFaces.end()) {
754 pd << ", " << (*it++);
762 //=============================================================================
766 //=============================================================================
767 Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeChamferFacesAD
768 (Handle(GEOM_Object) theShape, double theD, double theAngle,
769 std::list<int> theFaces)
773 //Add a new Chamfer object
774 Handle(GEOM_Object) aChamfer = GetEngine()->AddObject(GEOM_CHAMFER);
776 //Add a new Chamfer function
777 Handle(GEOM_Function) aFunction =
778 aChamfer->AddFunction(GEOMImpl_ChamferDriver::GetID(), CHAMFER_SHAPE_FACES_AD);
779 if (aFunction.IsNull()) return NULL;
781 //Check if the function is set correctly
782 if (aFunction->GetDriverGUID() != GEOMImpl_ChamferDriver::GetID()) return NULL;
784 GEOMImpl_IChamfer aCI (aFunction);
786 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
787 if (aRefShape.IsNull()) return NULL;
789 aCI.SetShape(aRefShape);
791 aCI.SetAngle(theAngle);
792 int aLen = theFaces.size();
796 std::list<int>::iterator it = theFaces.begin();
797 for (; it != theFaces.end(); it++, ind++) {
798 aCI.SetFace(ind, (*it));
801 //Compute the Chamfer value
804 if (!GetSolver()->ComputeFunction(aFunction)) {
805 SetErrorCode("Chamfer driver failed");
809 catch (Standard_Failure& aFail) {
810 SetErrorCode(aFail.GetMessageString());
814 //Make a Python command
815 GEOM::TPythonDump pd (aFunction);
816 pd << aChamfer << " = geompy.MakeChamferFacesAD(" << theShape
817 << ", " << theD << ", " << theAngle << ", [";
819 it = theFaces.begin();
821 while (it != theFaces.end()) {
822 pd << ", " << (*it++);
830 //=============================================================================
834 //=============================================================================
835 Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeChamferEdges
836 (Handle(GEOM_Object) theShape, double theD1, double theD2,
837 std::list<int> theEdges)
841 //Add a new Chamfer object
842 Handle(GEOM_Object) aChamfer = GetEngine()->AddObject(GEOM_CHAMFER);
844 //Add a new Chamfer function
845 Handle(GEOM_Function) aFunction =
846 aChamfer->AddFunction(GEOMImpl_ChamferDriver::GetID(), CHAMFER_SHAPE_EDGES);
847 if (aFunction.IsNull()) { MESSAGE ( "Edges Function is NULL!!!" ); return NULL;}
849 //Check if the function is set correctly
850 if (aFunction->GetDriverGUID() != GEOMImpl_ChamferDriver::GetID())
851 { MESSAGE ( "Chamfer Driver is NULL!!!" ); return NULL; }
853 GEOMImpl_IChamfer aCI (aFunction);
855 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
856 if (aRefShape.IsNull()) { MESSAGE ("Shape is NULL!!!"); return NULL;}
858 aCI.SetShape(aRefShape);
861 int aLen = theEdges.size();
865 std::list<int>::iterator it = theEdges.begin();
866 for (; it != theEdges.end(); it++, ind++) {
867 aCI.SetEdge(ind, (*it));
870 //Compute the Chamfer value
873 if (!GetSolver()->ComputeFunction(aFunction)) {
874 SetErrorCode("Chamfer driver failed");
878 catch (Standard_Failure& aFail) {
879 SetErrorCode(aFail.GetMessageString());
883 //Make a Python command
884 GEOM::TPythonDump pd (aFunction);
885 pd << aChamfer << " = geompy.MakeChamferEdges(" << theShape
886 << ", " << theD1 << ", " << theD2 << ", [";
888 it = theEdges.begin();
890 while (it != theEdges.end()) {
891 pd << ", " << (*it++);
899 //=============================================================================
903 //=============================================================================
904 Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeChamferEdgesAD
905 (Handle(GEOM_Object) theShape, double theD, double theAngle,
906 std::list<int> theEdges)
910 //Add a new Chamfer object
911 Handle(GEOM_Object) aChamfer = GetEngine()->AddObject(GEOM_CHAMFER);
913 //Add a new Chamfer function
914 Handle(GEOM_Function) aFunction =
915 aChamfer->AddFunction(GEOMImpl_ChamferDriver::GetID(), CHAMFER_SHAPE_EDGES_AD);
916 if (aFunction.IsNull()) { MESSAGE ( "Edges Function is NULL!!!" ); return NULL; }
918 //Check if the function is set correctly
919 if (aFunction->GetDriverGUID() != GEOMImpl_ChamferDriver::GetID())
920 { MESSAGE("Chamfer Driver is NULL!!!"); return NULL;}
922 GEOMImpl_IChamfer aCI (aFunction);
924 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
925 if (aRefShape.IsNull()) { MESSAGE ("Shape is NULL!!!"); return NULL;}
927 aCI.SetShape(aRefShape);
929 aCI.SetAngle(theAngle);
930 int aLen = theEdges.size();
934 std::list<int>::iterator it = theEdges.begin();
935 for (; it != theEdges.end(); it++, ind++) {
936 aCI.SetEdge(ind, (*it));
939 //Compute the Chamfer value
942 if (!GetSolver()->ComputeFunction(aFunction)) {
943 SetErrorCode("Chamfer driver failed");
947 catch (Standard_Failure& aFail) {
948 SetErrorCode(aFail.GetMessageString());
952 //Make a Python command
953 GEOM::TPythonDump pd (aFunction);
954 pd << aChamfer << " = geompy.MakeChamferEdgesAD(" << theShape
955 << ", " << theD << ", " << theAngle << ", [";
957 it = theEdges.begin();
959 while (it != theEdges.end()) {
960 pd << ", " << (*it++);
968 //=============================================================================
972 //=============================================================================
973 Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeArchimede (Handle(GEOM_Object) theShape,
975 double theWaterDensity,
976 double theMeshingDeflection)
980 //Add a new Archimede object
981 Handle(GEOM_Object) aChamfer = GetEngine()->AddObject(GEOM_ARCHIMEDE);
983 //Add a new Archimede function
984 Handle(GEOM_Function) aFunction = aChamfer->AddFunction(GEOMImpl_ArchimedeDriver::GetID(), ARCHIMEDE_TYPE);
985 if (aFunction.IsNull()) return NULL;
987 //Check if the function is set correctly
988 if (aFunction->GetDriverGUID() != GEOMImpl_ArchimedeDriver::GetID()) return NULL;
990 GEOMImpl_IArchimede aAI (aFunction);
992 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
993 if (aRefShape.IsNull()) return NULL;
995 aAI.SetBasicShape(aRefShape);
996 aAI.SetWeight(theWeight);
997 aAI.SetDensity(theWaterDensity);
998 aAI.SetDeflection(theMeshingDeflection);
1000 //Compute the Archimede value
1003 if (!GetSolver()->ComputeFunction(aFunction)) {
1004 SetErrorCode("Archimede driver failed");
1008 catch (Standard_Failure& aFail) {
1009 SetErrorCode(aFail.GetMessageString());
1013 //Make a Python command
1014 GEOM::TPythonDump(aFunction) << aChamfer
1015 << " = geompy.Archimede(" << theShape << ", " << theWeight << ", "
1016 << theWaterDensity << ", " << theMeshingDeflection << ")";
1022 //=============================================================================
1026 //=============================================================================
1027 bool GEOMImpl_ILocalOperations::GetSubShape (const TopoDS_Shape& theShape, const int theIndex,
1028 TopoDS_Shape& theSubShape)
1030 if (theShape.IsNull() || theIndex < 1)
1033 TopTools_IndexedMapOfShape anIndices;
1034 TopExp::MapShapes(theShape, anIndices);
1035 if (theIndex > anIndices.Extent()) return false;
1036 theSubShape = anIndices.FindKey(theIndex);
1041 //=============================================================================
1045 //=============================================================================
1046 Standard_Integer GEOMImpl_ILocalOperations::GetSubShapeIndex (Handle(GEOM_Object) theShape,
1047 Handle(GEOM_Object) theSubShape)
1051 Standard_Integer anInd = -1;
1052 GEOM_Engine* anEngine = GetEngine();
1053 //GEOMImpl_Gen* aGen = dynamic_cast<GEOMImpl_Gen*>(anEngine);
1054 GEOMImpl_Gen* aGen = (GEOMImpl_Gen*)anEngine;
1057 GEOMImpl_IShapesOperations* anIShapesOperations =
1058 aGen->GetIShapesOperations();
1059 anInd = anIShapesOperations->GetSubShapeIndex(theShape, theSubShape);
1060 SetErrorCode(anIShapesOperations->GetErrorCode());