// ****************************************************************************
//
//  $Id: cisSegment3D.h,v 1.1.1.1 2001/09/27 20:12:22 anton Exp $
//
//  Description:
//		Brief description of what this object or file does
//
//  Usage:
//		#include "header.hpp"  or other important usage information
//
//  See Also:
//		header.cpp  or other related files
//
//  Author(s):	Andrew Bzostek
//  Created on: dd/mm/yy
//
//
//              Developed by the Engineering Research Center for
//          Computer-Integrated Surgical Systems & Technology (CISST)
//
//               Copyright(c) 2001, The Johns Hopkins University
//                          All Rights Reserved.
//
//  Experimental Software - Not certified for clinical use.
//  For use only by CISST sponsored research projects.  For use outside of
//  CISST, please contact Dr. Russell Taylor, CISST Director, at rht@cs.jhu.edu
//  or Dr. Gabor Fichtinger, CISST Engineering Director, at gabor@cs.jhu.edu.
//  
// ****************************************************************************

#ifndef _cisSegment3D_h
#define _cisSegment3D_h



// Here are a few conditional compilation directives that are introduced to find if
// there are redundancies.
// Ofri, 2003-03-23

#define cisSegment3D_with_caching 0
#define cisSegment3D_copy_ctor cisSegment3D_with_caching 
#define cisSegment3D_op_assignment cisSegment3D_with_caching
#define cisSegment3D_mutable 0
#define cisSegment3D_Angle 0

#include <cisVecs.h>
#include <cisGeomObj3DCommon.h>
#include <cisGeomObj3DExport.h>

class cisEXPORT cisAbstractSegment3D
{
public:
	// The type used for local parametrization of points on the line
	typedef cisScalar ParametrizationType;

	// Type of angles
	typedef double AngleType;

	// The type that represents a point on the line
	typedef cisVec3 LocalPointType;

	// The type that represents the direction of the line
	typedef cisVec3 LocalDirectionType;

	// The type that represents any point in space
	typedef cisVec3 GlobalPointType;

	// The type that represents any direction in space
	typedef cisVec3 GlobalDirectionType;

	// Type of this class
	typedef cisSegment3D SelfType;

	

#if cisSegment3D_copy_ctor
	inline cisSegment3D(const cisSegment3D& L2);
#endif

	inline const cisVec3 & GetPoint1() const
	{ return Point1; }

	inline const cisVec3 & GetPoint2() const
	{ return Point2; }

#if cisSegment3D_mutable
	inline void Set(cisVec3 npt1, cisVec3 npt2);
#endif

#if cisSegment3D_mutable
	inline void SetFromLineParams(const cisLine3D& L, cisScalar p1, cisScalar p2);
#endif

#if cisSegment3D_Angle
	// return the phase angle of the projection of this segment on the XY plane,
	// in degrees.
	//
	// I doubt if this function is used at all. At any rate, it should return
	// radians and not degrees. Ofri, 2003-03-23
	inline cisScalar Angle(void) const;
#endif


	// return the length of this segment
	inline cisScalar GetLength(void) const;
	
	// return the normalized direction vector, from Point1 to Point2 of this segment
	inline cisVec3 GetDir(void) const;
	
	// return the difference vector Point2 - Point1
	inline cisVec3 Diff(void) const;
	
	// return the midpoint of this segment
	inline cisVec3 GetMidPoint(void) const;
	
	// evaluate the point parameterized by p: 
	// V = Point1 + p * (Point2 - Point1) == (1-p) * Point1 + p * Point2
	inline cisVec3 EvalAt(cisScalar p) const;
	
#if cisSegment3D_mutable
	// displace this segment by a given positive displacement
	inline cisSegment3D& operator += (cisVec3 disp);
	
	// displace this segment by a given positive displacement
	inline cisSegment3D& operator += (cisIntVec3 disp);
	
	// displace this segment by a given negative displacement
	inline cisSegment3D& operator -= (cisVec3 disp);
	
	// displace this segment by a given negative displacement
	inline cisSegment3D& operator -= (cisIntVec3 disp);
#endif
	
	inline cisSegment3D operator + (cisVec3 disp) const;
	
	inline cisSegment3D operator - (cisVec3 disp) const;
	
	inline cisSegment3D operator + (cisIntVec3 disp) const;
	
	inline cisSegment3D operator - (cisIntVec3 disp) const;
	
#if cisSegment3D_op_assignment
	inline cisSegment3D& operator = (const cisSegment3D& L2);
#endif

	inline cisBool operator == (const cisSegment3D& L2) const;
	
	inline cisBool operator != (const cisSegment3D& L2) const;
	
	inline cisScalar DistSqrToPt(cisVec3 test) const;
	
	// Returns a Vec2 where x is distance from pt1 along the line to the
	// pt on the line closest to test & y is the distance fromt this pt
	// to test
	inline cisVec2 TransPt(cisVec3 test) const;
};


#define _cisSegment3D_inl_h
#include "cisSegment3D-inl.h"
#undef _cisSegment3D_inl_h


#endif // CIS_GeomObj_Segment3D_HPP

// ****************************************************************************
//                              Change History
// ****************************************************************************
//
//  $Log: cisSegment3D.h,v $
//  Revision 1.1.1.1  2001/09/27 20:12:22  anton
//  Creation of new repository for CIS 2.
//
//
//  Older:
//
//  Revision 1.2  2001/04/26 15:30:19  anton
//  Include CISGeomObjExport.hpp and added EXPORT_xxx macros
//
//  Revision 1.1  2001/03/26 19:32:05  anton
//  Import of GeomObj within CIS from Andy Bzostek code with some formating and cleaning.  Add some -inl.hpp files.
//
//
// ****************************************************************************


