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 "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, int theDocID)
69 : GEOM_IOperations(theEngine, theDocID)
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(GetDocID(), 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) {
123 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
124 SetErrorCode(aFail->GetMessageString());
128 //Make a Python command
129 GEOM::TPythonDump(aFunction) << aFillet << " = geompy.MakeFilletAll("
130 << theShape << ", " << theR << ")";
136 //=============================================================================
140 //=============================================================================
141 Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeFilletEdges
142 (Handle(GEOM_Object) theShape, double theR, std::list<int> theEdges)
146 //Add a new Fillet object
147 Handle(GEOM_Object) aFillet = GetEngine()->AddObject(GetDocID(), GEOM_FILLET);
149 //Add a new Fillet function
150 Handle(GEOM_Function) aFunction =
151 aFillet->AddFunction(GEOMImpl_FilletDriver::GetID(), FILLET_SHAPE_EDGES);
152 if (aFunction.IsNull()) return NULL;
154 //Check if the function is set correctly
155 if (aFunction->GetDriverGUID() != GEOMImpl_FilletDriver::GetID()) return NULL;
157 GEOMImpl_IFillet aCI (aFunction);
159 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
160 if (aRefShape.IsNull()) return NULL;
162 aCI.SetShape(aRefShape);
164 int aLen = theEdges.size();
168 std::list<int>::iterator it = theEdges.begin();
169 for (; it != theEdges.end(); it++, ind++) {
170 aCI.SetEdge(ind, (*it));
173 //Compute the Fillet value
176 if (!GetSolver()->ComputeFunction(aFunction)) {
177 SetErrorCode("Fillet driver failed");
181 catch (Standard_Failure) {
182 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
183 SetErrorCode(aFail->GetMessageString());
187 //Make a Python command
188 GEOM::TPythonDump pd (aFunction);
189 pd << aFillet << " = geompy.MakeFillet(" << theShape
190 << ", " << theR << ", geompy.ShapeType[\"EDGE\"], [";
192 it = theEdges.begin();
194 while (it != theEdges.end()) {
195 pd << ", " << (*it++);
203 //=============================================================================
205 * MakeFilletEdges R1 R2
207 //=============================================================================
208 Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeFilletEdgesR1R2
209 (Handle(GEOM_Object) theShape, double theR1, double theR2, std::list<int> theEdges)
213 //Add a new Fillet object
214 Handle(GEOM_Object) aFillet = GetEngine()->AddObject(GetDocID(), GEOM_FILLET);
216 //Add a new Fillet function
217 Handle(GEOM_Function) aFunction =
218 aFillet->AddFunction(GEOMImpl_FilletDriver::GetID(), FILLET_SHAPE_EDGES_2R);
219 if (aFunction.IsNull()) return NULL;
221 //Check if the function is set correctly
222 if (aFunction->GetDriverGUID() != GEOMImpl_FilletDriver::GetID()) return NULL;
224 GEOMImpl_IFillet aCI (aFunction);
226 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
227 if (aRefShape.IsNull()) return NULL;
229 aCI.SetShape(aRefShape);
232 int aLen = theEdges.size();
236 std::list<int>::iterator it = theEdges.begin();
237 for (; it != theEdges.end(); it++, ind++) {
238 aCI.SetEdge(ind, (*it));
241 //Compute the Fillet value
244 if (!GetSolver()->ComputeFunction(aFunction)) {
245 SetErrorCode("Fillet driver failed");
249 catch (Standard_Failure) {
250 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
251 SetErrorCode(aFail->GetMessageString());
255 //Make a Python command
256 GEOM::TPythonDump pd (aFunction);
257 pd << aFillet << " = geompy.MakeFilletR1R2(" << theShape
258 << ", " << theR1 << ", " <<theR2 << ", geompy.ShapeType[\"EDGE\"], [";
260 it = theEdges.begin();
262 while (it != theEdges.end()) {
263 pd << ", " << (*it++);
272 //=============================================================================
276 //=============================================================================
277 Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeFilletFaces
278 (Handle(GEOM_Object) theShape, double theR, std::list<int> theFaces)
282 //Add a new Fillet object
283 Handle(GEOM_Object) aFillet = GetEngine()->AddObject(GetDocID(), GEOM_FILLET);
285 //Add a new Fillet function
286 Handle(GEOM_Function) aFunction =
287 aFillet->AddFunction(GEOMImpl_FilletDriver::GetID(), FILLET_SHAPE_FACES);
288 if (aFunction.IsNull()) return NULL;
290 //Check if the function is set correctly
291 if (aFunction->GetDriverGUID() != GEOMImpl_FilletDriver::GetID()) return NULL;
293 GEOMImpl_IFillet aCI (aFunction);
295 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
296 if (aRefShape.IsNull()) return NULL;
298 aCI.SetShape(aRefShape);
300 int aLen = theFaces.size();
304 std::list<int>::iterator it = theFaces.begin();
305 for (; it != theFaces.end(); it++, ind++) {
306 aCI.SetFace(ind, (*it));
309 //Compute the Fillet value
312 if (!GetSolver()->ComputeFunction(aFunction)) {
313 SetErrorCode("Fillet driver failed");
317 catch (Standard_Failure) {
318 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
319 SetErrorCode(aFail->GetMessageString());
323 //Make a Python command
324 GEOM::TPythonDump pd (aFunction);
325 pd << aFillet << " = geompy.MakeFillet(" << theShape
326 << ", " << theR << ", geompy.ShapeType[\"FACE\"], [";
328 it = theFaces.begin();
330 while (it != theFaces.end()) {
331 pd << ", " << (*it++);
339 //=============================================================================
341 * MakeFilletFaces R1 R2
343 //=============================================================================
344 Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeFilletFacesR1R2
345 (Handle(GEOM_Object) theShape, double theR1, double theR2, std::list<int> theFaces)
349 //Add a new Fillet object
350 Handle(GEOM_Object) aFillet = GetEngine()->AddObject(GetDocID(), GEOM_FILLET);
352 //Add a new Fillet function
353 Handle(GEOM_Function) aFunction =
354 aFillet->AddFunction(GEOMImpl_FilletDriver::GetID(), FILLET_SHAPE_FACES_2R);
355 if (aFunction.IsNull()) return NULL;
357 //Check if the function is set correctly
358 if (aFunction->GetDriverGUID() != GEOMImpl_FilletDriver::GetID()) return NULL;
360 GEOMImpl_IFillet aCI (aFunction);
362 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
363 if (aRefShape.IsNull()) return NULL;
365 aCI.SetShape(aRefShape);
368 int aLen = theFaces.size();
372 std::list<int>::iterator it = theFaces.begin();
373 for (; it != theFaces.end(); it++, ind++) {
374 aCI.SetFace(ind, (*it));
377 //Compute the Fillet value
380 if (!GetSolver()->ComputeFunction(aFunction)) {
381 SetErrorCode("Fillet driver failed");
385 catch (Standard_Failure) {
386 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
387 SetErrorCode(aFail->GetMessageString());
391 //Make a Python command
392 GEOM::TPythonDump pd (aFunction);
393 pd << aFillet << " = geompy.MakeFilletR1R2(" << theShape
394 << ", " << theR1 << ", " << theR2 << ", geompy.ShapeType[\"FACE\"], [";
396 it = theFaces.begin();
398 while (it != theFaces.end()) {
399 pd << ", " << (*it++);
407 //=============================================================================
411 //=============================================================================
412 Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeFillet2D
413 (Handle(GEOM_Object) theShape, double theR, std::list<int> theVertexes)
417 //Add a new Fillet object
418 Handle(GEOM_Object) aFillet2D = GetEngine()->AddObject(GetDocID(), GEOM_FILLET_2D);
420 //Add a new Fillet function
421 Handle(GEOM_Function) aFunction =
422 aFillet2D->AddFunction(GEOMImpl_Fillet2dDriver::GetID(), FILLET_2D_SHAPE_VERTEXES);
423 if (aFunction.IsNull()) return NULL;
425 //Check if the function is set correctly
426 if (aFunction->GetDriverGUID() != GEOMImpl_Fillet2dDriver::GetID()) return NULL;
428 GEOMImpl_IFillet2d aCI (aFunction);
430 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
431 if (aRefShape.IsNull()) return NULL;
433 aCI.SetShape(aRefShape);
435 int aLen = theVertexes.size();
439 std::list<int>::iterator it = theVertexes.begin();
440 for (; it != theVertexes.end(); it++, ind++) {
441 aCI.SetVertex(ind, (*it));
444 //Compute the Fillet value
447 if (!GetSolver()->ComputeFunction(aFunction)) {
448 SetErrorCode("2D Fillet driver failed");
452 catch (Standard_Failure) {
453 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
454 SetErrorCode(aFail->GetMessageString());
458 //Make a Python command
459 GEOM::TPythonDump pd (aFunction);
460 pd << aFillet2D << " = geompy.MakeFillet2D(" << theShape
461 << ", " << theR << ", [";
463 it = theVertexes.begin();
465 while (it != theVertexes.end()) {
466 pd << ", " << (*it++);
474 //=============================================================================
478 //=============================================================================
479 Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeFillet1D
480 (Handle(GEOM_Object) theShape, double theR,
481 std::list<int> theVertexes, bool doIgnoreSecantVertices)
485 //Add a new Fillet object
486 Handle(GEOM_Object) aFillet1D = GetEngine()->AddObject(GetDocID(), GEOM_FILLET_1D);
488 //Add a new Fillet function
489 Handle(GEOM_Function) aFunction =
490 aFillet1D->AddFunction(GEOMImpl_Fillet1dDriver::GetID(), FILLET_1D_SHAPE_VERTEXES);
491 if (aFunction.IsNull()) return NULL;
493 //Check if the function is set correctly
494 if (aFunction->GetDriverGUID() != GEOMImpl_Fillet1dDriver::GetID()) return NULL;
496 GEOMImpl_IFillet1d aCI (aFunction);
498 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
499 if (aRefShape.IsNull()) return NULL;
501 aCI.SetShape(aRefShape);
503 aCI.SetFlag(doIgnoreSecantVertices);
504 int aLen = theVertexes.size();
508 std::list<int>::iterator it = theVertexes.begin();
509 for (; it != theVertexes.end(); it++, ind++) {
510 aCI.SetVertex(ind, (*it));
513 //Compute the Fillet value
516 if (!GetSolver()->ComputeFunction(aFunction)) {
517 SetErrorCode("1D Fillet driver failed");
521 catch (Standard_Failure) {
522 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
523 SetErrorCode(aFail->GetMessageString());
527 //Make a Python command
528 GEOM::TPythonDump pd (aFunction);
529 pd << aFillet1D << " = geompy.MakeFillet1D(" << theShape
530 << ", " << theR << ", [";
532 it = theVertexes.begin();
533 if (it != theVertexes.end()) {
535 while (it != theVertexes.end())
536 pd << ", " << (*it++);
544 //=============================================================================
548 //=============================================================================
549 Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeChamferAll (Handle(GEOM_Object) theShape, double theD)
553 //Add a new Chamfer object
554 Handle(GEOM_Object) aChamfer = GetEngine()->AddObject(GetDocID(), GEOM_CHAMFER);
556 //Add a new Chamfer function
557 Handle(GEOM_Function) aFunction =
558 aChamfer->AddFunction(GEOMImpl_ChamferDriver::GetID(), CHAMFER_SHAPE_ALL);
559 if (aFunction.IsNull()) return NULL;
561 //Check if the function is set correctly
562 if (aFunction->GetDriverGUID() != GEOMImpl_ChamferDriver::GetID()) return NULL;
564 GEOMImpl_IChamfer aCI (aFunction);
566 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
567 if (aRefShape.IsNull()) return NULL;
569 aCI.SetShape(aRefShape);
572 //Compute the Chamfer value
575 if (!GetSolver()->ComputeFunction(aFunction)) {
576 SetErrorCode("Chamfer driver failed");
580 catch (Standard_Failure) {
581 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
582 SetErrorCode(aFail->GetMessageString());
586 //Make a Python command
587 GEOM::TPythonDump(aFunction) << aChamfer << " = geompy.MakeChamferAll("
588 << theShape << ", " << theD << ")";
594 //=============================================================================
598 //=============================================================================
599 Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeChamferEdge
600 (Handle(GEOM_Object) theShape, double theD1, double theD2,
601 int theFace1, int theFace2)
605 //Add a new Chamfer object
606 Handle(GEOM_Object) aChamfer = GetEngine()->AddObject(GetDocID(), GEOM_CHAMFER);
608 //Add a new Chamfer function
609 Handle(GEOM_Function) aFunction =
610 aChamfer->AddFunction(GEOMImpl_ChamferDriver::GetID(), CHAMFER_SHAPE_EDGE);
611 if (aFunction.IsNull()) return NULL;
613 //Check if the function is set correctly
614 if (aFunction->GetDriverGUID() != GEOMImpl_ChamferDriver::GetID()) return NULL;
616 GEOMImpl_IChamfer aCI (aFunction);
618 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
619 if (aRefShape.IsNull()) return NULL;
621 aCI.SetShape(aRefShape);
624 aCI.SetFace1(theFace1);
625 aCI.SetFace2(theFace2);
627 //Compute the Chamfer value
630 if (!GetSolver()->ComputeFunction(aFunction)) {
631 SetErrorCode("Chamfer driver failed");
635 catch (Standard_Failure) {
636 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
637 SetErrorCode(aFail->GetMessageString());
641 //Make a Python command
642 GEOM::TPythonDump(aFunction) << aChamfer
643 << " = geompy.MakeChamferEdge(" << theShape << ", " << theD1
644 << ", " << theD2 << ", " << theFace1 << ", " << theFace2 << ")";
650 //=============================================================================
654 //=============================================================================
655 Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeChamferEdgeAD
656 (Handle(GEOM_Object) theShape, double theD, double theAngle,
657 int theFace1, int theFace2)
661 //Add a new Chamfer object
662 Handle(GEOM_Object) aChamfer = GetEngine()->AddObject(GetDocID(), GEOM_CHAMFER);
664 //Add a new Chamfer function
665 Handle(GEOM_Function) aFunction =
666 aChamfer->AddFunction(GEOMImpl_ChamferDriver::GetID(), CHAMFER_SHAPE_EDGE_AD);
667 if (aFunction.IsNull()) return NULL;
669 //Check if the function is set correctly
670 if (aFunction->GetDriverGUID() != GEOMImpl_ChamferDriver::GetID()) return NULL;
672 GEOMImpl_IChamfer aCI (aFunction);
674 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
675 if (aRefShape.IsNull()) return NULL;
677 aCI.SetShape(aRefShape);
679 aCI.SetAngle(theAngle);
680 aCI.SetFace1(theFace1);
681 aCI.SetFace2(theFace2);
683 //Compute the Chamfer value
686 if (!GetSolver()->ComputeFunction(aFunction)) {
687 SetErrorCode("Chamfer driver failed");
691 catch (Standard_Failure) {
692 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
693 SetErrorCode(aFail->GetMessageString());
697 //Make a Python command
698 GEOM::TPythonDump(aFunction) << aChamfer
699 << " = geompy.MakeChamferEdgeAD(" << theShape << ", " << theD
700 << ", " << theAngle << ", " << theFace1 << ", " << theFace2 << ")";
705 //=============================================================================
709 //=============================================================================
710 Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeChamferFaces
711 (Handle(GEOM_Object) theShape, double theD1, double theD2,
712 std::list<int> theFaces)
716 //Add a new Chamfer object
717 Handle(GEOM_Object) aChamfer = GetEngine()->AddObject(GetDocID(), GEOM_CHAMFER);
719 //Add a new Chamfer function
720 Handle(GEOM_Function) aFunction =
721 aChamfer->AddFunction(GEOMImpl_ChamferDriver::GetID(), CHAMFER_SHAPE_FACES);
722 if (aFunction.IsNull()) return NULL;
724 //Check if the function is set correctly
725 if (aFunction->GetDriverGUID() != GEOMImpl_ChamferDriver::GetID()) return NULL;
727 GEOMImpl_IChamfer aCI (aFunction);
729 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
730 if (aRefShape.IsNull()) return NULL;
732 aCI.SetShape(aRefShape);
735 int aLen = theFaces.size();
739 std::list<int>::iterator it = theFaces.begin();
740 for (; it != theFaces.end(); it++, ind++) {
741 aCI.SetFace(ind, (*it));
744 //Compute the Chamfer value
747 if (!GetSolver()->ComputeFunction(aFunction)) {
748 SetErrorCode("Chamfer driver failed");
752 catch (Standard_Failure) {
753 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
754 SetErrorCode(aFail->GetMessageString());
758 //Make a Python command
759 GEOM::TPythonDump pd (aFunction);
760 pd << aChamfer << " = geompy.MakeChamferFaces(" << theShape
761 << ", " << theD1 << ", " << theD2 << ", [";
763 it = theFaces.begin();
765 while (it != theFaces.end()) {
766 pd << ", " << (*it++);
774 //=============================================================================
778 //=============================================================================
779 Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeChamferFacesAD
780 (Handle(GEOM_Object) theShape, double theD, double theAngle,
781 std::list<int> theFaces)
785 //Add a new Chamfer object
786 Handle(GEOM_Object) aChamfer = GetEngine()->AddObject(GetDocID(), GEOM_CHAMFER);
788 //Add a new Chamfer function
789 Handle(GEOM_Function) aFunction =
790 aChamfer->AddFunction(GEOMImpl_ChamferDriver::GetID(), CHAMFER_SHAPE_FACES_AD);
791 if (aFunction.IsNull()) return NULL;
793 //Check if the function is set correctly
794 if (aFunction->GetDriverGUID() != GEOMImpl_ChamferDriver::GetID()) return NULL;
796 GEOMImpl_IChamfer aCI (aFunction);
798 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
799 if (aRefShape.IsNull()) return NULL;
801 aCI.SetShape(aRefShape);
803 aCI.SetAngle(theAngle);
804 int aLen = theFaces.size();
808 std::list<int>::iterator it = theFaces.begin();
809 for (; it != theFaces.end(); it++, ind++) {
810 aCI.SetFace(ind, (*it));
813 //Compute the Chamfer value
816 if (!GetSolver()->ComputeFunction(aFunction)) {
817 SetErrorCode("Chamfer driver failed");
821 catch (Standard_Failure) {
822 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
823 SetErrorCode(aFail->GetMessageString());
827 //Make a Python command
828 GEOM::TPythonDump pd (aFunction);
829 pd << aChamfer << " = geompy.MakeChamferFacesAD(" << theShape
830 << ", " << theD << ", " << theAngle << ", [";
832 it = theFaces.begin();
834 while (it != theFaces.end()) {
835 pd << ", " << (*it++);
843 //=============================================================================
847 //=============================================================================
848 Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeChamferEdges
849 (Handle(GEOM_Object) theShape, double theD1, double theD2,
850 std::list<int> theEdges)
854 //Add a new Chamfer object
855 Handle(GEOM_Object) aChamfer = GetEngine()->AddObject(GetDocID(), GEOM_CHAMFER);
857 //Add a new Chamfer function
858 Handle(GEOM_Function) aFunction =
859 aChamfer->AddFunction(GEOMImpl_ChamferDriver::GetID(), CHAMFER_SHAPE_EDGES);
860 if (aFunction.IsNull()) { MESSAGE ( "Edges Function is NULL!!!" ); return NULL;}
862 //Check if the function is set correctly
863 if (aFunction->GetDriverGUID() != GEOMImpl_ChamferDriver::GetID())
864 { MESSAGE ( "Chamfer Driver is NULL!!!" ); return NULL; }
866 GEOMImpl_IChamfer aCI (aFunction);
868 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
869 if (aRefShape.IsNull()) { MESSAGE ("Shape is NULL!!!"); return NULL;}
871 aCI.SetShape(aRefShape);
874 int aLen = theEdges.size();
878 std::list<int>::iterator it = theEdges.begin();
879 for (; it != theEdges.end(); it++, ind++) {
880 aCI.SetEdge(ind, (*it));
883 //Compute the Chamfer value
886 if (!GetSolver()->ComputeFunction(aFunction)) {
887 SetErrorCode("Chamfer driver failed");
891 catch (Standard_Failure) {
892 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
893 SetErrorCode(aFail->GetMessageString());
897 //Make a Python command
898 GEOM::TPythonDump pd (aFunction);
899 pd << aChamfer << " = geompy.MakeChamferEdges(" << theShape
900 << ", " << theD1 << ", " << theD2 << ", [";
902 it = theEdges.begin();
904 while (it != theEdges.end()) {
905 pd << ", " << (*it++);
913 //=============================================================================
917 //=============================================================================
918 Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeChamferEdgesAD
919 (Handle(GEOM_Object) theShape, double theD, double theAngle,
920 std::list<int> theEdges)
924 //Add a new Chamfer object
925 Handle(GEOM_Object) aChamfer = GetEngine()->AddObject(GetDocID(), GEOM_CHAMFER);
927 //Add a new Chamfer function
928 Handle(GEOM_Function) aFunction =
929 aChamfer->AddFunction(GEOMImpl_ChamferDriver::GetID(), CHAMFER_SHAPE_EDGES_AD);
930 if (aFunction.IsNull()) { MESSAGE ( "Edges Function is NULL!!!" ); return NULL; }
932 //Check if the function is set correctly
933 if (aFunction->GetDriverGUID() != GEOMImpl_ChamferDriver::GetID())
934 { MESSAGE("Chamfer Driver is NULL!!!"); return NULL;}
936 GEOMImpl_IChamfer aCI (aFunction);
938 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
939 if (aRefShape.IsNull()) { MESSAGE ("Shape is NULL!!!"); return NULL;}
941 aCI.SetShape(aRefShape);
943 aCI.SetAngle(theAngle);
944 int aLen = theEdges.size();
948 std::list<int>::iterator it = theEdges.begin();
949 for (; it != theEdges.end(); it++, ind++) {
950 aCI.SetEdge(ind, (*it));
953 //Compute the Chamfer value
956 if (!GetSolver()->ComputeFunction(aFunction)) {
957 SetErrorCode("Chamfer driver failed");
961 catch (Standard_Failure) {
962 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
963 SetErrorCode(aFail->GetMessageString());
967 //Make a Python command
968 GEOM::TPythonDump pd (aFunction);
969 pd << aChamfer << " = geompy.MakeChamferEdgesAD(" << theShape
970 << ", " << theD << ", " << theAngle << ", [";
972 it = theEdges.begin();
974 while (it != theEdges.end()) {
975 pd << ", " << (*it++);
983 //=============================================================================
987 //=============================================================================
988 Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeArchimede (Handle(GEOM_Object) theShape,
990 double theWaterDensity,
991 double theMeshingDeflection)
995 //Add a new Archimede object
996 Handle(GEOM_Object) aChamfer = GetEngine()->AddObject(GetDocID(), GEOM_ARCHIMEDE);
998 //Add a new Archimede function
999 Handle(GEOM_Function) aFunction = aChamfer->AddFunction(GEOMImpl_ArchimedeDriver::GetID(), ARCHIMEDE_TYPE);
1000 if (aFunction.IsNull()) return NULL;
1002 //Check if the function is set correctly
1003 if (aFunction->GetDriverGUID() != GEOMImpl_ArchimedeDriver::GetID()) return NULL;
1005 GEOMImpl_IArchimede aAI (aFunction);
1007 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
1008 if (aRefShape.IsNull()) return NULL;
1010 aAI.SetBasicShape(aRefShape);
1011 aAI.SetWeight(theWeight);
1012 aAI.SetDensity(theWaterDensity);
1013 aAI.SetDeflection(theMeshingDeflection);
1015 //Compute the Archimede value
1018 if (!GetSolver()->ComputeFunction(aFunction)) {
1019 SetErrorCode("Archimede driver failed");
1023 catch (Standard_Failure) {
1024 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1025 SetErrorCode(aFail->GetMessageString());
1029 //Make a Python command
1030 GEOM::TPythonDump(aFunction) << aChamfer
1031 << " = geompy.Archimede(" << theShape << ", " << theWeight << ", "
1032 << theWaterDensity << ", " << theMeshingDeflection << ")";
1038 //=============================================================================
1042 //=============================================================================
1043 bool GEOMImpl_ILocalOperations::GetSubShape (const TopoDS_Shape& theShape, const int theIndex,
1044 TopoDS_Shape& theSubShape)
1046 if (theShape.IsNull() || theIndex < 1)
1049 TopTools_IndexedMapOfShape anIndices;
1050 TopExp::MapShapes(theShape, anIndices);
1051 if (theIndex > anIndices.Extent()) return false;
1052 theSubShape = anIndices.FindKey(theIndex);
1057 //=============================================================================
1061 //=============================================================================
1062 Standard_Integer GEOMImpl_ILocalOperations::GetSubShapeIndex (Handle(GEOM_Object) theShape,
1063 Handle(GEOM_Object) theSubShape)
1067 Standard_Integer anInd = -1;
1068 GEOM_Engine* anEngine = GetEngine();
1069 //GEOMImpl_Gen* aGen = dynamic_cast<GEOMImpl_Gen*>(anEngine);
1070 GEOMImpl_Gen* aGen = (GEOMImpl_Gen*)anEngine;
1073 GEOMImpl_IShapesOperations* anIShapesOperations =
1074 aGen->GetIShapesOperations(GetDocID());
1075 anInd = anIShapesOperations->GetSubShapeIndex(theShape, theSubShape);
1076 SetErrorCode(anIShapesOperations->GetErrorCode());