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,Standard_Transient)
31 //=======================================================================
32 //function : ShapeUpgrade_SplitCurve
34 //=======================================================================
35 ShapeUpgrade_SplitCurve::ShapeUpgrade_SplitCurve()
41 //=======================================================================
44 //=======================================================================
46 void ShapeUpgrade_SplitCurve::Init(const Standard_Real First,
47 const Standard_Real Last)
49 myStatus = ShapeExtend::EncodeStatus (ShapeExtend_OK);
50 // if (ShapeUpgrade::Debug()) std::cout << "SplitCurve::Init"<<std::endl;
53 // mySplitValues.Clear();
54 mySplitValues = new TColStd_HSequenceOfReal;
55 mySplitValues->Append(First);
56 mySplitValues->Append(Last);
59 //=======================================================================
60 //function : SetSplitValues
62 //=======================================================================
64 void ShapeUpgrade_SplitCurve::SetSplitValues (const Handle(TColStd_HSequenceOfReal)& SplitValues)
66 Standard_Real precision = Precision::PConfusion();
67 if(SplitValues.IsNull()) return;
68 if(SplitValues->Length()==0) return;
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));
86 //=======================================================================
89 //=======================================================================
91 void ShapeUpgrade_SplitCurve::Build(const Standard_Boolean /*Segment*/)
93 myStatus = ShapeExtend::EncodeStatus (ShapeExtend_OK);
97 //=======================================================================
98 //function : GlobalKnots
100 //=======================================================================
102 const Handle(TColStd_HSequenceOfReal)& ShapeUpgrade_SplitCurve::SplitValues() const
104 return mySplitValues;
107 //=======================================================================
110 //=======================================================================
112 void ShapeUpgrade_SplitCurve::Perform(const Standard_Boolean Segment)
115 //if ( ! mySplitValues.IsNull() )
116 // SetSplitValues(mySplitValues);
120 //=======================================================================
123 //===================================================================
124 void ShapeUpgrade_SplitCurve::Compute()
126 myStatus = ShapeExtend::EncodeStatus (ShapeExtend_OK);
128 //=======================================================================
131 //=======================================================================
133 Standard_Boolean ShapeUpgrade_SplitCurve::Status(const ShapeExtend_Status status) const
135 return ShapeExtend::DecodeStatus (myStatus, status);