1 // Created on: 2016-04-19
2 // Copyright (c) 2016 OPEN CASCADE SAS
3 // Created by: Oleg AGASHIN
5 // This file is part of Open CASCADE Technology software library.
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.
13 // Alternatively, this file may be used under the terms of Open CASCADE
14 // commercial license or contractual agreement.
16 #include <BRepMesh_EdgeTessellationExtractor.hxx>
18 #include <BRepMesh_ShapeTool.hxx>
19 #include <BRep_Tool.hxx>
21 #include <IMeshData_Edge.hxx>
22 #include <IMeshData_Face.hxx>
23 #include <Poly_Triangulation.hxx>
25 IMPLEMENT_STANDARD_RTTIEXT(BRepMesh_EdgeTessellationExtractor, IMeshTools_CurveTessellator)
27 //=======================================================================
28 //function : Constructor
30 //=======================================================================
31 BRepMesh_EdgeTessellationExtractor::BRepMesh_EdgeTessellationExtractor (
32 const IMeshData::IEdgeHandle& theEdge,
33 const IMeshData::IFaceHandle& theFace)
35 Handle (Poly_Triangulation) aTriangulation =
36 BRep_Tool::Triangulation (theFace->GetFace(), myLoc);
38 Handle (Poly_PolygonOnTriangulation) aPolygon =
39 BRep_Tool::PolygonOnTriangulation (theEdge->GetEdge(), aTriangulation, myLoc);
41 myTriangulation = aTriangulation.get();
42 myIndices = &aPolygon->Nodes ();
43 myProvider.Init (theEdge, TopAbs_FORWARD, theFace, aPolygon->Parameters ());
46 //=======================================================================
47 //function : Constructor
49 //=======================================================================
50 BRepMesh_EdgeTessellationExtractor::~BRepMesh_EdgeTessellationExtractor ()
54 //=======================================================================
57 //=======================================================================
58 Standard_Integer BRepMesh_EdgeTessellationExtractor::PointsNb () const
60 return myIndices->Size ();
63 //=======================================================================
66 //=======================================================================
67 Standard_Boolean BRepMesh_EdgeTessellationExtractor::Value (
68 const Standard_Integer theIndex,
70 Standard_Real& theParameter) const
72 const gp_Pnt aRefPnt = myTriangulation->Node (myIndices->Value (theIndex));
73 thePoint = BRepMesh_ShapeTool::UseLocation (aRefPnt, myLoc);
75 theParameter = myProvider.Parameter (theIndex, thePoint);