Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions include/geometrycentral/surface/embedded_geometry_interface.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@ class EmbeddedGeometryInterface : public ExtrinsicGeometryInterface {
void requireVertexPositions();
void unrequireVertexPositions();

// Face centroids
FaceData<Vector3> faceCentroids;
void requireFaceCentroids();
void unrequireFaceCentroids();

// Face normal
FaceData<Vector3> faceNormals;
void requireFaceNormals();
Expand Down Expand Up @@ -116,6 +121,9 @@ class EmbeddedGeometryInterface : public ExtrinsicGeometryInterface {
DependentQuantityD<VertexData<Vector3>> vertexPositionsQ;
virtual void computeVertexPositions() = 0;

DependentQuantityD<FaceData<Vector3>> faceCentroidsQ;
virtual void computeFaceCentroids();

DependentQuantityD<FaceData<Vector3>> faceNormalsQ;
virtual void computeFaceNormals();

Expand Down
20 changes: 20 additions & 0 deletions src/surface/embedded_geometry_interface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ EmbeddedGeometryInterface::EmbeddedGeometryInterface(SurfaceMesh& mesh_) :
ExtrinsicGeometryInterface(mesh_),

vertexPositionsQ (&vertexPositions, std::bind(&EmbeddedGeometryInterface::computeVertexPositions, this), quantities),
faceCentroidsQ (&faceCentroids, std::bind(&EmbeddedGeometryInterface::computeFaceCentroids, this), quantities),
faceNormalsQ (&faceNormals, std::bind(&EmbeddedGeometryInterface::computeFaceNormals, this), quantities),
vertexNormalsQ (&vertexNormals, std::bind(&EmbeddedGeometryInterface::computeVertexNormals, this), quantities),
faceTangentBasisQ (&faceTangentBasis, std::bind(&EmbeddedGeometryInterface::computeFaceTangentBasis, this), quantities),
Expand Down Expand Up @@ -76,6 +77,25 @@ void EmbeddedGeometryInterface::computeEdgeDihedralAngles() {
void EmbeddedGeometryInterface::requireVertexPositions() { vertexPositionsQ.require(); }
void EmbeddedGeometryInterface::unrequireVertexPositions() { vertexPositionsQ.unrequire(); }

// Face centroids
void EmbeddedGeometryInterface::computeFaceCentroids() {
vertexPositionsQ.ensureHave();

faceCentroids = FaceData<Vector3>(mesh);

for (Face f : mesh.faces()) {
Vector3 centroid = Vector3::zero();
size_t n = 0;
for (Vertex v : f.adjacentVertices()) {
centroid += vertexPositions[v];
n++;
}
centroid /= static_cast<double>(n);
faceCentroids[f] = centroid;
}
}
void EmbeddedGeometryInterface::requireFaceCentroids() { faceCentroidsQ.require(); }
void EmbeddedGeometryInterface::unrequireFaceCentroids() { faceCentroidsQ.unrequire(); }

void EmbeddedGeometryInterface::computeFaceNormals() {
vertexPositionsQ.ensureHave();
Expand Down