1 // Created on: 2004-03-05
2 // Created by: Mikhail KUZMITCHEV
3 // Copyright (c) 2004-2014 OPEN CASCADE SAS
5 // This file is part of Open CASCADE Technology software library.
7 // This library is free software; you can redistribute it and/or modify it under
8 // the terms of the GNU Lesser General Public License version 2.1 as published
9 // by the Free Software Foundation, with special exception defined in the file
10 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
11 // distribution for complete text of the license and disclaimer of any warranty.
13 // Alternatively, this file may be used under the terms of Open CASCADE
14 // commercial license or contractual agreement.
16 #include <QANCollection.hxx>
17 #include <Draw_Interpretor.hxx>
19 #include <OSD_PerfMeter.hxx>
21 #include <TColgp_Array1OfPnt.hxx>
22 #include <TColgp_SequenceOfPnt.hxx>
26 #include <NCollection_DefineArray1.hxx>
27 #include <NCollection_DefineSequence.hxx>
28 DEFINE_BASECOLLECTION (MyBaseCollPnt, gp_Pnt)
29 DEFINE_ARRAY1 (MyArray1, MyBaseCollPnt, gp_Pnt)
30 DEFINE_SEQUENCE (MySequence, MyBaseCollPnt, gp_Pnt)
32 #include <NCollection_Sequence.hxx>
33 #include <NCollection_Array1.hxx>
34 typedef NCollection_Array1<gp_Pnt> MyArray1;
35 typedef NCollection_Sequence<gp_Pnt> MySequence;
36 typedef NCollection_BaseCollection<gp_Pnt> MyBaseCollPnt;
38 void checkArray (const Standard_Boolean);
39 void checkSequence (const Standard_Boolean, const Standard_Boolean);
40 void createArray (TColgp_Array1OfPnt&);
41 void assignArray (TColgp_Array1OfPnt&, const TColgp_Array1OfPnt&);
42 void createSequence (TColgp_SequenceOfPnt&);
43 void assignSequence (TColgp_SequenceOfPnt&, const TColgp_SequenceOfPnt&);
45 void createArray (MyArray1&);
46 void assignArray (MyArray1&, const MyArray1&);
47 void createSequence (MySequence&);
48 void assignSequence (MySequence&, const MySequence&);
49 void assignCollection (MyBaseCollPnt&, const MyBaseCollPnt&, const char *);
50 void printAllMeters ();
52 void checkArray (const Standard_Boolean isNewColl)
55 MyArray1 anArrPnt (1, 100000), anArrPnt1 (1, 100000);
56 createArray (anArrPnt);
57 assignArray (anArrPnt1, anArrPnt);
58 assignCollection (anArrPnt1, anArrPnt, "Assign collect to array");
60 TColgp_Array1OfPnt anArrPnt (1,100000), anArrPnt1 (1, 100000);
61 createArray (anArrPnt);
62 assignArray (anArrPnt1, anArrPnt);
67 static Handle(NCollection_BaseAllocator) anAlloc[2];
69 Handle(NCollection_BaseAllocator) getAlloc (const int i)
71 return i == 0 ? anAlloc[0]: anAlloc[1];
74 void checkSequence (const Standard_Boolean isNewColl,
75 const Standard_Boolean isIncr)
79 anAlloc[0] = new NCollection_IncAllocator;
80 anAlloc[1] = new NCollection_IncAllocator;
82 MySequence aSeqPnt (anAlloc[0]), aSeqPnt1(anAlloc[1]);
83 createSequence (aSeqPnt);
84 assignSequence (aSeqPnt1, aSeqPnt);
85 assignCollection (aSeqPnt1, aSeqPnt, "Assign collect to sequence");
87 TColgp_SequenceOfPnt aSeqPnt, aSeqPnt1;
88 createSequence (aSeqPnt);
89 assignSequence (aSeqPnt1, aSeqPnt);
94 //=======================================================================
95 //function : QANColCheckArray1
97 //=======================================================================
98 static Standard_Integer QANColCheckArray1(Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
101 di << "Usage : " << argv[0] << " [-n]" << "\n";
105 Standard_Boolean isNewColl = Standard_False;
107 if (strcmp (argv[1], "-n") == 0) isNewColl = Standard_True;
109 checkArray (isNewColl);
113 //=======================================================================
114 //function : QANColCheckSequence
116 //=======================================================================
117 static Standard_Integer QANColCheckSequence(Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
120 di << "Usage : " << argv[0] << " [-n]/[-ni]/[-in]" << "\n";
124 Standard_Boolean isNewColl = Standard_False, isIncr = Standard_False;
126 if (strcmp (argv[1], "-n") == 0) isNewColl = Standard_True;
127 if (strcmp (argv[1], "-ni") == 0 || strcmp (argv[1], "-in") == 0)
129 isNewColl = Standard_True;
130 isIncr = Standard_True;
133 checkSequence (isNewColl, isIncr);
137 void QANCollection::Commands1(Draw_Interpretor& theCommands) {
138 const char *group = "QANCollection";
140 // from agvCollTest/src/AgvColEXE/TestEXE.cxx
141 theCommands.Add("QANColCheckArray1", "QANColCheckArray1 [-n]", __FILE__, QANColCheckArray1, group);
142 theCommands.Add("QANColCheckSequence", "QANColCheckSequence [-n]/[-ni]/[-in]", __FILE__, QANColCheckSequence, group);