1 // Copyright (C) 2007-2012 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,
495 std::list<int> theVertexes, bool doIgnoreSecantVertices)
499 //Add a new Fillet object
500 Handle(GEOM_Object) aFillet1D = GetEngine()->AddObject(GetDocID(), GEOM_FILLET_1D);
502 //Add a new Fillet function
503 Handle(GEOM_Function) aFunction =
504 aFillet1D->AddFunction(GEOMImpl_Fillet1dDriver::GetID(), FILLET_1D_SHAPE_VERTEXES);
505 if (aFunction.IsNull()) return NULL;
507 //Check if the function is set correctly
508 if (aFunction->GetDriverGUID() != GEOMImpl_Fillet1dDriver::GetID()) return NULL;
510 GEOMImpl_IFillet1d aCI (aFunction);
512 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
513 if (aRefShape.IsNull()) return NULL;
515 aCI.SetShape(aRefShape);
517 aCI.SetFlag(doIgnoreSecantVertices);
518 int aLen = theVertexes.size();
522 std::list<int>::iterator it = theVertexes.begin();
523 for (; it != theVertexes.end(); it++, ind++) {
524 aCI.SetVertex(ind, (*it));
527 //Compute the Fillet value
529 #if OCC_VERSION_LARGE > 0x06010000
532 if (!GetSolver()->ComputeFunction(aFunction)) {
533 SetErrorCode("1D Fillet driver failed");
537 catch (Standard_Failure) {
538 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
539 SetErrorCode(aFail->GetMessageString());
543 //Make a Python command
544 GEOM::TPythonDump pd (aFunction);
545 pd << aFillet1D << " = geompy.MakeFillet1D(" << theShape
546 << ", " << theR << ", [";
548 it = theVertexes.begin();
549 if (it != theVertexes.end()) {
551 while (it != theVertexes.end())
552 pd << ", " << (*it++);
560 //=============================================================================
564 //=============================================================================
565 Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeChamferAll (Handle(GEOM_Object) theShape, double theD)
569 //Add a new Chamfer object
570 Handle(GEOM_Object) aChamfer = GetEngine()->AddObject(GetDocID(), GEOM_CHAMFER);
572 //Add a new Chamfer function
573 Handle(GEOM_Function) aFunction =
574 aChamfer->AddFunction(GEOMImpl_ChamferDriver::GetID(), CHAMFER_SHAPE_ALL);
575 if (aFunction.IsNull()) return NULL;
577 //Check if the function is set correctly
578 if (aFunction->GetDriverGUID() != GEOMImpl_ChamferDriver::GetID()) return NULL;
580 GEOMImpl_IChamfer aCI (aFunction);
582 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
583 if (aRefShape.IsNull()) return NULL;
585 aCI.SetShape(aRefShape);
588 //Compute the Chamfer value
590 #if OCC_VERSION_LARGE > 0x06010000
593 if (!GetSolver()->ComputeFunction(aFunction)) {
594 SetErrorCode("Chamfer driver failed");
598 catch (Standard_Failure) {
599 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
600 SetErrorCode(aFail->GetMessageString());
604 //Make a Python command
605 GEOM::TPythonDump(aFunction) << aChamfer << " = geompy.MakeChamferAll("
606 << theShape << ", " << theD << ")";
612 //=============================================================================
616 //=============================================================================
617 Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeChamferEdge
618 (Handle(GEOM_Object) theShape, double theD1, double theD2,
619 int theFace1, int theFace2)
623 //Add a new Chamfer object
624 Handle(GEOM_Object) aChamfer = GetEngine()->AddObject(GetDocID(), GEOM_CHAMFER);
626 //Add a new Chamfer function
627 Handle(GEOM_Function) aFunction =
628 aChamfer->AddFunction(GEOMImpl_ChamferDriver::GetID(), CHAMFER_SHAPE_EDGE);
629 if (aFunction.IsNull()) return NULL;
631 //Check if the function is set correctly
632 if (aFunction->GetDriverGUID() != GEOMImpl_ChamferDriver::GetID()) return NULL;
634 GEOMImpl_IChamfer aCI (aFunction);
636 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
637 if (aRefShape.IsNull()) return NULL;
639 aCI.SetShape(aRefShape);
642 aCI.SetFace1(theFace1);
643 aCI.SetFace2(theFace2);
645 //Compute the Chamfer value
647 #if OCC_VERSION_LARGE > 0x06010000
650 if (!GetSolver()->ComputeFunction(aFunction)) {
651 SetErrorCode("Chamfer driver failed");
655 catch (Standard_Failure) {
656 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
657 SetErrorCode(aFail->GetMessageString());
661 //Make a Python command
662 GEOM::TPythonDump(aFunction) << aChamfer
663 << " = geompy.MakeChamferEdge(" << theShape << ", " << theD1
664 << ", " << theD2 << ", " << theFace1 << ", " << theFace2 << ")";
670 //=============================================================================
674 //=============================================================================
675 Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeChamferEdgeAD
676 (Handle(GEOM_Object) theShape, double theD, double theAngle,
677 int theFace1, int theFace2)
681 //Add a new Chamfer object
682 Handle(GEOM_Object) aChamfer = GetEngine()->AddObject(GetDocID(), GEOM_CHAMFER);
684 //Add a new Chamfer function
685 Handle(GEOM_Function) aFunction =
686 aChamfer->AddFunction(GEOMImpl_ChamferDriver::GetID(), CHAMFER_SHAPE_EDGE_AD);
687 if (aFunction.IsNull()) return NULL;
689 //Check if the function is set correctly
690 if (aFunction->GetDriverGUID() != GEOMImpl_ChamferDriver::GetID()) return NULL;
692 GEOMImpl_IChamfer aCI (aFunction);
694 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
695 if (aRefShape.IsNull()) return NULL;
697 aCI.SetShape(aRefShape);
699 aCI.SetAngle(theAngle);
700 aCI.SetFace1(theFace1);
701 aCI.SetFace2(theFace2);
703 //Compute the Chamfer value
705 #if OCC_VERSION_LARGE > 0x06010000
708 if (!GetSolver()->ComputeFunction(aFunction)) {
709 SetErrorCode("Chamfer driver failed");
713 catch (Standard_Failure) {
714 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
715 SetErrorCode(aFail->GetMessageString());
719 //Make a Python command
720 GEOM::TPythonDump(aFunction) << aChamfer
721 << " = geompy.MakeChamferEdgeAD(" << theShape << ", " << theD
722 << ", " << theAngle << ", " << theFace1 << ", " << theFace2 << ")";
727 //=============================================================================
731 //=============================================================================
732 Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeChamferFaces
733 (Handle(GEOM_Object) theShape, double theD1, double theD2,
734 std::list<int> theFaces)
738 //Add a new Chamfer object
739 Handle(GEOM_Object) aChamfer = GetEngine()->AddObject(GetDocID(), GEOM_CHAMFER);
741 //Add a new Chamfer function
742 Handle(GEOM_Function) aFunction =
743 aChamfer->AddFunction(GEOMImpl_ChamferDriver::GetID(), CHAMFER_SHAPE_FACES);
744 if (aFunction.IsNull()) return NULL;
746 //Check if the function is set correctly
747 if (aFunction->GetDriverGUID() != GEOMImpl_ChamferDriver::GetID()) return NULL;
749 GEOMImpl_IChamfer aCI (aFunction);
751 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
752 if (aRefShape.IsNull()) return NULL;
754 aCI.SetShape(aRefShape);
757 int aLen = theFaces.size();
761 std::list<int>::iterator it = theFaces.begin();
762 for (; it != theFaces.end(); it++, ind++) {
763 aCI.SetFace(ind, (*it));
766 //Compute the Chamfer value
768 #if OCC_VERSION_LARGE > 0x06010000
771 if (!GetSolver()->ComputeFunction(aFunction)) {
772 SetErrorCode("Chamfer driver failed");
776 catch (Standard_Failure) {
777 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
778 SetErrorCode(aFail->GetMessageString());
782 //Make a Python command
783 GEOM::TPythonDump pd (aFunction);
784 pd << aChamfer << " = geompy.MakeChamferFaces(" << theShape
785 << ", " << theD1 << ", " << theD2 << ", [";
787 it = theFaces.begin();
789 while (it != theFaces.end()) {
790 pd << ", " << (*it++);
798 //=============================================================================
802 //=============================================================================
803 Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeChamferFacesAD
804 (Handle(GEOM_Object) theShape, double theD, double theAngle,
805 std::list<int> theFaces)
809 //Add a new Chamfer object
810 Handle(GEOM_Object) aChamfer = GetEngine()->AddObject(GetDocID(), GEOM_CHAMFER);
812 //Add a new Chamfer function
813 Handle(GEOM_Function) aFunction =
814 aChamfer->AddFunction(GEOMImpl_ChamferDriver::GetID(), CHAMFER_SHAPE_FACES_AD);
815 if (aFunction.IsNull()) return NULL;
817 //Check if the function is set correctly
818 if (aFunction->GetDriverGUID() != GEOMImpl_ChamferDriver::GetID()) return NULL;
820 GEOMImpl_IChamfer aCI (aFunction);
822 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
823 if (aRefShape.IsNull()) return NULL;
825 aCI.SetShape(aRefShape);
827 aCI.SetAngle(theAngle);
828 int aLen = theFaces.size();
832 std::list<int>::iterator it = theFaces.begin();
833 for (; it != theFaces.end(); it++, ind++) {
834 aCI.SetFace(ind, (*it));
837 //Compute the Chamfer value
839 #if OCC_VERSION_LARGE > 0x06010000
842 if (!GetSolver()->ComputeFunction(aFunction)) {
843 SetErrorCode("Chamfer driver failed");
847 catch (Standard_Failure) {
848 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
849 SetErrorCode(aFail->GetMessageString());
853 //Make a Python command
854 GEOM::TPythonDump pd (aFunction);
855 pd << aChamfer << " = geompy.MakeChamferFacesAD(" << theShape
856 << ", " << theD << ", " << theAngle << ", [";
858 it = theFaces.begin();
860 while (it != theFaces.end()) {
861 pd << ", " << (*it++);
869 //=============================================================================
873 //=============================================================================
874 Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeChamferEdges
875 (Handle(GEOM_Object) theShape, double theD1, double theD2,
876 std::list<int> theEdges)
880 //Add a new Chamfer object
881 Handle(GEOM_Object) aChamfer = GetEngine()->AddObject(GetDocID(), GEOM_CHAMFER);
883 //Add a new Chamfer function
884 Handle(GEOM_Function) aFunction =
885 aChamfer->AddFunction(GEOMImpl_ChamferDriver::GetID(), CHAMFER_SHAPE_EDGES);
886 if (aFunction.IsNull()) { MESSAGE ( "Edges Function is NULL!!!" ); return NULL;}
888 //Check if the function is set correctly
889 if (aFunction->GetDriverGUID() != GEOMImpl_ChamferDriver::GetID())
890 { MESSAGE ( "Chamfer Driver is NULL!!!" ); return NULL; }
892 GEOMImpl_IChamfer aCI (aFunction);
894 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
895 if (aRefShape.IsNull()) { MESSAGE ("Shape is NULL!!!"); return NULL;}
897 aCI.SetShape(aRefShape);
900 int aLen = theEdges.size();
904 std::list<int>::iterator it = theEdges.begin();
905 for (; it != theEdges.end(); it++, ind++) {
906 aCI.SetEdge(ind, (*it));
909 //Compute the Chamfer value
911 #if OCC_VERSION_LARGE > 0x06010000
914 if (!GetSolver()->ComputeFunction(aFunction)) {
915 SetErrorCode("Chamfer driver failed");
919 catch (Standard_Failure) {
920 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
921 SetErrorCode(aFail->GetMessageString());
925 //Make a Python command
926 GEOM::TPythonDump pd (aFunction);
927 pd << aChamfer << " = geompy.MakeChamferEdges(" << theShape
928 << ", " << theD1 << ", " << theD2 << ", [";
930 it = theEdges.begin();
932 while (it != theEdges.end()) {
933 pd << ", " << (*it++);
941 //=============================================================================
945 //=============================================================================
946 Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeChamferEdgesAD
947 (Handle(GEOM_Object) theShape, double theD, double theAngle,
948 std::list<int> theEdges)
952 //Add a new Chamfer object
953 Handle(GEOM_Object) aChamfer = GetEngine()->AddObject(GetDocID(), GEOM_CHAMFER);
955 //Add a new Chamfer function
956 Handle(GEOM_Function) aFunction =
957 aChamfer->AddFunction(GEOMImpl_ChamferDriver::GetID(), CHAMFER_SHAPE_EDGES_AD);
958 if (aFunction.IsNull()) { MESSAGE ( "Edges Function is NULL!!!" ); return NULL; }
960 //Check if the function is set correctly
961 if (aFunction->GetDriverGUID() != GEOMImpl_ChamferDriver::GetID())
962 { MESSAGE("Chamfer Driver is NULL!!!"); return NULL;}
964 GEOMImpl_IChamfer aCI (aFunction);
966 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
967 if (aRefShape.IsNull()) { MESSAGE ("Shape is NULL!!!"); return NULL;}
969 aCI.SetShape(aRefShape);
971 aCI.SetAngle(theAngle);
972 int aLen = theEdges.size();
976 std::list<int>::iterator it = theEdges.begin();
977 for (; it != theEdges.end(); it++, ind++) {
978 aCI.SetEdge(ind, (*it));
981 //Compute the Chamfer value
983 #if OCC_VERSION_LARGE > 0x06010000
986 if (!GetSolver()->ComputeFunction(aFunction)) {
987 SetErrorCode("Chamfer driver failed");
991 catch (Standard_Failure) {
992 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
993 SetErrorCode(aFail->GetMessageString());
997 //Make a Python command
998 GEOM::TPythonDump pd (aFunction);
999 pd << aChamfer << " = geompy.MakeChamferEdgesAD(" << theShape
1000 << ", " << theD << ", " << theAngle << ", [";
1002 it = theEdges.begin();
1004 while (it != theEdges.end()) {
1005 pd << ", " << (*it++);
1013 //=============================================================================
1017 //=============================================================================
1018 Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeArchimede (Handle(GEOM_Object) theShape,
1020 double theWaterDensity,
1021 double theMeshingDeflection)
1025 //Add a new Archimede object
1026 Handle(GEOM_Object) aChamfer = GetEngine()->AddObject(GetDocID(), GEOM_ARCHIMEDE);
1028 //Add a new Archimede function
1029 Handle(GEOM_Function) aFunction = aChamfer->AddFunction(GEOMImpl_ArchimedeDriver::GetID(), ARCHIMEDE_TYPE);
1030 if (aFunction.IsNull()) return NULL;
1032 //Check if the function is set correctly
1033 if (aFunction->GetDriverGUID() != GEOMImpl_ArchimedeDriver::GetID()) return NULL;
1035 GEOMImpl_IArchimede aAI (aFunction);
1037 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
1038 if (aRefShape.IsNull()) return NULL;
1040 aAI.SetBasicShape(aRefShape);
1041 aAI.SetWeight(theWeight);
1042 aAI.SetDensity(theWaterDensity);
1043 aAI.SetDeflection(theMeshingDeflection);
1045 //Compute the Archimede value
1047 #if OCC_VERSION_LARGE > 0x06010000
1050 if (!GetSolver()->ComputeFunction(aFunction)) {
1051 SetErrorCode("Archimede driver failed");
1055 catch (Standard_Failure) {
1056 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1057 SetErrorCode(aFail->GetMessageString());
1061 //Make a Python command
1062 GEOM::TPythonDump(aFunction) << aChamfer
1063 << " = geompy.Archimede(" << theShape << ", " << theWeight << ", "
1064 << theWaterDensity << ", " << theMeshingDeflection << ")";
1070 //=============================================================================
1074 //=============================================================================
1075 bool GEOMImpl_ILocalOperations::GetSubShape (const TopoDS_Shape& theShape, const int theIndex,
1076 TopoDS_Shape& theSubShape)
1078 if (theShape.IsNull() || theIndex < 1)
1081 TopTools_IndexedMapOfShape anIndices;
1082 TopExp::MapShapes(theShape, anIndices);
1083 if (theIndex > anIndices.Extent()) return false;
1084 theSubShape = anIndices.FindKey(theIndex);
1089 //=============================================================================
1093 //=============================================================================
1094 Standard_Integer GEOMImpl_ILocalOperations::GetSubShapeIndex (Handle(GEOM_Object) theShape,
1095 Handle(GEOM_Object) theSubShape)
1099 Standard_Integer anInd = -1;
1100 GEOM_Engine* anEngine = GetEngine();
1101 //GEOMImpl_Gen* aGen = dynamic_cast<GEOMImpl_Gen*>(anEngine);
1102 GEOMImpl_Gen* aGen = (GEOMImpl_Gen*)anEngine;
1105 GEOMImpl_IShapesOperations* anIShapesOperations =
1106 aGen->GetIShapesOperations(GetDocID());
1107 anInd = anIShapesOperations->GetSubShapeIndex(theShape, theSubShape);
1108 SetErrorCode(anIShapesOperations->GetErrorCode());