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>
25 #include "GEOM_IMeasureOperations_i.hh"
27 #include "utilities.h"
30 #include "GEOM_Engine.hxx"
31 #include "GEOM_Object.hxx"
34 * This function converts shape errors from theErrorsFrom to theErrorsTo.
35 * Note that theErrorsTo is not cleared at first.
37 * \param theErrorsFrom errors to be converted.
38 * \param theErrorsTo result errors.
40 static void ConvertShapeError
41 (const GEOM::GEOM_IMeasureOperations::ShapeErrors &theErrorsFrom,
42 std::list<GEOMImpl_IMeasureOperations::ShapeError> &theErrorsTo)
44 int aNbErr = theErrorsFrom.length();
47 for (; i < aNbErr; i++) {
48 const GEOM::GEOM_IMeasureOperations::ShapeError anErr = theErrorsFrom[i];
49 const GEOM::GEOM_IMeasureOperations::ShapeErrorType aType = anErr.error;
50 const GEOM::ListOfLong anIncrims = anErr.incriminated;
51 GEOMImpl_IMeasureOperations::ShapeError anErrStruct;
54 case GEOM::GEOM_IMeasureOperations::InvalidPointOnCurve:
55 anErrStruct.error = BRepCheck_InvalidPointOnCurve;
57 case GEOM::GEOM_IMeasureOperations::InvalidPointOnCurveOnSurface:
58 anErrStruct.error = BRepCheck_InvalidPointOnCurveOnSurface;
60 case GEOM::GEOM_IMeasureOperations::InvalidPointOnSurface:
61 anErrStruct.error = BRepCheck_InvalidPointOnSurface;
63 case GEOM::GEOM_IMeasureOperations::No3DCurve:
64 anErrStruct.error = BRepCheck_No3DCurve;
66 case GEOM::GEOM_IMeasureOperations::Multiple3DCurve:
67 anErrStruct.error = BRepCheck_Multiple3DCurve;
69 case GEOM::GEOM_IMeasureOperations::Invalid3DCurve:
70 anErrStruct.error = BRepCheck_Invalid3DCurve;
72 case GEOM::GEOM_IMeasureOperations::NoCurveOnSurface:
73 anErrStruct.error = BRepCheck_NoCurveOnSurface;
75 case GEOM::GEOM_IMeasureOperations::InvalidCurveOnSurface:
76 anErrStruct.error = BRepCheck_InvalidCurveOnSurface;
78 case GEOM::GEOM_IMeasureOperations::InvalidCurveOnClosedSurface:
79 anErrStruct.error = BRepCheck_InvalidCurveOnClosedSurface;
81 case GEOM::GEOM_IMeasureOperations::InvalidSameRangeFlag:
82 anErrStruct.error = BRepCheck_InvalidSameRangeFlag;
84 case GEOM::GEOM_IMeasureOperations::InvalidSameParameterFlag:
85 anErrStruct.error = BRepCheck_InvalidSameParameterFlag;
87 case GEOM::GEOM_IMeasureOperations::InvalidDegeneratedFlag:
88 anErrStruct.error = BRepCheck_InvalidDegeneratedFlag;
90 case GEOM::GEOM_IMeasureOperations::FreeEdge:
91 anErrStruct.error = BRepCheck_FreeEdge;
93 case GEOM::GEOM_IMeasureOperations::InvalidMultiConnexity:
94 anErrStruct.error = BRepCheck_InvalidMultiConnexity;
96 case GEOM::GEOM_IMeasureOperations::InvalidRange:
97 anErrStruct.error = BRepCheck_InvalidRange;
99 case GEOM::GEOM_IMeasureOperations::EmptyWire:
100 anErrStruct.error = BRepCheck_EmptyWire;
102 case GEOM::GEOM_IMeasureOperations::RedundantEdge:
103 anErrStruct.error = BRepCheck_RedundantEdge;
105 case GEOM::GEOM_IMeasureOperations::SelfIntersectingWire:
106 anErrStruct.error = BRepCheck_SelfIntersectingWire;
108 case GEOM::GEOM_IMeasureOperations::NoSurface:
109 anErrStruct.error = BRepCheck_NoSurface;
111 case GEOM::GEOM_IMeasureOperations::InvalidWire:
112 anErrStruct.error = BRepCheck_InvalidWire;
114 case GEOM::GEOM_IMeasureOperations::RedundantWire:
115 anErrStruct.error = BRepCheck_RedundantWire;
117 case GEOM::GEOM_IMeasureOperations::IntersectingWires:
118 anErrStruct.error = BRepCheck_IntersectingWires;
120 case GEOM::GEOM_IMeasureOperations::InvalidImbricationOfWires:
121 anErrStruct.error = BRepCheck_InvalidImbricationOfWires;
123 case GEOM::GEOM_IMeasureOperations::EmptyShell:
124 anErrStruct.error = BRepCheck_EmptyShell;
126 case GEOM::GEOM_IMeasureOperations::RedundantFace:
127 anErrStruct.error = BRepCheck_RedundantFace;
129 case GEOM::GEOM_IMeasureOperations::UnorientableShape:
130 anErrStruct.error = BRepCheck_UnorientableShape;
132 case GEOM::GEOM_IMeasureOperations::NotClosed:
133 anErrStruct.error = BRepCheck_NotClosed;
135 case GEOM::GEOM_IMeasureOperations::NotConnected:
136 anErrStruct.error = BRepCheck_NotConnected;
138 case GEOM::GEOM_IMeasureOperations::SubshapeNotInShape:
139 anErrStruct.error = BRepCheck_SubshapeNotInShape;
141 case GEOM::GEOM_IMeasureOperations::BadOrientation:
142 anErrStruct.error = BRepCheck_BadOrientation;
144 case GEOM::GEOM_IMeasureOperations::BadOrientationOfSubshape:
145 anErrStruct.error = BRepCheck_BadOrientationOfSubshape;
147 case GEOM::GEOM_IMeasureOperations::InvalidToleranceValue:
148 anErrStruct.error = BRepCheck_InvalidToleranceValue;
150 case GEOM::GEOM_IMeasureOperations::CheckFail:
151 anErrStruct.error = BRepCheck_CheckFail;
158 int aLen = anIncrims.length();
160 for (; ii < aLen; ii++) {
161 anErrStruct.incriminated.push_back(anIncrims[ii]);
164 theErrorsTo.push_back(anErrStruct);
169 * This function converts shape errors from theErrorsFrom to theErrorsTo.
170 * Note that theErrorsTo is not cleared at first.
172 * \param theErrorsFrom errors to be converted.
173 * \param theErrorsTo result errors.
175 static void ConvertShapeError
176 (const std::list<GEOMImpl_IMeasureOperations::ShapeError> &theErrorsFrom,
177 GEOM::GEOM_IMeasureOperations::ShapeErrors_out &theErrorsTo)
179 const int aNbErr = theErrorsFrom.size();
180 GEOM::GEOM_IMeasureOperations::ShapeErrors_var anErrArray =
181 new GEOM::GEOM_IMeasureOperations::ShapeErrors;
183 anErrArray->length(aNbErr);
185 // fill the local CORBA array with values from lists
186 std::list<GEOMImpl_IMeasureOperations::ShapeError>::const_iterator
187 anIt = theErrorsFrom.begin();
190 for (; anIt != theErrorsFrom.end(); i++, anIt++) {
191 GEOM::GEOM_IMeasureOperations::ShapeError_var anErrStruct =
192 new GEOM::GEOM_IMeasureOperations::ShapeError;
194 switch (anIt->error) {
195 case BRepCheck_InvalidPointOnCurve:
196 anErrStruct->error = GEOM::GEOM_IMeasureOperations::InvalidPointOnCurve;
198 case BRepCheck_InvalidPointOnCurveOnSurface:
199 anErrStruct->error = GEOM::GEOM_IMeasureOperations::InvalidPointOnCurveOnSurface;
201 case BRepCheck_InvalidPointOnSurface:
202 anErrStruct->error = GEOM::GEOM_IMeasureOperations::InvalidPointOnSurface;
204 case BRepCheck_No3DCurve:
205 anErrStruct->error = GEOM::GEOM_IMeasureOperations::No3DCurve;
207 case BRepCheck_Multiple3DCurve:
208 anErrStruct->error = GEOM::GEOM_IMeasureOperations::Multiple3DCurve;
210 case BRepCheck_Invalid3DCurve:
211 anErrStruct->error = GEOM::GEOM_IMeasureOperations::Invalid3DCurve;
213 case BRepCheck_NoCurveOnSurface:
214 anErrStruct->error = GEOM::GEOM_IMeasureOperations::NoCurveOnSurface;
216 case BRepCheck_InvalidCurveOnSurface:
217 anErrStruct->error = GEOM::GEOM_IMeasureOperations::InvalidCurveOnSurface;
219 case BRepCheck_InvalidCurveOnClosedSurface:
220 anErrStruct->error = GEOM::GEOM_IMeasureOperations::InvalidCurveOnClosedSurface;
222 case BRepCheck_InvalidSameRangeFlag:
223 anErrStruct->error = GEOM::GEOM_IMeasureOperations::InvalidSameRangeFlag;
225 case BRepCheck_InvalidSameParameterFlag:
226 anErrStruct->error = GEOM::GEOM_IMeasureOperations::InvalidSameParameterFlag;
228 case BRepCheck_InvalidDegeneratedFlag:
229 anErrStruct->error = GEOM::GEOM_IMeasureOperations::InvalidDegeneratedFlag;
231 case BRepCheck_FreeEdge:
232 anErrStruct->error = GEOM::GEOM_IMeasureOperations::FreeEdge;
234 case BRepCheck_InvalidMultiConnexity:
235 anErrStruct->error = GEOM::GEOM_IMeasureOperations::InvalidMultiConnexity;
237 case BRepCheck_InvalidRange:
238 anErrStruct->error = GEOM::GEOM_IMeasureOperations::InvalidRange;
240 case BRepCheck_EmptyWire:
241 anErrStruct->error = GEOM::GEOM_IMeasureOperations::EmptyWire;
243 case BRepCheck_RedundantEdge:
244 anErrStruct->error = GEOM::GEOM_IMeasureOperations::RedundantEdge;
246 case BRepCheck_SelfIntersectingWire:
247 anErrStruct->error = GEOM::GEOM_IMeasureOperations::SelfIntersectingWire;
249 case BRepCheck_NoSurface:
250 anErrStruct->error = GEOM::GEOM_IMeasureOperations::NoSurface;
252 case BRepCheck_InvalidWire:
253 anErrStruct->error = GEOM::GEOM_IMeasureOperations::InvalidWire;
255 case BRepCheck_RedundantWire:
256 anErrStruct->error = GEOM::GEOM_IMeasureOperations::RedundantWire;
258 case BRepCheck_IntersectingWires:
259 anErrStruct->error = GEOM::GEOM_IMeasureOperations::IntersectingWires;
261 case BRepCheck_InvalidImbricationOfWires:
262 anErrStruct->error = GEOM::GEOM_IMeasureOperations::InvalidImbricationOfWires;
264 case BRepCheck_EmptyShell:
265 anErrStruct->error = GEOM::GEOM_IMeasureOperations::EmptyShell;
267 case BRepCheck_RedundantFace:
268 anErrStruct->error = GEOM::GEOM_IMeasureOperations::RedundantFace;
270 case BRepCheck_UnorientableShape:
271 anErrStruct->error = GEOM::GEOM_IMeasureOperations::UnorientableShape;
273 case BRepCheck_NotClosed:
274 anErrStruct->error = GEOM::GEOM_IMeasureOperations::NotClosed;
276 case BRepCheck_NotConnected:
277 anErrStruct->error = GEOM::GEOM_IMeasureOperations::NotConnected;
279 case BRepCheck_SubshapeNotInShape:
280 anErrStruct->error = GEOM::GEOM_IMeasureOperations::SubshapeNotInShape;
282 case BRepCheck_BadOrientation:
283 anErrStruct->error = GEOM::GEOM_IMeasureOperations::BadOrientation;
285 case BRepCheck_BadOrientationOfSubshape:
286 anErrStruct->error = GEOM::GEOM_IMeasureOperations::BadOrientationOfSubshape;
288 case BRepCheck_InvalidToleranceValue:
289 anErrStruct->error = GEOM::GEOM_IMeasureOperations::InvalidToleranceValue;
291 case BRepCheck_CheckFail:
292 anErrStruct->error = GEOM::GEOM_IMeasureOperations::CheckFail;
298 std::list<int> aIndList = anIt->incriminated;
299 GEOM::ListOfLong_var anIncrims = new GEOM::ListOfLong();
300 anIncrims->length(aIndList.size());
302 std::list<int>::iterator anIndIt = aIndList.begin();
305 for (; anIndIt != aIndList.end(); jj++, anIndIt++) {
306 anIncrims[jj] = *anIndIt;
309 anErrStruct->incriminated = anIncrims;
311 anErrArray[i] = anErrStruct;
314 // initialize out-parameter with local array
315 theErrorsTo = anErrArray._retn();
318 //=============================================================================
322 //=============================================================================
323 GEOM_IMeasureOperations_i::GEOM_IMeasureOperations_i (PortableServer::POA_ptr thePOA,
324 GEOM::GEOM_Gen_ptr theEngine,
325 ::GEOMImpl_IMeasureOperations* theImpl)
326 :GEOM_IOperations_i(thePOA, theEngine, theImpl)
328 MESSAGE("GEOM_IMeasureOperations_i::GEOM_IMeasureOperations_i");
331 //=============================================================================
335 //=============================================================================
336 GEOM_IMeasureOperations_i::~GEOM_IMeasureOperations_i()
338 MESSAGE("GEOM_IMeasureOperations_i::~GEOM_IMeasureOperations_i");
341 //=============================================================================
345 //=============================================================================
346 GEOM::GEOM_IKindOfShape::shape_kind GEOM_IMeasureOperations_i::KindOfShape
347 (GEOM::GEOM_Object_ptr theShape,
348 GEOM::ListOfLong_out theIntegers,
349 GEOM::ListOfDouble_out theDoubles)
351 GEOMImpl_IMeasureOperations::ShapeKind aKind = GEOMImpl_IMeasureOperations::SK_NO_SHAPE;
353 // allocate the CORBA arrays
354 GEOM::ListOfLong_var anIntegersArray = new GEOM::ListOfLong();
355 GEOM::ListOfDouble_var aDoublesArray = new GEOM::ListOfDouble();
357 //Get the reference shape
358 Handle(::GEOM_Object) aShape = GetObjectImpl(theShape);
360 if (!aShape.IsNull()) {
361 Handle(TColStd_HSequenceOfInteger) anIntegers = new TColStd_HSequenceOfInteger;
362 Handle(TColStd_HSequenceOfReal) aDoubles = new TColStd_HSequenceOfReal;
364 // Detect kind of shape and parameters
365 aKind = GetOperations()->KindOfShape(aShape, anIntegers, aDoubles);
367 int nbInts = anIntegers->Length();
368 int nbDbls = aDoubles->Length();
370 anIntegersArray->length(nbInts);
371 aDoublesArray->length(nbDbls);
373 for (int ii = 0; ii < nbInts; ii++) {
374 anIntegersArray[ii] = anIntegers->Value(ii + 1);
376 for (int id = 0; id < nbDbls; id++) {
377 aDoublesArray[id] = aDoubles->Value(id + 1);
381 // initialize out-parameters with local arrays
382 theIntegers = anIntegersArray._retn();
383 theDoubles = aDoublesArray._retn();
384 return (GEOM::GEOM_IKindOfShape::shape_kind)aKind;
387 //=============================================================================
391 //=============================================================================
392 void GEOM_IMeasureOperations_i::GetPosition
393 (GEOM::GEOM_Object_ptr theShape,
394 CORBA::Double& Ox, CORBA::Double& Oy, CORBA::Double& Oz,
395 CORBA::Double& Zx, CORBA::Double& Zy, CORBA::Double& Zz,
396 CORBA::Double& Xx, CORBA::Double& Xy, CORBA::Double& Xz)
398 //Set a not done flag
399 GetOperations()->SetNotDone();
401 //Set default values: global CS
402 Ox = Oy = Oz = Zx = Zy = Xy = Xz = 0.;
405 //Get the reference shape
406 Handle(::GEOM_Object) aShape = GetObjectImpl(theShape);
407 if (aShape.IsNull()) return;
409 // Get shape parameters
410 GetOperations()->GetPosition(aShape, Ox,Oy,Oz, Zx,Zy,Zz, Xx,Xy,Xz);
413 //=============================================================================
417 //=============================================================================
418 GEOM::GEOM_Object_ptr GEOM_IMeasureOperations_i::GetCentreOfMass
419 (GEOM::GEOM_Object_ptr theShape)
421 GEOM::GEOM_Object_var aGEOMObject;
423 //Set a not done flag
424 GetOperations()->SetNotDone();
426 //Get the reference shape
427 Handle(::GEOM_Object) aShape = GetObjectImpl(theShape);
428 if (aShape.IsNull()) return aGEOMObject._retn();
430 // Make Point - centre of mass of theShape
431 Handle(::GEOM_Object) anObject = GetOperations()->GetCentreOfMass(aShape);
432 if (!GetOperations()->IsDone() || anObject.IsNull())
433 return aGEOMObject._retn();
435 return GetObject(anObject);
438 //=============================================================================
442 //=============================================================================
443 GEOM::GEOM_Object_ptr
444 GEOM_IMeasureOperations_i::GetVertexByIndex( GEOM::GEOM_Object_ptr theShape,
445 CORBA::Long theIndex,
446 CORBA::Boolean theUseOri )
448 GEOM::GEOM_Object_var aGEOMObject;
450 //Set a not done flag
451 GetOperations()->SetNotDone();
453 //Get the reference shape
454 Handle(::GEOM_Object) aShape = GetObjectImpl(theShape);
455 if ( aShape.IsNull() ) return aGEOMObject._retn();
457 // Get vertex by index
458 Handle(::GEOM_Object) anObject = GetOperations()->GetVertexByIndex(aShape, theIndex, theUseOri);
459 if (!GetOperations()->IsDone() || anObject.IsNull())
460 return aGEOMObject._retn();
462 return GetObject(anObject);
465 //=============================================================================
469 //=============================================================================
470 GEOM::GEOM_Object_ptr GEOM_IMeasureOperations_i::GetNormal
471 (GEOM::GEOM_Object_ptr theFace,
472 GEOM::GEOM_Object_ptr theOptionalPoint)
474 GEOM::GEOM_Object_var aGEOMObject;
476 //Set a not done flag
477 GetOperations()->SetNotDone();
479 //Get the reference shape
480 Handle(::GEOM_Object) aFace = GetObjectImpl(theFace);
481 if (aFace.IsNull()) return aGEOMObject._retn();
483 // Get the OptionalPoint (can be not defined)
484 Handle(::GEOM_Object) anOptionalPoint = GetObjectImpl(theOptionalPoint);
486 // Make Vector - normal to theFace (in point theOptionalPoint if the face is not planar)
487 Handle(::GEOM_Object) anObject = GetOperations()->GetNormal(aFace, anOptionalPoint);
488 if (!GetOperations()->IsDone() || anObject.IsNull())
489 return aGEOMObject._retn();
491 return GetObject(anObject);
494 //=============================================================================
498 //=============================================================================
499 void GEOM_IMeasureOperations_i::GetBasicProperties (GEOM::GEOM_Object_ptr theShape,
500 CORBA::Double theTolerance,
501 CORBA::Double& theLength,
502 CORBA::Double& theSurfArea,
503 CORBA::Double& theVolume)
505 //Set a not done flag
506 GetOperations()->SetNotDone();
508 //Get the reference shape
509 Handle(::GEOM_Object) aShape = GetObjectImpl(theShape);
510 if (aShape.IsNull()) return;
512 // Get shape parameters
513 GetOperations()->GetBasicProperties(aShape, theTolerance, theLength,
514 theSurfArea, theVolume);
517 //=============================================================================
521 //=============================================================================
522 void GEOM_IMeasureOperations_i::GetInertia
523 (GEOM::GEOM_Object_ptr theShape,
524 CORBA::Double& I11, CORBA::Double& I12, CORBA::Double& I13,
525 CORBA::Double& I21, CORBA::Double& I22, CORBA::Double& I23,
526 CORBA::Double& I31, CORBA::Double& I32, CORBA::Double& I33,
527 CORBA::Double& Ix , CORBA::Double& Iy , CORBA::Double& Iz)
529 //Set a not done flag
530 GetOperations()->SetNotDone();
532 //Get the reference shape
533 Handle(::GEOM_Object) aShape = GetObjectImpl(theShape);
534 if (aShape.IsNull()) return;
536 // Get shape parameters
537 GetOperations()->GetInertia(aShape,
544 //=============================================================================
548 //=============================================================================
549 void GEOM_IMeasureOperations_i::GetBoundingBox (GEOM::GEOM_Object_ptr theShape,
550 CORBA::Boolean precise,
551 CORBA::Double& Xmin, CORBA::Double& Xmax,
552 CORBA::Double& Ymin, CORBA::Double& Ymax,
553 CORBA::Double& Zmin, CORBA::Double& Zmax)
555 //Set a not done flag
556 GetOperations()->SetNotDone();
558 //Get the reference shape
559 Handle(::GEOM_Object) aShape = GetObjectImpl(theShape);
560 if (aShape.IsNull()) return;
562 // Get shape parameters
563 GetOperations()->GetBoundingBox
564 (aShape, precise, Xmin, Xmax, Ymin, Ymax, Zmin, Zmax);
567 //=============================================================================
571 //=============================================================================
572 GEOM::GEOM_Object_ptr GEOM_IMeasureOperations_i::MakeBoundingBox
573 (GEOM::GEOM_Object_ptr theShape,
574 CORBA::Boolean precise)
576 GEOM::GEOM_Object_var aGEOMObject;
578 //Set a not done flag
579 GetOperations()->SetNotDone();
581 //Get the reference shape
582 Handle(::GEOM_Object) aShape = GetObjectImpl(theShape);
583 if (aShape.IsNull()) return aGEOMObject._retn();
585 // Make Box - bounding box of theShape
586 Handle(::GEOM_Object) anObject =
587 GetOperations()->GetBoundingBox(aShape, precise);
588 if (!GetOperations()->IsDone() || anObject.IsNull())
589 return aGEOMObject._retn();
591 return GetObject(anObject);
594 //=============================================================================
598 //=============================================================================
599 void GEOM_IMeasureOperations_i::GetTolerance
600 (GEOM::GEOM_Object_ptr theShape,
601 CORBA::Double& FaceMin, CORBA::Double& FaceMax,
602 CORBA::Double& EdgeMin, CORBA::Double& EdgeMax,
603 CORBA::Double& VertMin, CORBA::Double& VertMax)
605 //Set a not done flag
606 GetOperations()->SetNotDone();
608 //Get the reference shape
609 Handle(::GEOM_Object) aShape = GetObjectImpl(theShape);
610 if (aShape.IsNull()) return;
612 // Get shape parameters
613 GetOperations()->GetTolerance(aShape,
619 //=============================================================================
623 //=============================================================================
624 CORBA::Boolean GEOM_IMeasureOperations_i::CheckShape
625 (GEOM::GEOM_Object_ptr theShape,
626 GEOM::GEOM_IMeasureOperations::ShapeErrors_out theErrors)
628 //Set a not done flag
629 GetOperations()->SetNotDone();
631 if (CORBA::is_nil(theShape))
636 //Get the reference shape
637 Handle(::GEOM_Object) aShape = GetObjectImpl(theShape);
644 std::list<GEOMImpl_IMeasureOperations::ShapeError> anErrList;
645 bool isOk = GetOperations()->CheckShape(aShape, false, anErrList);
647 ConvertShapeError(anErrList, theErrors);
652 CORBA::Boolean GEOM_IMeasureOperations_i::CheckShapeWithGeometry
653 (GEOM::GEOM_Object_ptr theShape,
654 GEOM::GEOM_IMeasureOperations::ShapeErrors_out theErrors)
656 //Set a not done flag
657 GetOperations()->SetNotDone();
659 if (CORBA::is_nil(theShape))
664 //Get the reference shape
665 Handle(::GEOM_Object) aShape = GetObjectImpl(theShape);
672 std::list<GEOMImpl_IMeasureOperations::ShapeError> anErrList;
673 bool isOk = GetOperations()->CheckShape(aShape, true, anErrList);
675 ConvertShapeError(anErrList, theErrors);
680 //=============================================================================
684 //=============================================================================
685 char* GEOM_IMeasureOperations_i::PrintShapeErrors
686 ( GEOM::GEOM_Object_ptr theShape,
687 const GEOM::GEOM_IMeasureOperations::ShapeErrors &theErrors)
689 //Get the reference shape
690 Handle(::GEOM_Object) aShape = GetObjectImpl(theShape);
692 if (aShape.IsNull()) {
696 // Convert the errors sequence
697 std::list<GEOMImpl_IMeasureOperations::ShapeError> anErrList;
699 ConvertShapeError(theErrors, anErrList);
701 TCollection_AsciiString aDescr =
702 GetOperations()->PrintShapeErrors(aShape, anErrList);
704 return CORBA::string_dup(aDescr.ToCString());
707 //=============================================================================
709 * CheckSelfIntersections
711 //=============================================================================
712 CORBA::Boolean GEOM_IMeasureOperations_i::CheckSelfIntersections (GEOM::GEOM_Object_ptr theShape,
713 CORBA::Long theCheckLevel,
714 GEOM::ListOfLong_out theIntersections)
716 // Set a not done flag
717 GetOperations()->SetNotDone();
721 // Allocate the CORBA arrays
722 GEOM::ListOfLong_var anIntegersArray = new GEOM::ListOfLong();
724 // Get the reference shape
725 Handle(::GEOM_Object) aShape = GetObjectImpl(theShape);
727 if (!aShape.IsNull()) {
728 GEOMImpl_IMeasureOperations::SICheckLevel aCheckLevel;
730 switch(theCheckLevel) {
732 aCheckLevel = GEOMImpl_IMeasureOperations::SI_V_V;
735 aCheckLevel = GEOMImpl_IMeasureOperations::SI_V_E;
738 aCheckLevel = GEOMImpl_IMeasureOperations::SI_E_E;
741 aCheckLevel = GEOMImpl_IMeasureOperations::SI_V_F;
744 aCheckLevel = GEOMImpl_IMeasureOperations::SI_E_F;
748 aCheckLevel = GEOMImpl_IMeasureOperations::SI_ALL;
752 Handle(TColStd_HSequenceOfInteger) anIntegers = new TColStd_HSequenceOfInteger;
754 // Detect self-intersections
755 isGood = GetOperations()->CheckSelfIntersections
756 (aShape, aCheckLevel, anIntegers);
758 int nbInts = anIntegers->Length();
760 anIntegersArray->length(nbInts);
762 for (int ii = 0; ii < nbInts; ii++) {
763 anIntegersArray[ii] = anIntegers->Value(ii + 1);
767 // Initialize out-parameters with local arrays
768 theIntersections = anIntegersArray._retn();
772 //=============================================================================
774 * CheckSelfIntersectionsFast
776 //=============================================================================
777 CORBA::Boolean GEOM_IMeasureOperations_i::CheckSelfIntersectionsFast
778 (GEOM::GEOM_Object_ptr theShape,
779 CORBA::Float theDeflection,
780 CORBA::Double theTolerance,
781 GEOM::ListOfLong_out theIntersections)
783 // Set a not done flag
784 GetOperations()->SetNotDone();
788 // Allocate the CORBA arrays
789 GEOM::ListOfLong_var anIntegersArray = new GEOM::ListOfLong();
791 // Get the reference shape
792 Handle(::GEOM_Object) aShape = GetObjectImpl(theShape);
794 if (!aShape.IsNull()) {
795 Handle(TColStd_HSequenceOfInteger) anIntegers = new TColStd_HSequenceOfInteger;
797 // Detect self-intersections
798 isGood = GetOperations()->CheckSelfIntersectionsFast
799 (aShape, theDeflection, theTolerance, anIntegers);
801 int nbInts = anIntegers->Length();
803 anIntegersArray->length(nbInts);
805 for (int ii = 0; ii < nbInts; ii++) {
806 anIntegersArray[ii] = anIntegers->Value(ii + 1);
810 // Initialize out-parameters with local arrays
811 theIntersections = anIntegersArray._retn();
815 //=============================================================================
819 //=============================================================================
820 CORBA::Boolean GEOM_IMeasureOperations_i::CheckBOPArguments
821 (GEOM::GEOM_Object_ptr theShape)
823 // Set a not done flag
824 GetOperations()->SetNotDone();
826 // Get the reference shape
827 Handle(::GEOM_Object) aShape = GetObjectImpl(theShape);
830 if (!aShape.IsNull()) {
831 // Check BOP arguments
832 isGood = GetOperations()->CheckBOPArguments(aShape);
838 //=============================================================================
842 //=============================================================================
843 CORBA::Boolean GEOM_IMeasureOperations_i::FastIntersect (GEOM::GEOM_Object_ptr theShape1,
844 GEOM::GEOM_Object_ptr theShape2,
845 CORBA::Double theTolerance,
846 CORBA::Float theDeflection,
847 GEOM::ListOfLong_out theIntersections1,
848 GEOM::ListOfLong_out theIntersections2)
850 // Set a not done flag
851 GetOperations()->SetNotDone();
855 // Allocate the CORBA arrays
856 GEOM::ListOfLong_var anIntegersArray1 = new GEOM::ListOfLong();
857 GEOM::ListOfLong_var anIntegersArray2 = new GEOM::ListOfLong();
859 // Get the reference shape
860 Handle(::GEOM_Object) aShape1 = GetObjectImpl(theShape1);
861 Handle(::GEOM_Object) aShape2 = GetObjectImpl(theShape2);
863 if (!aShape1.IsNull() && !aShape2.IsNull()) {
864 Handle(TColStd_HSequenceOfInteger) anIntegers1 = new TColStd_HSequenceOfInteger;
865 Handle(TColStd_HSequenceOfInteger) anIntegers2 = new TColStd_HSequenceOfInteger;
867 // Detect intersections
868 isGood = GetOperations()->FastIntersect
869 (aShape1, aShape2, theTolerance, theDeflection, anIntegers1, anIntegers2);
871 int nbInts1 = anIntegers1->Length();
872 int nbInts2 = anIntegers2->Length();
874 anIntegersArray1->length(nbInts1);
875 anIntegersArray2->length(nbInts2);
877 for (int ii = 0; ii < nbInts1; ii++) {
878 anIntegersArray1[ii] = anIntegers1->Value(ii + 1);
880 for (int ii = 0; ii < nbInts2; ii++) {
881 anIntegersArray2[ii] = anIntegers2->Value(ii + 1);
885 // Initialize out-parameters with local arrays
886 theIntersections1 = anIntegersArray1._retn();
887 theIntersections2 = anIntegersArray2._retn();
891 //=============================================================================
895 //=============================================================================
896 char* GEOM_IMeasureOperations_i::IsGoodForSolid (GEOM::GEOM_Object_ptr theShape)
898 //Set a not done flag
899 GetOperations()->SetNotDone();
901 //Get the reference shape
902 Handle(::GEOM_Object) aShape = GetObjectImpl(theShape);
903 if (aShape.IsNull()) return CORBA::string_dup("WRN_NULL_OBJECT_OR_SHAPE");
905 // Get shape parameters
906 TCollection_AsciiString aDescription = GetOperations()->IsGoodForSolid(aShape);
907 return CORBA::string_dup(aDescription.ToCString());
910 //=============================================================================
914 //=============================================================================
915 char* GEOM_IMeasureOperations_i::WhatIs (GEOM::GEOM_Object_ptr theShape)
917 //Set a not done flag
918 GetOperations()->SetNotDone();
920 //Get the reference shape
921 Handle(::GEOM_Object) aShape = GetObjectImpl(theShape);
922 if (aShape.IsNull()) return NULL;
924 // Get shape parameters
925 TCollection_AsciiString aDescription = GetOperations()->WhatIs(aShape);
926 return CORBA::string_dup(aDescription.ToCString());
929 //=============================================================================
933 //=============================================================================
934 GEOM::ListOfBool* GEOM_IMeasureOperations_i::AreCoordsInside (GEOM::GEOM_Object_ptr theShape,
935 const GEOM::ListOfDouble& theCoords,
936 CORBA::Double tolerance)
938 //Set a not done flag
939 GetOperations()->SetNotDone();
941 int nb_points = theCoords.length()/3;
943 GEOM::ListOfBool_var aResults = new GEOM::ListOfBool;
944 aResults->length(nb_points);
946 Handle(::GEOM_Object) aShape = GetObjectImpl(theShape);
948 std::vector<double> tmp(3*nb_points);
949 for (int i = 0; i < 3*nb_points; i++)
950 tmp[i] = theCoords[i];
951 std::vector<bool> res = GetOperations()->AreCoordsInside(aShape, tmp, tolerance);
952 for (int i = 0, resSize = res.size(); i < nb_points; i++)
953 aResults[i] = i < resSize ? res[i] : false;
954 return aResults._retn();
957 //=============================================================================
961 //=============================================================================
962 CORBA::Double GEOM_IMeasureOperations_i::GetMinDistance
963 (GEOM::GEOM_Object_ptr theShape1, GEOM::GEOM_Object_ptr theShape2,
964 CORBA::Double& X1, CORBA::Double& Y1, CORBA::Double& Z1,
965 CORBA::Double& X2, CORBA::Double& Y2, CORBA::Double& Z2)
967 //Set a not done flag
968 GetOperations()->SetNotDone();
970 //Get the reference shape
971 Handle(::GEOM_Object) aShape1 = GetObjectImpl(theShape1);
972 Handle(::GEOM_Object) aShape2 = GetObjectImpl(theShape2);
973 if (aShape1.IsNull() || aShape2.IsNull()) return -1.0;
975 // Get shape parameters
976 return GetOperations()->GetMinDistance(aShape1, aShape2, X1, Y1, Z1, X2, Y2, Z2);
979 //=============================================================================
983 //=============================================================================
984 CORBA::Long GEOM_IMeasureOperations_i::ClosestPoints
985 (GEOM::GEOM_Object_ptr theShape1, GEOM::GEOM_Object_ptr theShape2,
986 GEOM::ListOfDouble_out theCoords)
988 //Set a not done flag
989 GetOperations()->SetNotDone();
991 // allocate the CORBA array
993 GEOM::ListOfDouble_var aDoublesArray = new GEOM::ListOfDouble();
995 //Get the reference shape
996 Handle(::GEOM_Object) aShape1 = GetObjectImpl(theShape1);
997 Handle(::GEOM_Object) aShape2 = GetObjectImpl(theShape2);
999 if (!aShape1.IsNull() && !aShape2.IsNull()) {
1000 Handle(TColStd_HSequenceOfReal) aDoubles = new TColStd_HSequenceOfReal;
1001 // Get shape parameters
1002 nbSols = GetOperations()->ClosestPoints(aShape1, aShape2, aDoubles);
1003 int nbDbls = aDoubles->Length();
1004 aDoublesArray->length(nbDbls);
1005 for (int id = 0; id < nbDbls; id++) {
1006 aDoublesArray[id] = aDoubles->Value(id + 1);
1010 theCoords = aDoublesArray._retn();
1014 //=============================================================================
1018 //=============================================================================
1019 void GEOM_IMeasureOperations_i::PointCoordinates (GEOM::GEOM_Object_ptr theShape,
1020 CORBA::Double& X, CORBA::Double& Y, CORBA::Double& Z)
1023 //Set a not done flag
1024 GetOperations()->SetNotDone();
1026 //Get the reference shape
1027 Handle(::GEOM_Object) aShape = GetObjectImpl(theShape);
1028 if (aShape.IsNull())
1031 // Get shape parameters
1032 GetOperations()->PointCoordinates( aShape, X, Y, Z );
1035 //=============================================================================
1039 //=============================================================================
1040 CORBA::Double GEOM_IMeasureOperations_i::GetAngle (GEOM::GEOM_Object_ptr theShape1,
1041 GEOM::GEOM_Object_ptr theShape2)
1043 //Set a not done flag
1044 GetOperations()->SetNotDone();
1046 //Get the reference shapes
1047 Handle(::GEOM_Object) aShape1 = GetObjectImpl(theShape1);
1048 Handle(::GEOM_Object) aShape2 = GetObjectImpl(theShape2);
1049 if (aShape1.IsNull() || aShape2.IsNull()) return -1.0;
1052 return GetOperations()->GetAngle(aShape1, aShape2);
1055 //=============================================================================
1059 //=============================================================================
1060 CORBA::Double GEOM_IMeasureOperations_i::GetAngleBtwVectors (GEOM::GEOM_Object_ptr theShape1,
1061 GEOM::GEOM_Object_ptr theShape2)
1063 //Set a not done flag
1064 GetOperations()->SetNotDone();
1066 //Get the reference shapes
1067 Handle(::GEOM_Object) aShape1 = GetObjectImpl(theShape1);
1068 Handle(::GEOM_Object) aShape2 = GetObjectImpl(theShape2);
1069 if (aShape1.IsNull() || aShape2.IsNull()) return -1.0;
1072 return GetOperations()->GetAngleBtwVectors(aShape1, aShape2);
1075 //=============================================================================
1079 //=============================================================================
1080 GEOM::ListOfGO* GEOM_IMeasureOperations_i::PatchFace(GEOM::GEOM_Object_ptr theShape)
1082 GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
1084 //Get the reference shape
1085 Handle(::GEOM_Object) aShapeRef = GetObjectImpl(theShape);
1086 if (aShapeRef.IsNull()) return aSeq._retn();
1088 // Perform patch face operation
1089 Handle(TColStd_HSequenceOfTransient) aHSeq =
1090 GetOperations()->PatchFace(aShapeRef);
1091 if (!GetOperations()->IsDone() || aHSeq.IsNull())
1092 return aSeq._retn();
1094 Standard_Integer aLength = aHSeq->Length();
1095 aSeq->length(aLength);
1096 for (Standard_Integer i = 1; i <= aLength; i++)
1097 aSeq[i - 1] = GetObject(Handle(::GEOM_Object)::DownCast(aHSeq->Value(i)));
1099 return aSeq._retn();
1102 //=============================================================================
1104 * CurveCurvatureByParam
1106 //=============================================================================
1107 CORBA::Double GEOM_IMeasureOperations_i::CurveCurvatureByParam
1108 (GEOM::GEOM_Object_ptr theCurve, CORBA::Double theParam)
1110 //Set a not done flag
1111 GetOperations()->SetNotDone();
1113 //Get the reference shape
1114 Handle(::GEOM_Object) aShape = GetObjectImpl(theCurve);
1115 if(aShape.IsNull()) return -1.0;
1117 return GetOperations()->CurveCurvatureByParam(aShape,theParam);
1120 //=============================================================================
1122 * CurveCurvatureByPoint
1124 //=============================================================================
1125 CORBA::Double GEOM_IMeasureOperations_i::CurveCurvatureByPoint
1126 (GEOM::GEOM_Object_ptr theCurve, GEOM::GEOM_Object_ptr thePoint)
1128 //Set a not done flag
1129 GetOperations()->SetNotDone();
1131 //Get the reference shape
1132 Handle(::GEOM_Object) aShape = GetObjectImpl(theCurve);
1133 Handle(::GEOM_Object) aPoint = GetObjectImpl(thePoint);
1134 if( aShape.IsNull() || aPoint.IsNull() ) return -1.0;
1136 return GetOperations()->CurveCurvatureByPoint(aShape,aPoint);
1140 //=============================================================================
1142 * MaxSurfaceCurvatureByParam
1144 //=============================================================================
1145 CORBA::Double GEOM_IMeasureOperations_i::MaxSurfaceCurvatureByParam
1146 (GEOM::GEOM_Object_ptr theSurf,
1147 CORBA::Double theUParam,
1148 CORBA::Double theVParam)
1150 //Set a not done flag
1151 GetOperations()->SetNotDone();
1153 //Get the reference shape
1154 Handle(::GEOM_Object) aShape = GetObjectImpl(theSurf);
1155 if(aShape.IsNull()) return -1.0;
1157 return GetOperations()->MaxSurfaceCurvatureByParam(aShape,theUParam,theVParam);
1160 //=============================================================================
1162 * MaxSurfaceCurvatureByPoint
1164 //=============================================================================
1165 CORBA::Double GEOM_IMeasureOperations_i::MaxSurfaceCurvatureByPoint
1166 (GEOM::GEOM_Object_ptr theSurf, GEOM::GEOM_Object_ptr thePoint)
1168 //Set a not done flag
1169 GetOperations()->SetNotDone();
1171 //Get the reference shape
1172 Handle(::GEOM_Object) aShape = GetObjectImpl(theSurf);
1173 Handle(::GEOM_Object) aPoint = GetObjectImpl(thePoint);
1174 if( aShape.IsNull() || aPoint.IsNull() ) return -1.0;
1176 return GetOperations()->MaxSurfaceCurvatureByPoint(aShape,aPoint);
1179 //=============================================================================
1181 * MinSurfaceCurvatureByParam
1183 //=============================================================================
1184 CORBA::Double GEOM_IMeasureOperations_i::MinSurfaceCurvatureByParam
1185 (GEOM::GEOM_Object_ptr theSurf,
1186 CORBA::Double theUParam,
1187 CORBA::Double theVParam)
1189 //Set a not done flag
1190 GetOperations()->SetNotDone();
1192 //Get the reference shape
1193 Handle(::GEOM_Object) aShape = GetObjectImpl(theSurf);
1194 if (aShape.IsNull()) return -1.0;
1196 return GetOperations()->MinSurfaceCurvatureByParam(aShape,theUParam,theVParam);
1199 //=============================================================================
1201 * MinSurfaceCurvatureByPoint
1203 //=============================================================================
1204 CORBA::Double GEOM_IMeasureOperations_i::MinSurfaceCurvatureByPoint
1205 (GEOM::GEOM_Object_ptr theSurf, GEOM::GEOM_Object_ptr thePoint)
1207 //Set a not done flag
1208 GetOperations()->SetNotDone();
1210 //Get the reference shape
1211 Handle(::GEOM_Object) aShape = GetObjectImpl(theSurf);
1212 Handle(::GEOM_Object) aPoint = GetObjectImpl(thePoint);
1213 if (aShape.IsNull() || aPoint.IsNull()) return -1.0;
1215 return GetOperations()->MinSurfaceCurvatureByPoint(aShape,aPoint);
1218 //=============================================================================
1220 * SurfaceCurvatureByPointAndDirection
1222 //=============================================================================
1223 GEOM::GEOM_Object_ptr GEOM_IMeasureOperations_i::SurfaceCurvatureByPointAndDirection
1224 (GEOM::GEOM_Object_ptr theSurf,
1225 GEOM::GEOM_Object_ptr thePoint,
1226 GEOM::GEOM_Object_ptr theDirection)
1228 GEOM::GEOM_Object_var aGEOMObject;
1230 //Set a not done flag
1231 GetOperations()->SetNotDone();
1233 //Get the reference shape
1234 Handle(::GEOM_Object) aShape = GetObjectImpl(theSurf);
1235 Handle(::GEOM_Object) aPoint = GetObjectImpl(thePoint);
1236 Handle(::GEOM_Object) aDirection = GetObjectImpl(theDirection);
1237 if (aShape.IsNull() || aPoint.IsNull() || aDirection.IsNull()) return aGEOMObject._retn();
1239 Handle(::GEOM_Object) anObject =
1240 GetOperations()->SurfaceCurvatureByPointAndDirection(aShape,aPoint,aDirection);
1241 if (!GetOperations()->IsDone() || anObject.IsNull())
1242 return aGEOMObject._retn();
1244 return GetObject(anObject);
1247 //=============================================================================
1250 * Find all self-intersected 2D curves.
1251 * \param theShape Shape for check.
1253 //=============================================================================
1254 GEOM::GEOM_IMeasureOperations::SequenceOfPairOfShape* GEOM_IMeasureOperations_i::SelfIntersected2D(
1255 const GEOM::GEOM_IMeasureOperations::CheckResults& theResuts)
1257 GEOM::GEOM_IMeasureOperations::SequenceOfPairOfShape_var aSeq =
1258 new GEOM::GEOM_IMeasureOperations::SequenceOfPairOfShape;
1260 // Perform patch face operation
1261 std::list<GEOMImpl_IMeasureOperations::FailedChecks> aResults;
1262 ConvertToList(theResuts, aResults);
1264 std::list<GEOMImpl_IMeasureOperations::CoupleOfObjects> aSelfInters = GetOperations()->SelfIntersected2D(aResults);
1265 if (!GetOperations()->IsDone() || aSelfInters.empty())
1266 return aSeq._retn();
1268 Standard_Integer aLength = aSelfInters.size();
1269 aSeq->length(aLength);
1270 std::list<GEOMImpl_IMeasureOperations::CoupleOfObjects>::iterator anIter(aSelfInters.begin());
1271 for (Standard_Integer i = 0; i < aLength; i++, ++anIter)
1273 aSeq[i].first = GetObject(Handle(::GEOM_Object)::DownCast((*anIter).first));
1274 aSeq[i].second = GetObject(Handle(::GEOM_Object)::DownCast((*anIter).second));
1277 return aSeq._retn();
1280 //=============================================================================
1282 * InterferingSubshapes
1283 * Find pairs of interfering sub-shapes, by default all pairs of interfering shapes are returned.
1284 * \param theShape Shape for check.
1285 * \param theShapeType1 Type of shape.
1286 * \param theShapeType2 Type of shape.
1288 //=============================================================================
1289 GEOM::GEOM_IMeasureOperations::SequenceOfPairOfShape* GEOM_IMeasureOperations_i::InterferingSubshapes(
1290 const GEOM::GEOM_IMeasureOperations::CheckResults& theResuts,
1291 const CORBA::Long theShapeType1,
1292 const CORBA::Long theShapeType2)
1294 GEOM::GEOM_IMeasureOperations::SequenceOfPairOfShape_var aSeq =
1295 new GEOM::GEOM_IMeasureOperations::SequenceOfPairOfShape;
1297 // Perform patch face operation
1298 std::list<GEOMImpl_IMeasureOperations::FailedChecks> aResults;
1299 ConvertToList(theResuts, aResults);
1301 std::list<GEOMImpl_IMeasureOperations::CoupleOfObjects> aSelfInterf =
1302 GetOperations()->InterferingSubshapes(aResults, theShapeType1, theShapeType2);
1303 if (!GetOperations()->IsDone() || aSelfInterf.empty())
1304 return aSeq._retn();
1306 Standard_Integer aLength = aSelfInterf.size();
1307 aSeq->length(aLength);
1308 std::list<GEOMImpl_IMeasureOperations::CoupleOfObjects>::iterator anIter(aSelfInterf.begin());
1309 for (Standard_Integer i = 0; i < aLength; i++, ++anIter)
1311 aSeq[i].first = GetObject(Handle(::GEOM_Object)::DownCast((*anIter).first));
1312 aSeq[i].second = GetObject(Handle(::GEOM_Object)::DownCast((*anIter).second));
1315 return aSeq._retn();
1318 //=============================================================================
1321 * Find edges, which are fully covered by tolerances of vertices.
1322 * \param theShape Shape for check.
1324 //=============================================================================
1325 GEOM::ListOfGO* GEOM_IMeasureOperations_i::SmallEdges(const GEOM::GEOM_IMeasureOperations::CheckResults& theResuts)
1327 GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
1329 std::list<GEOMImpl_IMeasureOperations::FailedChecks> aResults;
1330 ConvertToList(theResuts, aResults);
1332 //Get the reference shape
1333 Handle(TColStd_HSequenceOfTransient) aSmallEdges = GetOperations()->SmallEdges(aResults);
1334 if (!GetOperations()->IsDone() || aSmallEdges.IsNull())
1335 return aSeq._retn();
1337 Standard_Integer aLength = aSmallEdges->Length();
1338 aSeq->length(aLength);
1339 for (Standard_Integer i = 1; i <= aLength; i++)
1340 aSeq[i - 1] = GetObject(Handle(::GEOM_Object)::DownCast(aSmallEdges->Value(i)));
1342 return aSeq._retn();
1345 //=============================================================================
1348 * find remote objects (sub-shape on a shape).
1349 * \param theShape Shape for check.
1350 * \param theShapeType Type of shape.
1351 * \param theSubShapeType Type of sub-shape.
1352 * \param theTolerance tolerance.
1354 //=============================================================================
1355 GEOM::GEOM_IMeasureOperations::SequenceOfPairOfShape* GEOM_IMeasureOperations_i::DistantShapes(
1356 const GEOM::GEOM_IMeasureOperations::CheckResults& theResuts,
1357 const CORBA::Long theShapeType,
1358 const CORBA::Long theSubShapeType,
1359 const CORBA::Double theTolerance)
1361 GEOM::GEOM_IMeasureOperations::SequenceOfPairOfShape_var aSeq =
1362 new GEOM::GEOM_IMeasureOperations::SequenceOfPairOfShape;
1364 std::list<GEOMImpl_IMeasureOperations::FailedChecks> aResults;
1365 ConvertToList(theResuts, aResults);
1367 // Perform patch face operation
1368 std::list<GEOMImpl_IMeasureOperations::CoupleOfObjects> aDistantS =
1369 GetOperations()->DistantShapes(aResults, theShapeType, theSubShapeType, theTolerance);
1370 if (!GetOperations()->IsDone() || aDistantS.empty())
1371 return aSeq._retn();
1373 Standard_Integer aLength = aDistantS.size();
1374 aSeq->length(aLength);
1375 std::list<GEOMImpl_IMeasureOperations::CoupleOfObjects>::iterator anIter(aDistantS.begin());
1376 for (Standard_Integer i = 0; i < aLength; i++, ++anIter)
1378 aSeq[i].first = GetObject(Handle(::GEOM_Object)::DownCast((*anIter).first));
1379 aSeq[i].second = GetObject(Handle(::GEOM_Object)::DownCast((*anIter).second));
1382 return aSeq._retn();
1385 //=============================================================================
1387 * CheckConformityShape
1388 * Perform all required checks
1390 //=============================================================================
1391 GEOM::GEOM_IMeasureOperations::CheckResults* GEOM_IMeasureOperations_i::CheckConformityShape(
1392 GEOM::GEOM_Object_ptr theShape)
1394 GEOM::GEOM_IMeasureOperations::CheckResults_var aRes = new GEOM::GEOM_IMeasureOperations::CheckResults;
1396 //Get the reference shape
1397 Handle(::GEOM_Object) aShapeRef = GetObjectImpl(theShape);
1398 if (aShapeRef.IsNull()) return nullptr;
1400 std::list<GEOMImpl_IMeasureOperations::FailedChecks> aChecks;
1401 GetOperations()->CheckConformityShape(aShapeRef, aChecks);
1403 Standard_Integer aLength = aChecks.size();
1404 aRes->length(aLength);
1405 std::list<GEOMImpl_IMeasureOperations::FailedChecks>::const_iterator anIntIt = aChecks.cbegin();
1406 for (Standard_Integer i = 0; i < aLength; i++, ++anIntIt)
1408 aRes[i].type = (*anIntIt).TypeOfCheck;
1409 aRes[i].failedShapes.first = GetObject(Handle(::GEOM_Object)::DownCast((*anIntIt).FailedShapes.first));
1410 aRes[i].failedShapes.second = GetObject(Handle(::GEOM_Object)::DownCast((*anIntIt).FailedShapes.second));
1413 return aRes._retn();
1416 //=============================================================================
1419 * Compute possible tolerance for the shape, minimize tolerance of shape as well
1420 * as tolerance of sub-shapes as much as possible
1421 * \param theShape Shape for check.
1423 //=============================================================================
1424 CORBA::Double GEOM_IMeasureOperations_i::UpdateTolerance(GEOM::GEOM_Object_ptr theShape)
1426 //Get the reference shape
1427 Handle(::GEOM_Object) aShapeRef = GetObjectImpl(theShape);
1428 if (aShapeRef.IsNull())
1431 return GetOperations()->UpdateTolerance(aShapeRef);
1434 void GEOM_IMeasureOperations_i::ConvertToList(const GEOM::GEOM_IMeasureOperations::CheckResults& theResuts,
1435 std::list<GEOMImpl_IMeasureOperations::FailedChecks>& theListOfResults)
1437 for (Standard_Integer i = 0; i < theResuts.length(); ++i)
1439 GEOMImpl_IMeasureOperations::FailedChecks aCheck;
1440 aCheck.TypeOfCheck = theResuts[i].type;
1441 aCheck.FailedShapes.first = GetObjectImpl(theResuts[i].failedShapes.first);
1442 aCheck.FailedShapes.second = GetObjectImpl(theResuts[i].failedShapes.second);
1443 theListOfResults.push_back(aCheck);
1447 //=============================================================================
1449 * ShapeProximityCalculator
1451 //=============================================================================
1452 GEOM::GEOM_Object_ptr GEOM_IMeasureOperations_i::ShapeProximityCalculator(GEOM::GEOM_Object_ptr theShape1,
1453 GEOM::GEOM_Object_ptr theShape2)
1455 GEOM::GEOM_Object_var anEmptyCalc;
1457 //Set a not done flag
1458 GetOperations()->SetNotDone();
1460 //Get the reference shape
1461 Handle(::GEOM_Object) aShape1 = GetObjectImpl(theShape1);
1462 Handle(::GEOM_Object) aShape2 = GetObjectImpl(theShape2);
1463 if (aShape1.IsNull() || aShape2.IsNull())
1464 return anEmptyCalc._retn();
1466 Handle(::GEOM_Object) aCalculator = GetOperations()->ShapeProximityCalculator(aShape1, aShape2);
1467 if (!GetOperations()->IsDone() || aCalculator.IsNull())
1468 return anEmptyCalc._retn();
1470 return GetObject(aCalculator);
1473 //=============================================================================
1477 //=============================================================================
1478 void GEOM_IMeasureOperations_i::SetShapeSampling(GEOM::GEOM_Object_ptr theCalculator,
1479 GEOM::GEOM_Object_ptr theShape,
1480 CORBA::Long theNbSamples)
1482 //Set a not done flag
1483 GetOperations()->SetNotDone();
1485 //Get the proximity calculator
1486 Handle(::GEOM_Object) aCalc = GetObjectImpl(theCalculator);
1489 //Get the reference shape
1490 Handle(::GEOM_Object) aShape = GetObjectImpl(theShape);
1491 if (aShape.IsNull())
1494 GetOperations()->SetShapeSampling(aCalc, aShape, theNbSamples);
1497 //=============================================================================
1499 * GetCoarseProximity
1501 //=============================================================================
1502 CORBA::Double GEOM_IMeasureOperations_i::GetCoarseProximity(GEOM::GEOM_Object_ptr theCalculator)
1504 //Set a not done flag
1505 GetOperations()->SetNotDone();
1507 //Get the reference shape
1508 Handle(::GEOM_Object) aCalc = GetObjectImpl(theCalculator);
1512 Standard_Real aProximity = GetOperations()->GetCoarseProximity(aCalc);
1513 if (!GetOperations()->IsDone())
1519 //=============================================================================
1521 * GetPreciseProximity
1523 //=============================================================================
1524 CORBA::Double GEOM_IMeasureOperations_i::GetPreciseProximity(GEOM::GEOM_Object_ptr theCalculator)
1526 //Set a not done flag
1527 GetOperations()->SetNotDone();
1529 //Get the reference shape
1530 Handle(::GEOM_Object) aCalc = GetObjectImpl(theCalculator);
1534 Standard_Real aProximity = GetOperations()->GetPreciseProximity(aCalc);
1535 if (!GetOperations()->IsDone())