X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FGEOMImpl%2FGEOMImpl_IMeasureOperations.cxx;h=4d500a92d236293a6bcdfd2e1f9bda5ea8178387;hb=de2617e3f55fc12bac2da61fcbaf2d96f1e38926;hp=ea7b453ce12f995c676fb248867a47479514d1ce;hpb=3468a943e05903238dbf37e7925c8e32fcb4241d;p=modules%2Fgeom.git diff --git a/src/GEOMImpl/GEOMImpl_IMeasureOperations.cxx b/src/GEOMImpl/GEOMImpl_IMeasureOperations.cxx index ea7b453ce..4d500a92d 100644 --- a/src/GEOMImpl/GEOMImpl_IMeasureOperations.cxx +++ b/src/GEOMImpl/GEOMImpl_IMeasureOperations.cxx @@ -34,7 +34,18 @@ #include #include -#include +#include + +#include +#include +#include +//#include +#include +#include +//#include +#include + +#include #include #include @@ -1310,6 +1321,91 @@ bool GEOMImpl_IMeasureOperations::CheckShape (Handle(GEOM_Object) theShape, return isValid; } +//============================================================================= +/*! + * CheckSelfIntersections + */ +//============================================================================= +bool GEOMImpl_IMeasureOperations::CheckSelfIntersections + (Handle(GEOM_Object) theShape, + Handle(TColStd_HSequenceOfInteger)& theIntersections) +{ + SetErrorCode(KO); + bool isGood = false; + + if (theIntersections.IsNull()) + theIntersections = new TColStd_HSequenceOfInteger; + else + theIntersections->Clear(); + + if (theShape.IsNull()) + return isGood; + + Handle(GEOM_Function) aRefShape = theShape->GetLastFunction(); + if (aRefShape.IsNull()) return isGood; + + TopoDS_Shape aShape = aRefShape->GetValue(); + if (aShape.IsNull()) return isGood; + + // 0. Prepare data + BRep_Builder aBB; + TopoDS_Compound aCS; + TopoDS_Shape aScopy; + NMTDS_Tools::CopyShape(aShape, aScopy); + + // Map sub-shapes and their indices + TopTools_IndexedMapOfShape anIndices; + TopExp::MapShapes(aScopy, anIndices); + + aBB.MakeCompound(aCS); + aBB.Add(aCS, aScopy); + + NMTTools_CheckerSI aCSI; // checker of self-interferences + aCSI.SetCompositeShape(aCS); + + // 1. Launch the checker + aCSI.Perform(); + Standard_Integer iErr = aCSI.StopStatus(); + if (iErr) { + return false; // Error + } + + isGood = true; + + // 2. Take the shapes from DS + const NMTDS_ShapesDataStructure& aDS = *(aCSI.DS()); + Standard_Integer aNbS = aDS.NumberOfShapesOfTheObject(); + + // 3. Get the pairs of interfered shapes + NMTDS_PInterfPool pIP = aCSI.IP(); + //const NMTDS_ListOfPassKeyBoolean& aLPKB = pIP->Get(); + const NMTDS_ListOfPairBoolean& aLPKB = pIP->Get(); + + Standard_Integer n1, n2; + //NMTDS_ListIteratorOfListOfPassKeyBoolean aIt; + NMTDS_ListIteratorOfListOfPairBoolean aIt; + + aIt.Initialize(aLPKB); + for (; aIt.More(); aIt.Next()) { + //const NMTDS_PassKeyBoolean& aPKB = aIt.Value(); + const NMTDS_PairBoolean& aPKB = aIt.Value(); + aPKB.Ids(n1, n2); + + if (n1 > aNbS || n2 > aNbS) + return false; // Error + + const TopoDS_Shape& aS1 = aDS.Shape(n1); + const TopoDS_Shape& aS2 = aDS.Shape(n2); + + theIntersections->Append(anIndices.FindIndex(aS1)); + theIntersections->Append(anIndices.FindIndex(aS2)); + isGood = false; + } + + SetErrorCode(OK); + return isGood; +} + //============================================================================= /*! * IsGoodForSolid @@ -1921,6 +2017,10 @@ void GEOMImpl_IMeasureOperations::PointCoordinates (Handle(GEOM_Object) theShape Standard_Real GEOMImpl_IMeasureOperations::GetAngle (Handle(GEOM_Object) theLine1, Handle(GEOM_Object) theLine2) { + if (theLine1->GetType() == GEOM_VECTOR && + theLine2->GetType() == GEOM_VECTOR) + return GetAngleBtwVectors(theLine1, theLine2); + SetErrorCode(KO); Standard_Real anAngle = -1.0;