b311480e |
1 | // Created on: 1992-10-02 |
2 | // Created by: Remi GILET |
3 | // Copyright (c) 1992-1999 Matra Datavision |
973c2be1 |
4 | // Copyright (c) 1999-2014 OPEN CASCADE SAS |
b311480e |
5 | // |
973c2be1 |
6 | // This file is part of Open CASCADE Technology software library. |
b311480e |
7 | // |
d5f74e42 |
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 |
973c2be1 |
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. |
b311480e |
13 | // |
973c2be1 |
14 | // Alternatively, this file may be used under the terms of Open CASCADE |
15 | // commercial license or contractual agreement. |
7fd59977 |
16 | |
42cf5bc1 |
17 | |
18 | #include <ElCLib.hxx> |
7fd59977 |
19 | #include <GC_MakeLine.hxx> |
42cf5bc1 |
20 | #include <GC_MakeSegment.hxx> |
7fd59977 |
21 | #include <Geom_Line.hxx> |
42cf5bc1 |
22 | #include <Geom_TrimmedCurve.hxx> |
23 | #include <gp_Lin.hxx> |
24 | #include <gp_Pnt.hxx> |
7fd59977 |
25 | #include <StdFail_NotDone.hxx> |
7fd59977 |
26 | |
27 | GC_MakeSegment::GC_MakeSegment(const gp_Pnt& P1 , |
28 | const gp_Pnt& P2 ) |
29 | { |
30 | Standard_Real dist = P1.Distance(P2); |
31 | Handle(Geom_Line) L = GC_MakeLine(P1,P2); |
32 | TheSegment = new Geom_TrimmedCurve(L,0.,dist,Standard_True); |
33 | TheError = gce_Done; |
34 | } |
35 | |
36 | GC_MakeSegment::GC_MakeSegment(const gp_Lin& Line , |
37 | const gp_Pnt& Point , |
38 | const Standard_Real U ) |
39 | { |
40 | Standard_Real Ufirst = ElCLib::Parameter(Line,Point); |
41 | Handle(Geom_Line) L = new Geom_Line(Line); |
42 | TheSegment=new Geom_TrimmedCurve(L,Ufirst,U,Standard_True); |
43 | TheError = gce_Done; |
44 | } |
45 | |
46 | GC_MakeSegment::GC_MakeSegment(const gp_Lin& Line , |
47 | const gp_Pnt& P1 , |
48 | const gp_Pnt& P2 ) |
49 | { |
50 | Standard_Real Ufirst = ElCLib::Parameter(Line,P1); |
51 | Standard_Real Ulast = ElCLib::Parameter(Line,P2); |
52 | Handle(Geom_Line) L = new Geom_Line(Line); |
53 | TheSegment = new Geom_TrimmedCurve(L,Ufirst,Ulast,Standard_True); |
54 | TheError = gce_Done; |
55 | } |
56 | |
57 | GC_MakeSegment::GC_MakeSegment(const gp_Lin& Line , |
58 | const Standard_Real U1 , |
59 | const Standard_Real U2 ) |
60 | { |
61 | Handle(Geom_Line) L = new Geom_Line(Line); |
62 | TheSegment = new Geom_TrimmedCurve(L,U1,U2,Standard_True); |
63 | TheError = gce_Done; |
64 | } |
65 | |
66 | const Handle(Geom_TrimmedCurve)& GC_MakeSegment::Value() const |
67 | { |
82fc327c |
68 | StdFail_NotDone_Raise_if(TheError != gce_Done,""); |
7fd59977 |
69 | return TheSegment; |
70 | } |