1 // Copyright (C) 2007-2010 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
23 #include <Standard_Stream.hxx>
25 #include <GEOMImpl_ILocalOperations.hxx>
27 #include <GEOM_Function.hxx>
28 #include <GEOM_PythonDump.hxx>
30 #include <GEOMImpl_Types.hxx>
32 #include <GEOMImpl_FilletDriver.hxx>
33 #include <GEOMImpl_Fillet1dDriver.hxx>
34 #include <GEOMImpl_Fillet2dDriver.hxx>
35 #include <GEOMImpl_ChamferDriver.hxx>
37 #include <GEOMImpl_IFillet.hxx>
38 #include <GEOMImpl_IFillet1d.hxx>
39 #include <GEOMImpl_IFillet2d.hxx>
40 #include <GEOMImpl_IChamfer.hxx>
42 #include <GEOMImpl_IArchimede.hxx>
43 #include <GEOMImpl_ArchimedeDriver.hxx>
45 #include <GEOMImpl_Gen.hxx>
46 #include <GEOMImpl_IShapesOperations.hxx>
48 #include "utilities.h"
50 #include <Utils_ExceptHandlers.hxx>
52 #include <TFunction_DriverTable.hxx>
53 #include <TFunction_Driver.hxx>
54 #include <TFunction_Logbook.hxx>
55 #include <TDF_Tool.hxx>
58 #include <TopoDS_TShape.hxx>
59 #include <TopTools_IndexedMapOfShape.hxx>
61 #include <Standard_Failure.hxx>
62 #include <Standard_ErrorHandler.hxx> // CAREFUL ! position of this file is critic : see Lucien PIGNOLONI / OCC
64 //=============================================================================
68 //=============================================================================
69 GEOMImpl_ILocalOperations::GEOMImpl_ILocalOperations (GEOM_Engine* theEngine, int theDocID)
70 : GEOM_IOperations(theEngine, theDocID)
72 MESSAGE("GEOMImpl_ILocalOperations::GEOMImpl_ILocalOperations");
75 //=============================================================================
79 //=============================================================================
80 GEOMImpl_ILocalOperations::~GEOMImpl_ILocalOperations()
82 MESSAGE("GEOMImpl_ILocalOperations::~GEOMImpl_ILocalOperations");
86 //=============================================================================
90 //=============================================================================
91 Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeFilletAll
92 (Handle(GEOM_Object) theShape, double theR)
96 //Add a new Fillet object
97 Handle(GEOM_Object) aFillet = GetEngine()->AddObject(GetDocID(), GEOM_FILLET);
99 //Add a new Fillet function
100 Handle(GEOM_Function) aFunction =
101 aFillet->AddFunction(GEOMImpl_FilletDriver::GetID(), FILLET_SHAPE_ALL);
102 if (aFunction.IsNull()) return NULL;
104 //Check if the function is set correctly
105 if (aFunction->GetDriverGUID() != GEOMImpl_FilletDriver::GetID()) return NULL;
107 GEOMImpl_IFillet aCI (aFunction);
109 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
110 if (aRefShape.IsNull()) return NULL;
112 aCI.SetShape(aRefShape);
115 //Compute the Fillet value
117 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
120 if (!GetSolver()->ComputeFunction(aFunction)) {
121 SetErrorCode("Fillet driver failed");
125 catch (Standard_Failure) {
126 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
127 SetErrorCode(aFail->GetMessageString());
131 //Make a Python command
132 GEOM::TPythonDump(aFunction) << aFillet << " = geompy.MakeFilletAll("
133 << theShape << ", " << theR << ")";
139 //=============================================================================
143 //=============================================================================
144 Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeFilletEdges
145 (Handle(GEOM_Object) theShape, double theR, std::list<int> theEdges)
149 //Add a new Fillet object
150 Handle(GEOM_Object) aFillet = GetEngine()->AddObject(GetDocID(), GEOM_FILLET);
152 //Add a new Fillet function
153 Handle(GEOM_Function) aFunction =
154 aFillet->AddFunction(GEOMImpl_FilletDriver::GetID(), FILLET_SHAPE_EDGES);
155 if (aFunction.IsNull()) return NULL;
157 //Check if the function is set correctly
158 if (aFunction->GetDriverGUID() != GEOMImpl_FilletDriver::GetID()) return NULL;
160 GEOMImpl_IFillet aCI (aFunction);
162 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
163 if (aRefShape.IsNull()) return NULL;
165 aCI.SetShape(aRefShape);
167 int aLen = theEdges.size();
171 std::list<int>::iterator it = theEdges.begin();
172 for (; it != theEdges.end(); it++, ind++) {
173 aCI.SetEdge(ind, (*it));
176 //Compute the Fillet value
178 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
181 if (!GetSolver()->ComputeFunction(aFunction)) {
182 SetErrorCode("Fillet driver failed");
186 catch (Standard_Failure) {
187 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
188 SetErrorCode(aFail->GetMessageString());
192 //Make a Python command
193 GEOM::TPythonDump pd (aFunction);
194 pd << aFillet << " = geompy.MakeFillet(" << theShape
195 << ", " << theR << ", geompy.ShapeType[\"EDGE\"], [";
197 it = theEdges.begin();
199 while (it != theEdges.end()) {
200 pd << ", " << (*it++);
208 //=============================================================================
210 * MakeFilletEdges R1 R2
212 //=============================================================================
213 Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeFilletEdgesR1R2
214 (Handle(GEOM_Object) theShape, double theR1, double theR2, std::list<int> theEdges)
218 //Add a new Fillet object
219 Handle(GEOM_Object) aFillet = GetEngine()->AddObject(GetDocID(), GEOM_FILLET);
221 //Add a new Fillet function
222 Handle(GEOM_Function) aFunction =
223 aFillet->AddFunction(GEOMImpl_FilletDriver::GetID(), FILLET_SHAPE_EDGES_2R);
224 if (aFunction.IsNull()) return NULL;
226 //Check if the function is set correctly
227 if (aFunction->GetDriverGUID() != GEOMImpl_FilletDriver::GetID()) return NULL;
229 GEOMImpl_IFillet aCI (aFunction);
231 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
232 if (aRefShape.IsNull()) return NULL;
234 aCI.SetShape(aRefShape);
237 int aLen = theEdges.size();
241 std::list<int>::iterator it = theEdges.begin();
242 for (; it != theEdges.end(); it++, ind++) {
243 aCI.SetEdge(ind, (*it));
246 //Compute the Fillet value
248 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
251 if (!GetSolver()->ComputeFunction(aFunction)) {
252 SetErrorCode("Fillet driver failed");
256 catch (Standard_Failure) {
257 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
258 SetErrorCode(aFail->GetMessageString());
262 //Make a Python command
263 GEOM::TPythonDump pd (aFunction);
264 pd << aFillet << " = geompy.MakeFilletR1R2(" << theShape
265 << ", " << theR1 << ", " <<theR2 << ", geompy.ShapeType[\"EDGE\"], [";
267 it = theEdges.begin();
269 while (it != theEdges.end()) {
270 pd << ", " << (*it++);
279 //=============================================================================
283 //=============================================================================
284 Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeFilletFaces
285 (Handle(GEOM_Object) theShape, double theR, std::list<int> theFaces)
289 //Add a new Fillet object
290 Handle(GEOM_Object) aFillet = GetEngine()->AddObject(GetDocID(), GEOM_FILLET);
292 //Add a new Fillet function
293 Handle(GEOM_Function) aFunction =
294 aFillet->AddFunction(GEOMImpl_FilletDriver::GetID(), FILLET_SHAPE_FACES);
295 if (aFunction.IsNull()) return NULL;
297 //Check if the function is set correctly
298 if (aFunction->GetDriverGUID() != GEOMImpl_FilletDriver::GetID()) return NULL;
300 GEOMImpl_IFillet aCI (aFunction);
302 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
303 if (aRefShape.IsNull()) return NULL;
305 aCI.SetShape(aRefShape);
307 int aLen = theFaces.size();
311 std::list<int>::iterator it = theFaces.begin();
312 for (; it != theFaces.end(); it++, ind++) {
313 aCI.SetFace(ind, (*it));
316 //Compute the Fillet value
318 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
321 if (!GetSolver()->ComputeFunction(aFunction)) {
322 SetErrorCode("Fillet driver failed");
326 catch (Standard_Failure) {
327 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
328 SetErrorCode(aFail->GetMessageString());
332 //Make a Python command
333 GEOM::TPythonDump pd (aFunction);
334 pd << aFillet << " = geompy.MakeFillet(" << theShape
335 << ", " << theR << ", geompy.ShapeType[\"FACE\"], [";
337 it = theFaces.begin();
339 while (it != theFaces.end()) {
340 pd << ", " << (*it++);
348 //=============================================================================
350 * MakeFilletFaces R1 R2
352 //=============================================================================
353 Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeFilletFacesR1R2
354 (Handle(GEOM_Object) theShape, double theR1, double theR2, std::list<int> theFaces)
358 //Add a new Fillet object
359 Handle(GEOM_Object) aFillet = GetEngine()->AddObject(GetDocID(), GEOM_FILLET);
361 //Add a new Fillet function
362 Handle(GEOM_Function) aFunction =
363 aFillet->AddFunction(GEOMImpl_FilletDriver::GetID(), FILLET_SHAPE_FACES_2R);
364 if (aFunction.IsNull()) return NULL;
366 //Check if the function is set correctly
367 if (aFunction->GetDriverGUID() != GEOMImpl_FilletDriver::GetID()) return NULL;
369 GEOMImpl_IFillet aCI (aFunction);
371 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
372 if (aRefShape.IsNull()) return NULL;
374 aCI.SetShape(aRefShape);
377 int aLen = theFaces.size();
381 std::list<int>::iterator it = theFaces.begin();
382 for (; it != theFaces.end(); it++, ind++) {
383 aCI.SetFace(ind, (*it));
386 //Compute the Fillet value
388 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
391 if (!GetSolver()->ComputeFunction(aFunction)) {
392 SetErrorCode("Fillet driver failed");
396 catch (Standard_Failure) {
397 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
398 SetErrorCode(aFail->GetMessageString());
402 //Make a Python command
403 GEOM::TPythonDump pd (aFunction);
404 pd << aFillet << " = geompy.MakeFilletR1R2(" << theShape
405 << ", " << theR1 << ", " << theR2 << ", geompy.ShapeType[\"FACE\"], [";
407 it = theFaces.begin();
409 while (it != theFaces.end()) {
410 pd << ", " << (*it++);
418 //=============================================================================
422 //=============================================================================
423 Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeFillet2D
424 (Handle(GEOM_Object) theShape, double theR, std::list<int> theVertexes)
428 //Add a new Fillet object
429 Handle(GEOM_Object) aFillet2D = GetEngine()->AddObject(GetDocID(), GEOM_FILLET_2D);
431 //Add a new Fillet function
432 Handle(GEOM_Function) aFunction =
433 aFillet2D->AddFunction(GEOMImpl_Fillet2dDriver::GetID(), FILLET_2D_SHAPE_VERTEXES);
434 if (aFunction.IsNull()) return NULL;
436 //Check if the function is set correctly
437 if (aFunction->GetDriverGUID() != GEOMImpl_Fillet2dDriver::GetID()) return NULL;
439 GEOMImpl_IFillet2d aCI (aFunction);
441 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
442 if (aRefShape.IsNull()) return NULL;
444 aCI.SetShape(aRefShape);
446 int aLen = theVertexes.size();
450 std::list<int>::iterator it = theVertexes.begin();
451 for (; it != theVertexes.end(); it++, ind++) {
452 aCI.SetVertex(ind, (*it));
455 //Compute the Fillet value
457 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
460 if (!GetSolver()->ComputeFunction(aFunction)) {
461 SetErrorCode("2D Fillet driver failed");
465 catch (Standard_Failure) {
466 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
467 SetErrorCode(aFail->GetMessageString());
471 //Make a Python command
472 GEOM::TPythonDump pd (aFunction);
473 pd << aFillet2D << " = geompy.MakeFillet2D(" << theShape
474 << ", " << theR << ", [";
476 it = theVertexes.begin();
478 while (it != theVertexes.end()) {
479 pd << ", " << (*it++);
487 //=============================================================================
491 //=============================================================================
492 Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeFillet1D
493 (Handle(GEOM_Object) theShape, double theR, std::list<int> theVertexes)
497 //Add a new Fillet object
498 Handle(GEOM_Object) aFillet1D = GetEngine()->AddObject(GetDocID(), GEOM_FILLET_1D);
500 //Add a new Fillet function
501 Handle(GEOM_Function) aFunction =
502 aFillet1D->AddFunction(GEOMImpl_Fillet1dDriver::GetID(), FILLET_1D_SHAPE_VERTEXES);
503 if (aFunction.IsNull()) return NULL;
505 //Check if the function is set correctly
506 if (aFunction->GetDriverGUID() != GEOMImpl_Fillet1dDriver::GetID()) return NULL;
508 GEOMImpl_IFillet1d aCI (aFunction);
510 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
511 if (aRefShape.IsNull()) return NULL;
513 aCI.SetShape(aRefShape);
515 int aLen = theVertexes.size();
519 std::list<int>::iterator it = theVertexes.begin();
520 for (; it != theVertexes.end(); it++, ind++) {
521 aCI.SetVertex(ind, (*it));
524 //Compute the Fillet value
526 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
529 if (!GetSolver()->ComputeFunction(aFunction)) {
530 SetErrorCode("1D Fillet driver failed");
534 catch (Standard_Failure) {
535 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
536 SetErrorCode(aFail->GetMessageString());
540 //Make a Python command
541 GEOM::TPythonDump pd (aFunction);
542 pd << aFillet1D << " = geompy.MakeFillet1D(" << theShape
543 << ", " << theR << ", [";
545 it = theVertexes.begin();
547 while (it != theVertexes.end()) {
548 pd << ", " << (*it++);
556 //=============================================================================
560 //=============================================================================
561 Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeChamferAll (Handle(GEOM_Object) theShape, double theD)
565 //Add a new Chamfer object
566 Handle(GEOM_Object) aChamfer = GetEngine()->AddObject(GetDocID(), GEOM_CHAMFER);
568 //Add a new Chamfer function
569 Handle(GEOM_Function) aFunction =
570 aChamfer->AddFunction(GEOMImpl_ChamferDriver::GetID(), CHAMFER_SHAPE_ALL);
571 if (aFunction.IsNull()) return NULL;
573 //Check if the function is set correctly
574 if (aFunction->GetDriverGUID() != GEOMImpl_ChamferDriver::GetID()) return NULL;
576 GEOMImpl_IChamfer aCI (aFunction);
578 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
579 if (aRefShape.IsNull()) return NULL;
581 aCI.SetShape(aRefShape);
584 //Compute the Chamfer value
586 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
589 if (!GetSolver()->ComputeFunction(aFunction)) {
590 SetErrorCode("Chamfer driver failed");
594 catch (Standard_Failure) {
595 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
596 SetErrorCode(aFail->GetMessageString());
600 //Make a Python command
601 GEOM::TPythonDump(aFunction) << aChamfer << " = geompy.MakeChamferAll("
602 << theShape << ", " << theD << ")";
608 //=============================================================================
612 //=============================================================================
613 Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeChamferEdge
614 (Handle(GEOM_Object) theShape, double theD1, double theD2,
615 int theFace1, int theFace2)
619 //Add a new Chamfer object
620 Handle(GEOM_Object) aChamfer = GetEngine()->AddObject(GetDocID(), GEOM_CHAMFER);
622 //Add a new Chamfer function
623 Handle(GEOM_Function) aFunction =
624 aChamfer->AddFunction(GEOMImpl_ChamferDriver::GetID(), CHAMFER_SHAPE_EDGE);
625 if (aFunction.IsNull()) return NULL;
627 //Check if the function is set correctly
628 if (aFunction->GetDriverGUID() != GEOMImpl_ChamferDriver::GetID()) return NULL;
630 GEOMImpl_IChamfer aCI (aFunction);
632 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
633 if (aRefShape.IsNull()) return NULL;
635 aCI.SetShape(aRefShape);
638 aCI.SetFace1(theFace1);
639 aCI.SetFace2(theFace2);
641 //Compute the Chamfer value
643 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
646 if (!GetSolver()->ComputeFunction(aFunction)) {
647 SetErrorCode("Chamfer driver failed");
651 catch (Standard_Failure) {
652 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
653 SetErrorCode(aFail->GetMessageString());
657 //Make a Python command
658 GEOM::TPythonDump(aFunction) << aChamfer
659 << " = geompy.MakeChamferEdge(" << theShape << ", " << theD1
660 << ", " << theD2 << ", " << theFace1 << ", " << theFace2 << ")";
666 //=============================================================================
670 //=============================================================================
671 Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeChamferEdgeAD
672 (Handle(GEOM_Object) theShape, double theD, double theAngle,
673 int theFace1, int theFace2)
677 //Add a new Chamfer object
678 Handle(GEOM_Object) aChamfer = GetEngine()->AddObject(GetDocID(), GEOM_CHAMFER);
680 //Add a new Chamfer function
681 Handle(GEOM_Function) aFunction =
682 aChamfer->AddFunction(GEOMImpl_ChamferDriver::GetID(), CHAMFER_SHAPE_EDGE_AD);
683 if (aFunction.IsNull()) return NULL;
685 //Check if the function is set correctly
686 if (aFunction->GetDriverGUID() != GEOMImpl_ChamferDriver::GetID()) return NULL;
688 GEOMImpl_IChamfer aCI (aFunction);
690 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
691 if (aRefShape.IsNull()) return NULL;
693 aCI.SetShape(aRefShape);
695 aCI.SetAngle(theAngle);
696 aCI.SetFace1(theFace1);
697 aCI.SetFace2(theFace2);
699 //Compute the Chamfer value
701 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
704 if (!GetSolver()->ComputeFunction(aFunction)) {
705 SetErrorCode("Chamfer driver failed");
709 catch (Standard_Failure) {
710 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
711 SetErrorCode(aFail->GetMessageString());
715 //Make a Python command
716 GEOM::TPythonDump(aFunction) << aChamfer
717 << " = geompy.MakeChamferEdgeAD(" << theShape << ", " << theD
718 << ", " << theAngle << ", " << theFace1 << ", " << theFace2 << ")";
723 //=============================================================================
727 //=============================================================================
728 Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeChamferFaces
729 (Handle(GEOM_Object) theShape, double theD1, double theD2,
730 std::list<int> theFaces)
734 //Add a new Chamfer object
735 Handle(GEOM_Object) aChamfer = GetEngine()->AddObject(GetDocID(), GEOM_CHAMFER);
737 //Add a new Chamfer function
738 Handle(GEOM_Function) aFunction =
739 aChamfer->AddFunction(GEOMImpl_ChamferDriver::GetID(), CHAMFER_SHAPE_FACES);
740 if (aFunction.IsNull()) return NULL;
742 //Check if the function is set correctly
743 if (aFunction->GetDriverGUID() != GEOMImpl_ChamferDriver::GetID()) return NULL;
745 GEOMImpl_IChamfer aCI (aFunction);
747 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
748 if (aRefShape.IsNull()) return NULL;
750 aCI.SetShape(aRefShape);
753 int aLen = theFaces.size();
757 std::list<int>::iterator it = theFaces.begin();
758 for (; it != theFaces.end(); it++, ind++) {
759 aCI.SetFace(ind, (*it));
762 //Compute the Chamfer value
764 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
767 if (!GetSolver()->ComputeFunction(aFunction)) {
768 SetErrorCode("Chamfer driver failed");
772 catch (Standard_Failure) {
773 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
774 SetErrorCode(aFail->GetMessageString());
778 //Make a Python command
779 GEOM::TPythonDump pd (aFunction);
780 pd << aChamfer << " = geompy.MakeChamferFaces(" << theShape
781 << ", " << theD1 << ", " << theD2 << ", [";
783 it = theFaces.begin();
785 while (it != theFaces.end()) {
786 pd << ", " << (*it++);
794 //=============================================================================
798 //=============================================================================
799 Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeChamferFacesAD
800 (Handle(GEOM_Object) theShape, double theD, double theAngle,
801 std::list<int> theFaces)
805 //Add a new Chamfer object
806 Handle(GEOM_Object) aChamfer = GetEngine()->AddObject(GetDocID(), GEOM_CHAMFER);
808 //Add a new Chamfer function
809 Handle(GEOM_Function) aFunction =
810 aChamfer->AddFunction(GEOMImpl_ChamferDriver::GetID(), CHAMFER_SHAPE_FACES_AD);
811 if (aFunction.IsNull()) return NULL;
813 //Check if the function is set correctly
814 if (aFunction->GetDriverGUID() != GEOMImpl_ChamferDriver::GetID()) return NULL;
816 GEOMImpl_IChamfer aCI (aFunction);
818 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
819 if (aRefShape.IsNull()) return NULL;
821 aCI.SetShape(aRefShape);
823 aCI.SetAngle(theAngle);
824 int aLen = theFaces.size();
828 std::list<int>::iterator it = theFaces.begin();
829 for (; it != theFaces.end(); it++, ind++) {
830 aCI.SetFace(ind, (*it));
833 //Compute the Chamfer value
835 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
838 if (!GetSolver()->ComputeFunction(aFunction)) {
839 SetErrorCode("Chamfer driver failed");
843 catch (Standard_Failure) {
844 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
845 SetErrorCode(aFail->GetMessageString());
849 //Make a Python command
850 GEOM::TPythonDump pd (aFunction);
851 pd << aChamfer << " = geompy.MakeChamferFacesAD(" << theShape
852 << ", " << theD << ", " << theAngle << ", [";
854 it = theFaces.begin();
856 while (it != theFaces.end()) {
857 pd << ", " << (*it++);
865 //=============================================================================
869 //=============================================================================
870 Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeChamferEdges
871 (Handle(GEOM_Object) theShape, double theD1, double theD2,
872 std::list<int> theEdges)
876 //Add a new Chamfer object
877 Handle(GEOM_Object) aChamfer = GetEngine()->AddObject(GetDocID(), GEOM_CHAMFER);
879 //Add a new Chamfer function
880 Handle(GEOM_Function) aFunction =
881 aChamfer->AddFunction(GEOMImpl_ChamferDriver::GetID(), CHAMFER_SHAPE_EDGES);
882 if (aFunction.IsNull()) { MESSAGE ( "Edges Function is NULL!!!" ); return NULL;}
884 //Check if the function is set correctly
885 if (aFunction->GetDriverGUID() != GEOMImpl_ChamferDriver::GetID())
886 { MESSAGE ( "Chamfer Driver is NULL!!!" ); return NULL; }
888 GEOMImpl_IChamfer aCI (aFunction);
890 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
891 if (aRefShape.IsNull()) { MESSAGE ("Shape is NULL!!!"); return NULL;}
893 aCI.SetShape(aRefShape);
896 int aLen = theEdges.size();
900 std::list<int>::iterator it = theEdges.begin();
901 for (; it != theEdges.end(); it++, ind++) {
902 aCI.SetEdge(ind, (*it));
905 //Compute the Chamfer value
907 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
910 if (!GetSolver()->ComputeFunction(aFunction)) {
911 SetErrorCode("Chamfer driver failed");
915 catch (Standard_Failure) {
916 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
917 SetErrorCode(aFail->GetMessageString());
921 //Make a Python command
922 GEOM::TPythonDump pd (aFunction);
923 pd << aChamfer << " = geompy.MakeChamferEdges(" << theShape
924 << ", " << theD1 << ", " << theD2 << ", [";
926 it = theEdges.begin();
928 while (it != theEdges.end()) {
929 pd << ", " << (*it++);
937 //=============================================================================
941 //=============================================================================
942 Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeChamferEdgesAD
943 (Handle(GEOM_Object) theShape, double theD, double theAngle,
944 std::list<int> theEdges)
948 //Add a new Chamfer object
949 Handle(GEOM_Object) aChamfer = GetEngine()->AddObject(GetDocID(), GEOM_CHAMFER);
951 //Add a new Chamfer function
952 Handle(GEOM_Function) aFunction =
953 aChamfer->AddFunction(GEOMImpl_ChamferDriver::GetID(), CHAMFER_SHAPE_EDGES_AD);
954 if (aFunction.IsNull()) { MESSAGE ( "Edges Function is NULL!!!" ); return NULL; }
956 //Check if the function is set correctly
957 if (aFunction->GetDriverGUID() != GEOMImpl_ChamferDriver::GetID())
958 { MESSAGE("Chamfer Driver is NULL!!!"); return NULL;}
960 GEOMImpl_IChamfer aCI (aFunction);
962 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
963 if (aRefShape.IsNull()) { MESSAGE ("Shape is NULL!!!"); return NULL;}
965 aCI.SetShape(aRefShape);
967 aCI.SetAngle(theAngle);
968 int aLen = theEdges.size();
972 std::list<int>::iterator it = theEdges.begin();
973 for (; it != theEdges.end(); it++, ind++) {
974 aCI.SetEdge(ind, (*it));
977 //Compute the Chamfer value
979 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
982 if (!GetSolver()->ComputeFunction(aFunction)) {
983 SetErrorCode("Chamfer driver failed");
987 catch (Standard_Failure) {
988 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
989 SetErrorCode(aFail->GetMessageString());
993 //Make a Python command
994 GEOM::TPythonDump pd (aFunction);
995 pd << aChamfer << " = geompy.MakeChamferEdgesAD(" << theShape
996 << ", " << theD << ", " << theAngle << ", [";
998 it = theEdges.begin();
1000 while (it != theEdges.end()) {
1001 pd << ", " << (*it++);
1009 //=============================================================================
1013 //=============================================================================
1014 Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeArchimede (Handle(GEOM_Object) theShape,
1016 double theWaterDensity,
1017 double theMeshingDeflection)
1021 //Add a new Archimede object
1022 Handle(GEOM_Object) aChamfer = GetEngine()->AddObject(GetDocID(), GEOM_ARCHIMEDE);
1024 //Add a new Archimede function
1025 Handle(GEOM_Function) aFunction = aChamfer->AddFunction(GEOMImpl_ArchimedeDriver::GetID(), ARCHIMEDE_TYPE);
1026 if (aFunction.IsNull()) return NULL;
1028 //Check if the function is set correctly
1029 if (aFunction->GetDriverGUID() != GEOMImpl_ArchimedeDriver::GetID()) return NULL;
1031 GEOMImpl_IArchimede aAI (aFunction);
1033 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
1034 if (aRefShape.IsNull()) return NULL;
1036 aAI.SetBasicShape(aRefShape);
1037 aAI.SetWeight(theWeight);
1038 aAI.SetDensity(theWaterDensity);
1039 aAI.SetDeflection(theMeshingDeflection);
1041 //Compute the Archimede value
1043 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1046 if (!GetSolver()->ComputeFunction(aFunction)) {
1047 SetErrorCode("Archimede driver failed");
1051 catch (Standard_Failure) {
1052 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1053 SetErrorCode(aFail->GetMessageString());
1057 //Make a Python command
1058 GEOM::TPythonDump(aFunction) << aChamfer
1059 << " = geompy.Archimede(" << theShape << ", " << theWeight << ", "
1060 << theWaterDensity << ", " << theMeshingDeflection << ")";
1066 //=============================================================================
1070 //=============================================================================
1071 bool GEOMImpl_ILocalOperations::GetSubShape (const TopoDS_Shape& theShape, const int theIndex,
1072 TopoDS_Shape& theSubShape)
1074 if (theShape.IsNull() || theIndex < 1)
1077 TopTools_IndexedMapOfShape anIndices;
1078 TopExp::MapShapes(theShape, anIndices);
1079 if (theIndex > anIndices.Extent()) return false;
1080 theSubShape = anIndices.FindKey(theIndex);
1085 //=============================================================================
1089 //=============================================================================
1090 Standard_Integer GEOMImpl_ILocalOperations::GetSubShapeIndex (Handle(GEOM_Object) theShape,
1091 Handle(GEOM_Object) theSubShape)
1095 Standard_Integer anInd = -1;
1096 GEOM_Engine* anEngine = GetEngine();
1097 //GEOMImpl_Gen* aGen = dynamic_cast<GEOMImpl_Gen*>(anEngine);
1098 GEOMImpl_Gen* aGen = (GEOMImpl_Gen*)anEngine;
1101 GEOMImpl_IShapesOperations* anIShapesOperations =
1102 aGen->GetIShapesOperations(GetDocID());
1103 anInd = anIShapesOperations->GetSubShapeIndex(theShape, theSubShape);
1104 SetErrorCode(anIShapesOperations->GetErrorCode());