3 #include "GEOM_IBooleanOperations_i.hh"
8 #include "GEOM_Engine.hxx"
9 #include "GEOM_Object.hxx"
11 #include <TColStd_HArray1OfInteger.hxx>
13 //=============================================================================
17 //=============================================================================
18 GEOM_IBooleanOperations_i::GEOM_IBooleanOperations_i (PortableServer::POA_ptr thePOA,
19 GEOM::GEOM_Gen_ptr theEngine,
20 ::GEOMImpl_IBooleanOperations* theImpl)
21 :GEOM_IOperations_i(thePOA, theEngine, theImpl)
23 MESSAGE("GEOM_IBooleanOperations_i::GEOM_IBooleanOperations_i");
26 //=============================================================================
30 //=============================================================================
31 GEOM_IBooleanOperations_i::~GEOM_IBooleanOperations_i()
33 MESSAGE("GEOM_IBooleanOperations_i::~GEOM_IBooleanOperations_i");
37 //=============================================================================
41 //=============================================================================
42 GEOM::GEOM_Object_ptr GEOM_IBooleanOperations_i::MakeBoolean
43 (GEOM::GEOM_Object_ptr theShape1,
44 GEOM::GEOM_Object_ptr theShape2,
47 GEOM::GEOM_Object_var aGEOMObject;
50 GetOperations()->SetNotDone();
52 if (theShape1 == NULL || theShape2 == NULL) return aGEOMObject._retn();
54 //Get the reference shapes
55 Handle(GEOM_Object) aSh1 = GetOperations()->GetEngine()->GetObject
56 (theShape1->GetStudyID(), theShape1->GetEntry());
57 Handle(GEOM_Object) aSh2 = GetOperations()->GetEngine()->GetObject
58 (theShape2->GetStudyID(), theShape2->GetEntry());
60 if (aSh1.IsNull() || aSh2.IsNull()) return aGEOMObject._retn();
63 Handle(GEOM_Object) anObject = GetOperations()->MakeBoolean(aSh1, aSh2, theOp);
64 if (!GetOperations()->IsDone() || anObject.IsNull())
65 return aGEOMObject._retn();
67 return GetObject(anObject);
70 //=============================================================================
74 //=============================================================================
75 GEOM::GEOM_Object_ptr GEOM_IBooleanOperations_i::MakePartition
76 (const GEOM::ListOfGO& theShapes,
77 const GEOM::ListOfGO& theTools,
78 const GEOM::ListOfGO& theKeepIns,
79 const GEOM::ListOfGO& theRemoveIns,
80 const CORBA::Short theLimit,
81 const CORBA::Boolean theRemoveWebs,
82 const GEOM::ListOfLong& theMaterials)
84 GEOM::GEOM_Object_var aGEOMObject;
87 GetOperations()->SetNotDone();
90 Handle(TColStd_HSequenceOfTransient) aShapes = new TColStd_HSequenceOfTransient;
91 Handle(TColStd_HSequenceOfTransient) aTools = new TColStd_HSequenceOfTransient;
92 Handle(TColStd_HSequenceOfTransient) aKeepIns = new TColStd_HSequenceOfTransient;
93 Handle(TColStd_HSequenceOfTransient) aRemIns = new TColStd_HSequenceOfTransient;
94 Handle(TColStd_HArray1OfInteger) aMaterials;
97 aLen = theShapes.length();
98 for (ind = 0; ind < aLen; ind++) {
99 if (theShapes[ind] == NULL) return aGEOMObject._retn();
100 Handle(GEOM_Object) aSh = GetOperations()->GetEngine()->GetObject
101 (theShapes[ind]->GetStudyID(), theShapes[ind]->GetEntry());
102 if (aSh.IsNull()) return aGEOMObject._retn();
103 aShapes->Append(aSh);
107 aLen = theTools.length();
108 for (ind = 0; ind < aLen; ind++) {
109 if (theTools[ind] == NULL) return aGEOMObject._retn();
110 Handle(GEOM_Object) aSh = GetOperations()->GetEngine()->GetObject
111 (theTools[ind]->GetStudyID(), theTools[ind]->GetEntry());
112 if (aSh.IsNull()) return aGEOMObject._retn();
116 //Get the keep inside shapes
117 aLen = theKeepIns.length();
118 for (ind = 0; ind < aLen; ind++) {
119 if (theKeepIns[ind] == NULL) return aGEOMObject._retn();
120 Handle(GEOM_Object) aSh = GetOperations()->GetEngine()->GetObject
121 (theKeepIns[ind]->GetStudyID(), theKeepIns[ind]->GetEntry());
122 if (aSh.IsNull()) return aGEOMObject._retn();
123 aKeepIns->Append(aSh);
126 //Get the remove inside shapes
127 aLen = theRemoveIns.length();
128 for (ind = 0; ind < aLen; ind++) {
129 if (theRemoveIns[ind] == NULL) return aGEOMObject._retn();
130 Handle(GEOM_Object) aSh = GetOperations()->GetEngine()->GetObject
131 (theRemoveIns[ind]->GetStudyID(), theRemoveIns[ind]->GetEntry());
132 if (aSh.IsNull()) return aGEOMObject._retn();
133 aRemIns->Append(aSh);
137 aLen = theMaterials.length();
138 aMaterials = new TColStd_HArray1OfInteger (1, aLen);
139 for (ind = 0; ind < aLen; ind++) {
140 aMaterials->SetValue(ind+1, theMaterials[ind]);
144 Handle(GEOM_Object) anObject =
145 GetOperations()->MakePartition(aShapes, aTools, aKeepIns, aRemIns,
146 theLimit, theRemoveWebs, aMaterials);
147 if (!GetOperations()->IsDone() || anObject.IsNull())
148 return aGEOMObject._retn();
150 return GetObject(anObject);
153 //=============================================================================
157 //=============================================================================
158 GEOM::GEOM_Object_ptr GEOM_IBooleanOperations_i::MakeHalfPartition
159 (GEOM::GEOM_Object_ptr theShape,
160 GEOM::GEOM_Object_ptr thePlane)
162 GEOM::GEOM_Object_var aGEOMObject;
164 //Set a not done flag
165 GetOperations()->SetNotDone();
167 if (theShape == NULL || thePlane == NULL) return aGEOMObject._retn();
169 //Get the reference shapes
170 Handle(GEOM_Object) aSh = GetOperations()->GetEngine()->GetObject
171 (theShape->GetStudyID(), theShape->GetEntry());
172 Handle(GEOM_Object) aPl = GetOperations()->GetEngine()->GetObject
173 (thePlane->GetStudyID(), thePlane->GetEntry());
175 if (aSh.IsNull() || aPl.IsNull()) return aGEOMObject._retn();
177 // Make Half Partition
178 Handle(GEOM_Object) anObject = GetOperations()->MakeHalfPartition(aSh, aPl);
179 if (!GetOperations()->IsDone() || anObject.IsNull())
180 return aGEOMObject._retn();
182 return GetObject(anObject);