0033661: Data Exchange, Step Import - Tessellated GDTs are not imported
[occt.git] / src / BRepMesh / BRepMesh_EdgeTessellationExtractor.cxx
1 // Created on: 2016-04-19
2 // Copyright (c) 2016 OPEN CASCADE SAS
3 // Created by: Oleg AGASHIN
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 <BRepMesh_ShapeTool.hxx>
18 #include <gp_Pnt.hxx>
19 #include <BRep_Tool.hxx>
20 #include <IMeshData_Face.hxx>
21 #include <IMeshData_Edge.hxx>
22
23 //=======================================================================
24 //function : Constructor
25 //purpose  : 
26 //=======================================================================
27 BRepMesh_EdgeTessellationExtractor::BRepMesh_EdgeTessellationExtractor (
28   const IMeshData::IEdgeHandle& theEdge,
29   const IMeshData::IFaceHandle& theFace)
30 {
31   Handle (Poly_Triangulation) aTriangulation =
32     BRep_Tool::Triangulation (theFace->GetFace(), myLoc);
33
34   Handle (Poly_PolygonOnTriangulation) aPolygon =
35     BRep_Tool::PolygonOnTriangulation (theEdge->GetEdge(), aTriangulation, myLoc);
36
37   myNodes   = &aTriangulation->Nodes ();
38   myIndices = &aPolygon->Nodes ();
39   myProvider.Init (theEdge, TopAbs_FORWARD, theFace, aPolygon->Parameters ());
40 }
41
42 //=======================================================================
43 //function : Constructor
44 //purpose  : 
45 //=======================================================================
46 BRepMesh_EdgeTessellationExtractor::~BRepMesh_EdgeTessellationExtractor ()
47 {
48 }
49
50 //=======================================================================
51 //function : NbPoints
52 //purpose  : 
53 //=======================================================================
54 Standard_Integer BRepMesh_EdgeTessellationExtractor::PointsNb () const
55 {
56   return myIndices->Size ();
57 }
58
59 //=======================================================================
60 //function : Value
61 //purpose  : 
62 //=======================================================================
63 Standard_Boolean BRepMesh_EdgeTessellationExtractor::Value (
64   const Standard_Integer theIndex,
65   gp_Pnt&                thePoint,
66   Standard_Real&         theParameter) const
67 {
68   const gp_Pnt& theRefPnt = (*myNodes) ((*myIndices) (theIndex));
69   thePoint = BRepMesh_ShapeTool::UseLocation (theRefPnt, myLoc);
70
71   theParameter = myProvider.Parameter (theIndex, thePoint);
72   return Standard_True;
73 }