summaryrefslogtreecommitdiff
path: root/src/BOP/BOP_SolidSolidHistoryCollector.cxx
blob: 3834659624e3358e06241ee32bc57fc07134acba (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
#include <BOP_SolidSolidHistoryCollector.ixx>

#include <TopAbs.hxx>
#include <TopExp_Explorer.hxx>
#include <BooleanOperations_ShapesDataStructure.hxx>
#include <BooleanOperations_IndexedDataMapOfShapeInteger.hxx>
#include <BOPTools_SSInterference.hxx>
#include <BOPTools_InterferencePool.hxx>
#include <BOPTools_CArray1OfSSInterference.hxx>
#include <BOPTools_ListIteratorOfListOfPaveBlock.hxx>
#include <BOPTools_Curve.hxx>
#include <BOPTools_PaveBlock.hxx>
#include <BOPTools_DSFiller.hxx>
#include <BOPTools_PaveFiller.hxx>
#include <BOPTools_CommonBlock.hxx>
#include <BOPTools_ListOfCommonBlock.hxx>
#include <BOPTools_ListIteratorOfListOfCommonBlock.hxx>
#include <BOPTools_ListIteratorOfListOfPave.hxx>
#include <BOP_BuilderTools.hxx>
#include <TopTools_IndexedMapOfShape.hxx>
#include <TopExp.hxx>
#include <TColStd_ListIteratorOfListOfInteger.hxx>

// ======================================================================================================
// function: Constructor
// purpose:
// ======================================================================================================
BOP_SolidSolidHistoryCollector::BOP_SolidSolidHistoryCollector(const TopoDS_Shape&       theShape1,
							       const TopoDS_Shape&       theShape2,
							       const BOP_Operation       theOperation):
BOP_HistoryCollector(theShape1, theShape2, theOperation)
{
}

// ======================================================================================================
// function: AddNewShape
// purpose:
// warning: Treats only faces
// ======================================================================================================
void BOP_SolidSolidHistoryCollector::AddNewShape(const TopoDS_Shape&       theOldShape,
						 const TopoDS_Shape&       theNewShape,
						 const BOPTools_PDSFiller& theDSFiller) 
{
  if(theOldShape.ShapeType() != theNewShape.ShapeType())
    return;

  if(theOldShape.ShapeType() != TopAbs_FACE) {
    return;
  }
  Standard_Integer iRank = 0;
  const BooleanOperations_IndexedDataMapOfShapeInteger& aMap1 = 
    theDSFiller->DS().ShapeIndexMap(1);

  const BooleanOperations_IndexedDataMapOfShapeInteger& aMap2 = 
    theDSFiller->DS().ShapeIndexMap(2);

  if(aMap1.Contains(theOldShape))
    iRank = 1;
  else {
    if(aMap2.Contains(theOldShape))
      iRank = 2;
  }

  if(iRank == 0)
    return;

  TopTools_DataMapOfShapeListOfShape& aHistoryMap = myModifMap;

  if(aHistoryMap.IsBound(theOldShape)) {
    aHistoryMap.ChangeFind(theOldShape).Append(theNewShape);
  }
  else {
    TopTools_ListOfShape aShapeList;
    aShapeList.Append(theNewShape);
    aHistoryMap.Bind(theOldShape, aShapeList);
  }
}

// ======================================================================================================
// function: SetResult
// purpose:
// ======================================================================================================
void BOP_SolidSolidHistoryCollector::SetResult(const TopoDS_Shape&       theResult,
					       const BOPTools_PDSFiller& theDSFiller) 
{
  myResult = theResult;
  myHasDeleted = Standard_False;

  TopAbs_ShapeEnum aType = TopAbs_FACE;
  TopTools_IndexedMapOfShape aMap;
  TopExp::MapShapes(myResult, aType, aMap);

  TopExp_Explorer anExpObj(myS1, aType);

  for(; anExpObj.More(); anExpObj.Next()) {
    const TopoDS_Shape& aS = anExpObj.Current();

    if(!aMap.Contains(aS)) {

      if(!myModifMap.IsBound(aS) || myModifMap(aS).IsEmpty()) {

	if(!myGenMap.IsBound(aS) || myGenMap(aS).IsEmpty()) {
	  myHasDeleted = Standard_True;
	  break;
	}
      }
    }
  }

  if(!myHasDeleted) {
    TopExp_Explorer anExpTool(myS2, aType);

    for(; anExpTool.More(); anExpTool.Next()) {
      const TopoDS_Shape& aS = anExpTool.Current();

      if(!aMap.Contains(aS)) {
	if(!myModifMap.IsBound(aS) || myModifMap(aS).IsEmpty()) {

	  if(!myGenMap.IsBound(aS) || myGenMap(aS).IsEmpty()) {
	    myHasDeleted = Standard_True;
	    break;
	  }
	}
      }
    }
  }
}