
// File		Visual3d_PickDescriptor.cxx
// Created	Fevrier 1992
// Author	NW,JPB,CAL

//-Copyright	MatraDatavision 1991,1992

//-Version	

//-Design	Declaration des variables specifiques a la classe
//		decrivant un reperage.

//-Warning	Un retour de reperage est defini par :
//		- une sequence de (Elem_Num, Pick_Id, Structure)
//		- une profondeur

//-References	

//-Language	C++ 2.0

//-Declarations

// for the class
#include <Visual3d_PickDescriptor.ixx>

//-Aliases

//-Global data definitions

//	-- sequence reperee
//	MyPickPathSequence	:	HSequenceOfPickPath;

//	-- contexte picking de reperage associe
//	MyContext		:	ContextPick;

//-Constructors

//-Destructors

//-Methods, in order

Visual3d_PickDescriptor::Visual3d_PickDescriptor (const Visual3d_ContextPick& CTXP):
MyContext (CTXP) {

	MyPickPathSequence	= new Visual3d_HSequenceOfPickPath ();

}

void Visual3d_PickDescriptor::AddPickPath (const Visual3d_PickPath& APickPath) {

	if (MyContext.Depth () > MyPickPathSequence->Length ())
		MyPickPathSequence->Append (APickPath);

}

void Visual3d_PickDescriptor::Clear () {

	MyPickPathSequence->Clear ();

}

Standard_Integer Visual3d_PickDescriptor::Depth () const {

	return (MyPickPathSequence->Length ());

}

Handle(Graphic3d_Structure) Visual3d_PickDescriptor::TopStructure () const {

Visual3d_PickPath Result;

	if (MyPickPathSequence->IsEmpty ())
		Visual3d_PickError::Raise ("PickDescriptor empty");

	switch (MyContext.Order ()) {

		case Visual3d_TOO_TOPFIRST :
			// MyPickPathSequence->First retourne le premier
			// PickPath qui se trouve dans la sequence.
			Result	= MyPickPathSequence->Sequence().First ();
		break;

		case Visual3d_TOO_BOTTOMFIRST :
			// MyPickPathSequence->Last retourne le dernier
			// PickPath qui se trouve dans la sequence.
			Result	= MyPickPathSequence->Sequence().Last ();
		break;

	}
	return (Result.StructIdentifier ());
}

Standard_Integer Visual3d_PickDescriptor::TopPickId () const {

Visual3d_PickPath Result;

	if (MyPickPathSequence->IsEmpty ())
		Visual3d_PickError::Raise ("PickDescriptor empty");

	switch (MyContext.Order ()) {

		case Visual3d_TOO_TOPFIRST :
			// MyPickPathSequence->First retourne le premier
			// PickPath qui se trouve dans la sequence.
			Result	= MyPickPathSequence->Sequence().First ();
		break;

		case Visual3d_TOO_BOTTOMFIRST :
			// MyPickPathSequence->Last retourne le dernier
			// PickPath qui se trouve dans la sequence.
			Result	= MyPickPathSequence->Sequence().Last ();
		break;

	}
	return (Result.PickIdentifier ());
}

Standard_Integer Visual3d_PickDescriptor::TopElementNumber () const {

Visual3d_PickPath Result;

	if (MyPickPathSequence->IsEmpty ())
		Visual3d_PickError::Raise ("PickDescriptor empty");

	switch (MyContext.Order ()) {

		case Visual3d_TOO_TOPFIRST :
			// MyPickPathSequence->First retourne le premier
			// PickPath qui se trouve dans la sequence.
			Result	= MyPickPathSequence->Sequence().First ();
		break;

		case Visual3d_TOO_BOTTOMFIRST :
			// MyPickPathSequence->Last retourne le dernier
			// PickPath qui se trouve dans la sequence.
			Result	= MyPickPathSequence->Sequence().Last ();
		break;

	}
	return (Result.ElementNumber ());
}

Handle(Visual3d_HSequenceOfPickPath) Visual3d_PickDescriptor::PickPath () const {

	return (Handle(Visual3d_HSequenceOfPickPath)::DownCast
					(MyPickPathSequence->ShallowCopy ()));

}
