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
6 // This file is part of Open CASCADE Technology software library.
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.
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
17 // gka 30.04.99 S4137: re-worked
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>
29 IMPLEMENT_STANDARD_RTTIEXT(ShapeUpgrade_SplitCurve,MMgt_TShared)
31 //=======================================================================
32 //function : ShapeUpgrade_SplitCurve
34 //=======================================================================
35 ShapeUpgrade_SplitCurve::ShapeUpgrade_SplitCurve() : myStatus(0)
39 //=======================================================================
42 //=======================================================================
44 void ShapeUpgrade_SplitCurve::Init(const Standard_Real First,
45 const Standard_Real Last)
47 myStatus = ShapeExtend::EncodeStatus (ShapeExtend_OK);
48 // if (ShapeUpgrade::Debug()) cout << "SplitCurve::Init"<<endl;
51 // mySplitValues.Clear();
52 mySplitValues = new TColStd_HSequenceOfReal;
53 mySplitValues->Append(First);
54 mySplitValues->Append(Last);
57 //=======================================================================
58 //function : SetSplitValues
60 //=======================================================================
62 void ShapeUpgrade_SplitCurve::SetSplitValues (const Handle(TColStd_HSequenceOfReal)& SplitValues)
64 Standard_Real precision = Precision::PConfusion();
65 if(SplitValues.IsNull()) return;
66 if(SplitValues->Length()==0) return;
68 Standard_Real First = mySplitValues->Value(1),
69 Last = mySplitValues->Value(mySplitValues->Length());
70 Standard_Integer i =1;
71 Standard_Integer len = SplitValues->Length();
72 for( Standard_Integer k = 2;k <= mySplitValues->Length();k++) {
73 Last = mySplitValues->Value(k);
74 for(; i <= len; i++) {
75 if( (First + precision) >= SplitValues->Value(i)) continue;
76 if((Last - precision) <= SplitValues->Value(i)) break;
77 mySplitValues->InsertBefore(k++,SplitValues->Value(i));
84 //=======================================================================
87 //=======================================================================
89 void ShapeUpgrade_SplitCurve::Build(const Standard_Boolean /*Segment*/)
91 myStatus = ShapeExtend::EncodeStatus (ShapeExtend_OK);
95 //=======================================================================
96 //function : GlobalKnots
98 //=======================================================================
100 const Handle(TColStd_HSequenceOfReal)& ShapeUpgrade_SplitCurve::SplitValues() const
102 return mySplitValues;
105 //=======================================================================
108 //=======================================================================
110 void ShapeUpgrade_SplitCurve::Perform(const Standard_Boolean Segment)
113 //if ( ! mySplitValues.IsNull() )
114 // SetSplitValues(mySplitValues);
118 //=======================================================================
121 //===================================================================
122 void ShapeUpgrade_SplitCurve::Compute()
124 myStatus = ShapeExtend::EncodeStatus (ShapeExtend_OK);
126 //=======================================================================
129 //=======================================================================
131 Standard_Boolean ShapeUpgrade_SplitCurve::Status(const ShapeExtend_Status status) const
133 return ShapeExtend::DecodeStatus (myStatus, status);