e2498196d849a996fb4767e2588fd9b51d693e29
[occt.git] / src / GCE2d / GCE2d_MakeSegment.hxx
1 // Created on: 1992-09-28
2 // Created by: Remi GILET
3 // Copyright (c) 1992-1999 Matra Datavision
4 // Copyright (c) 1999-2014 OPEN CASCADE SAS
5 //
6 // This file is part of Open CASCADE Technology software library.
7 //
8 // This library is free software; you can redistribute it and/or modify it under
9 // the terms of the GNU Lesser General Public License version 2.1 as published
10 // by the Free Software Foundation, with special exception defined in the file
11 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
12 // distribution for complete text of the license and disclaimer of any warranty.
13 //
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
16
17 #ifndef _GCE2d_MakeSegment_HeaderFile
18 #define _GCE2d_MakeSegment_HeaderFile
19
20 #include <Standard.hxx>
21 #include <Standard_DefineAlloc.hxx>
22 #include <Standard_Handle.hxx>
23
24 #include <GCE2d_Root.hxx>
25 #include <Geom2d_TrimmedCurve.hxx>
26
27 class StdFail_NotDone;
28 class gp_Pnt2d;
29 class gp_Dir2d;
30 class gp_Lin2d;
31
32
33 //! Implements construction algorithms for a line
34 //! segment in the plane. The result is a
35 //! Geom2d_TrimmedCurve curve.
36 //! A MakeSegment object provides a framework for:
37 //! -   defining the construction of the line segment,
38 //! -   implementing the construction algorithm, and
39 //! -   consulting the results. In particular, the Value
40 //! function returns the constructed line segment.
41 class GCE2d_MakeSegment  : public GCE2d_Root
42 {
43 public:
44
45   DEFINE_STANDARD_ALLOC
46
47   
48   //! Make a segment of Line from the 2 points <P1> and <P2>.
49   //! Status is "ConfusedPoints" if <P1> and <P2> are confused.
50   Standard_EXPORT GCE2d_MakeSegment(const gp_Pnt2d& P1, const gp_Pnt2d& P2);
51   
52   //! Make a segment of Line from the point <P1> with
53   //! the direction <P> and ended by the projection of
54   //! <P2> on the line <P1,V>.
55   //! Status is "ConfusedPoints" if <P1> and <P2> are confused.
56   Standard_EXPORT GCE2d_MakeSegment(const gp_Pnt2d& P1, const gp_Dir2d& V, const gp_Pnt2d& P2);
57   
58   //! Make a segment of Line from the line <Line>
59   //! between the two parameters U1 and U2.
60   //! Status is "SameParamters" if <U1> is equal <U2>.
61   Standard_EXPORT GCE2d_MakeSegment(const gp_Lin2d& Line, const Standard_Real U1, const Standard_Real U2);
62   
63   //! Make a segment of Line from the line <Line>
64   //! between the point <Point> and the parameter Ulast.
65   //! It returns NullObject if <U1> is equal <U2>.
66   Standard_EXPORT GCE2d_MakeSegment(const gp_Lin2d& Line, const gp_Pnt2d& Point, const Standard_Real Ulast);
67   
68   //! Make a segment of Line from the line <Line>
69   //! between the two points <P1> and <P2>.
70   //! It returns NullObject if <P1> and <P2> are confused.
71   //! Warning
72   //! If the points which limit the segment are coincident
73   //! for given points or for the projection of given points
74   //! on the line which supports the line segment (that is,
75   //! when IsDone returns false), the Status function
76   //! returns gce_ConfusedPoints. This warning only
77   //! concerns the first two constructors.
78   Standard_EXPORT GCE2d_MakeSegment(const gp_Lin2d& Line, const gp_Pnt2d& P1, const gp_Pnt2d& P2);
79   
80   //! Returns the constructed line segment.
81   //! Exceptions StdFail_NotDone if no line segment is constructed.
82   Standard_EXPORT const Handle(Geom2d_TrimmedCurve)& Value() const;
83
84   operator const Handle(Geom2d_TrimmedCurve)& () const { return Value(); }
85
86 private:
87   Handle(Geom2d_TrimmedCurve) TheSegment;
88 };
89
90 #endif // _GCE2d_MakeSegment_HeaderFile