ResInsight/Fwk/AppFwk/cafVizExtensions/cafHexGridIntersectionTools/cafHexGridIntersectionTools.h
Gaute Lindkvist 9da54a115b Fix crash in cafHexGridIntersectionTools when exporting fracture completions.
* Account for two new triangle plane intersection cases where one vertex is touching the plane.
2018-05-09 10:44:29 +02:00

81 lines
3.2 KiB
C++

#pragma once
#include "cvfBase.h"
#include "cvfVector3.h"
#include <vector>
namespace cvf {
class Plane;
};
namespace caf {
//==================================================================================================
//
//
//==================================================================================================
class HexGridIntersectionTools
{
public:
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
struct ClipVx
{
ClipVx();
cvf::Vec3d vx;
double normDistFromEdgeVx1;
size_t clippedEdgeVx1Id;
size_t clippedEdgeVx2Id;
bool isVxIdsNative; //< Pointing to real vertices, or indices to ClipVx's in the supplied triangle vertices array
int derivedVxLevel; //< Helper data to make it possible to track what set of ClipVx's the indices is reffering to in case of consecutive clips
};
static bool planeLineIntersect(const cvf::Plane& plane,
const cvf::Vec3d& a,
const cvf::Vec3d& b,
cvf::Vec3d* intersection,
double* normalizedDistFromA,
double epsilon);
static bool planeTriangleIntersection(const cvf::Plane& plane,
const cvf::Vec3d& p1,
size_t p1Id,
const cvf::Vec3d& p2,
size_t p2Id,
const cvf::Vec3d& p3,
size_t p3Id,
ClipVx* newVx1,
ClipVx* newVx2,
bool* isMostVxesOnPositiveSide);
static void clipTrianglesBetweenTwoParallelPlanes(const std::vector<ClipVx>& triangleVxes,
const std::vector<int>& cellFaceForEachTriangleEdge,
const cvf::Plane& p1Plane,
const cvf::Plane& p2Plane,
std::vector<ClipVx>* clippedTriangleVxes,
std::vector<int>* cellFaceForEachClippedTriangleEdge);
static cvf::Vec3d planeLineIntersectionForMC(const cvf::Plane& plane,
const cvf::Vec3d& p1,
const cvf::Vec3d& p2,
double* normalizedDistFromP1);
static int planeHexIntersectionMC(const cvf::Plane& plane,
const cvf::Vec3d cell[8],
const size_t hexCornersIds[8],
std::vector<ClipVx>* triangleVxes,
std::vector<int>* cellFaceForEachTriangleEdge);
};
}; // namespace caf