summaryrefslogtreecommitdiff
path: root/src/BooleanOperations/BooleanOperations_AncestorsAndSuccessors.cxx
blob: 7ebebcb378020a54d1603a8848ff694ffd4a28f9 (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
// File:	BooleanOperations_AncestorsAndSuccessors.cxx
// Created:	Mon Jul 10 15:52:52 2000
// Author:	Vincent DELOS
//		<vds@bulox.paris1.matra-dtv.fr>


#include <BooleanOperations_AncestorsAndSuccessors.ixx>
#include <BooleanOperations_AncestorsSeqAndSuccessorsSeq.hxx>

//===========================================================================
//function : BooleanOperations_AncestorsAndSuccessors
//purpose  : default creator
//===========================================================================
  BooleanOperations_AncestorsAndSuccessors::BooleanOperations_AncestorsAndSuccessors():
 myAncestors(0L),
 mySuccessors(0L),
 myOrientations(0L),
 myAncestorsSize(0),
 mySuccessorsSize(0)
{
}


//===========================================================================
//function : BooleanOperations_AncestorsAndSuccessors
//purpose  : 
//===========================================================================
  BooleanOperations_AncestorsAndSuccessors::BooleanOperations_AncestorsAndSuccessors
                          (const BooleanOperations_AncestorsSeqAndSuccessorsSeq& AncSuc, 
			   const Standard_Integer shift) :
  
  myAncestors(0L),
  mySuccessors(0L),
  myOrientations(0L),
  myAncestorsSize(0),
  mySuccessorsSize(0)
{
  Standard_Integer i, j;
  //
  // Ancestors
  //
  myAncestorsSize  = AncSuc.NumberOfAncestors();
  if (myAncestorsSize) {
    myAncestors =      (Standard_Integer*)Standard::Allocate(myAncestorsSize*sizeof(Standard_Integer));

    for (i=1; i<=myAncestorsSize; i++) {
      ((Standard_Integer*)myAncestors)[i-1] = AncSuc.GetAncestor(i) + shift;
    }
  }
  //
  // Successors
  //
  mySuccessorsSize = AncSuc.NumberOfSuccessors();
  if (mySuccessorsSize) {
    mySuccessors   = (Standard_Integer*)  Standard::Allocate(mySuccessorsSize*sizeof(Standard_Integer));
    myOrientations = (TopAbs_Orientation*)Standard::Allocate(mySuccessorsSize*sizeof(TopAbs_Orientation));
    
    for (i=1; i<=mySuccessorsSize; i++)    {
      j=i-1;
      ((Standard_Integer*)mySuccessors    )[j] = AncSuc.GetSuccessor(i) + shift;
      ((TopAbs_Orientation*)myOrientations)[j] = AncSuc.GetOrientation(i);
    }
  }
}


//===========================================================================
//function : Destroy
//purpose  : destructor
//===========================================================================
  void BooleanOperations_AncestorsAndSuccessors::Destroy()
{
  if (myAncestors) {
    Standard::Free((Standard_Address&)myAncestors);
  }
  if (mySuccessors) {
    Standard::Free((Standard_Address&)mySuccessors);
  }
  if (myOrientations) {
    Standard::Free((Standard_Address&)myOrientations);
  }
}


//===========================================================================
//function : Dump
//purpose  : 
//===========================================================================
  void BooleanOperations_AncestorsAndSuccessors::Dump() const
{
  Standard_Integer i;

  cout<<endl<<"AncestorsAndSuccessors :";
  cout<<endl<<"myAncestorsSize = "<<myAncestorsSize<<endl;
  for (i=1;i<=NumberOfAncestors();i++)
    cout<<GetAncestor(i)<<" ";
  cout<<endl<<"mySuccessorsSize = "<<mySuccessorsSize<<endl;
  for (i=1;i<=NumberOfSuccessors();i++)
    cout<<GetSuccessor(i)<<" ";
  cout<<endl;
  for (i=1;i<=NumberOfSuccessors();i++)
    cout<<GetOrientation(i)<<" ";
  cout<<endl;
}