X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FNMTDS%2FNMTDS_ShapesDataStructure.cxx;h=229f3c5436ced0ecc40af286bcaae831f44b7018;hb=02aab3a5b3529674f5d3edf2dc5f6dab61d20c29;hp=0fde817470427750cc38215fe7786906512410f2;hpb=a62a321c849518376e3aa4d24a0b902a24167c64;p=modules%2Fgeom.git diff --git a/src/NMTDS/NMTDS_ShapesDataStructure.cxx b/src/NMTDS/NMTDS_ShapesDataStructure.cxx index 0fde81747..229f3c543 100644 --- a/src/NMTDS/NMTDS_ShapesDataStructure.cxx +++ b/src/NMTDS/NMTDS_ShapesDataStructure.cxx @@ -15,7 +15,7 @@ // License along with this library; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// See http://www.salome-platform.org/ +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // // File: NMTDS_ShapesDataStructure.cxx // Created: Mon Dec 1 10:21:04 2003 @@ -31,6 +31,10 @@ #include #include #include +// +#include +#include +#include //=========================================================================== //function : NMTDS_ShapesDataStructure::NMTDS_ShapesDataStructure @@ -39,19 +43,7 @@ NMTDS_ShapesDataStructure::NMTDS_ShapesDataStructure() : BooleanOperations_ShapesDataStructure() -{ - //printf(" NMTDS_ShapesDataStructure CREATE:%x\n", (int)this); -} -//modified by NIZNHY-PKV Wed Feb 2 11:45:04 2005f -//=========================================================================== -//function : ~ -//purpose : -//=========================================================================== - NMTDS_ShapesDataStructure::~NMTDS_ShapesDataStructure() -{ - //printf(" NMTDS_ShapesDataStructure DELETE:%x\n", (int)this); -} -//modified by NIZNHY-PKV Wed Feb 2 11:45:06 2005t +{} //=========================================================================== //function : SetCompositeShape //purpose : @@ -76,6 +68,79 @@ { return myRanges; } +// Modified to Add new methods Thu Sep 14 14:35:18 2006 +// Contribution of Samtech www.samcef.com BEGIN +//=========================================================================== +//function : FillMap +//purpose : +//=========================================================================== + void NMTDS_ShapesDataStructure::FillMap + (const TopoDS_Shape& aS, + BooleanOperations_IndexedDataMapOfShapeAncestorsSuccessors& aMSA, + BooleanOperations_IndexedDataMapOfShapeAncestorsSuccessors& aMS) const +{ + Standard_Integer iX, i, j, aIndex, aNbSc, aNbS; + BooleanOperations_AncestorsSeqAndSuccessorsSeq aAS; + // + aMSA.Add(aS, aAS); + aMS.Add(aS, aAS); + FillSubshapes(aS, aMSA, aMS); + // + aNbS=aMS.Extent(); + for(i=1; i<=aNbS; ++i) { + TColStd_MapOfInteger aMFence; + // + const TopoDS_Shape& aSX=aMS.FindKey(i); + iX=aMSA.FindIndex(aSX); + const BooleanOperations_AncestorsSeqAndSuccessorsSeq& aAS1=aMSA(iX); + // + aNbSc=aAS1.NumberOfSuccessors(); + for(j=1; j<=aNbSc; ++j) { + aIndex=aAS1.GetSuccessor(j); + if(aMFence.Add(aIndex)) { + BooleanOperations_AncestorsSeqAndSuccessorsSeq& aAS2=aMSA.ChangeFromIndex(aIndex); + aAS2.SetNewAncestor(iX); + } + } + } +} +//=========================================================================== +//function : FillSubshapes +//purpose : +//=========================================================================== + void NMTDS_ShapesDataStructure::FillSubshapes + (const TopoDS_Shape& aS, + BooleanOperations_IndexedDataMapOfShapeAncestorsSuccessors& aMSA, + BooleanOperations_IndexedDataMapOfShapeAncestorsSuccessors& aMS) const +{ + Standard_Boolean bIsNewSubShape; + Standard_Integer aIndexSubShape, aIndex; + BooleanOperations_AncestorsSeqAndSuccessorsSeq aASx; + // + aIndex=aMSA.FindIndex(aS); + BooleanOperations_AncestorsSeqAndSuccessorsSeq& aAS=aMSA.ChangeFromIndex(aIndex); + // + TopoDS_Iterator anIt(aS, Standard_True); + for(; anIt.More(); anIt.Next()) { + const TopoDS_Shape& aSubShape = anIt.Value(); + bIsNewSubShape = Standard_False; + if(!aMSA.Contains(aSubShape)) { + bIsNewSubShape=!bIsNewSubShape; + aIndexSubShape=aMSA.Add(aSubShape, aASx); + aMS.Add(aSubShape, aASx); + } + else { + aIndexSubShape=aMSA.FindIndex(aSubShape); + } + aAS.SetNewSuccessor(aIndexSubShape); + aAS.SetNewOrientation(aSubShape.Orientation()); + // + if(bIsNewSubShape && (aSubShape.ShapeType() != TopAbs_VERTEX)) { + FillSubshapes(aSubShape, aMSA, aMS); + } + } +} +// Contribution of Samtech www.samcef.com END //=========================================================================== //function : Init //purpose : @@ -87,24 +152,35 @@ NMTDS_ListOfIndexedDataMapOfShapeAncestorsSuccessors aLx; NMTDS_ListIteratorOfListOfIndexedDataMapOfShapeAncestorsSuccessors aLit; TopoDS_Iterator anIt; + // Modified Thu Sep 14 14:35:18 2006 + // Contribution of Samtech www.samcef.com BEGIN + BooleanOperations_IndexedDataMapOfShapeAncestorsSuccessors aMSA; + // Contribution of Samtech www.samcef.com END // - aNbS=0; anIt.Initialize(myCompositeShape); for (i=0; anIt.More(); anIt.Next(), ++i) { - const TopoDS_Shape& aSx=anIt.Value(); - BooleanOperations_IndexedDataMapOfShapeAncestorsSuccessors aIndDatMapShape; - FillIndexedMapOfShapesAncestorsAndSuccessors(aSx, aIndDatMapShape); - aNbSx=aIndDatMapShape.Extent(); - aNbS+=aNbSx; - aLx.Append(aIndDatMapShape); + // Modified Thu Sep 14 14:35:18 2006 + // Contribution of Samtech www.samcef.com BEGIN + const TopoDS_Shape& aSx=anIt.Value(); + BooleanOperations_IndexedDataMapOfShapeAncestorsSuccessors aMS; + FillMap(aSx, aMSA, aMS); + aLx.Append(aMS); + // Contribution of Samtech www.samcef.com END } + // Modified Thu Sep 14 14:35:18 2006 + // Contribution of Samtech www.samcef.com BEGIN + aNbS=aMSA.Extent(); + // Contribution of Samtech www.samcef.com END // // Fill myRanges myRanges.Resize(i); aLit.Initialize(aLx); for (i=1; aLit.More(); aLit.Next(), ++i) { - const BooleanOperations_IndexedDataMapOfShapeAncestorsSuccessors& aM=aLit.Value(); - aNbSx=aM.Extent(); + // Modified Thu Sep 14 14:35:18 2006 + // Contribution of Samtech www.samcef.com BEGIN + const BooleanOperations_IndexedDataMapOfShapeAncestorsSuccessors& aMSx=aLit.Value(); + aNbSx=aMSx.Extent(); + // Contribution of Samtech www.samcef.com END if (i==1) { iFirst=1; iLast=aNbSx; @@ -119,31 +195,43 @@ } // myNumberOfShapesOfTheObject=aNbS; - myNumberOfShapesOfTheTool=aNbS; - myLength=3*aNbS; + // Modified Thu Sep 14 14:35:18 2006 + // Contribution of Samtech www.samcef.com BEGIN + //myNumberOfShapesOfTheTool=aNbS; + //myLength=3*aNbS; + myNumberOfShapesOfTheTool=0; + myLength=2*aNbS; + // Contribution of Samtech www.samcef.com END // // Allocate the whole Table myListOfShapeAndInterferences = (BooleanOperations_PShapeAndInterferences) Standard::Allocate(myLength*sizeof(BooleanOperations_ShapeAndInterferences)); + // Modified Thu Sep 14 14:35:18 2006 + // Contribution of Samtech www.samcef.com BEGIN // // Fill the table - for (i=0; i<2; ++i) { - aShift=0; - if (i) { - aShift=myNumberOfShapesOfTheObject; - } - aLit.Initialize(aLx); - for (; aLit.More(); aLit.Next()) { - const BooleanOperations_IndexedDataMapOfShapeAncestorsSuccessors& aM=aLit.Value(); - aNbSx=aM.Extent(); - for (j=1; j<=aNbSx; ++j) { - const TopoDS_Shape& aSx=aM.FindKey(j); - const BooleanOperations_AncestorsSeqAndSuccessorsSeq& aASx=aM.FindFromIndex(j); - InsertShapeAndAncestorsSuccessors(aSx, aASx, aShift); - } - aShift+=aNbSx; - } + //modified by NIZNHY-PKV Tue May 16 11:47:28 2006f + + //aShift=0; + //for (i=0; i<2; ++i) { + // if (i) { + // aShift=aNbS; + // } + // for (j=1; j<=aNbS; ++j) { + // const TopoDS_Shape& aSx=aMSA.FindKey(j); + // const BooleanOperations_AncestorsSeqAndSuccessorsSeq& aASx= + // aMSA.FindFromIndex(j); + // InsertShapeAndAncestorsSuccessors(aSx, aASx, aShift); + // } + //} + + aShift=0; + for (j=1; j<=aNbS; ++j) { + const TopoDS_Shape& aSx=aMSA.FindKey(j); + const BooleanOperations_AncestorsSeqAndSuccessorsSeq& aASx=aMSA.FindFromIndex(j); + InsertShapeAndAncestorsSuccessors(aSx, aASx, aShift); } + // Contribution of Samtech www.samcef.com END // // myShapeIndexMap myShapeIndexMap.Clear(); @@ -156,7 +244,7 @@ iFirst=aR.First(); iLast =aR.Last(); for (j=iFirst; j<=iLast; ++j) { - const TopoDS_Shape& aS=GetShape(j); + const TopoDS_Shape& aS=Shape(j); aSIM.Add(aS, j); } myShapeIndexMap.Add(i, aSIM); @@ -244,14 +332,30 @@ if (!bFound) { return aIndex; } + // Modified Thu Sep 14 14:35:18 2006 + // Contribution of Samtech www.samcef.com BEGIN // - const BooleanOperations_IndexedDataMapOfShapeInteger& aSIM=myShapeIndexMap.FindFromKey(aRank); + //const BooleanOperations_IndexedDataMapOfShapeInteger& aSIM= + // myShapeIndexMap.FindFromKey(aRank); // - bFound=aSIM.Contains(aS); - if (!bFound) { - return aIndex; - } + //bFound=aSIM.Contains(aS); + //if (!bFound) { + // return aIndex; + //} // - aIndex=aSIM.FindFromKey(aS); + //aIndex=aSIM.FindFromKey(aS); + // + Standard_Integer i, aNbRanks; + // + aNbRanks=myShapeIndexMap.Extent(); + for (i=1; i<=aNbRanks; ++i){ + const BooleanOperations_IndexedDataMapOfShapeInteger& aSIM=myShapeIndexMap.FindFromKey(i); + bFound=aSIM.Contains(aS); + if (bFound) { + aIndex=aSIM.FindFromKey(aS); + return aIndex; + } + } + // Contribution of Samtech www.samcef.com END return aIndex; }