1 // Created by: NW,JPB,CAL
2 // Copyright (c) 1991-1999 Matra Datavision
3 // Copyright (c) 1999-2012 OPEN CASCADE SAS
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.
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.
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.
25 //-Design Declaration of variables specific to the class
26 // describing marking.
28 //-Warning A return of marking is defined by :
29 // - sequence of (Elem_Num, Pick_Id, Structure)
39 #include <Visual3d_PickDescriptor.ixx>
43 //-Global data definitions
45 // -- sequence reperee
46 // MyPickPathSequence : HSequenceOfPickPath;
48 // -- contexte picking de reperage associe
49 // MyContext : ContextPick;
57 Visual3d_PickDescriptor::Visual3d_PickDescriptor (const Visual3d_ContextPick& CTXP):
60 MyPickPathSequence = new Visual3d_HSequenceOfPickPath ();
64 void Visual3d_PickDescriptor::AddPickPath (const Visual3d_PickPath& APickPath) {
66 if (MyContext.Depth () > MyPickPathSequence->Length ())
67 MyPickPathSequence->Append (APickPath);
71 void Visual3d_PickDescriptor::Clear () {
73 MyPickPathSequence->Clear ();
77 Standard_Integer Visual3d_PickDescriptor::Depth () const {
79 return (MyPickPathSequence->Length ());
83 Handle(Graphic3d_Structure) Visual3d_PickDescriptor::TopStructure () const {
85 Visual3d_PickPath Result;
87 if (MyPickPathSequence->IsEmpty ())
88 Visual3d_PickError::Raise ("PickDescriptor empty");
90 switch (MyContext.Order ()) {
92 case Visual3d_TOO_TOPFIRST :
93 // MyPickPathSequence->First returns the first
94 // PickPath found in the sequence.
95 Result = MyPickPathSequence->Sequence().First ();
98 case Visual3d_TOO_BOTTOMFIRST :
99 // MyPickPathSequence->Last returns the last
100 // PickPath found in the sequence.
101 Result = MyPickPathSequence->Sequence().Last ();
105 return (Result.StructIdentifier ());
108 Standard_Integer Visual3d_PickDescriptor::TopPickId () const {
110 Visual3d_PickPath Result;
112 if (MyPickPathSequence->IsEmpty ())
113 Visual3d_PickError::Raise ("PickDescriptor empty");
115 switch (MyContext.Order ()) {
117 case Visual3d_TOO_TOPFIRST :
118 // MyPickPathSequence->First returns the first
119 // PickPath found in the sequence.
120 Result = MyPickPathSequence->Sequence().First ();
123 case Visual3d_TOO_BOTTOMFIRST :
124 // MyPickPathSequence->Last returns the last
125 // PickPath found in the sequence.
126 Result = MyPickPathSequence->Sequence().Last ();
130 return (Result.PickIdentifier ());
133 Standard_Integer Visual3d_PickDescriptor::TopElementNumber () const {
135 Visual3d_PickPath Result;
137 if (MyPickPathSequence->IsEmpty ())
138 Visual3d_PickError::Raise ("PickDescriptor empty");
140 switch (MyContext.Order ()) {
142 case Visual3d_TOO_TOPFIRST :
143 // MyPickPathSequence->First returns the first
144 // PickPath found in the sequence.
145 Result = MyPickPathSequence->Sequence().First ();
148 case Visual3d_TOO_BOTTOMFIRST :
149 // MyPickPathSequence->Last returns the last
150 // PickPath found in the sequence.
151 Result = MyPickPathSequence->Sequence().Last ();
155 return (Result.ElementNumber ());
158 Handle(Visual3d_HSequenceOfPickPath) Visual3d_PickDescriptor::PickPath () const {
160 return (Handle(Visual3d_HSequenceOfPickPath)::DownCast
161 (MyPickPathSequence->ShallowCopy ()));