X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FGEOM_I%2FGEOM_IMeasureOperations_i.cc;fp=src%2FGEOM_I%2FGEOM_IMeasureOperations_i.cc;h=c2bffa8e9a4a12abe774b1140662db441c0f3b64;hb=f190cc9ae627a8bd91983609a5b008fbdabad5d1;hp=0c09e09c4b1ebaccdf503e5e29c0762917fdee19;hpb=89b8ea7bd712a14894636057019750c709de8970;p=modules%2Fgeom.git diff --git a/src/GEOM_I/GEOM_IMeasureOperations_i.cc b/src/GEOM_I/GEOM_IMeasureOperations_i.cc index 0c09e09c4..c2bffa8e9 100644 --- a/src/GEOM_I/GEOM_IMeasureOperations_i.cc +++ b/src/GEOM_I/GEOM_IMeasureOperations_i.cc @@ -1243,3 +1243,203 @@ GEOM::GEOM_Object_ptr GEOM_IMeasureOperations_i::SurfaceCurvatureByPointAndDirec return GetObject(anObject); } + +//============================================================================= +/*! + * 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); + } +}