0024530: TKMesh - remove unused package IntPoly
[occt.git] / src / ShapeUpgrade / ShapeUpgrade_SplitCurve.cxx
CommitLineData
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//
973c2be1 8// This library is free software; you can redistribute it and / or modify it
9// under the terms of the GNU Lesser General Public 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.
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
19#include <ShapeUpgrade_SplitCurve.ixx>
20#include <Geom_BSplineCurve.hxx>
21#include <Precision.hxx>
22#include <ShapeUpgrade.hxx>
23#include <TColStd_ListIteratorOfListOfReal.hxx>
24#include <TColGeom_HArray1OfCurve.hxx>
25#include <TColStd_HSequenceOfReal.hxx>
26#include <ShapeExtend.hxx>
27
28//=======================================================================
29//function : ShapeUpgrade_SplitCurve
30//purpose :
31//=======================================================================
32
33ShapeUpgrade_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
60 void ShapeUpgrade_SplitCurve::SetSplitValues (const Handle(TColStd_HSequenceOfReal& SplitValues))
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
98const Handle(TColStd_HSequenceOfReal)& ShapeUpgrade_SplitCurve::SplitValues() const
99{
100 return mySplitValues;
101}
102
103//=======================================================================
104//function : Perform
105//purpose :
106//=======================================================================
107
108void 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//===================================================================
120void ShapeUpgrade_SplitCurve::Compute()
121{
122 myStatus = ShapeExtend::EncodeStatus (ShapeExtend_OK);
123}
124//=======================================================================
125//function : Status
126//purpose :
127//=======================================================================
128
129Standard_Boolean ShapeUpgrade_SplitCurve::Status(const ShapeExtend_Status status) const
130{
131 return ShapeExtend::DecodeStatus (myStatus, status);
132}