1 // Copyright (C) 2007-2016 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License, or (at your option) any later version.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
23 #include <Standard_Stream.hxx>
25 #include <GEOMImpl_ILocalOperations.hxx>
27 #include <GEOMImpl_Types.hxx>
29 #include <GEOMImpl_FilletDriver.hxx>
30 #include <GEOMImpl_Fillet1dDriver.hxx>
31 #include <GEOMImpl_Fillet2dDriver.hxx>
32 #include <GEOMImpl_ChamferDriver.hxx>
34 #include <GEOMImpl_IFillet.hxx>
35 #include <GEOMImpl_IFillet1d.hxx>
36 #include <GEOMImpl_IFillet2d.hxx>
37 #include <GEOMImpl_IChamfer.hxx>
39 #include <GEOMImpl_IArchimede.hxx>
40 #include <GEOMImpl_ArchimedeDriver.hxx>
42 #include <GEOMImpl_Gen.hxx>
43 #include <GEOMImpl_IShapesOperations.hxx>
45 #include <GEOM_Function.hxx>
46 #include <GEOM_PythonDump.hxx>
48 #include <Basics_OCCTVersion.hxx>
50 #include "utilities.h"
52 #include <Utils_ExceptHandlers.hxx>
54 #include <TFunction_DriverTable.hxx>
55 #include <TFunction_Driver.hxx>
56 #include <TDF_Tool.hxx>
59 #include <TopoDS_TShape.hxx>
60 #include <TopTools_IndexedMapOfShape.hxx>
62 #include <Standard_Failure.hxx>
63 #include <Standard_ErrorHandler.hxx> // CAREFUL ! position of this file is critic : see Lucien PIGNOLONI / OCC
65 //=============================================================================
69 //=============================================================================
70 GEOMImpl_ILocalOperations::GEOMImpl_ILocalOperations (GEOM_Engine* theEngine, int theDocID)
71 : GEOM_IOperations(theEngine, theDocID)
73 MESSAGE("GEOMImpl_ILocalOperations::GEOMImpl_ILocalOperations");
76 //=============================================================================
80 //=============================================================================
81 GEOMImpl_ILocalOperations::~GEOMImpl_ILocalOperations()
83 MESSAGE("GEOMImpl_ILocalOperations::~GEOMImpl_ILocalOperations");
87 //=============================================================================
91 //=============================================================================
92 Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeFilletAll
93 (Handle(GEOM_Object) theShape, double theR)
97 //Add a new Fillet object
98 Handle(GEOM_Object) aFillet = GetEngine()->AddObject(GetDocID(), GEOM_FILLET);
100 //Add a new Fillet function
101 Handle(GEOM_Function) aFunction =
102 aFillet->AddFunction(GEOMImpl_FilletDriver::GetID(), FILLET_SHAPE_ALL);
103 if (aFunction.IsNull()) return NULL;
105 //Check if the function is set correctly
106 if (aFunction->GetDriverGUID() != GEOMImpl_FilletDriver::GetID()) return NULL;
108 GEOMImpl_IFillet aCI (aFunction);
110 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
111 if (aRefShape.IsNull()) return NULL;
113 aCI.SetShape(aRefShape);
116 //Compute the Fillet value
119 if (!GetSolver()->ComputeFunction(aFunction)) {
120 SetErrorCode("Fillet driver failed");
124 catch (Standard_Failure) {
125 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
126 SetErrorCode(aFail->GetMessageString());
130 //Make a Python command
131 GEOM::TPythonDump(aFunction) << aFillet << " = geompy.MakeFilletAll("
132 << theShape << ", " << theR << ")";
138 //=============================================================================
142 //=============================================================================
143 Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeFilletEdges
144 (Handle(GEOM_Object) theShape, double theR, std::list<int> theEdges)
148 //Add a new Fillet object
149 Handle(GEOM_Object) aFillet = GetEngine()->AddObject(GetDocID(), GEOM_FILLET);
151 //Add a new Fillet function
152 Handle(GEOM_Function) aFunction =
153 aFillet->AddFunction(GEOMImpl_FilletDriver::GetID(), FILLET_SHAPE_EDGES);
154 if (aFunction.IsNull()) return NULL;
156 //Check if the function is set correctly
157 if (aFunction->GetDriverGUID() != GEOMImpl_FilletDriver::GetID()) return NULL;
159 GEOMImpl_IFillet aCI (aFunction);
161 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
162 if (aRefShape.IsNull()) return NULL;
164 aCI.SetShape(aRefShape);
166 int aLen = theEdges.size();
170 std::list<int>::iterator it = theEdges.begin();
171 for (; it != theEdges.end(); it++, ind++) {
172 aCI.SetEdge(ind, (*it));
175 //Compute the Fillet value
178 if (!GetSolver()->ComputeFunction(aFunction)) {
179 SetErrorCode("Fillet driver failed");
183 catch (Standard_Failure) {
184 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
185 SetErrorCode(aFail->GetMessageString());
189 //Make a Python command
190 GEOM::TPythonDump pd (aFunction);
191 pd << aFillet << " = geompy.MakeFillet(" << theShape
192 << ", " << theR << ", geompy.ShapeType[\"EDGE\"], [";
194 it = theEdges.begin();
196 while (it != theEdges.end()) {
197 pd << ", " << (*it++);
205 //=============================================================================
207 * MakeFilletEdges R1 R2
209 //=============================================================================
210 Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeFilletEdgesR1R2
211 (Handle(GEOM_Object) theShape, double theR1, double theR2, std::list<int> theEdges)
215 //Add a new Fillet object
216 Handle(GEOM_Object) aFillet = GetEngine()->AddObject(GetDocID(), GEOM_FILLET);
218 //Add a new Fillet function
219 Handle(GEOM_Function) aFunction =
220 aFillet->AddFunction(GEOMImpl_FilletDriver::GetID(), FILLET_SHAPE_EDGES_2R);
221 if (aFunction.IsNull()) return NULL;
223 //Check if the function is set correctly
224 if (aFunction->GetDriverGUID() != GEOMImpl_FilletDriver::GetID()) return NULL;
226 GEOMImpl_IFillet aCI (aFunction);
228 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
229 if (aRefShape.IsNull()) return NULL;
231 aCI.SetShape(aRefShape);
234 int aLen = theEdges.size();
238 std::list<int>::iterator it = theEdges.begin();
239 for (; it != theEdges.end(); it++, ind++) {
240 aCI.SetEdge(ind, (*it));
243 //Compute the Fillet value
246 if (!GetSolver()->ComputeFunction(aFunction)) {
247 SetErrorCode("Fillet driver failed");
251 catch (Standard_Failure) {
252 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
253 SetErrorCode(aFail->GetMessageString());
257 //Make a Python command
258 GEOM::TPythonDump pd (aFunction);
259 pd << aFillet << " = geompy.MakeFilletR1R2(" << theShape
260 << ", " << theR1 << ", " <<theR2 << ", geompy.ShapeType[\"EDGE\"], [";
262 it = theEdges.begin();
264 while (it != theEdges.end()) {
265 pd << ", " << (*it++);
274 //=============================================================================
278 //=============================================================================
279 Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeFilletFaces
280 (Handle(GEOM_Object) theShape, double theR, std::list<int> theFaces)
284 //Add a new Fillet object
285 Handle(GEOM_Object) aFillet = GetEngine()->AddObject(GetDocID(), GEOM_FILLET);
287 //Add a new Fillet function
288 Handle(GEOM_Function) aFunction =
289 aFillet->AddFunction(GEOMImpl_FilletDriver::GetID(), FILLET_SHAPE_FACES);
290 if (aFunction.IsNull()) return NULL;
292 //Check if the function is set correctly
293 if (aFunction->GetDriverGUID() != GEOMImpl_FilletDriver::GetID()) return NULL;
295 GEOMImpl_IFillet aCI (aFunction);
297 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
298 if (aRefShape.IsNull()) return NULL;
300 aCI.SetShape(aRefShape);
302 int aLen = theFaces.size();
306 std::list<int>::iterator it = theFaces.begin();
307 for (; it != theFaces.end(); it++, ind++) {
308 aCI.SetFace(ind, (*it));
311 //Compute the Fillet value
314 if (!GetSolver()->ComputeFunction(aFunction)) {
315 SetErrorCode("Fillet driver failed");
319 catch (Standard_Failure) {
320 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
321 SetErrorCode(aFail->GetMessageString());
325 //Make a Python command
326 GEOM::TPythonDump pd (aFunction);
327 pd << aFillet << " = geompy.MakeFillet(" << theShape
328 << ", " << theR << ", geompy.ShapeType[\"FACE\"], [";
330 it = theFaces.begin();
332 while (it != theFaces.end()) {
333 pd << ", " << (*it++);
341 //=============================================================================
343 * MakeFilletFaces R1 R2
345 //=============================================================================
346 Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeFilletFacesR1R2
347 (Handle(GEOM_Object) theShape, double theR1, double theR2, std::list<int> theFaces)
351 //Add a new Fillet object
352 Handle(GEOM_Object) aFillet = GetEngine()->AddObject(GetDocID(), GEOM_FILLET);
354 //Add a new Fillet function
355 Handle(GEOM_Function) aFunction =
356 aFillet->AddFunction(GEOMImpl_FilletDriver::GetID(), FILLET_SHAPE_FACES_2R);
357 if (aFunction.IsNull()) return NULL;
359 //Check if the function is set correctly
360 if (aFunction->GetDriverGUID() != GEOMImpl_FilletDriver::GetID()) return NULL;
362 GEOMImpl_IFillet aCI (aFunction);
364 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
365 if (aRefShape.IsNull()) return NULL;
367 aCI.SetShape(aRefShape);
370 int aLen = theFaces.size();
374 std::list<int>::iterator it = theFaces.begin();
375 for (; it != theFaces.end(); it++, ind++) {
376 aCI.SetFace(ind, (*it));
379 //Compute the Fillet value
382 if (!GetSolver()->ComputeFunction(aFunction)) {
383 SetErrorCode("Fillet driver failed");
387 catch (Standard_Failure) {
388 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
389 SetErrorCode(aFail->GetMessageString());
393 //Make a Python command
394 GEOM::TPythonDump pd (aFunction);
395 pd << aFillet << " = geompy.MakeFilletR1R2(" << theShape
396 << ", " << theR1 << ", " << theR2 << ", geompy.ShapeType[\"FACE\"], [";
398 it = theFaces.begin();
400 while (it != theFaces.end()) {
401 pd << ", " << (*it++);
409 //=============================================================================
413 //=============================================================================
414 Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeFillet2D
415 (Handle(GEOM_Object) theShape, double theR, std::list<int> theVertexes)
419 //Add a new Fillet object
420 Handle(GEOM_Object) aFillet2D = GetEngine()->AddObject(GetDocID(), GEOM_FILLET_2D);
422 //Add a new Fillet function
423 Handle(GEOM_Function) aFunction =
424 aFillet2D->AddFunction(GEOMImpl_Fillet2dDriver::GetID(), FILLET_2D_SHAPE_VERTEXES);
425 if (aFunction.IsNull()) return NULL;
427 //Check if the function is set correctly
428 if (aFunction->GetDriverGUID() != GEOMImpl_Fillet2dDriver::GetID()) return NULL;
430 GEOMImpl_IFillet2d aCI (aFunction);
432 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
433 if (aRefShape.IsNull()) return NULL;
435 aCI.SetShape(aRefShape);
437 int aLen = theVertexes.size();
441 std::list<int>::iterator it = theVertexes.begin();
442 for (; it != theVertexes.end(); it++, ind++) {
443 aCI.SetVertex(ind, (*it));
446 //Compute the Fillet value
449 if (!GetSolver()->ComputeFunction(aFunction)) {
450 SetErrorCode("2D Fillet driver failed");
454 catch (Standard_Failure) {
455 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
456 SetErrorCode(aFail->GetMessageString());
460 //Make a Python command
461 GEOM::TPythonDump pd (aFunction);
462 pd << aFillet2D << " = geompy.MakeFillet2D(" << theShape
463 << ", " << theR << ", [";
465 it = theVertexes.begin();
467 while (it != theVertexes.end()) {
468 pd << ", " << (*it++);
476 //=============================================================================
480 //=============================================================================
481 Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeFillet1D
482 (Handle(GEOM_Object) theShape, double theR,
483 std::list<int> theVertexes, bool doIgnoreSecantVertices)
487 //Add a new Fillet object
488 Handle(GEOM_Object) aFillet1D = GetEngine()->AddObject(GetDocID(), GEOM_FILLET_1D);
490 //Add a new Fillet function
491 Handle(GEOM_Function) aFunction =
492 aFillet1D->AddFunction(GEOMImpl_Fillet1dDriver::GetID(), FILLET_1D_SHAPE_VERTEXES);
493 if (aFunction.IsNull()) return NULL;
495 //Check if the function is set correctly
496 if (aFunction->GetDriverGUID() != GEOMImpl_Fillet1dDriver::GetID()) return NULL;
498 GEOMImpl_IFillet1d aCI (aFunction);
500 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
501 if (aRefShape.IsNull()) return NULL;
503 aCI.SetShape(aRefShape);
505 aCI.SetFlag(doIgnoreSecantVertices);
506 int aLen = theVertexes.size();
510 std::list<int>::iterator it = theVertexes.begin();
511 for (; it != theVertexes.end(); it++, ind++) {
512 aCI.SetVertex(ind, (*it));
515 //Compute the Fillet value
518 if (!GetSolver()->ComputeFunction(aFunction)) {
519 SetErrorCode("1D Fillet driver failed");
523 catch (Standard_Failure) {
524 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
525 SetErrorCode(aFail->GetMessageString());
529 //Make a Python command
530 GEOM::TPythonDump pd (aFunction);
531 pd << aFillet1D << " = geompy.MakeFillet1D(" << theShape
532 << ", " << theR << ", [";
534 it = theVertexes.begin();
535 if (it != theVertexes.end()) {
537 while (it != theVertexes.end())
538 pd << ", " << (*it++);
546 //=============================================================================
550 //=============================================================================
551 Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeChamferAll (Handle(GEOM_Object) theShape, double theD)
555 //Add a new Chamfer object
556 Handle(GEOM_Object) aChamfer = GetEngine()->AddObject(GetDocID(), GEOM_CHAMFER);
558 //Add a new Chamfer function
559 Handle(GEOM_Function) aFunction =
560 aChamfer->AddFunction(GEOMImpl_ChamferDriver::GetID(), CHAMFER_SHAPE_ALL);
561 if (aFunction.IsNull()) return NULL;
563 //Check if the function is set correctly
564 if (aFunction->GetDriverGUID() != GEOMImpl_ChamferDriver::GetID()) return NULL;
566 GEOMImpl_IChamfer aCI (aFunction);
568 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
569 if (aRefShape.IsNull()) return NULL;
571 aCI.SetShape(aRefShape);
574 //Compute the Chamfer value
577 if (!GetSolver()->ComputeFunction(aFunction)) {
578 SetErrorCode("Chamfer driver failed");
582 catch (Standard_Failure) {
583 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
584 SetErrorCode(aFail->GetMessageString());
588 //Make a Python command
589 GEOM::TPythonDump(aFunction) << aChamfer << " = geompy.MakeChamferAll("
590 << theShape << ", " << theD << ")";
596 //=============================================================================
600 //=============================================================================
601 Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeChamferEdge
602 (Handle(GEOM_Object) theShape, double theD1, double theD2,
603 int theFace1, int theFace2)
607 //Add a new Chamfer object
608 Handle(GEOM_Object) aChamfer = GetEngine()->AddObject(GetDocID(), GEOM_CHAMFER);
610 //Add a new Chamfer function
611 Handle(GEOM_Function) aFunction =
612 aChamfer->AddFunction(GEOMImpl_ChamferDriver::GetID(), CHAMFER_SHAPE_EDGE);
613 if (aFunction.IsNull()) return NULL;
615 //Check if the function is set correctly
616 if (aFunction->GetDriverGUID() != GEOMImpl_ChamferDriver::GetID()) return NULL;
618 GEOMImpl_IChamfer aCI (aFunction);
620 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
621 if (aRefShape.IsNull()) return NULL;
623 aCI.SetShape(aRefShape);
626 aCI.SetFace1(theFace1);
627 aCI.SetFace2(theFace2);
629 //Compute the Chamfer value
632 if (!GetSolver()->ComputeFunction(aFunction)) {
633 SetErrorCode("Chamfer driver failed");
637 catch (Standard_Failure) {
638 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
639 SetErrorCode(aFail->GetMessageString());
643 //Make a Python command
644 GEOM::TPythonDump(aFunction) << aChamfer
645 << " = geompy.MakeChamferEdge(" << theShape << ", " << theD1
646 << ", " << theD2 << ", " << theFace1 << ", " << theFace2 << ")";
652 //=============================================================================
656 //=============================================================================
657 Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeChamferEdgeAD
658 (Handle(GEOM_Object) theShape, double theD, double theAngle,
659 int theFace1, int theFace2)
663 //Add a new Chamfer object
664 Handle(GEOM_Object) aChamfer = GetEngine()->AddObject(GetDocID(), GEOM_CHAMFER);
666 //Add a new Chamfer function
667 Handle(GEOM_Function) aFunction =
668 aChamfer->AddFunction(GEOMImpl_ChamferDriver::GetID(), CHAMFER_SHAPE_EDGE_AD);
669 if (aFunction.IsNull()) return NULL;
671 //Check if the function is set correctly
672 if (aFunction->GetDriverGUID() != GEOMImpl_ChamferDriver::GetID()) return NULL;
674 GEOMImpl_IChamfer aCI (aFunction);
676 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
677 if (aRefShape.IsNull()) return NULL;
679 aCI.SetShape(aRefShape);
681 aCI.SetAngle(theAngle);
682 aCI.SetFace1(theFace1);
683 aCI.SetFace2(theFace2);
685 //Compute the Chamfer value
688 if (!GetSolver()->ComputeFunction(aFunction)) {
689 SetErrorCode("Chamfer driver failed");
693 catch (Standard_Failure) {
694 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
695 SetErrorCode(aFail->GetMessageString());
699 //Make a Python command
700 GEOM::TPythonDump(aFunction) << aChamfer
701 << " = geompy.MakeChamferEdgeAD(" << theShape << ", " << theD
702 << ", " << theAngle << ", " << theFace1 << ", " << theFace2 << ")";
707 //=============================================================================
711 //=============================================================================
712 Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeChamferFaces
713 (Handle(GEOM_Object) theShape, double theD1, double theD2,
714 std::list<int> theFaces)
718 //Add a new Chamfer object
719 Handle(GEOM_Object) aChamfer = GetEngine()->AddObject(GetDocID(), GEOM_CHAMFER);
721 //Add a new Chamfer function
722 Handle(GEOM_Function) aFunction =
723 aChamfer->AddFunction(GEOMImpl_ChamferDriver::GetID(), CHAMFER_SHAPE_FACES);
724 if (aFunction.IsNull()) return NULL;
726 //Check if the function is set correctly
727 if (aFunction->GetDriverGUID() != GEOMImpl_ChamferDriver::GetID()) return NULL;
729 GEOMImpl_IChamfer aCI (aFunction);
731 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
732 if (aRefShape.IsNull()) return NULL;
734 aCI.SetShape(aRefShape);
737 int aLen = theFaces.size();
741 std::list<int>::iterator it = theFaces.begin();
742 for (; it != theFaces.end(); it++, ind++) {
743 aCI.SetFace(ind, (*it));
746 //Compute the Chamfer value
749 if (!GetSolver()->ComputeFunction(aFunction)) {
750 SetErrorCode("Chamfer driver failed");
754 catch (Standard_Failure) {
755 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
756 SetErrorCode(aFail->GetMessageString());
760 //Make a Python command
761 GEOM::TPythonDump pd (aFunction);
762 pd << aChamfer << " = geompy.MakeChamferFaces(" << theShape
763 << ", " << theD1 << ", " << theD2 << ", [";
765 it = theFaces.begin();
767 while (it != theFaces.end()) {
768 pd << ", " << (*it++);
776 //=============================================================================
780 //=============================================================================
781 Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeChamferFacesAD
782 (Handle(GEOM_Object) theShape, double theD, double theAngle,
783 std::list<int> theFaces)
787 //Add a new Chamfer object
788 Handle(GEOM_Object) aChamfer = GetEngine()->AddObject(GetDocID(), GEOM_CHAMFER);
790 //Add a new Chamfer function
791 Handle(GEOM_Function) aFunction =
792 aChamfer->AddFunction(GEOMImpl_ChamferDriver::GetID(), CHAMFER_SHAPE_FACES_AD);
793 if (aFunction.IsNull()) return NULL;
795 //Check if the function is set correctly
796 if (aFunction->GetDriverGUID() != GEOMImpl_ChamferDriver::GetID()) return NULL;
798 GEOMImpl_IChamfer aCI (aFunction);
800 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
801 if (aRefShape.IsNull()) return NULL;
803 aCI.SetShape(aRefShape);
805 aCI.SetAngle(theAngle);
806 int aLen = theFaces.size();
810 std::list<int>::iterator it = theFaces.begin();
811 for (; it != theFaces.end(); it++, ind++) {
812 aCI.SetFace(ind, (*it));
815 //Compute the Chamfer value
818 if (!GetSolver()->ComputeFunction(aFunction)) {
819 SetErrorCode("Chamfer driver failed");
823 catch (Standard_Failure) {
824 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
825 SetErrorCode(aFail->GetMessageString());
829 //Make a Python command
830 GEOM::TPythonDump pd (aFunction);
831 pd << aChamfer << " = geompy.MakeChamferFacesAD(" << theShape
832 << ", " << theD << ", " << theAngle << ", [";
834 it = theFaces.begin();
836 while (it != theFaces.end()) {
837 pd << ", " << (*it++);
845 //=============================================================================
849 //=============================================================================
850 Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeChamferEdges
851 (Handle(GEOM_Object) theShape, double theD1, double theD2,
852 std::list<int> theEdges)
856 //Add a new Chamfer object
857 Handle(GEOM_Object) aChamfer = GetEngine()->AddObject(GetDocID(), GEOM_CHAMFER);
859 //Add a new Chamfer function
860 Handle(GEOM_Function) aFunction =
861 aChamfer->AddFunction(GEOMImpl_ChamferDriver::GetID(), CHAMFER_SHAPE_EDGES);
862 if (aFunction.IsNull()) { MESSAGE ( "Edges Function is NULL!!!" ); return NULL;}
864 //Check if the function is set correctly
865 if (aFunction->GetDriverGUID() != GEOMImpl_ChamferDriver::GetID())
866 { MESSAGE ( "Chamfer Driver is NULL!!!" ); return NULL; }
868 GEOMImpl_IChamfer aCI (aFunction);
870 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
871 if (aRefShape.IsNull()) { MESSAGE ("Shape is NULL!!!"); return NULL;}
873 aCI.SetShape(aRefShape);
876 int aLen = theEdges.size();
880 std::list<int>::iterator it = theEdges.begin();
881 for (; it != theEdges.end(); it++, ind++) {
882 aCI.SetEdge(ind, (*it));
885 //Compute the Chamfer value
888 if (!GetSolver()->ComputeFunction(aFunction)) {
889 SetErrorCode("Chamfer driver failed");
893 catch (Standard_Failure) {
894 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
895 SetErrorCode(aFail->GetMessageString());
899 //Make a Python command
900 GEOM::TPythonDump pd (aFunction);
901 pd << aChamfer << " = geompy.MakeChamferEdges(" << theShape
902 << ", " << theD1 << ", " << theD2 << ", [";
904 it = theEdges.begin();
906 while (it != theEdges.end()) {
907 pd << ", " << (*it++);
915 //=============================================================================
919 //=============================================================================
920 Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeChamferEdgesAD
921 (Handle(GEOM_Object) theShape, double theD, double theAngle,
922 std::list<int> theEdges)
926 //Add a new Chamfer object
927 Handle(GEOM_Object) aChamfer = GetEngine()->AddObject(GetDocID(), GEOM_CHAMFER);
929 //Add a new Chamfer function
930 Handle(GEOM_Function) aFunction =
931 aChamfer->AddFunction(GEOMImpl_ChamferDriver::GetID(), CHAMFER_SHAPE_EDGES_AD);
932 if (aFunction.IsNull()) { MESSAGE ( "Edges Function is NULL!!!" ); return NULL; }
934 //Check if the function is set correctly
935 if (aFunction->GetDriverGUID() != GEOMImpl_ChamferDriver::GetID())
936 { MESSAGE("Chamfer Driver is NULL!!!"); return NULL;}
938 GEOMImpl_IChamfer aCI (aFunction);
940 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
941 if (aRefShape.IsNull()) { MESSAGE ("Shape is NULL!!!"); return NULL;}
943 aCI.SetShape(aRefShape);
945 aCI.SetAngle(theAngle);
946 int aLen = theEdges.size();
950 std::list<int>::iterator it = theEdges.begin();
951 for (; it != theEdges.end(); it++, ind++) {
952 aCI.SetEdge(ind, (*it));
955 //Compute the Chamfer value
958 if (!GetSolver()->ComputeFunction(aFunction)) {
959 SetErrorCode("Chamfer driver failed");
963 catch (Standard_Failure) {
964 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
965 SetErrorCode(aFail->GetMessageString());
969 //Make a Python command
970 GEOM::TPythonDump pd (aFunction);
971 pd << aChamfer << " = geompy.MakeChamferEdgesAD(" << theShape
972 << ", " << theD << ", " << theAngle << ", [";
974 it = theEdges.begin();
976 while (it != theEdges.end()) {
977 pd << ", " << (*it++);
985 //=============================================================================
989 //=============================================================================
990 Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeArchimede (Handle(GEOM_Object) theShape,
992 double theWaterDensity,
993 double theMeshingDeflection)
997 //Add a new Archimede object
998 Handle(GEOM_Object) aChamfer = GetEngine()->AddObject(GetDocID(), GEOM_ARCHIMEDE);
1000 //Add a new Archimede function
1001 Handle(GEOM_Function) aFunction = aChamfer->AddFunction(GEOMImpl_ArchimedeDriver::GetID(), ARCHIMEDE_TYPE);
1002 if (aFunction.IsNull()) return NULL;
1004 //Check if the function is set correctly
1005 if (aFunction->GetDriverGUID() != GEOMImpl_ArchimedeDriver::GetID()) return NULL;
1007 GEOMImpl_IArchimede aAI (aFunction);
1009 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
1010 if (aRefShape.IsNull()) return NULL;
1012 aAI.SetBasicShape(aRefShape);
1013 aAI.SetWeight(theWeight);
1014 aAI.SetDensity(theWaterDensity);
1015 aAI.SetDeflection(theMeshingDeflection);
1017 //Compute the Archimede value
1020 if (!GetSolver()->ComputeFunction(aFunction)) {
1021 SetErrorCode("Archimede driver failed");
1025 catch (Standard_Failure) {
1026 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1027 SetErrorCode(aFail->GetMessageString());
1031 //Make a Python command
1032 GEOM::TPythonDump(aFunction) << aChamfer
1033 << " = geompy.Archimede(" << theShape << ", " << theWeight << ", "
1034 << theWaterDensity << ", " << theMeshingDeflection << ")";
1040 //=============================================================================
1044 //=============================================================================
1045 bool GEOMImpl_ILocalOperations::GetSubShape (const TopoDS_Shape& theShape, const int theIndex,
1046 TopoDS_Shape& theSubShape)
1048 if (theShape.IsNull() || theIndex < 1)
1051 TopTools_IndexedMapOfShape anIndices;
1052 TopExp::MapShapes(theShape, anIndices);
1053 if (theIndex > anIndices.Extent()) return false;
1054 theSubShape = anIndices.FindKey(theIndex);
1059 //=============================================================================
1063 //=============================================================================
1064 Standard_Integer GEOMImpl_ILocalOperations::GetSubShapeIndex (Handle(GEOM_Object) theShape,
1065 Handle(GEOM_Object) theSubShape)
1069 Standard_Integer anInd = -1;
1070 GEOM_Engine* anEngine = GetEngine();
1071 //GEOMImpl_Gen* aGen = dynamic_cast<GEOMImpl_Gen*>(anEngine);
1072 GEOMImpl_Gen* aGen = (GEOMImpl_Gen*)anEngine;
1075 GEOMImpl_IShapesOperations* anIShapesOperations =
1076 aGen->GetIShapesOperations(GetDocID());
1077 anInd = anIShapesOperations->GetSubShapeIndex(theShape, theSubShape);
1078 SetErrorCode(anIShapesOperations->GetErrorCode());