60 os <<
"v " <<
p.x() <<
' ' <<
p.y() <<
' ' <<
p.z() <<
nl;
63 for (
const label edgei : edgeLabels)
65 const edge&
e = edges[edgei];
67 os <<
"l " <<
e.start()+1 <<
' ' <<
e.end()+1 <<
nl;
77void Foam::edgeSurface::calcPointEdges()
85 const edge&
e = edges_[edgeI];
91 forAll(pointEdges_, pointi)
93 pointEdges_[pointi].
setSize(pointNEdges[pointi]);
100 const edge&
e = edges_[edgeI];
103 pEdges0[pointNEdges[
e[0]]++] = edgeI;
106 pEdges1[pointNEdges[
e[1]]++] = edgeI;
116 const triSurface& surf,
117 const bool isFirstSurface,
118 const surfaceIntersection& inter
121 points_(surf.
nPoints() + inter.cutPoints().size()),
122 nSurfacePoints_(surf.
nPoints()),
124 nSurfaceEdges_(surf.nEdges()),
126 faceEdges_(surf.size()),
127 pointEdges_(points_.size())
134 const pointField& surfPoints = surf.localPoints();
138 points_[pointi++] = surfPoints[i];
141 const pointField& cutPoints = inter.cutPoints();
145 points_[pointi++] = cutPoints[i];
152 DynamicList<edge> allEdges(surf.nEdges() + inter.cutEdges().size());
153 DynamicList<label> allParentEdges(surf.nEdges());
154 List<DynamicList<label>> allFaceEdges(surf.size());
159 const edgeList& surfEdges = surf.edges();
163 const edge&
e = surfEdges[edgeI];
166 const labelList& extraVerts = inter.edgeCuts(isFirstSurface)[edgeI];
169 label freeNewEdgeI = allEdges.
size();
171 if (extraVerts.empty())
186 extraVerts[0] + nSurfacePoints_
190 for (label extraI = 1; extraI < extraVerts.size(); extraI++)
196 extraVerts[extraI-1] + nSurfacePoints_,
197 extraVerts[extraI] + nSurfacePoints_
205 extraVerts.last() + nSurfacePoints_,
214 const labelList& myFaces = surf.edgeFaces()[edgeI];
216 for (label eI = freeNewEdgeI; eI < allEdges.size(); eI++)
218 allParentEdges.append(edgeI);
222 allFaceEdges[myFaces[myFacei]].append(eI);
228 nSurfaceEdges_ = allEdges.
size();
233 const edgeList& cutEdges = inter.cutEdges();
237 const edge&
e = cutEdges[i];
239 allEdges.
append(edge(
e[0] + nSurfacePoints_,
e[1] + nSurfacePoints_));
249 const label facei = iter.key()[isFirstSurface ? 0 : 1];
252 const label edgeI = iter.val();
255 allFaceEdges[facei].append(edgeI + nSurfaceEdges_);
259 edges_.transfer(allEdges);
260 parentEdges_.transfer(allParentEdges);
262 forAll(allFaceEdges, facei)
264 faceEdges_[facei].transfer(allFaceEdges[facei]);
276 Pout<<
"edgeSurface : Dumping faceEdges to files" <<
endl;
280 const labelList& fEdges = faceEdges_[facei];
282 if (fEdges.size() != 3)
284 fileName faceFName(
"face_" +
name(facei) +
".obj");
285 Pout<<
"edgeSurface : Dumping faceEdges for face " << facei
286 <<
" to " << faceFName <<
endl;
288 OFstream fStream(faceFName);
293 Pout<<
"edgeSurface : Dumping edges to edges.obj" <<
endl;
294 OBJstream(
"edges.obj").
write(edges_, points_);
296 Pout<<
"edgeSurface : Dumping intersectionEdges to"
297 <<
" intersectionEdges.obj" <<
endl;
299 OFstream intEdgesStream(
"intersectionEdges.obj");
300 labelList edgeLabels(edges_.size() - nSurfaceEdges_);
303 for (label edgeI = nSurfaceEdges_; edgeI < edges_.size(); edgeI++)
305 edgeLabels[i++] = edgeI;
323 Pout<<
"Old face consisted of edges:" <<
endl;
325 const labelList& fEdges = faceEdges_[facei];
328 const edge&
e = edges_[fEdges[i]];
330 Pout<<
" " << fEdges[i] <<
' ' <<
e
331 << points_[
e.start()] <<
' ' << points_[
e.end()] <<
endl;
336 const label oldNEdges = edges_.size();
338 edges_.setSize(oldNEdges + additionalEdges.size());
341 label newEdgeI = oldNEdges;
343 forAll(additionalEdges, i)
345 edges_[newEdgeI] = additionalEdges[i];
353 label nFEdges = fEdges.size();
355 fEdges.setSize(nFEdges + additionalEdges.size());
357 forAll(additionalEdges, i)
359 fEdges[nFEdges++] = oldNEdges + i;
369 const labelList& fEdges = faceEdges_[facei];
371 Pout<<
"New face consists of edges:" <<
endl;
374 const edge&
e = edges_[fEdges[i]];
376 Pout<<
" " << fEdges[i] <<
' ' <<
e
377 << points_[
e.start()] <<
' ' << points_[
e.
end()] <<
endl;
A 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects.
void append(const T &val)
Copy append an element to the end of this list.
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
void append(const T &val)
Append an element at the end of the list.
void setSize(label n)
Alias for resize().
An OFstream that keeps track of vertices and provides convenience output methods for OBJ files.
virtual Ostream & write(const char c) override
Write character.
Output to file stream as an OSstream, normally using std::ofstream for the actual output.
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
virtual bool write(const token &tok)=0
Write token to stream or otherwise handle it.
label nEdges() const
Number of edges in patch.
const edgeList & edges() const
Return list of edges, address into LOCAL point list.
const Field< point_type > & localPoints() const
Return pointField of points in patch.
const labelListList & edgeFaces() const
Return edge-face addressing.
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
bool empty() const noexcept
True if List is empty (ie, size() is zero).
iterator end() noexcept
Return an iterator to end traversing the UList.
void size(const label n)
Older name for setAddressableSize.
T & last()
Access last element of the list, position [size()-1].
Description of surface in form of 'cloud of edges'.
void addIntersectionEdges(const label facei, const edgeList &)
Add intersection edges to a face. Used for connecting.
edgeSurface(const triSurface &surf, const bool isFirstSurface, const surfaceIntersection &inter)
Construct from surface and intersection description.
An edge is a list of two vertex labels. This can correspond to a directed graph edge or an edge on a ...
A class for handling file names.
Basic surface-surface intersection description. Constructed from two surfaces it creates a descriptio...
const edgeList & cutEdges() const
The list of created edges.
const labelListList & edgeCuts(const bool isFirstSurf) const
Access either surf1EdgeCuts (isFirstSurface = true) or.
const labelPairLookup & facePairToEdgeId() const
Lookup of pairs of faces to created edges.
const pointField & cutPoints() const
The list of cut points.
Triangulated surface description with patch information.
#define defineTypeNameAndDebug(Type, DebugSwitch)
Define the typeName and debug information.
OBJstream os(runTime.globalPath()/outputName)
Namespace for handling debugging switches.
List< edge > edgeList
List of edge.
List< label > labelList
A List of labels.
Ostream & endl(Ostream &os)
Add newline and flush stream.
static void writeObjEdges(const UList< point > &points, const edgeList &edges, const labelUList &edgeLabels, Ostream &os)
vector point
Point is a vector.
static constexpr const zero Zero
Global zero (0).
prefixOSstream Pout
OSstream wrapped stdout (std::cout) with parallel prefix.
vectorField pointField
pointField is a vectorField.
UList< label > labelUList
A UList of labels.
constexpr char nl
The newline '\n' character (0x0a).
#define forAll(list, i)
Loop across all elements in list.
#define forAllConstIters(container, iter)
Iterate across all elements of the container object with const access.