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_ChamferDriver.hxx>
34 #include <GEOMImpl_IFillet.hxx>
35 #include <GEOMImpl_IChamfer.hxx>
37 #include <GEOMImpl_IArchimede.hxx>
38 #include <GEOMImpl_ArchimedeDriver.hxx>
40 #include <GEOMImpl_Gen.hxx>
41 #include <GEOMImpl_IShapesOperations.hxx>
43 #include "utilities.h"
45 #include <Utils_ExceptHandlers.hxx>
47 #include <TFunction_DriverTable.hxx>
48 #include <TFunction_Driver.hxx>
49 #include <TFunction_Logbook.hxx>
50 #include <TDF_Tool.hxx>
53 #include <TopoDS_TShape.hxx>
54 #include <TopTools_IndexedMapOfShape.hxx>
56 #include <Standard_Failure.hxx>
57 #include <Standard_ErrorHandler.hxx> // CAREFUL ! position of this file is critic : see Lucien PIGNOLONI / OCC
59 //=============================================================================
63 //=============================================================================
64 GEOMImpl_ILocalOperations::GEOMImpl_ILocalOperations (GEOM_Engine* theEngine, int theDocID)
65 : GEOM_IOperations(theEngine, theDocID)
67 MESSAGE("GEOMImpl_ILocalOperations::GEOMImpl_ILocalOperations");
70 //=============================================================================
74 //=============================================================================
75 GEOMImpl_ILocalOperations::~GEOMImpl_ILocalOperations()
77 MESSAGE("GEOMImpl_ILocalOperations::~GEOMImpl_ILocalOperations");
81 //=============================================================================
85 //=============================================================================
86 Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeFilletAll
87 (Handle(GEOM_Object) theShape, double theR)
91 //Add a new Fillet object
92 Handle(GEOM_Object) aFillet = GetEngine()->AddObject(GetDocID(), GEOM_FILLET);
94 //Add a new Fillet function
95 Handle(GEOM_Function) aFunction =
96 aFillet->AddFunction(GEOMImpl_FilletDriver::GetID(), FILLET_SHAPE_ALL);
97 if (aFunction.IsNull()) return NULL;
99 //Check if the function is set correctly
100 if (aFunction->GetDriverGUID() != GEOMImpl_FilletDriver::GetID()) return NULL;
102 GEOMImpl_IFillet aCI (aFunction);
104 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
105 if (aRefShape.IsNull()) return NULL;
107 aCI.SetShape(aRefShape);
110 //Compute the Fillet value
112 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
115 if (!GetSolver()->ComputeFunction(aFunction)) {
116 SetErrorCode("Fillet driver failed");
120 catch (Standard_Failure) {
121 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
122 SetErrorCode(aFail->GetMessageString());
126 //Make a Python command
127 GEOM::TPythonDump(aFunction) << aFillet << " = geompy.MakeFilletAll("
128 << theShape << ", " << theR << ")";
134 //=============================================================================
138 //=============================================================================
139 Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeFilletEdges
140 (Handle(GEOM_Object) theShape, double theR, std::list<int> theEdges)
144 //Add a new Fillet object
145 Handle(GEOM_Object) aFillet = GetEngine()->AddObject(GetDocID(), GEOM_FILLET);
147 //Add a new Fillet function
148 Handle(GEOM_Function) aFunction =
149 aFillet->AddFunction(GEOMImpl_FilletDriver::GetID(), FILLET_SHAPE_EDGES);
150 if (aFunction.IsNull()) return NULL;
152 //Check if the function is set correctly
153 if (aFunction->GetDriverGUID() != GEOMImpl_FilletDriver::GetID()) return NULL;
155 GEOMImpl_IFillet aCI (aFunction);
157 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
158 if (aRefShape.IsNull()) return NULL;
160 aCI.SetShape(aRefShape);
162 int aLen = theEdges.size();
166 std::list<int>::iterator it = theEdges.begin();
167 for (; it != theEdges.end(); it++, ind++) {
168 aCI.SetEdge(ind, (*it));
171 //Compute the Fillet value
173 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
176 if (!GetSolver()->ComputeFunction(aFunction)) {
177 SetErrorCode("Fillet driver failed");
181 catch (Standard_Failure) {
182 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
183 SetErrorCode(aFail->GetMessageString());
187 //Make a Python command
188 GEOM::TPythonDump pd (aFunction);
189 pd << aFillet << " = geompy.MakeFillet(" << theShape
190 << ", " << theR << ", geompy.ShapeType[\"EDGE\"], [";
192 it = theEdges.begin();
194 while (it != theEdges.end()) {
195 pd << ", " << (*it++);
203 //=============================================================================
205 * MakeFilletEdges R1 R2
207 //=============================================================================
208 Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeFilletEdgesR1R2
209 (Handle(GEOM_Object) theShape, double theR1, double theR2, std::list<int> theEdges)
213 //Add a new Fillet object
214 Handle(GEOM_Object) aFillet = GetEngine()->AddObject(GetDocID(), GEOM_FILLET);
216 //Add a new Fillet function
217 Handle(GEOM_Function) aFunction =
218 aFillet->AddFunction(GEOMImpl_FilletDriver::GetID(), FILLET_SHAPE_EDGES_2R);
219 if (aFunction.IsNull()) return NULL;
221 //Check if the function is set correctly
222 if (aFunction->GetDriverGUID() != GEOMImpl_FilletDriver::GetID()) return NULL;
224 GEOMImpl_IFillet aCI (aFunction);
226 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
227 if (aRefShape.IsNull()) return NULL;
229 aCI.SetShape(aRefShape);
232 int aLen = theEdges.size();
236 std::list<int>::iterator it = theEdges.begin();
237 for (; it != theEdges.end(); it++, ind++) {
238 aCI.SetEdge(ind, (*it));
241 //Compute the Fillet value
243 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
246 if (!GetSolver()->ComputeFunction(aFunction)) {
247 SetErrorCode("Fillet driver failed");
251 catch (Standard_Failure) {
252 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
253 SetErrorCode(aFail->GetMessageString());
257 //Make a Python command
258 GEOM::TPythonDump pd (aFunction);
259 pd << aFillet << " = geompy.MakeFilletR1R2(" << theShape
260 << ", " << theR1 << ", " <<theR2 << ", geompy.ShapeType[\"EDGE\"], [";
262 it = theEdges.begin();
264 while (it != theEdges.end()) {
265 pd << ", " << (*it++);
274 //=============================================================================
278 //=============================================================================
279 Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeFilletFaces
280 (Handle(GEOM_Object) theShape, double theR, std::list<int> theFaces)
284 //Add a new Fillet object
285 Handle(GEOM_Object) aFillet = GetEngine()->AddObject(GetDocID(), GEOM_FILLET);
287 //Add a new Fillet function
288 Handle(GEOM_Function) aFunction =
289 aFillet->AddFunction(GEOMImpl_FilletDriver::GetID(), FILLET_SHAPE_FACES);
290 if (aFunction.IsNull()) return NULL;
292 //Check if the function is set correctly
293 if (aFunction->GetDriverGUID() != GEOMImpl_FilletDriver::GetID()) return NULL;
295 GEOMImpl_IFillet aCI (aFunction);
297 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
298 if (aRefShape.IsNull()) return NULL;
300 aCI.SetShape(aRefShape);
302 int aLen = theFaces.size();
306 std::list<int>::iterator it = theFaces.begin();
307 for (; it != theFaces.end(); it++, ind++) {
308 aCI.SetFace(ind, (*it));
311 //Compute the Fillet value
313 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
316 if (!GetSolver()->ComputeFunction(aFunction)) {
317 SetErrorCode("Fillet driver failed");
321 catch (Standard_Failure) {
322 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
323 SetErrorCode(aFail->GetMessageString());
327 //Make a Python command
328 GEOM::TPythonDump pd (aFunction);
329 pd << aFillet << " = geompy.MakeFillet(" << theShape
330 << ", " << theR << ", geompy.ShapeType[\"FACE\"], [";
332 it = theFaces.begin();
334 while (it != theFaces.end()) {
335 pd << ", " << (*it++);
343 //=============================================================================
345 * MakeFilletFaces R1 R2
347 //=============================================================================
348 Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeFilletFacesR1R2
349 (Handle(GEOM_Object) theShape, double theR1, double theR2, std::list<int> theFaces)
353 //Add a new Fillet object
354 Handle(GEOM_Object) aFillet = GetEngine()->AddObject(GetDocID(), GEOM_FILLET);
356 //Add a new Fillet function
357 Handle(GEOM_Function) aFunction =
358 aFillet->AddFunction(GEOMImpl_FilletDriver::GetID(), FILLET_SHAPE_FACES_2R);
359 if (aFunction.IsNull()) return NULL;
361 //Check if the function is set correctly
362 if (aFunction->GetDriverGUID() != GEOMImpl_FilletDriver::GetID()) return NULL;
364 GEOMImpl_IFillet aCI (aFunction);
366 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
367 if (aRefShape.IsNull()) return NULL;
369 aCI.SetShape(aRefShape);
372 int aLen = theFaces.size();
376 std::list<int>::iterator it = theFaces.begin();
377 for (; it != theFaces.end(); it++, ind++) {
378 aCI.SetFace(ind, (*it));
381 //Compute the Fillet value
383 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
386 if (!GetSolver()->ComputeFunction(aFunction)) {
387 SetErrorCode("Fillet driver failed");
391 catch (Standard_Failure) {
392 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
393 SetErrorCode(aFail->GetMessageString());
397 //Make a Python command
398 GEOM::TPythonDump pd (aFunction);
399 pd << aFillet << " = geompy.MakeFilletR1R2(" << theShape
400 << ", " << theR1 << ", " << theR2 << ", geompy.ShapeType[\"FACE\"], [";
402 it = theFaces.begin();
404 while (it != theFaces.end()) {
405 pd << ", " << (*it++);
413 //=============================================================================
417 //=============================================================================
418 Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeChamferAll (Handle(GEOM_Object) theShape, double theD)
422 //Add a new Chamfer object
423 Handle(GEOM_Object) aChamfer = GetEngine()->AddObject(GetDocID(), GEOM_CHAMFER);
425 //Add a new Chamfer function
426 Handle(GEOM_Function) aFunction =
427 aChamfer->AddFunction(GEOMImpl_ChamferDriver::GetID(), CHAMFER_SHAPE_ALL);
428 if (aFunction.IsNull()) return NULL;
430 //Check if the function is set correctly
431 if (aFunction->GetDriverGUID() != GEOMImpl_ChamferDriver::GetID()) return NULL;
433 GEOMImpl_IChamfer aCI (aFunction);
435 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
436 if (aRefShape.IsNull()) return NULL;
438 aCI.SetShape(aRefShape);
441 //Compute the Chamfer value
443 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
446 if (!GetSolver()->ComputeFunction(aFunction)) {
447 SetErrorCode("Chamfer driver failed");
451 catch (Standard_Failure) {
452 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
453 SetErrorCode(aFail->GetMessageString());
457 //Make a Python command
458 GEOM::TPythonDump(aFunction) << aChamfer << " = geompy.MakeChamferAll("
459 << theShape << ", " << theD << ")";
465 //=============================================================================
469 //=============================================================================
470 Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeChamferEdge
471 (Handle(GEOM_Object) theShape, double theD1, double theD2,
472 int theFace1, int theFace2)
476 //Add a new Chamfer object
477 Handle(GEOM_Object) aChamfer = GetEngine()->AddObject(GetDocID(), GEOM_CHAMFER);
479 //Add a new Chamfer function
480 Handle(GEOM_Function) aFunction =
481 aChamfer->AddFunction(GEOMImpl_ChamferDriver::GetID(), CHAMFER_SHAPE_EDGE);
482 if (aFunction.IsNull()) return NULL;
484 //Check if the function is set correctly
485 if (aFunction->GetDriverGUID() != GEOMImpl_ChamferDriver::GetID()) return NULL;
487 GEOMImpl_IChamfer aCI (aFunction);
489 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
490 if (aRefShape.IsNull()) return NULL;
492 aCI.SetShape(aRefShape);
495 aCI.SetFace1(theFace1);
496 aCI.SetFace2(theFace2);
498 //Compute the Chamfer value
500 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
503 if (!GetSolver()->ComputeFunction(aFunction)) {
504 SetErrorCode("Chamfer driver failed");
508 catch (Standard_Failure) {
509 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
510 SetErrorCode(aFail->GetMessageString());
514 //Make a Python command
515 GEOM::TPythonDump(aFunction) << aChamfer
516 << " = geompy.MakeChamferEdge(" << theShape << ", " << theD1
517 << ", " << theD2 << ", " << theFace1 << ", " << theFace2 << ")";
523 //=============================================================================
527 //=============================================================================
528 Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeChamferEdgeAD
529 (Handle(GEOM_Object) theShape, double theD, double theAngle,
530 int theFace1, int theFace2)
534 //Add a new Chamfer object
535 Handle(GEOM_Object) aChamfer = GetEngine()->AddObject(GetDocID(), GEOM_CHAMFER);
537 //Add a new Chamfer function
538 Handle(GEOM_Function) aFunction =
539 aChamfer->AddFunction(GEOMImpl_ChamferDriver::GetID(), CHAMFER_SHAPE_EDGE_AD);
540 if (aFunction.IsNull()) return NULL;
542 //Check if the function is set correctly
543 if (aFunction->GetDriverGUID() != GEOMImpl_ChamferDriver::GetID()) return NULL;
545 GEOMImpl_IChamfer aCI (aFunction);
547 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
548 if (aRefShape.IsNull()) return NULL;
550 aCI.SetShape(aRefShape);
552 aCI.SetAngle(theAngle);
553 aCI.SetFace1(theFace1);
554 aCI.SetFace2(theFace2);
556 //Compute the Chamfer value
558 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
561 if (!GetSolver()->ComputeFunction(aFunction)) {
562 SetErrorCode("Chamfer driver failed");
566 catch (Standard_Failure) {
567 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
568 SetErrorCode(aFail->GetMessageString());
572 //Make a Python command
573 GEOM::TPythonDump(aFunction) << aChamfer
574 << " = geompy.MakeChamferEdgeAD(" << theShape << ", " << theD
575 << ", " << theAngle << ", " << theFace1 << ", " << theFace2 << ")";
580 //=============================================================================
584 //=============================================================================
585 Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeChamferFaces
586 (Handle(GEOM_Object) theShape, double theD1, double theD2,
587 std::list<int> theFaces)
591 //Add a new Chamfer object
592 Handle(GEOM_Object) aChamfer = GetEngine()->AddObject(GetDocID(), GEOM_CHAMFER);
594 //Add a new Chamfer function
595 Handle(GEOM_Function) aFunction =
596 aChamfer->AddFunction(GEOMImpl_ChamferDriver::GetID(), CHAMFER_SHAPE_FACES);
597 if (aFunction.IsNull()) return NULL;
599 //Check if the function is set correctly
600 if (aFunction->GetDriverGUID() != GEOMImpl_ChamferDriver::GetID()) return NULL;
602 GEOMImpl_IChamfer aCI (aFunction);
604 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
605 if (aRefShape.IsNull()) return NULL;
607 aCI.SetShape(aRefShape);
610 int aLen = theFaces.size();
614 std::list<int>::iterator it = theFaces.begin();
615 for (; it != theFaces.end(); it++, ind++) {
616 aCI.SetFace(ind, (*it));
619 //Compute the Chamfer value
621 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
624 if (!GetSolver()->ComputeFunction(aFunction)) {
625 SetErrorCode("Chamfer driver failed");
629 catch (Standard_Failure) {
630 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
631 SetErrorCode(aFail->GetMessageString());
635 //Make a Python command
636 GEOM::TPythonDump pd (aFunction);
637 pd << aChamfer << " = geompy.MakeChamferFaces(" << theShape
638 << ", " << theD1 << ", " << theD2 << ", [";
640 it = theFaces.begin();
642 while (it != theFaces.end()) {
643 pd << ", " << (*it++);
651 //=============================================================================
655 //=============================================================================
656 Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeChamferFacesAD
657 (Handle(GEOM_Object) theShape, double theD, double theAngle,
658 std::list<int> theFaces)
662 //Add a new Chamfer object
663 Handle(GEOM_Object) aChamfer = GetEngine()->AddObject(GetDocID(), GEOM_CHAMFER);
665 //Add a new Chamfer function
666 Handle(GEOM_Function) aFunction =
667 aChamfer->AddFunction(GEOMImpl_ChamferDriver::GetID(), CHAMFER_SHAPE_FACES_AD);
668 if (aFunction.IsNull()) return NULL;
670 //Check if the function is set correctly
671 if (aFunction->GetDriverGUID() != GEOMImpl_ChamferDriver::GetID()) return NULL;
673 GEOMImpl_IChamfer aCI (aFunction);
675 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
676 if (aRefShape.IsNull()) return NULL;
678 aCI.SetShape(aRefShape);
680 aCI.SetAngle(theAngle);
681 int aLen = theFaces.size();
685 std::list<int>::iterator it = theFaces.begin();
686 for (; it != theFaces.end(); it++, ind++) {
687 aCI.SetFace(ind, (*it));
690 //Compute the Chamfer value
692 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
695 if (!GetSolver()->ComputeFunction(aFunction)) {
696 SetErrorCode("Chamfer driver failed");
700 catch (Standard_Failure) {
701 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
702 SetErrorCode(aFail->GetMessageString());
706 //Make a Python command
707 GEOM::TPythonDump pd (aFunction);
708 pd << aChamfer << " = geompy.MakeChamferFacesAD(" << theShape
709 << ", " << theD << ", " << theAngle << ", [";
711 it = theFaces.begin();
713 while (it != theFaces.end()) {
714 pd << ", " << (*it++);
722 //=============================================================================
726 //=============================================================================
727 Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeChamferEdges
728 (Handle(GEOM_Object) theShape, double theD1, double theD2,
729 std::list<int> theEdges)
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_EDGES);
739 if (aFunction.IsNull()) { MESSAGE ( "Edges Function is NULL!!!" ); return NULL;}
741 //Check if the function is set correctly
742 if (aFunction->GetDriverGUID() != GEOMImpl_ChamferDriver::GetID())
743 { MESSAGE ( "Chamfer Driver is NULL!!!" ); return NULL; }
745 GEOMImpl_IChamfer aCI (aFunction);
747 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
748 if (aRefShape.IsNull()) { MESSAGE ("Shape is NULL!!!"); return NULL;}
750 aCI.SetShape(aRefShape);
753 int aLen = theEdges.size();
757 std::list<int>::iterator it = theEdges.begin();
758 for (; it != theEdges.end(); it++, ind++) {
759 aCI.SetEdge(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.MakeChamferEdges(" << theShape
781 << ", " << theD1 << ", " << theD2 << ", [";
783 it = theEdges.begin();
785 while (it != theEdges.end()) {
786 pd << ", " << (*it++);
794 //=============================================================================
798 //=============================================================================
799 Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeChamferEdgesAD
800 (Handle(GEOM_Object) theShape, double theD, double theAngle,
801 std::list<int> theEdges)
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_EDGES_AD);
811 if (aFunction.IsNull()) { MESSAGE ( "Edges Function is NULL!!!" ); return NULL; }
813 //Check if the function is set correctly
814 if (aFunction->GetDriverGUID() != GEOMImpl_ChamferDriver::GetID())
815 { MESSAGE("Chamfer Driver is NULL!!!"); return NULL;}
817 GEOMImpl_IChamfer aCI (aFunction);
819 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
820 if (aRefShape.IsNull()) { MESSAGE ("Shape is NULL!!!"); return NULL;}
822 aCI.SetShape(aRefShape);
824 aCI.SetAngle(theAngle);
825 int aLen = theEdges.size();
829 std::list<int>::iterator it = theEdges.begin();
830 for (; it != theEdges.end(); it++, ind++) {
831 aCI.SetEdge(ind, (*it));
834 //Compute the Chamfer value
836 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
839 if (!GetSolver()->ComputeFunction(aFunction)) {
840 SetErrorCode("Chamfer driver failed");
844 catch (Standard_Failure) {
845 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
846 SetErrorCode(aFail->GetMessageString());
850 //Make a Python command
851 GEOM::TPythonDump pd (aFunction);
852 pd << aChamfer << " = geompy.MakeChamferEdgesAD(" << theShape
853 << ", " << theD << ", " << theAngle << ", [";
855 it = theEdges.begin();
857 while (it != theEdges.end()) {
858 pd << ", " << (*it++);
866 //=============================================================================
870 //=============================================================================
871 Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeArchimede (Handle(GEOM_Object) theShape,
873 double theWaterDensity,
874 double theMeshingDeflection)
878 //Add a new Archimede object
879 Handle(GEOM_Object) aChamfer = GetEngine()->AddObject(GetDocID(), GEOM_ARCHIMEDE);
881 //Add a new Archimede function
882 Handle(GEOM_Function) aFunction = aChamfer->AddFunction(GEOMImpl_ArchimedeDriver::GetID(), ARCHIMEDE_TYPE);
883 if (aFunction.IsNull()) return NULL;
885 //Check if the function is set correctly
886 if (aFunction->GetDriverGUID() != GEOMImpl_ArchimedeDriver::GetID()) return NULL;
888 GEOMImpl_IArchimede aAI (aFunction);
890 Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
891 if (aRefShape.IsNull()) return NULL;
893 aAI.SetBasicShape(aRefShape);
894 aAI.SetWeight(theWeight);
895 aAI.SetDensity(theWaterDensity);
896 aAI.SetDeflection(theMeshingDeflection);
898 //Compute the Archimede value
900 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
903 if (!GetSolver()->ComputeFunction(aFunction)) {
904 SetErrorCode("Archimede driver failed");
908 catch (Standard_Failure) {
909 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
910 SetErrorCode(aFail->GetMessageString());
914 //Make a Python command
915 GEOM::TPythonDump(aFunction) << aChamfer
916 << " = geompy.Archimede(" << theShape << ", " << theWeight << ", "
917 << theWaterDensity << ", " << theMeshingDeflection << ")";
923 //=============================================================================
927 //=============================================================================
928 bool GEOMImpl_ILocalOperations::GetSubShape (const TopoDS_Shape& theShape, const int theIndex,
929 TopoDS_Shape& theSubShape)
931 if (theShape.IsNull() || theIndex < 1)
934 TopTools_IndexedMapOfShape anIndices;
935 TopExp::MapShapes(theShape, anIndices);
936 if (theIndex > anIndices.Extent()) return false;
937 theSubShape = anIndices.FindKey(theIndex);
942 //=============================================================================
946 //=============================================================================
947 Standard_Integer GEOMImpl_ILocalOperations::GetSubShapeIndex (Handle(GEOM_Object) theShape,
948 Handle(GEOM_Object) theSubShape)
952 Standard_Integer anInd = -1;
953 GEOM_Engine* anEngine = GetEngine();
954 //GEOMImpl_Gen* aGen = dynamic_cast<GEOMImpl_Gen*>(anEngine);
955 GEOMImpl_Gen* aGen = (GEOMImpl_Gen*)anEngine;
958 GEOMImpl_IShapesOperations* anIShapesOperations =
959 aGen->GetIShapesOperations(GetDocID());
960 anInd = anIShapesOperations->GetSubShapeIndex(theShape, theSubShape);
961 SetErrorCode(anIShapesOperations->GetErrorCode());