1 // Copyright (C) 2007-2022 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, or (at your option) any later version.
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>
24 #include <TColStd_HArray1OfReal.hxx>
26 #include "GEOM_IMeasureOperations_i.hh"
28 #include "utilities.h"
31 #include "GEOM_Engine.hxx"
32 #include "GEOM_Object.hxx"
35 * This function converts shape errors from theErrorsFrom to theErrorsTo.
36 * Note that theErrorsTo is not cleared at first.
38 * \param theErrorsFrom errors to be converted.
39 * \param theErrorsTo result errors.
41 static void ConvertShapeError
42 (const GEOM::GEOM_IMeasureOperations::ShapeErrors &theErrorsFrom,
43 std::list<GEOMImpl_IMeasureOperations::ShapeError> &theErrorsTo)
45 int aNbErr = theErrorsFrom.length();
48 for (; i < aNbErr; i++) {
49 const GEOM::GEOM_IMeasureOperations::ShapeError anErr = theErrorsFrom[i];
50 const GEOM::GEOM_IMeasureOperations::ShapeErrorType aType = anErr.error;
51 const GEOM::ListOfLong anIncrims = anErr.incriminated;
52 GEOMImpl_IMeasureOperations::ShapeError anErrStruct;
55 case GEOM::GEOM_IMeasureOperations::InvalidPointOnCurve:
56 anErrStruct.error = BRepCheck_InvalidPointOnCurve;
58 case GEOM::GEOM_IMeasureOperations::InvalidPointOnCurveOnSurface:
59 anErrStruct.error = BRepCheck_InvalidPointOnCurveOnSurface;
61 case GEOM::GEOM_IMeasureOperations::InvalidPointOnSurface:
62 anErrStruct.error = BRepCheck_InvalidPointOnSurface;
64 case GEOM::GEOM_IMeasureOperations::No3DCurve:
65 anErrStruct.error = BRepCheck_No3DCurve;
67 case GEOM::GEOM_IMeasureOperations::Multiple3DCurve:
68 anErrStruct.error = BRepCheck_Multiple3DCurve;
70 case GEOM::GEOM_IMeasureOperations::Invalid3DCurve:
71 anErrStruct.error = BRepCheck_Invalid3DCurve;
73 case GEOM::GEOM_IMeasureOperations::NoCurveOnSurface:
74 anErrStruct.error = BRepCheck_NoCurveOnSurface;
76 case GEOM::GEOM_IMeasureOperations::InvalidCurveOnSurface:
77 anErrStruct.error = BRepCheck_InvalidCurveOnSurface;
79 case GEOM::GEOM_IMeasureOperations::InvalidCurveOnClosedSurface:
80 anErrStruct.error = BRepCheck_InvalidCurveOnClosedSurface;
82 case GEOM::GEOM_IMeasureOperations::InvalidSameRangeFlag:
83 anErrStruct.error = BRepCheck_InvalidSameRangeFlag;
85 case GEOM::GEOM_IMeasureOperations::InvalidSameParameterFlag:
86 anErrStruct.error = BRepCheck_InvalidSameParameterFlag;
88 case GEOM::GEOM_IMeasureOperations::InvalidDegeneratedFlag:
89 anErrStruct.error = BRepCheck_InvalidDegeneratedFlag;
91 case GEOM::GEOM_IMeasureOperations::FreeEdge:
92 anErrStruct.error = BRepCheck_FreeEdge;
94 case GEOM::GEOM_IMeasureOperations::InvalidMultiConnexity:
95 anErrStruct.error = BRepCheck_InvalidMultiConnexity;
97 case GEOM::GEOM_IMeasureOperations::InvalidRange:
98 anErrStruct.error = BRepCheck_InvalidRange;
100 case GEOM::GEOM_IMeasureOperations::EmptyWire:
101 anErrStruct.error = BRepCheck_EmptyWire;
103 case GEOM::GEOM_IMeasureOperations::RedundantEdge:
104 anErrStruct.error = BRepCheck_RedundantEdge;
106 case GEOM::GEOM_IMeasureOperations::SelfIntersectingWire:
107 anErrStruct.error = BRepCheck_SelfIntersectingWire;
109 case GEOM::GEOM_IMeasureOperations::NoSurface:
110 anErrStruct.error = BRepCheck_NoSurface;
112 case GEOM::GEOM_IMeasureOperations::InvalidWire:
113 anErrStruct.error = BRepCheck_InvalidWire;
115 case GEOM::GEOM_IMeasureOperations::RedundantWire:
116 anErrStruct.error = BRepCheck_RedundantWire;
118 case GEOM::GEOM_IMeasureOperations::IntersectingWires:
119 anErrStruct.error = BRepCheck_IntersectingWires;
121 case GEOM::GEOM_IMeasureOperations::InvalidImbricationOfWires:
122 anErrStruct.error = BRepCheck_InvalidImbricationOfWires;
124 case GEOM::GEOM_IMeasureOperations::EmptyShell:
125 anErrStruct.error = BRepCheck_EmptyShell;
127 case GEOM::GEOM_IMeasureOperations::RedundantFace:
128 anErrStruct.error = BRepCheck_RedundantFace;
130 case GEOM::GEOM_IMeasureOperations::UnorientableShape:
131 anErrStruct.error = BRepCheck_UnorientableShape;
133 case GEOM::GEOM_IMeasureOperations::NotClosed:
134 anErrStruct.error = BRepCheck_NotClosed;
136 case GEOM::GEOM_IMeasureOperations::NotConnected:
137 anErrStruct.error = BRepCheck_NotConnected;
139 case GEOM::GEOM_IMeasureOperations::SubshapeNotInShape:
140 anErrStruct.error = BRepCheck_SubshapeNotInShape;
142 case GEOM::GEOM_IMeasureOperations::BadOrientation:
143 anErrStruct.error = BRepCheck_BadOrientation;
145 case GEOM::GEOM_IMeasureOperations::BadOrientationOfSubshape:
146 anErrStruct.error = BRepCheck_BadOrientationOfSubshape;
148 case GEOM::GEOM_IMeasureOperations::InvalidToleranceValue:
149 anErrStruct.error = BRepCheck_InvalidToleranceValue;
151 case GEOM::GEOM_IMeasureOperations::CheckFail:
152 anErrStruct.error = BRepCheck_CheckFail;
159 int aLen = anIncrims.length();
161 for (; ii < aLen; ii++) {
162 anErrStruct.incriminated.push_back(anIncrims[ii]);
165 theErrorsTo.push_back(anErrStruct);
170 * This function converts shape errors from theErrorsFrom to theErrorsTo.
171 * Note that theErrorsTo is not cleared at first.
173 * \param theErrorsFrom errors to be converted.
174 * \param theErrorsTo result errors.
176 static void ConvertShapeError
177 (const std::list<GEOMImpl_IMeasureOperations::ShapeError> &theErrorsFrom,
178 GEOM::GEOM_IMeasureOperations::ShapeErrors_out &theErrorsTo)
180 const int aNbErr = theErrorsFrom.size();
181 GEOM::GEOM_IMeasureOperations::ShapeErrors_var anErrArray =
182 new GEOM::GEOM_IMeasureOperations::ShapeErrors;
184 anErrArray->length(aNbErr);
186 // fill the local CORBA array with values from lists
187 std::list<GEOMImpl_IMeasureOperations::ShapeError>::const_iterator
188 anIt = theErrorsFrom.begin();
191 for (; anIt != theErrorsFrom.end(); i++, anIt++) {
192 GEOM::GEOM_IMeasureOperations::ShapeError_var anErrStruct =
193 new GEOM::GEOM_IMeasureOperations::ShapeError;
195 switch (anIt->error) {
196 case BRepCheck_InvalidPointOnCurve:
197 anErrStruct->error = GEOM::GEOM_IMeasureOperations::InvalidPointOnCurve;
199 case BRepCheck_InvalidPointOnCurveOnSurface:
200 anErrStruct->error = GEOM::GEOM_IMeasureOperations::InvalidPointOnCurveOnSurface;
202 case BRepCheck_InvalidPointOnSurface:
203 anErrStruct->error = GEOM::GEOM_IMeasureOperations::InvalidPointOnSurface;
205 case BRepCheck_No3DCurve:
206 anErrStruct->error = GEOM::GEOM_IMeasureOperations::No3DCurve;
208 case BRepCheck_Multiple3DCurve:
209 anErrStruct->error = GEOM::GEOM_IMeasureOperations::Multiple3DCurve;
211 case BRepCheck_Invalid3DCurve:
212 anErrStruct->error = GEOM::GEOM_IMeasureOperations::Invalid3DCurve;
214 case BRepCheck_NoCurveOnSurface:
215 anErrStruct->error = GEOM::GEOM_IMeasureOperations::NoCurveOnSurface;
217 case BRepCheck_InvalidCurveOnSurface:
218 anErrStruct->error = GEOM::GEOM_IMeasureOperations::InvalidCurveOnSurface;
220 case BRepCheck_InvalidCurveOnClosedSurface:
221 anErrStruct->error = GEOM::GEOM_IMeasureOperations::InvalidCurveOnClosedSurface;
223 case BRepCheck_InvalidSameRangeFlag:
224 anErrStruct->error = GEOM::GEOM_IMeasureOperations::InvalidSameRangeFlag;
226 case BRepCheck_InvalidSameParameterFlag:
227 anErrStruct->error = GEOM::GEOM_IMeasureOperations::InvalidSameParameterFlag;
229 case BRepCheck_InvalidDegeneratedFlag:
230 anErrStruct->error = GEOM::GEOM_IMeasureOperations::InvalidDegeneratedFlag;
232 case BRepCheck_FreeEdge:
233 anErrStruct->error = GEOM::GEOM_IMeasureOperations::FreeEdge;
235 case BRepCheck_InvalidMultiConnexity:
236 anErrStruct->error = GEOM::GEOM_IMeasureOperations::InvalidMultiConnexity;
238 case BRepCheck_InvalidRange:
239 anErrStruct->error = GEOM::GEOM_IMeasureOperations::InvalidRange;
241 case BRepCheck_EmptyWire:
242 anErrStruct->error = GEOM::GEOM_IMeasureOperations::EmptyWire;
244 case BRepCheck_RedundantEdge:
245 anErrStruct->error = GEOM::GEOM_IMeasureOperations::RedundantEdge;
247 case BRepCheck_SelfIntersectingWire:
248 anErrStruct->error = GEOM::GEOM_IMeasureOperations::SelfIntersectingWire;
250 case BRepCheck_NoSurface:
251 anErrStruct->error = GEOM::GEOM_IMeasureOperations::NoSurface;
253 case BRepCheck_InvalidWire:
254 anErrStruct->error = GEOM::GEOM_IMeasureOperations::InvalidWire;
256 case BRepCheck_RedundantWire:
257 anErrStruct->error = GEOM::GEOM_IMeasureOperations::RedundantWire;
259 case BRepCheck_IntersectingWires:
260 anErrStruct->error = GEOM::GEOM_IMeasureOperations::IntersectingWires;
262 case BRepCheck_InvalidImbricationOfWires:
263 anErrStruct->error = GEOM::GEOM_IMeasureOperations::InvalidImbricationOfWires;
265 case BRepCheck_EmptyShell:
266 anErrStruct->error = GEOM::GEOM_IMeasureOperations::EmptyShell;
268 case BRepCheck_RedundantFace:
269 anErrStruct->error = GEOM::GEOM_IMeasureOperations::RedundantFace;
271 case BRepCheck_UnorientableShape:
272 anErrStruct->error = GEOM::GEOM_IMeasureOperations::UnorientableShape;
274 case BRepCheck_NotClosed:
275 anErrStruct->error = GEOM::GEOM_IMeasureOperations::NotClosed;
277 case BRepCheck_NotConnected:
278 anErrStruct->error = GEOM::GEOM_IMeasureOperations::NotConnected;
280 case BRepCheck_SubshapeNotInShape:
281 anErrStruct->error = GEOM::GEOM_IMeasureOperations::SubshapeNotInShape;
283 case BRepCheck_BadOrientation:
284 anErrStruct->error = GEOM::GEOM_IMeasureOperations::BadOrientation;
286 case BRepCheck_BadOrientationOfSubshape:
287 anErrStruct->error = GEOM::GEOM_IMeasureOperations::BadOrientationOfSubshape;
289 case BRepCheck_InvalidToleranceValue:
290 anErrStruct->error = GEOM::GEOM_IMeasureOperations::InvalidToleranceValue;
292 case BRepCheck_CheckFail:
293 anErrStruct->error = GEOM::GEOM_IMeasureOperations::CheckFail;
299 std::list<int> aIndList = anIt->incriminated;
300 GEOM::ListOfLong_var anIncrims = new GEOM::ListOfLong();
301 anIncrims->length(aIndList.size());
303 std::list<int>::iterator anIndIt = aIndList.begin();
306 for (; anIndIt != aIndList.end(); jj++, anIndIt++) {
307 anIncrims[jj] = *anIndIt;
310 anErrStruct->incriminated = anIncrims;
312 anErrArray[i] = anErrStruct;
315 // initialize out-parameter with local array
316 theErrorsTo = anErrArray._retn();
319 //=============================================================================
323 //=============================================================================
324 GEOM_IMeasureOperations_i::GEOM_IMeasureOperations_i (PortableServer::POA_ptr thePOA,
325 GEOM::GEOM_Gen_ptr theEngine,
326 ::GEOMImpl_IMeasureOperations* theImpl)
327 :GEOM_IOperations_i(thePOA, theEngine, theImpl)
329 MESSAGE("GEOM_IMeasureOperations_i::GEOM_IMeasureOperations_i");
332 //=============================================================================
336 //=============================================================================
337 GEOM_IMeasureOperations_i::~GEOM_IMeasureOperations_i()
339 MESSAGE("GEOM_IMeasureOperations_i::~GEOM_IMeasureOperations_i");
342 //=============================================================================
346 //=============================================================================
347 GEOM::GEOM_IKindOfShape::shape_kind GEOM_IMeasureOperations_i::KindOfShape
348 (GEOM::GEOM_Object_ptr theShape,
349 GEOM::ListOfLong_out theIntegers,
350 GEOM::ListOfDouble_out theDoubles)
352 GEOMImpl_IMeasureOperations::ShapeKind aKind = GEOMImpl_IMeasureOperations::SK_NO_SHAPE;
354 // allocate the CORBA arrays
355 GEOM::ListOfLong_var anIntegersArray = new GEOM::ListOfLong();
356 GEOM::ListOfDouble_var aDoublesArray = new GEOM::ListOfDouble();
358 //Get the reference shape
359 Handle(::GEOM_Object) aShape = GetObjectImpl(theShape);
361 if (!aShape.IsNull()) {
362 Handle(TColStd_HSequenceOfInteger) anIntegers = new TColStd_HSequenceOfInteger;
363 Handle(TColStd_HSequenceOfReal) aDoubles = new TColStd_HSequenceOfReal;
365 // Detect kind of shape and parameters
366 aKind = GetOperations()->KindOfShape(aShape, anIntegers, aDoubles);
368 int nbInts = anIntegers->Length();
369 int nbDbls = aDoubles->Length();
371 anIntegersArray->length(nbInts);
372 aDoublesArray->length(nbDbls);
374 for (int ii = 0; ii < nbInts; ii++) {
375 anIntegersArray[ii] = anIntegers->Value(ii + 1);
377 for (int id = 0; id < nbDbls; id++) {
378 aDoublesArray[id] = aDoubles->Value(id + 1);
382 // initialize out-parameters with local arrays
383 theIntegers = anIntegersArray._retn();
384 theDoubles = aDoublesArray._retn();
385 return (GEOM::GEOM_IKindOfShape::shape_kind)aKind;
388 //=============================================================================
392 //=============================================================================
393 void GEOM_IMeasureOperations_i::GetPosition
394 (GEOM::GEOM_Object_ptr theShape,
395 CORBA::Double& Ox, CORBA::Double& Oy, CORBA::Double& Oz,
396 CORBA::Double& Zx, CORBA::Double& Zy, CORBA::Double& Zz,
397 CORBA::Double& Xx, CORBA::Double& Xy, CORBA::Double& Xz)
399 //Set a not done flag
400 GetOperations()->SetNotDone();
402 //Set default values: global CS
403 Ox = Oy = Oz = Zx = Zy = Xy = Xz = 0.;
406 //Get the reference shape
407 Handle(::GEOM_Object) aShape = GetObjectImpl(theShape);
408 if (aShape.IsNull()) return;
410 // Get shape parameters
411 GetOperations()->GetPosition(aShape, Ox,Oy,Oz, Zx,Zy,Zz, Xx,Xy,Xz);
414 //=============================================================================
418 //=============================================================================
419 GEOM::GEOM_Object_ptr GEOM_IMeasureOperations_i::GetCentreOfMass
420 (GEOM::GEOM_Object_ptr theShape)
422 GEOM::GEOM_Object_var aGEOMObject;
424 //Set a not done flag
425 GetOperations()->SetNotDone();
427 //Get the reference shape
428 Handle(::GEOM_Object) aShape = GetObjectImpl(theShape);
429 if (aShape.IsNull()) return aGEOMObject._retn();
431 // Make Point - centre of mass of theShape
432 Handle(::GEOM_Object) anObject = GetOperations()->GetCentreOfMass(aShape);
433 if (!GetOperations()->IsDone() || anObject.IsNull())
434 return aGEOMObject._retn();
436 return GetObject(anObject);
439 //=============================================================================
443 //=============================================================================
444 GEOM::GEOM_Object_ptr
445 GEOM_IMeasureOperations_i::GetVertexByIndex( GEOM::GEOM_Object_ptr theShape,
446 CORBA::Long theIndex,
447 CORBA::Boolean theUseOri )
449 GEOM::GEOM_Object_var aGEOMObject;
451 //Set a not done flag
452 GetOperations()->SetNotDone();
454 //Get the reference shape
455 Handle(::GEOM_Object) aShape = GetObjectImpl(theShape);
456 if ( aShape.IsNull() ) return aGEOMObject._retn();
458 // Get vertex by index
459 Handle(::GEOM_Object) anObject = GetOperations()->GetVertexByIndex(aShape, theIndex, theUseOri);
460 if (!GetOperations()->IsDone() || anObject.IsNull())
461 return aGEOMObject._retn();
463 return GetObject(anObject);
466 //=============================================================================
470 //=============================================================================
471 GEOM::GEOM_Object_ptr GEOM_IMeasureOperations_i::GetNormal
472 (GEOM::GEOM_Object_ptr theFace,
473 GEOM::GEOM_Object_ptr theOptionalPoint)
475 GEOM::GEOM_Object_var aGEOMObject;
477 //Set a not done flag
478 GetOperations()->SetNotDone();
480 //Get the reference shape
481 Handle(::GEOM_Object) aFace = GetObjectImpl(theFace);
482 if (aFace.IsNull()) return aGEOMObject._retn();
484 // Get the OptionalPoint (can be not defined)
485 Handle(::GEOM_Object) anOptionalPoint = GetObjectImpl(theOptionalPoint);
487 // Make Vector - normal to theFace (in point theOptionalPoint if the face is not planar)
488 Handle(::GEOM_Object) anObject = GetOperations()->GetNormal(aFace, anOptionalPoint);
489 if (!GetOperations()->IsDone() || anObject.IsNull())
490 return aGEOMObject._retn();
492 return GetObject(anObject);
495 //=============================================================================
499 //=============================================================================
500 void GEOM_IMeasureOperations_i::GetBasicProperties (GEOM::GEOM_Object_ptr theShape,
501 CORBA::Double theTolerance,
502 CORBA::Double& theLength,
503 CORBA::Double& theSurfArea,
504 CORBA::Double& theVolume)
506 //Set a not done flag
507 GetOperations()->SetNotDone();
509 //Get the reference shape
510 Handle(::GEOM_Object) aShape = GetObjectImpl(theShape);
511 if (aShape.IsNull()) return;
513 // Get shape parameters
514 GetOperations()->GetBasicProperties(aShape, theTolerance, theLength,
515 theSurfArea, theVolume);
518 //=============================================================================
522 //=============================================================================
523 void GEOM_IMeasureOperations_i::GetInertia
524 (GEOM::GEOM_Object_ptr theShape,
525 CORBA::Double& I11, CORBA::Double& I12, CORBA::Double& I13,
526 CORBA::Double& I21, CORBA::Double& I22, CORBA::Double& I23,
527 CORBA::Double& I31, CORBA::Double& I32, CORBA::Double& I33,
528 CORBA::Double& Ix , CORBA::Double& Iy , CORBA::Double& Iz)
530 //Set a not done flag
531 GetOperations()->SetNotDone();
533 //Get the reference shape
534 Handle(::GEOM_Object) aShape = GetObjectImpl(theShape);
535 if (aShape.IsNull()) return;
537 // Get shape parameters
538 GetOperations()->GetInertia(aShape,
545 //=============================================================================
549 //=============================================================================
550 void GEOM_IMeasureOperations_i::GetBoundingBox (GEOM::GEOM_Object_ptr theShape,
551 CORBA::Boolean precise,
552 CORBA::Double& Xmin, CORBA::Double& Xmax,
553 CORBA::Double& Ymin, CORBA::Double& Ymax,
554 CORBA::Double& Zmin, CORBA::Double& Zmax)
556 //Set a not done flag
557 GetOperations()->SetNotDone();
559 //Get the reference shape
560 Handle(::GEOM_Object) aShape = GetObjectImpl(theShape);
561 if (aShape.IsNull()) return;
563 // Get shape parameters
564 GetOperations()->GetBoundingBox
565 (aShape, precise, Xmin, Xmax, Ymin, Ymax, Zmin, Zmax);
568 //=============================================================================
572 //=============================================================================
573 GEOM::GEOM_Object_ptr GEOM_IMeasureOperations_i::MakeBoundingBox
574 (GEOM::GEOM_Object_ptr theShape,
575 CORBA::Boolean precise)
577 GEOM::GEOM_Object_var aGEOMObject;
579 //Set a not done flag
580 GetOperations()->SetNotDone();
582 //Get the reference shape
583 Handle(::GEOM_Object) aShape = GetObjectImpl(theShape);
584 if (aShape.IsNull()) return aGEOMObject._retn();
586 // Make Box - bounding box of theShape
587 Handle(::GEOM_Object) anObject =
588 GetOperations()->GetBoundingBox(aShape, precise);
589 if (!GetOperations()->IsDone() || anObject.IsNull())
590 return aGEOMObject._retn();
592 return GetObject(anObject);
595 //=============================================================================
599 //=============================================================================
600 void GEOM_IMeasureOperations_i::GetTolerance
601 (GEOM::GEOM_Object_ptr theShape,
602 CORBA::Double& FaceMin, CORBA::Double& FaceMax,
603 CORBA::Double& EdgeMin, CORBA::Double& EdgeMax,
604 CORBA::Double& VertMin, CORBA::Double& VertMax)
606 //Set a not done flag
607 GetOperations()->SetNotDone();
609 //Get the reference shape
610 Handle(::GEOM_Object) aShape = GetObjectImpl(theShape);
611 if (aShape.IsNull()) return;
613 // Get shape parameters
614 GetOperations()->GetTolerance(aShape,
620 //=============================================================================
624 //=============================================================================
625 CORBA::Boolean GEOM_IMeasureOperations_i::CheckShape
626 (GEOM::GEOM_Object_ptr theShape,
627 GEOM::GEOM_IMeasureOperations::ShapeErrors_out theErrors)
629 //Set a not done flag
630 GetOperations()->SetNotDone();
632 if (CORBA::is_nil(theShape))
637 //Get the reference shape
638 Handle(::GEOM_Object) aShape = GetObjectImpl(theShape);
645 std::list<GEOMImpl_IMeasureOperations::ShapeError> anErrList;
646 bool isOk = GetOperations()->CheckShape(aShape, false, anErrList);
648 ConvertShapeError(anErrList, theErrors);
653 CORBA::Boolean GEOM_IMeasureOperations_i::CheckShapeWithGeometry
654 (GEOM::GEOM_Object_ptr theShape,
655 GEOM::GEOM_IMeasureOperations::ShapeErrors_out theErrors)
657 //Set a not done flag
658 GetOperations()->SetNotDone();
660 if (CORBA::is_nil(theShape))
665 //Get the reference shape
666 Handle(::GEOM_Object) aShape = GetObjectImpl(theShape);
673 std::list<GEOMImpl_IMeasureOperations::ShapeError> anErrList;
674 bool isOk = GetOperations()->CheckShape(aShape, true, anErrList);
676 ConvertShapeError(anErrList, theErrors);
681 //=============================================================================
685 //=============================================================================
686 char* GEOM_IMeasureOperations_i::PrintShapeErrors
687 ( GEOM::GEOM_Object_ptr theShape,
688 const GEOM::GEOM_IMeasureOperations::ShapeErrors &theErrors)
690 //Get the reference shape
691 Handle(::GEOM_Object) aShape = GetObjectImpl(theShape);
693 if (aShape.IsNull()) {
697 // Convert the errors sequence
698 std::list<GEOMImpl_IMeasureOperations::ShapeError> anErrList;
700 ConvertShapeError(theErrors, anErrList);
702 TCollection_AsciiString aDescr =
703 GetOperations()->PrintShapeErrors(aShape, anErrList);
705 return CORBA::string_dup(aDescr.ToCString());
708 //=============================================================================
710 * CheckSelfIntersections
712 //=============================================================================
713 CORBA::Boolean GEOM_IMeasureOperations_i::CheckSelfIntersections (GEOM::GEOM_Object_ptr theShape,
714 CORBA::Long theCheckLevel,
715 GEOM::ListOfLong_out theIntersections)
717 // Set a not done flag
718 GetOperations()->SetNotDone();
722 // Allocate the CORBA arrays
723 GEOM::ListOfLong_var anIntegersArray = new GEOM::ListOfLong();
725 // Get the reference shape
726 Handle(::GEOM_Object) aShape = GetObjectImpl(theShape);
728 if (!aShape.IsNull()) {
729 GEOMImpl_IMeasureOperations::SICheckLevel aCheckLevel;
731 switch(theCheckLevel) {
733 aCheckLevel = GEOMImpl_IMeasureOperations::SI_V_V;
736 aCheckLevel = GEOMImpl_IMeasureOperations::SI_V_E;
739 aCheckLevel = GEOMImpl_IMeasureOperations::SI_E_E;
742 aCheckLevel = GEOMImpl_IMeasureOperations::SI_V_F;
745 aCheckLevel = GEOMImpl_IMeasureOperations::SI_E_F;
749 aCheckLevel = GEOMImpl_IMeasureOperations::SI_ALL;
753 Handle(TColStd_HSequenceOfInteger) anIntegers = new TColStd_HSequenceOfInteger;
755 // Detect self-intersections
756 isGood = GetOperations()->CheckSelfIntersections
757 (aShape, aCheckLevel, anIntegers);
759 int nbInts = anIntegers->Length();
761 anIntegersArray->length(nbInts);
763 for (int ii = 0; ii < nbInts; ii++) {
764 anIntegersArray[ii] = anIntegers->Value(ii + 1);
768 // Initialize out-parameters with local arrays
769 theIntersections = anIntegersArray._retn();
773 //=============================================================================
775 * CheckSelfIntersectionsFast
777 //=============================================================================
778 CORBA::Boolean GEOM_IMeasureOperations_i::CheckSelfIntersectionsFast
779 (GEOM::GEOM_Object_ptr theShape,
780 CORBA::Float theDeflection,
781 CORBA::Double theTolerance,
782 GEOM::ListOfLong_out theIntersections)
784 // Set a not done flag
785 GetOperations()->SetNotDone();
789 // Allocate the CORBA arrays
790 GEOM::ListOfLong_var anIntegersArray = new GEOM::ListOfLong();
792 // Get the reference shape
793 Handle(::GEOM_Object) aShape = GetObjectImpl(theShape);
795 if (!aShape.IsNull()) {
796 Handle(TColStd_HSequenceOfInteger) anIntegers = new TColStd_HSequenceOfInteger;
798 // Detect self-intersections
799 isGood = GetOperations()->CheckSelfIntersectionsFast
800 (aShape, theDeflection, theTolerance, anIntegers);
802 int nbInts = anIntegers->Length();
804 anIntegersArray->length(nbInts);
806 for (int ii = 0; ii < nbInts; ii++) {
807 anIntegersArray[ii] = anIntegers->Value(ii + 1);
811 // Initialize out-parameters with local arrays
812 theIntersections = anIntegersArray._retn();
816 //=============================================================================
820 //=============================================================================
821 CORBA::Boolean GEOM_IMeasureOperations_i::CheckBOPArguments
822 (GEOM::GEOM_Object_ptr theShape)
824 // Set a not done flag
825 GetOperations()->SetNotDone();
827 // Get the reference shape
828 Handle(::GEOM_Object) aShape = GetObjectImpl(theShape);
831 if (!aShape.IsNull()) {
832 // Check BOP arguments
833 isGood = GetOperations()->CheckBOPArguments(aShape);
839 //=============================================================================
843 //=============================================================================
844 CORBA::Boolean GEOM_IMeasureOperations_i::FastIntersect (GEOM::GEOM_Object_ptr theShape1,
845 GEOM::GEOM_Object_ptr theShape2,
846 CORBA::Double theTolerance,
847 CORBA::Float theDeflection,
848 GEOM::ListOfLong_out theIntersections1,
849 GEOM::ListOfLong_out theIntersections2)
851 // Set a not done flag
852 GetOperations()->SetNotDone();
856 // Allocate the CORBA arrays
857 GEOM::ListOfLong_var anIntegersArray1 = new GEOM::ListOfLong();
858 GEOM::ListOfLong_var anIntegersArray2 = new GEOM::ListOfLong();
860 // Get the reference shape
861 Handle(::GEOM_Object) aShape1 = GetObjectImpl(theShape1);
862 Handle(::GEOM_Object) aShape2 = GetObjectImpl(theShape2);
864 if (!aShape1.IsNull() && !aShape2.IsNull()) {
865 Handle(TColStd_HSequenceOfInteger) anIntegers1 = new TColStd_HSequenceOfInteger;
866 Handle(TColStd_HSequenceOfInteger) anIntegers2 = new TColStd_HSequenceOfInteger;
868 // Detect intersections
869 isGood = GetOperations()->FastIntersect
870 (aShape1, aShape2, theTolerance, theDeflection, anIntegers1, anIntegers2);
872 int nbInts1 = anIntegers1->Length();
873 int nbInts2 = anIntegers2->Length();
875 anIntegersArray1->length(nbInts1);
876 anIntegersArray2->length(nbInts2);
878 for (int ii = 0; ii < nbInts1; ii++) {
879 anIntegersArray1[ii] = anIntegers1->Value(ii + 1);
881 for (int ii = 0; ii < nbInts2; ii++) {
882 anIntegersArray2[ii] = anIntegers2->Value(ii + 1);
886 // Initialize out-parameters with local arrays
887 theIntersections1 = anIntegersArray1._retn();
888 theIntersections2 = anIntegersArray2._retn();
892 //=============================================================================
896 //=============================================================================
897 char* GEOM_IMeasureOperations_i::IsGoodForSolid (GEOM::GEOM_Object_ptr theShape)
899 //Set a not done flag
900 GetOperations()->SetNotDone();
902 //Get the reference shape
903 Handle(::GEOM_Object) aShape = GetObjectImpl(theShape);
904 if (aShape.IsNull()) return CORBA::string_dup("WRN_NULL_OBJECT_OR_SHAPE");
906 // Get shape parameters
907 TCollection_AsciiString aDescription = GetOperations()->IsGoodForSolid(aShape);
908 return CORBA::string_dup(aDescription.ToCString());
911 //=============================================================================
915 //=============================================================================
916 char* GEOM_IMeasureOperations_i::WhatIs (GEOM::GEOM_Object_ptr theShape)
918 //Set a not done flag
919 GetOperations()->SetNotDone();
921 //Get the reference shape
922 Handle(::GEOM_Object) aShape = GetObjectImpl(theShape);
923 if (aShape.IsNull()) return NULL;
925 // Get shape parameters
926 TCollection_AsciiString aDescription = GetOperations()->WhatIs(aShape);
927 return CORBA::string_dup(aDescription.ToCString());
930 //=============================================================================
934 //=============================================================================
935 GEOM::ListOfBool* GEOM_IMeasureOperations_i::AreCoordsInside (GEOM::GEOM_Object_ptr theShape,
936 const GEOM::ListOfDouble& theCoords,
937 CORBA::Double tolerance)
939 //Set a not done flag
940 GetOperations()->SetNotDone();
942 int nb_points = theCoords.length()/3;
944 GEOM::ListOfBool_var aResults = new GEOM::ListOfBool;
945 aResults->length(nb_points);
947 Handle(::GEOM_Object) aShape = GetObjectImpl(theShape);
949 std::vector<double> tmp(3*nb_points);
950 for (int i = 0; i < 3*nb_points; i++)
951 tmp[i] = theCoords[i];
952 std::vector<bool> res = GetOperations()->AreCoordsInside(aShape, tmp, tolerance);
953 for (int i = 0, resSize = res.size(); i < nb_points; i++)
954 aResults[i] = i < resSize ? res[i] : false;
955 return aResults._retn();
958 //=============================================================================
962 //=============================================================================
963 CORBA::Double GEOM_IMeasureOperations_i::GetMinDistance
964 (GEOM::GEOM_Object_ptr theShape1, GEOM::GEOM_Object_ptr theShape2,
965 CORBA::Double& X1, CORBA::Double& Y1, CORBA::Double& Z1,
966 CORBA::Double& X2, CORBA::Double& Y2, CORBA::Double& Z2)
968 //Set a not done flag
969 GetOperations()->SetNotDone();
971 //Get the reference shape
972 Handle(::GEOM_Object) aShape1 = GetObjectImpl(theShape1);
973 Handle(::GEOM_Object) aShape2 = GetObjectImpl(theShape2);
974 if (aShape1.IsNull() || aShape2.IsNull()) return -1.0;
976 // Get shape parameters
977 return GetOperations()->GetMinDistance(aShape1, aShape2, X1, Y1, Z1, X2, Y2, Z2);
980 //=============================================================================
984 //=============================================================================
985 CORBA::Long GEOM_IMeasureOperations_i::ClosestPoints
986 (GEOM::GEOM_Object_ptr theShape1, GEOM::GEOM_Object_ptr theShape2,
987 GEOM::ListOfDouble_out theCoords)
989 //Set a not done flag
990 GetOperations()->SetNotDone();
992 // allocate the CORBA array
994 GEOM::ListOfDouble_var aDoublesArray = new GEOM::ListOfDouble();
996 //Get the reference shape
997 Handle(::GEOM_Object) aShape1 = GetObjectImpl(theShape1);
998 Handle(::GEOM_Object) aShape2 = GetObjectImpl(theShape2);
1000 if (!aShape1.IsNull() && !aShape2.IsNull()) {
1001 Handle(TColStd_HSequenceOfReal) aDoubles = new TColStd_HSequenceOfReal;
1002 // Get shape parameters
1003 nbSols = GetOperations()->ClosestPoints(aShape1, aShape2, aDoubles);
1004 int nbDbls = aDoubles->Length();
1005 aDoublesArray->length(nbDbls);
1006 for (int id = 0; id < nbDbls; id++) {
1007 aDoublesArray[id] = aDoubles->Value(id + 1);
1011 theCoords = aDoublesArray._retn();
1015 //=============================================================================
1019 //=============================================================================
1020 void GEOM_IMeasureOperations_i::PointCoordinates (GEOM::GEOM_Object_ptr theShape,
1021 CORBA::Double& X, CORBA::Double& Y, CORBA::Double& Z)
1024 //Set a not done flag
1025 GetOperations()->SetNotDone();
1027 //Get the reference shape
1028 Handle(::GEOM_Object) aShape = GetObjectImpl(theShape);
1029 if (aShape.IsNull())
1032 // Get shape parameters
1033 GetOperations()->PointCoordinates( aShape, X, Y, Z );
1036 //=============================================================================
1040 //=============================================================================
1041 CORBA::Double GEOM_IMeasureOperations_i::GetAngle (GEOM::GEOM_Object_ptr theShape1,
1042 GEOM::GEOM_Object_ptr theShape2)
1044 //Set a not done flag
1045 GetOperations()->SetNotDone();
1047 //Get the reference shapes
1048 Handle(::GEOM_Object) aShape1 = GetObjectImpl(theShape1);
1049 Handle(::GEOM_Object) aShape2 = GetObjectImpl(theShape2);
1050 if (aShape1.IsNull() || aShape2.IsNull()) return -1.0;
1053 return GetOperations()->GetAngle(aShape1, aShape2);
1056 //=============================================================================
1060 //=============================================================================
1061 CORBA::Double GEOM_IMeasureOperations_i::GetAngleBtwVectors (GEOM::GEOM_Object_ptr theShape1,
1062 GEOM::GEOM_Object_ptr theShape2)
1064 //Set a not done flag
1065 GetOperations()->SetNotDone();
1067 //Get the reference shapes
1068 Handle(::GEOM_Object) aShape1 = GetObjectImpl(theShape1);
1069 Handle(::GEOM_Object) aShape2 = GetObjectImpl(theShape2);
1070 if (aShape1.IsNull() || aShape2.IsNull()) return -1.0;
1073 return GetOperations()->GetAngleBtwVectors(aShape1, aShape2);
1076 //=============================================================================
1080 //=============================================================================
1081 GEOM::ListOfGO* GEOM_IMeasureOperations_i::PatchFace(GEOM::GEOM_Object_ptr theShape)
1083 GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
1085 //Get the reference shape
1086 Handle(::GEOM_Object) aShapeRef = GetObjectImpl(theShape);
1087 if (aShapeRef.IsNull()) return aSeq._retn();
1089 // Perform patch face operation
1090 Handle(TColStd_HSequenceOfTransient) aHSeq =
1091 GetOperations()->PatchFace(aShapeRef);
1092 if (!GetOperations()->IsDone() || aHSeq.IsNull())
1093 return aSeq._retn();
1095 Standard_Integer aLength = aHSeq->Length();
1096 aSeq->length(aLength);
1097 for (Standard_Integer i = 1; i <= aLength; i++)
1098 aSeq[i - 1] = GetObject(Handle(::GEOM_Object)::DownCast(aHSeq->Value(i)));
1100 return aSeq._retn();
1103 //=============================================================================
1105 * CurveCurvatureByParam
1107 //=============================================================================
1108 CORBA::Double GEOM_IMeasureOperations_i::CurveCurvatureByParam
1109 (GEOM::GEOM_Object_ptr theCurve, CORBA::Double theParam)
1111 //Set a not done flag
1112 GetOperations()->SetNotDone();
1114 //Get the reference shape
1115 Handle(::GEOM_Object) aShape = GetObjectImpl(theCurve);
1116 if(aShape.IsNull()) return -1.0;
1118 return GetOperations()->CurveCurvatureByParam(aShape,theParam);
1121 //=============================================================================
1123 * CurveCurvatureByPoint
1125 //=============================================================================
1126 CORBA::Double GEOM_IMeasureOperations_i::CurveCurvatureByPoint
1127 (GEOM::GEOM_Object_ptr theCurve, GEOM::GEOM_Object_ptr thePoint)
1129 //Set a not done flag
1130 GetOperations()->SetNotDone();
1132 //Get the reference shape
1133 Handle(::GEOM_Object) aShape = GetObjectImpl(theCurve);
1134 Handle(::GEOM_Object) aPoint = GetObjectImpl(thePoint);
1135 if( aShape.IsNull() || aPoint.IsNull() ) return -1.0;
1137 return GetOperations()->CurveCurvatureByPoint(aShape,aPoint);
1141 //=============================================================================
1143 * MaxSurfaceCurvatureByParam
1145 //=============================================================================
1146 CORBA::Double GEOM_IMeasureOperations_i::MaxSurfaceCurvatureByParam
1147 (GEOM::GEOM_Object_ptr theSurf,
1148 CORBA::Double theUParam,
1149 CORBA::Double theVParam)
1151 //Set a not done flag
1152 GetOperations()->SetNotDone();
1154 //Get the reference shape
1155 Handle(::GEOM_Object) aShape = GetObjectImpl(theSurf);
1156 if(aShape.IsNull()) return -1.0;
1158 return GetOperations()->MaxSurfaceCurvatureByParam(aShape,theUParam,theVParam);
1161 //=============================================================================
1163 * MaxSurfaceCurvatureByPoint
1165 //=============================================================================
1166 CORBA::Double GEOM_IMeasureOperations_i::MaxSurfaceCurvatureByPoint
1167 (GEOM::GEOM_Object_ptr theSurf, GEOM::GEOM_Object_ptr thePoint)
1169 //Set a not done flag
1170 GetOperations()->SetNotDone();
1172 //Get the reference shape
1173 Handle(::GEOM_Object) aShape = GetObjectImpl(theSurf);
1174 Handle(::GEOM_Object) aPoint = GetObjectImpl(thePoint);
1175 if( aShape.IsNull() || aPoint.IsNull() ) return -1.0;
1177 return GetOperations()->MaxSurfaceCurvatureByPoint(aShape,aPoint);
1180 //=============================================================================
1182 * MinSurfaceCurvatureByParam
1184 //=============================================================================
1185 CORBA::Double GEOM_IMeasureOperations_i::MinSurfaceCurvatureByParam
1186 (GEOM::GEOM_Object_ptr theSurf,
1187 CORBA::Double theUParam,
1188 CORBA::Double theVParam)
1190 //Set a not done flag
1191 GetOperations()->SetNotDone();
1193 //Get the reference shape
1194 Handle(::GEOM_Object) aShape = GetObjectImpl(theSurf);
1195 if (aShape.IsNull()) return -1.0;
1197 return GetOperations()->MinSurfaceCurvatureByParam(aShape,theUParam,theVParam);
1200 //=============================================================================
1202 * MinSurfaceCurvatureByPoint
1204 //=============================================================================
1205 CORBA::Double GEOM_IMeasureOperations_i::MinSurfaceCurvatureByPoint
1206 (GEOM::GEOM_Object_ptr theSurf, GEOM::GEOM_Object_ptr thePoint)
1208 //Set a not done flag
1209 GetOperations()->SetNotDone();
1211 //Get the reference shape
1212 Handle(::GEOM_Object) aShape = GetObjectImpl(theSurf);
1213 Handle(::GEOM_Object) aPoint = GetObjectImpl(thePoint);
1214 if (aShape.IsNull() || aPoint.IsNull()) return -1.0;
1216 return GetOperations()->MinSurfaceCurvatureByPoint(aShape,aPoint);
1219 //=============================================================================
1221 * SurfaceCurvatureByPointAndDirection
1223 //=============================================================================
1224 GEOM::GEOM_Object_ptr GEOM_IMeasureOperations_i::SurfaceCurvatureByPointAndDirection
1225 (GEOM::GEOM_Object_ptr theSurf,
1226 GEOM::GEOM_Object_ptr thePoint,
1227 GEOM::GEOM_Object_ptr theDirection)
1229 GEOM::GEOM_Object_var aGEOMObject;
1231 //Set a not done flag
1232 GetOperations()->SetNotDone();
1234 //Get the reference shape
1235 Handle(::GEOM_Object) aShape = GetObjectImpl(theSurf);
1236 Handle(::GEOM_Object) aPoint = GetObjectImpl(thePoint);
1237 Handle(::GEOM_Object) aDirection = GetObjectImpl(theDirection);
1238 if (aShape.IsNull() || aPoint.IsNull() || aDirection.IsNull()) return aGEOMObject._retn();
1240 Handle(::GEOM_Object) anObject =
1241 GetOperations()->SurfaceCurvatureByPointAndDirection(aShape,aPoint,aDirection);
1242 if (!GetOperations()->IsDone() || anObject.IsNull())
1243 return aGEOMObject._retn();
1245 return GetObject(anObject);
1248 //=============================================================================
1252 //=============================================================================
1253 GEOM::ListOfDouble* GEOM_IMeasureOperations_i::XYZtoUV
1254 (GEOM::GEOM_Object_ptr theSurf,
1255 const GEOM::ListOfDouble& theXYZlist,
1256 CORBA::Boolean theIsNormalized)
1258 GEOM::ListOfDouble_var resUV = new GEOM::ListOfDouble;
1260 //Set a not done flag
1261 GetOperations()->SetNotDone();
1263 //Get the reference shape
1264 Handle(::GEOM_Object) aShape = GetObjectImpl(theSurf);
1265 if (aShape.IsNull()) return resUV._retn();
1267 //Get input XYZ list
1268 Handle(TColStd_HArray1OfReal) aXYZlist =
1269 new TColStd_HArray1OfReal (0, theXYZlist.length() - 1);
1271 size_t nb = theXYZlist.length();
1272 for (size_t i = 0; i < nb; ++i)
1273 aXYZlist->SetValue(i, theXYZlist[i]);
1276 //Call implementation
1277 Handle(TColStd_HArray1OfReal) aUVlist =
1278 GetOperations()->XYZtoUV(aShape, aXYZlist, theIsNormalized);
1280 if (GetOperations()->IsDone()) {
1281 resUV->length(aUVlist->Length());
1282 int i0 = aUVlist->Lower();
1283 int nb = aUVlist->Upper();
1284 for (int i = i0; i <= nb; ++i)
1285 resUV[ i-i0 ] = aUVlist->Value(i);
1288 return resUV._retn();
1291 //=============================================================================
1295 //=============================================================================
1296 GEOM::ListOfDouble* GEOM_IMeasureOperations_i::UVtoXYZ
1297 (GEOM::GEOM_Object_ptr theSurf,
1298 const GEOM::ListOfDouble& theUVlist,
1299 CORBA::Boolean theIsNormalized)
1301 GEOM::ListOfDouble_var resXYZ = new GEOM::ListOfDouble;
1303 //Set a not done flag
1304 GetOperations()->SetNotDone();
1306 //Get the reference shape
1307 Handle(::GEOM_Object) aShape = GetObjectImpl(theSurf);
1308 if (aShape.IsNull()) return resXYZ._retn();
1311 Handle(TColStd_HArray1OfReal) aUVlist =
1312 new TColStd_HArray1OfReal (0, theUVlist.length() - 1);
1314 size_t nb = theUVlist.length();
1315 for (size_t i = 0; i < nb; ++i)
1316 aUVlist->SetValue(i, theUVlist[i]);
1319 //Call implementation
1320 Handle(TColStd_HArray1OfReal) aXYZlist =
1321 GetOperations()->UVtoXYZ(aShape, aUVlist, theIsNormalized);
1323 if (GetOperations()->IsDone()) {
1324 resXYZ->length(aXYZlist->Length());
1325 int i0 = aXYZlist->Lower();
1326 int nb = aXYZlist->Upper();
1327 for (int i = i0; i <= nb; ++i)
1328 resXYZ[ i-i0 ] = aXYZlist->Value(i);
1331 return resXYZ._retn();
1334 //=============================================================================
1337 * Find all self-intersected 2D curves.
1338 * \param theShape Shape for check.
1340 //=============================================================================
1341 GEOM::GEOM_IMeasureOperations::SequenceOfPairOfShape* GEOM_IMeasureOperations_i::SelfIntersected2D(
1342 const GEOM::GEOM_IMeasureOperations::CheckResults& theResuts)
1344 GEOM::GEOM_IMeasureOperations::SequenceOfPairOfShape_var aSeq =
1345 new GEOM::GEOM_IMeasureOperations::SequenceOfPairOfShape;
1347 // Perform patch face operation
1348 std::list<GEOMImpl_IMeasureOperations::FailedChecks> aResults;
1349 ConvertToList(theResuts, aResults);
1351 std::list<GEOMImpl_IMeasureOperations::CoupleOfObjects> aSelfInters = GetOperations()->SelfIntersected2D(aResults);
1352 if (!GetOperations()->IsDone() || aSelfInters.empty())
1353 return aSeq._retn();
1355 Standard_Integer aLength = aSelfInters.size();
1356 aSeq->length(aLength);
1357 std::list<GEOMImpl_IMeasureOperations::CoupleOfObjects>::iterator anIter(aSelfInters.begin());
1358 for (Standard_Integer i = 0; i < aLength; i++, ++anIter)
1360 aSeq[i].first = GetObject(Handle(::GEOM_Object)::DownCast((*anIter).first));
1361 aSeq[i].second = GetObject(Handle(::GEOM_Object)::DownCast((*anIter).second));
1364 return aSeq._retn();
1367 //=============================================================================
1369 * InterferingSubshapes
1370 * Find pairs of interfering sub-shapes, by default all pairs of interfering shapes are returned.
1371 * \param theShape Shape for check.
1372 * \param theShapeType1 Type of shape.
1373 * \param theShapeType2 Type of shape.
1375 //=============================================================================
1376 GEOM::GEOM_IMeasureOperations::SequenceOfPairOfShape* GEOM_IMeasureOperations_i::InterferingSubshapes(
1377 const GEOM::GEOM_IMeasureOperations::CheckResults& theResuts,
1378 const CORBA::Long theShapeType1,
1379 const CORBA::Long theShapeType2)
1381 GEOM::GEOM_IMeasureOperations::SequenceOfPairOfShape_var aSeq =
1382 new GEOM::GEOM_IMeasureOperations::SequenceOfPairOfShape;
1384 // Perform patch face operation
1385 std::list<GEOMImpl_IMeasureOperations::FailedChecks> aResults;
1386 ConvertToList(theResuts, aResults);
1388 std::list<GEOMImpl_IMeasureOperations::CoupleOfObjects> aSelfInterf =
1389 GetOperations()->InterferingSubshapes(aResults, theShapeType1, theShapeType2);
1390 if (!GetOperations()->IsDone() || aSelfInterf.empty())
1391 return aSeq._retn();
1393 Standard_Integer aLength = aSelfInterf.size();
1394 aSeq->length(aLength);
1395 std::list<GEOMImpl_IMeasureOperations::CoupleOfObjects>::iterator anIter(aSelfInterf.begin());
1396 for (Standard_Integer i = 0; i < aLength; i++, ++anIter)
1398 aSeq[i].first = GetObject(Handle(::GEOM_Object)::DownCast((*anIter).first));
1399 aSeq[i].second = GetObject(Handle(::GEOM_Object)::DownCast((*anIter).second));
1402 return aSeq._retn();
1405 //=============================================================================
1408 * Find edges, which are fully covered by tolerances of vertices.
1409 * \param theShape Shape for check.
1411 //=============================================================================
1412 GEOM::ListOfGO* GEOM_IMeasureOperations_i::SmallEdges(const GEOM::GEOM_IMeasureOperations::CheckResults& theResuts)
1414 GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
1416 std::list<GEOMImpl_IMeasureOperations::FailedChecks> aResults;
1417 ConvertToList(theResuts, aResults);
1419 //Get the reference shape
1420 Handle(TColStd_HSequenceOfTransient) aSmallEdges = GetOperations()->SmallEdges(aResults);
1421 if (!GetOperations()->IsDone() || aSmallEdges.IsNull())
1422 return aSeq._retn();
1424 Standard_Integer aLength = aSmallEdges->Length();
1425 aSeq->length(aLength);
1426 for (Standard_Integer i = 1; i <= aLength; i++)
1427 aSeq[i - 1] = GetObject(Handle(::GEOM_Object)::DownCast(aSmallEdges->Value(i)));
1429 return aSeq._retn();
1432 //=============================================================================
1435 * find remote objects (sub-shape on a shape).
1436 * \param theShape Shape for check.
1437 * \param theShapeType Type of shape.
1438 * \param theSubShapeType Type of sub-shape.
1439 * \param theTolerance tolerance.
1441 //=============================================================================
1442 GEOM::GEOM_IMeasureOperations::SequenceOfPairOfShape* GEOM_IMeasureOperations_i::DistantShapes(
1443 const GEOM::GEOM_IMeasureOperations::CheckResults& theResuts,
1444 const CORBA::Long theShapeType,
1445 const CORBA::Long theSubShapeType,
1446 const CORBA::Double theTolerance)
1448 GEOM::GEOM_IMeasureOperations::SequenceOfPairOfShape_var aSeq =
1449 new GEOM::GEOM_IMeasureOperations::SequenceOfPairOfShape;
1451 std::list<GEOMImpl_IMeasureOperations::FailedChecks> aResults;
1452 ConvertToList(theResuts, aResults);
1454 // Perform patch face operation
1455 std::list<GEOMImpl_IMeasureOperations::CoupleOfObjects> aDistantS =
1456 GetOperations()->DistantShapes(aResults, theShapeType, theSubShapeType, theTolerance);
1457 if (!GetOperations()->IsDone() || aDistantS.empty())
1458 return aSeq._retn();
1460 Standard_Integer aLength = aDistantS.size();
1461 aSeq->length(aLength);
1462 std::list<GEOMImpl_IMeasureOperations::CoupleOfObjects>::iterator anIter(aDistantS.begin());
1463 for (Standard_Integer i = 0; i < aLength; i++, ++anIter)
1465 aSeq[i].first = GetObject(Handle(::GEOM_Object)::DownCast((*anIter).first));
1466 aSeq[i].second = GetObject(Handle(::GEOM_Object)::DownCast((*anIter).second));
1469 return aSeq._retn();
1472 //=============================================================================
1474 * CheckConformityShape
1475 * Perform all required checks
1477 //=============================================================================
1478 GEOM::GEOM_IMeasureOperations::CheckResults* GEOM_IMeasureOperations_i::CheckConformityShape(
1479 GEOM::GEOM_Object_ptr theShape)
1481 GEOM::GEOM_IMeasureOperations::CheckResults_var aRes = new GEOM::GEOM_IMeasureOperations::CheckResults;
1483 //Get the reference shape
1484 Handle(::GEOM_Object) aShapeRef = GetObjectImpl(theShape);
1485 if (aShapeRef.IsNull()) return nullptr;
1487 std::list<GEOMImpl_IMeasureOperations::FailedChecks> aChecks;
1488 GetOperations()->CheckConformityShape(aShapeRef, aChecks);
1490 Standard_Integer aLength = aChecks.size();
1491 aRes->length(aLength);
1492 std::list<GEOMImpl_IMeasureOperations::FailedChecks>::const_iterator anIntIt = aChecks.cbegin();
1493 for (Standard_Integer i = 0; i < aLength; i++, ++anIntIt)
1495 aRes[i].type = (*anIntIt).TypeOfCheck;
1496 aRes[i].failedShapes.first = GetObject(Handle(::GEOM_Object)::DownCast((*anIntIt).FailedShapes.first));
1497 aRes[i].failedShapes.second = GetObject(Handle(::GEOM_Object)::DownCast((*anIntIt).FailedShapes.second));
1500 return aRes._retn();
1503 //=============================================================================
1506 * Compute possible tolerance for the shape, minimize tolerance of shape as well
1507 * as tolerance of sub-shapes as much as possible
1508 * \param theShape Shape for check.
1510 //=============================================================================
1511 CORBA::Double GEOM_IMeasureOperations_i::UpdateTolerance(GEOM::GEOM_Object_ptr theShape)
1513 //Get the reference shape
1514 Handle(::GEOM_Object) aShapeRef = GetObjectImpl(theShape);
1515 if (aShapeRef.IsNull())
1518 return GetOperations()->UpdateTolerance(aShapeRef);
1521 void GEOM_IMeasureOperations_i::ConvertToList(const GEOM::GEOM_IMeasureOperations::CheckResults& theResuts,
1522 std::list<GEOMImpl_IMeasureOperations::FailedChecks>& theListOfResults)
1524 for (Standard_Integer i = 0; i < theResuts.length(); ++i)
1526 GEOMImpl_IMeasureOperations::FailedChecks aCheck;
1527 aCheck.TypeOfCheck = theResuts[i].type;
1528 aCheck.FailedShapes.first = GetObjectImpl(theResuts[i].failedShapes.first);
1529 aCheck.FailedShapes.second = GetObjectImpl(theResuts[i].failedShapes.second);
1530 theListOfResults.push_back(aCheck);
1534 //=============================================================================
1536 * ShapeProximityCalculator
1538 //=============================================================================
1539 GEOM::GEOM_Object_ptr GEOM_IMeasureOperations_i::ShapeProximityCalculator(GEOM::GEOM_Object_ptr theShape1,
1540 GEOM::GEOM_Object_ptr theShape2)
1542 GEOM::GEOM_Object_var anEmptyCalc;
1544 //Set a not done flag
1545 GetOperations()->SetNotDone();
1547 //Get the reference shape
1548 Handle(::GEOM_Object) aShape1 = GetObjectImpl(theShape1);
1549 Handle(::GEOM_Object) aShape2 = GetObjectImpl(theShape2);
1550 if (aShape1.IsNull() || aShape2.IsNull())
1551 return anEmptyCalc._retn();
1553 Handle(::GEOM_Object) aCalculator = GetOperations()->ShapeProximityCalculator(aShape1, aShape2);
1554 if (!GetOperations()->IsDone() || aCalculator.IsNull())
1555 return anEmptyCalc._retn();
1557 return GetObject(aCalculator);
1560 //=============================================================================
1564 //=============================================================================
1565 void GEOM_IMeasureOperations_i::SetShapeSampling(GEOM::GEOM_Object_ptr theCalculator,
1566 GEOM::GEOM_Object_ptr theShape,
1567 CORBA::Long theNbSamples)
1569 //Set a not done flag
1570 GetOperations()->SetNotDone();
1572 //Get the proximity calculator
1573 Handle(::GEOM_Object) aCalc = GetObjectImpl(theCalculator);
1576 //Get the reference shape
1577 Handle(::GEOM_Object) aShape = GetObjectImpl(theShape);
1578 if (aShape.IsNull())
1581 GetOperations()->SetShapeSampling(aCalc, aShape, theNbSamples);
1584 //=============================================================================
1586 * GetCoarseProximity
1588 //=============================================================================
1589 CORBA::Double GEOM_IMeasureOperations_i::GetCoarseProximity(GEOM::GEOM_Object_ptr theCalculator)
1591 //Set a not done flag
1592 GetOperations()->SetNotDone();
1594 //Get the reference shape
1595 Handle(::GEOM_Object) aCalc = GetObjectImpl(theCalculator);
1599 Standard_Real aProximity = GetOperations()->GetCoarseProximity(aCalc);
1600 if (!GetOperations()->IsDone())
1606 //=============================================================================
1608 * GetPreciseProximity
1610 //=============================================================================
1611 CORBA::Double GEOM_IMeasureOperations_i::GetPreciseProximity(GEOM::GEOM_Object_ptr theCalculator)
1613 //Set a not done flag
1614 GetOperations()->SetNotDone();
1616 //Get the reference shape
1617 Handle(::GEOM_Object) aCalc = GetObjectImpl(theCalculator);
1621 Standard_Real aProximity = GetOperations()->GetPreciseProximity(aCalc);
1622 if (!GetOperations()->IsDone())