1 // Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
22 #include <Standard_Stream.hxx>
24 #include <GEOMImpl_ILocalOperations.hxx>
26 #include <GEOM_Function.hxx>
27 #include <GEOM_PythonDump.hxx>
29 #include <GEOMImpl_Types.hxx>
31 #include <GEOMImpl_FilletDriver.hxx>
32 #include <GEOMImpl_Fillet1dDriver.hxx>
33 #include <GEOMImpl_Fillet2dDriver.hxx>
34 #include <GEOMImpl_ChamferDriver.hxx>
36 #include <GEOMImpl_IFillet.hxx>
37 #include <GEOMImpl_IFillet1d.hxx>
38 #include <GEOMImpl_IFillet2d.hxx>
39 #include <GEOMImpl_IChamfer.hxx>
41 #include <GEOMImpl_IArchimede.hxx>
42 #include <GEOMImpl_ArchimedeDriver.hxx>
44 #include <GEOMImpl_Gen.hxx>
45 #include <GEOMImpl_IShapesOperations.hxx>
47 #include "utilities.h"
49 #include <Utils_ExceptHandlers.hxx>
51 #include <TFunction_DriverTable.hxx>
52 #include <TFunction_Driver.hxx>
53 #include <TFunction_Logbook.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
116 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
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
177 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
180 if (!GetSolver()->ComputeFunction(aFunction)) {
181 SetErrorCode("Fillet driver failed");
185 catch (Standard_Failure) {
186 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
187 SetErrorCode(aFail->GetMessageString());
191 //Make a Python command
192 GEOM::TPythonDump pd (aFunction);
193 pd << aFillet << " = geompy.MakeFillet(" << theShape
194 << ", " << theR << ", geompy.ShapeType[\"EDGE\"], [";
196 it = theEdges.begin();
198 while (it != theEdges.end()) {
199 pd << ", " << (*it++);
207 //=============================================================================
209 * MakeFilletEdges R1 R2
211 //=============================================================================
212 Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeFilletEdgesR1R2
213 (Handle(GEOM_Object) theShape, double theR1, double theR2, std::list<int> theEdges)
217 //Add a new Fillet object
218 Handle(GEOM_Object) aFillet = GetEngine()->AddObject(GetDocID(), GEOM_FILLET);
220 //Add a new Fillet function
221 Handle(GEOM_Function) aFunction =
222 aFillet->AddFunction(GEOMImpl_FilletDriver::GetID(), FILLET_SHAPE_EDGES_2R);
223 if (aFunction.IsNull()) return NULL;
225 //Check if the function is set correctly
226 if (aFunction->GetDriverGUID() != GEOMImpl_FilletDriver::GetID()) return NULL;
228 GEOMImpl_IFillet aCI (aFunction);
230 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
231 if (aRefShape.IsNull()) return NULL;
233 aCI.SetShape(aRefShape);
236 int aLen = theEdges.size();
240 std::list<int>::iterator it = theEdges.begin();
241 for (; it != theEdges.end(); it++, ind++) {
242 aCI.SetEdge(ind, (*it));
245 //Compute the Fillet value
247 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
250 if (!GetSolver()->ComputeFunction(aFunction)) {
251 SetErrorCode("Fillet driver failed");
255 catch (Standard_Failure) {
256 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
257 SetErrorCode(aFail->GetMessageString());
261 //Make a Python command
262 GEOM::TPythonDump pd (aFunction);
263 pd << aFillet << " = geompy.MakeFilletR1R2(" << theShape
264 << ", " << theR1 << ", " <<theR2 << ", geompy.ShapeType[\"EDGE\"], [";
266 it = theEdges.begin();
268 while (it != theEdges.end()) {
269 pd << ", " << (*it++);
278 //=============================================================================
282 //=============================================================================
283 Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeFilletFaces
284 (Handle(GEOM_Object) theShape, double theR, std::list<int> theFaces)
288 //Add a new Fillet object
289 Handle(GEOM_Object) aFillet = GetEngine()->AddObject(GetDocID(), GEOM_FILLET);
291 //Add a new Fillet function
292 Handle(GEOM_Function) aFunction =
293 aFillet->AddFunction(GEOMImpl_FilletDriver::GetID(), FILLET_SHAPE_FACES);
294 if (aFunction.IsNull()) return NULL;
296 //Check if the function is set correctly
297 if (aFunction->GetDriverGUID() != GEOMImpl_FilletDriver::GetID()) return NULL;
299 GEOMImpl_IFillet aCI (aFunction);
301 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
302 if (aRefShape.IsNull()) return NULL;
304 aCI.SetShape(aRefShape);
306 int aLen = theFaces.size();
310 std::list<int>::iterator it = theFaces.begin();
311 for (; it != theFaces.end(); it++, ind++) {
312 aCI.SetFace(ind, (*it));
315 //Compute the Fillet value
317 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
320 if (!GetSolver()->ComputeFunction(aFunction)) {
321 SetErrorCode("Fillet driver failed");
325 catch (Standard_Failure) {
326 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
327 SetErrorCode(aFail->GetMessageString());
331 //Make a Python command
332 GEOM::TPythonDump pd (aFunction);
333 pd << aFillet << " = geompy.MakeFillet(" << theShape
334 << ", " << theR << ", geompy.ShapeType[\"FACE\"], [";
336 it = theFaces.begin();
338 while (it != theFaces.end()) {
339 pd << ", " << (*it++);
347 //=============================================================================
349 * MakeFilletFaces R1 R2
351 //=============================================================================
352 Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeFilletFacesR1R2
353 (Handle(GEOM_Object) theShape, double theR1, double theR2, std::list<int> theFaces)
357 //Add a new Fillet object
358 Handle(GEOM_Object) aFillet = GetEngine()->AddObject(GetDocID(), GEOM_FILLET);
360 //Add a new Fillet function
361 Handle(GEOM_Function) aFunction =
362 aFillet->AddFunction(GEOMImpl_FilletDriver::GetID(), FILLET_SHAPE_FACES_2R);
363 if (aFunction.IsNull()) return NULL;
365 //Check if the function is set correctly
366 if (aFunction->GetDriverGUID() != GEOMImpl_FilletDriver::GetID()) return NULL;
368 GEOMImpl_IFillet aCI (aFunction);
370 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
371 if (aRefShape.IsNull()) return NULL;
373 aCI.SetShape(aRefShape);
376 int aLen = theFaces.size();
380 std::list<int>::iterator it = theFaces.begin();
381 for (; it != theFaces.end(); it++, ind++) {
382 aCI.SetFace(ind, (*it));
385 //Compute the Fillet value
387 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
390 if (!GetSolver()->ComputeFunction(aFunction)) {
391 SetErrorCode("Fillet driver failed");
395 catch (Standard_Failure) {
396 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
397 SetErrorCode(aFail->GetMessageString());
401 //Make a Python command
402 GEOM::TPythonDump pd (aFunction);
403 pd << aFillet << " = geompy.MakeFilletR1R2(" << theShape
404 << ", " << theR1 << ", " << theR2 << ", geompy.ShapeType[\"FACE\"], [";
406 it = theFaces.begin();
408 while (it != theFaces.end()) {
409 pd << ", " << (*it++);
417 //=============================================================================
421 //=============================================================================
422 Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeFillet2D
423 (Handle(GEOM_Object) theShape, double theR, std::list<int> theVertexes)
427 //Add a new Fillet object
428 Handle(GEOM_Object) aFillet2D = GetEngine()->AddObject(GetDocID(), GEOM_FILLET_2D);
430 //Add a new Fillet function
431 Handle(GEOM_Function) aFunction =
432 aFillet2D->AddFunction(GEOMImpl_Fillet2dDriver::GetID(), FILLET_2D_SHAPE_VERTEXES);
433 if (aFunction.IsNull()) return NULL;
435 //Check if the function is set correctly
436 if (aFunction->GetDriverGUID() != GEOMImpl_Fillet2dDriver::GetID()) return NULL;
438 GEOMImpl_IFillet2d aCI (aFunction);
440 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
441 if (aRefShape.IsNull()) return NULL;
443 aCI.SetShape(aRefShape);
445 int aLen = theVertexes.size();
449 std::list<int>::iterator it = theVertexes.begin();
450 for (; it != theVertexes.end(); it++, ind++) {
451 aCI.SetVertex(ind, (*it));
454 //Compute the Fillet value
456 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
459 if (!GetSolver()->ComputeFunction(aFunction)) {
460 SetErrorCode("2D Fillet driver failed");
464 catch (Standard_Failure) {
465 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
466 SetErrorCode(aFail->GetMessageString());
470 //Make a Python command
471 GEOM::TPythonDump pd (aFunction);
472 pd << aFillet2D << " = geompy.MakeFillet2D(" << theShape
473 << ", " << theR << ", [";
475 it = theVertexes.begin();
477 while (it != theVertexes.end()) {
478 pd << ", " << (*it++);
486 //=============================================================================
490 //=============================================================================
491 Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeFillet1D
492 (Handle(GEOM_Object) theShape, double theR, std::list<int> theVertexes)
496 //Add a new Fillet object
497 Handle(GEOM_Object) aFillet1D = GetEngine()->AddObject(GetDocID(), GEOM_FILLET_1D);
499 //Add a new Fillet function
500 Handle(GEOM_Function) aFunction =
501 aFillet1D->AddFunction(GEOMImpl_Fillet1dDriver::GetID(), FILLET_1D_SHAPE_VERTEXES);
502 if (aFunction.IsNull()) return NULL;
504 //Check if the function is set correctly
505 if (aFunction->GetDriverGUID() != GEOMImpl_Fillet1dDriver::GetID()) return NULL;
507 GEOMImpl_IFillet1d aCI (aFunction);
509 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
510 if (aRefShape.IsNull()) return NULL;
512 aCI.SetShape(aRefShape);
514 int aLen = theVertexes.size();
518 std::list<int>::iterator it = theVertexes.begin();
519 for (; it != theVertexes.end(); it++, ind++) {
520 aCI.SetVertex(ind, (*it));
523 //Compute the Fillet value
525 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
528 if (!GetSolver()->ComputeFunction(aFunction)) {
529 SetErrorCode("1D Fillet driver failed");
533 catch (Standard_Failure) {
534 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
535 SetErrorCode(aFail->GetMessageString());
539 //Make a Python command
540 GEOM::TPythonDump pd (aFunction);
541 pd << aFillet1D << " = geompy.MakeFillet1D(" << theShape
542 << ", " << theR << ", [";
544 it = theVertexes.begin();
546 while (it != theVertexes.end()) {
547 pd << ", " << (*it++);
555 //=============================================================================
559 //=============================================================================
560 Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeChamferAll (Handle(GEOM_Object) theShape, double theD)
564 //Add a new Chamfer object
565 Handle(GEOM_Object) aChamfer = GetEngine()->AddObject(GetDocID(), GEOM_CHAMFER);
567 //Add a new Chamfer function
568 Handle(GEOM_Function) aFunction =
569 aChamfer->AddFunction(GEOMImpl_ChamferDriver::GetID(), CHAMFER_SHAPE_ALL);
570 if (aFunction.IsNull()) return NULL;
572 //Check if the function is set correctly
573 if (aFunction->GetDriverGUID() != GEOMImpl_ChamferDriver::GetID()) return NULL;
575 GEOMImpl_IChamfer aCI (aFunction);
577 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
578 if (aRefShape.IsNull()) return NULL;
580 aCI.SetShape(aRefShape);
583 //Compute the Chamfer value
585 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
588 if (!GetSolver()->ComputeFunction(aFunction)) {
589 SetErrorCode("Chamfer driver failed");
593 catch (Standard_Failure) {
594 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
595 SetErrorCode(aFail->GetMessageString());
599 //Make a Python command
600 GEOM::TPythonDump(aFunction) << aChamfer << " = geompy.MakeChamferAll("
601 << theShape << ", " << theD << ")";
607 //=============================================================================
611 //=============================================================================
612 Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeChamferEdge
613 (Handle(GEOM_Object) theShape, double theD1, double theD2,
614 int theFace1, int theFace2)
618 //Add a new Chamfer object
619 Handle(GEOM_Object) aChamfer = GetEngine()->AddObject(GetDocID(), GEOM_CHAMFER);
621 //Add a new Chamfer function
622 Handle(GEOM_Function) aFunction =
623 aChamfer->AddFunction(GEOMImpl_ChamferDriver::GetID(), CHAMFER_SHAPE_EDGE);
624 if (aFunction.IsNull()) return NULL;
626 //Check if the function is set correctly
627 if (aFunction->GetDriverGUID() != GEOMImpl_ChamferDriver::GetID()) return NULL;
629 GEOMImpl_IChamfer aCI (aFunction);
631 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
632 if (aRefShape.IsNull()) return NULL;
634 aCI.SetShape(aRefShape);
637 aCI.SetFace1(theFace1);
638 aCI.SetFace2(theFace2);
640 //Compute the Chamfer value
642 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
645 if (!GetSolver()->ComputeFunction(aFunction)) {
646 SetErrorCode("Chamfer driver failed");
650 catch (Standard_Failure) {
651 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
652 SetErrorCode(aFail->GetMessageString());
656 //Make a Python command
657 GEOM::TPythonDump(aFunction) << aChamfer
658 << " = geompy.MakeChamferEdge(" << theShape << ", " << theD1
659 << ", " << theD2 << ", " << theFace1 << ", " << theFace2 << ")";
665 //=============================================================================
669 //=============================================================================
670 Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeChamferEdgeAD
671 (Handle(GEOM_Object) theShape, double theD, double theAngle,
672 int theFace1, int theFace2)
676 //Add a new Chamfer object
677 Handle(GEOM_Object) aChamfer = GetEngine()->AddObject(GetDocID(), GEOM_CHAMFER);
679 //Add a new Chamfer function
680 Handle(GEOM_Function) aFunction =
681 aChamfer->AddFunction(GEOMImpl_ChamferDriver::GetID(), CHAMFER_SHAPE_EDGE_AD);
682 if (aFunction.IsNull()) return NULL;
684 //Check if the function is set correctly
685 if (aFunction->GetDriverGUID() != GEOMImpl_ChamferDriver::GetID()) return NULL;
687 GEOMImpl_IChamfer aCI (aFunction);
689 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
690 if (aRefShape.IsNull()) return NULL;
692 aCI.SetShape(aRefShape);
694 aCI.SetAngle(theAngle);
695 aCI.SetFace1(theFace1);
696 aCI.SetFace2(theFace2);
698 //Compute the Chamfer value
700 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
703 if (!GetSolver()->ComputeFunction(aFunction)) {
704 SetErrorCode("Chamfer driver failed");
708 catch (Standard_Failure) {
709 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
710 SetErrorCode(aFail->GetMessageString());
714 //Make a Python command
715 GEOM::TPythonDump(aFunction) << aChamfer
716 << " = geompy.MakeChamferEdgeAD(" << theShape << ", " << theD
717 << ", " << theAngle << ", " << theFace1 << ", " << theFace2 << ")";
722 //=============================================================================
726 //=============================================================================
727 Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeChamferFaces
728 (Handle(GEOM_Object) theShape, double theD1, double theD2,
729 std::list<int> theFaces)
733 //Add a new Chamfer object
734 Handle(GEOM_Object) aChamfer = GetEngine()->AddObject(GetDocID(), GEOM_CHAMFER);
736 //Add a new Chamfer function
737 Handle(GEOM_Function) aFunction =
738 aChamfer->AddFunction(GEOMImpl_ChamferDriver::GetID(), CHAMFER_SHAPE_FACES);
739 if (aFunction.IsNull()) return NULL;
741 //Check if the function is set correctly
742 if (aFunction->GetDriverGUID() != GEOMImpl_ChamferDriver::GetID()) return NULL;
744 GEOMImpl_IChamfer aCI (aFunction);
746 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
747 if (aRefShape.IsNull()) return NULL;
749 aCI.SetShape(aRefShape);
752 int aLen = theFaces.size();
756 std::list<int>::iterator it = theFaces.begin();
757 for (; it != theFaces.end(); it++, ind++) {
758 aCI.SetFace(ind, (*it));
761 //Compute the Chamfer value
763 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
766 if (!GetSolver()->ComputeFunction(aFunction)) {
767 SetErrorCode("Chamfer driver failed");
771 catch (Standard_Failure) {
772 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
773 SetErrorCode(aFail->GetMessageString());
777 //Make a Python command
778 GEOM::TPythonDump pd (aFunction);
779 pd << aChamfer << " = geompy.MakeChamferFaces(" << theShape
780 << ", " << theD1 << ", " << theD2 << ", [";
782 it = theFaces.begin();
784 while (it != theFaces.end()) {
785 pd << ", " << (*it++);
793 //=============================================================================
797 //=============================================================================
798 Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeChamferFacesAD
799 (Handle(GEOM_Object) theShape, double theD, double theAngle,
800 std::list<int> theFaces)
804 //Add a new Chamfer object
805 Handle(GEOM_Object) aChamfer = GetEngine()->AddObject(GetDocID(), GEOM_CHAMFER);
807 //Add a new Chamfer function
808 Handle(GEOM_Function) aFunction =
809 aChamfer->AddFunction(GEOMImpl_ChamferDriver::GetID(), CHAMFER_SHAPE_FACES_AD);
810 if (aFunction.IsNull()) return NULL;
812 //Check if the function is set correctly
813 if (aFunction->GetDriverGUID() != GEOMImpl_ChamferDriver::GetID()) return NULL;
815 GEOMImpl_IChamfer aCI (aFunction);
817 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
818 if (aRefShape.IsNull()) return NULL;
820 aCI.SetShape(aRefShape);
822 aCI.SetAngle(theAngle);
823 int aLen = theFaces.size();
827 std::list<int>::iterator it = theFaces.begin();
828 for (; it != theFaces.end(); it++, ind++) {
829 aCI.SetFace(ind, (*it));
832 //Compute the Chamfer value
834 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
837 if (!GetSolver()->ComputeFunction(aFunction)) {
838 SetErrorCode("Chamfer driver failed");
842 catch (Standard_Failure) {
843 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
844 SetErrorCode(aFail->GetMessageString());
848 //Make a Python command
849 GEOM::TPythonDump pd (aFunction);
850 pd << aChamfer << " = geompy.MakeChamferFacesAD(" << theShape
851 << ", " << theD << ", " << theAngle << ", [";
853 it = theFaces.begin();
855 while (it != theFaces.end()) {
856 pd << ", " << (*it++);
864 //=============================================================================
868 //=============================================================================
869 Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeChamferEdges
870 (Handle(GEOM_Object) theShape, double theD1, double theD2,
871 std::list<int> theEdges)
875 //Add a new Chamfer object
876 Handle(GEOM_Object) aChamfer = GetEngine()->AddObject(GetDocID(), GEOM_CHAMFER);
878 //Add a new Chamfer function
879 Handle(GEOM_Function) aFunction =
880 aChamfer->AddFunction(GEOMImpl_ChamferDriver::GetID(), CHAMFER_SHAPE_EDGES);
881 if (aFunction.IsNull()) { MESSAGE ( "Edges Function is NULL!!!" ); return NULL;}
883 //Check if the function is set correctly
884 if (aFunction->GetDriverGUID() != GEOMImpl_ChamferDriver::GetID())
885 { MESSAGE ( "Chamfer Driver is NULL!!!" ); return NULL; }
887 GEOMImpl_IChamfer aCI (aFunction);
889 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
890 if (aRefShape.IsNull()) { MESSAGE ("Shape is NULL!!!"); return NULL;}
892 aCI.SetShape(aRefShape);
895 int aLen = theEdges.size();
899 std::list<int>::iterator it = theEdges.begin();
900 for (; it != theEdges.end(); it++, ind++) {
901 aCI.SetEdge(ind, (*it));
904 //Compute the Chamfer value
906 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
909 if (!GetSolver()->ComputeFunction(aFunction)) {
910 SetErrorCode("Chamfer driver failed");
914 catch (Standard_Failure) {
915 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
916 SetErrorCode(aFail->GetMessageString());
920 //Make a Python command
921 GEOM::TPythonDump pd (aFunction);
922 pd << aChamfer << " = geompy.MakeChamferEdges(" << theShape
923 << ", " << theD1 << ", " << theD2 << ", [";
925 it = theEdges.begin();
927 while (it != theEdges.end()) {
928 pd << ", " << (*it++);
936 //=============================================================================
940 //=============================================================================
941 Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeChamferEdgesAD
942 (Handle(GEOM_Object) theShape, double theD, double theAngle,
943 std::list<int> theEdges)
947 //Add a new Chamfer object
948 Handle(GEOM_Object) aChamfer = GetEngine()->AddObject(GetDocID(), GEOM_CHAMFER);
950 //Add a new Chamfer function
951 Handle(GEOM_Function) aFunction =
952 aChamfer->AddFunction(GEOMImpl_ChamferDriver::GetID(), CHAMFER_SHAPE_EDGES_AD);
953 if (aFunction.IsNull()) { MESSAGE ( "Edges Function is NULL!!!" ); return NULL; }
955 //Check if the function is set correctly
956 if (aFunction->GetDriverGUID() != GEOMImpl_ChamferDriver::GetID())
957 { MESSAGE("Chamfer Driver is NULL!!!"); return NULL;}
959 GEOMImpl_IChamfer aCI (aFunction);
961 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
962 if (aRefShape.IsNull()) { MESSAGE ("Shape is NULL!!!"); return NULL;}
964 aCI.SetShape(aRefShape);
966 aCI.SetAngle(theAngle);
967 int aLen = theEdges.size();
971 std::list<int>::iterator it = theEdges.begin();
972 for (; it != theEdges.end(); it++, ind++) {
973 aCI.SetEdge(ind, (*it));
976 //Compute the Chamfer value
978 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
981 if (!GetSolver()->ComputeFunction(aFunction)) {
982 SetErrorCode("Chamfer driver failed");
986 catch (Standard_Failure) {
987 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
988 SetErrorCode(aFail->GetMessageString());
992 //Make a Python command
993 GEOM::TPythonDump pd (aFunction);
994 pd << aChamfer << " = geompy.MakeChamferEdgesAD(" << theShape
995 << ", " << theD << ", " << theAngle << ", [";
997 it = theEdges.begin();
999 while (it != theEdges.end()) {
1000 pd << ", " << (*it++);
1008 //=============================================================================
1012 //=============================================================================
1013 Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeArchimede (Handle(GEOM_Object) theShape,
1015 double theWaterDensity,
1016 double theMeshingDeflection)
1020 //Add a new Archimede object
1021 Handle(GEOM_Object) aChamfer = GetEngine()->AddObject(GetDocID(), GEOM_ARCHIMEDE);
1023 //Add a new Archimede function
1024 Handle(GEOM_Function) aFunction = aChamfer->AddFunction(GEOMImpl_ArchimedeDriver::GetID(), ARCHIMEDE_TYPE);
1025 if (aFunction.IsNull()) return NULL;
1027 //Check if the function is set correctly
1028 if (aFunction->GetDriverGUID() != GEOMImpl_ArchimedeDriver::GetID()) return NULL;
1030 GEOMImpl_IArchimede aAI (aFunction);
1032 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
1033 if (aRefShape.IsNull()) return NULL;
1035 aAI.SetBasicShape(aRefShape);
1036 aAI.SetWeight(theWeight);
1037 aAI.SetDensity(theWaterDensity);
1038 aAI.SetDeflection(theMeshingDeflection);
1040 //Compute the Archimede value
1042 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1045 if (!GetSolver()->ComputeFunction(aFunction)) {
1046 SetErrorCode("Archimede driver failed");
1050 catch (Standard_Failure) {
1051 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1052 SetErrorCode(aFail->GetMessageString());
1056 //Make a Python command
1057 GEOM::TPythonDump(aFunction) << aChamfer
1058 << " = geompy.Archimede(" << theShape << ", " << theWeight << ", "
1059 << theWaterDensity << ", " << theMeshingDeflection << ")";
1065 //=============================================================================
1069 //=============================================================================
1070 bool GEOMImpl_ILocalOperations::GetSubShape (const TopoDS_Shape& theShape, const int theIndex,
1071 TopoDS_Shape& theSubShape)
1073 if (theShape.IsNull() || theIndex < 1)
1076 TopTools_IndexedMapOfShape anIndices;
1077 TopExp::MapShapes(theShape, anIndices);
1078 if (theIndex > anIndices.Extent()) return false;
1079 theSubShape = anIndices.FindKey(theIndex);
1084 //=============================================================================
1088 //=============================================================================
1089 Standard_Integer GEOMImpl_ILocalOperations::GetSubShapeIndex (Handle(GEOM_Object) theShape,
1090 Handle(GEOM_Object) theSubShape)
1094 Standard_Integer anInd = -1;
1095 GEOM_Engine* anEngine = GetEngine();
1096 //GEOMImpl_Gen* aGen = dynamic_cast<GEOMImpl_Gen*>(anEngine);
1097 GEOMImpl_Gen* aGen = (GEOMImpl_Gen*)anEngine;
1100 GEOMImpl_IShapesOperations* anIShapesOperations =
1101 aGen->GetIShapesOperations(GetDocID());
1102 anInd = anIShapesOperations->GetSubShapeIndex(theShape, theSubShape);
1103 SetErrorCode(anIShapesOperations->GetErrorCode());