1 // Copyright (c) 1995-1999 Matra Datavision
2 // Copyright (c) 1999-2012 OPEN CASCADE SAS
4 // The content of this file is subject to the Open CASCADE Technology Public
5 // License Version 6.5 (the "License"). You may not use the content of this file
6 // except in compliance with the License. Please obtain a copy of the License
7 // at http://www.opencascade.org and read it completely before using this file.
9 // The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
10 // main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
12 // The Original Code and all software distributed under the License is
13 // distributed on an "AS IS" basis, without warranty of any kind, and the
14 // Initial Developer hereby disclaims all such warranties, including without
15 // limitation, any warranties of merchantability, fitness for a particular
16 // purpose or non-infringement. Please see the License for the specific terms
17 // and conditions governing the rights and limitations under the License.
20 #include <OSD_Chronometer.hxx>
21 OSD_Chronometer Chronrsnld;
25 #include <NCollection_IncAllocator.hxx>
26 #include <Precision.hxx>
28 IntWalk_IWalking::IntWalk_IWalking (const Standard_Real Epsilon,
29 const Standard_Real Deflection,
30 const Standard_Real Increment ) :
35 epsilon(Epsilon*Epsilon),
36 wd1 (IntWalk_VectorOfWalkingData::allocator_type (new NCollection_IncAllocator)),
37 wd2 (wd1.get_allocator()),
38 nbMultiplicities (wd1.get_allocator()),
39 NbPointsConfondusConsecutifs(0),
40 EpsilonSembleTropGrand(0)
45 //=======================================================================
47 //purpose : Clears NCollection_Vector-based containers and adds
48 // dummy data to maintain start index of 1 and consistent with
49 // previous TCollection_Sequence-based implementation and other
50 // used TCollection-based containers
51 //=======================================================================
53 void IntWalk_IWalking::Clear()
57 IntWalk_WalkingData aDummy;
59 aDummy.ustart = aDummy.vstart = 0.;
60 wd1.push_back (aDummy);
61 wd2.push_back (aDummy);
62 nbMultiplicities.clear();
63 nbMultiplicities.push_back (-1);
65 done = Standard_False;
70 // ***************************************************************************
71 // etat1=12 not tangent, not passes
72 // etat1=11 tangent, not passes
73 // etat1=2 not tangent, passes
74 // etat1=1 tangent, passes
75 // after a point is processed its state becomes negative.
76 // ***************************************************************************
77 // etat2=13 interior start point on closed line
78 // etat2=12 interior start point on open line
79 // (line initially closed -> la line s is open)
80 // after a point is processed (or if it is passed over during
81 // routing) its state becomes negative.
82 // ****************************************************************************
85 // Perform with interior points
87 void IntWalk_IWalking::Perform(const ThePOPIterator& Pnts1,
88 const ThePOLIterator& Pnts2,
90 const ThePSurface& Caro,
91 const Standard_Boolean Reversed)
96 Standard_Boolean Rajout = Standard_False;
97 Standard_Integer nbPnts1 = Pnts1.Length();
98 Standard_Integer nbPnts2 = Pnts2.Length();
105 // Loading of etat1 and etat2 as well as ustart and vstart.
107 TColStd_SequenceOfReal Umult;
108 TColStd_SequenceOfReal Vmult;
110 Standard_Integer decal=0;
111 wd1.reserve (nbPnts1+decal);
112 nbMultiplicities.reserve (nbPnts1+decal);
113 for (I=1;I <= nbPnts1+decal; I++) {
114 const ThePointOfPath& PathPnt = Pnts1.Value(I-decal);
115 IntWalk_WalkingData aWD1;
117 if (!ThePointOfPathTool::IsPassingPnt(PathPnt))
119 if (!ThePointOfPathTool::IsTangent(PathPnt))
126 ThePointOfPathTool::Value2d(PathPnt, aWD1.ustart, aWD1.vstart);
127 wd1.push_back (aWD1);
128 Standard_Integer aNbMult = ThePointOfPathTool::Multiplicity(PathPnt);
129 nbMultiplicities.push_back(aNbMult);
131 for (Standard_Integer J = 1; J <= aNbMult; J++) {
132 ThePointOfPathTool::Parameters(PathPnt, J, U, V);
138 wd2.reserve (nbPnts2);
139 for (I = 1; I <= nbPnts2; I++) {
140 IntWalk_WalkingData aWD2;
142 ThePointOfLoopTool::Value2d(Pnts2.Value(I), aWD2.ustart, aWD2.vstart);
143 wd2.push_back (aWD2);
146 tolerance(1) = ThePSurfaceTool::UResolution(Caro,Precision::Confusion());
147 tolerance(2) = ThePSurfaceTool::VResolution(Caro,Precision::Confusion());
149 Um = ThePSurfaceTool::FirstUParameter(Caro);
150 Vm = ThePSurfaceTool::FirstVParameter(Caro);
151 UM = ThePSurfaceTool::LastUParameter(Caro);
152 VM = ThePSurfaceTool::LastVParameter(Caro);
155 Standard_Real utemp = UM;
160 Standard_Real vtemp = VM;
167 // calculation of all open lines
168 if (nbPnts1 != 0) ComputeOpenLine(Umult,Vmult,Pnts1,Func,Rajout);
169 // calculation of all closed lines
170 if (nbPnts2 != 0) ComputeCloseLine(Umult,Vmult,Pnts1,Pnts2,Func,Rajout);
171 for (I = 1; I <= nbPnts1; I++) {
172 if (wd1[I].etat >0) seqSingle.Append(Pnts1(I));
174 done = Standard_True;
180 // Perform without interior point
183 void IntWalk_IWalking::Perform(const ThePOPIterator& Pnts1,
185 const ThePSurface& Caro,
186 const Standard_Boolean Reversed)
190 Standard_Boolean Rajout = Standard_False;
191 Standard_Integer nbPnts1 = Pnts1.Length();
197 // Loading of etat1 as well as ustart1 and vstart1.
199 TColStd_SequenceOfReal Umult;
200 TColStd_SequenceOfReal Vmult;
202 wd1.reserve (nbPnts1);
203 for (I=1;I <= nbPnts1; I++) {
204 const ThePointOfPath& PathPnt = Pnts1.Value(I);
205 IntWalk_WalkingData aWD1;
207 if (!ThePointOfPathTool::IsPassingPnt(PathPnt)) aWD1.etat = 11;
208 if (!ThePointOfPathTool::IsTangent(PathPnt)) ++aWD1.etat;
209 ThePointOfPathTool::Value2d(PathPnt, aWD1.ustart, aWD1.vstart);
210 wd1.push_back (aWD1);
211 Standard_Integer aNbMult = ThePointOfPathTool::Multiplicity(PathPnt);
212 nbMultiplicities.push_back(aNbMult);
214 for (Standard_Integer J = 1; J <= aNbMult; J++) {
215 ThePointOfPathTool::Parameters(PathPnt, J, U, V);
221 tolerance(1) = ThePSurfaceTool::UResolution(Caro,Precision::Confusion());
222 tolerance(2) = ThePSurfaceTool::VResolution(Caro,Precision::Confusion());
224 Um = ThePSurfaceTool::FirstUParameter(Caro);
225 Vm = ThePSurfaceTool::FirstVParameter(Caro);
226 UM = ThePSurfaceTool::LastUParameter(Caro);
227 VM = ThePSurfaceTool::LastVParameter(Caro);
230 Standard_Real utemp = UM;
235 Standard_Real vtemp = VM;
242 // calcul de toutes les lignes ouvertes
243 if (nbPnts1 != 0) ComputeOpenLine(Umult,Vmult,Pnts1,Func,Rajout);
245 for (I = 1; I <= nbPnts1; I++) {
246 if (wd1[I].etat >0) seqSingle.Append(Pnts1(I));
248 done = Standard_True;