X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FGEOM_I%2FGEOM_IMeasureOperations_i.cc;h=a740731b4b648c22badcb4e0f6115774649c1274;hb=611d40ba2a33af6bea4a6440612e5940ddf67ed0;hp=5093451fe2c602b573733894eaf84c58cf249fba;hpb=8370b4a1c488f6ef18d8944869d6a8cd3a2d18d2;p=modules%2Fgeom.git diff --git a/src/GEOM_I/GEOM_IMeasureOperations_i.cc b/src/GEOM_I/GEOM_IMeasureOperations_i.cc index 5093451fe..a740731b4 100644 --- a/src/GEOM_I/GEOM_IMeasureOperations_i.cc +++ b/src/GEOM_I/GEOM_IMeasureOperations_i.cc @@ -1,4 +1,4 @@ -// Copyright (C) 2007-2016 CEA/DEN, EDF R&D, OPEN CASCADE +// Copyright (C) 2007-2022 CEA/DEN, EDF R&D, OPEN CASCADE // // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS @@ -21,6 +21,7 @@ // #include +#include #include "GEOM_IMeasureOperations_i.hh" @@ -355,7 +356,7 @@ GEOM::GEOM_IKindOfShape::shape_kind GEOM_IMeasureOperations_i::KindOfShape GEOM::ListOfDouble_var aDoublesArray = new GEOM::ListOfDouble(); //Get the reference shape - Handle(GEOM_Object) aShape = GetObjectImpl(theShape); + Handle(::GEOM_Object) aShape = GetObjectImpl(theShape); if (!aShape.IsNull()) { Handle(TColStd_HSequenceOfInteger) anIntegers = new TColStd_HSequenceOfInteger; @@ -403,7 +404,7 @@ void GEOM_IMeasureOperations_i::GetPosition Zz = Xx = 1.; //Get the reference shape - Handle(GEOM_Object) aShape = GetObjectImpl(theShape); + Handle(::GEOM_Object) aShape = GetObjectImpl(theShape); if (aShape.IsNull()) return; // Get shape parameters @@ -424,11 +425,11 @@ GEOM::GEOM_Object_ptr GEOM_IMeasureOperations_i::GetCentreOfMass GetOperations()->SetNotDone(); //Get the reference shape - Handle(GEOM_Object) aShape = GetObjectImpl(theShape); + Handle(::GEOM_Object) aShape = GetObjectImpl(theShape); if (aShape.IsNull()) return aGEOMObject._retn(); // Make Point - centre of mass of theShape - Handle(GEOM_Object) anObject = GetOperations()->GetCentreOfMass(aShape); + Handle(::GEOM_Object) anObject = GetOperations()->GetCentreOfMass(aShape); if (!GetOperations()->IsDone() || anObject.IsNull()) return aGEOMObject._retn(); @@ -440,8 +441,10 @@ GEOM::GEOM_Object_ptr GEOM_IMeasureOperations_i::GetCentreOfMass * GetVertexByIndex */ //============================================================================= -GEOM::GEOM_Object_ptr GEOM_IMeasureOperations_i::GetVertexByIndex - (GEOM::GEOM_Object_ptr theShape, CORBA::Long theIndex) +GEOM::GEOM_Object_ptr +GEOM_IMeasureOperations_i::GetVertexByIndex( GEOM::GEOM_Object_ptr theShape, + CORBA::Long theIndex, + CORBA::Boolean theUseOri ) { GEOM::GEOM_Object_var aGEOMObject; @@ -449,11 +452,11 @@ GEOM::GEOM_Object_ptr GEOM_IMeasureOperations_i::GetVertexByIndex GetOperations()->SetNotDone(); //Get the reference shape - Handle(GEOM_Object) aShape = GetObjectImpl(theShape); + Handle(::GEOM_Object) aShape = GetObjectImpl(theShape); if ( aShape.IsNull() ) return aGEOMObject._retn(); // Get vertex by index - Handle(GEOM_Object) anObject = GetOperations()->GetVertexByIndex(aShape, theIndex); + Handle(::GEOM_Object) anObject = GetOperations()->GetVertexByIndex(aShape, theIndex, theUseOri); if (!GetOperations()->IsDone() || anObject.IsNull()) return aGEOMObject._retn(); @@ -475,14 +478,14 @@ GEOM::GEOM_Object_ptr GEOM_IMeasureOperations_i::GetNormal GetOperations()->SetNotDone(); //Get the reference shape - Handle(GEOM_Object) aFace = GetObjectImpl(theFace); + Handle(::GEOM_Object) aFace = GetObjectImpl(theFace); if (aFace.IsNull()) return aGEOMObject._retn(); // Get the OptionalPoint (can be not defined) - Handle(GEOM_Object) anOptionalPoint = GetObjectImpl(theOptionalPoint); + Handle(::GEOM_Object) anOptionalPoint = GetObjectImpl(theOptionalPoint); // Make Vector - normal to theFace (in point theOptionalPoint if the face is not planar) - Handle(GEOM_Object) anObject = GetOperations()->GetNormal(aFace, anOptionalPoint); + Handle(::GEOM_Object) anObject = GetOperations()->GetNormal(aFace, anOptionalPoint); if (!GetOperations()->IsDone() || anObject.IsNull()) return aGEOMObject._retn(); @@ -495,6 +498,7 @@ GEOM::GEOM_Object_ptr GEOM_IMeasureOperations_i::GetNormal */ //============================================================================= void GEOM_IMeasureOperations_i::GetBasicProperties (GEOM::GEOM_Object_ptr theShape, + CORBA::Double theTolerance, CORBA::Double& theLength, CORBA::Double& theSurfArea, CORBA::Double& theVolume) @@ -503,11 +507,12 @@ void GEOM_IMeasureOperations_i::GetBasicProperties (GEOM::GEOM_Object_ptr theSha GetOperations()->SetNotDone(); //Get the reference shape - Handle(GEOM_Object) aShape = GetObjectImpl(theShape); + Handle(::GEOM_Object) aShape = GetObjectImpl(theShape); if (aShape.IsNull()) return; // Get shape parameters - GetOperations()->GetBasicProperties(aShape, theLength, theSurfArea, theVolume); + GetOperations()->GetBasicProperties(aShape, theTolerance, theLength, + theSurfArea, theVolume); } //============================================================================= @@ -526,7 +531,7 @@ void GEOM_IMeasureOperations_i::GetInertia GetOperations()->SetNotDone(); //Get the reference shape - Handle(GEOM_Object) aShape = GetObjectImpl(theShape); + Handle(::GEOM_Object) aShape = GetObjectImpl(theShape); if (aShape.IsNull()) return; // Get shape parameters @@ -552,7 +557,7 @@ void GEOM_IMeasureOperations_i::GetBoundingBox (GEOM::GEOM_Object_ptr theShape, GetOperations()->SetNotDone(); //Get the reference shape - Handle(GEOM_Object) aShape = GetObjectImpl(theShape); + Handle(::GEOM_Object) aShape = GetObjectImpl(theShape); if (aShape.IsNull()) return; // Get shape parameters @@ -575,11 +580,11 @@ GEOM::GEOM_Object_ptr GEOM_IMeasureOperations_i::MakeBoundingBox GetOperations()->SetNotDone(); //Get the reference shape - Handle(GEOM_Object) aShape = GetObjectImpl(theShape); + Handle(::GEOM_Object) aShape = GetObjectImpl(theShape); if (aShape.IsNull()) return aGEOMObject._retn(); // Make Box - bounding box of theShape - Handle(GEOM_Object) anObject = + Handle(::GEOM_Object) anObject = GetOperations()->GetBoundingBox(aShape, precise); if (!GetOperations()->IsDone() || anObject.IsNull()) return aGEOMObject._retn(); @@ -602,7 +607,7 @@ void GEOM_IMeasureOperations_i::GetTolerance GetOperations()->SetNotDone(); //Get the reference shape - Handle(GEOM_Object) aShape = GetObjectImpl(theShape); + Handle(::GEOM_Object) aShape = GetObjectImpl(theShape); if (aShape.IsNull()) return; // Get shape parameters @@ -630,7 +635,7 @@ CORBA::Boolean GEOM_IMeasureOperations_i::CheckShape } //Get the reference shape - Handle(GEOM_Object) aShape = GetObjectImpl(theShape); + Handle(::GEOM_Object) aShape = GetObjectImpl(theShape); if (aShape.IsNull()) { @@ -658,7 +663,7 @@ CORBA::Boolean GEOM_IMeasureOperations_i::CheckShapeWithGeometry } //Get the reference shape - Handle(GEOM_Object) aShape = GetObjectImpl(theShape); + Handle(::GEOM_Object) aShape = GetObjectImpl(theShape); if (aShape.IsNull()) { @@ -683,7 +688,7 @@ char* GEOM_IMeasureOperations_i::PrintShapeErrors const GEOM::GEOM_IMeasureOperations::ShapeErrors &theErrors) { //Get the reference shape - Handle(GEOM_Object) aShape = GetObjectImpl(theShape); + Handle(::GEOM_Object) aShape = GetObjectImpl(theShape); if (aShape.IsNull()) { return NULL; @@ -718,7 +723,7 @@ CORBA::Boolean GEOM_IMeasureOperations_i::CheckSelfIntersections (GEOM::GEOM_Obj GEOM::ListOfLong_var anIntegersArray = new GEOM::ListOfLong(); // Get the reference shape - Handle(GEOM_Object) aShape = GetObjectImpl(theShape); + Handle(::GEOM_Object) aShape = GetObjectImpl(theShape); if (!aShape.IsNull()) { GEOMImpl_IMeasureOperations::SICheckLevel aCheckLevel; @@ -785,7 +790,7 @@ CORBA::Boolean GEOM_IMeasureOperations_i::CheckSelfIntersectionsFast GEOM::ListOfLong_var anIntegersArray = new GEOM::ListOfLong(); // Get the reference shape - Handle(GEOM_Object) aShape = GetObjectImpl(theShape); + Handle(::GEOM_Object) aShape = GetObjectImpl(theShape); if (!aShape.IsNull()) { Handle(TColStd_HSequenceOfInteger) anIntegers = new TColStd_HSequenceOfInteger; @@ -808,6 +813,29 @@ CORBA::Boolean GEOM_IMeasureOperations_i::CheckSelfIntersectionsFast return isGood; } +//============================================================================= +/*! + * CheckBOPArguments + */ +//============================================================================= +CORBA::Boolean GEOM_IMeasureOperations_i::CheckBOPArguments + (GEOM::GEOM_Object_ptr theShape) +{ + // Set a not done flag + GetOperations()->SetNotDone(); + + // Get the reference shape + Handle(::GEOM_Object) aShape = GetObjectImpl(theShape); + bool isGood = false; + + if (!aShape.IsNull()) { + // Check BOP arguments + isGood = GetOperations()->CheckBOPArguments(aShape); + } + + return isGood; +} + //============================================================================= /*! * FastIntersect @@ -830,8 +858,8 @@ CORBA::Boolean GEOM_IMeasureOperations_i::FastIntersect (GEOM::GEOM_Object_ptr t GEOM::ListOfLong_var anIntegersArray2 = new GEOM::ListOfLong(); // Get the reference shape - Handle(GEOM_Object) aShape1 = GetObjectImpl(theShape1); - Handle(GEOM_Object) aShape2 = GetObjectImpl(theShape2); + Handle(::GEOM_Object) aShape1 = GetObjectImpl(theShape1); + Handle(::GEOM_Object) aShape2 = GetObjectImpl(theShape2); if (!aShape1.IsNull() && !aShape2.IsNull()) { Handle(TColStd_HSequenceOfInteger) anIntegers1 = new TColStd_HSequenceOfInteger; @@ -872,7 +900,7 @@ char* GEOM_IMeasureOperations_i::IsGoodForSolid (GEOM::GEOM_Object_ptr theShape) GetOperations()->SetNotDone(); //Get the reference shape - Handle(GEOM_Object) aShape = GetObjectImpl(theShape); + Handle(::GEOM_Object) aShape = GetObjectImpl(theShape); if (aShape.IsNull()) return CORBA::string_dup("WRN_NULL_OBJECT_OR_SHAPE"); // Get shape parameters @@ -891,7 +919,7 @@ char* GEOM_IMeasureOperations_i::WhatIs (GEOM::GEOM_Object_ptr theShape) GetOperations()->SetNotDone(); //Get the reference shape - Handle(GEOM_Object) aShape = GetObjectImpl(theShape); + Handle(::GEOM_Object) aShape = GetObjectImpl(theShape); if (aShape.IsNull()) return NULL; // Get shape parameters @@ -911,19 +939,19 @@ GEOM::ListOfBool* GEOM_IMeasureOperations_i::AreCoordsInside (GEOM::GEOM_Object_ //Set a not done flag GetOperations()->SetNotDone(); - unsigned int nb_points = theCoords.length()/3; + int nb_points = theCoords.length()/3; GEOM::ListOfBool_var aResults = new GEOM::ListOfBool; aResults->length(nb_points); - Handle(GEOM_Object) aShape = GetObjectImpl(theShape); + Handle(::GEOM_Object) aShape = GetObjectImpl(theShape); std::vector tmp(3*nb_points); for (int i = 0; i < 3*nb_points; i++) tmp[i] = theCoords[i]; std::vector res = GetOperations()->AreCoordsInside(aShape, tmp, tolerance); - for (int i = 0; i < nb_points; i++) - aResults[i] = i < res.size() ? res[i] : false; + for (int i = 0, resSize = res.size(); i < nb_points; i++) + aResults[i] = i < resSize ? res[i] : false; return aResults._retn(); } @@ -941,8 +969,8 @@ CORBA::Double GEOM_IMeasureOperations_i::GetMinDistance GetOperations()->SetNotDone(); //Get the reference shape - Handle(GEOM_Object) aShape1 = GetObjectImpl(theShape1); - Handle(GEOM_Object) aShape2 = GetObjectImpl(theShape2); + Handle(::GEOM_Object) aShape1 = GetObjectImpl(theShape1); + Handle(::GEOM_Object) aShape2 = GetObjectImpl(theShape2); if (aShape1.IsNull() || aShape2.IsNull()) return -1.0; // Get shape parameters @@ -966,8 +994,8 @@ CORBA::Long GEOM_IMeasureOperations_i::ClosestPoints GEOM::ListOfDouble_var aDoublesArray = new GEOM::ListOfDouble(); //Get the reference shape - Handle(GEOM_Object) aShape1 = GetObjectImpl(theShape1); - Handle(GEOM_Object) aShape2 = GetObjectImpl(theShape2); + Handle(::GEOM_Object) aShape1 = GetObjectImpl(theShape1); + Handle(::GEOM_Object) aShape2 = GetObjectImpl(theShape2); if (!aShape1.IsNull() && !aShape2.IsNull()) { Handle(TColStd_HSequenceOfReal) aDoubles = new TColStd_HSequenceOfReal; @@ -997,7 +1025,7 @@ void GEOM_IMeasureOperations_i::PointCoordinates (GEOM::GEOM_Object_ptr theShape GetOperations()->SetNotDone(); //Get the reference shape - Handle(GEOM_Object) aShape = GetObjectImpl(theShape); + Handle(::GEOM_Object) aShape = GetObjectImpl(theShape); if (aShape.IsNull()) return; @@ -1017,8 +1045,8 @@ CORBA::Double GEOM_IMeasureOperations_i::GetAngle (GEOM::GEOM_Object_ptr theShap GetOperations()->SetNotDone(); //Get the reference shapes - Handle(GEOM_Object) aShape1 = GetObjectImpl(theShape1); - Handle(GEOM_Object) aShape2 = GetObjectImpl(theShape2); + Handle(::GEOM_Object) aShape1 = GetObjectImpl(theShape1); + Handle(::GEOM_Object) aShape2 = GetObjectImpl(theShape2); if (aShape1.IsNull() || aShape2.IsNull()) return -1.0; // Get the angle @@ -1037,14 +1065,40 @@ CORBA::Double GEOM_IMeasureOperations_i::GetAngleBtwVectors (GEOM::GEOM_Object_p GetOperations()->SetNotDone(); //Get the reference shapes - Handle(GEOM_Object) aShape1 = GetObjectImpl(theShape1); - Handle(GEOM_Object) aShape2 = GetObjectImpl(theShape2); + Handle(::GEOM_Object) aShape1 = GetObjectImpl(theShape1); + Handle(::GEOM_Object) aShape2 = GetObjectImpl(theShape2); if (aShape1.IsNull() || aShape2.IsNull()) return -1.0; // Get the angle return GetOperations()->GetAngleBtwVectors(aShape1, aShape2); } +//============================================================================= +/*! +* PatchFace +*/ +//============================================================================= +GEOM::ListOfGO* GEOM_IMeasureOperations_i::PatchFace(GEOM::GEOM_Object_ptr theShape) +{ + GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO; + + //Get the reference shape + Handle(::GEOM_Object) aShapeRef = GetObjectImpl(theShape); + if (aShapeRef.IsNull()) return aSeq._retn(); + + // Perform patch face operation + Handle(TColStd_HSequenceOfTransient) aHSeq = + GetOperations()->PatchFace(aShapeRef); + if (!GetOperations()->IsDone() || aHSeq.IsNull()) + return aSeq._retn(); + + Standard_Integer aLength = aHSeq->Length(); + aSeq->length(aLength); + for (Standard_Integer i = 1; i <= aLength; i++) + aSeq[i - 1] = GetObject(Handle(::GEOM_Object)::DownCast(aHSeq->Value(i))); + + return aSeq._retn(); +} //============================================================================= /*! @@ -1058,7 +1112,7 @@ CORBA::Double GEOM_IMeasureOperations_i::CurveCurvatureByParam GetOperations()->SetNotDone(); //Get the reference shape - Handle(GEOM_Object) aShape = GetObjectImpl(theCurve); + Handle(::GEOM_Object) aShape = GetObjectImpl(theCurve); if(aShape.IsNull()) return -1.0; return GetOperations()->CurveCurvatureByParam(aShape,theParam); @@ -1076,8 +1130,8 @@ CORBA::Double GEOM_IMeasureOperations_i::CurveCurvatureByPoint GetOperations()->SetNotDone(); //Get the reference shape - Handle(GEOM_Object) aShape = GetObjectImpl(theCurve); - Handle(GEOM_Object) aPoint = GetObjectImpl(thePoint); + Handle(::GEOM_Object) aShape = GetObjectImpl(theCurve); + Handle(::GEOM_Object) aPoint = GetObjectImpl(thePoint); if( aShape.IsNull() || aPoint.IsNull() ) return -1.0; return GetOperations()->CurveCurvatureByPoint(aShape,aPoint); @@ -1098,7 +1152,7 @@ CORBA::Double GEOM_IMeasureOperations_i::MaxSurfaceCurvatureByParam GetOperations()->SetNotDone(); //Get the reference shape - Handle(GEOM_Object) aShape = GetObjectImpl(theSurf); + Handle(::GEOM_Object) aShape = GetObjectImpl(theSurf); if(aShape.IsNull()) return -1.0; return GetOperations()->MaxSurfaceCurvatureByParam(aShape,theUParam,theVParam); @@ -1116,8 +1170,8 @@ CORBA::Double GEOM_IMeasureOperations_i::MaxSurfaceCurvatureByPoint GetOperations()->SetNotDone(); //Get the reference shape - Handle(GEOM_Object) aShape = GetObjectImpl(theSurf); - Handle(GEOM_Object) aPoint = GetObjectImpl(thePoint); + Handle(::GEOM_Object) aShape = GetObjectImpl(theSurf); + Handle(::GEOM_Object) aPoint = GetObjectImpl(thePoint); if( aShape.IsNull() || aPoint.IsNull() ) return -1.0; return GetOperations()->MaxSurfaceCurvatureByPoint(aShape,aPoint); @@ -1137,7 +1191,7 @@ CORBA::Double GEOM_IMeasureOperations_i::MinSurfaceCurvatureByParam GetOperations()->SetNotDone(); //Get the reference shape - Handle(GEOM_Object) aShape = GetObjectImpl(theSurf); + Handle(::GEOM_Object) aShape = GetObjectImpl(theSurf); if (aShape.IsNull()) return -1.0; return GetOperations()->MinSurfaceCurvatureByParam(aShape,theUParam,theVParam); @@ -1155,9 +1209,418 @@ CORBA::Double GEOM_IMeasureOperations_i::MinSurfaceCurvatureByPoint GetOperations()->SetNotDone(); //Get the reference shape - Handle(GEOM_Object) aShape = GetObjectImpl(theSurf); - Handle(GEOM_Object) aPoint = GetObjectImpl(thePoint); + Handle(::GEOM_Object) aShape = GetObjectImpl(theSurf); + Handle(::GEOM_Object) aPoint = GetObjectImpl(thePoint); if (aShape.IsNull() || aPoint.IsNull()) return -1.0; return GetOperations()->MinSurfaceCurvatureByPoint(aShape,aPoint); } + +//============================================================================= +/*! + * SurfaceCurvatureByPointAndDirection + */ +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_IMeasureOperations_i::SurfaceCurvatureByPointAndDirection + (GEOM::GEOM_Object_ptr theSurf, + GEOM::GEOM_Object_ptr thePoint, + GEOM::GEOM_Object_ptr theDirection) +{ + GEOM::GEOM_Object_var aGEOMObject; + + //Set a not done flag + GetOperations()->SetNotDone(); + + //Get the reference shape + Handle(::GEOM_Object) aShape = GetObjectImpl(theSurf); + Handle(::GEOM_Object) aPoint = GetObjectImpl(thePoint); + Handle(::GEOM_Object) aDirection = GetObjectImpl(theDirection); + if (aShape.IsNull() || aPoint.IsNull() || aDirection.IsNull()) return aGEOMObject._retn(); + + Handle(::GEOM_Object) anObject = + GetOperations()->SurfaceCurvatureByPointAndDirection(aShape,aPoint,aDirection); + if (!GetOperations()->IsDone() || anObject.IsNull()) + return aGEOMObject._retn(); + + return GetObject(anObject); +} + +//============================================================================= +/*! + * XYZtoUV + */ +//============================================================================= +GEOM::ListOfDouble* GEOM_IMeasureOperations_i::XYZtoUV + (GEOM::GEOM_Object_ptr theSurf, + const GEOM::ListOfDouble& theXYZlist, + CORBA::Boolean theIsNormalized) +{ + GEOM::ListOfDouble_var resUV = new GEOM::ListOfDouble; + + //Set a not done flag + GetOperations()->SetNotDone(); + + //Get the reference shape + Handle(::GEOM_Object) aShape = GetObjectImpl(theSurf); + if (aShape.IsNull()) return resUV._retn(); + + //Get input XYZ list + Handle(TColStd_HArray1OfReal) aXYZlist = + new TColStd_HArray1OfReal (0, theXYZlist.length() - 1); + { + size_t nb = theXYZlist.length(); + for (size_t i = 0; i < nb; ++i) + aXYZlist->SetValue(i, theXYZlist[i]); + } + + //Call implementation + Handle(TColStd_HArray1OfReal) aUVlist = + GetOperations()->XYZtoUV(aShape, aXYZlist, theIsNormalized); + + if (GetOperations()->IsDone()) { + resUV->length(aUVlist->Length()); + int i0 = aUVlist->Lower(); + int nb = aUVlist->Upper(); + for (int i = i0; i <= nb; ++i) + resUV[ i-i0 ] = aUVlist->Value(i); + } + + return resUV._retn(); +} + +//============================================================================= +/*! + * UVtoXYZ + */ +//============================================================================= +GEOM::ListOfDouble* GEOM_IMeasureOperations_i::UVtoXYZ + (GEOM::GEOM_Object_ptr theSurf, + const GEOM::ListOfDouble& theUVlist, + CORBA::Boolean theIsNormalized) +{ + GEOM::ListOfDouble_var resXYZ = new GEOM::ListOfDouble; + + //Set a not done flag + GetOperations()->SetNotDone(); + + //Get the reference shape + Handle(::GEOM_Object) aShape = GetObjectImpl(theSurf); + if (aShape.IsNull()) return resXYZ._retn(); + + //Get input UV list + Handle(TColStd_HArray1OfReal) aUVlist = + new TColStd_HArray1OfReal (0, theUVlist.length() - 1); + { + size_t nb = theUVlist.length(); + for (size_t i = 0; i < nb; ++i) + aUVlist->SetValue(i, theUVlist[i]); + } + + //Call implementation + Handle(TColStd_HArray1OfReal) aXYZlist = + GetOperations()->UVtoXYZ(aShape, aUVlist, theIsNormalized); + + if (GetOperations()->IsDone()) { + resXYZ->length(aXYZlist->Length()); + int i0 = aXYZlist->Lower(); + int nb = aXYZlist->Upper(); + for (int i = i0; i <= nb; ++i) + resXYZ[ i-i0 ] = aXYZlist->Value(i); + } + + return resXYZ._retn(); +} + +//============================================================================= +/*! + * SelfIntersected2D + * Find all self-intersected 2D curves. + * \param theShape Shape for check. + */ + //============================================================================= +GEOM::GEOM_IMeasureOperations::SequenceOfPairOfShape* GEOM_IMeasureOperations_i::SelfIntersected2D( + const GEOM::GEOM_IMeasureOperations::CheckResults& theResuts) +{ + GEOM::GEOM_IMeasureOperations::SequenceOfPairOfShape_var aSeq = + new GEOM::GEOM_IMeasureOperations::SequenceOfPairOfShape; + + // Perform patch face operation + std::list aResults; + ConvertToList(theResuts, aResults); + + std::list aSelfInters = GetOperations()->SelfIntersected2D(aResults); + if (!GetOperations()->IsDone() || aSelfInters.empty()) + return aSeq._retn(); + + Standard_Integer aLength = aSelfInters.size(); + aSeq->length(aLength); + std::list::iterator anIter(aSelfInters.begin()); + for (Standard_Integer i = 0; i < aLength; i++, ++anIter) + { + aSeq[i].first = GetObject(Handle(::GEOM_Object)::DownCast((*anIter).first)); + aSeq[i].second = GetObject(Handle(::GEOM_Object)::DownCast((*anIter).second)); + } + + return aSeq._retn(); +} + +//============================================================================= +/*! + * InterferingSubshapes + * Find pairs of interfering sub-shapes, by default all pairs of interfering shapes are returned. + * \param theShape Shape for check. + * \param theShapeType1 Type of shape. + * \param theShapeType2 Type of shape. + */ + //============================================================================= +GEOM::GEOM_IMeasureOperations::SequenceOfPairOfShape* GEOM_IMeasureOperations_i::InterferingSubshapes( + const GEOM::GEOM_IMeasureOperations::CheckResults& theResuts, + const CORBA::Long theShapeType1, + const CORBA::Long theShapeType2) +{ + GEOM::GEOM_IMeasureOperations::SequenceOfPairOfShape_var aSeq = + new GEOM::GEOM_IMeasureOperations::SequenceOfPairOfShape; + + // Perform patch face operation + std::list aResults; + ConvertToList(theResuts, aResults); + + std::list aSelfInterf = + GetOperations()->InterferingSubshapes(aResults, theShapeType1, theShapeType2); + if (!GetOperations()->IsDone() || aSelfInterf.empty()) + return aSeq._retn(); + + Standard_Integer aLength = aSelfInterf.size(); + aSeq->length(aLength); + std::list::iterator anIter(aSelfInterf.begin()); + for (Standard_Integer i = 0; i < aLength; i++, ++anIter) + { + aSeq[i].first = GetObject(Handle(::GEOM_Object)::DownCast((*anIter).first)); + aSeq[i].second = GetObject(Handle(::GEOM_Object)::DownCast((*anIter).second)); + } + + return aSeq._retn(); +} + +//============================================================================= +/*! + * SmallEdges + * Find edges, which are fully covered by tolerances of vertices. + * \param theShape Shape for check. + */ + //============================================================================= +GEOM::ListOfGO* GEOM_IMeasureOperations_i::SmallEdges(const GEOM::GEOM_IMeasureOperations::CheckResults& theResuts) +{ + GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO; + + std::list aResults; + ConvertToList(theResuts, aResults); + + //Get the reference shape + Handle(TColStd_HSequenceOfTransient) aSmallEdges = GetOperations()->SmallEdges(aResults); + if (!GetOperations()->IsDone() || aSmallEdges.IsNull()) + return aSeq._retn(); + + Standard_Integer aLength = aSmallEdges->Length(); + aSeq->length(aLength); + for (Standard_Integer i = 1; i <= aLength; i++) + aSeq[i - 1] = GetObject(Handle(::GEOM_Object)::DownCast(aSmallEdges->Value(i))); + + return aSeq._retn(); +} + +//============================================================================= +/*! + * DistantShapes + * find remote objects (sub-shape on a shape). + * \param theShape Shape for check. + * \param theShapeType Type of shape. + * \param theSubShapeType Type of sub-shape. + * \param theTolerance tolerance. + */ + //============================================================================= +GEOM::GEOM_IMeasureOperations::SequenceOfPairOfShape* GEOM_IMeasureOperations_i::DistantShapes( + const GEOM::GEOM_IMeasureOperations::CheckResults& theResuts, + const CORBA::Long theShapeType, + const CORBA::Long theSubShapeType, + const CORBA::Double theTolerance) +{ + GEOM::GEOM_IMeasureOperations::SequenceOfPairOfShape_var aSeq = + new GEOM::GEOM_IMeasureOperations::SequenceOfPairOfShape; + + std::list aResults; + ConvertToList(theResuts, aResults); + + // Perform patch face operation + std::list aDistantS = + GetOperations()->DistantShapes(aResults, theShapeType, theSubShapeType, theTolerance); + if (!GetOperations()->IsDone() || aDistantS.empty()) + return aSeq._retn(); + + Standard_Integer aLength = aDistantS.size(); + aSeq->length(aLength); + std::list::iterator anIter(aDistantS.begin()); + for (Standard_Integer i = 0; i < aLength; i++, ++anIter) + { + aSeq[i].first = GetObject(Handle(::GEOM_Object)::DownCast((*anIter).first)); + aSeq[i].second = GetObject(Handle(::GEOM_Object)::DownCast((*anIter).second)); + } + + return aSeq._retn(); +} + +//============================================================================= +/*! + * CheckConformityShape + * Perform all required checks + */ + //============================================================================= +GEOM::GEOM_IMeasureOperations::CheckResults* GEOM_IMeasureOperations_i::CheckConformityShape( + GEOM::GEOM_Object_ptr theShape) +{ + GEOM::GEOM_IMeasureOperations::CheckResults_var aRes = new GEOM::GEOM_IMeasureOperations::CheckResults; + + //Get the reference shape + Handle(::GEOM_Object) aShapeRef = GetObjectImpl(theShape); + if (aShapeRef.IsNull()) return nullptr; + + std::list aChecks; + GetOperations()->CheckConformityShape(aShapeRef, aChecks); + + Standard_Integer aLength = aChecks.size(); + aRes->length(aLength); + std::list::const_iterator anIntIt = aChecks.cbegin(); + for (Standard_Integer i = 0; i < aLength; i++, ++anIntIt) + { + aRes[i].type = (*anIntIt).TypeOfCheck; + aRes[i].failedShapes.first = GetObject(Handle(::GEOM_Object)::DownCast((*anIntIt).FailedShapes.first)); + aRes[i].failedShapes.second = GetObject(Handle(::GEOM_Object)::DownCast((*anIntIt).FailedShapes.second)); + } + + return aRes._retn(); +} + +//============================================================================= +/*! + * UpdateTolerance + * Compute possible tolerance for the shape, minimize tolerance of shape as well + * as tolerance of sub-shapes as much as possible + * \param theShape Shape for check. + */ + //============================================================================= +CORBA::Double GEOM_IMeasureOperations_i::UpdateTolerance(GEOM::GEOM_Object_ptr theShape) +{ + //Get the reference shape + Handle(::GEOM_Object) aShapeRef = GetObjectImpl(theShape); + if (aShapeRef.IsNull()) + return false; + + return GetOperations()->UpdateTolerance(aShapeRef); +} + +void GEOM_IMeasureOperations_i::ConvertToList(const GEOM::GEOM_IMeasureOperations::CheckResults& theResuts, + std::list& theListOfResults) +{ + for (Standard_Integer i = 0; i < theResuts.length(); ++i) + { + GEOMImpl_IMeasureOperations::FailedChecks aCheck; + aCheck.TypeOfCheck = theResuts[i].type; + aCheck.FailedShapes.first = GetObjectImpl(theResuts[i].failedShapes.first); + aCheck.FailedShapes.second = GetObjectImpl(theResuts[i].failedShapes.second); + theListOfResults.push_back(aCheck); + } +} + +//============================================================================= +/*! + * ShapeProximityCalculator + */ +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_IMeasureOperations_i::ShapeProximityCalculator(GEOM::GEOM_Object_ptr theShape1, + GEOM::GEOM_Object_ptr theShape2) +{ + GEOM::GEOM_Object_var anEmptyCalc; + + //Set a not done flag + GetOperations()->SetNotDone(); + + //Get the reference shape + Handle(::GEOM_Object) aShape1 = GetObjectImpl(theShape1); + Handle(::GEOM_Object) aShape2 = GetObjectImpl(theShape2); + if (aShape1.IsNull() || aShape2.IsNull()) + return anEmptyCalc._retn(); + + Handle(::GEOM_Object) aCalculator = GetOperations()->ShapeProximityCalculator(aShape1, aShape2); + if (!GetOperations()->IsDone() || aCalculator.IsNull()) + return anEmptyCalc._retn(); + + return GetObject(aCalculator); +} + +//============================================================================= +/*! + * SetShapeSampling + */ + //============================================================================= +void GEOM_IMeasureOperations_i::SetShapeSampling(GEOM::GEOM_Object_ptr theCalculator, + GEOM::GEOM_Object_ptr theShape, + CORBA::Long theNbSamples) +{ + //Set a not done flag + GetOperations()->SetNotDone(); + + //Get the proximity calculator + Handle(::GEOM_Object) aCalc = GetObjectImpl(theCalculator); + if (aCalc.IsNull()) + return ; + //Get the reference shape + Handle(::GEOM_Object) aShape = GetObjectImpl(theShape); + if (aShape.IsNull()) + return ; + + GetOperations()->SetShapeSampling(aCalc, aShape, theNbSamples); +} + +//============================================================================= +/*! + * GetCoarseProximity + */ + //============================================================================= +CORBA::Double GEOM_IMeasureOperations_i::GetCoarseProximity(GEOM::GEOM_Object_ptr theCalculator) +{ + //Set a not done flag + GetOperations()->SetNotDone(); + + //Get the reference shape + Handle(::GEOM_Object) aCalc = GetObjectImpl(theCalculator); + if (aCalc.IsNull()) + return -1.0; + + Standard_Real aProximity = GetOperations()->GetCoarseProximity(aCalc); + if (!GetOperations()->IsDone()) + return -1.0; + + return aProximity; +} + +//============================================================================= +/*! + * GetPreciseProximity + */ + //============================================================================= +CORBA::Double GEOM_IMeasureOperations_i::GetPreciseProximity(GEOM::GEOM_Object_ptr theCalculator) +{ + //Set a not done flag + GetOperations()->SetNotDone(); + + //Get the reference shape + Handle(::GEOM_Object) aCalc = GetObjectImpl(theCalculator); + if (aCalc.IsNull()) + return -1.0; + + Standard_Real aProximity = GetOperations()->GetPreciseProximity(aCalc); + if (!GetOperations()->IsDone()) + return -1.0; + + return aProximity; +}