0033661: Data Exchange, Step Import - Tessellated GDTs are not imported
[occt.git] / src / BRepExtrema / BRepExtrema_ExtPF.cxx
CommitLineData
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
34BRepExtrema_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
46void 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);
c894a5fd 52
53 if (mySurf.GetType() == GeomAbs_OtherSurface)
54 return; // protect against non-geometric type (e.g. triangulation)
55
0e4e1240 56 Standard_Real Tol = Min(BRep_Tool::Tolerance(TheFace), Precision::Confusion());
57 Standard_Real aTolU, aTolV;
58 aTolU = Max(mySurf.UResolution(Tol), Precision::PConfusion());
59 aTolV = Max(mySurf.VResolution(Tol), Precision::PConfusion());
7fd59977 60 Standard_Real U1, U2, V1, V2;
92d1589b
A
61 BRepTools::UVBounds(TheFace, U1, U2, V1, V2);
62 myExtPS.SetFlag(TheFlag);
63 myExtPS.SetAlgo(TheAlgo);
0e4e1240 64 myExtPS.Initialize(mySurf, U1, U2, V1, V2, aTolU, aTolV);
7fd59977 65}
66
67//=======================================================================
68//function : Perform
69//purpose :
70//=======================================================================
71
92d1589b 72void BRepExtrema_ExtPF::Perform(const TopoDS_Vertex& TheVertex, const TopoDS_Face& TheFace)
7fd59977 73{
74 mySqDist.Clear();
75 myPoints.Clear();
7fd59977 76
92d1589b 77 const gp_Pnt P = BRep_Tool::Pnt(TheVertex);
c894a5fd 78 if (mySurf.GetType() == GeomAbs_OtherSurface)
79 return; // protect against non-geometric type (e.g. triangulation)
80
92d1589b
A
81 myExtPS.Perform(P);
82
83 // Exploration of points and classification
84 if (myExtPS.IsDone())
85 {
86 BRepClass_FaceClassifier classifier;
87 Standard_Real U1, U2;
88 const Standard_Real Tol = BRep_Tool::Tolerance(TheFace);
89 for (Standard_Integer i = 1; i <= myExtPS.NbExt(); i++)
90 {
91 myExtPS.Point(i).Parameter(U1, U2);
92 const gp_Pnt2d Puv(U1, U2);
93 classifier.Perform(TheFace, Puv, Tol);
94 const TopAbs_State state = classifier.State();
95 if(state == TopAbs_ON || state == TopAbs_IN)
96 {
97 mySqDist.Append(myExtPS.SquareDistance(i));
98 myPoints.Append(myExtPS.Point(i));
99 }
7fd59977 100 }
101 }
7fd59977 102}