1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
|
// File: BRepMesh_VertexInspector.cxx
// Created: Jun 1 18:32:12 2011
// Author: Oleg AGASHIN
// Copyright: Open CASCADE SAS 2011
#include <gp_XY.hxx>
#include <Precision.hxx>
#include <BRepMesh_VertexInspector.hxx>
#include <BRepMesh_Vertex.hxx>
//=======================================================================
//function : BRepMesh_VertexInspector
//purpose : Constructor
//
//=======================================================================
BRepMesh_VertexInspector::BRepMesh_VertexInspector (const Standard_Integer nbComp,
const BRepMesh_BaseAllocator& theAlloc)
: myTol(0,1),
myResInd(theAlloc),
myVertices(nbComp),
myDelNodes(theAlloc)
{
SetTolerance( Precision::Confusion() );
}
BRepMesh_VertexInspector::BRepMesh_VertexInspector (const Standard_Integer nbComp,
const Standard_Real aTol,
const BRepMesh_BaseAllocator& theAlloc)
: myTol(0,1),
myResInd(theAlloc),
myVertices(nbComp),
myDelNodes(theAlloc)
{
SetTolerance( aTol );
}
BRepMesh_VertexInspector::BRepMesh_VertexInspector (const Standard_Integer nbComp,
const Standard_Real aTolX,
const Standard_Real aTolY,
const BRepMesh_BaseAllocator& theAlloc)
: myTol(0,1),
myResInd(theAlloc),
myVertices(nbComp),
myDelNodes(theAlloc)
{
SetTolerance( aTolX, aTolY );
}
//=======================================================================
//function : Inspect
//purpose :
//
//=======================================================================
NCollection_CellFilter_Action BRepMesh_VertexInspector::Inspect (const Standard_Integer theTarget)
{
const BRepMesh_Vertex& aVertex = myVertices(theTarget-1);
if( aVertex.Movability() == BRepMesh_Deleted )
{
myDelNodes.Append(theTarget);
return CellFilter_Purge;
}
const gp_XY& aPos = aVertex.Coord();
Standard_Real dx,dy;
dx = myCurrent.X() - aPos.X();
dy = myCurrent.Y() - aPos.Y();
Standard_Boolean inTol;
if ( myTol(1) == 0. )
{
inTol = (dx*dx + dy*dy) <= myTol(0);
}
else
{
inTol = ( (dx*dx) <= myTol(0) ) &&
( (dy*dy) <= myTol(1) );
}
if ( inTol )
myResInd.Append(theTarget);
return CellFilter_Keep;
}
//=======================================================================
//function : Add
//purpose :
//
//=======================================================================
Standard_Integer BRepMesh_VertexInspector::Add(const BRepMesh_Vertex& theVertex)
{
if( myDelNodes.IsEmpty() )
{
myVertices.Append(theVertex);
return myVertices.Length();
}
Standard_Integer aNodeIndex = myDelNodes.First();
myVertices(aNodeIndex-1) = theVertex;
myDelNodes.RemoveFirst();
return aNodeIndex;
}
|