Skip to content

Commit

Permalink
Minor adjustment
Browse files Browse the repository at this point in the history
- Refactor welding in grid surface endpoint
- Add missing include
  • Loading branch information
jorgenherje committed Apr 4, 2024
1 parent d552c1b commit 7b2a458
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include "RivEnclosingPolygonGenerator.h"
#include "cvfMath.h"

#include <algorithm>
#include <map>

RivEnclosingPolygonGenerator::RivEnclosingPolygonGenerator()
Expand Down
23 changes: 12 additions & 11 deletions GrpcInterface/RiaGrpcGridGeometryExtractionService.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -179,15 +179,11 @@ grpc::Status RiaGrpcGridGeometryExtractionService::GetGridSurface( grpc::ServerC

// Weld surface vertices
cvf::VertexWelder surfaceVertexWelder;
const cvf::uint numSurfaceWelderBuckets = static_cast<cvf::uint>( gridSurfaceVertices->size() );
surfaceVertexWelder.initialize( weldingDistance, weldingCellSize, numSurfaceWelderBuckets );
const auto& surfaceVertexIndices = weldVertices( surfaceVertexWelder, *gridSurfaceVertices );
const auto& surfaceVertexIndices = initAndWeldVertices( surfaceVertexWelder, *gridSurfaceVertices );

// Weld fault vertices
cvf::VertexWelder faultVertexWelder;
const cvf::uint numFaultWelderBuckets = static_cast<cvf::uint>( gridFaultVertices->size() );
faultVertexWelder.initialize( weldingDistance, weldingCellSize, numFaultWelderBuckets );
const auto& faultVertexIndices = weldVertices( faultVertexWelder, *gridFaultVertices );
const auto& faultVertexIndices = initAndWeldVertices( faultVertexWelder, *gridFaultVertices );
m_elapsedTimeInfo.elapsedTimePerEventMs["WeldVertices"] =
static_cast<std::uint32_t>( weldVerticesTimeCount.elapsedMsCount() );

Expand Down Expand Up @@ -429,17 +425,22 @@ std::vector<RiaGrpcCallbackInterface*> RiaGrpcGridGeometryExtractionService::cre
//--------------------------------------------------------------------------------------------------
/// Weld vertices and return array of indices of welded vertices
//--------------------------------------------------------------------------------------------------
std::vector<cvf::uint> RiaGrpcGridGeometryExtractionService::weldVertices( cvf::VertexWelder& rWelder,
const cvf::Vec3fArray& vertices )
std::vector<cvf::uint> RiaGrpcGridGeometryExtractionService::initAndWeldVertices( cvf::VertexWelder& rWelder,
const cvf::Vec3fArray& vertices ) const
{
std::vector<cvf::uint> vertexIndices;
// Initialize welder
const cvf::uint numBuckets = static_cast<cvf::uint>( vertices.size() );
rWelder.initialize( m_weldingDistance, m_weldingCellSize, numBuckets );

// Weld vertices
std::vector<cvf::uint> weldedVertexIndices;
for ( const auto& vertex : vertices )
{
bool wasWelded = false;
const auto welderIndex = rWelder.weldVertex( vertex, &wasWelded );
vertexIndices.push_back( welderIndex );
weldedVertexIndices.push_back( welderIndex );
}
return vertexIndices;
return weldedVertexIndices;
}

//--------------------------------------------------------------------------------------------------
Expand Down
8 changes: 7 additions & 1 deletion GrpcInterface/RiaGrpcGridGeometryExtractionService.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ class RiaGrpcGridGeometryExtractionService final : public rips::GridGeometryExtr
public:
std::vector<RiaGrpcCallbackInterface*> createCallbacks() override;

static std::vector<cvf::uint> weldVertices( cvf::VertexWelder& rWelder, const cvf::Vec3fArray& vertices );
std::vector<cvf::uint> initAndWeldVertices( cvf::VertexWelder& rWelder, const cvf::Vec3fArray& vertices ) const;

private:
void resetInternalPointers();
Expand All @@ -85,6 +85,12 @@ class RiaGrpcGridGeometryExtractionService final : public rips::GridGeometryExtr
std::unique_ptr<RigGridCellFaceVisibilityFilter> m_surfaceFaceVisibilityFilter = nullptr;
std::unique_ptr<RigGridCellFaultFaceVisibilityFilter> m_faultFaceVisibilityFilter = nullptr;

// Vertex welding
// - Low welding distance, as the goal is to weld duplicate vertices
// - Welding is done for surface and fault vertices separately
const double m_weldingDistance = 1e-3;
const double m_weldingCellSize = 4.0 * m_weldingDistance;

struct ElapsedTimeInfo
{
std::uint32_t totalTimeElapsedMs = 0; // Total time elapsed for entire request
Expand Down

0 comments on commit 7b2a458

Please sign in to comment.