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