0026692: BRepMesh hangs on the attached shape due to tessellation points produced...
[occt.git] / src / BRepMesh / BRepMesh_EdgeTessellationExtractor.cxx
1 // Created on: 2014-08-13
2 // Created by: Oleg AGASHIN
3 // Copyright (c) 2011-2014 OPEN CASCADE SAS
4 //
5 // This file is part of Open CASCADE Technology software library.
6 //
7 // This library is free software; you can redistribute it and/or modify it under
8 // the terms of the GNU Lesser General Public License version 2.1 as published
9 // by the Free Software Foundation, with special exception defined in the file
10 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
11 // distribution for complete text of the license and disclaimer of any warranty.
12 //
13 // Alternatively, this file may be used under the terms of Open CASCADE
14 // commercial license or contractual agreement.
15
16 #include <BRepMesh_EdgeTessellationExtractor.hxx>
17 #include <Geom2d_Curve.hxx>
18 #include <Poly_PolygonOnTriangulation.hxx>
19 #include <Poly_Triangulation.hxx>
20 #include <BRepMesh_ShapeTool.hxx>
21
22
23 IMPLEMENT_STANDARD_RTTIEXT(BRepMesh_EdgeTessellationExtractor,BRepMesh_IEdgeTool)
24
25 //=======================================================================
26 //function : Constructor
27 //purpose  : 
28 //=======================================================================
29 BRepMesh_EdgeTessellationExtractor::BRepMesh_EdgeTessellationExtractor(
30   const TopoDS_Edge&                          theEdge,
31   const Handle(Geom2d_Curve)&                 thePCurve,
32   const TopoDS_Face&                          theFace,
33   const Handle(Poly_Triangulation)&           theTriangulation,
34   const Handle(Poly_PolygonOnTriangulation)&  thePolygon,
35   const TopLoc_Location&                      theLocation)
36   : myProvider(theEdge, theFace, thePolygon->Parameters()),
37     myPCurve(thePCurve),
38     myNodes(theTriangulation->Nodes()),
39     myIndices(thePolygon->Nodes()),
40     myLoc(theLocation)
41 {
42 }
43
44 //=======================================================================
45 //function : Value
46 //purpose  : 
47 //=======================================================================
48 Standard_Boolean BRepMesh_EdgeTessellationExtractor::Value(
49   const Standard_Integer theIndex,
50   Standard_Real&         theParameter,
51   gp_Pnt&                thePoint,
52   gp_Pnt2d&              theUV)
53 {
54   const gp_Pnt& theRefPnt = myNodes(myIndices(theIndex));
55   thePoint = BRepMesh_ShapeTool::UseLocation(theRefPnt, myLoc);
56
57   theParameter = myProvider.Parameter(theIndex, thePoint);
58   theUV        = myPCurve->Value(theParameter);
59
60   return Standard_True;
61 }