Commit | Line | Data |
---|---|---|
b311480e | 1 | // Created on: 1993-12-15 |
2 | // Created by: Christophe MARION | |
3 | // Copyright (c) 1993-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 (june 96) : on utilise BRepClass_FaceClassifier seulement |
18 | // si IsDone de Extrema est vrai | |
92d1589b A |
19 | |
20 | #include <BRepExtrema_ExtPF.hxx> | |
21 | ||
7fd59977 | 22 | #include <BRep_Tool.hxx> |
23 | #include <BRepTools.hxx> | |
7fd59977 | 24 | #include <BRepClass_FaceClassifier.hxx> |
25 | #include <gp_Pnt2d.hxx> | |
7fd59977 | 26 | #include <BRepAdaptor_Surface.hxx> |
0e4e1240 | 27 | #include <Precision.hxx> |
7fd59977 | 28 | |
29 | //======================================================================= | |
30 | //function : BRepExtrema_ExtPF | |
31 | //purpose : | |
32 | //======================================================================= | |
33 | ||
92d1589b A |
34 | BRepExtrema_ExtPF::BRepExtrema_ExtPF(const TopoDS_Vertex& TheVertex, const TopoDS_Face& TheFace, |
35 | const Extrema_ExtFlag TheFlag, const Extrema_ExtAlgo TheAlgo) | |
7fd59977 | 36 | { |
92d1589b A |
37 | Initialize(TheFace,TheFlag,TheAlgo); |
38 | Perform(TheVertex,TheFace); | |
7fd59977 | 39 | } |
40 | ||
41 | //======================================================================= | |
42 | //function : Initialize | |
43 | //purpose : | |
44 | //======================================================================= | |
45 | ||
92d1589b A |
46 | void BRepExtrema_ExtPF::Initialize(const TopoDS_Face& TheFace, |
47 | const Extrema_ExtFlag TheFlag, const Extrema_ExtAlgo TheAlgo) | |
7fd59977 | 48 | { |
49 | // cette surface doit etre en champ. Extrema ne fait | |
50 | // pas de copie et prend seulement un pointeur dessus. | |
92d1589b | 51 | mySurf.Initialize(TheFace, Standard_False); |
0e4e1240 | 52 | Standard_Real Tol = Min(BRep_Tool::Tolerance(TheFace), Precision::Confusion()); |
53 | Standard_Real aTolU, aTolV; | |
54 | aTolU = Max(mySurf.UResolution(Tol), Precision::PConfusion()); | |
55 | aTolV = Max(mySurf.VResolution(Tol), Precision::PConfusion()); | |
7fd59977 | 56 | Standard_Real U1, U2, V1, V2; |
92d1589b A |
57 | BRepTools::UVBounds(TheFace, U1, U2, V1, V2); |
58 | myExtPS.SetFlag(TheFlag); | |
59 | myExtPS.SetAlgo(TheAlgo); | |
0e4e1240 | 60 | myExtPS.Initialize(mySurf, U1, U2, V1, V2, aTolU, aTolV); |
7fd59977 | 61 | } |
62 | ||
63 | //======================================================================= | |
64 | //function : Perform | |
65 | //purpose : | |
66 | //======================================================================= | |
67 | ||
92d1589b | 68 | void BRepExtrema_ExtPF::Perform(const TopoDS_Vertex& TheVertex, const TopoDS_Face& TheFace) |
7fd59977 | 69 | { |
70 | mySqDist.Clear(); | |
71 | myPoints.Clear(); | |
7fd59977 | 72 | |
92d1589b A |
73 | const gp_Pnt P = BRep_Tool::Pnt(TheVertex); |
74 | myExtPS.Perform(P); | |
75 | ||
76 | // Exploration of points and classification | |
77 | if (myExtPS.IsDone()) | |
78 | { | |
79 | BRepClass_FaceClassifier classifier; | |
80 | Standard_Real U1, U2; | |
81 | const Standard_Real Tol = BRep_Tool::Tolerance(TheFace); | |
82 | for (Standard_Integer i = 1; i <= myExtPS.NbExt(); i++) | |
83 | { | |
84 | myExtPS.Point(i).Parameter(U1, U2); | |
85 | const gp_Pnt2d Puv(U1, U2); | |
86 | classifier.Perform(TheFace, Puv, Tol); | |
87 | const TopAbs_State state = classifier.State(); | |
88 | if(state == TopAbs_ON || state == TopAbs_IN) | |
89 | { | |
90 | mySqDist.Append(myExtPS.SquareDistance(i)); | |
91 | myPoints.Append(myExtPS.Point(i)); | |
92 | } | |
7fd59977 | 93 | } |
94 | } | |
7fd59977 | 95 | } |