0030785: Mesh - protect BRepMesh_IncrementalMesh::Perform from raising exception
[occt.git] / src / BRepMesh / BRepMesh_EdgeDiscret.hxx
CommitLineData
7bd071ed 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#ifndef _BRepMesh_EdgeDiscret_HeaderFile
17#define _BRepMesh_EdgeDiscret_HeaderFile
18
19#include <IMeshTools_ModelAlgo.hxx>
20#include <IMeshTools_Parameters.hxx>
21#include <IMeshData_Types.hxx>
22
23class IMeshTools_CurveTessellator;
24
25//! Class implements functionality of edge discret tool.
26//! Performs check of the edges for existing Poly_PolygonOnTriangulation.
27//! In case if it fits specified deflection, restores data structure using
28//! it, else clears edges from outdated data.
29class BRepMesh_EdgeDiscret : public IMeshTools_ModelAlgo
30{
31public:
32 //! Constructor.
33 Standard_EXPORT BRepMesh_EdgeDiscret ();
34
35 //! Destructor.
36 Standard_EXPORT virtual ~BRepMesh_EdgeDiscret ();
37
38 //! Creates instance of free edge tessellator.
39 Standard_EXPORT static Handle(IMeshTools_CurveTessellator) CreateEdgeTessellator(
40 const IMeshData::IEdgeHandle& theDEdge,
41 const IMeshTools_Parameters& theParameters);
42
43 //! Creates instance of edge tessellator.
44 Standard_EXPORT static Handle(IMeshTools_CurveTessellator) CreateEdgeTessellator(
45 const IMeshData::IEdgeHandle& theDEdge,
46 const TopAbs_Orientation theOrientation,
47 const IMeshData::IFaceHandle& theDFace,
48 const IMeshTools_Parameters& theParameters);
49
50 //! Creates instance of tessellation extractor.
51 Standard_EXPORT static Handle(IMeshTools_CurveTessellator) CreateEdgeTessellationExtractor(
52 const IMeshData::IEdgeHandle& theDEdge,
53 const IMeshData::IFaceHandle& theDFace);
54
7bd071ed 55 //! Functor API to discretize the given edge.
56 inline void operator() (const Standard_Integer theEdgeIndex) const {
57 process (theEdgeIndex);
58 }
59
60 //! Updates 3d discrete edge model using the given tessellation tool.
61 Standard_EXPORT static void Tessellate3d(
62 const IMeshData::IEdgeHandle& theDEdge,
63 const Handle(IMeshTools_CurveTessellator)& theTessellator,
64 const Standard_Boolean theUpdateEnds);
65
66 //! Updates 2d discrete edge model using tessellation of 3D curve.
67 Standard_EXPORT static void Tessellate2d(
68 const IMeshData::IEdgeHandle& theDEdge,
69 const Standard_Boolean theUpdateEnds);
70
71 DEFINE_STANDARD_RTTI_INLINE(BRepMesh_EdgeDiscret, IMeshTools_ModelAlgo)
72
c2a25d52 73protected:
74
75 //! Performs processing of edges of the given model.
76 Standard_EXPORT virtual Standard_Boolean performInternal (
77 const Handle (IMeshData_Model)& theModel,
78 const IMeshTools_Parameters& theParameters) Standard_OVERRIDE;
79
7bd071ed 80private:
81
82 //! Checks existing discretization of the edge and updates data model.
83 void process (const Standard_Integer theEdgeIndex) const;
84
85 //! Checks existing polygon on triangulation does it fit edge deflection or not.
86 //! @return deflection of polygon or RealLast () in case if edge has no polygon
87 //! or it was dropped.
88 Standard_Real checkExistingPolygonAndUpdateStatus(
89 const IMeshData::IEdgeHandle& theDEdge,
90 const IMeshData::IPCurveHandle& thePCurve) const;
91
92private:
93
94 Handle (IMeshData_Model) myModel;
95 IMeshTools_Parameters myParameters;
96};
97
98#endif