b311480e |
1 | // Created on: 1998-03-12 |
2 | // Created by: Pierre BARRAS |
3 | // Copyright (c) 1998-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. |
b311480e |
16 | |
7fd59977 |
17 | // gka 30.04.99 S4137: re-worked |
18 | |
7fd59977 |
19 | #include <Geom_BSplineCurve.hxx> |
20 | #include <Precision.hxx> |
42cf5bc1 |
21 | #include <ShapeExtend.hxx> |
7fd59977 |
22 | #include <ShapeUpgrade.hxx> |
42cf5bc1 |
23 | #include <ShapeUpgrade_SplitCurve.hxx> |
24 | #include <Standard_Type.hxx> |
7fd59977 |
25 | #include <TColGeom_HArray1OfCurve.hxx> |
26 | #include <TColStd_HSequenceOfReal.hxx> |
42cf5bc1 |
27 | #include <TColStd_ListIteratorOfListOfReal.hxx> |
7fd59977 |
28 | |
29 | //======================================================================= |
30 | //function : ShapeUpgrade_SplitCurve |
31 | //purpose : |
32 | //======================================================================= |
7fd59977 |
33 | ShapeUpgrade_SplitCurve::ShapeUpgrade_SplitCurve() : myStatus(0) |
34 | { |
35 | } |
36 | |
37 | //======================================================================= |
38 | //function : Init |
39 | //purpose : |
40 | //======================================================================= |
41 | |
42 | void ShapeUpgrade_SplitCurve::Init(const Standard_Real First, |
43 | const Standard_Real Last) |
44 | { |
45 | myStatus = ShapeExtend::EncodeStatus (ShapeExtend_OK); |
46 | // if (ShapeUpgrade::Debug()) cout << "SplitCurve::Init"<<endl; |
47 | |
48 | myNbCurves = 1; |
49 | // mySplitValues.Clear(); |
50 | mySplitValues = new TColStd_HSequenceOfReal; |
51 | mySplitValues->Append(First); |
52 | mySplitValues->Append(Last); |
53 | } |
54 | |
55 | //======================================================================= |
56 | //function : SetSplitValues |
57 | //purpose : |
58 | //======================================================================= |
59 | |
c04c30b3 |
60 | void ShapeUpgrade_SplitCurve::SetSplitValues (const Handle(TColStd_HSequenceOfReal)& SplitValues) |
7fd59977 |
61 | { |
62 | Standard_Real precision = Precision::PConfusion(); |
63 | if(SplitValues.IsNull()) return; |
64 | if(SplitValues->Length()==0) return; |
65 | |
66 | Standard_Real First = mySplitValues->Value(1), |
67 | Last = mySplitValues->Value(mySplitValues->Length()); |
68 | Standard_Integer i =1; |
69 | Standard_Integer len = SplitValues->Length(); |
70 | for( Standard_Integer k = 2;k <= mySplitValues->Length();k++) { |
71 | Last = mySplitValues->Value(k); |
72 | for(; i <= len; i++) { |
73 | if( (First + precision) >= SplitValues->Value(i)) continue; |
74 | if((Last - precision) <= SplitValues->Value(i)) break; |
75 | mySplitValues->InsertBefore(k++,SplitValues->Value(i)); |
76 | } |
77 | First = Last; |
78 | } |
79 | } |
80 | |
81 | |
82 | //======================================================================= |
83 | //function : Build |
84 | //purpose : |
85 | //======================================================================= |
86 | |
87 | void ShapeUpgrade_SplitCurve::Build(const Standard_Boolean /*Segment*/) |
88 | { |
89 | myStatus = ShapeExtend::EncodeStatus (ShapeExtend_OK); |
90 | } |
91 | |
92 | |
93 | //======================================================================= |
94 | //function : GlobalKnots |
95 | //purpose : |
96 | //======================================================================= |
97 | |
98 | const Handle(TColStd_HSequenceOfReal)& ShapeUpgrade_SplitCurve::SplitValues() const |
99 | { |
100 | return mySplitValues; |
101 | } |
102 | |
103 | //======================================================================= |
104 | //function : Perform |
105 | //purpose : |
106 | //======================================================================= |
107 | |
108 | void ShapeUpgrade_SplitCurve::Perform(const Standard_Boolean Segment) |
109 | { |
110 | Compute(); |
111 | //if ( ! mySplitValues.IsNull() ) |
112 | // SetSplitValues(mySplitValues); |
113 | Build(Segment); |
114 | |
115 | } |
116 | //======================================================================= |
117 | //function : Compute |
118 | //purpose : |
119 | //=================================================================== |
120 | void ShapeUpgrade_SplitCurve::Compute() |
121 | { |
122 | myStatus = ShapeExtend::EncodeStatus (ShapeExtend_OK); |
123 | } |
124 | //======================================================================= |
125 | //function : Status |
126 | //purpose : |
127 | //======================================================================= |
128 | |
129 | Standard_Boolean ShapeUpgrade_SplitCurve::Status(const ShapeExtend_Status status) const |
130 | { |
131 | return ShapeExtend::DecodeStatus (myStatus, status); |
132 | } |