summaryrefslogtreecommitdiff
path: root/src/BRepMesh/BRepMesh_SelectorOfDataStructureOfDelaun.cxx
blob: 6016ab420a2fcc3c027604bb4397916984e4a8b5 (plain)
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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
// File:        BRepMesh_SelectorOfDataStructureOfDelaun.cxx
// Created:     Tue Jun  1 11:20:51 1993
// Author:      Didier PIFFAULT
//              <dpf@zerox>

#include <BRepMesh_SelectorOfDataStructureOfDelaun.ixx>
#include <BRepMesh_PairOfIndex.hxx>

//=======================================================================
//function : BRepMesh_SelectorOfDataStructureOfDelaun
//purpose  : 
//=======================================================================
BRepMesh_SelectorOfDataStructureOfDelaun::BRepMesh_SelectorOfDataStructureOfDelaun()
: myNodes(10, new NCollection_IncAllocator),
myLinks(10, new NCollection_IncAllocator),
myElements(10, new NCollection_IncAllocator),
myFrontier(10, new NCollection_IncAllocator)

{}

BRepMesh_SelectorOfDataStructureOfDelaun::BRepMesh_SelectorOfDataStructureOfDelaun(const Handle(BRepMesh_DataStructureOfDelaun)& theMesh)
: myMesh(theMesh),
myNodes(10, myMesh->Allocator()),
myLinks(10, myMesh->Allocator()),
myElements(10, myMesh->Allocator()),
myFrontier(10, myMesh->Allocator())
{}

void  BRepMesh_SelectorOfDataStructureOfDelaun::Initialize(const Handle(BRepMesh_DataStructureOfDelaun)& theMesh)
{
  myMesh=theMesh;
  myNodes.Clear();
  myLinks.Clear();
  myElements.Clear();
  myFrontier.Clear();
}

//=======================================================================
//function : NeighboursOfNode
//purpose  : 
//=======================================================================
void  BRepMesh_SelectorOfDataStructureOfDelaun::NeighboursOf(const BRepMesh_Vertex& theNode)
{
  NeighboursOfNode(myMesh->IndexOf(theNode));
}

void  BRepMesh_SelectorOfDataStructureOfDelaun::NeighboursOfNode(const Standard_Integer indexNode)
{
  BRepMesh_ListOfInteger::Iterator itL(myMesh->LinkNeighboursOf(indexNode));

  for (; itL.More(); itL.Next()) {
    const BRepMesh_PairOfIndex& aPair = myMesh->ElemConnectedTo(itL.Value());
    for(Standard_Integer j = 1, jn = aPair.Extent(); j <= jn; j++)
      myElements.Add(aPair.Index(j));
  }
}

//=======================================================================
//function : NeighboursOfLink
//purpose  : 
//=======================================================================
void  BRepMesh_SelectorOfDataStructureOfDelaun::NeighboursOf(const BRepMesh_Edge& theLink)
{
  NeighboursOfNode(theLink.FirstNode());
  NeighboursOfNode(theLink.LastNode());
}

void  BRepMesh_SelectorOfDataStructureOfDelaun::NeighboursOfLink(const Standard_Integer indexLink)
{
  NeighboursOf(myMesh->GetLink(indexLink));
}

//=======================================================================
//function : NeighboursOfElement
//purpose  : by edge and by vertices
//=======================================================================
void  BRepMesh_SelectorOfDataStructureOfDelaun::NeighboursOf(const BRepMesh_Triangle& theElem)
{
  Standard_Integer v1, v2, v3, ev;
  Standard_Boolean o1, o2, o3;
  theElem.Edges(v1, v3, ev, o1, o2, o3);
  v2=myMesh->GetLink(v1).LastNode();
  v1=myMesh->GetLink(v1).FirstNode();
  ev=myMesh->GetLink(v3).LastNode();
  if (v1!=ev && v2!=ev) v3=ev;
  else v3=myMesh->GetLink(v3).FirstNode();
  NeighboursOfNode(v1);
  NeighboursOfNode(v2);
  NeighboursOfNode(v3);
}

void  BRepMesh_SelectorOfDataStructureOfDelaun::NeighboursOfElement(const Standard_Integer indexElem)
{
  NeighboursOf(myMesh->GetElement(indexElem));
}

//=======================================================================
//function : NeighboursByEdgeOf
//purpose  : Neighbours Of an element only by edge
//=======================================================================
void  BRepMesh_SelectorOfDataStructureOfDelaun::NeighboursByEdgeOf(const BRepMesh_Triangle& theElem)
{
  Standard_Integer e[3], iEd;
  Standard_Boolean o1, o2, o3;
  theElem.Edges(e[0], e[1], e[2], o1, o2, o3);

  for (iEd=0; iEd<3; iEd++) {
    const BRepMesh_PairOfIndex& aPair = myMesh->ElemConnectedTo(e[iEd]);
    for(Standard_Integer j = 1, jn = aPair.Extent(); j <= jn; j++)
      myElements.Add(aPair.Index(j));
  }
}


//=======================================================================
//function : NeighboursOfSelector
//purpose  : 
//=======================================================================
void  BRepMesh_SelectorOfDataStructureOfDelaun::NeighboursOf(const BRepMesh_SelectorOfDataStructureOfDelaun& /*theSelector*/)
{}

//=======================================================================
//function : AddNeighbours
//purpose  : 
//=======================================================================
void  BRepMesh_SelectorOfDataStructureOfDelaun::AddNeighbours()
{}

//=======================================================================
//function : Nodes
//purpose  : 
//=======================================================================
const BRepMesh_MapOfInteger& BRepMesh_SelectorOfDataStructureOfDelaun::Nodes()const
{return myNodes;}

//=======================================================================
//function : Links
//purpose  : 
//=======================================================================
const BRepMesh_MapOfInteger& BRepMesh_SelectorOfDataStructureOfDelaun::Links()const
{return myLinks;}

//=======================================================================
//function : Elements
//purpose  : 
//=======================================================================
const BRepMesh_MapOfInteger& BRepMesh_SelectorOfDataStructureOfDelaun::Elements()const
{return myElements;}

//=======================================================================
//function : FrontierLinks
//purpose  : 
//=======================================================================
const BRepMesh_MapOfInteger& BRepMesh_SelectorOfDataStructureOfDelaun::FrontierLinks()const
{return myFrontier;}