0026106: BRepMesh - revision of data model
[occt.git] / src / BRepMesh / BRepMesh_EdgeTessellationExtractor.cxx
CommitLineData
7bd071ed 1// Created on: 2016-04-19
2// Copyright (c) 2016 OPEN CASCADE SAS
ceb418e1 3// Created by: Oleg AGASHIN
ceb418e1 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>
ceb418e1 17#include <BRepMesh_ShapeTool.hxx>
7bd071ed 18#include <gp_Pnt.hxx>
19#include <BRep_Tool.hxx>
20#include <IMeshData_Face.hxx>
21#include <IMeshData_Edge.hxx>
ceb418e1 22
7bd071ed 23//=======================================================================
24//function : Constructor
25//purpose :
26//=======================================================================
27BRepMesh_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);
ceb418e1 36
7bd071ed 37 myNodes = &aTriangulation->Nodes ();
38 myIndices = &aPolygon->Nodes ();
39 myProvider.Init (theEdge, TopAbs_FORWARD, theFace, aPolygon->Parameters ());
40}
92efcf78 41
ceb418e1 42//=======================================================================
43//function : Constructor
44//purpose :
45//=======================================================================
7bd071ed 46BRepMesh_EdgeTessellationExtractor::~BRepMesh_EdgeTessellationExtractor ()
ceb418e1 47{
48}
49
50//=======================================================================
7bd071ed 51//function : NbPoints
52//purpose :
53//=======================================================================
54Standard_Integer BRepMesh_EdgeTessellationExtractor::PointsNb () const
55{
56 return myIndices->Size ();
57}
58
59//=======================================================================
ceb418e1 60//function : Value
61//purpose :
62//=======================================================================
7bd071ed 63Standard_Boolean BRepMesh_EdgeTessellationExtractor::Value (
ceb418e1 64 const Standard_Integer theIndex,
ceb418e1 65 gp_Pnt& thePoint,
7bd071ed 66 Standard_Real& theParameter) const
ceb418e1 67{
7bd071ed 68 const gp_Pnt& theRefPnt = (*myNodes) ((*myIndices) (theIndex));
69 thePoint = BRepMesh_ShapeTool::UseLocation (theRefPnt, myLoc);
660b601e 70
7bd071ed 71 theParameter = myProvider.Parameter (theIndex, thePoint);
660b601e 72 return Standard_True;
ceb418e1 73}