1 // Copyright (C) 2007-2011 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 <GEOMImpl_Types.hxx>
28 #include <GEOMImpl_FilletDriver.hxx>
29 #include <GEOMImpl_Fillet1dDriver.hxx>
30 #include <GEOMImpl_Fillet2dDriver.hxx>
31 #include <GEOMImpl_ChamferDriver.hxx>
33 #include <GEOMImpl_IFillet.hxx>
34 #include <GEOMImpl_IFillet1d.hxx>
35 #include <GEOMImpl_IFillet2d.hxx>
36 #include <GEOMImpl_IChamfer.hxx>
38 #include <GEOMImpl_IArchimede.hxx>
39 #include <GEOMImpl_ArchimedeDriver.hxx>
41 #include <GEOMImpl_Gen.hxx>
42 #include <GEOMImpl_IShapesOperations.hxx>
44 #include <GEOM_Function.hxx>
45 #include <GEOM_PythonDump.hxx>
47 #include <Basics_OCCTVersion.hxx>
49 #include "utilities.h"
51 #include <Utils_ExceptHandlers.hxx>
53 #include <TFunction_DriverTable.hxx>
54 #include <TFunction_Driver.hxx>
55 #include <TFunction_Logbook.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
118 #if OCC_VERSION_LARGE > 0x06010000
121 if (!GetSolver()->ComputeFunction(aFunction)) {
122 SetErrorCode("Fillet driver failed");
126 catch (Standard_Failure) {
127 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
128 SetErrorCode(aFail->GetMessageString());
132 //Make a Python command
133 GEOM::TPythonDump(aFunction) << aFillet << " = geompy.MakeFilletAll("
134 << theShape << ", " << theR << ")";
140 //=============================================================================
144 //=============================================================================
145 Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeFilletEdges
146 (Handle(GEOM_Object) theShape, double theR, std::list<int> theEdges)
150 //Add a new Fillet object
151 Handle(GEOM_Object) aFillet = GetEngine()->AddObject(GetDocID(), GEOM_FILLET);
153 //Add a new Fillet function
154 Handle(GEOM_Function) aFunction =
155 aFillet->AddFunction(GEOMImpl_FilletDriver::GetID(), FILLET_SHAPE_EDGES);
156 if (aFunction.IsNull()) return NULL;
158 //Check if the function is set correctly
159 if (aFunction->GetDriverGUID() != GEOMImpl_FilletDriver::GetID()) return NULL;
161 GEOMImpl_IFillet aCI (aFunction);
163 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
164 if (aRefShape.IsNull()) return NULL;
166 aCI.SetShape(aRefShape);
168 int aLen = theEdges.size();
172 std::list<int>::iterator it = theEdges.begin();
173 for (; it != theEdges.end(); it++, ind++) {
174 aCI.SetEdge(ind, (*it));
177 //Compute the Fillet value
179 #if OCC_VERSION_LARGE > 0x06010000
182 if (!GetSolver()->ComputeFunction(aFunction)) {
183 SetErrorCode("Fillet driver failed");
187 catch (Standard_Failure) {
188 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
189 SetErrorCode(aFail->GetMessageString());
193 //Make a Python command
194 GEOM::TPythonDump pd (aFunction);
195 pd << aFillet << " = geompy.MakeFillet(" << theShape
196 << ", " << theR << ", geompy.ShapeType[\"EDGE\"], [";
198 it = theEdges.begin();
200 while (it != theEdges.end()) {
201 pd << ", " << (*it++);
209 //=============================================================================
211 * MakeFilletEdges R1 R2
213 //=============================================================================
214 Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeFilletEdgesR1R2
215 (Handle(GEOM_Object) theShape, double theR1, double theR2, std::list<int> theEdges)
219 //Add a new Fillet object
220 Handle(GEOM_Object) aFillet = GetEngine()->AddObject(GetDocID(), GEOM_FILLET);
222 //Add a new Fillet function
223 Handle(GEOM_Function) aFunction =
224 aFillet->AddFunction(GEOMImpl_FilletDriver::GetID(), FILLET_SHAPE_EDGES_2R);
225 if (aFunction.IsNull()) return NULL;
227 //Check if the function is set correctly
228 if (aFunction->GetDriverGUID() != GEOMImpl_FilletDriver::GetID()) return NULL;
230 GEOMImpl_IFillet aCI (aFunction);
232 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
233 if (aRefShape.IsNull()) return NULL;
235 aCI.SetShape(aRefShape);
238 int aLen = theEdges.size();
242 std::list<int>::iterator it = theEdges.begin();
243 for (; it != theEdges.end(); it++, ind++) {
244 aCI.SetEdge(ind, (*it));
247 //Compute the Fillet value
249 #if OCC_VERSION_LARGE > 0x06010000
252 if (!GetSolver()->ComputeFunction(aFunction)) {
253 SetErrorCode("Fillet driver failed");
257 catch (Standard_Failure) {
258 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
259 SetErrorCode(aFail->GetMessageString());
263 //Make a Python command
264 GEOM::TPythonDump pd (aFunction);
265 pd << aFillet << " = geompy.MakeFilletR1R2(" << theShape
266 << ", " << theR1 << ", " <<theR2 << ", geompy.ShapeType[\"EDGE\"], [";
268 it = theEdges.begin();
270 while (it != theEdges.end()) {
271 pd << ", " << (*it++);
280 //=============================================================================
284 //=============================================================================
285 Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeFilletFaces
286 (Handle(GEOM_Object) theShape, double theR, std::list<int> theFaces)
290 //Add a new Fillet object
291 Handle(GEOM_Object) aFillet = GetEngine()->AddObject(GetDocID(), GEOM_FILLET);
293 //Add a new Fillet function
294 Handle(GEOM_Function) aFunction =
295 aFillet->AddFunction(GEOMImpl_FilletDriver::GetID(), FILLET_SHAPE_FACES);
296 if (aFunction.IsNull()) return NULL;
298 //Check if the function is set correctly
299 if (aFunction->GetDriverGUID() != GEOMImpl_FilletDriver::GetID()) return NULL;
301 GEOMImpl_IFillet aCI (aFunction);
303 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
304 if (aRefShape.IsNull()) return NULL;
306 aCI.SetShape(aRefShape);
308 int aLen = theFaces.size();
312 std::list<int>::iterator it = theFaces.begin();
313 for (; it != theFaces.end(); it++, ind++) {
314 aCI.SetFace(ind, (*it));
317 //Compute the Fillet value
319 #if OCC_VERSION_LARGE > 0x06010000
322 if (!GetSolver()->ComputeFunction(aFunction)) {
323 SetErrorCode("Fillet driver failed");
327 catch (Standard_Failure) {
328 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
329 SetErrorCode(aFail->GetMessageString());
333 //Make a Python command
334 GEOM::TPythonDump pd (aFunction);
335 pd << aFillet << " = geompy.MakeFillet(" << theShape
336 << ", " << theR << ", geompy.ShapeType[\"FACE\"], [";
338 it = theFaces.begin();
340 while (it != theFaces.end()) {
341 pd << ", " << (*it++);
349 //=============================================================================
351 * MakeFilletFaces R1 R2
353 //=============================================================================
354 Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeFilletFacesR1R2
355 (Handle(GEOM_Object) theShape, double theR1, double theR2, std::list<int> theFaces)
359 //Add a new Fillet object
360 Handle(GEOM_Object) aFillet = GetEngine()->AddObject(GetDocID(), GEOM_FILLET);
362 //Add a new Fillet function
363 Handle(GEOM_Function) aFunction =
364 aFillet->AddFunction(GEOMImpl_FilletDriver::GetID(), FILLET_SHAPE_FACES_2R);
365 if (aFunction.IsNull()) return NULL;
367 //Check if the function is set correctly
368 if (aFunction->GetDriverGUID() != GEOMImpl_FilletDriver::GetID()) return NULL;
370 GEOMImpl_IFillet aCI (aFunction);
372 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
373 if (aRefShape.IsNull()) return NULL;
375 aCI.SetShape(aRefShape);
378 int aLen = theFaces.size();
382 std::list<int>::iterator it = theFaces.begin();
383 for (; it != theFaces.end(); it++, ind++) {
384 aCI.SetFace(ind, (*it));
387 //Compute the Fillet value
389 #if OCC_VERSION_LARGE > 0x06010000
392 if (!GetSolver()->ComputeFunction(aFunction)) {
393 SetErrorCode("Fillet driver failed");
397 catch (Standard_Failure) {
398 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
399 SetErrorCode(aFail->GetMessageString());
403 //Make a Python command
404 GEOM::TPythonDump pd (aFunction);
405 pd << aFillet << " = geompy.MakeFilletR1R2(" << theShape
406 << ", " << theR1 << ", " << theR2 << ", geompy.ShapeType[\"FACE\"], [";
408 it = theFaces.begin();
410 while (it != theFaces.end()) {
411 pd << ", " << (*it++);
419 //=============================================================================
423 //=============================================================================
424 Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeFillet2D
425 (Handle(GEOM_Object) theShape, double theR, std::list<int> theVertexes)
429 //Add a new Fillet object
430 Handle(GEOM_Object) aFillet2D = GetEngine()->AddObject(GetDocID(), GEOM_FILLET_2D);
432 //Add a new Fillet function
433 Handle(GEOM_Function) aFunction =
434 aFillet2D->AddFunction(GEOMImpl_Fillet2dDriver::GetID(), FILLET_2D_SHAPE_VERTEXES);
435 if (aFunction.IsNull()) return NULL;
437 //Check if the function is set correctly
438 if (aFunction->GetDriverGUID() != GEOMImpl_Fillet2dDriver::GetID()) return NULL;
440 GEOMImpl_IFillet2d aCI (aFunction);
442 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
443 if (aRefShape.IsNull()) return NULL;
445 aCI.SetShape(aRefShape);
447 int aLen = theVertexes.size();
451 std::list<int>::iterator it = theVertexes.begin();
452 for (; it != theVertexes.end(); it++, ind++) {
453 aCI.SetVertex(ind, (*it));
456 //Compute the Fillet value
458 #if OCC_VERSION_LARGE > 0x06010000
461 if (!GetSolver()->ComputeFunction(aFunction)) {
462 SetErrorCode("2D Fillet driver failed");
466 catch (Standard_Failure) {
467 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
468 SetErrorCode(aFail->GetMessageString());
472 //Make a Python command
473 GEOM::TPythonDump pd (aFunction);
474 pd << aFillet2D << " = geompy.MakeFillet2D(" << theShape
475 << ", " << theR << ", [";
477 it = theVertexes.begin();
479 while (it != theVertexes.end()) {
480 pd << ", " << (*it++);
488 //=============================================================================
492 //=============================================================================
493 Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeFillet1D
494 (Handle(GEOM_Object) theShape, double theR, std::list<int> theVertexes)
498 //Add a new Fillet object
499 Handle(GEOM_Object) aFillet1D = GetEngine()->AddObject(GetDocID(), GEOM_FILLET_1D);
501 //Add a new Fillet function
502 Handle(GEOM_Function) aFunction =
503 aFillet1D->AddFunction(GEOMImpl_Fillet1dDriver::GetID(), FILLET_1D_SHAPE_VERTEXES);
504 if (aFunction.IsNull()) return NULL;
506 //Check if the function is set correctly
507 if (aFunction->GetDriverGUID() != GEOMImpl_Fillet1dDriver::GetID()) return NULL;
509 GEOMImpl_IFillet1d aCI (aFunction);
511 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
512 if (aRefShape.IsNull()) return NULL;
514 aCI.SetShape(aRefShape);
516 int aLen = theVertexes.size();
520 std::list<int>::iterator it = theVertexes.begin();
521 for (; it != theVertexes.end(); it++, ind++) {
522 aCI.SetVertex(ind, (*it));
525 //Compute the Fillet value
527 #if OCC_VERSION_LARGE > 0x06010000
530 if (!GetSolver()->ComputeFunction(aFunction)) {
531 SetErrorCode("1D Fillet driver failed");
535 catch (Standard_Failure) {
536 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
537 SetErrorCode(aFail->GetMessageString());
541 //Make a Python command
542 GEOM::TPythonDump pd (aFunction);
543 pd << aFillet1D << " = geompy.MakeFillet1D(" << theShape
544 << ", " << theR << ", [";
546 it = theVertexes.begin();
547 if (it != theVertexes.end()) {
549 while (it != theVertexes.end())
550 pd << ", " << (*it++);
558 //=============================================================================
562 //=============================================================================
563 Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeChamferAll (Handle(GEOM_Object) theShape, double theD)
567 //Add a new Chamfer object
568 Handle(GEOM_Object) aChamfer = GetEngine()->AddObject(GetDocID(), GEOM_CHAMFER);
570 //Add a new Chamfer function
571 Handle(GEOM_Function) aFunction =
572 aChamfer->AddFunction(GEOMImpl_ChamferDriver::GetID(), CHAMFER_SHAPE_ALL);
573 if (aFunction.IsNull()) return NULL;
575 //Check if the function is set correctly
576 if (aFunction->GetDriverGUID() != GEOMImpl_ChamferDriver::GetID()) return NULL;
578 GEOMImpl_IChamfer aCI (aFunction);
580 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
581 if (aRefShape.IsNull()) return NULL;
583 aCI.SetShape(aRefShape);
586 //Compute the Chamfer value
588 #if OCC_VERSION_LARGE > 0x06010000
591 if (!GetSolver()->ComputeFunction(aFunction)) {
592 SetErrorCode("Chamfer driver failed");
596 catch (Standard_Failure) {
597 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
598 SetErrorCode(aFail->GetMessageString());
602 //Make a Python command
603 GEOM::TPythonDump(aFunction) << aChamfer << " = geompy.MakeChamferAll("
604 << theShape << ", " << theD << ")";
610 //=============================================================================
614 //=============================================================================
615 Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeChamferEdge
616 (Handle(GEOM_Object) theShape, double theD1, double theD2,
617 int theFace1, int theFace2)
621 //Add a new Chamfer object
622 Handle(GEOM_Object) aChamfer = GetEngine()->AddObject(GetDocID(), GEOM_CHAMFER);
624 //Add a new Chamfer function
625 Handle(GEOM_Function) aFunction =
626 aChamfer->AddFunction(GEOMImpl_ChamferDriver::GetID(), CHAMFER_SHAPE_EDGE);
627 if (aFunction.IsNull()) return NULL;
629 //Check if the function is set correctly
630 if (aFunction->GetDriverGUID() != GEOMImpl_ChamferDriver::GetID()) return NULL;
632 GEOMImpl_IChamfer aCI (aFunction);
634 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
635 if (aRefShape.IsNull()) return NULL;
637 aCI.SetShape(aRefShape);
640 aCI.SetFace1(theFace1);
641 aCI.SetFace2(theFace2);
643 //Compute the Chamfer value
645 #if OCC_VERSION_LARGE > 0x06010000
648 if (!GetSolver()->ComputeFunction(aFunction)) {
649 SetErrorCode("Chamfer driver failed");
653 catch (Standard_Failure) {
654 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
655 SetErrorCode(aFail->GetMessageString());
659 //Make a Python command
660 GEOM::TPythonDump(aFunction) << aChamfer
661 << " = geompy.MakeChamferEdge(" << theShape << ", " << theD1
662 << ", " << theD2 << ", " << theFace1 << ", " << theFace2 << ")";
668 //=============================================================================
672 //=============================================================================
673 Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeChamferEdgeAD
674 (Handle(GEOM_Object) theShape, double theD, double theAngle,
675 int theFace1, int theFace2)
679 //Add a new Chamfer object
680 Handle(GEOM_Object) aChamfer = GetEngine()->AddObject(GetDocID(), GEOM_CHAMFER);
682 //Add a new Chamfer function
683 Handle(GEOM_Function) aFunction =
684 aChamfer->AddFunction(GEOMImpl_ChamferDriver::GetID(), CHAMFER_SHAPE_EDGE_AD);
685 if (aFunction.IsNull()) return NULL;
687 //Check if the function is set correctly
688 if (aFunction->GetDriverGUID() != GEOMImpl_ChamferDriver::GetID()) return NULL;
690 GEOMImpl_IChamfer aCI (aFunction);
692 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
693 if (aRefShape.IsNull()) return NULL;
695 aCI.SetShape(aRefShape);
697 aCI.SetAngle(theAngle);
698 aCI.SetFace1(theFace1);
699 aCI.SetFace2(theFace2);
701 //Compute the Chamfer value
703 #if OCC_VERSION_LARGE > 0x06010000
706 if (!GetSolver()->ComputeFunction(aFunction)) {
707 SetErrorCode("Chamfer driver failed");
711 catch (Standard_Failure) {
712 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
713 SetErrorCode(aFail->GetMessageString());
717 //Make a Python command
718 GEOM::TPythonDump(aFunction) << aChamfer
719 << " = geompy.MakeChamferEdgeAD(" << theShape << ", " << theD
720 << ", " << theAngle << ", " << theFace1 << ", " << theFace2 << ")";
725 //=============================================================================
729 //=============================================================================
730 Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeChamferFaces
731 (Handle(GEOM_Object) theShape, double theD1, double theD2,
732 std::list<int> theFaces)
736 //Add a new Chamfer object
737 Handle(GEOM_Object) aChamfer = GetEngine()->AddObject(GetDocID(), GEOM_CHAMFER);
739 //Add a new Chamfer function
740 Handle(GEOM_Function) aFunction =
741 aChamfer->AddFunction(GEOMImpl_ChamferDriver::GetID(), CHAMFER_SHAPE_FACES);
742 if (aFunction.IsNull()) return NULL;
744 //Check if the function is set correctly
745 if (aFunction->GetDriverGUID() != GEOMImpl_ChamferDriver::GetID()) return NULL;
747 GEOMImpl_IChamfer aCI (aFunction);
749 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
750 if (aRefShape.IsNull()) return NULL;
752 aCI.SetShape(aRefShape);
755 int aLen = theFaces.size();
759 std::list<int>::iterator it = theFaces.begin();
760 for (; it != theFaces.end(); it++, ind++) {
761 aCI.SetFace(ind, (*it));
764 //Compute the Chamfer value
766 #if OCC_VERSION_LARGE > 0x06010000
769 if (!GetSolver()->ComputeFunction(aFunction)) {
770 SetErrorCode("Chamfer driver failed");
774 catch (Standard_Failure) {
775 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
776 SetErrorCode(aFail->GetMessageString());
780 //Make a Python command
781 GEOM::TPythonDump pd (aFunction);
782 pd << aChamfer << " = geompy.MakeChamferFaces(" << theShape
783 << ", " << theD1 << ", " << theD2 << ", [";
785 it = theFaces.begin();
787 while (it != theFaces.end()) {
788 pd << ", " << (*it++);
796 //=============================================================================
800 //=============================================================================
801 Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeChamferFacesAD
802 (Handle(GEOM_Object) theShape, double theD, double theAngle,
803 std::list<int> theFaces)
807 //Add a new Chamfer object
808 Handle(GEOM_Object) aChamfer = GetEngine()->AddObject(GetDocID(), GEOM_CHAMFER);
810 //Add a new Chamfer function
811 Handle(GEOM_Function) aFunction =
812 aChamfer->AddFunction(GEOMImpl_ChamferDriver::GetID(), CHAMFER_SHAPE_FACES_AD);
813 if (aFunction.IsNull()) return NULL;
815 //Check if the function is set correctly
816 if (aFunction->GetDriverGUID() != GEOMImpl_ChamferDriver::GetID()) return NULL;
818 GEOMImpl_IChamfer aCI (aFunction);
820 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
821 if (aRefShape.IsNull()) return NULL;
823 aCI.SetShape(aRefShape);
825 aCI.SetAngle(theAngle);
826 int aLen = theFaces.size();
830 std::list<int>::iterator it = theFaces.begin();
831 for (; it != theFaces.end(); it++, ind++) {
832 aCI.SetFace(ind, (*it));
835 //Compute the Chamfer value
837 #if OCC_VERSION_LARGE > 0x06010000
840 if (!GetSolver()->ComputeFunction(aFunction)) {
841 SetErrorCode("Chamfer driver failed");
845 catch (Standard_Failure) {
846 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
847 SetErrorCode(aFail->GetMessageString());
851 //Make a Python command
852 GEOM::TPythonDump pd (aFunction);
853 pd << aChamfer << " = geompy.MakeChamferFacesAD(" << theShape
854 << ", " << theD << ", " << theAngle << ", [";
856 it = theFaces.begin();
858 while (it != theFaces.end()) {
859 pd << ", " << (*it++);
867 //=============================================================================
871 //=============================================================================
872 Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeChamferEdges
873 (Handle(GEOM_Object) theShape, double theD1, double theD2,
874 std::list<int> theEdges)
878 //Add a new Chamfer object
879 Handle(GEOM_Object) aChamfer = GetEngine()->AddObject(GetDocID(), GEOM_CHAMFER);
881 //Add a new Chamfer function
882 Handle(GEOM_Function) aFunction =
883 aChamfer->AddFunction(GEOMImpl_ChamferDriver::GetID(), CHAMFER_SHAPE_EDGES);
884 if (aFunction.IsNull()) { MESSAGE ( "Edges Function is NULL!!!" ); return NULL;}
886 //Check if the function is set correctly
887 if (aFunction->GetDriverGUID() != GEOMImpl_ChamferDriver::GetID())
888 { MESSAGE ( "Chamfer Driver is NULL!!!" ); return NULL; }
890 GEOMImpl_IChamfer aCI (aFunction);
892 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
893 if (aRefShape.IsNull()) { MESSAGE ("Shape is NULL!!!"); return NULL;}
895 aCI.SetShape(aRefShape);
898 int aLen = theEdges.size();
902 std::list<int>::iterator it = theEdges.begin();
903 for (; it != theEdges.end(); it++, ind++) {
904 aCI.SetEdge(ind, (*it));
907 //Compute the Chamfer value
909 #if OCC_VERSION_LARGE > 0x06010000
912 if (!GetSolver()->ComputeFunction(aFunction)) {
913 SetErrorCode("Chamfer driver failed");
917 catch (Standard_Failure) {
918 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
919 SetErrorCode(aFail->GetMessageString());
923 //Make a Python command
924 GEOM::TPythonDump pd (aFunction);
925 pd << aChamfer << " = geompy.MakeChamferEdges(" << theShape
926 << ", " << theD1 << ", " << theD2 << ", [";
928 it = theEdges.begin();
930 while (it != theEdges.end()) {
931 pd << ", " << (*it++);
939 //=============================================================================
943 //=============================================================================
944 Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeChamferEdgesAD
945 (Handle(GEOM_Object) theShape, double theD, double theAngle,
946 std::list<int> theEdges)
950 //Add a new Chamfer object
951 Handle(GEOM_Object) aChamfer = GetEngine()->AddObject(GetDocID(), GEOM_CHAMFER);
953 //Add a new Chamfer function
954 Handle(GEOM_Function) aFunction =
955 aChamfer->AddFunction(GEOMImpl_ChamferDriver::GetID(), CHAMFER_SHAPE_EDGES_AD);
956 if (aFunction.IsNull()) { MESSAGE ( "Edges Function is NULL!!!" ); return NULL; }
958 //Check if the function is set correctly
959 if (aFunction->GetDriverGUID() != GEOMImpl_ChamferDriver::GetID())
960 { MESSAGE("Chamfer Driver is NULL!!!"); return NULL;}
962 GEOMImpl_IChamfer aCI (aFunction);
964 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
965 if (aRefShape.IsNull()) { MESSAGE ("Shape is NULL!!!"); return NULL;}
967 aCI.SetShape(aRefShape);
969 aCI.SetAngle(theAngle);
970 int aLen = theEdges.size();
974 std::list<int>::iterator it = theEdges.begin();
975 for (; it != theEdges.end(); it++, ind++) {
976 aCI.SetEdge(ind, (*it));
979 //Compute the Chamfer value
981 #if OCC_VERSION_LARGE > 0x06010000
984 if (!GetSolver()->ComputeFunction(aFunction)) {
985 SetErrorCode("Chamfer driver failed");
989 catch (Standard_Failure) {
990 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
991 SetErrorCode(aFail->GetMessageString());
995 //Make a Python command
996 GEOM::TPythonDump pd (aFunction);
997 pd << aChamfer << " = geompy.MakeChamferEdgesAD(" << theShape
998 << ", " << theD << ", " << theAngle << ", [";
1000 it = theEdges.begin();
1002 while (it != theEdges.end()) {
1003 pd << ", " << (*it++);
1011 //=============================================================================
1015 //=============================================================================
1016 Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeArchimede (Handle(GEOM_Object) theShape,
1018 double theWaterDensity,
1019 double theMeshingDeflection)
1023 //Add a new Archimede object
1024 Handle(GEOM_Object) aChamfer = GetEngine()->AddObject(GetDocID(), GEOM_ARCHIMEDE);
1026 //Add a new Archimede function
1027 Handle(GEOM_Function) aFunction = aChamfer->AddFunction(GEOMImpl_ArchimedeDriver::GetID(), ARCHIMEDE_TYPE);
1028 if (aFunction.IsNull()) return NULL;
1030 //Check if the function is set correctly
1031 if (aFunction->GetDriverGUID() != GEOMImpl_ArchimedeDriver::GetID()) return NULL;
1033 GEOMImpl_IArchimede aAI (aFunction);
1035 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
1036 if (aRefShape.IsNull()) return NULL;
1038 aAI.SetBasicShape(aRefShape);
1039 aAI.SetWeight(theWeight);
1040 aAI.SetDensity(theWaterDensity);
1041 aAI.SetDeflection(theMeshingDeflection);
1043 //Compute the Archimede value
1045 #if OCC_VERSION_LARGE > 0x06010000
1048 if (!GetSolver()->ComputeFunction(aFunction)) {
1049 SetErrorCode("Archimede driver failed");
1053 catch (Standard_Failure) {
1054 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1055 SetErrorCode(aFail->GetMessageString());
1059 //Make a Python command
1060 GEOM::TPythonDump(aFunction) << aChamfer
1061 << " = geompy.Archimede(" << theShape << ", " << theWeight << ", "
1062 << theWaterDensity << ", " << theMeshingDeflection << ")";
1068 //=============================================================================
1072 //=============================================================================
1073 bool GEOMImpl_ILocalOperations::GetSubShape (const TopoDS_Shape& theShape, const int theIndex,
1074 TopoDS_Shape& theSubShape)
1076 if (theShape.IsNull() || theIndex < 1)
1079 TopTools_IndexedMapOfShape anIndices;
1080 TopExp::MapShapes(theShape, anIndices);
1081 if (theIndex > anIndices.Extent()) return false;
1082 theSubShape = anIndices.FindKey(theIndex);
1087 //=============================================================================
1091 //=============================================================================
1092 Standard_Integer GEOMImpl_ILocalOperations::GetSubShapeIndex (Handle(GEOM_Object) theShape,
1093 Handle(GEOM_Object) theSubShape)
1097 Standard_Integer anInd = -1;
1098 GEOM_Engine* anEngine = GetEngine();
1099 //GEOMImpl_Gen* aGen = dynamic_cast<GEOMImpl_Gen*>(anEngine);
1100 GEOMImpl_Gen* aGen = (GEOMImpl_Gen*)anEngine;
1103 GEOMImpl_IShapesOperations* anIShapesOperations =
1104 aGen->GetIShapesOperations(GetDocID());
1105 anInd = anIShapesOperations->GetSubShapeIndex(theShape, theSubShape);
1106 SetErrorCode(anIShapesOperations->GetErrorCode());