b311480e |
1 | // Created on: 2001-03-14 |
2 | // Created by: Peter KURNEV |
3 | // Copyright (c) 2001-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 <BOPTools_CommonBlockAPI.ixx> |
23 | |
24 | #include <BOPTools_CommonBlock.hxx> |
25 | #include <BOPTools_PaveBlock.hxx> |
26 | #include <BOPTools_ListOfPaveBlock.hxx> |
27 | #include <BOPTools_ListOfCommonBlock.hxx> |
28 | #include <BOPTools_ListIteratorOfListOfCommonBlock.hxx> |
29 | #include <BOPTools_ListIteratorOfListOfPaveBlock.hxx> |
30 | |
31 | |
32 | //======================================================================= |
33 | // function: BOPTools_CommonBlockAPI::BOPTools_CommonBlockAPI |
34 | // purpose: |
35 | //======================================================================= |
b311480e |
36 | BOPTools_CommonBlockAPI::BOPTools_CommonBlockAPI |
7fd59977 |
37 | (const BOPTools_ListOfCommonBlock& aLCB) |
38 | { |
39 | myListOfCommonBlock=(void *)&aLCB; |
40 | } |
41 | //======================================================================= |
42 | // function: List |
43 | // purpose: |
44 | //======================================================================= |
45 | const BOPTools_ListOfCommonBlock& BOPTools_CommonBlockAPI::List () const |
46 | { |
47 | BOPTools_ListOfCommonBlock* pListOfCommonBlock= |
48 | (BOPTools_ListOfCommonBlock*)myListOfCommonBlock; |
49 | return *pListOfCommonBlock; |
50 | } |
51 | //======================================================================= |
52 | // function: CommonPaveBlocks |
53 | // purpose: get all CommonPaveBlocks |
54 | //======================================================================= |
55 | const BOPTools_ListOfPaveBlock& |
56 | BOPTools_CommonBlockAPI::CommonPaveBlocks |
57 | (const Standard_Integer anE) const |
58 | { |
59 | Standard_Integer anECurrent, i; |
60 | |
61 | BOPTools_ListOfPaveBlock* pmyListOfPaveBlock= |
62 | (BOPTools_ListOfPaveBlock*) &myListOfPaveBlock; |
63 | pmyListOfPaveBlock->Clear(); |
64 | |
65 | BOPTools_ListOfCommonBlock* pListOfCommonBlock= |
66 | (BOPTools_ListOfCommonBlock*)myListOfCommonBlock; |
67 | |
68 | BOPTools_ListIteratorOfListOfCommonBlock anIt(*pListOfCommonBlock); |
69 | for (; anIt.More(); anIt.Next()) { |
70 | const BOPTools_CommonBlock& aCB=anIt.Value(); |
71 | |
72 | for (i=0; i<2; i++) { |
73 | const BOPTools_PaveBlock& aPB=(!i) ? aCB.PaveBlock1() : aCB.PaveBlock2(); |
74 | anECurrent=aPB.OriginalEdge(); |
75 | if (anECurrent==anE) { |
76 | pmyListOfPaveBlock->Append(aPB); |
77 | break; |
78 | } |
79 | } |
80 | } |
81 | |
82 | return myListOfPaveBlock; |
83 | } |
84 | //======================================================================= |
85 | // function: IsCommonBlock |
86 | // purpose: |
87 | //======================================================================= |
88 | Standard_Boolean BOPTools_CommonBlockAPI::IsCommonBlock |
89 | (const BOPTools_PaveBlock& aPB) const |
90 | { |
91 | Standard_Integer anE; |
92 | |
93 | anE=aPB.OriginalEdge(); |
94 | |
95 | CommonPaveBlocks(anE); |
96 | |
97 | BOPTools_ListIteratorOfListOfPaveBlock anIt(myListOfPaveBlock); |
98 | for (; anIt.More(); anIt.Next()) { |
99 | const BOPTools_PaveBlock& aPB1=anIt.Value(); |
100 | if (aPB1.IsEqual(aPB)) { |
101 | return Standard_True; |
102 | } |
103 | } |
104 | return Standard_False; |
105 | } |
106 | |