Commit | Line | Data |
---|---|---|
b311480e | 1 | // Created on: 1997-03-01 |
2 | // Created by: MPS | |
3 | // Copyright (c) 1997-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 | // |
d5f74e42 | 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 | |
973c2be1 | 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 | // Modified by MPS (14-04-97) traitement des cas ou il n'y a pas |
18 | // d'intersection entre les stripes | |
19 | // Modified by MPS (16-06-97) : on tient compte du fait que GeomPlate | |
20 | // rend les courbes 2d dans meme ordre que les | |
21 | // courbes frontieres passees en entree | |
22 | // Modified by JLR (20-08-97) mise en place des nouveaux constructeurs de GeomPlate | |
7fd59977 | 23 | // Modified by MPS (03-11-97) on ne cree pas un batten lorsque le rapport |
24 | // entre les deux resolutions sur la surface est trop grand (PRO10649) | |
7fd59977 | 25 | // Modified by MPS (05-12-97) on ne tient pas compte des aretes degenerees |
26 | // lors du calcul du nombre d'aretes. | |
7fd59977 | 27 | // Modified by JCT (08-12-97) traitement des aretes vives consecutives ou non |
28 | // (grille EDC412 sauf D2, L1, L2, L3) | |
7fd59977 | 29 | // Modified by JCT (11-12-97) pb osf avec indpoint + orientation de plate |
30 | // ( --> D2, L1, L2, L3 valides mais laids) | |
7fd59977 | 31 | // Modified by MPS (24-02-98) traitement des aretes de regularite |
7fd59977 | 32 | // Modified by MPS (01-06-98) traitement des aretes de couture |
33 | // Modified by MPS (01-12-98) traitement des bords libres | |
34 | // Modified by MPS (01-02-99) traitement des aretes de regularite | |
35 | // consecutives | |
36 | // Traitement des coins | |
37 | ||
c22b52d6 | 38 | #include <Adaptor2d_Curve2d.hxx> |
7fd59977 | 39 | #include <Adaptor3d_CurveOnSurface.hxx> |
c22b52d6 | 40 | #include <Adaptor3d_Surface.hxx> |
42cf5bc1 | 41 | #include <Adaptor3d_TopolTool.hxx> |
42 | #include <AppBlend_Approx.hxx> | |
43 | #include <Blend_CurvPointFuncInv.hxx> | |
44 | #include <Blend_FuncInv.hxx> | |
45 | #include <Blend_Function.hxx> | |
46 | #include <Blend_RstRstFunction.hxx> | |
47 | #include <Blend_SurfCurvFuncInv.hxx> | |
48 | #include <Blend_SurfPointFuncInv.hxx> | |
49 | #include <Blend_SurfRstFunction.hxx> | |
7fd59977 | 50 | #include <Bnd_Box2d.hxx> |
51 | #include <BndLib_Add2dCurve.hxx> | |
52 | #include <BRep_Tool.hxx> | |
c22b52d6 | 53 | #include <BRepAdaptor_Curve2d.hxx> |
54 | #include <BRepAdaptor_Surface.hxx> | |
7fd59977 | 55 | #include <BRepAlgo_NormalProjection.hxx> |
42cf5bc1 | 56 | #include <BRepBlend_Line.hxx> |
57 | #include <BRepLib_MakeEdge.hxx> | |
58 | #include <BRepLib_MakeFace.hxx> | |
59 | #include <BRepTools.hxx> | |
60 | #include <BRepTopAdaptor_TopolTool.hxx> | |
61 | #include <ChFi3d_Builder.hxx> | |
7fd59977 | 62 | #include <ChFi3d_Builder_0.hxx> |
42cf5bc1 | 63 | #include <ChFiDS_CommonPoint.hxx> |
7fd59977 | 64 | #include <ChFiDS_FaceInterference.hxx> |
42cf5bc1 | 65 | #include <ChFiDS_HData.hxx> |
c22b52d6 | 66 | #include <ChFiDS_ElSpine.hxx> |
7fd59977 | 67 | #include <ChFiDS_ListIteratorOfListOfStripe.hxx> |
42cf5bc1 | 68 | #include <ChFiDS_Regul.hxx> |
7fd59977 | 69 | #include <ChFiDS_SequenceOfSurfData.hxx> |
42cf5bc1 | 70 | #include <ChFiDS_Spine.hxx> |
7fd59977 | 71 | #include <ChFiDS_Stripe.hxx> |
7fd59977 | 72 | #include <ChFiDS_StripeArray1.hxx> |
42cf5bc1 | 73 | #include <ChFiDS_SurfData.hxx> |
7fd59977 | 74 | #include <Extrema_ExtCC.hxx> |
7fd59977 | 75 | #include <Extrema_ExtPC.hxx> |
42cf5bc1 | 76 | #include <Extrema_POnCurv.hxx> |
77 | #include <FairCurve_Batten.hxx> | |
7fd59977 | 78 | #include <Geom2d_BSplineCurve.hxx> |
42cf5bc1 | 79 | #include <Geom2d_Curve.hxx> |
7fd59977 | 80 | #include <Geom2d_Line.hxx> |
7fd59977 | 81 | #include <Geom2d_TrimmedCurve.hxx> |
c22b52d6 | 82 | #include <Geom2dAdaptor_Curve.hxx> |
42cf5bc1 | 83 | #include <Geom2dLProp_CLProps2d.hxx> |
84 | #include <Geom_BezierCurve.hxx> | |
85 | #include <Geom_BSplineSurface.hxx> | |
86 | #include <Geom_Curve.hxx> | |
87 | #include <Geom_Line.hxx> | |
88 | #include <Geom_Surface.hxx> | |
89 | #include <GeomAdaptor.hxx> | |
c22b52d6 | 90 | #include <GeomAdaptor_Surface.hxx> |
7fd59977 | 91 | #include <GeomInt_IntSS.hxx> |
92 | #include <GeomLib.hxx> | |
7fd59977 | 93 | #include <GeomPlate_BuildPlateSurface.hxx> |
42cf5bc1 | 94 | #include <GeomPlate_CurveConstraint.hxx> |
465e6861 | 95 | #include <GeomPlate_HArray1OfHCurve.hxx> |
7fd59977 | 96 | #include <GeomPlate_MakeApprox.hxx> |
97 | #include <GeomPlate_PlateG0Criterion.hxx> | |
42cf5bc1 | 98 | #include <GeomPlate_Surface.hxx> |
99 | #include <gp_Dir2d.hxx> | |
7fd59977 | 100 | #include <gp_Pnt.hxx> |
101 | #include <gp_Pnt2d.hxx> | |
7fd59977 | 102 | #include <math_Matrix.hxx> |
103 | #include <PLib.hxx> | |
42cf5bc1 | 104 | #include <Precision.hxx> |
105 | #include <Standard_ConstructionError.hxx> | |
106 | #include <Standard_NoSuchObject.hxx> | |
107 | #include <Standard_OutOfRange.hxx> | |
108 | #include <TColGeom2d_Array1OfCurve.hxx> | |
109 | #include <TColGeom2d_HArray1OfCurve.hxx> | |
110 | #include <TColGeom2d_SequenceOfCurve.hxx> | |
111 | #include <TColGeom_Array1OfCurve.hxx> | |
112 | #include <TColGeom_SequenceOfCurve.hxx> | |
7fd59977 | 113 | #include <TColgp_Array1OfPnt.hxx> |
114 | #include <TColgp_Array1OfPnt2d.hxx> | |
42cf5bc1 | 115 | #include <TColgp_Array1OfXYZ.hxx> |
116 | #include <TColgp_SequenceOfXY.hxx> | |
117 | #include <TColgp_SequenceOfXYZ.hxx> | |
7fd59977 | 118 | #include <TColStd_Array1OfBoolean.hxx> |
42cf5bc1 | 119 | #include <TColStd_Array1OfInteger.hxx> |
7fd59977 | 120 | #include <TColStd_Array1OfReal.hxx> |
42cf5bc1 | 121 | #include <TColStd_Array2OfInteger.hxx> |
7fd59977 | 122 | #include <TColStd_Array2OfReal.hxx> |
42cf5bc1 | 123 | #include <TColStd_HArray1OfInteger.hxx> |
124 | #include <TColStd_ListOfInteger.hxx> | |
7fd59977 | 125 | #include <TopAbs_Orientation.hxx> |
126 | #include <TopExp.hxx> | |
42cf5bc1 | 127 | #include <TopExp_Explorer.hxx> |
128 | #include <TopoDS_Edge.hxx> | |
129 | #include <TopoDS_Face.hxx> | |
130 | #include <TopoDS_Shape.hxx> | |
131 | #include <TopoDS_Vertex.hxx> | |
132 | #include <TopOpeBRepBuild_HBuilder.hxx> | |
7fd59977 | 133 | #include <TopOpeBRepDS_Curve.hxx> |
42cf5bc1 | 134 | #include <TopOpeBRepDS_CurvePointInterference.hxx> |
135 | #include <TopOpeBRepDS_DataStructure.hxx> | |
136 | #include <TopOpeBRepDS_HDataStructure.hxx> | |
137 | #include <TopOpeBRepDS_Kind.hxx> | |
7fd59977 | 138 | #include <TopOpeBRepDS_ListOfInterference.hxx> |
42cf5bc1 | 139 | #include <TopOpeBRepDS_Point.hxx> |
7fd59977 | 140 | #include <TopOpeBRepDS_SolidSurfaceInterference.hxx> |
42cf5bc1 | 141 | #include <TopOpeBRepDS_Surface.hxx> |
7fd59977 | 142 | #include <TopOpeBRepDS_SurfaceCurveInterference.hxx> |
42cf5bc1 | 143 | #include <TopOpeBRepDS_Transition.hxx> |
7fd59977 | 144 | #include <TopTools_Array2OfShape.hxx> |
42cf5bc1 | 145 | #include <TopTools_IndexedMapOfShape.hxx> |
3f54cc41 | 146 | #include <ChFi3d.hxx> |
42cf5bc1 | 147 | |
7fd59977 | 148 | // performances |
0797d9d3 | 149 | #ifdef OCCT_DEBUG |
7fd59977 | 150 | #include <OSD_Chronometer.hxx> |
151 | extern Standard_Real t_plate ,t_approxplate,t_batten; | |
152 | extern void ChFi3d_InitChron(OSD_Chronometer& ch); | |
153 | extern void ChFi3d_ResultChron(OSD_Chronometer & ch,Standard_Real& time); | |
154 | #endif | |
155 | ||
7fd59977 | 156 | |
157 | //======================================================================= | |
158 | //function : Indices | |
159 | //purpose : | |
160 | //======================================================================= | |
161 | ||
162 | static void Indices ( const Standard_Integer n, | |
163 | const Standard_Integer ic, | |
164 | Standard_Integer & icplus, | |
165 | Standard_Integer & icmoins) | |
166 | { | |
167 | if (ic== (n-1)) icplus=0; | |
168 | else icplus=ic+1; | |
169 | if (ic==0) icmoins=n-1; | |
170 | else icmoins=ic-1; | |
171 | } | |
172 | ||
173 | //======================================================================= | |
174 | //function : Calcul_Param | |
175 | //purpose : | |
176 | //======================================================================= | |
177 | ||
178 | static void Calcul_Param (const Handle(ChFiDS_Stripe)& stripe, | |
179 | const Standard_Integer jfposit, | |
180 | const Standard_Integer indice, | |
181 | const Standard_Boolean isfirst, | |
182 | Standard_Real & param) | |
183 | { | |
184 | if (jfposit==2 ) | |
185 | param=stripe->SetOfSurfData()->Value(indice)->InterferenceOnS2().Parameter(isfirst); | |
186 | else | |
187 | param=stripe->SetOfSurfData()->Value(indice)->InterferenceOnS1().Parameter(isfirst); | |
188 | } | |
189 | ||
190 | //======================================================================= | |
191 | //function : Calcul_P2dOnSurf | |
192 | //purpose : | |
193 | //======================================================================= | |
194 | ||
195 | static void Calcul_P2dOnSurf(const Handle(ChFiDS_Stripe)& stripe, | |
196 | const Standard_Integer jfposit, | |
197 | const Standard_Integer indice, | |
198 | const Standard_Real param, | |
199 | gp_Pnt2d & p2) | |
200 | ||
201 | { | |
202 | if (jfposit==1) | |
203 | stripe->SetOfSurfData()->Value(indice) | |
204 | ->InterferenceOnS1().PCurveOnSurf()->D0(param,p2); | |
205 | else | |
206 | stripe->SetOfSurfData()->Value(indice) | |
207 | ->InterferenceOnS2().PCurveOnSurf()->D0(param,p2); | |
208 | } | |
209 | ||
210 | //======================================================================= | |
211 | //function : Calcul_C2dOnFace | |
212 | //purpose : | |
213 | //======================================================================= | |
214 | ||
215 | static void Calcul_C2dOnFace (const Handle(ChFiDS_Stripe)& stripe, | |
216 | const Standard_Integer jfposit, | |
217 | const Standard_Integer indice, | |
218 | Handle(Geom2d_Curve) & c2d) | |
219 | ||
220 | { | |
221 | if (jfposit==1) | |
222 | c2d = stripe->SetOfSurfData()->Value(indice) | |
223 | ->InterferenceOnS1().PCurveOnFace(); | |
224 | else | |
225 | c2d = stripe->SetOfSurfData()->Value(indice) | |
226 | ->InterferenceOnS2().PCurveOnFace(); | |
227 | } | |
228 | ||
229 | //======================================================================= | |
230 | //function : Calcul_Orientation | |
231 | //purpose : | |
232 | //======================================================================= | |
233 | ||
234 | static void Calcul_Orientation(const Handle(ChFiDS_Stripe)& stripe, | |
235 | const Standard_Integer jfposit, | |
236 | const Standard_Integer indice, | |
237 | TopAbs_Orientation & orient) | |
238 | { | |
239 | if (jfposit==1) | |
240 | orient = stripe->SetOfSurfData()->Value(indice) | |
241 | ->InterferenceOnS1().Transition(); | |
242 | else | |
243 | orient = stripe->SetOfSurfData()->Value(indice) | |
244 | ->InterferenceOnS2().Transition(); | |
245 | } | |
246 | ||
247 | //======================================================================= | |
248 | //function : RemoveSD | |
249 | //purpose : | |
250 | //======================================================================= | |
251 | ||
252 | static void RemoveSD(Handle(ChFiDS_Stripe)& Stripe, | |
253 | const Standard_Integer num1, | |
254 | const Standard_Integer num2 ) | |
255 | { | |
256 | ChFiDS_SequenceOfSurfData& Seq = | |
257 | Stripe->ChangeSetOfSurfData()->ChangeSequence(); | |
258 | if(Seq.IsEmpty()) return; | |
259 | if (num1==num2) | |
260 | Seq.Remove(num1); | |
261 | else | |
262 | Seq.Remove(num1,num2); | |
263 | } | |
264 | ||
265 | //======================================================================= | |
266 | //function : cherche_edge1 | |
81bba717 | 267 | //purpose : find common edge of faces F1 and F2 |
7fd59977 | 268 | //======================================================================= |
269 | ||
270 | static void cherche_edge1 (const TopoDS_Face & F1, | |
271 | const TopoDS_Face & F2, | |
272 | TopoDS_Edge & Edge) | |
273 | { Standard_Integer i,j; | |
274 | TopoDS_Edge Ecur1,Ecur2; | |
275 | Standard_Boolean trouve=Standard_False; | |
276 | TopTools_IndexedMapOfShape MapE1,MapE2; | |
277 | TopExp::MapShapes( F1,TopAbs_EDGE,MapE1); | |
278 | TopExp::MapShapes( F2,TopAbs_EDGE,MapE2); | |
279 | for ( i=1; i<= MapE1.Extent()&&!trouve; i++) | |
280 | { | |
281 | TopoDS_Shape aLocalShape = TopoDS_Shape (MapE1(i)); | |
282 | Ecur1=TopoDS::Edge(aLocalShape); | |
283 | // Ecur1=TopoDS::Edge(TopoDS_Shape (MapE1(i))); | |
284 | for ( j=1; j<= MapE2.Extent()&&!trouve; j++) | |
285 | { | |
286 | aLocalShape = TopoDS_Shape (MapE2(j)); | |
287 | Ecur2=TopoDS::Edge(aLocalShape); | |
288 | // Ecur2=TopoDS::Edge(TopoDS_Shape (MapE2(j))); | |
289 | if (Ecur2.IsSame(Ecur1)) | |
290 | {Edge=Ecur1;trouve=Standard_True;} | |
291 | } | |
292 | } | |
293 | } | |
294 | ||
295 | //======================================================================= | |
296 | //function : CurveHermite | |
81bba717 | 297 | //purpose : calculate a curve 3d using polynoms of Hermite. |
298 | // the edge is a regular edge. Curve 3D is constructed | |
299 | // between edges icmoins and icplus. | |
7fd59977 | 300 | //======================================================================= |
301 | ||
302 | static void CurveHermite (const TopOpeBRepDS_DataStructure& DStr, | |
303 | const Handle(ChFiDS_Stripe)& CDicmoins, | |
304 | const Standard_Integer jficmoins, | |
305 | const Standard_Integer icmoins, | |
306 | const Standard_Real picmoins, | |
307 | const Standard_Integer sensicmoins, | |
308 | const Standard_Boolean sharpicmoins, | |
309 | const TopoDS_Edge & Eviveicmoins, | |
310 | const Handle(ChFiDS_Stripe)& CDicplus, | |
311 | const Standard_Integer jficplus, | |
312 | const Standard_Integer icplus, | |
313 | const Standard_Real picplus, | |
314 | const Standard_Integer sensicplus, | |
315 | const Standard_Boolean sharpicplus, | |
316 | const TopoDS_Edge & Eviveicplus, | |
317 | const Standard_Integer nbface, | |
318 | TopTools_SequenceOfShape & Ecom, | |
319 | const TopTools_SequenceOfShape & Face, | |
320 | TColGeom2d_SequenceOfCurve & proj2d, | |
321 | TColGeom_SequenceOfCurve & cproj, | |
322 | TopTools_SequenceOfShape & Eproj, | |
323 | TColStd_SequenceOfReal & param, | |
324 | Standard_Real & error) | |
325 | { | |
326 | gp_Pnt p01,p02; | |
327 | gp_Vec d11,d12; | |
328 | Standard_Integer ii,jj; | |
329 | Standard_Real up1,up2; | |
330 | Standard_Integer ilin,jfp; | |
331 | Handle (Geom_Curve) c1,c2; | |
332 | if (sharpicmoins) { | |
333 | c1=BRep_Tool::Curve(Eviveicmoins,up1,up2); | |
334 | } | |
335 | else { | |
336 | if (jficmoins==1) | |
337 | ilin= CDicmoins->SetOfSurfData()->Value( icmoins)->InterferenceOnS1().LineIndex(); | |
338 | else ilin= CDicmoins->SetOfSurfData()->Value(icmoins)->InterferenceOnS2().LineIndex(); | |
339 | c1=DStr.Curve(ilin).Curve(); | |
340 | } | |
341 | if (sharpicplus){ | |
342 | c2=BRep_Tool::Curve(Eviveicplus,up1,up2); | |
343 | } | |
344 | else { | |
345 | jfp=3-jficplus; | |
346 | if (jfp==1) | |
347 | ilin= CDicplus->SetOfSurfData()->Value( icplus)->InterferenceOnS1().LineIndex(); | |
348 | else ilin=CDicplus->SetOfSurfData()->Value(icplus)->InterferenceOnS2().LineIndex(); | |
349 | c2=DStr.Curve(ilin ).Curve(); | |
350 | } | |
351 | c1->D1(picmoins,p01,d11); | |
352 | c2->D1(picplus,p02,d12); | |
353 | Standard_Integer size = 4; | |
354 | math_Matrix MatCoefs(1,size, 1,size); | |
355 | TColgp_Array1OfXYZ Cont(1,size); | |
356 | PLib::HermiteCoefficients(0, 1,1,1,MatCoefs); | |
357 | Standard_Real L1=p01.Distance(p02); | |
358 | Standard_Real lambda= ((Standard_Real)1) / Max (d11.Magnitude() / L1, 1.e-6); | |
359 | Cont(1) = p01.XYZ(); | |
360 | if (sensicmoins==1) Cont(2) = d11.XYZ()*(-lambda) ; | |
361 | else Cont(2) = d11.XYZ()*(lambda) ; | |
362 | lambda= ((Standard_Real)1) / Max (d12.Magnitude() / L1, 1.e-6); | |
363 | Cont(3) = p02.XYZ(); | |
364 | if (sensicplus==1) Cont(4) = d12.XYZ()*(lambda); | |
365 | else Cont(4) = d12.XYZ()*(-lambda); | |
366 | TColgp_Array1OfPnt ExtrapPoles(1, size); | |
367 | TColgp_Array1OfPnt ExtraCoeffs(1, size); | |
368 | gp_Pnt p0(0,0,0); | |
369 | ExtraCoeffs.Init(p0); | |
370 | for (ii=1; ii<=size; ii++) { | |
371 | for (jj=1; jj<=size; jj++) { | |
372 | ExtraCoeffs(jj).ChangeCoord() += MatCoefs(ii,jj)*Cont(ii); | |
373 | } | |
374 | } | |
375 | PLib::CoefficientsPoles(ExtraCoeffs, PLib::NoWeights(), | |
376 | ExtrapPoles, PLib::NoWeights()); | |
377 | Handle(Geom_BezierCurve) Bezier = new (Geom_BezierCurve) (ExtrapPoles); | |
378 | BRepLib_MakeEdge Bedge (Bezier); | |
379 | TopoDS_Edge edg =Bedge. Edge(); | |
380 | TopoDS_Face F; | |
381 | error=1.e-30; | |
382 | Standard_Integer nb; | |
383 | for(nb=1;nb<=nbface;nb++){ | |
384 | F=TopoDS::Face(Face.Value(nb)); | |
385 | TopTools_IndexedMapOfShape MapE1; | |
386 | TopoDS_Edge E1; | |
387 | Handle(Geom2d_Curve) proj1; | |
388 | Handle(Geom_Curve) proj1c,proj2c; | |
389 | BRepAlgo_NormalProjection OrtProj; | |
390 | OrtProj.Init(F); | |
391 | OrtProj.Add(edg); | |
392 | OrtProj.SetParams(1.e-4, 1.e-4, GeomAbs_C1, 14, 16); | |
393 | OrtProj.Build(); | |
394 | if ( OrtProj.IsDone()){ | |
395 | TopExp::MapShapes(OrtProj.Projection() , TopAbs_EDGE, MapE1); | |
396 | if (MapE1.Extent()!=0){ | |
397 | if (MapE1.Extent()!=1) { | |
1c72dff6 | 398 | BRepLib_MakeFace Bface (BRep_Tool::Surface(F), Precision::Confusion()); |
7fd59977 | 399 | F=Bface.Face(); |
400 | OrtProj.Init(F); | |
401 | OrtProj.Build(); | |
402 | MapE1.Clear(); | |
403 | if ( OrtProj.IsDone()) | |
404 | TopExp::MapShapes(OrtProj.Projection() ,TopAbs_EDGE, MapE1); | |
405 | } | |
406 | if (MapE1.Extent()!=0) { | |
407 | Standard_Boolean trouve=Standard_False; | |
408 | for (Standard_Integer ind=1;ind<=MapE1.Extent()&&!trouve;ind++){ | |
409 | TopoDS_Shape aLocalShape = TopoDS_Shape( MapE1(ind)); | |
410 | E1=TopoDS::Edge( aLocalShape ); | |
411 | // E1=TopoDS::Edge( TopoDS_Shape (MapE1(ind))); | |
412 | if (!BRep_Tool::Degenerated(E1)) trouve=Standard_True; | |
413 | } | |
414 | Eproj.Append(E1); | |
415 | proj1=BRep_Tool::CurveOnSurface(E1,F,up1,up2); | |
416 | proj2d.Append(new Geom2d_TrimmedCurve(proj1,up1,up2)); | |
417 | proj1c=BRep_Tool::Curve(E1,up1,up2); | |
418 | cproj.Append(new Geom_TrimmedCurve(proj1c,up1,up2)); | |
419 | if (error>BRep_Tool::Tolerance(E1)) error=BRep_Tool::Tolerance(E1); | |
420 | } | |
421 | else { | |
422 | Eproj.Append(E1); | |
423 | proj2d.Append(proj1); | |
424 | cproj.Append(proj1c); | |
425 | } | |
426 | } | |
427 | else { | |
428 | Eproj.Append(E1); | |
429 | proj2d.Append(proj1); | |
430 | cproj.Append(proj1c); | |
431 | } | |
432 | } | |
433 | } | |
434 | for (nb=1;nb<=nbface-1;nb++) { | |
435 | BRepAdaptor_Curve C(TopoDS::Edge(Ecom.Value(nb))); | |
436 | C.D0(param.Value(nb),p02); | |
437 | GeomAdaptor_Curve L (Bezier); | |
438 | Extrema_ExtCC ext (C,L); | |
439 | if (ext.IsDone()){ | |
94beb42a | 440 | if (!ext.IsParallel() && ext.NbExt()!=0){ |
7fd59977 | 441 | Extrema_POnCurv POnC, POnL; |
442 | ext.Points(1, POnC, POnL); | |
4bbaf12b | 443 | if (POnC.Value().Distance(POnL.Value()) < Precision::Confusion()) |
444 | param.ChangeValue(nb) =POnC.Parameter(); | |
445 | else | |
446 | { | |
447 | if (!cproj.Value(nb).IsNull()) { | |
448 | cproj.Value(nb)->D0(cproj.Value(nb)->LastParameter(),p01); | |
449 | } | |
450 | else if (!cproj.Value(nb+1).IsNull()) { | |
451 | cproj.Value(nb+1)->D0(cproj.Value(nb+1)->FirstParameter(),p01); | |
452 | } | |
453 | } | |
7fd59977 | 454 | } |
455 | } | |
456 | if (!ext.IsDone()||ext.NbExt()==0) { | |
457 | if (!cproj.Value(nb).IsNull()) { | |
458 | cproj.Value(nb)->D0(cproj.Value(nb)->LastParameter(),p01); | |
459 | } | |
460 | else if (!cproj.Value(nb+1).IsNull()) { | |
461 | cproj.Value(nb+1)->D0(cproj.Value(nb+1)->FirstParameter(),p01); | |
462 | } | |
463 | if (p01.Distance(p02)>1.e-4 ){ | |
464 | Extrema_ExtPC ext1 (p01,C); | |
465 | if (ext1.IsDone()){ | |
466 | if (ext1.NbExt()!=0){ | |
467 | Extrema_POnCurv POnC(ext1.Point(1)); | |
468 | param.ChangeValue(nb) =POnC.Parameter(); | |
469 | } | |
470 | } | |
471 | } | |
472 | } | |
473 | } | |
474 | } | |
475 | ||
476 | //======================================================================= | |
477 | //function : CalculDroite | |
81bba717 | 478 | //purpose : calculate a 2D straight line passing through point p2d1 and direction xdir ydir |
7fd59977 | 479 | //======================================================================= |
480 | ||
481 | static void CalculDroite(const gp_Pnt2d & p2d1, | |
482 | const Standard_Real xdir, | |
483 | const Standard_Real ydir, | |
484 | Handle (Geom2d_Curve) & pcurve) | |
485 | { gp_Dir2d dir1 (xdir, ydir); | |
486 | Handle(Geom2d_Line) l= new Geom2d_Line (p2d1,dir1); | |
487 | Standard_Real l0 = sqrt(xdir*xdir+ ydir*ydir ); | |
488 | pcurve = new Geom2d_TrimmedCurve(l,0,l0); | |
489 | } | |
490 | ||
491 | //======================================================================= | |
492 | //function : CalculBatten | |
81bba717 | 493 | //purpose : calcule a batten between curves 2d curv2d1 and curv2d2 at points p2d1 and p2d2 |
7fd59977 | 494 | //======================================================================= |
495 | ||
c22b52d6 | 496 | static void CalculBatten (const Handle (GeomAdaptor_Surface) ASurf, |
7fd59977 | 497 | const TopoDS_Face Face , |
498 | const Standard_Real xdir, | |
499 | const Standard_Real ydir, | |
500 | const gp_Pnt2d & p2d1, | |
501 | const gp_Pnt2d & p2d2, | |
502 | const Standard_Boolean contraint1, | |
503 | const Standard_Boolean contraint2, | |
504 | Handle (Geom2d_Curve) & curv2d1, | |
505 | Handle (Geom2d_Curve) & curv2d2, | |
506 | const Standard_Real picicplus, | |
507 | const Standard_Real picplusic, | |
508 | const Standard_Boolean inverseic, | |
509 | const Standard_Boolean inverseicplus, | |
510 | Handle (Geom2d_Curve)& pcurve) | |
511 | { | |
512 | Standard_Boolean isplane; | |
7fd59977 | 513 | Standard_Boolean anglebig = Standard_False; |
7fd59977 | 514 | isplane=ASurf->GetType()==GeomAbs_Plane; |
515 | gp_Dir2d dir1 (xdir, ydir); | |
516 | Geom2dLProp_CLProps2d CL1(curv2d1, picicplus, 1, 1.e-4); | |
517 | Geom2dLProp_CLProps2d CL2( curv2d2, picplusic, 1, 1.e-4); | |
518 | gp_Dir2d dir3,dir4 ; | |
519 | CL1.Tangent(dir3); | |
520 | CL2.Tangent(dir4); | |
521 | if (inverseic) dir3.Reverse(); | |
522 | if (inverseicplus) dir4.Reverse(); | |
523 | Standard_Real h = p2d2.Distance(p2d1)/20; | |
524 | FairCurve_Batten Bat(p2d1,p2d2,h); | |
525 | Bat.SetFreeSliding (Standard_True); | |
526 | Standard_Real ang1,ang2; | |
527 | ang1=dir1.Angle(dir3); | |
c6541a0c D |
528 | if (dir1.Angle(dir4) >0 ) ang2=M_PI-dir1.Angle(dir4); |
529 | else ang2=-M_PI-dir1.Angle(dir4); | |
7fd59977 | 530 | if (contraint1&&contraint2) |
531 | anglebig=(Abs(ang1)>1.2)|| (Abs(ang2)>1.2 ); | |
532 | else if (contraint1) | |
533 | anglebig=Abs(ang1)>1.2; | |
534 | else if (contraint2) | |
535 | anglebig=Abs(ang2)>1.2; | |
c6541a0c | 536 | if (isplane && (Abs(ang1)>M_PI/2 || Abs(ang2)>M_PI/2)) |
7fd59977 | 537 | isplane=Standard_False; |
538 | if (anglebig && !isplane) { | |
539 | CalculDroite(p2d1,xdir,ydir,pcurve); | |
540 | } | |
541 | else { | |
542 | if (contraint1) Bat.SetAngle1(ang1); | |
543 | else Bat.SetConstraintOrder1(0); | |
544 | if (contraint2) Bat.SetAngle2(ang2); | |
545 | else Bat.SetConstraintOrder2(0); | |
546 | FairCurve_AnalysisCode Iana; | |
547 | Standard_Boolean Ok; | |
548 | Ok = Bat.Compute(Iana,25,1.e-2); | |
0797d9d3 | 549 | #ifdef OCCT_DEBUG |
7fd59977 | 550 | if (!Ok) { |
04232180 | 551 | std::cout<<"no batten :"; |
552 | Bat.Dump(std::cout); | |
7fd59977 | 553 | } |
554 | #endif | |
555 | if (Ok) { | |
556 | pcurve = Bat.Curve(); | |
557 | Standard_Real umin,vmin,umax,vmax; | |
558 | BRepTools::UVBounds(Face,umin,umax,vmin,vmax); | |
559 | Bnd_Box2d bf,bc; | |
560 | Geom2dAdaptor_Curve acur(pcurve); | |
561 | BndLib_Add2dCurve::Add(acur,0,bc); | |
562 | bf.Update(umin,vmin,umax,vmax); | |
563 | Standard_Real uminc,vminc,umaxc,vmaxc; | |
564 | bc.Get(uminc,vminc,umaxc,vmaxc); | |
565 | if (uminc<umin-1.e-7) Ok=Standard_False; | |
566 | if (umaxc>umax+1.e-7) Ok=Standard_False; | |
567 | if (vminc<vmin-1.e-7) Ok=Standard_False; | |
568 | if (vmaxc>vmax+1.e-7) Ok=Standard_False; | |
569 | } | |
570 | if (!Ok) CalculDroite(p2d1, xdir,ydir, pcurve); | |
571 | } | |
572 | } | |
573 | ||
574 | //======================================================================= | |
575 | //function : OrientationIcNonVive | |
81bba717 | 576 | //purpose : calculate the orientation of the curve between ic and icplus knowing that ic |
577 | // is not a living edge. | |
7fd59977 | 578 | //======================================================================= |
579 | ||
580 | static void OrientationIcNonVive (const Handle(ChFiDS_Stripe) & CDic, | |
581 | const Standard_Integer jfic, | |
582 | const Standard_Integer icicplus, | |
583 | const Standard_Integer sensic, | |
584 | TopAbs_Orientation & orien ) | |
585 | { | |
586 | TopAbs_Orientation orinterf; | |
587 | Calcul_Orientation(CDic,jfic,icicplus,orinterf); | |
588 | if (sensic!=1){ | |
589 | if (orinterf==TopAbs_FORWARD) orien=TopAbs_FORWARD; | |
590 | else orien=TopAbs_REVERSED; | |
591 | } | |
592 | else { | |
593 | if (orinterf==TopAbs_FORWARD) orien=TopAbs_REVERSED; | |
594 | else orien=TopAbs_FORWARD; | |
595 | } | |
596 | } | |
597 | ||
598 | //======================================================================= | |
599 | //function : OrientationIcplusNonVive | |
81bba717 | 600 | //purpose : calculate the orientation of the curve between ic and icplus knowing that icplus |
601 | // is not a living edge; | |
7fd59977 | 602 | //======================================================================= |
603 | ||
604 | static void OrientationIcplusNonVive (const Handle(ChFiDS_Stripe) & CDicplus, | |
605 | const Standard_Integer jficplus, | |
606 | const Standard_Integer icplusic, | |
607 | const Standard_Integer sensicplus, | |
608 | TopAbs_Orientation & orien ) | |
609 | { | |
610 | TopAbs_Orientation orinterf; | |
611 | Standard_Integer jfp = 3 -jficplus; | |
612 | Calcul_Orientation(CDicplus,jfp,icplusic,orinterf); | |
613 | if (sensicplus==1){ | |
614 | if (orinterf==TopAbs_FORWARD) orien=TopAbs_FORWARD; | |
615 | else orien=TopAbs_REVERSED; | |
616 | } | |
617 | else { | |
618 | if (orinterf==TopAbs_FORWARD) orien=TopAbs_REVERSED; | |
619 | else orien=TopAbs_FORWARD; | |
620 | } | |
621 | } | |
622 | ||
623 | //======================================================================= | |
624 | //function : OrientationAreteViveConsecutive | |
81bba717 | 625 | //purpose : calculate the orientation of the curve between edges ic and icplus |
626 | // where ic and icplus are consecutively living | |
7fd59977 | 627 | //======================================================================= |
628 | ||
629 | static void OrientationAreteViveConsecutive (const TopoDS_Shape & Fviveicicplus, | |
630 | const TopoDS_Shape & Eviveic, | |
631 | const TopoDS_Vertex & V1, | |
632 | TopAbs_Orientation & orien) | |
633 | ||
81bba717 | 634 | { // orinterf is orientation of edge ic corresponding to face Fviveicicplus taken FORWARD |
7fd59977 | 635 | TopAbs_Orientation orinterf = TopAbs_FORWARD; |
7fd59977 | 636 | TopoDS_Face F=TopoDS::Face( Fviveicicplus); |
637 | TopoDS_Edge E=TopoDS::Edge( Eviveic); | |
638 | TopExp_Explorer ex; | |
639 | for(ex.Init(F.Oriented(TopAbs_FORWARD),TopAbs_EDGE);ex.More(); ex.Next()){ | |
640 | if(E.IsSame(ex.Current())) { | |
641 | orinterf = ex.Current().Orientation(); | |
642 | break; | |
643 | } | |
644 | } | |
81bba717 | 645 | // if V1 is vertex REVERSED of edge ic the curve |
646 | // has the same orientation as ic | |
7fd59977 | 647 | TopoDS_Vertex vl; |
648 | vl=TopExp::LastVertex(E); | |
649 | if (vl.IsSame(V1)){ | |
650 | if (orinterf==TopAbs_FORWARD) orien=TopAbs_FORWARD; | |
651 | else orien=TopAbs_REVERSED; | |
652 | } | |
653 | else { | |
654 | if (orinterf==TopAbs_FORWARD) orien=TopAbs_REVERSED; | |
655 | else orien=TopAbs_FORWARD; | |
656 | } | |
657 | } | |
658 | ||
659 | //======================================================================= | |
660 | //function : PerformTwoCornerSameExt | |
81bba717 | 661 | //purpose : calculate intersection between two stripes stripe1 and stripe2 |
7fd59977 | 662 | //======================================================================= |
663 | ||
664 | static void PerformTwoCornerSameExt(TopOpeBRepDS_DataStructure& DStr, | |
665 | const Handle(ChFiDS_Stripe)& stripe1, | |
666 | const Standard_Integer index1, | |
667 | const Standard_Integer sens1, | |
668 | const Handle(ChFiDS_Stripe) &stripe2, | |
669 | const Standard_Integer index2, | |
670 | const Standard_Integer sens2, | |
671 | Standard_Boolean & trouve) | |
672 | ||
673 | { Handle (TopOpeBRepDS_CurvePointInterference) Interfp1, Interfp2; | |
674 | Handle (TopOpeBRepDS_SurfaceCurveInterference) Interfc; | |
675 | TopAbs_Orientation orpcurve,trafil1,orsurf1,orsurf2; | |
676 | Standard_Boolean isfirst; | |
677 | Standard_Integer indic1,indic2, indpoint1,indpoint2,ind,indcurve; | |
678 | Standard_Real tol; | |
679 | gp_Pnt P1,P2,P3,P4; | |
680 | gp_Pnt2d p2d; | |
681 | Handle(Geom_Curve)cint; | |
682 | Handle(Geom2d_Curve) C2dint1,C2dint2; | |
683 | isfirst=sens1==1; | |
684 | ChFiDS_CommonPoint& Com11= stripe1->SetOfSurfData()->Value(index1)->ChangeVertex (isfirst,1); | |
685 | ChFiDS_CommonPoint& Com12= stripe1->SetOfSurfData()->Value(index1)->ChangeVertex (isfirst,2); | |
686 | isfirst=sens2==1; | |
687 | ChFiDS_CommonPoint& Com21= stripe2->SetOfSurfData()->Value(index2)->ChangeVertex (isfirst,1); | |
0797d9d3 | 688 | #ifdef OCCT_DEBUG |
7fd59977 | 689 | // ChFiDS_CommonPoint& Com22= |
690 | // stripe2->SetOfSurfData()->Value(index2)->ChangeVertex (isfirst,2); | |
691 | #endif | |
692 | indic1=stripe1->SetOfSurfData()->Value(index1)->Surf(); | |
693 | indic2=stripe2->SetOfSurfData()->Value(index2)->Surf(); | |
694 | const Handle(ChFiDS_SurfData) Fd1=stripe1->SetOfSurfData()->Value(index1); | |
695 | const Handle(ChFiDS_SurfData) Fd2=stripe2->SetOfSurfData()->Value(index2); | |
696 | ||
697 | TColStd_Array1OfReal Pardeb(1,4),Parfin(1,4); | |
698 | const ChFiDS_FaceInterference& Fi11 = Fd1->InterferenceOnS1(); | |
699 | const ChFiDS_FaceInterference& Fi12 = Fd1->InterferenceOnS2(); | |
700 | const ChFiDS_FaceInterference& Fi21 = Fd2->InterferenceOnS1(); | |
701 | const ChFiDS_FaceInterference& Fi22 = Fd2->InterferenceOnS2(); | |
702 | gp_Pnt2d pfi11,pfi12,pfi21,pfi22; | |
703 | isfirst=sens1==1; | |
704 | pfi11 = Fi11.PCurveOnSurf()->Value(Fi11.Parameter(isfirst)); | |
705 | pfi12 = Fi12.PCurveOnSurf()->Value(Fi12.Parameter(isfirst)); | |
706 | isfirst=sens2==1; | |
707 | if (Com11.Point().Distance(Com21.Point()) <1.e-4) { | |
708 | pfi21 = Fi21.PCurveOnSurf()->Value(Fi21.Parameter(isfirst)); | |
709 | pfi22 = Fi22.PCurveOnSurf()->Value(Fi22.Parameter(isfirst)); | |
710 | } | |
711 | else { | |
712 | pfi22 = Fi21.PCurveOnSurf()->Value(Fi21.Parameter(isfirst)); | |
713 | pfi21 = Fi22.PCurveOnSurf()->Value(Fi22.Parameter(isfirst)); | |
714 | } | |
715 | ||
716 | Pardeb(1)= pfi11.X();Pardeb(2) = pfi11.Y(); | |
717 | Pardeb(3)= pfi21.X();Pardeb(4) = pfi21.Y(); | |
718 | Parfin(1)= pfi12.X();Parfin(2) = pfi12.Y(); | |
719 | Parfin(3)= pfi22.X();Parfin(4) = pfi22.Y(); | |
720 | ||
c22b52d6 | 721 | Handle(GeomAdaptor_Surface) HS1= ChFi3d_BoundSurf(DStr,Fd1,1,2); |
722 | Handle(GeomAdaptor_Surface) HS2= ChFi3d_BoundSurf(DStr,Fd2,1,2); | |
7fd59977 | 723 | trouve=Standard_False; |
724 | if (ChFi3d_ComputeCurves(HS1,HS2,Pardeb,Parfin,cint, | |
725 | C2dint1,C2dint2,1.e-4,1.e-5,tol)){ | |
726 | cint->D0(cint->FirstParameter(),P1); | |
727 | cint->D0(cint->LastParameter(),P2); | |
728 | trouve=((Com11.Point().Distance(P1) <1.e-4 || Com11.Point().Distance(P2)<1.e-4)&& | |
729 | (Com12.Point().Distance(P1) <1.e-4 || Com12.Point().Distance(P2)<1.e-4)); | |
730 | } | |
731 | ||
732 | if (trouve) { | |
733 | isfirst=sens1==1; | |
734 | stripe1->InDS(isfirst); | |
735 | indpoint1=ChFi3d_IndexPointInDS(Com11,DStr); | |
736 | indpoint2=ChFi3d_IndexPointInDS(Com12,DStr); | |
737 | stripe1->SetIndexPoint(indpoint1,isfirst,1); | |
738 | stripe1->SetIndexPoint(indpoint2,isfirst,2); | |
739 | isfirst=sens2==1; | |
740 | stripe2->InDS(isfirst); | |
741 | if (Com11.Point().Distance(Com21.Point()) <1.e-4) { | |
742 | stripe2->SetIndexPoint(indpoint1,isfirst,1); | |
743 | stripe2->SetIndexPoint(indpoint2,isfirst,2); | |
744 | } | |
745 | else { | |
746 | stripe2->SetIndexPoint(indpoint2,isfirst,1); | |
747 | stripe2->SetIndexPoint(indpoint1,isfirst,2); | |
748 | } | |
749 | ||
750 | orsurf1=Fd1->Orientation(); | |
751 | trafil1 = DStr.Shape(Fd1->IndexOfS1()).Orientation(); | |
752 | trafil1 = TopAbs::Compose(trafil1,Fd1->Orientation()); | |
753 | trafil1 = TopAbs::Compose(TopAbs::Reverse(Fi11.Transition()),trafil1); | |
754 | orsurf2=Fd2->Orientation(); | |
755 | TopOpeBRepDS_Curve tcurv3d(cint,tol); | |
756 | indcurve= DStr.AddCurve(tcurv3d); | |
757 | cint->D0(cint->FirstParameter(),P1); | |
758 | cint->D0(cint->LastParameter(),P2); | |
759 | Fi11.PCurveOnFace()->D0(Fi11.LastParameter(),p2d); | |
760 | const Handle(Geom_Surface) Stemp = | |
761 | BRep_Tool::Surface(TopoDS::Face(DStr.Shape(Fd1->IndexOfS1()))); | |
762 | Stemp ->D0(p2d.X(),p2d.Y(),P4); | |
763 | Fi11.PCurveOnFace()->D0(Fi11.FirstParameter(),p2d); | |
764 | Stemp ->D0(p2d.X(),p2d.Y(),P3); | |
765 | if (P1.Distance(P4)<1.e-4 || P2.Distance(P3)<1.e-4) | |
766 | orpcurve=trafil1; | |
767 | else orpcurve=TopAbs::Reverse(trafil1); | |
768 | if (Com11.Point().Distance(P1) >1.e-4) { | |
769 | ind=indpoint1; | |
770 | indpoint1=indpoint2; | |
771 | indpoint2=ind; | |
772 | } | |
773 | Interfp1=ChFi3d_FilPointInDS(TopAbs_FORWARD,indcurve, indpoint1, cint->FirstParameter()); | |
774 | Interfp2=ChFi3d_FilPointInDS(TopAbs_REVERSED,indcurve,indpoint2, cint->LastParameter()); | |
775 | DStr.ChangeCurveInterferences(indcurve).Append(Interfp1); | |
776 | DStr.ChangeCurveInterferences(indcurve).Append(Interfp2); | |
777 | Interfc=ChFi3d_FilCurveInDS(indcurve,indic1,C2dint1,orpcurve); | |
778 | DStr.ChangeSurfaceInterferences(indic1).Append(Interfc); | |
779 | if (orsurf1==orsurf2) orpcurve=TopAbs::Reverse(orpcurve); | |
780 | Interfc=ChFi3d_FilCurveInDS(indcurve,indic2,C2dint2,orpcurve); | |
781 | DStr.ChangeSurfaceInterferences(indic2).Append(Interfc); | |
782 | } | |
783 | } | |
784 | ||
785 | //======================================================================= | |
786 | //function : CpOnEdge | |
81bba717 | 787 | //purpose : determine if surfdata num has a common point on Eadj1 or Eadj2 |
7fd59977 | 788 | //======================================================================= |
789 | ||
790 | static void CpOnEdge (const Handle(ChFiDS_Stripe) & stripe, | |
791 | Standard_Integer num, | |
792 | Standard_Boolean isfirst, | |
793 | const TopoDS_Edge & Eadj1, | |
794 | const TopoDS_Edge & Eadj2, | |
795 | Standard_Boolean & compoint) | |
796 | ||
797 | { ChFiDS_CommonPoint cp1,cp2; | |
798 | compoint=Standard_False; | |
799 | cp1 = stripe->SetOfSurfData()->Value(num)->ChangeVertex (isfirst,1); | |
800 | cp2 = stripe->SetOfSurfData()->Value(num)->ChangeVertex (isfirst,2); | |
801 | if(cp1.IsOnArc()){ | |
802 | if (cp1.Arc().IsSame(Eadj1)||cp1.Arc().IsSame(Eadj2)) | |
803 | compoint=Standard_True; | |
804 | } | |
805 | if(cp2.IsOnArc()){ | |
806 | if (cp2.Arc().IsSame(Eadj1)||cp2.Arc().IsSame(Eadj2)) | |
807 | compoint=Standard_True; | |
808 | } | |
809 | } | |
810 | ||
811 | //======================================================================= | |
812 | //function : RemoveSurfData | |
81bba717 | 813 | //purpose : for each stripe removal of unused surfdatas |
7fd59977 | 814 | //======================================================================= |
815 | ||
816 | static void RemoveSurfData (const ChFiDS_StripeMap & myVDataMap, | |
817 | const ChFiDS_Map & myEFMap, | |
818 | const TopoDS_Edge &edgecouture, | |
819 | const TopoDS_Face & facecouture, | |
820 | const TopoDS_Vertex &V1) | |
821 | { ChFiDS_ListIteratorOfListOfStripe It; | |
822 | Standard_Boolean isfirst; | |
823 | TopoDS_Edge Ecur,Eadj1,Eadj2; | |
824 | TopoDS_Face Fg,Fd,F1,F2; | |
825 | TopoDS_Vertex Vbid; | |
826 | Standard_Integer nbsurf,nbedge,sense,num; | |
827 | for (It.Initialize(myVDataMap(V1));It.More();It.Next()) { | |
828 | nbsurf= It.Value()->SetOfSurfData()->Length(); | |
829 | nbedge = It.Value()->Spine()->NbEdges(); | |
830 | if (nbsurf!=1){ | |
831 | num=ChFi3d_IndexOfSurfData(V1,It.Value(),sense); | |
832 | if (sense==1) | |
833 | Ecur = It.Value()->Spine()->Edges(1); | |
834 | else | |
835 | Ecur = It.Value()->Spine()->Edges(nbedge); | |
836 | ChFi3d_edge_common_faces(myEFMap(Ecur),F1,F2); | |
837 | if (F1.IsSame(facecouture)) Eadj1=edgecouture; | |
838 | else ChFi3d_cherche_element(V1,Ecur,F1,Eadj1,Vbid); | |
839 | ChFi3d_edge_common_faces(myEFMap(Eadj1),Fg,Fd); | |
840 | if (F2.IsSame(facecouture)) Eadj2=edgecouture; | |
841 | else ChFi3d_cherche_element(V1,Ecur,F2,Eadj2,Vbid); | |
842 | ChFi3d_edge_common_faces(myEFMap(Eadj2),Fg,Fd); | |
843 | Standard_Boolean compoint=Standard_False; | |
844 | isfirst=(sense==1); | |
845 | Standard_Integer ind; | |
846 | if (sense==1) { | |
847 | ind=0; | |
81bba717 | 848 | // among surfdatas find the greatest indice ind so that |
849 | // surfdata could have one of commonpoint on Eadj1 and Eadj2 | |
850 | // remove surfdata from 1 to ind-1 | |
7fd59977 | 851 | for (Standard_Integer i=1;i<=nbsurf;i++) { |
852 | CpOnEdge (It.Value(),i,isfirst,Eadj1,Eadj2,compoint); | |
853 | if (compoint) ind=i; | |
854 | } | |
855 | if (ind>=2) RemoveSD(It.Value(),1,ind-1); | |
856 | } | |
857 | else { | |
858 | ind=num; | |
81bba717 | 859 | // among surfdatas find the smallest indice ind so that |
860 | // surfdata could have one of commonpoint on Eadj1 and Eadj2 | |
861 | // remove surfdata from ind+1 to num | |
7fd59977 | 862 | for (Standard_Integer i=num;i>=1;i--) { |
863 | CpOnEdge (It.Value(),i,isfirst,Eadj1,Eadj2,compoint); | |
864 | if (compoint) ind=i; | |
865 | } | |
866 | if (ind<num) RemoveSD(It.Value(),ind+1,num); | |
867 | } | |
868 | } | |
869 | } | |
870 | } | |
871 | ||
872 | //======================================================================= | |
873 | //function : ParametrePlate | |
874 | //purpose : | |
875 | //======================================================================= | |
876 | ||
877 | static void ParametrePlate(const Standard_Integer n3d, | |
878 | const GeomPlate_BuildPlateSurface & PSurf, | |
879 | const Handle(Geom_Surface) & Surf, | |
880 | const gp_Pnt & point, | |
881 | const Standard_Real apperror, | |
882 | gp_Pnt2d & uv) | |
883 | { Standard_Integer ip; | |
884 | gp_Pnt P1; | |
885 | Standard_Real par; | |
886 | Standard_Boolean trouve=Standard_False; | |
887 | for (ip=1;ip<=n3d && !trouve;ip++){ | |
888 | par=PSurf.Curves2d()->Value(ip)->FirstParameter(); | |
889 | PSurf.Curves2d()->Value(ip)->D0(par,uv); | |
890 | Surf->D0(uv.X(),uv.Y(),P1); | |
891 | trouve=P1.IsEqual(point,apperror); | |
892 | if (!trouve) { | |
893 | par=PSurf.Curves2d()->Value(ip)->LastParameter(); | |
894 | PSurf.Curves2d()->Value(ip)->D0(par,uv); | |
895 | Surf->D0(uv.X(),uv.Y(),P1); | |
896 | trouve=P1.IsEqual(point,apperror); | |
897 | } | |
898 | } | |
899 | } | |
900 | ||
901 | //======================================================================= | |
902 | //function : SummarizeNormal | |
903 | //purpose : | |
904 | //======================================================================= | |
905 | ||
906 | static void SummarizeNormal(const TopoDS_Vertex& V1, | |
907 | const TopoDS_Face& Fcur, | |
908 | const TopoDS_Edge& Ecur, | |
909 | gp_Vec& SumFaceNormalAtV1) | |
910 | { | |
911 | gp_Pnt2d uv1, uv2; | |
912 | BRep_Tool::UVPoints(Ecur,Fcur,uv1,uv2); | |
913 | if ( ! V1.IsSame(TopExp::FirstVertex(Ecur))) uv1 = uv2; | |
914 | ||
915 | gp_Pnt P; | |
916 | gp_Vec d1U, d1V; | |
917 | BRep_Tool::Surface(Fcur)->D1( uv1.X(), uv1.Y(), P, d1U, d1V); | |
918 | gp_Vec N = d1U.Crossed(d1V); | |
919 | if (Fcur.Orientation() == TopAbs_REVERSED) N.Reverse(); | |
920 | ||
921 | if (N.SquareMagnitude() <= Precision::PConfusion()) return; | |
922 | ||
923 | SumFaceNormalAtV1 += N.Normalized(); | |
924 | SumFaceNormalAtV1.Normalize(); | |
925 | } | |
926 | ||
927 | enum ChFi3d_SurfType { ChFiSURFACE, FACE1, FACE2 }; // for call SurfIndex(...) | |
928 | ||
929 | //======================================================================= | |
930 | //function : SurfIndex | |
931 | //purpose : | |
932 | //======================================================================= | |
933 | ||
934 | static Standard_Integer SurfIndex(const ChFiDS_StripeArray1& StripeArray1, | |
935 | const Standard_Integer StripeIndex, | |
936 | const Standard_Integer SurfDataIndex, | |
937 | const ChFi3d_SurfType SurfType) | |
938 | { | |
939 | const Handle(ChFiDS_SurfData)& aSurfData = | |
940 | StripeArray1(StripeIndex)->SetOfSurfData()->Value(SurfDataIndex); | |
941 | switch (SurfType) { | |
942 | case ChFiSURFACE: return aSurfData->Surf(); | |
943 | case FACE1: return aSurfData->IndexOfS1(); | |
944 | case FACE2: return aSurfData->IndexOfS2(); | |
945 | default: return -1; | |
946 | } | |
7fd59977 | 947 | } |
948 | ||
949 | //======================================================================= | |
950 | //function : PlateOrientation | |
951 | //purpose : Define Plate orientation compared to <theRefDir> previewing | |
952 | // that Plate surface can have a sharp angle with adjacent | |
953 | // filet (bug occ266: 2 chamfs, OnSame and OnDiff) and | |
954 | // can be even twisted (grid tests cfi900 B1) | |
955 | //======================================================================= | |
956 | ||
957 | static TopAbs_Orientation PlateOrientation(const Handle(Geom_Surface)& thePlateSurf, | |
958 | const Handle(TColGeom2d_HArray1OfCurve)& thePCArr, | |
959 | const gp_Vec& theRefDir) | |
960 | { | |
961 | gp_Vec du,dv; | |
962 | gp_Pnt pp1,pp2,pp3; | |
963 | gp_Pnt2d uv; | |
964 | Standard_Real fpar, lpar; | |
965 | Standard_Real SumScal1 = 0, SumScal2 = 0; | |
966 | ||
967 | Standard_Integer i, nb = thePCArr->Upper(); | |
968 | Handle(Geom2d_Curve) aPC = thePCArr->Value(nb); | |
969 | fpar = aPC->FirstParameter(); | |
970 | lpar = aPC->LastParameter(); | |
971 | aPC->D0( (fpar + lpar) / 2., uv); | |
972 | thePlateSurf-> D0(uv.X(),uv.Y(),pp1); | |
973 | aPC->D0( lpar ,uv); | |
974 | thePlateSurf-> D0(uv.X(),uv.Y(),pp2); | |
975 | ||
976 | for (i=1; i<=nb; i++) { | |
977 | aPC = thePCArr->Value(i); | |
978 | fpar = aPC->FirstParameter(); | |
979 | lpar = aPC->LastParameter(); | |
980 | aPC->D0( fpar ,uv); | |
981 | thePlateSurf -> D1(uv.X(),uv.Y(),pp2,du,dv); | |
982 | gp_Vec n1 = du^dv; | |
983 | n1.Normalize(); | |
984 | ||
985 | aPC->D0( (fpar + lpar) / 2., uv); | |
986 | thePlateSurf-> D0(uv.X(),uv.Y(),pp3); | |
987 | ||
988 | gp_Vec vv1(pp2,pp1), vv2(pp2,pp3); | |
989 | gp_Vec n2 = vv2^vv1; | |
990 | n2.Normalize(); | |
991 | ||
992 | SumScal1 += n1*n2; | |
993 | SumScal2 += n2*theRefDir; | |
994 | ||
995 | pp1 = pp3; | |
996 | } | |
997 | if (SumScal2*SumScal1>0) return TopAbs_FORWARD; | |
998 | else return TopAbs_REVERSED; | |
999 | } | |
1000 | ||
1001 | //======================================================================= | |
1002 | //function : PerformMoreThreeCorner | |
81bba717 | 1003 | //purpose : Process case of a top with n edges. |
7fd59977 | 1004 | //======================================================================= |
1005 | ||
1006 | void ChFi3d_Builder::PerformMoreThreeCorner(const Standard_Integer Jndex, | |
1007 | const Standard_Integer nconges) | |
1008 | { | |
1009 | // ======================================== | |
1010 | // Initialisations | |
1011 | // ======================================== | |
0797d9d3 | 1012 | #ifdef OCCT_DEBUG |
7fd59977 | 1013 | OSD_Chronometer ch; |
1014 | #endif | |
1015 | TopOpeBRepDS_DataStructure& DStr=myDS->ChangeDS(); | |
1016 | const TopoDS_Vertex& V1 = myVDataMap.FindKey(Jndex); | |
1017 | Standard_Integer nedge; | |
1018 | Standard_Boolean bordlibre; | |
1019 | TopoDS_Edge edgelibre1,edgelibre2; | |
1020 | // TopTools_ListIteratorOfListOfShape ItE; | |
1021 | nedge=ChFi3d_NbNotDegeneratedEdges(V1,myVEMap); | |
1022 | ChFi3d_ChercheBordsLibres(myVEMap,V1,bordlibre,edgelibre1,edgelibre2); | |
1023 | Standard_Boolean droit=Standard_False; | |
1024 | if (bordlibre) {nedge=(nedge-2)/2 +2; | |
1025 | Standard_Real angedg=Abs(ChFi3d_AngleEdge(V1,edgelibre1,edgelibre2)); | |
c6541a0c | 1026 | droit=Abs(angedg-M_PI)<0.01; |
7fd59977 | 1027 | } |
1028 | else nedge=nedge/2; | |
1029 | Standard_Integer size=nedge*2; | |
1030 | ChFiDS_StripeArray1 CD(0,size); | |
1031 | TColStd_Array1OfInteger jf(0,size); | |
1032 | TColStd_Array1OfInteger Index(0,size); | |
1033 | TColStd_Array1OfInteger Indice(0,size); | |
1034 | TColStd_Array1OfInteger sens(0,size); | |
1035 | TColStd_Array1OfInteger indcurve3d(0,size); | |
1036 | TColStd_Array2OfInteger numfa( 0,size,0,size); | |
1037 | TColStd_Array1OfInteger Order( 0,size); | |
1038 | TColStd_Array2OfInteger i(0,size,0,size); | |
1039 | TColStd_Array2OfInteger indpoint(0,size,0,1); | |
1040 | TColStd_Array1OfBoolean oksea(0,size); | |
1041 | TColStd_Array1OfBoolean sharp(0,size); | |
1042 | TColStd_Array1OfBoolean regul(0,size); | |
1043 | TColStd_Array2OfReal p (0,size,0,size); | |
1044 | TColStd_Array1OfReal errapp (0,size); | |
1045 | TopTools_Array1OfShape Evive(0,size); | |
1046 | TopTools_Array2OfShape Fvive(0,size,0,size); | |
1047 | TColStd_Array1OfBoolean ponctuel (0,size); | |
1048 | TColStd_Array1OfBoolean samedge (0,size); | |
1049 | TColStd_Array1OfBoolean moresurf (0,size); | |
1050 | TColStd_Array1OfBoolean libre(0,size); | |
1051 | TColStd_Array1OfBoolean tangentregul (0,size); | |
1052 | TColStd_Array1OfBoolean isG1(0,size); | |
1053 | // for(Standard_Integer ind=0;ind<=size;ind++){ | |
1054 | Standard_Integer ind; | |
1055 | for(ind=0;ind<=size;ind++){ | |
1056 | indpoint.SetValue(ind,0,0); | |
1057 | indpoint.SetValue(ind,1,0); | |
1058 | Indice.SetValue(ind,0); | |
1059 | oksea.SetValue(ind,Standard_False); | |
1060 | sharp.SetValue(ind,Standard_False); | |
1061 | regul.SetValue(ind,Standard_False); | |
1062 | ponctuel.SetValue(ind,Standard_False); | |
1063 | samedge.SetValue(ind,Standard_False); | |
1064 | moresurf.SetValue(ind,Standard_False); | |
1065 | libre.SetValue(ind,Standard_False); | |
1066 | tangentregul.SetValue(ind,Standard_False); | |
1067 | isG1.SetValue(ind,Standard_False); | |
1068 | } | |
1069 | ChFiDS_ListIteratorOfListOfStripe It; | |
1070 | Handle(ChFiDS_Stripe) cd2,cdbid,cnext; | |
1071 | TopoDS_Face face; | |
1d47d8d0 | 1072 | Standard_Integer jfp = 0,ii; |
7fd59977 | 1073 | Standard_Integer ic,icplus,icmoins,icplus2, |
d20d815b | 1074 | sense,index = 0,indice,isurf1,isurf2; |
1d47d8d0 | 1075 | Standard_Integer cbplus=0, n3d=0,IVtx = 0,nb; |
7fd59977 | 1076 | Standard_Boolean sameside,trouve,isfirst; |
1077 | Standard_Real pardeb ,parfin,xdir,ydir; | |
1d47d8d0 | 1078 | Standard_Real tolapp=1.e-4,maxapp = 0.,maxapp1 = 0.,avedev; |
7fd59977 | 1079 | Handle (TopOpeBRepDS_CurvePointInterference) Interfp1, Interfp2; |
1080 | Handle (TopOpeBRepDS_SurfaceCurveInterference) Interfc; | |
1081 | Handle(Geom_Curve) Curv3d; | |
1082 | ChFiDS_Regul regular; | |
1083 | TopTools_SequenceOfShape Fproj; | |
1084 | Standard_Integer num; | |
1085 | TopoDS_Edge Ecur; | |
1086 | TopTools_ListIteratorOfListOfShape ItF; | |
0797d9d3 | 1087 | #ifdef OCCT_DEBUG |
7fd59977 | 1088 | // Standard_Integer nface=ChFi3d_nbface(myVFMap(V1)); |
1089 | #endif | |
1090 | TopoDS_Face F1,F2; | |
1091 | gp_Vec SumFaceNormalAtV1(0,0,0); // is used to define Plate orientation | |
1092 | ||
81bba717 | 1093 | // it is determined if there is a sewing edge |
7fd59977 | 1094 | Standard_Boolean couture=Standard_False; |
1095 | TopoDS_Face facecouture; | |
1096 | TopoDS_Edge edgecouture; | |
1097 | for(ItF.Initialize(myVFMap(V1));ItF.More()&&!couture;ItF.Next()) { | |
1098 | TopoDS_Face fcur = TopoDS::Face(ItF.Value()); | |
1099 | ChFi3d_CoutureOnVertex(fcur,V1,couture,edgecouture); | |
1100 | if (couture) | |
1101 | facecouture=fcur; | |
1102 | } | |
1103 | ||
81bba717 | 1104 | // unused surfdata are removed |
7fd59977 | 1105 | RemoveSurfData (myVDataMap, myEFMap,edgecouture,facecouture,V1); |
1106 | ||
81bba717 | 1107 | // parse edges and faces |
7fd59977 | 1108 | trouve=Standard_False; |
1109 | TopoDS_Edge Enext; | |
1110 | TopoDS_Vertex VV; | |
1111 | TopoDS_Face Fcur,Fnext; | |
1112 | for (It.Initialize(myVDataMap(Jndex));It.More()&&!trouve;It.Next()) { | |
1113 | cnext=It.Value(); | |
1114 | CD.SetValue(0,cnext); | |
1115 | Index.SetValue(0,ChFi3d_IndexOfSurfData(V1,cnext,sense)); | |
1116 | sens.SetValue(0,sense); | |
1117 | numfa.SetValue(0 ,1,SurfIndex(CD, 0, Index.Value(0), FACE2)); | |
1118 | numfa.SetValue(1 ,0, numfa.Value(0 ,1)); | |
1119 | Fcur=TopoDS::Face(DStr.Shape(numfa.Value(0,1))); | |
1120 | Fvive.SetValue(0,1,Fcur); | |
1121 | Fvive.SetValue(1,0,Fcur); | |
1122 | jf.SetValue(0,2); | |
1123 | if (sens.Value(0)==1) | |
1124 | Ecur = CD.Value(0)->Spine()->Edges(1); | |
1125 | else | |
1126 | Ecur = CD.Value(0)->Spine()->Edges(CD.Value(0)->Spine()->NbEdges()); | |
1127 | Evive.SetValue(0,Ecur); | |
1128 | ChFi3d_cherche_edge(V1,Evive,Fcur,Enext,VV); | |
1129 | trouve= !Enext.IsNull(); | |
1130 | } | |
81bba717 | 1131 | // find sum of all face normals at V1 |
7fd59977 | 1132 | SummarizeNormal(V1, Fcur, Ecur, SumFaceNormalAtV1); |
1133 | ||
1134 | Standard_Integer nbcouture=0; | |
1135 | for ( ii=1; ii<nedge; ii++) { | |
1136 | if (Fcur.IsSame(facecouture)&& nbcouture==0) { | |
1137 | Enext=edgecouture; | |
1138 | nbcouture++; | |
1139 | } | |
1140 | else ChFi3d_cherche_edge(V1,Evive,Fcur,Enext,VV); | |
9775fa61 | 1141 | if (Enext.IsNull())throw Standard_Failure("PerformMoreThreeCorner: pb in the parsing of edges and faces"); |
7fd59977 | 1142 | if (Enext.IsSame(edgelibre1)|| Enext.IsSame(edgelibre2)) { |
1143 | CD.SetValue(ii, cdbid); | |
1144 | Index.SetValue(ii, 0); | |
1145 | sens.SetValue(ii, -1); | |
1146 | TopoDS_Vertex Vref; | |
1147 | Vref = TopExp::FirstVertex(Enext); | |
1148 | if (Vref.IsSame(V1)) sens.SetValue(ii, 1); | |
1149 | sharp.SetValue(ii, Standard_True); | |
1150 | Evive.SetValue(ii, Enext); | |
1151 | jf.SetValue(ii, 0); | |
1152 | Indices(nedge,ii,icplus,icmoins); | |
1153 | Fvive.SetValue(ii,icplus, Fcur); | |
1154 | Fvive.SetValue(icplus,ii, Fcur); | |
1155 | numfa.SetValue(ii,icplus, DStr.AddShape(Fcur)); | |
1156 | numfa.SetValue(icplus,ii,numfa.Value(ii,icplus)); | |
1157 | ii++; | |
1158 | if (Enext.IsSame (edgelibre1)) Ecur=edgelibre2; | |
1159 | else Ecur=edgelibre1; | |
1160 | ChFi3d_edge_common_faces(myEFMap(Ecur),Fcur,Fcur); | |
1161 | Indices(nedge,ii,icplus,icmoins); | |
1162 | Fvive.SetValue(ii,icplus, Fcur); | |
1163 | Fvive.SetValue(icplus,ii, Fcur); | |
1164 | numfa.SetValue(ii,icplus, DStr.AddShape(Fcur)); | |
1165 | numfa.SetValue(icplus,ii,numfa.Value(ii,icplus)); | |
1166 | CD.SetValue(ii, cdbid); | |
1167 | Index.SetValue(ii, 0); | |
1168 | sens.SetValue(ii, -1); | |
1169 | Vref = TopExp::FirstVertex(Ecur); | |
1170 | if (Vref.IsSame(V1)) sens.SetValue(ii, 1); | |
1171 | sharp.SetValue(ii, Standard_True); | |
1172 | Evive.SetValue(ii, Ecur); | |
1173 | jf.SetValue(ii, 0); | |
1174 | } | |
1175 | else { | |
81bba717 | 1176 | // it is found if Enext is in the map of stripes |
7fd59977 | 1177 | TopoDS_Edge EE; |
1178 | /*Standard_Boolean */trouve = Standard_False; | |
1179 | for (It.Initialize(myVDataMap(Jndex));It.More()&&!trouve;It.Next()) { | |
1180 | index = ChFi3d_IndexOfSurfData(V1,It.Value(),sense); | |
1181 | if (sense==1) | |
1182 | EE = It.Value()->Spine()->Edges(1); | |
1183 | else | |
1184 | EE = It.Value()->Spine()->Edges(It.Value()->Spine()->NbEdges()); | |
1185 | if (Enext.IsSame(EE)) { | |
1186 | cnext=It.Value(); | |
1187 | trouve=Standard_True; | |
1188 | } | |
1189 | } | |
1190 | if (trouve) { | |
1191 | CD.SetValue(ii, cnext); | |
1192 | Index.SetValue(ii, index); | |
1193 | sens.SetValue(ii, sense); | |
1194 | sharp.SetValue(ii, Standard_False); | |
1195 | Evive.SetValue(ii, Enext); | |
1196 | } | |
1197 | else { | |
81bba717 | 1198 | // edge ii is alive |
7fd59977 | 1199 | CD.SetValue(ii, cdbid); |
1200 | Index.SetValue(ii, 0); | |
1201 | sens.SetValue(ii, -1); | |
1202 | TopoDS_Vertex Vref; | |
1203 | Vref = TopExp::FirstVertex(Enext); | |
1204 | if (Vref.IsSame(V1)) sens.SetValue(ii, 1); | |
1205 | sharp.SetValue(ii, Standard_True); | |
1206 | Evive.SetValue(ii, Enext); | |
1207 | jf.SetValue(ii, 0); | |
1208 | } | |
81bba717 | 1209 | // Face Fnext!=Fcur containing Enext |
7fd59977 | 1210 | Fnext=Fcur; |
1211 | ChFi3d_cherche_face1(myEFMap(Enext),Fcur,Fnext); | |
1212 | Indices(nedge,ii,icplus,icmoins); | |
1213 | Fvive.SetValue(ii,icplus, Fnext); | |
1214 | Fvive.SetValue(icplus,ii, Fnext); | |
1215 | numfa.SetValue(ii,icplus, DStr.AddShape(Fnext)); | |
1216 | numfa.SetValue(icplus,ii,numfa.Value(ii,icplus)); | |
1217 | Standard_Integer numface1,numface2; | |
1218 | if (trouve) { | |
81bba717 | 1219 | // it is checked if numfa corresponds to IndexOfS1 or IndexOfS2 |
1220 | // jf is updated is consequently updated | |
1221 | // if it is not the case among the previous faces are found | |
1222 | // those which correspond to IndexOfs1 IndexOfS2 and | |
1223 | // numfa and Fvive are reupdated (cts16288) | |
7fd59977 | 1224 | numface2 = SurfIndex(CD, ii, Index.Value(ii), FACE2); |
1225 | if (numface2==numfa.Value(ii,icplus)) | |
1226 | jf.SetValue(ii, 2); | |
1227 | else { | |
1228 | numface1 = SurfIndex(CD, ii, Index.Value(ii), FACE1); | |
1229 | if (numface1==numfa.Value(ii,icplus)) | |
1230 | jf.SetValue(ii, 1); | |
1231 | else { | |
1232 | if (numface1==numfa.Value(icmoins,ii)) { | |
1233 | jf.SetValue(ii, 2); | |
1234 | Fvive.SetValue(ii,icplus,TopoDS::Face(DStr.Shape(numface2))); | |
1235 | Fvive.SetValue(icplus,ii,TopoDS::Face(DStr.Shape(numface2))); | |
1236 | numfa.SetValue(ii,icplus, DStr.AddShape(TopoDS::Face(DStr.Shape(numface2)))); | |
1237 | numfa.SetValue(icplus,ii, numfa.Value (ii,icplus)); | |
1238 | } | |
1239 | if (numface2==numfa.Value(icmoins,ii)) { | |
1240 | jf.SetValue(ii, 1); | |
1241 | Fvive.SetValue(ii,icplus,TopoDS::Face(DStr.Shape(numface1))); | |
1242 | Fvive.SetValue(icplus,ii,TopoDS::Face(DStr.Shape(numface1))); | |
1243 | numfa.SetValue(ii,icplus, DStr.AddShape(TopoDS::Face(DStr.Shape(numface1)))); | |
1244 | numfa.SetValue(icplus,ii, numfa.Value (ii,icplus)); | |
1245 | } | |
1246 | } | |
1247 | } | |
1248 | } | |
1249 | Ecur = Enext; | |
1250 | Fcur = Fnext; | |
1251 | // find sum of all face normales at V1 | |
1252 | SummarizeNormal(V1, Fcur, Ecur, SumFaceNormalAtV1); | |
1253 | } | |
1254 | } | |
1255 | // mise a jour du tableau regul | |
1256 | for (ic=0;ic<nedge;ic++) { | |
1257 | if (sharp.Value(ic)) { | |
1258 | Ecur=TopoDS::Edge(Evive.Value(ic)); | |
1259 | if (!Ecur.IsSame(edgecouture)) { | |
1260 | ChFi3d_edge_common_faces(myEFMap(Ecur),F1,F2); | |
1261 | // Modified by Sergey KHROMOV - Fri Dec 21 18:11:02 2001 Begin | |
1262 | // regul.SetValue(ic,BRep_Tool::Continuity(TopoDS::Edge(Evive.Value(ic)),F1,F2) | |
1263 | // !=GeomAbs_C0); | |
3f54cc41 | 1264 | regul.SetValue(ic, ChFi3d::IsTangentFaces(TopoDS::Edge(Evive.Value(ic)),F1,F2)); |
7fd59977 | 1265 | // Modified by Sergey KHROMOV - Fri Dec 21 18:11:07 2001 End |
1266 | } | |
1267 | } | |
1268 | } | |
81bba717 | 1269 | // it is checked if a regular edge is not tangent to another edge |
1270 | // in case if it is not considered regular (cts60072) | |
7fd59977 | 1271 | for (ic=0;ic<nedge;ic++) { |
1272 | if (regul.Value(ic) ) { | |
1273 | trouve=Standard_False; | |
1274 | TopoDS_Edge ereg=TopoDS::Edge(Evive.Value(ic)); | |
1275 | for( ind=0;ind<nedge &&!trouve;ind++) { | |
1276 | if (ind!=ic) { | |
1277 | TopoDS_Edge ecur=TopoDS::Edge(Evive.Value(ind)); | |
1278 | Standard_Real ang=Abs(ChFi3d_AngleEdge(V1,ecur,ereg)); | |
c6541a0c | 1279 | if (ang<0.01 || Abs(ang-M_PI) <0.01) { |
7fd59977 | 1280 | regul.SetValue(ic,Standard_False); |
1281 | tangentregul.SetValue(ic,Standard_True); | |
1282 | trouve=Standard_True; | |
1283 | } | |
1284 | } | |
1285 | } | |
1286 | } | |
1287 | } | |
1288 | ||
81bba717 | 1289 | // variable deuxconges allows detecting cases when there is a top with |
1290 | // n edges and two fillets on two tangent edges that are not free borders | |
1291 | // the connecting curves start from the fillet and end on top | |
7fd59977 | 1292 | |
1293 | Standard_Boolean deuxconges,deuxcgnontg; | |
1294 | deuxconges=Standard_False; | |
1295 | trouve=Standard_False; | |
1296 | if (nconges==2) { | |
1297 | TopoDS_Edge E1,E2; | |
1298 | for (ic=0;ic<nedge&&!trouve;ic++) { | |
1299 | Indices(nedge,ic,icplus,icmoins); | |
1300 | if (!sharp.Value(ic) && !sharp.Value(icplus)){ | |
1301 | E1=TopoDS::Edge(Evive.Value(ic)); | |
1302 | E2=TopoDS::Edge(Evive.Value(icplus)); | |
1303 | deuxconges=(Abs(ChFi3d_AngleEdge(V1 ,E1,E2) )<0.01) ; | |
1304 | trouve=deuxconges; | |
1305 | } | |
1306 | } | |
1307 | } | |
1308 | ||
81bba717 | 1309 | // variable deuxconges is used in the special case when there are |
1310 | // two fillets and if two other living edges are tangent (cts60072) | |
7fd59977 | 1311 | if (nconges==2 && nedge==4) { |
1312 | TopoDS_Edge E1,E2; | |
1313 | for (ic=0;ic<nedge&&!deuxconges;ic++) { | |
1314 | Indices(nedge,ic,icplus,icmoins); | |
1315 | if (sharp.Value(ic) && sharp.Value(icplus)){ | |
1316 | E1=TopoDS::Edge(Evive.Value(ic)); | |
1317 | E2=TopoDS::Edge(Evive.Value(icplus)); | |
1318 | if ( !E1.IsSame(edgelibre1) && !E1.IsSame(edgelibre2) && | |
1319 | !E2.IsSame(edgelibre1) && !E2.IsSame(edgelibre2)){ | |
1320 | Standard_Real ang=Abs(ChFi3d_AngleEdge(V1 ,E1,E2)); | |
c6541a0c | 1321 | deuxconges=(ang<0.01 || Abs(ang-M_PI)<0.01); |
7fd59977 | 1322 | } |
1323 | } | |
1324 | } | |
1325 | } | |
1326 | ||
1327 | deuxcgnontg=nconges==2&& nedge==3 && !deuxconges; // pro12305 | |
1328 | ||
1329 | if (deuxconges ) | |
1330 | for (ic=0;ic<nedge;ic++){ | |
1331 | regul.SetValue(ic,Standard_False); | |
1332 | } | |
1333 | ||
1334 | // Detect case of 3 edges & 2 conges: OnSame + OnDiff | |
1335 | // (eap, Arp 9 2002, occ266) | |
1336 | Standard_Boolean isOnSameDiff = Standard_False; | |
1337 | if (deuxcgnontg) { | |
1338 | Standard_Boolean isOnSame = Standard_False, isOnDiff = Standard_False; | |
1339 | for (ic=0; ic<nedge; ic++) { | |
1340 | if (sharp.Value(ic)) continue; | |
1341 | ChFiDS_State stat; | |
1342 | if ( sens(ic) == 1 ) | |
1343 | stat = CD.Value(ic)->Spine()->FirstStatus(); | |
1344 | else | |
1345 | stat = CD.Value(ic)->Spine()->LastStatus(); | |
1346 | ||
1347 | if (stat == ChFiDS_OnSame) isOnSame = Standard_True; | |
1348 | else if (stat == ChFiDS_OnDiff) isOnDiff = Standard_True; | |
1349 | } | |
1350 | isOnSameDiff = isOnSame && isOnDiff; | |
1351 | } | |
1352 | if ( isOnSameDiff ) { | |
0797d9d3 | 1353 | #ifdef OCCT_DEBUG |
04232180 | 1354 | std::cout << "OnSame + OnDiff, PerformMoreThreeCorner() calls PerformOneCorner()" << std::endl; |
7fd59977 | 1355 | #endif |
1356 | PerformOneCorner (Jndex, Standard_True); | |
1357 | } | |
1358 | ||
81bba717 | 1359 | // if the commonpoint is on an edge that does not have a |
1360 | // vertex at the extremity, Evive is found anew | |
1361 | // Fvive is found anew if it does not correspond | |
1362 | // to two faces adjacent to Evive (cts16288) | |
7fd59977 | 1363 | |
1364 | if (!deuxconges && !isOnSameDiff) | |
1365 | for (ic=0;ic<nedge;ic++) { | |
1366 | if (sharp.Value(ic)) { | |
1367 | Indices(nedge,ic,icplus,icmoins); | |
1368 | TopoDS_Edge Arc=TopoDS::Edge(Evive.Value(ic)); | |
1369 | ChFiDS_CommonPoint cp1, cp2; | |
c6541a0c | 1370 | Standard_Real angedg=M_PI; |
7fd59977 | 1371 | TopoDS_Vertex Vcom; |
1372 | if (!sharp.Value(icplus)) { | |
1373 | isfirst=(sens.Value(icplus)==1); | |
1374 | jfp = 3 - jf.Value(icplus); | |
1375 | cp1 = CD.Value(icplus)->SetOfSurfData()->Value(Index.Value(icplus))-> | |
1376 | ChangeVertex (isfirst,jfp); | |
1377 | if (cp1.IsOnArc()){ | |
1378 | ChFi3d_cherche_vertex(Arc,cp1.Arc(),Vcom,trouve); | |
1379 | if (trouve) angedg=Abs(ChFi3d_AngleEdge(Vcom,Arc,cp1.Arc())); | |
c6541a0c | 1380 | if (!cp1.Arc().IsSame(Arc) && Abs(angedg-M_PI)<0.01){ |
7fd59977 | 1381 | Evive.SetValue(ic,cp1.Arc()); |
1382 | ChFi3d_edge_common_faces(myEFMap(cp1.Arc()),F1,F2); | |
1383 | if (!Fvive.Value(ic,icplus).IsSame(F1) && !Fvive.Value(ic,icplus).IsSame(F2)) { | |
1384 | if (Fvive.Value(ic,icmoins).IsSame(F2)) { | |
1385 | Fvive.SetValue(ic,icplus,F1); | |
1386 | Fvive.SetValue(icplus,ic,F1); | |
1387 | numfa.SetValue(ic,icplus,DStr.AddShape(F1)); | |
1388 | numfa.SetValue(icplus,ic,DStr.AddShape(F1)); | |
1389 | } | |
1390 | else { | |
1391 | Fvive.SetValue(ic,icplus,F2); | |
1392 | Fvive.SetValue(icplus,ic,F2); | |
1393 | numfa.SetValue(ic,icplus,DStr.AddShape(F2)); | |
1394 | numfa.SetValue(icplus,ic,DStr.AddShape(F2)); | |
1395 | } | |
1396 | } | |
1397 | samedge.SetValue(ic,Standard_True); | |
1398 | p.SetValue(ic,icplus,cp1.ParameterOnArc()); | |
1399 | p.SetValue(ic,icmoins,cp1.ParameterOnArc()); | |
1400 | i.SetValue(ic,icplus,1); | |
1401 | } | |
1402 | } | |
1403 | } | |
1404 | if (!sharp.Value(icmoins)) { | |
1405 | isfirst=(sens.Value(icmoins)==1); | |
1406 | cp2 = CD.Value(icmoins)->SetOfSurfData()->Value(Index.Value(icmoins))-> | |
1407 | ChangeVertex (isfirst,jf.Value(icmoins)); | |
1408 | if (cp2.IsOnArc()) { | |
c6541a0c | 1409 | angedg=M_PI; |
7fd59977 | 1410 | ChFi3d_cherche_vertex(Arc,cp2.Arc(),Vcom,trouve); |
1411 | if (trouve) angedg=Abs(ChFi3d_AngleEdge(Vcom,Arc,cp2.Arc())); | |
c6541a0c | 1412 | if (!cp2.Arc().IsSame(Arc)&&Abs(angedg-M_PI)<0.01) { |
7fd59977 | 1413 | Evive.SetValue(ic,cp2.Arc()); |
1414 | ChFi3d_edge_common_faces(myEFMap(cp2.Arc()),F1,F2); | |
1415 | if (!Fvive.Value(ic,icmoins).IsSame(F1) && !Fvive.Value(ic,icmoins).IsSame(F2)) { | |
1416 | if (Fvive.Value(ic,icplus).IsSame(F2)) { | |
1417 | Fvive.SetValue(ic,icmoins,F1); | |
1418 | numfa.SetValue(ic,icmoins,DStr.AddShape(F1)); | |
1419 | Fvive.SetValue(icmoins,ic,F1); | |
1420 | numfa.SetValue(icmoins,ic,DStr.AddShape(F1)); | |
1421 | } | |
1422 | else { | |
1423 | Fvive.SetValue(ic,icmoins,F2); | |
1424 | numfa.SetValue(ic,icmoins,DStr.AddShape(F2)); | |
1425 | Fvive.SetValue(icmoins,ic,F2); | |
1426 | numfa.SetValue(icmoins,ic,DStr.AddShape(F2)); | |
1427 | } | |
1428 | } | |
1429 | samedge.SetValue(ic,Standard_True); | |
1430 | p.SetValue(ic,icmoins,cp2.ParameterOnArc()); | |
1431 | p.SetValue(ic,icplus,cp2.ParameterOnArc()); | |
1432 | i.SetValue(ic,icmoins,1); | |
1433 | } | |
1434 | } | |
1435 | } | |
1436 | } | |
1437 | } | |
1438 | ||
81bba717 | 1439 | // the first free edge is restored if it exists |
7fd59977 | 1440 | trouve=Standard_False; |
1441 | for (ic=0; ic<nedge&&!trouve;ic++) { | |
1442 | TopoDS_Edge ecom; | |
1443 | ecom=TopoDS::Edge(Evive.Value(ic)); | |
1444 | if (ecom.IsSame(edgelibre1)||ecom.IsSame(edgelibre2)){ | |
1445 | libre.SetValue(ic,Standard_True); | |
1446 | trouve=Standard_True; | |
1447 | } | |
1448 | } | |
1449 | ||
81bba717 | 1450 | // determine the minimum recoil distance that can't be exceeded |
7fd59977 | 1451 | Standard_Boolean distmini=Standard_False; |
1452 | gp_Pnt som=BRep_Tool::Pnt(V1),pic; | |
1453 | gp_Pnt2d p2; | |
1454 | TopoDS_Edge edgemin; | |
1455 | TopoDS_Vertex V,V2; | |
1456 | Standard_Real dst,distmin; | |
1457 | distmin=1.e30; | |
1458 | for (ic=0;ic<nedge;ic++) { | |
1459 | if (sharp.Value(ic)) | |
1460 | edgemin=TopoDS::Edge(Evive.Value(ic)); | |
1461 | else { | |
1462 | if (sens.Value(ic)==1) | |
1463 | edgemin= CD.Value(ic)->Spine()->Edges(1); | |
1464 | else | |
1465 | edgemin = CD.Value(ic)->Spine()->Edges(CD.Value(ic)->Spine()->NbEdges()); | |
1466 | } | |
1467 | V=TopExp::FirstVertex(edgemin); | |
1468 | V2=TopExp::LastVertex(edgemin); | |
1469 | dst=(BRep_Tool::Pnt(V)).Distance(BRep_Tool::Pnt(V2))/1.5; | |
1470 | if (dst<distmin) distmin=dst; | |
1471 | } | |
1472 | ||
81bba717 | 1473 | // calculate intersections between stripes and determine the parameters on each pcurve |
7fd59977 | 1474 | Standard_Boolean inters=Standard_True; |
1475 | for (ic=0;ic<nedge;ic++) { | |
1476 | Indices(nedge,ic,icplus,icmoins); | |
1477 | if (sharp.Value(ic)||sharp.Value(icplus)) { | |
1478 | oksea.SetValue(ic, Standard_False); | |
1479 | } | |
1480 | else { | |
1d47d8d0 | 1481 | Standard_Integer jf1 = 0; |
1482 | Standard_Integer i1 = 0,i2 = 0; | |
1483 | Standard_Real pa1 = 0.,pa2; | |
7fd59977 | 1484 | Standard_Boolean ok; |
1485 | Handle(ChFiDS_Stripe) strip; | |
1486 | Standard_Real angedg; | |
1487 | Standard_Integer iface; | |
81bba717 | 1488 | // if two edges are tangent the intersection is not attempted (cts60046) |
7fd59977 | 1489 | angedg=Abs(ChFi3d_AngleEdge(V1,TopoDS::Edge(Evive.Value(ic)),TopoDS::Edge(Evive.Value(icplus)))); |
c6541a0c | 1490 | if (Abs(angedg-M_PI)>0.01) |
7fd59977 | 1491 | ok = ChFi3d_SearchFD(DStr,CD.Value(ic),CD.Value(icplus),sens.Value(ic),sens.Value(icplus), |
1492 | i1,i2,pa1,pa2, | |
1493 | Index.Value(ic),Index.Value(icplus), | |
1494 | face,sameside,jf1,jfp); | |
1495 | else ok=Standard_False; | |
81bba717 | 1496 | // if there is an intersection it is checked if surfdata with the intersection |
1497 | // corresponds to the first or the last | |
1498 | // if this is not the case, the surfdata are removed from SD | |
7fd59977 | 1499 | |
1500 | if (ok) { | |
1501 | if (i1!=Index.Value(ic) ){ | |
1502 | Standard_Integer ideb,ifin; | |
1503 | strip=CD.Value(ic); | |
1504 | if (sens.Value(ic)==1) { | |
1505 | ideb=Index.Value(ic); | |
1506 | ifin=i1-1; | |
1507 | } | |
1508 | else { | |
1509 | ifin=Index.Value(ic); | |
1510 | ideb=i1+1; | |
1511 | } | |
1512 | if (i1<Index.Value(ic)) { | |
1513 | for (nb=Index.Value(ic);nb>=i1;nb--) { | |
1514 | if ((3-jf1)==1) | |
1515 | iface=SurfIndex(CD, ic, nb , FACE1); | |
1516 | else iface=SurfIndex(CD, ic, nb , FACE2); | |
1517 | Fproj.Append(TopoDS::Face(myDS->Shape(iface))); | |
1518 | } | |
1519 | } | |
1520 | if (i1>Index.Value(ic)) { | |
1521 | for (nb=Index.Value(ic);nb<=i1;nb++) { | |
1522 | if ((3-jf1)==1) | |
1523 | iface=SurfIndex(CD, ic, nb , FACE1); | |
1524 | else iface=SurfIndex(CD, ic, nb , FACE2); | |
1525 | Fproj.Append(TopoDS::Face(myDS->Shape(iface))); | |
1526 | } | |
1527 | } | |
1528 | strip=CD.Value(ic); | |
1529 | RemoveSD(strip,ideb,ifin); | |
1530 | num=ChFi3d_IndexOfSurfData(V1,CD.Value(ic),sense); | |
1531 | Index.SetValue(ic,num); | |
1532 | i1=num; | |
1533 | } | |
1534 | if (i2!=Index.Value(icplus) ){ | |
1535 | Standard_Integer ideb,ifin; | |
1536 | strip=CD.Value(icplus); | |
1537 | if (sens.Value(icplus)==1) { | |
1538 | ideb=Index.Value(icplus); | |
1539 | ifin=i2-1; | |
1540 | } | |
1541 | else { | |
1542 | ifin=Index.Value(icplus); | |
1543 | ideb=i2+1; | |
1544 | } | |
1545 | ||
1546 | if (i2<Index.Value(icplus)) { | |
1547 | for (nb=i2;nb<=Index.Value(icplus);nb++) { | |
1548 | if ((3-jfp)==1) | |
1549 | iface=SurfIndex(CD, icplus, nb , FACE1); | |
1550 | else iface=SurfIndex(CD, icplus, nb , FACE2); | |
1551 | Fproj.Append(TopoDS::Face(myDS->Shape(iface))); | |
1552 | } | |
1553 | } | |
1554 | if (i2>Index.Value(icplus)) { | |
1555 | for (nb=i2;nb>=Index.Value(icplus);nb--) { | |
1556 | if ((3-jfp)==1) | |
1557 | iface=SurfIndex(CD, icplus, nb , FACE1); | |
1558 | else iface=SurfIndex(CD, icplus, nb , FACE2); | |
1559 | Fproj.Append(TopoDS::Face(myDS->Shape(iface))); | |
1560 | } | |
1561 | } | |
1562 | RemoveSD(strip,ideb,ifin); | |
1563 | num=ChFi3d_IndexOfSurfData(V1,CD.Value(icplus),sense); | |
1564 | Index.SetValue(icplus,num); | |
1565 | i2=num; | |
1566 | } | |
1567 | Calcul_P2dOnSurf(CD.Value(ic),jf1,i1,pa1,p2); | |
1568 | indice=SurfIndex(CD, ic, i1, ChFiSURFACE); | |
1569 | DStr.Surface(indice).Surface()->D0(p2.X(),p2.Y(),pic); | |
1570 | if (pic.Distance(som)>distmin) distmini =Standard_True; | |
1571 | jf.SetValue(ic,jf1); | |
1572 | i.SetValue(ic,icplus,i1); | |
1573 | i.SetValue(icplus,ic,i2); | |
1574 | p.SetValue(ic,icplus,pa1); | |
1575 | p.SetValue(icplus,ic,pa2); | |
1576 | } | |
1577 | oksea.SetValue(ic, ok); | |
1578 | } | |
1579 | if (!oksea.Value(ic) ) inters=Standard_False; | |
1580 | } | |
1581 | ||
81bba717 | 1582 | // case if there are only intersections |
1583 | // the parametres on Pcurves are the extremities of the stripe | |
7fd59977 | 1584 | Standard_Real para; |
1585 | if (!inters) { | |
1586 | for (ic=0;ic<nedge;ic++) { | |
1587 | Indices(nedge,ic,icplus,icmoins); | |
1588 | Indices(nedge,icplus,icplus2,ic); | |
1589 | if (!oksea.Value(ic)) { | |
1590 | cbplus++; | |
1591 | if (sharp.Value(ic)) { | |
1592 | if (!samedge.Value(ic)){ | |
1593 | para=BRep_Tool::Parameter(V1,TopoDS::Edge(Evive.Value(ic))); | |
1594 | p.SetValue(ic,icplus,para); | |
1595 | i.SetValue(ic,icplus,1); | |
1596 | } | |
1597 | } | |
1598 | else { | |
1599 | isfirst= (sens.Value(ic)==1); | |
1600 | i.SetValue(ic,icplus,ChFi3d_IndexOfSurfData(V1,CD.Value(ic),sense)); | |
1601 | if (oksea.Value(icmoins)) { | |
1602 | para=p.Value(ic,icmoins); | |
1603 | p.SetValue(ic,icplus,para); | |
1604 | } | |
1605 | else { | |
1606 | Calcul_Param(CD.Value(ic),jf.Value(ic),i.Value(ic,icplus),isfirst,para); | |
1607 | p.SetValue(ic,icplus,para); | |
1608 | } | |
1609 | } | |
1610 | if (sharp.Value(icplus)) { | |
1611 | if (!samedge.Value(icplus)) { | |
1612 | para=BRep_Tool::Parameter(V1,TopoDS::Edge(Evive.Value(icplus))); | |
1613 | p.SetValue(icplus,ic, para); | |
1614 | i.SetValue(icplus,ic,1); | |
1615 | } | |
1616 | } | |
1617 | else { | |
1618 | isfirst= (sens.Value(icplus)==1); | |
1619 | i.SetValue(icplus,ic,ChFi3d_IndexOfSurfData(V1,CD.Value(icplus),sense)); | |
1620 | if (oksea.Value(icplus)){ | |
1621 | para=p.Value(icplus,icplus2); | |
1622 | p.SetValue(icplus,ic,para); | |
1623 | } | |
1624 | else { | |
1625 | jfp = 3 - jf.Value(icplus); | |
1626 | Calcul_Param(CD.Value(icplus),jfp,i.Value(icplus,ic),isfirst,para); | |
1627 | p.SetValue(icplus,ic,para); | |
1628 | } | |
1629 | } | |
1630 | } | |
1631 | } | |
1632 | ||
81bba717 | 1633 | // calculate max distance to the top at each point |
7fd59977 | 1634 | TColStd_Array1OfReal dist1(0,size); |
1635 | TColStd_Array1OfReal dist2(0,size); | |
1636 | Standard_Real distance=0.; | |
1637 | gp_Pnt sommet=BRep_Tool::Pnt(V1); | |
1638 | if (!deuxconges) | |
1639 | for (ic=0;ic<nedge;ic++) { | |
1640 | Indices(nedge,ic,icplus,icmoins); | |
1641 | if (sharp.Value(ic)) { | |
1642 | dist1.SetValue(ic, 0); | |
1643 | dist2.SetValue(ic, 0); | |
1644 | } | |
1645 | else { | |
1646 | jfp = 3 - jf.Value(ic); | |
1647 | Calcul_P2dOnSurf(CD.Value(ic),jfp,i.Value(ic,icmoins),p.Value(ic,icmoins),p2); | |
1648 | indice=SurfIndex(CD, ic, i.Value(ic,icmoins), ChFiSURFACE); | |
1649 | DStr.Surface(indice).Surface()->D0(p2.X(),p2.Y(),pic); | |
1650 | dist1.SetValue(ic, sommet.Distance(pic)); | |
1651 | if (dist1.Value(ic) > distance ) distance= dist1.Value(ic); | |
1652 | ||
1653 | Calcul_P2dOnSurf(CD.Value(ic),jf.Value(ic),i.Value(ic,icplus),p.Value(ic,icplus),p2); | |
1654 | indice=SurfIndex(CD, ic, i.Value(ic,icplus), ChFiSURFACE); | |
1655 | DStr.Surface(indice).Surface()->D0(p2.X(),p2.Y(),pic); | |
1656 | dist2.SetValue(ic, sommet.Distance(pic)); | |
1657 | if( dist2.Value(ic) > distance ) | |
1658 | distance= dist2.Value(ic); | |
1659 | } | |
1660 | } | |
1661 | ||
81bba717 | 1662 | // offset of parameters and removal of intersection points |
1663 | // too close to the top | |
7fd59977 | 1664 | |
1665 | Standard_Real ec, dist; | |
1666 | if (!deuxconges && !deuxcgnontg) | |
1667 | for (ic=0;ic<nedge;ic++) { | |
1668 | Indices(nedge,ic,icplus,icmoins); | |
1669 | if (sharp.Value(ic) ) { | |
1670 | BRepAdaptor_Curve C(TopoDS::Edge(Evive.Value(ic))); | |
81bba717 | 1671 | // to pass from 3D distance to a parametric distance |
7fd59977 | 1672 | if (!tangentregul(ic)) |
1673 | ec = distance*100*C.Resolution(0.01); | |
1674 | else ec=0.0; | |
1675 | if (TopExp::FirstVertex(TopoDS::Edge(Evive.Value(ic))).IsSame(V1)) { | |
1676 | para=p.Value(ic,icmoins) + ec; | |
1677 | p.SetValue(ic,icmoins, para); | |
1678 | } | |
1679 | else { | |
1680 | para=p.Value(ic,icmoins) - ec; | |
1681 | p.SetValue(ic,icmoins,para); | |
1682 | } | |
81bba717 | 1683 | // it is necessary to be on to remain on the edge |
7fd59977 | 1684 | p.SetValue(ic,icplus, p.Value(ic,icmoins)); |
1685 | } | |
1686 | else if (!distmini) { | |
1687 | dist = dist1.Value(ic); | |
1688 | if ((!oksea.Value(icmoins))||(oksea.Value(icmoins)&&(distance>1.3*dist))) { | |
1689 | ec= distance-dist; | |
1690 | if (oksea.Value(icmoins)) { | |
1691 | oksea.SetValue(icmoins,Standard_False); | |
1692 | inters=Standard_False; | |
1693 | cbplus++; | |
1694 | } | |
1695 | if (sens.Value(ic)==1) { | |
1696 | para=p.Value(ic,icmoins) + ec; | |
1697 | p.SetValue(ic,icmoins, para); | |
1698 | } | |
1699 | else{ | |
1700 | para=p.Value(ic,icmoins) - ec; | |
1701 | p.SetValue(ic,icmoins,para); | |
1702 | } | |
1703 | } | |
1704 | dist = dist2.Value(ic); | |
1705 | if ((!oksea.Value(ic))||(oksea.Value(ic)&&(distance>1.3*dist))) { | |
1706 | if(oksea.Value(ic)) { | |
1707 | oksea.SetValue(ic,Standard_False); | |
1708 | inters=Standard_False; | |
1709 | cbplus++; | |
1710 | } | |
1711 | if (nconges!=1) { | |
1712 | Standard_Real parold,parnew; | |
1713 | parold=p.Value(ic,icplus); | |
1714 | parnew=p.Value(ic,icmoins); | |
1715 | if (sens.Value(ic)==1) { | |
1716 | if (parnew> parold) p.SetValue(ic,icplus, p.Value(ic,icmoins)); | |
1717 | } | |
1718 | else { | |
1719 | if (parnew<parold) p.SetValue(ic,icplus, p.Value(ic,icmoins)); | |
1720 | } | |
1721 | } | |
1722 | } | |
1723 | } | |
1724 | } | |
1725 | } | |
1726 | ||
81bba717 | 1727 | // it is attempted to limit the edge by a commonpoint |
7fd59977 | 1728 | // |
1729 | ||
1730 | Standard_Real tolcp=0; | |
1731 | gp_Pnt PE, sommet=BRep_Tool::Pnt(V1); | |
1732 | if (!deuxconges) | |
1733 | for (ic=0;ic<nedge;ic++) { | |
1734 | if (sharp.Value(ic)) { | |
1735 | Indices(nedge,ic,icplus,icmoins); | |
1736 | BRepAdaptor_Curve C(TopoDS::Edge(Evive.Value(ic))); | |
1737 | PE = C.Value(p.Value(ic,icplus)); | |
1738 | Standard_Real d1=0., d2=0., dS = PE.Distance(sommet); | |
1739 | ChFiDS_CommonPoint cp1, cp2; | |
1740 | if (!sharp.Value(icplus)) { | |
1741 | isfirst=(sens.Value(icplus)==1); | |
1742 | jfp = 3 - jf.Value(icplus); | |
1743 | cp1 = CD.Value(icplus)->SetOfSurfData()->Value(i.Value(icplus,ic))-> | |
1744 | ChangeVertex (isfirst,jfp); | |
1745 | d1 = cp1.Point().Distance(sommet); | |
1746 | } | |
1747 | if (!sharp.Value(icmoins)) { | |
1748 | isfirst=(sens.Value(icmoins)==1); | |
1749 | cp2 = CD.Value(icmoins)->SetOfSurfData()->Value(i.Value(icmoins,ic))-> | |
1750 | ChangeVertex (isfirst,jf.Value(icmoins)); | |
1751 | d2 = cp2.Point().Distance(sommet); | |
1752 | } | |
1753 | Standard_Boolean samecompoint=Standard_False; | |
1754 | if (!sharp.Value(icmoins) && !sharp.Value(icplus)) | |
1755 | samecompoint=cp1.Point().Distance(cp2.Point())<tolapp; | |
1756 | if ((dS<d1 || dS<d2)&& !samecompoint) { | |
81bba717 | 1757 | // step back till Common Points |
1758 | // without leaving the Edge ?? | |
7fd59977 | 1759 | if (d2<d1 &&cp1.IsOnArc() ) { |
81bba717 | 1760 | // cp1 is chosen |
7fd59977 | 1761 | p.SetValue(ic,icmoins, cp1.ParameterOnArc()); |
1762 | p.SetValue(ic,icplus, p.Value(ic,icmoins)); | |
1763 | isfirst=(sens.Value(icplus)==1); | |
1764 | jfp = 3 - jf.Value(icplus); | |
1765 | Calcul_Param(CD.Value(icplus),jfp,i.Value(icplus,ic),isfirst,para); | |
1766 | p.SetValue(icplus,ic,para); | |
1767 | if (cp1.Tolerance()>tolcp &&cp1.Tolerance()<1 ) tolcp=cp1.Tolerance(); | |
1768 | } | |
1769 | else if( cp2.IsOnArc()){ | |
81bba717 | 1770 | // cp2 is chosen |
7fd59977 | 1771 | p.SetValue(ic,icmoins, cp2.ParameterOnArc()); |
1772 | p.SetValue(ic,icplus, p.Value(ic,icmoins)); | |
1773 | isfirst=(sens.Value(icmoins)==1); | |
1774 | Calcul_Param(CD.Value(icmoins),jf.Value(icmoins),i.Value(icmoins,ic),isfirst, para); | |
1775 | p.SetValue(icmoins,ic,para); | |
1776 | if (cp2.Tolerance()>tolcp&&cp2.Tolerance()<1) tolcp=cp2.Tolerance(); | |
1777 | } | |
1778 | } | |
1779 | else { | |
81bba717 | 1780 | // step back till Common Point only if it is very close |
7fd59977 | 1781 | if (!sharp.Value(icplus)) { |
1782 | if ((cp1.Point().Distance(PE)<cp1.Tolerance() || | |
1783 | samecompoint || nconges==1) && cp1.IsOnArc()) { | |
81bba717 | 1784 | // it is very close to cp1 |
7fd59977 | 1785 | p.SetValue(ic,icmoins, cp1.ParameterOnArc()); |
1786 | ponctuel.SetValue(ic,Standard_True); | |
1787 | p.SetValue(ic,icplus, p.Value(ic,icmoins)); | |
1788 | isfirst=(sens.Value(icplus)==1); | |
1789 | jfp = 3 - jf.Value(icplus); | |
1790 | Calcul_Param(CD.Value(icplus),jfp,i.Value(icplus,ic),isfirst,para); | |
1791 | p.SetValue(icplus,ic,para); | |
1792 | if (cp1.Tolerance()>tolcp &&cp1.Tolerance()<1) tolcp=cp1.Tolerance(); | |
1793 | } | |
1794 | } | |
1795 | if (!sharp.Value(icmoins)){ | |
1796 | if ((cp2.Point().Distance(PE)<cp2.Tolerance() || | |
1797 | samecompoint || nconges==1) && cp2.IsOnArc()) { | |
81bba717 | 1798 | // it is very close to cp2 |
7fd59977 | 1799 | ponctuel.SetValue(icmoins,Standard_True); |
1800 | p.SetValue(ic,icmoins, cp2.ParameterOnArc()); | |
1801 | p.SetValue(ic,icplus,p.Value(ic,icmoins)); | |
1802 | isfirst=(sens.Value(icmoins)==1); | |
1803 | Calcul_Param(CD.Value(icmoins),jf.Value(icmoins),i.Value(icmoins,ic),isfirst,para); | |
1804 | p.SetValue(icmoins,ic,para); | |
1805 | if (cp2.Tolerance()>tolcp&&cp2.Tolerance()<1 ) tolcp=cp2.Tolerance(); | |
1806 | } | |
1807 | } | |
1808 | } | |
1809 | } | |
1810 | } | |
1811 | ||
81bba717 | 1812 | // in case of a free border the parameter corresponding |
1813 | // to the common point on the free edge is chosen. | |
7fd59977 | 1814 | |
1815 | for (ic=0;ic<nedge;ic++) { | |
1816 | if (TopoDS::Edge(Evive.Value(ic)).IsSame(edgelibre1) || | |
1817 | TopoDS::Edge(Evive.Value(ic)).IsSame(edgelibre2)) { | |
1818 | Standard_Integer indic; | |
1819 | ChFiDS_CommonPoint CP1; | |
1820 | Indices(nedge,ic,icplus,icmoins); | |
1821 | if (libre.Value(ic))indic=icmoins; | |
1822 | else indic=icplus; | |
1823 | if (!sharp(indic)) { | |
1824 | isfirst=sens.Value(indic)==1; | |
1825 | CP1 = CD.Value(indic)->SetOfSurfData()->Value(Index.Value(indic))->ChangeVertex(isfirst,1); | |
1826 | /*Standard_Boolean*/ trouve=Standard_False; | |
1827 | if (CP1.IsOnArc()) { | |
1828 | if(CP1.Arc().IsSame(TopoDS::Edge(Evive.Value(ic)))) { | |
1829 | p.SetValue(ic,icmoins,CP1.ParameterOnArc()); | |
1830 | p.SetValue(ic,icplus,CP1.ParameterOnArc()); | |
1831 | trouve=Standard_True; | |
1832 | } | |
1833 | } | |
1834 | if (!trouve) { | |
1835 | CP1 = CD.Value(indic)->SetOfSurfData()->Value(Index.Value(indic))->ChangeVertex(isfirst,2); | |
1836 | if (CP1.IsOnArc()) { | |
1837 | if(CP1.Arc().IsSame(TopoDS::Edge(Evive.Value(ic)))) { | |
1838 | p.SetValue(ic,icmoins,CP1.ParameterOnArc()); | |
1839 | p.SetValue(ic,icplus,CP1.ParameterOnArc()); | |
1840 | } | |
1841 | } | |
1842 | } | |
1843 | } | |
1844 | } | |
1845 | } | |
1846 | ||
81bba717 | 1847 | // if ic is a regular edge, one finds edge indfin which is not |
1848 | // a regular edge, and construtc a curve 3d | |
1849 | // between edges (or stripes ) icmoins and indfin. | |
1850 | // Then this courbe3d is projected on all faces (nbface) that | |
1851 | // separate icmoins and indfin | |
7fd59977 | 1852 | Standard_Integer nbface = 0; |
1d47d8d0 | 1853 | Standard_Real error = 0.; |
7fd59977 | 1854 | TColGeom2d_Array1OfCurve proj2d1(0,size); |
1855 | TColGeom2d_Array1OfCurve proj2d2(0,size); | |
1856 | TColGeom_Array1OfCurve cproj1(0,size); | |
1857 | TColGeom_Array1OfCurve cproj2(0,size); | |
1858 | if (!deuxconges) | |
1859 | for (ic=0;ic<nedge;ic++) { | |
1860 | Standard_Integer ilin; | |
1861 | TColGeom_SequenceOfCurve cr; | |
1862 | TColGeom2d_SequenceOfCurve pr; | |
1863 | TopTools_SequenceOfShape Lface; | |
1864 | TopTools_SequenceOfShape Ledge; | |
1865 | Lface.Clear(); | |
1866 | if (regul.Value(ic)){ | |
1867 | Indices(nedge,ic,icplus,icmoins); | |
1868 | Indices(nedge,icplus,icplus2,ic); | |
1869 | Standard_Integer indfin,indfinmoins,indfinplus; | |
1870 | indfin=icplus; | |
1871 | trouve=Standard_False; | |
1872 | ii=icplus; | |
1873 | while (!trouve) { | |
1874 | if (!regul.Value(ii)) { | |
1875 | indfin=ii; | |
1876 | trouve=Standard_True; | |
1877 | } | |
1878 | if (ii==nedge-1) ii=0; | |
1879 | else ii++; | |
1880 | } | |
1881 | Indices(nedge,indfin,indfinplus,indfinmoins); | |
1882 | if (!sharp.Value(icmoins)){ | |
1883 | if( jf.Value(icmoins)==1) | |
1884 | ilin= SurfIndex(CD, icmoins, i.Value(icmoins,ic), FACE1); | |
1885 | else | |
1886 | ilin= SurfIndex(CD, icmoins, i.Value(icmoins,ic), FACE2); | |
1887 | Lface.Append(TopoDS::Face(DStr.Shape(ilin))); | |
1888 | } | |
1889 | else Lface.Append( Fvive(ic,icmoins)); | |
1890 | if (indfin>icmoins) | |
1891 | nbface=indfin-icmoins; | |
1892 | else nbface =nedge-(icmoins-indfin); | |
1893 | TopTools_SequenceOfShape Epj; | |
1894 | TColStd_SequenceOfReal seqpr; | |
1895 | ii=ic; | |
1896 | for (Standard_Integer nf=1;nf<=nbface-1;nf++) { | |
1897 | Standard_Integer iimoins,iiplus; | |
1898 | Indices(nedge,ii,iiplus,iimoins); | |
1899 | Ledge.Append(TopoDS::Edge(Evive.Value(ii))); | |
1900 | seqpr.Append(p.Value(ii,iiplus)); | |
1901 | if (nf!=nbface-1) Lface.Append( Fvive(ii,iiplus)); | |
1902 | if (ii==nedge-1) ii=0; | |
1903 | else ii++; | |
1904 | } | |
1905 | if (!sharp.Value(indfin) ){ | |
1906 | jfp=3-jf.Value(indfin); | |
1907 | if (jfp==1) | |
1908 | ilin= SurfIndex(CD, indfin, i.Value(indfin,indfinmoins), FACE1); | |
1909 | else ilin=SurfIndex(CD, indfin, i.Value(indfin,indfinmoins), FACE2); | |
1910 | Lface.Append(TopoDS::Face(DStr.Shape(ilin))); | |
1911 | } | |
1912 | else Lface.Append(Fvive(indfin,indfinmoins)); | |
1913 | CurveHermite(DStr,CD.Value(icmoins),jf.Value(icmoins),i.Value(icmoins,ic), | |
1914 | p.Value(icmoins,ic),sens.Value(icmoins),sharp.Value(icmoins), | |
1915 | TopoDS::Edge(Evive.Value(icmoins)),CD.Value(indfin),jf.Value(indfin), | |
1916 | i.Value(indfin,indfinmoins),p.Value(indfin,indfinmoins),sens.Value(indfin), | |
1917 | sharp.Value(indfin),TopoDS::Edge(Evive.Value(indfin)),nbface,Ledge, | |
1918 | Lface,pr,cr,Epj,seqpr,error); | |
1919 | ii=ic; | |
1920 | for (ind=1;ind<=nbface-1;ind++) { | |
1921 | Standard_Integer iimoins,iiplus; | |
1922 | Indices(nedge,ii,iiplus,iimoins); | |
1923 | p.SetValue(ii,iiplus,seqpr.Value(ind)); | |
1924 | p.SetValue(ii,iimoins,seqpr.Value(ind)); | |
1925 | proj2d1.SetValue(ii,pr.Value(ind)); | |
1926 | proj2d2.SetValue(ii,pr.Value(ind+1)); | |
1927 | cproj1.SetValue(ii,cr.Value(ind)); | |
1928 | cproj2.SetValue(ii,cr.Value(ind+1)); | |
1929 | if (ii==nedge-1) ii=0; | |
1930 | else ii++; | |
1931 | } | |
1932 | if (!sharp.Value(icmoins)&&!sharp.Value(indfin)) { | |
1933 | ii=icmoins; | |
1934 | while (ii!=indfin) { | |
1935 | isG1.SetValue(ii,Standard_True); | |
1936 | if (ii==nedge-1) ii=0; | |
1937 | else ii++; | |
1938 | } | |
1939 | } | |
1940 | ic=ic+nbface-1; | |
1941 | } | |
1942 | } | |
1943 | ||
81bba717 | 1944 | // case when the conncting curve between ic and icplus crosses many faces |
7fd59977 | 1945 | |
1946 | TopTools_SequenceOfShape Ecom; | |
1947 | TopTools_SequenceOfShape Eproj; | |
1948 | TColStd_SequenceOfReal parcom; | |
1949 | if (!deuxconges) | |
1950 | for (ic=0;ic<nedge;ic++) { | |
1951 | Standard_Integer iface1,iface2; | |
1952 | TopoDS_Face face1,face2; | |
1953 | TopoDS_Edge edge; | |
1954 | TColGeom_SequenceOfCurve cr; | |
1955 | TColGeom2d_SequenceOfCurve pr; | |
1956 | Indices(nedge,ic,icplus,icmoins); | |
1957 | if (!oksea.Value(ic)){ | |
1958 | iface1=numfa.Value(ic,icplus); | |
1959 | iface2=numfa.Value(icplus,ic); | |
1960 | if (!sharp.Value(ic)) { | |
1961 | if (jf.Value(ic)==1) | |
1962 | iface1 =SurfIndex(CD, ic, i.Value(ic,icplus), FACE1); | |
1963 | else iface1=SurfIndex(CD, ic, i.Value(ic,icplus), FACE2); | |
1964 | } | |
1965 | face1=TopoDS::Face(myDS->Shape(iface1)); | |
1966 | ||
1967 | if (!sharp.Value(icplus)) { | |
1968 | if (jf.Value(icplus)==1) | |
1969 | iface2 =SurfIndex(CD, icplus, i.Value(icplus,ic), FACE2); | |
1970 | else iface2=SurfIndex(CD, icplus, i.Value(icplus,ic), FACE1); | |
1971 | } | |
1972 | face2=TopoDS::Face(myDS->Shape(iface2)); | |
1973 | if (!face1.IsSame(face2)) { | |
1974 | if (Fproj.Length()==0) { | |
1975 | Fproj.Append(face1); | |
1976 | Fproj.Append(face2); | |
1977 | } | |
1978 | moresurf.SetValue(ic,Standard_True); | |
1979 | nbface=Fproj.Length(); | |
1980 | if (!TopoDS::Face(Fproj.Value(nbface)).IsSame(face2)) { | |
1981 | Fproj.Remove(nbface); | |
1982 | Fproj.Append(face2); | |
1983 | } | |
1984 | if (!TopoDS::Face(Fproj.Value(1)).IsSame(face1)) { | |
1985 | Fproj.Remove(1); | |
1986 | Fproj.Prepend(face1); | |
1987 | } | |
1988 | for (nb=1;nb<=nbface-1; nb++) { | |
1989 | cherche_edge1 ( TopoDS::Face(Fproj.Value(nb)), TopoDS::Face(Fproj.Value(nb+1)),edge); | |
1990 | Ecom.Append(edge); | |
1991 | para=BRep_Tool::Parameter(TopExp::FirstVertex(edge),edge); | |
1992 | parcom.Append(para); | |
1993 | } | |
1994 | CurveHermite (DStr,CD.Value(ic),jf.Value(ic),i.Value(ic,icplus), | |
1995 | p.Value(ic,icplus),sens.Value(ic),sharp.Value(ic), | |
1996 | TopoDS::Edge(Evive.Value(ic)), | |
1997 | CD.Value(icplus),jf.Value(icplus),i.Value(icplus,ic), | |
1998 | p.Value(icplus,ic),sens.Value(icplus),sharp.Value(icplus), | |
1999 | TopoDS::Edge(Evive.Value(icplus)),nbface,Ecom,Fproj, pr,cr,Eproj,parcom,error); | |
2000 | Ecom.Append(Ecom.Value(nbface-1)); | |
2001 | parcom.Append(parcom.Value(nbface-1)); | |
2002 | } | |
2003 | } | |
2004 | } | |
2005 | ||
81bba717 | 2006 | // case when two fillets have the same commonpoints |
2007 | // one continues then by intersection | |
2008 | // it is checked if the extremities of the intersection coincide with commonpoints | |
7fd59977 | 2009 | |
2010 | Standard_Boolean intersection=Standard_False, introuve; | |
2011 | if (nconges==2 && !deuxconges) { | |
2012 | gp_Pnt P1,P2,P3,P4; | |
7fd59977 | 2013 | Standard_Integer ic1 = 0,ic2 = 0; |
7fd59977 | 2014 | trouve=Standard_False; |
2015 | for (ic=0;ic<nedge&&!trouve;ic++) { | |
2016 | if (!sharp.Value(ic)){ | |
2017 | ic1=ic; | |
2018 | trouve=Standard_True; | |
2019 | } | |
2020 | } | |
2021 | for (ic=0;ic<nedge;ic++) { | |
2022 | if (!sharp.Value(ic)&& ic!=ic1) ic2=ic; | |
2023 | } | |
2024 | jfp = 3 - jf.Value(ic1); | |
2025 | Indices(nedge,ic1,icplus,icmoins); | |
2026 | Calcul_P2dOnSurf(CD.Value(ic1),jfp,i.Value(ic1,icmoins),p.Value(ic1,icmoins),p2); | |
2027 | indice=SurfIndex(CD, ic1, i.Value(ic1,icmoins), ChFiSURFACE); | |
2028 | DStr.Surface(indice).Surface()->D0(p2.X(),p2.Y(),P1); | |
2029 | ||
2030 | Calcul_P2dOnSurf(CD.Value(ic1),jf.Value(ic1),i.Value(ic1,icplus),p.Value(ic1,icplus),p2); | |
2031 | indice=SurfIndex(CD, ic1, i.Value(ic1,icplus), ChFiSURFACE); | |
2032 | DStr.Surface(indice).Surface()->D0(p2.X(),p2.Y(),P2); | |
2033 | ||
2034 | jfp = 3 - jf.Value(ic2); | |
2035 | Indices(nedge,ic2,icplus,icmoins); | |
2036 | Calcul_P2dOnSurf(CD.Value(ic2),jfp,i.Value(ic2,icmoins),p.Value(ic2,icmoins),p2); | |
2037 | indice=SurfIndex(CD, ic2, i.Value(ic2,icmoins), ChFiSURFACE); | |
2038 | DStr.Surface(indice).Surface()->D0(p2.X(),p2.Y(),P3); | |
2039 | ||
2040 | Calcul_P2dOnSurf(CD.Value(ic2),jf.Value(ic2),i.Value(ic2,icplus),p.Value(ic2,icplus),p2); | |
2041 | indice=SurfIndex(CD, ic2, i.Value(ic2,icplus), ChFiSURFACE); | |
2042 | DStr.Surface(indice).Surface()->D0(p2.X(),p2.Y(),P4); | |
2043 | intersection=(P1.Distance(P4)<=1.e-7 || P1.Distance(P3)<=1.e-7) && | |
2044 | (P2.Distance(P4)<=1.e-7 || P2.Distance(P3)<=1.e-7); | |
2045 | if (intersection) { | |
2046 | PerformTwoCornerSameExt(DStr,CD.Value(ic1),Index.Value(ic1),sens.Value(ic1), | |
2047 | CD.Value(ic2),Index.Value(ic2),sens.Value(ic2),introuve); | |
2048 | if (introuve) return; | |
2049 | } | |
2050 | } | |
2051 | ||
81bba717 | 2052 | // declaration for plate |
7fd59977 | 2053 | GeomPlate_BuildPlateSurface PSurf(3,10,3,tol2d,tolesp,angular); |
2054 | ||
81bba717 | 2055 | // calculation of curves on surface for each stripe |
7fd59977 | 2056 | for (ic=0;ic<nedge;ic++) { |
2057 | gp_Pnt2d p2d1, p2d2; | |
2058 | if (!sharp.Value(ic)) { | |
2059 | n3d++; | |
2060 | Indices(nedge,ic,icplus,icmoins); | |
2061 | jfp = 3 - jf.Value(ic); | |
2062 | Calcul_P2dOnSurf(CD.Value(ic),jfp,i.Value(ic,icmoins),p.Value(ic,icmoins),p2d1); | |
2063 | Calcul_P2dOnSurf(CD.Value(ic),jf.Value(ic),i.Value(ic,icplus),p.Value(ic,icplus),p2d2); | |
04232180 | 2064 | // if (i[ic][icplus]!= i[ic][icmoins]) std::cout<<"probleme surface"<<std::endl; |
7fd59977 | 2065 | indice= SurfIndex(CD, ic, i.Value(ic,icplus), ChFiSURFACE); |
c22b52d6 | 2066 | Handle (GeomAdaptor_Surface) Asurf = |
2067 | new GeomAdaptor_Surface(DStr.Surface(indice).Surface()); | |
81bba717 | 2068 | // calculation of curve 2d |
7fd59977 | 2069 | xdir= p2d2.X()-p2d1.X(); |
2070 | ydir= p2d2.Y()-p2d1.Y(); | |
2071 | Standard_Real l0 = sqrt(xdir*xdir+ ydir*ydir ); | |
2072 | gp_Dir2d dir (xdir, ydir); | |
2073 | Handle(Geom2d_Line) l= new Geom2d_Line (p2d1 ,dir); | |
2074 | Handle (Geom2d_Curve) pcurve = new Geom2d_TrimmedCurve(l,0,l0); | |
c22b52d6 | 2075 | Handle (Geom2dAdaptor_Curve) Acurv = new Geom2dAdaptor_Curve(pcurve); |
7fd59977 | 2076 | Adaptor3d_CurveOnSurface CurvOnS (Acurv,Asurf); |
c22b52d6 | 2077 | Handle(Adaptor3d_CurveOnSurface) HCons = |
2078 | new Adaptor3d_CurveOnSurface(CurvOnS); | |
7fd59977 | 2079 | Order.SetValue(ic,1); |
2080 | Handle(GeomPlate_CurveConstraint) Cont = | |
2081 | new GeomPlate_CurveConstraint(HCons,Order.Value(ic),10,tolesp,angular,0.1); | |
2082 | PSurf.Add(Cont); | |
2083 | ||
81bba717 | 2084 | // calculate indexes of points and of the curve for the DS |
7fd59977 | 2085 | isfirst=(sens.Value(ic)==1); |
2086 | GeomLib::BuildCurve3d(tolapp,CurvOnS,CurvOnS.FirstParameter(), | |
2087 | CurvOnS.LastParameter(),Curv3d,maxapp,avedev); | |
2088 | TopOpeBRepDS_Curve tcurv3d( Curv3d,maxapp); | |
2089 | indcurve3d.SetValue(n3d,DStr.AddCurve(tcurv3d)); | |
2090 | gp_Pnt point1,point2; | |
2091 | point1= CurvOnS.Value(CurvOnS.FirstParameter()); | |
2092 | point2 =CurvOnS.Value(CurvOnS.LastParameter()); | |
2093 | ||
2094 | TopOpeBRepDS_Point tpoint1 (point1,maxapp); | |
2095 | TopOpeBRepDS_Point tpoint2 (point2,maxapp); | |
2096 | errapp.SetValue(ic,maxapp); | |
2097 | if (ic==0) { | |
81bba717 | 2098 | // it is necessary to create two points |
7fd59977 | 2099 | indpoint.SetValue(ic,0,DStr.AddPoint(tpoint1)); |
2100 | indpoint.SetValue(ic,1,DStr.AddPoint(tpoint2)); | |
2101 | } | |
2102 | else { | |
81bba717 | 2103 | // probably the points are already on the fillet |
2104 | // (previous intersection...) | |
7fd59977 | 2105 | trouve = Standard_False; |
2106 | for (ii=0;ii<ic&&(!trouve);ii++) { | |
2107 | if (!sharp.Value(ii)) { | |
2108 | TopOpeBRepDS_Point & tpt= DStr.ChangePoint(indpoint.Value(ii,1)); | |
2109 | if (point1.Distance(tpt.Point())<1.e-4) | |
2110 | trouve = Standard_True; | |
2111 | } | |
2112 | } | |
2113 | if (trouve) | |
2114 | indpoint.SetValue(ic,0,indpoint.Value(ii-1,1)); | |
2115 | else | |
2116 | indpoint.SetValue(ic,0,DStr.AddPoint(tpoint1)); | |
2117 | ||
2118 | trouve = Standard_False; | |
2119 | for (ii=0;ii<ic&&(!trouve);ii++) { | |
2120 | if (!sharp.Value(ii)) { | |
2121 | TopOpeBRepDS_Point & tpt= DStr.ChangePoint(indpoint.Value(ii,0)); | |
2122 | if (point2.Distance(tpt.Point())<1.e-4) | |
2123 | trouve = Standard_True; | |
2124 | } | |
2125 | } | |
2126 | if (trouve) | |
2127 | indpoint.SetValue(ic,1,indpoint.Value(ii-1,0)); | |
2128 | else | |
2129 | indpoint.SetValue(ic,1,DStr.AddPoint(tpoint2)); | |
2130 | } | |
2131 | ||
81bba717 | 2132 | // update of the stripe |
7fd59977 | 2133 | isurf1=3-jf.Value(ic); isurf2=jf.Value(ic); |
2134 | if (isurf1==2) CD.Value(ic)->SetOrientation(TopAbs_REVERSED,isfirst); | |
2135 | CD.Value(ic)->SetCurve(indcurve3d.Value(n3d),isfirst); | |
2136 | CD.Value(ic)->SetIndexPoint(indpoint.Value(ic,0),isfirst,isurf1); | |
2137 | CD.Value(ic)->SetIndexPoint(indpoint.Value(ic,1),isfirst,isurf2); | |
2138 | CD.Value(ic)->SetParameters(isfirst,pcurve->FirstParameter(),pcurve->LastParameter()); | |
2139 | ChFiDS_CommonPoint cp1; | |
2140 | ChFiDS_CommonPoint cp2; | |
2141 | cp1.SetPoint (point1); | |
2142 | cp2.SetPoint( point2); | |
2143 | CD.Value(ic)->SetOfSurfData()->Value(i.Value(ic,icmoins))-> | |
2144 | ChangeVertex (isfirst,isurf1)=cp1; | |
2145 | CD.Value(ic)->SetOfSurfData()->Value(i.Value(ic,icmoins))-> | |
2146 | ChangeVertex (isfirst,isurf2)=cp2; | |
2147 | CD.Value(ic)->SetOfSurfData()->Value(i.Value(ic,icmoins))-> | |
2148 | ChangeInterference(isurf1).SetParameter(p.Value(ic,icmoins),isfirst); | |
2149 | CD.Value(ic)->SetOfSurfData()->Value(i.Value(ic,icmoins))-> | |
2150 | ChangeInterference(isurf2).SetParameter(p.Value(ic,icplus),isfirst); | |
2151 | CD.Value(ic)-> ChangePCurve(isfirst)= pcurve; | |
2152 | } | |
2153 | } | |
2154 | ||
81bba717 | 2155 | // calculate the indices of points for living edges |
7fd59977 | 2156 | for (ic=0;ic<nedge;ic++) { |
2157 | if (sharp.Value(ic)) { | |
2158 | Indices(nedge,ic,icplus,icmoins); | |
2159 | BRepAdaptor_Curve C(TopoDS::Edge(Evive.Value(ic))); | |
2160 | /*gp_Pnt*/ PE = C.Value(p.Value(ic,icplus)); | |
2161 | TopOpeBRepDS_Point TPE(PE,BRep_Tool::Tolerance(TopoDS::Edge(Evive.Value(ic)))); | |
2162 | ChFiDS_CommonPoint cp; | |
2163 | if (deuxconges ) { | |
2164 | IVtx = DStr.AddShape(V1); | |
2165 | indpoint.SetValue(ic,0, IVtx ); | |
2166 | indpoint.SetValue(ic,1, IVtx ); | |
2167 | } | |
2168 | if (!sharp.Value(icplus)) { | |
2169 | isfirst=(sens.Value(icplus)==1); | |
2170 | jfp = 3 - jf.Value(icplus); | |
2171 | cp = CD.Value(icplus)->SetOfSurfData()->Value(i.Value(icplus,ic))-> | |
2172 | ChangeVertex (isfirst,jfp); | |
2173 | if ( cp.Point().Distance(PE) <= Max(1.e-4,tolcp)) { | |
81bba717 | 2174 | // edge was limited by the 1st CommonPoint of CD[icplus] |
7fd59977 | 2175 | indpoint.SetValue(ic,0,indpoint.Value(icplus,0)); |
2176 | indpoint.SetValue(ic,1,indpoint.Value(icplus,0)); | |
2177 | } | |
2178 | } | |
2179 | if (!sharp.Value(icmoins)) { | |
2180 | isfirst=(sens.Value(icmoins)==1); | |
2181 | cp = CD.Value(icmoins)->SetOfSurfData()->Value(i.Value(icmoins,ic))-> | |
2182 | ChangeVertex (isfirst,jf.Value(icmoins)); | |
2183 | if ( cp.Point().Distance(PE) <= Max(1.e-4,tolcp)) { | |
81bba717 | 2184 | // edge was limited by the 2nd CommonPoint of CD[icmoins] |
7fd59977 | 2185 | if (indpoint.Value(ic,0)==0) { |
2186 | indpoint.SetValue(ic,0, indpoint.Value(icmoins,1)); | |
2187 | indpoint.SetValue(ic,1, indpoint.Value(icmoins,1)); | |
2188 | } | |
2189 | } | |
2190 | } | |
2191 | if (indpoint.Value(ic,0)==0) { | |
2192 | indpoint.SetValue(ic,0,DStr.AddPoint(TPE)); | |
2193 | indpoint.SetValue(ic,1, indpoint.Value(ic,0)); | |
2194 | } | |
2195 | } | |
2196 | } | |
2197 | ||
81bba717 | 2198 | // calculation of intermediary curves connecting two stripes in case if |
2199 | // there is no intersection. The curve is a straight line, projection or batten | |
7fd59977 | 2200 | |
2201 | Standard_Boolean raccordbatten; | |
2202 | if (!inters) { | |
2203 | ||
2204 | for (ic=0;ic<nedge;ic++) { | |
2205 | ||
2206 | if (!oksea.Value(ic)&& !moresurf.Value(ic) && !libre.Value(ic) ) { | |
2207 | Indices(nedge,ic,icplus,icmoins); | |
2208 | raccordbatten=Standard_False; | |
2209 | if (!regul.Value(ic)) { | |
2210 | raccordbatten=Standard_True; | |
2211 | if (regul.Value(icplus)) | |
2212 | raccordbatten=Standard_False; | |
2213 | } | |
2214 | n3d++; | |
2215 | gp_Pnt2d p2d1, p2d2; | |
2216 | Handle(Geom2d_Curve) curv2d1,curv2d2; | |
2217 | Handle (Geom2d_Curve) pcurve; | |
2218 | Handle (Geom_Curve) curveint; | |
c22b52d6 | 2219 | Handle (GeomAdaptor_Surface) Asurf; |
7fd59977 | 2220 | Standard_Real u1bid,u2bid; |
2221 | ||
81bba717 | 2222 | // return the 1st curve 2d |
2223 | // and the 1st connection point | |
7fd59977 | 2224 | if (sharp.Value(ic)) |
2225 | curv2d1 = BRep_Tool::CurveOnSurface(TopoDS::Edge(Evive.Value(ic)),TopoDS::Face(Fvive.Value(ic,icplus)), | |
2226 | u1bid,u2bid); | |
2227 | else | |
2228 | Calcul_C2dOnFace(CD.Value(ic),jf.Value(ic),i.Value(ic,icplus),curv2d1); | |
2229 | p2d1 = curv2d1 ->Value(p.Value(ic,icplus)); | |
2230 | ||
2231 | // recuperation de la deuxieme courbe 2d | |
2232 | // et du deuxieme point de raccordement | |
2233 | if (sharp.Value(icplus)) | |
2234 | curv2d2 = BRep_Tool::CurveOnSurface(TopoDS::Edge(Evive.Value(icplus)), | |
2235 | TopoDS::Face(Fvive.Value(ic,icplus)),u1bid,u2bid); | |
2236 | else { | |
2237 | jfp = 3 - jf.Value(icplus); | |
2238 | Calcul_C2dOnFace(CD.Value(icplus),jfp,i.Value(icplus,ic),curv2d2); | |
2239 | } | |
2240 | p2d2 = curv2d2 ->Value(p.Value(icplus,ic)); | |
2241 | ||
c22b52d6 | 2242 | Asurf = new GeomAdaptor_Surface(BRep_Tool::Surface(TopoDS::Face(Fvive.Value(ic,icplus)))); |
7fd59977 | 2243 | Standard_Real tolu,tolv,ratio; |
c22b52d6 | 2244 | tolu=Asurf->UResolution(1.e-3); |
2245 | tolv=Asurf->VResolution(1.e-3); | |
7fd59977 | 2246 | if (tolu>tolv) ratio=tolu/tolv; |
2247 | else ratio=tolv/tolu; | |
2248 | ||
81bba717 | 2249 | // in case of a sewing edge the parameters are reframed |
7fd59977 | 2250 | if (couture) { |
2251 | Standard_Boolean PI1=Standard_False, PI2=Standard_False; | |
2252 | Standard_Real xx; | |
c6541a0c D |
2253 | PI1=0<=p2d1.X() && p2d1.X() <=M_PI; |
2254 | PI2=0<=p2d2.X() && p2d2.X() <=M_PI; | |
7fd59977 | 2255 | |
2256 | if (Evive.Value(ic).IsSame(edgecouture)){ | |
2257 | xx=p2d1.X(); | |
c6541a0c D |
2258 | if (PI2&&!PI1) xx=xx-2*M_PI; |
2259 | if (!PI2&&PI1) xx=xx+2*M_PI; | |
7fd59977 | 2260 | p2d1.SetX(xx); |
2261 | ||
2262 | } | |
2263 | if (Evive.Value(icplus).IsSame(edgecouture)){ | |
2264 | xx=p2d2.X(); | |
c6541a0c D |
2265 | if (PI2&&!PI1) xx=xx+2*M_PI; |
2266 | if (!PI2&&PI1) xx=xx-2*M_PI; | |
7fd59977 | 2267 | p2d2.SetX(xx); |
2268 | } | |
2269 | } | |
2270 | xdir= p2d2.X()-p2d1.X(); | |
2271 | ydir= p2d2.Y()-p2d1.Y(); | |
2272 | ||
2273 | Standard_Real l0 = sqrt(xdir*xdir+ ydir*ydir ); | |
2274 | if (l0<1.e-7|| ponctuel.Value(ic)) { | |
81bba717 | 2275 | // unused connection |
7fd59977 | 2276 | n3d--; |
2277 | ponctuel.SetValue(ic,Standard_True); | |
2278 | if (!deuxconges) { | |
2279 | if ( sharp.Value(icplus) && indpoint.Value(icplus,0) == 0 ) { | |
2280 | indpoint.SetValue(icplus,0, indpoint.Value(ic,1)); | |
2281 | indpoint.SetValue(icplus,1, indpoint.Value(ic,1)); | |
2282 | } | |
2283 | if ( sharp.Value(ic) && indpoint.Value(ic,0) == 0 ) { | |
2284 | indpoint.SetValue(ic,0,indpoint.Value(icmoins,1)); | |
2285 | indpoint.SetValue(ic,1,indpoint.Value(icmoins,1)); | |
2286 | } | |
2287 | } | |
2288 | } | |
81bba717 | 2289 | else { // the connection is a straight line, projection or batten |
7fd59977 | 2290 | if (ratio>10 && nconges==1) raccordbatten=Standard_True; |
2291 | if (ratio>10 && raccordbatten) { | |
2292 | CalculDroite(p2d1,xdir,ydir,pcurve); | |
2293 | raccordbatten=Standard_False; | |
2294 | } | |
81bba717 | 2295 | else if (!raccordbatten){ // the projected curves are returned |
7fd59977 | 2296 | if (regul.Value(ic)) { |
2297 | if (cproj2.Value(ic).IsNull()){ | |
2298 | raccordbatten=Standard_True; | |
2299 | } | |
2300 | else { | |
2301 | pcurve=proj2d2.Value(ic); | |
2302 | curveint=cproj2.Value(ic); | |
2303 | maxapp1=1.e-6; | |
2304 | } | |
2305 | ||
2306 | } | |
2307 | else { | |
2308 | if (cproj1.Value(ic+1).IsNull()) { | |
2309 | raccordbatten=Standard_True; | |
2310 | } | |
2311 | else { | |
2312 | pcurve=proj2d1.Value(ic+1); | |
2313 | curveint=cproj1.Value(ic+1); | |
2314 | maxapp1=1.e-6; | |
2315 | } | |
2316 | } | |
2317 | } | |
2318 | Standard_Boolean contraint1=Standard_True, | |
2319 | contraint2=Standard_True; | |
2320 | if (raccordbatten) { | |
0797d9d3 | 2321 | #ifdef OCCT_DEBUG |
81bba717 | 2322 | ChFi3d_InitChron(ch);// initial performances for battens |
7fd59977 | 2323 | #endif |
2324 | Standard_Boolean inverseic,inverseicplus; | |
2325 | if (sharp.Value(ic)) { | |
2326 | inverseic=TopExp::FirstVertex(TopoDS::Edge(Evive.Value(ic))). | |
2327 | IsSame(V1); | |
2328 | } | |
2329 | else { | |
2330 | inverseic=sens.Value(ic)==1; | |
2331 | } | |
2332 | if (sharp.Value(icplus)){ | |
2333 | inverseicplus=TopExp::FirstVertex(TopoDS::Edge(Evive.Value(icplus))). | |
2334 | IsSame(V1); | |
2335 | } | |
2336 | else { | |
2337 | inverseicplus=sens.Value(icplus)==1; | |
2338 | } | |
2339 | if (TopoDS::Edge(Evive.Value(ic)).IsSame(edgelibre1) || | |
2340 | TopoDS::Edge(Evive.Value(ic)).IsSame(edgelibre2)) | |
2341 | contraint1=Standard_False; | |
2342 | if (TopoDS::Edge(Evive.Value(icplus)).IsSame(edgelibre1) || | |
2343 | TopoDS::Edge(Evive.Value(icplus)).IsSame(edgelibre2)) | |
2344 | contraint2=Standard_False; | |
2345 | CalculBatten(Asurf,TopoDS::Face(Fvive(ic,icplus)),xdir,ydir,p2d1,p2d2,contraint1,contraint2,curv2d1,curv2d2,p.Value(ic,icplus), | |
2346 | p.Value(icplus,ic),inverseic,inverseicplus,pcurve); | |
0797d9d3 | 2347 | #ifdef OCCT_DEBUG |
81bba717 | 2348 | ChFi3d_ResultChron( ch,t_batten); // resulting performances for battens |
7fd59977 | 2349 | #endif |
2350 | } | |
2351 | ||
81bba717 | 2352 | // construction of borders for Plate |
c22b52d6 | 2353 | Handle (Geom2dAdaptor_Curve) Acurv=new Geom2dAdaptor_Curve(pcurve); |
7fd59977 | 2354 | Adaptor3d_CurveOnSurface CurvOnS (Acurv,Asurf); |
c22b52d6 | 2355 | Handle(Adaptor3d_CurveOnSurface) HCons = |
2356 | new Adaptor3d_CurveOnSurface(CurvOnS); | |
7fd59977 | 2357 | |
81bba717 | 2358 | // constraints G1 are set if edges ic and icplus are not both alive |
7fd59977 | 2359 | |
2360 | ||
2361 | Order.SetValue(n3d,0); | |
2362 | if (!sharp.Value(ic)&& !sharp.Value(icplus)) | |
2363 | Order.SetValue(n3d,1); | |
2364 | if (!contraint1 && !sharp.Value(icplus)) | |
2365 | Order.SetValue(n3d,1); | |
2366 | if (!contraint2 && !sharp.Value(ic)) | |
2367 | Order.SetValue(n3d,1); | |
2368 | if (tangentregul(ic) || tangentregul(icplus) ) | |
2369 | Order.SetValue(n3d,1); | |
2370 | if (isG1.Value(ic)) | |
2371 | Order.SetValue(n3d,1); | |
2372 | Handle(GeomPlate_CurveConstraint) Cont = | |
2373 | new GeomPlate_CurveConstraint(HCons,Order.Value(n3d),10,tolesp,angular,0.1); | |
2374 | PSurf.Add(Cont); | |
2375 | ||
81bba717 | 2376 | //calculation of curve 3d if it is not a projection |
7fd59977 | 2377 | if (curveint.IsNull()) { |
2378 | GeomLib::BuildCurve3d(tolapp,CurvOnS,CurvOnS.FirstParameter(), | |
2379 | CurvOnS.LastParameter(),Curv3d,maxapp1,avedev); | |
2380 | pardeb=CurvOnS.FirstParameter(); | |
2381 | parfin= CurvOnS.LastParameter(); | |
2382 | curveint= new Geom_TrimmedCurve(Curv3d,pardeb,parfin); | |
2383 | } | |
2384 | ||
81bba717 | 2385 | //storage in the DS |
7fd59977 | 2386 | TopOpeBRepDS_Curve tcurv3d( curveint,maxapp1); |
2387 | indcurve3d.SetValue(n3d, DStr.AddCurve(tcurv3d)); | |
2388 | pardeb=curveint->FirstParameter(); | |
2389 | parfin=curveint->LastParameter(); | |
2390 | if ( sharp.Value(icplus) && indpoint.Value(icplus,0) == 0) { | |
81bba717 | 2391 | // it is necessary to initialize indpoint[icplus][0] and indpoint[icplus][1] |
7fd59977 | 2392 | gp_Pnt point2; |
2393 | point2 =curveint->Value(parfin); | |
2394 | TopOpeBRepDS_Point tpoint2 (point2,maxapp); | |
2395 | indpoint.SetValue(icplus,0,DStr.AddPoint(tpoint2)); | |
2396 | indpoint.SetValue(icplus,1,indpoint.Value(icplus,0)); | |
2397 | } | |
2398 | Standard_Boolean IsVt1=Standard_False; | |
2399 | Standard_Boolean IsVt2=Standard_False; | |
2400 | if(deuxconges) { | |
2401 | IsVt1=sharp.Value(ic); | |
2402 | IsVt2=sharp.Value(icplus); | |
2403 | } | |
2404 | Interfp1=ChFi3d_FilPointInDS(TopAbs_FORWARD,indcurve3d.Value(n3d), | |
2405 | indpoint.Value(ic,1),pardeb,IsVt1); | |
2406 | Interfp2=ChFi3d_FilPointInDS(TopAbs_REVERSED,indcurve3d.Value(n3d), | |
2407 | indpoint(icplus,0),parfin,IsVt2); | |
2408 | DStr.ChangeCurveInterferences(indcurve3d.Value(n3d)).Append(Interfp1); | |
2409 | DStr.ChangeCurveInterferences(indcurve3d.Value(n3d)).Append(Interfp2); | |
2410 | if (!IsVt1) { | |
2411 | TopOpeBRepDS_Point & tpt1= DStr.ChangePoint(indpoint(ic,1)); | |
2412 | tpt1.Tolerance (tpt1.Tolerance()+maxapp1); | |
2413 | } | |
2414 | if (!IsVt2) { | |
2415 | TopOpeBRepDS_Point &tpt2= DStr.ChangePoint(indpoint(icplus,0)); | |
2416 | tpt2.Tolerance (tpt2.Tolerance()+maxapp1); | |
2417 | } | |
2418 | ||
81bba717 | 2419 | // calculate orientation of the curve |
7fd59977 | 2420 | TopAbs_Orientation orinterf; |
2421 | if (!sharp.Value(ic)) { | |
2422 | OrientationIcNonVive(CD.Value(ic),jf.Value(ic),i.Value(ic,icplus),sens.Value(ic),orinterf); | |
2423 | } | |
2424 | else if (!sharp.Value(icplus)) { | |
2425 | OrientationIcplusNonVive(CD.Value(icplus),jf.Value(icplus),i.Value(icplus,ic),sens.Value(icplus),orinterf); | |
2426 | } | |
2427 | else { | |
2428 | OrientationAreteViveConsecutive (Fvive.Value(ic,icplus) ,Evive.Value(ic),V1,orinterf); | |
2429 | } | |
2430 | Interfc=ChFi3d_FilCurveInDS(indcurve3d.Value(n3d),numfa.Value(ic,icplus),pcurve,orinterf); | |
2431 | DStr.ChangeShapeInterferences(numfa.Value(ic,icplus)).Append(Interfc); | |
2432 | } | |
81bba717 | 2433 | } // end of processing by edge |
2434 | } // end of the loop on edges | |
2435 | } // end of processing for intermediary curves | |
7fd59977 | 2436 | |
81bba717 | 2437 | // storage in the DS of curves projected on several faces |
7fd59977 | 2438 | for (ic=0;ic<nedge;ic++) { |
2439 | if (moresurf.Value(ic) ){ | |
2440 | TopoDS_Vertex Vf,Vl; | |
2441 | gp_Pnt Pf,Pl,P1,P2,Pcom; | |
2442 | ind = 0; //must be initialized because of possible use, see L2249 | |
2443 | Standard_Real up1,up2; | |
2444 | TopAbs_Orientation orvt; | |
2445 | TopAbs_Orientation oredge = TopAbs_FORWARD; | |
2446 | Standard_Integer indpoint1,indpoint2; | |
2447 | Indices(nedge,ic,icplus,icmoins); | |
2448 | Handle(Geom2d_Curve) proj,proj2d; | |
2449 | Handle(Geom_Curve) projc,cproj; | |
2450 | TopOpeBRepDS_Point& tpt1= DStr.ChangePoint(indpoint(ic,1)); | |
2451 | TopOpeBRepDS_Point& tpt2= DStr.ChangePoint(indpoint(icplus,0)); | |
2452 | tpt1.Tolerance (tpt1.Tolerance()+error); | |
2453 | tpt2.Tolerance (tpt1.Tolerance()+error); | |
2454 | for(nb=1;nb<=nbface;nb++) { | |
2455 | orvt=TopAbs_REVERSED; | |
2456 | Vf=TopExp::FirstVertex(TopoDS::Edge(Ecom.Value(nb))); | |
2457 | Vl=TopExp::LastVertex (TopoDS::Edge(Ecom.Value(nb))); | |
2458 | Pf=BRep_Tool::Pnt(Vf); | |
2459 | Pl=BRep_Tool::Pnt(Vl); | |
2460 | para=parcom.Value(nb); | |
2461 | Pcom=BRep_Tool::Curve(TopoDS::Edge(Ecom.Value(nb)),up1,up2)->Value(para); | |
2462 | if (Pf.Distance(BRep_Tool::Pnt(V1))< Pl.Distance(BRep_Tool::Pnt(V1))) | |
2463 | orvt=TopAbs_FORWARD; | |
2464 | if (!Eproj.Value(nb).IsNull()) { | |
2465 | n3d++; | |
2466 | proj=BRep_Tool::CurveOnSurface(TopoDS::Edge(Eproj.Value(nb)), | |
2467 | TopoDS::Face(Fproj.Value(nb)),up1,up2); | |
2468 | proj2d=new Geom2d_TrimmedCurve(proj,up1,up2); | |
2469 | projc=BRep_Tool::Curve(TopoDS::Edge(Eproj.Value(nb)),up1,up2); | |
2470 | cproj=new Geom_TrimmedCurve(projc,up1,up2); | |
2471 | pardeb=cproj->FirstParameter(); | |
2472 | parfin=cproj->LastParameter(); | |
2473 | P1=cproj->Value(pardeb); | |
2474 | P2=cproj->Value(parfin); | |
2475 | if (P1.Distance(tpt1.Point())<1.e-3) | |
2476 | indpoint1=indpoint(ic,1); | |
2477 | else indpoint1=ind; | |
2478 | if (P2.Distance(tpt2.Point())<1.e-3) | |
2479 | indpoint2=indpoint(icplus,0); | |
2480 | else { | |
2481 | TopOpeBRepDS_Point tpoint2 (P2,error); | |
2482 | indpoint2= DStr.AddPoint(tpoint2); | |
2483 | ind=indpoint2; | |
2484 | } | |
c22b52d6 | 2485 | Handle (GeomAdaptor_Surface) Asurf; |
2486 | Asurf = new GeomAdaptor_Surface(BRep_Tool::Surface | |
7fd59977 | 2487 | (TopoDS::Face(Fproj.Value(nb)))); |
c22b52d6 | 2488 | Handle (Geom2dAdaptor_Curve) Acurv=new Geom2dAdaptor_Curve(proj2d); |
7fd59977 | 2489 | Adaptor3d_CurveOnSurface CurvOnS (Acurv,Asurf); |
c22b52d6 | 2490 | Handle(Adaptor3d_CurveOnSurface) HCons =new Adaptor3d_CurveOnSurface(CurvOnS); |
7fd59977 | 2491 | Order.SetValue(n3d,1); |
2492 | Handle(GeomPlate_CurveConstraint) Cont = | |
2493 | new GeomPlate_CurveConstraint(HCons,Order.Value(n3d),10,tolesp,angular,0.1); | |
2494 | PSurf.Add(Cont); | |
2495 | TopOpeBRepDS_Curve tcurv3d( cproj,error); | |
2496 | indcurve3d.SetValue(n3d, DStr.AddCurve(tcurv3d)); | |
2497 | Interfp1=ChFi3d_FilPointInDS(TopAbs_FORWARD,indcurve3d.Value(n3d), | |
2498 | indpoint1,pardeb); | |
2499 | Interfp2=ChFi3d_FilPointInDS(TopAbs_REVERSED,indcurve3d.Value(n3d), | |
2500 | indpoint2,parfin); | |
2501 | DStr.ChangeCurveInterferences(indcurve3d.Value(n3d)).Append(Interfp1); | |
2502 | DStr.ChangeCurveInterferences(indcurve3d.Value(n3d)).Append(Interfp2); | |
2503 | num=DStr.AddShape(Fproj.Value(nb)); | |
2504 | TopExp_Explorer ex; | |
2505 | for(ex.Init(Fproj.Value(nb).Oriented(TopAbs_FORWARD),TopAbs_EDGE); | |
2506 | ex.More(); ex.Next()){ | |
2507 | if(Ecom.Value(nb).IsSame(ex.Current())) { | |
2508 | oredge = ex.Current().Orientation(); | |
2509 | break; | |
2510 | } | |
2511 | } | |
2512 | ||
81bba717 | 2513 | //calculation of the orientation |
7fd59977 | 2514 | TopAbs_Orientation orinterf; |
2515 | if (P1.Distance(Pcom)>1.e-4) { | |
2516 | if (orvt==TopAbs_FORWARD) { | |
2517 | orinterf=oredge; | |
2518 | } | |
2519 | else { | |
2520 | orinterf=TopAbs::Reverse(oredge); | |
2521 | } | |
2522 | } | |
2523 | else { | |
2524 | if (orvt==TopAbs_FORWARD) { | |
2525 | orinterf=TopAbs::Reverse(oredge); | |
2526 | } | |
2527 | else { | |
2528 | orinterf=oredge; | |
2529 | } | |
2530 | } | |
2531 | Interfc=ChFi3d_FilCurveInDS(indcurve3d.Value(n3d),num,proj2d,orinterf); | |
2532 | DStr.ChangeShapeInterferences(num).Append(Interfc); | |
2533 | } | |
2534 | indice=ind; | |
2535 | if (nb!=nbface) { | |
2536 | if (Eproj.Value(nb).IsNull()) indice=indpoint(ic,1); | |
2537 | if (Eproj.Value(nb+1).IsNull()) indice=indpoint(icplus,0); | |
2538 | Indice.SetValue(n3d,indice); | |
2539 | Standard_Integer Iarc1=DStr.AddShape(TopoDS::Edge(Ecom.Value(nb))); | |
2540 | Interfp1=ChFi3d_FilPointInDS(orvt,Iarc1,indice,parcom.Value(nb)); | |
2541 | DStr.ChangeShapeInterferences(Iarc1).Append(Interfp1); | |
2542 | } | |
2543 | } | |
2544 | } | |
2545 | } | |
2546 | ||
81bba717 | 2547 | // case when two free borders are tangent |
7fd59977 | 2548 | if (droit) |
2549 | for (ic=0;ic<nedge;ic++) { | |
2550 | Handle(Geom_Curve) curve,ctrim,rcurve; | |
2551 | Handle(Geom2d_Curve) curve2d,ctrim2d,rcurve2d; | |
2552 | Standard_Real ufirst,ulast; | |
2553 | Indices(nedge,ic,icplus,icmoins); | |
2554 | Standard_Integer indpoint1,indpoint2; | |
2555 | Standard_Boolean isvt1=Standard_False,isvt2=Standard_False; | |
2556 | TopoDS_Edge ecur =TopoDS::Edge(Evive.Value(ic)); | |
2557 | if (ecur.IsSame(edgelibre1)|| ecur.IsSame(edgelibre2)) { | |
2558 | n3d++; | |
2559 | curve2d=BRep_Tool::CurveOnSurface(TopoDS::Edge(Evive.Value(ic)), | |
2560 | TopoDS::Face(Fvive.Value(ic,icplus)),ufirst,ulast); | |
2561 | curve=BRep_Tool::Curve(TopoDS::Edge(Evive.Value(ic)),ufirst,ulast); | |
2562 | if (TopExp::FirstVertex((TopoDS::Edge(Evive.Value(ic)))).IsSame (V1)) { | |
2563 | ctrim=new Geom_TrimmedCurve(curve,ufirst,p.Value(ic,icmoins)); | |
2564 | ctrim2d=new Geom2d_TrimmedCurve(curve2d,ufirst,p.Value(ic,icmoins)); | |
2565 | indpoint1=DStr.AddShape(V1); | |
2566 | isvt1=1; | |
2567 | indpoint2=indpoint(ic,1); | |
2568 | } | |
2569 | else { | |
2570 | ctrim=new Geom_TrimmedCurve(curve, p.Value(ic,icmoins),ulast); | |
2571 | ctrim2d=new Geom2d_TrimmedCurve(curve2d,p.Value(ic,icmoins),ulast); | |
2572 | indpoint2=DStr.AddShape(V1); | |
2573 | isvt2=1; | |
2574 | indpoint1=indpoint(ic,1); | |
2575 | } | |
2576 | if (libre.Value(ic)){ | |
2577 | if (TopExp::FirstVertex((TopoDS::Edge(Evive.Value(ic)))).IsSame(V1)) { | |
2578 | ctrim->Reverse(); | |
2579 | ctrim2d->Reverse(); | |
2580 | indpoint2=DStr.AddShape(V1); | |
2581 | isvt2=1; | |
2582 | isvt1=0; | |
2583 | indpoint1=indpoint(ic,1); | |
2584 | } | |
2585 | } | |
2586 | else { | |
2587 | if (TopExp::LastVertex((TopoDS::Edge(Evive.Value(ic)))).IsSame(V1)) { | |
2588 | ctrim->Reverse(); | |
2589 | ctrim2d->Reverse(); | |
2590 | indpoint1=DStr.AddShape(V1); | |
2591 | isvt1=1; | |
2592 | isvt2=0; | |
2593 | indpoint2=indpoint(ic,1); | |
2594 | } | |
2595 | } | |
2596 | ufirst=ctrim->FirstParameter(); | |
2597 | ulast=ctrim->LastParameter(); | |
c22b52d6 | 2598 | Handle (GeomAdaptor_Surface) Asurf; |
2599 | Asurf = new GeomAdaptor_Surface(BRep_Tool::Surface | |
7fd59977 | 2600 | (TopoDS::Face(Fvive.Value(ic,icplus)))); |
c22b52d6 | 2601 | Handle (Geom2dAdaptor_Curve) Acurv=new Geom2dAdaptor_Curve(ctrim2d); |
7fd59977 | 2602 | Adaptor3d_CurveOnSurface CurvOnS (Acurv,Asurf); |
c22b52d6 | 2603 | Handle(Adaptor3d_CurveOnSurface) HCons =new Adaptor3d_CurveOnSurface(CurvOnS); |
7fd59977 | 2604 | Order.SetValue(n3d,0); |
2605 | Handle(GeomPlate_CurveConstraint) Cont = | |
2606 | new GeomPlate_CurveConstraint(HCons,Order.Value(n3d),10,tolesp,angular,0.1); | |
2607 | PSurf.Add(Cont); | |
2608 | TopOpeBRepDS_Curve tcurv3d( ctrim,1.e-4); | |
2609 | indcurve3d.SetValue(n3d, DStr.AddCurve(tcurv3d)); | |
2610 | Interfp1=ChFi3d_FilPointInDS(TopAbs_FORWARD,indcurve3d.Value(n3d), | |
2611 | indpoint1,ufirst,isvt1); | |
2612 | Interfp2=ChFi3d_FilPointInDS(TopAbs_REVERSED,indcurve3d.Value(n3d), | |
2613 | indpoint2,ulast,isvt2); | |
2614 | DStr.ChangeCurveInterferences(indcurve3d.Value(n3d)).Append(Interfp1); | |
2615 | DStr.ChangeCurveInterferences(indcurve3d.Value(n3d)).Append(Interfp2); | |
2616 | } | |
2617 | } | |
2618 | ||
0797d9d3 | 2619 | #ifdef OCCT_DEBUG |
81bba717 | 2620 | ChFi3d_InitChron(ch); // init performances for plate |
7fd59977 | 2621 | #endif |
2622 | ||
2623 | PSurf.Perform(); | |
2624 | ||
0797d9d3 | 2625 | #ifdef OCCT_DEBUG |
81bba717 | 2626 | ChFi3d_ResultChron(ch, t_plate); //result performances for plate |
7fd59977 | 2627 | #endif |
2628 | ||
81bba717 | 2629 | // call of approx |
7fd59977 | 2630 | |
0797d9d3 | 2631 | #ifdef OCCT_DEBUG |
81bba717 | 2632 | ChFi3d_InitChron(ch); // init performances for approxplate |
7fd59977 | 2633 | #endif |
2634 | if (PSurf.IsDone()) { | |
2635 | Standard_Integer nbcarreau=9; | |
2636 | Standard_Integer degmax=8; | |
2637 | Standard_Real seuil; | |
2638 | Handle(GeomPlate_Surface) gpPlate = PSurf.Surface(); | |
2639 | ||
2640 | TColgp_SequenceOfXY S2d; | |
2641 | TColgp_SequenceOfXYZ S3d; | |
2642 | S2d.Clear(); | |
2643 | S3d.Clear(); | |
2644 | PSurf.Disc2dContour(4,S2d); | |
2645 | PSurf.Disc3dContour(4,0,S3d); | |
2646 | seuil = Max(tolapp,10*PSurf.G0Error()); | |
2647 | GeomPlate_PlateG0Criterion critere (S2d,S3d,seuil); | |
2648 | GeomPlate_MakeApprox Mapp(gpPlate,critere,tolapp,nbcarreau,degmax); | |
2649 | Handle (Geom_Surface) Surf (Mapp.Surface()); | |
2650 | Standard_Real coef = 1.1 ,apperror; | |
2651 | apperror=Mapp.CriterionError()*coef; | |
2652 | ||
0797d9d3 | 2653 | #ifdef OCCT_DEBUG |
81bba717 | 2654 | ChFi3d_ResultChron(ch, t_approxplate); // result performances for approxplate |
7fd59977 | 2655 | #endif |
2656 | ||
81bba717 | 2657 | // Storage of the surface plate and corresponding curves in the DS |
7fd59977 | 2658 | |
2659 | TopAbs_Orientation orplate,orsurfdata,orpcurve,orien; | |
0797d9d3 | 2660 | #ifdef OCCT_DEBUG |
7fd59977 | 2661 | // Standard_Real ang1=PSurf.G1Error(); |
2662 | #endif | |
2663 | // gp_Vec n1,n2,du,dv,du1,dv1; | |
2664 | // gp_Pnt pp,pp1; | |
2665 | // Standard_Real tpar; | |
2666 | // gp_Pnt2d uv; | |
2667 | // Standard_Real scal; | |
2668 | ||
2669 | TopOpeBRepDS_Surface Tsurf(Surf,Mapp.ApproxError()); | |
2670 | Standard_Integer Isurf=DStr.AddSurface(Tsurf); | |
2671 | //lbo : historique QDF. | |
2672 | if(!myEVIMap.IsBound(V1)){ | |
2673 | TColStd_ListOfInteger li; | |
2674 | myEVIMap.Bind(V1,li); | |
2675 | } | |
2676 | myEVIMap.ChangeFind(V1).Append(Isurf); | |
2677 | ||
2678 | Standard_Integer SolInd = CD.Value(0)->SolidIndex(); | |
2679 | TopOpeBRepDS_ListOfInterference& SolidInterfs = | |
2680 | DStr.ChangeShapeInterferences(SolInd); | |
2681 | ||
81bba717 | 2682 | // in case when one rereads at top, it is necessary that |
2683 | // alive edges that arrive at the top should be removed from the DS. | |
2684 | // For this they are stored in the DS with their inverted orientation | |
7fd59977 | 2685 | Standard_Integer nbedge; |
2686 | TopExp_Explorer ex; | |
2687 | if (deuxconges) | |
2688 | for (ic=0;ic<nedge;ic++) { | |
2689 | if (!sharp.Value(ic)){ | |
2690 | nbedge = CD.Value(ic)->Spine()->NbEdges(); | |
2691 | TopoDS_Edge Arcspine; | |
2692 | if (sens.Value(ic) ==1) | |
2693 | Arcspine=CD.Value(ic) ->Spine()->Edges(1); | |
2694 | else | |
2695 | Arcspine= CD.Value(ic)->Spine()->Edges(nbedge); | |
2696 | Standard_Integer IArcspine = DStr.AddShape(Arcspine); | |
7fd59977 | 2697 | TopAbs_Orientation OVtx = TopAbs_FORWARD; |
7fd59977 | 2698 | for(ex.Init(Arcspine.Oriented(TopAbs_FORWARD),TopAbs_VERTEX); |
2699 | ex.More(); ex.Next()){ | |
2700 | if(V1.IsSame(ex.Current())) { | |
2701 | OVtx = ex.Current().Orientation(); | |
2702 | break; | |
2703 | } | |
2704 | } | |
2705 | OVtx = TopAbs::Reverse(OVtx); | |
2706 | Standard_Real parVtx = BRep_Tool::Parameter(V1,Arcspine); | |
2707 | Handle(TopOpeBRepDS_CurvePointInterference) | |
2708 | interfv = ChFi3d_FilVertexInDS(OVtx,IArcspine,IVtx,parVtx); | |
2709 | DStr.ChangeShapeInterferences(IArcspine).Append(interfv); | |
2710 | } | |
2711 | } | |
2712 | ||
81bba717 | 2713 | // calculate orientation of Plate orplate corresponding to surfdata |
2714 | // calculation corresponding to the first stripe | |
7fd59977 | 2715 | Indices(nedge,0,icplus,icmoins); |
2716 | isfirst=(sens.Value(0)==1); | |
2717 | const Handle(ChFiDS_SurfData)& Fd = | |
2718 | CD.Value(0)->SetOfSurfData()->Value(i.Value(0,icmoins)); | |
2719 | indice= Fd->Surf(); | |
2720 | // Handle (Geom_Surface) surfdata = DStr.Surface(indice).Surface(); | |
2721 | // tpar= (CD.Value(0)->PCurve(isfirst)->FirstParameter()+ | |
2722 | // CD.Value(0)->PCurve(isfirst)->LastParameter())/2 ; | |
2723 | // CD.Value(0)->PCurve(isfirst)->D0(tpar,uv); | |
2724 | // surfdata->D1(uv.X(),uv.Y(),pp,du,dv); | |
2725 | // tpar=(PSurf.Curves2d()->Value(1)->FirstParameter()+ | |
2726 | // PSurf.Curves2d()->Value(1)->LastParameter())/2; | |
2727 | // (PSurf.Curves2d())->Value(1)->D0(tpar,uv); | |
2728 | // Surf-> D1(uv.X(),uv.Y(),pp1,du1,dv1); | |
2729 | // n1=du.Crossed(dv); | |
2730 | // n2=du1.Crossed(dv1); | |
2731 | // scal= n1.Dot(n2); | |
2732 | orsurfdata=Fd->Orientation(); | |
2733 | // if (scal>0) orplate=orsurfdata; | |
2734 | // else orplate=TopAbs::Reverse(orsurfdata); | |
2735 | orplate = PlateOrientation(Surf,PSurf.Curves2d(),SumFaceNormalAtV1); | |
2736 | ||
81bba717 | 2737 | // creation of solidinterderence for Plate |
7fd59977 | 2738 | Handle(TopOpeBRepDS_SolidSurfaceInterference) SSI = |
2739 | new TopOpeBRepDS_SolidSurfaceInterference(TopOpeBRepDS_Transition(orplate), | |
2740 | TopOpeBRepDS_SOLID, | |
2741 | SolInd, | |
2742 | TopOpeBRepDS_SURFACE, | |
2743 | Isurf); | |
2744 | SolidInterfs.Append(SSI); | |
2745 | ||
81bba717 | 2746 | // calculate orientation orien of pcurves of Plate |
2747 | // the curves from ic to icplus the pcurves of Plate | |
2748 | // all have the same orientation | |
7fd59977 | 2749 | Standard_Integer Ishape1,Ishape2; |
7fd59977 | 2750 | TopAbs_Orientation trafil1 = TopAbs_FORWARD, trafil2 = TopAbs_FORWARD; |
7fd59977 | 2751 | Ishape1 = Fd->IndexOfS1(); |
2752 | Ishape2 = Fd->IndexOfS2(); | |
2753 | const ChFiDS_FaceInterference& Fi1 = Fd->InterferenceOnS1(); | |
2754 | const ChFiDS_FaceInterference& Fi2 = Fd->InterferenceOnS2(); | |
2755 | if (Ishape1 != 0) { | |
2756 | if (Ishape1 > 0) { | |
2757 | trafil1 = DStr.Shape(Ishape1).Orientation(); | |
2758 | } | |
2759 | trafil1 = TopAbs::Compose(trafil1,Fd->Orientation()); | |
2760 | trafil1 = TopAbs::Compose(TopAbs::Reverse(Fi1.Transition()),trafil1); | |
2761 | trafil2 = TopAbs::Reverse(trafil1); | |
2762 | } | |
2763 | else { | |
2764 | if (Ishape2 > 0) { | |
2765 | trafil2 = DStr.Shape(Ishape2).Orientation(); | |
2766 | } | |
2767 | trafil2 = TopAbs::Compose(trafil2,Fd->Orientation()); | |
2768 | trafil2 = TopAbs::Compose(TopAbs::Reverse(Fi2.Transition()),trafil2); | |
2769 | trafil1 = TopAbs::Reverse(trafil2); | |
2770 | } | |
2771 | if (isfirst) { | |
2772 | orpcurve=TopAbs::Reverse(trafil1); | |
2773 | orpcurve= TopAbs::Compose(orpcurve,CD.Value(0)->FirstPCurveOrientation ()); } | |
2774 | else { | |
2775 | orpcurve=trafil1; | |
2776 | orpcurve= TopAbs::Compose(orpcurve,CD.Value(0)->LastPCurveOrientation ()); | |
2777 | } | |
2778 | if (orsurfdata==orplate) | |
2779 | orien =TopAbs::Reverse(orpcurve); | |
2780 | else orien=orpcurve; | |
2781 | ||
2782 | ||
2783 | if (!droit) | |
2784 | for (ic=0;ic<=nedge;ic++) { | |
2785 | if (libre.Value(ic)) { | |
2786 | Standard_Integer icplus21; | |
2787 | Indices(nedge,ic,icplus,icmoins); | |
2788 | Indices(nedge,icplus,icplus21,ic); | |
2789 | gp_Pnt2d UV1,UV2; | |
2790 | Handle (Geom_Curve) C3d; | |
2791 | Handle (Geom2d_Curve) C2d,curv2d; | |
2792 | gp_Pnt ptic,pticplus; | |
2793 | BRepAdaptor_Curve BCurv1(TopoDS::Edge(Evive.Value(ic))); | |
2794 | BRepAdaptor_Curve BCurv2(TopoDS::Edge(Evive.Value(icplus))); | |
2795 | Standard_Real par1=p.Value(ic,icplus); | |
2796 | Standard_Real par2=p.Value(icplus,ic); | |
2797 | BCurv1.D0(par1,ptic); | |
2798 | BCurv2.D0(par2,pticplus); | |
2799 | ParametrePlate(n3d,PSurf,Surf,ptic,apperror,UV1); | |
2800 | ParametrePlate(n3d,PSurf,Surf,pticplus,apperror,UV2); | |
2801 | Standard_Real to3d=1.e-3,to2d=1.e-6,tolreached; | |
2802 | ChFiDS_CommonPoint CP1,CP2; | |
2803 | CP1.SetArc(1.e-3, TopoDS::Edge(Evive.Value(ic)),par1,TopAbs_FORWARD); | |
2804 | CP1.SetPoint(ptic); | |
2805 | CP2.SetArc(1.e-3, TopoDS::Edge(Evive.Value(icplus)),par2,TopAbs_FORWARD); | |
2806 | CP2.SetPoint(pticplus); | |
2807 | Standard_Real param1,param2; | |
2808 | ChFi3d_ComputeArete( CP1,UV1,CP2,UV2,Surf,C3d,C2d,param1,param2, | |
2809 | to3d,to2d,tolreached,0); | |
2810 | TopOpeBRepDS_Curve tcurv3d( C3d,tolreached); | |
2811 | Standard_Integer ind1,ind2; | |
2812 | ind1=indpoint(ic,0); | |
2813 | ind2=indpoint(icplus,0); | |
2814 | Standard_Integer indcurv=DStr.AddCurve(tcurv3d); | |
2815 | Interfp1=ChFi3d_FilPointInDS(TopAbs_FORWARD,indcurv,ind1,param1); | |
2816 | Interfp2=ChFi3d_FilPointInDS(TopAbs_REVERSED,indcurv,ind2,param2); | |
2817 | DStr.ChangeCurveInterferences(indcurv).Append(Interfp1); | |
2818 | DStr.ChangeCurveInterferences(indcurv).Append(Interfp2); | |
2819 | Interfc=ChFi3d_FilCurveInDS(indcurv,Isurf,C2d,orien); | |
2820 | DStr.ChangeSurfaceInterferences(Isurf).Append(Interfc); | |
2821 | } | |
2822 | } | |
2823 | ||
2824 | // stockage des courbes relatives aux stripes | |
2825 | n3d = 0; | |
2826 | for (ic=0; ic<nedge ;ic++) { | |
2827 | if (!sharp.Value(ic)) { | |
2828 | n3d++; | |
2829 | Indices(nedge,ic,icplus,icmoins); | |
2830 | ||
2831 | isfirst=(sens.Value(ic)==1); | |
81bba717 | 2832 | // calculate curves interference relative to stripes |
7fd59977 | 2833 | |
2834 | apperror=Mapp.CriterionError()*coef; | |
2835 | pardeb=CD.Value(ic)->PCurve(isfirst)->FirstParameter(); | |
2836 | parfin=CD.Value(ic)->PCurve(isfirst)->LastParameter(); | |
2837 | ||
2838 | Interfp1=ChFi3d_FilPointInDS(TopAbs_FORWARD,indcurve3d.Value(n3d), | |
2839 | indpoint.Value(ic,0),pardeb); | |
2840 | Interfp2=ChFi3d_FilPointInDS(TopAbs_REVERSED,indcurve3d.Value(n3d), | |
2841 | indpoint.Value(ic,1),parfin); | |
2842 | DStr.ChangeCurveInterferences(indcurve3d.Value(n3d)).Append( Interfp1); | |
2843 | DStr.ChangeCurveInterferences(indcurve3d.Value(n3d)).Append( Interfp2); | |
2844 | TopOpeBRepDS_Curve& tcourb = DStr.ChangeCurve(indcurve3d.Value(n3d)); | |
2845 | ||
2846 | tcourb.Tolerance(errapp.Value(ic)+apperror); | |
2847 | TopOpeBRepDS_Point& tpt1= DStr.ChangePoint(indpoint(ic,0)); | |
2848 | TopOpeBRepDS_Point& tpt2= DStr.ChangePoint(indpoint(ic,1)); | |
2849 | tpt1.Tolerance (tpt1.Tolerance()+apperror); | |
2850 | tpt2.Tolerance (tpt2.Tolerance()+apperror ); | |
2851 | ||
81bba717 | 2852 | // calculate surfaceinterference |
7fd59977 | 2853 | Interfc=ChFi3d_FilCurveInDS(indcurve3d.Value(n3d),Isurf, |
2854 | PSurf.Curves2d()->Value(n3d),orien); | |
2855 | DStr.ChangeSurfaceInterferences(Isurf).Append(Interfc); | |
2856 | regular.SetCurve(indcurve3d.Value(n3d)); | |
2857 | regular.SetS1(Isurf,Standard_False); | |
2858 | indice=CD.Value(ic)->SetOfSurfData()->Value( i.Value(ic,icmoins))->Surf(); | |
2859 | regular.SetS2(indice,Standard_False); | |
2860 | myRegul.Append(regular); | |
2861 | } | |
2862 | } | |
2863 | ||
81bba717 | 2864 | // storage of connection curves |
7fd59977 | 2865 | |
2866 | for (ic=0; ic<nedge;ic++) { | |
2867 | Indices(nedge,ic,icplus,icmoins); | |
2868 | if (!oksea.Value(ic)) { | |
2869 | if (sharp.Value(ic) &&!deuxconges) { | |
81bba717 | 2870 | // limitation of the alive edge |
7fd59977 | 2871 | TopAbs_Orientation ori; |
2872 | gp_Pnt Pf,Pl,sommet1; | |
2873 | TopoDS_Vertex Vd = TopExp::FirstVertex(TopoDS::Edge(Evive.Value(ic))); | |
2874 | TopoDS_Vertex Vf = TopExp::LastVertex(TopoDS::Edge(Evive.Value(ic))); | |
2875 | Pf=BRep_Tool::Pnt(Vd); | |
2876 | Pl=BRep_Tool::Pnt(Vf); | |
2877 | sommet1=BRep_Tool::Pnt(V1); | |
2878 | if (Pf.Distance(sommet1)<Pl.Distance(sommet1)) | |
2879 | ori = TopAbs_FORWARD; | |
2880 | else | |
2881 | ori = TopAbs_REVERSED; | |
2882 | Standard_Integer Iarc1=DStr.AddShape(TopoDS::Edge(Evive.Value(ic))); | |
2883 | Interfp1=ChFi3d_FilPointInDS(ori,Iarc1,indpoint(ic,1),p.Value(ic,icplus)); | |
2884 | DStr.ChangeShapeInterferences(TopoDS::Edge(Evive.Value(ic))).Append(Interfp1); | |
2885 | } | |
2886 | ||
2887 | if (!ponctuel.Value(ic) && !libre.Value(ic)) { | |
81bba717 | 2888 | // actual connection |
7fd59977 | 2889 | if (!moresurf.Value(ic)){ |
2890 | n3d++; | |
2891 | TopOpeBRepDS_Curve& tcourb1 = DStr.ChangeCurve(indcurve3d.Value(n3d)); | |
2892 | tcourb1.Tolerance(tcourb1.Tolerance()+apperror); | |
2893 | if (!deuxconges) { | |
2894 | TopOpeBRepDS_Point& tpt11= DStr.ChangePoint(indpoint(ic,1)); | |
2895 | TopOpeBRepDS_Point& tpt21= DStr.ChangePoint(indpoint(icplus,0)); | |
2896 | tpt11.Tolerance (tpt11.Tolerance()+apperror); | |
2897 | tpt21.Tolerance (tpt21.Tolerance()+apperror ); | |
2898 | } | |
2899 | Interfc=ChFi3d_FilCurveInDS(indcurve3d.Value(n3d),Isurf, | |
2900 | PSurf.Curves2d()->Value(n3d),orien); | |
2901 | DStr.ChangeSurfaceInterferences(Isurf).Append(Interfc); | |
2902 | if( Order.Value(n3d)==1) { | |
2903 | regular.SetCurve(indcurve3d.Value(n3d)); | |
2904 | regular.SetS1(Isurf,Standard_False); | |
2905 | regular.SetS2(numfa.Value(ic,icplus)); | |
2906 | myRegul.Append(regular); | |
2907 | } | |
2908 | } | |
2909 | } | |
2910 | } | |
2911 | } | |
2912 | ||
81bba717 | 2913 | //storage of curves projected on several faces |
7fd59977 | 2914 | for (ic=0; ic<nedge;ic++) { |
2915 | Indices(nedge,ic,icplus,icmoins); | |
2916 | if (moresurf(ic)) | |
2917 | for (nb=1;nb<=nbface;nb++){ | |
2918 | if (!Eproj.Value(nb).IsNull()) { | |
2919 | n3d++; | |
2920 | TopOpeBRepDS_Curve& tcourb1 = DStr.ChangeCurve(indcurve3d.Value(n3d)); | |
2921 | tcourb1.Tolerance(tcourb1.Tolerance()+apperror); | |
2922 | if(Indice.Value(n3d)!=0) { | |
2923 | TopOpeBRepDS_Point& tpt11= DStr.ChangePoint(Indice.Value(n3d)); | |
2924 | tpt11.Tolerance (tpt11.Tolerance()+apperror); | |
2925 | } | |
2926 | Interfc=ChFi3d_FilCurveInDS(indcurve3d.Value(n3d),Isurf, | |
2927 | PSurf.Curves2d()->Value(n3d),orien); | |
2928 | DStr.ChangeSurfaceInterferences(Isurf).Append(Interfc); | |
2929 | if( Order.Value(n3d)==1) { | |
2930 | regular.SetCurve(indcurve3d.Value(n3d)); | |
2931 | regular.SetS1(Isurf,Standard_False); | |
2932 | regular.SetS2(DStr.AddShape(TopoDS::Face(Fproj.Value(nb)))); | |
2933 | myRegul.Append(regular); | |
2934 | } | |
2935 | } | |
2936 | } | |
2937 | } | |
2938 | ||
81bba717 | 2939 | // storage of curves in case of tangent free borders |
7fd59977 | 2940 | if (droit) |
2941 | for (ic=0; ic<nedge;ic++) { | |
2942 | Indices(nedge,ic,icplus,icmoins); | |
2943 | TopoDS_Edge ecom; | |
2944 | ecom=TopoDS::Edge(Evive.Value(ic)); | |
2945 | if (ecom.IsSame(edgelibre1)||ecom.IsSame(edgelibre2)) { | |
2946 | n3d++; | |
2947 | TopOpeBRepDS_Curve& tcourb1 = DStr.ChangeCurve(indcurve3d.Value(n3d)); | |
2948 | tcourb1.Tolerance(tcourb1.Tolerance()+apperror); | |
2949 | Interfc=ChFi3d_FilCurveInDS(indcurve3d.Value(n3d),Isurf, | |
2950 | PSurf.Curves2d()->Value(n3d),orien); | |
2951 | DStr.ChangeSurfaceInterferences(Isurf).Append(Interfc); | |
2952 | } | |
2953 | } | |
2954 | } | |
81bba717 | 2955 | else { // there is only one partial result |
7fd59977 | 2956 | done=Standard_False; |
2957 | hasresult=Standard_True; | |
2958 | for (ic=0; ic<nedge;ic++) { | |
2959 | Indices(nedge,ic,icplus,icmoins); | |
2960 | if (!oksea.Value(ic)) { | |
2961 | if (sharp.Value(ic) &&!deuxconges) { | |
81bba717 | 2962 | // limitation of the alive edge |
7fd59977 | 2963 | TopAbs_Orientation ori; |
2964 | gp_Pnt Pf,Pl,sommet1; | |
2965 | TopoDS_Vertex Vd = TopExp::FirstVertex(TopoDS::Edge(Evive.Value(ic))); | |
2966 | TopoDS_Vertex Vf = TopExp::LastVertex(TopoDS::Edge(Evive.Value(ic))); | |
2967 | Pf=BRep_Tool::Pnt(Vd); | |
2968 | Pl=BRep_Tool::Pnt(Vf); | |
2969 | sommet1=BRep_Tool::Pnt(V1); | |
2970 | if (Pf.Distance(sommet1)<Pl.Distance(sommet1)) | |
2971 | ori = TopAbs_FORWARD; | |
2972 | else | |
2973 | ori = TopAbs_REVERSED; | |
2974 | Standard_Integer Iarc1=DStr.AddShape(TopoDS::Edge(Evive.Value(ic))); | |
2975 | Interfp1=ChFi3d_FilPointInDS(ori,Iarc1,indpoint(ic,1),p.Value(ic,icplus)); | |
2976 | DStr.ChangeShapeInterferences(TopoDS::Edge(Evive.Value(ic))).Append(Interfp1); | |
2977 | } | |
2978 | } | |
2979 | } | |
2980 | } | |
2981 | } |