37 void Foam::surfaceIntersection::writeOBJ(
const point& pt, Ostream& os)
39 os <<
"v " << pt.x() <<
' ' << pt.y() <<
' ' << pt.z() <<
endl;
43 void Foam::surfaceIntersection::writeOBJ
45 const List<point>& pts,
46 const List<edge>& edges,
56 const edge&
e = edges[i];
58 os <<
"l " <<
e.start()+1 <<
' ' <<
e.end()+1 <<
endl;
64 Foam::scalar Foam::surfaceIntersection::minEdgeLen
66 const triSurface& surf,
70 const labelList& pEdges = surf.pointEdges()[pointi];
72 scalar minLen = great;
76 const edge&
e = surf.edges()[pEdges[pEdgeI]];
78 minLen =
min(minLen,
e.mag(surf.localPoints()));
88 const triSurface& surf,
93 const edge faceEdge = surf.localFaces()[facei].faceEdge(fp);
95 const labelList& eLabels = surf.faceEdges()[facei];
99 const label edgeI = eLabels[eI];
101 if (surf.edges()[edgeI] == faceEdge)
108 <<
"Problem:: Cannot find edge with vertices " << faceEdge
109 <<
" in face " << facei
117 void Foam::surfaceIntersection::removeDuplicates
123 bool hasDuplicate =
false;
125 label prevVertI = -1;
129 label newVertI = map[elems[elemI]];
131 if (newVertI == prevVertI)
137 prevVertI = newVertI;
148 elems[elemI++] = map[oldElems[0]];
150 for (
label vertI = 1; vertI < oldElems.size(); vertI++)
153 label newVertI = map[oldElems[vertI]];
155 if (newVertI != elems.last())
157 elems[elemI++] = newVertI;
160 elems.setSize(elemI);
166 void Foam::surfaceIntersection::inlineRemap
174 elems[elemI] = map[elems[elemI]];
187 HashSet<edge, Hash<edge>> uniqueEdges(10*edges.size());
191 map.setSize(edges.size());
198 const edge&
e = edges[edgeI];
202 (
e.start() !=
e.end())
203 && (uniqueEdges.find(
e) == uniqueEdges.end())
207 uniqueEdges.insert(
e);
209 map[edgeI] = newEdgeI;
211 newEdges[newEdgeI++] =
e;
215 newEdges.setSize(newEdgeI);
232 map.setSize(elems.size());
239 label elem = elems[elemI];
241 if (uniqueElems.find(elem) == uniqueElems.end())
244 uniqueElems.insert(elem);
246 map[elemI] = newElemI;
248 newElems[newElemI++] = elem;
252 newElems.setSize(newElemI);
258 void Foam::surfaceIntersection::writeIntersectedEdges
260 const triSurface& surf,
272 forAll(cutPoints(), cutPointi)
274 writeOBJ(cutPoints()[cutPointi], os);
277 forAll(edgeCutVerts, edgeI)
279 const labelList& extraVerts = edgeCutVerts[edgeI];
281 if (extraVerts.size())
283 const edge&
e = surf.edges()[edgeI];
286 os <<
"l " <<
e.start()+1 <<
' '
287 << extraVerts[0] + surf.nPoints() + 1 <<
endl;
289 for (
label i = 1; i < extraVerts.size(); i++)
291 os <<
"l " << extraVerts[i-1] + surf.nPoints() + 1 <<
' '
292 << extraVerts[i] + surf.nPoints() + 1 <<
endl;
295 os <<
"l " << extraVerts.last() + surf.nPoints() + 1
296 <<
' ' <<
e.end()+1 <<
endl;
305 const scalar startTol,
#define forAll(list, i)
Loop across all elements in list.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
List< label > labelList
A List of labels.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Ostream & endl(Ostream &os)
Add newline and flush stream.
errorManip< error > abort(error &err)
vectorField pointField
pointField is a vectorField.
vector point
Point is a vector.
layerAndWeight min(const layerAndWeight &a, const layerAndWeight &b)
List< labelList > labelListList
A List of labelList.
dimensioned< scalar > mag(const dimensioned< Type > &)
HashSet< label, Hash< label > > labelHashSet
A HashSet with label keys.