b311480e |
1 | // Created on: 2004-03-05 |
2 | // Created by: Mikhail KUZMITCHEV |
3 | // Copyright (c) 2004-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 <QANCollection.hxx> |
23 | #include <Draw_Interpretor.hxx> |
24 | |
25 | #include <DebugTools.h> |
26 | |
27 | #include <TColgp_Array1OfPnt.hxx> |
28 | #include <TColgp_SequenceOfPnt.hxx> |
29 | |
30 | #define USE_MACROS |
31 | #ifdef USE_MACROS |
32 | #include <NCollection_DefineArray1.hxx> |
33 | #include <NCollection_DefineSequence.hxx> |
34 | DEFINE_BASECOLLECTION (MyBaseCollPnt, gp_Pnt) |
35 | DEFINE_ARRAY1 (MyArray1, MyBaseCollPnt, gp_Pnt) |
36 | DEFINE_SEQUENCE (MySequence, MyBaseCollPnt, gp_Pnt) |
37 | #else |
38 | #include <NCollection_Sequence.hxx> |
39 | #include <NCollection_Array1.hxx> |
40 | typedef NCollection_Array1<gp_Pnt> MyArray1; |
41 | typedef NCollection_Sequence<gp_Pnt> MySequence; |
42 | typedef NCollection_BaseCollection<gp_Pnt> MyBaseCollPnt; |
43 | #endif |
44 | void checkArray (const Standard_Boolean); |
45 | void checkSequence (const Standard_Boolean, const Standard_Boolean); |
46 | void createArray (TColgp_Array1OfPnt&); |
47 | void assignArray (TColgp_Array1OfPnt&, const TColgp_Array1OfPnt&); |
48 | void createSequence (TColgp_SequenceOfPnt&); |
49 | void assignSequence (TColgp_SequenceOfPnt&, const TColgp_SequenceOfPnt&); |
50 | |
51 | void createArray (MyArray1&); |
52 | void assignArray (MyArray1&, const MyArray1&); |
53 | void createSequence (MySequence&); |
54 | void assignSequence (MySequence&, const MySequence&); |
55 | void assignCollection (MyBaseCollPnt&, const MyBaseCollPnt&, const char *); |
56 | void printAllMeters (); |
57 | |
58 | void checkArray (const Standard_Boolean isNewColl) |
59 | { |
60 | if (isNewColl) { |
61 | MyArray1 anArrPnt (1, 100000), anArrPnt1 (1, 100000); |
62 | createArray (anArrPnt); |
63 | assignArray (anArrPnt1, anArrPnt); |
64 | assignCollection (anArrPnt1, anArrPnt, "Assign collect to array"); |
65 | } else { |
66 | TColgp_Array1OfPnt anArrPnt (1,100000), anArrPnt1 (1, 100000); |
67 | createArray (anArrPnt); |
68 | assignArray (anArrPnt1, anArrPnt); |
69 | } |
70 | printAllMeters (); |
71 | } |
72 | |
73 | static Handle(NCollection_BaseAllocator) anAlloc[2]; |
74 | |
75 | Handle(NCollection_BaseAllocator) getAlloc (const int i) |
76 | { |
77 | return i == 0 ? anAlloc[0]: anAlloc[1]; |
78 | } |
79 | |
80 | void checkSequence (const Standard_Boolean isNewColl, |
81 | const Standard_Boolean isIncr) |
82 | { |
83 | if (isNewColl) { |
84 | if (isIncr) { |
85 | anAlloc[0] = new NCollection_IncAllocator; |
86 | anAlloc[1] = new NCollection_IncAllocator; |
87 | } |
88 | MySequence aSeqPnt (anAlloc[0]), aSeqPnt1(anAlloc[1]); |
89 | createSequence (aSeqPnt); |
90 | assignSequence (aSeqPnt1, aSeqPnt); |
91 | assignCollection (aSeqPnt1, aSeqPnt, "Assign collect to sequence"); |
92 | } else { |
93 | TColgp_SequenceOfPnt aSeqPnt, aSeqPnt1; |
94 | createSequence (aSeqPnt); |
95 | assignSequence (aSeqPnt1, aSeqPnt); |
96 | } |
97 | printAllMeters (); |
98 | } |
99 | |
100 | //======================================================================= |
101 | //function : QANColCheckArray1 |
102 | //purpose : |
103 | //======================================================================= |
104 | static Standard_Integer QANColCheckArray1(Draw_Interpretor& di, Standard_Integer argc, const char ** argv) |
105 | { |
106 | if ( argc > 2) { |
107 | di << "Usage : " << argv[0] << " [-n]" << "\n"; |
108 | return 1; |
109 | } |
110 | |
111 | Standard_Boolean isNewColl = Standard_False; |
112 | if (argc > 1) { |
113 | if (strcmp (argv[1], "-n") == 0) isNewColl = Standard_True; |
114 | } |
115 | checkArray (isNewColl); |
116 | return 0; |
117 | } |
118 | |
119 | //======================================================================= |
120 | //function : QANColCheckSequence |
121 | //purpose : |
122 | //======================================================================= |
123 | static Standard_Integer QANColCheckSequence(Draw_Interpretor& di, Standard_Integer argc, const char ** argv) |
124 | { |
125 | if ( argc > 2) { |
126 | di << "Usage : " << argv[0] << " [-n]/[-ni]/[-in]" << "\n"; |
127 | return 1; |
128 | } |
129 | |
130 | Standard_Boolean isNewColl = Standard_False, isIncr = Standard_False; |
131 | if (argc > 1) { |
132 | if (strcmp (argv[1], "-n") == 0) isNewColl = Standard_True; |
133 | if (strcmp (argv[1], "-ni") == 0 || strcmp (argv[1], "-in") == 0) |
134 | { |
135 | isNewColl = Standard_True; |
136 | isIncr = Standard_True; |
137 | } |
138 | } |
139 | checkSequence (isNewColl, isIncr); |
140 | return 0; |
141 | } |
142 | |
143 | void QANCollection::Commands1(Draw_Interpretor& theCommands) { |
144 | char *group = "QANCollection"; |
145 | |
146 | // from agvCollTest/src/AgvColEXE/TestEXE.cxx |
147 | theCommands.Add("QANColCheckArray1", "QANColCheckArray1 [-n]", __FILE__, QANColCheckArray1, group); |
148 | theCommands.Add("QANColCheckSequence", "QANColCheckSequence [-n]/[-ni]/[-in]", __FILE__, QANColCheckSequence, group); |
149 | |
150 | return; |
151 | } |