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) return 0;
187 //Get the reference shape
188 Handle(GEOM_Object) aShape = GetOperations()->GetEngine()->GetObject
189 (theShape->GetStudyID(), theShape->GetEntry());
191 if (aShape.IsNull()) return 0;
193 // Get shape parameters
194 TCollection_AsciiString aDump;
195 if (GetOperations()->CheckShape(aShape, aDump)) return 1;
197 theDescription = CORBA::string_dup(aDump.ToCString());
201 //=============================================================================
205 //=============================================================================
206 char* GEOM_IMeasureOperations_i::WhatIs (GEOM::GEOM_Object_ptr theShape)
208 //Set a not done flag
209 GetOperations()->SetNotDone();
211 if (theShape == NULL) return NULL;
213 //Get the reference shape
214 Handle(GEOM_Object) aShape = GetOperations()->GetEngine()->GetObject
215 (theShape->GetStudyID(), theShape->GetEntry());
217 if (aShape.IsNull()) return NULL;
219 // Get shape parameters
220 TCollection_AsciiString aDescription = GetOperations()->WhatIs(aShape);
221 return strdup(aDescription.ToCString());
224 //=============================================================================
228 //=============================================================================
229 CORBA::Double GEOM_IMeasureOperations_i::GetMinDistance
230 (GEOM::GEOM_Object_ptr theShape1, GEOM::GEOM_Object_ptr theShape2,
231 CORBA::Double& X1, CORBA::Double& Y1, CORBA::Double& Z1,
232 CORBA::Double& X2, CORBA::Double& Y2, CORBA::Double& Z2)
234 //Set a not done flag
235 GetOperations()->SetNotDone();
237 if (theShape1 == NULL || theShape2 == NULL) return -1.0;
239 //Get the reference shape
240 Handle(GEOM_Object) aShape1 = GetOperations()->GetEngine()->GetObject
241 (theShape1->GetStudyID(), theShape1->GetEntry());
242 Handle(GEOM_Object) aShape2 = GetOperations()->GetEngine()->GetObject
243 (theShape2->GetStudyID(), theShape2->GetEntry());
245 if (aShape1.IsNull() || aShape2.IsNull()) return -1.0;
247 // Get shape parameters
248 return GetOperations()->GetMinDistance(aShape1, aShape2, X1, Y1, Z1, X2, Y2, Z2);
251 //=============================================================================
255 //=============================================================================
256 void GEOM_IMeasureOperations_i::PointCoordinates(
257 GEOM::GEOM_Object_ptr theShape, CORBA::Double& X, CORBA::Double& Y, CORBA::Double& Z )
260 //Set a not done flag
261 GetOperations()->SetNotDone();
263 if ( theShape->_is_nil() )
266 //Get the reference shape
267 Handle(GEOM_Object) aShape = GetOperations()->GetEngine()->GetObject(
268 theShape->GetStudyID(), theShape->GetEntry() );
270 if ( aShape.IsNull() )
273 // Get shape parameters
274 GetOperations()->PointCoordinates( aShape, X, Y, Z );