Test for 0022778: Bug in BRepMesh
[occt.git] / src / BooleanOperations / BooleanOperations_AncestorsAndSuccessors.cxx
CommitLineData
b311480e 1// Created on: 2000-07-10
2// Created by: Vincent DELOS
3// Copyright (c) 2000-2012 OPEN CASCADE SAS
4//
5// The content of this file is subject to the Open CASCADE Technology Public
6// License Version 6.5 (the "License"). You may not use the content of this file
7// except in compliance with the License. Please obtain a copy of the License
8// at http://www.opencascade.org and read it completely before using this file.
9//
10// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
11// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
12//
13// The Original Code and all software distributed under the License is
14// distributed on an "AS IS" basis, without warranty of any kind, and the
15// Initial Developer hereby disclaims all such warranties, including without
16// limitation, any warranties of merchantability, fitness for a particular
17// purpose or non-infringement. Please see the License for the specific terms
18// and conditions governing the rights and limitations under the License.
19
7fd59977 20
21
22#include <BooleanOperations_AncestorsAndSuccessors.ixx>
23#include <BooleanOperations_AncestorsSeqAndSuccessorsSeq.hxx>
24
25//===========================================================================
26//function : BooleanOperations_AncestorsAndSuccessors
27//purpose : default creator
28//===========================================================================
b311480e 29BooleanOperations_AncestorsAndSuccessors::BooleanOperations_AncestorsAndSuccessors():
7fd59977 30 myAncestors(0L),
31 mySuccessors(0L),
32 myOrientations(0L),
33 myAncestorsSize(0),
34 mySuccessorsSize(0)
35{
36}
37
38
39//===========================================================================
40//function : BooleanOperations_AncestorsAndSuccessors
41//purpose :
42//===========================================================================
43 BooleanOperations_AncestorsAndSuccessors::BooleanOperations_AncestorsAndSuccessors
44 (const BooleanOperations_AncestorsSeqAndSuccessorsSeq& AncSuc,
45 const Standard_Integer shift) :
46
47 myAncestors(0L),
48 mySuccessors(0L),
49 myOrientations(0L),
50 myAncestorsSize(0),
51 mySuccessorsSize(0)
52{
53 Standard_Integer i, j;
54 //
55 // Ancestors
56 //
57 myAncestorsSize = AncSuc.NumberOfAncestors();
58 if (myAncestorsSize) {
59 myAncestors = (Standard_Integer*)Standard::Allocate(myAncestorsSize*sizeof(Standard_Integer));
60
61 for (i=1; i<=myAncestorsSize; i++) {
62 ((Standard_Integer*)myAncestors)[i-1] = AncSuc.GetAncestor(i) + shift;
63 }
64 }
65 //
66 // Successors
67 //
68 mySuccessorsSize = AncSuc.NumberOfSuccessors();
69 if (mySuccessorsSize) {
70 mySuccessors = (Standard_Integer*) Standard::Allocate(mySuccessorsSize*sizeof(Standard_Integer));
71 myOrientations = (TopAbs_Orientation*)Standard::Allocate(mySuccessorsSize*sizeof(TopAbs_Orientation));
72
73 for (i=1; i<=mySuccessorsSize; i++) {
74 j=i-1;
75 ((Standard_Integer*)mySuccessors )[j] = AncSuc.GetSuccessor(i) + shift;
76 ((TopAbs_Orientation*)myOrientations)[j] = AncSuc.GetOrientation(i);
77 }
78 }
79}
80
81
82//===========================================================================
83//function : Destroy
84//purpose : destructor
85//===========================================================================
86 void BooleanOperations_AncestorsAndSuccessors::Destroy()
87{
88 if (myAncestors) {
89 Standard::Free((Standard_Address&)myAncestors);
90 }
91 if (mySuccessors) {
92 Standard::Free((Standard_Address&)mySuccessors);
93 }
94 if (myOrientations) {
95 Standard::Free((Standard_Address&)myOrientations);
96 }
97}
98
99
100//===========================================================================
101//function : Dump
102//purpose :
103//===========================================================================
104 void BooleanOperations_AncestorsAndSuccessors::Dump() const
105{
106 Standard_Integer i;
107
108 cout<<endl<<"AncestorsAndSuccessors :";
109 cout<<endl<<"myAncestorsSize = "<<myAncestorsSize<<endl;
110 for (i=1;i<=NumberOfAncestors();i++)
111 cout<<GetAncestor(i)<<" ";
112 cout<<endl<<"mySuccessorsSize = "<<mySuccessorsSize<<endl;
113 for (i=1;i<=NumberOfSuccessors();i++)
114 cout<<GetSuccessor(i)<<" ";
115 cout<<endl;
116 for (i=1;i<=NumberOfSuccessors();i++)
117 cout<<GetOrientation(i)<<" ";
118 cout<<endl;
119}