3 #include "GEOM_IMeasureOperations_i.hh"
8 #include "GEOM_Engine.hxx"
9 #include "GEOM_Object.hxx"
11 //=============================================================================
15 //=============================================================================
16 GEOM_IMeasureOperations_i::GEOM_IMeasureOperations_i (PortableServer::POA_ptr thePOA,
17 GEOM::GEOM_Gen_ptr theEngine,
18 ::GEOMImpl_IMeasureOperations* theImpl)
19 :GEOM_IOperations_i(thePOA, theEngine, theImpl)
21 MESSAGE("GEOM_IMeasureOperations_i::GEOM_IMeasureOperations_i");
24 //=============================================================================
28 //=============================================================================
29 GEOM_IMeasureOperations_i::~GEOM_IMeasureOperations_i()
31 MESSAGE("GEOM_IMeasureOperations_i::~GEOM_IMeasureOperations_i");
35 //=============================================================================
39 //=============================================================================
40 GEOM::GEOM_Object_ptr GEOM_IMeasureOperations_i::GetCentreOfMass
41 (GEOM::GEOM_Object_ptr theShape)
43 GEOM::GEOM_Object_var aGEOMObject;
46 GetOperations()->SetNotDone();
48 if (theShape == NULL) return aGEOMObject._retn();
50 //Get the reference shape
51 Handle(GEOM_Object) aShape = GetOperations()->GetEngine()->GetObject
52 (theShape->GetStudyID(), theShape->GetEntry());
54 if (aShape.IsNull()) return aGEOMObject._retn();
56 // Make Point - centre of mass of theShape
57 Handle(GEOM_Object) anObject = GetOperations()->GetCentreOfMass(aShape);
58 if (!GetOperations()->IsDone() || anObject.IsNull())
59 return aGEOMObject._retn();
61 return GetObject(anObject);
64 //=============================================================================
68 //=============================================================================
69 void GEOM_IMeasureOperations_i::GetBasicProperties (GEOM::GEOM_Object_ptr theShape,
70 CORBA::Double& theLength,
71 CORBA::Double& theSurfArea,
72 CORBA::Double& theVolume)
75 GetOperations()->SetNotDone();
77 if (theShape == NULL) return;
79 //Get the reference shape
80 Handle(GEOM_Object) aShape = GetOperations()->GetEngine()->GetObject
81 (theShape->GetStudyID(), theShape->GetEntry());
83 if (aShape.IsNull()) return;
85 // Get shape parameters
86 GetOperations()->GetBasicProperties(aShape, theLength, theSurfArea, theVolume);
89 //=============================================================================
93 //=============================================================================
94 void GEOM_IMeasureOperations_i::GetInertia
95 (GEOM::GEOM_Object_ptr theShape,
96 CORBA::Double& I11, CORBA::Double& I12, CORBA::Double& I13,
97 CORBA::Double& I21, CORBA::Double& I22, CORBA::Double& I23,
98 CORBA::Double& I31, CORBA::Double& I32, CORBA::Double& I33,
99 CORBA::Double& Ix , CORBA::Double& Iy , CORBA::Double& Iz)
101 //Set a not done flag
102 GetOperations()->SetNotDone();
104 if (theShape == NULL) return;
106 //Get the reference shape
107 Handle(GEOM_Object) aShape = GetOperations()->GetEngine()->GetObject
108 (theShape->GetStudyID(), theShape->GetEntry());
110 if (aShape.IsNull()) return;
112 // Get shape parameters
113 GetOperations()->GetInertia(aShape,
120 //=============================================================================
124 //=============================================================================
125 void GEOM_IMeasureOperations_i::GetBoundingBox (GEOM::GEOM_Object_ptr theShape,
126 CORBA::Double& Xmin, CORBA::Double& Xmax,
127 CORBA::Double& Ymin, CORBA::Double& Ymax,
128 CORBA::Double& Zmin, CORBA::Double& Zmax)
130 //Set a not done flag
131 GetOperations()->SetNotDone();
133 if (theShape == NULL) return;
135 //Get the reference shape
136 Handle(GEOM_Object) aShape = GetOperations()->GetEngine()->GetObject
137 (theShape->GetStudyID(), theShape->GetEntry());
139 if (aShape.IsNull()) return;
141 // Get shape parameters
142 GetOperations()->GetBoundingBox(aShape, Xmin, Xmax, Ymin, Ymax, Zmin, Zmax);
145 //=============================================================================
149 //=============================================================================
150 void GEOM_IMeasureOperations_i::GetTolerance
151 (GEOM::GEOM_Object_ptr theShape,
152 CORBA::Double& FaceMin, CORBA::Double& FaceMax,
153 CORBA::Double& EdgeMin, CORBA::Double& EdgeMax,
154 CORBA::Double& VertMin, CORBA::Double& VertMax)
156 //Set a not done flag
157 GetOperations()->SetNotDone();
159 if (theShape == NULL) return;
161 //Get the reference shape
162 Handle(GEOM_Object) aShape = GetOperations()->GetEngine()->GetObject
163 (theShape->GetStudyID(), theShape->GetEntry());
165 if (aShape.IsNull()) return;
167 // Get shape parameters
168 GetOperations()->GetTolerance(aShape,
174 //=============================================================================
178 //=============================================================================
179 CORBA::Boolean GEOM_IMeasureOperations_i::CheckShape (GEOM::GEOM_Object_ptr theShape,
180 CORBA::String_out theDescription)
182 //Set a not done flag
183 GetOperations()->SetNotDone();
185 if (theShape == NULL)
187 theDescription = CORBA::string_dup("null");
191 //Get the reference shape
192 Handle(GEOM_Object) aShape = GetOperations()->GetEngine()->GetObject
193 (theShape->GetStudyID(), theShape->GetEntry());
197 theDescription = CORBA::string_dup("null2");
201 // Get shape parameters
202 TCollection_AsciiString aDump;
203 if (GetOperations()->CheckShape(aShape, aDump))
205 theDescription = CORBA::string_dup(aDump.ToCString());
208 theDescription = CORBA::string_dup("checkShape 0");
212 //=============================================================================
216 //=============================================================================
217 char* GEOM_IMeasureOperations_i::WhatIs (GEOM::GEOM_Object_ptr theShape)
219 //Set a not done flag
220 GetOperations()->SetNotDone();
222 if (theShape == NULL) return NULL;
224 //Get the reference shape
225 Handle(GEOM_Object) aShape = GetOperations()->GetEngine()->GetObject
226 (theShape->GetStudyID(), theShape->GetEntry());
228 if (aShape.IsNull()) return NULL;
230 // Get shape parameters
231 TCollection_AsciiString aDescription = GetOperations()->WhatIs(aShape);
232 return strdup(aDescription.ToCString());
235 //=============================================================================
239 //=============================================================================
240 CORBA::Double GEOM_IMeasureOperations_i::GetMinDistance
241 (GEOM::GEOM_Object_ptr theShape1, GEOM::GEOM_Object_ptr theShape2,
242 CORBA::Double& X1, CORBA::Double& Y1, CORBA::Double& Z1,
243 CORBA::Double& X2, CORBA::Double& Y2, CORBA::Double& Z2)
245 //Set a not done flag
246 GetOperations()->SetNotDone();
248 if (theShape1 == NULL || theShape2 == NULL) return -1.0;
250 //Get the reference shape
251 Handle(GEOM_Object) aShape1 = GetOperations()->GetEngine()->GetObject
252 (theShape1->GetStudyID(), theShape1->GetEntry());
253 Handle(GEOM_Object) aShape2 = GetOperations()->GetEngine()->GetObject
254 (theShape2->GetStudyID(), theShape2->GetEntry());
256 if (aShape1.IsNull() || aShape2.IsNull()) return -1.0;
258 // Get shape parameters
259 return GetOperations()->GetMinDistance(aShape1, aShape2, X1, Y1, Z1, X2, Y2, Z2);
262 //=============================================================================
266 //=============================================================================
267 void GEOM_IMeasureOperations_i::PointCoordinates(
268 GEOM::GEOM_Object_ptr theShape, CORBA::Double& X, CORBA::Double& Y, CORBA::Double& Z )
271 //Set a not done flag
272 GetOperations()->SetNotDone();
274 if ( theShape->_is_nil() )
277 //Get the reference shape
278 Handle(GEOM_Object) aShape = GetOperations()->GetEngine()->GetObject(
279 theShape->GetStudyID(), theShape->GetEntry() );
281 if ( aShape.IsNull() )
284 // Get shape parameters
285 GetOperations()->PointCoordinates( aShape, X, Y, Z );