2015-11-16 03:52:38 -06:00
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
//
|
|
|
|
// Copyright (C) Statoil ASA
|
|
|
|
// Copyright (C) Ceetron Solutions AS
|
|
|
|
//
|
|
|
|
// ResInsight is free software: you can redistribute it and/or modify
|
|
|
|
// it under the terms of the GNU General Public License as published by
|
|
|
|
// the Free Software Foundation, either version 3 of the License, or
|
|
|
|
// (at your option) any later version.
|
|
|
|
//
|
|
|
|
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
|
|
|
|
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
|
|
// FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
//
|
|
|
|
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
|
|
|
// for more details.
|
|
|
|
//
|
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2016-09-21 03:36:11 -05:00
|
|
|
#include "RivIntersectionGeometryGenerator.h"
|
2015-11-26 09:00:08 -06:00
|
|
|
|
2015-11-16 03:52:38 -06:00
|
|
|
#include "RigMainGrid.h"
|
2015-11-16 05:12:42 -06:00
|
|
|
#include "RigResultAccessor.h"
|
2015-11-26 09:00:08 -06:00
|
|
|
|
2016-09-21 03:48:25 -05:00
|
|
|
#include "RimIntersection.h"
|
2015-11-26 09:00:08 -06:00
|
|
|
|
2017-01-17 08:11:02 -06:00
|
|
|
#include "RivHexGridIntersectionTools.h"
|
|
|
|
|
2016-09-20 08:57:06 -05:00
|
|
|
#include "cafHexGridIntersectionTools/cafHexGridIntersectionTools.h"
|
|
|
|
|
2015-11-26 09:00:08 -06:00
|
|
|
#include "cvfDrawableGeo.h"
|
2017-01-17 08:11:02 -06:00
|
|
|
#include "cvfGeometryTools.h"
|
|
|
|
#include "cvfPlane.h"
|
2015-11-18 08:29:10 -06:00
|
|
|
#include "cvfPrimitiveSetDirect.h"
|
2015-11-30 01:10:10 -06:00
|
|
|
#include "cvfPrimitiveSetIndexedUInt.h"
|
2015-11-26 09:00:08 -06:00
|
|
|
#include "cvfScalarMapper.h"
|
2015-11-16 03:52:38 -06:00
|
|
|
|
|
|
|
|
2015-11-16 05:12:42 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2016-09-21 03:48:25 -05:00
|
|
|
RivIntersectionGeometryGenerator::RivIntersectionGeometryGenerator(const RimIntersection* crossSection,
|
2015-11-26 09:00:08 -06:00
|
|
|
std::vector<std::vector<cvf::Vec3d> > &polylines,
|
|
|
|
const cvf::Vec3d& extrusionDirection,
|
2016-09-21 03:15:38 -05:00
|
|
|
const RivIntersectionHexGridInterface* grid)
|
2015-11-26 09:00:08 -06:00
|
|
|
: m_crossSection(crossSection),
|
|
|
|
m_polyLines(polylines),
|
2015-11-16 05:12:42 -06:00
|
|
|
m_extrusionDirection(extrusionDirection),
|
2015-11-20 06:26:41 -06:00
|
|
|
m_hexGrid(grid)
|
2015-11-16 05:12:42 -06:00
|
|
|
{
|
|
|
|
m_triangleVxes = new cvf::Vec3fArray;
|
2015-11-18 08:29:10 -06:00
|
|
|
m_cellBorderLineVxes = new cvf::Vec3fArray;
|
2015-11-16 05:12:42 -06:00
|
|
|
}
|
|
|
|
|
2015-11-16 03:52:38 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2016-09-21 03:36:11 -05:00
|
|
|
RivIntersectionGeometryGenerator::~RivIntersectionGeometryGenerator()
|
2015-11-16 03:52:38 -06:00
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2016-09-21 03:36:11 -05:00
|
|
|
void RivIntersectionGeometryGenerator::calculateArrays()
|
2015-11-16 03:52:38 -06:00
|
|
|
{
|
2015-11-16 05:12:42 -06:00
|
|
|
if (m_triangleVxes->size()) return;
|
|
|
|
|
2015-11-17 10:21:53 -06:00
|
|
|
m_extrusionDirection.normalize();
|
2015-11-16 05:12:42 -06:00
|
|
|
std::vector<cvf::Vec3f> triangleVertices;
|
2015-11-18 08:29:10 -06:00
|
|
|
std::vector<cvf::Vec3f> cellBorderLineVxes;
|
2015-11-20 06:26:41 -06:00
|
|
|
cvf::Vec3d displayOffset = m_hexGrid->displayOffset();
|
|
|
|
cvf::BoundingBox gridBBox = m_hexGrid->boundingBox();
|
2015-11-16 03:52:38 -06:00
|
|
|
|
2015-11-26 04:08:38 -06:00
|
|
|
for (size_t pLineIdx = 0; pLineIdx < m_polyLines.size(); ++pLineIdx)
|
2015-11-16 03:52:38 -06:00
|
|
|
{
|
2015-11-26 04:08:38 -06:00
|
|
|
const std::vector<cvf::Vec3d>& m_polyLine = m_polyLines[pLineIdx];
|
2015-11-27 10:14:21 -06:00
|
|
|
|
|
|
|
if (m_polyLine.size() < 2) continue;
|
|
|
|
|
2015-11-26 04:08:38 -06:00
|
|
|
std::vector<cvf::Vec3d> m_adjustedPolyline;
|
|
|
|
adjustPolyline(m_polyLine, m_extrusionDirection, &m_adjustedPolyline);
|
|
|
|
|
|
|
|
size_t lineCount = m_adjustedPolyline.size();
|
|
|
|
for (size_t lIdx = 0; lIdx < lineCount - 1; ++lIdx)
|
2015-11-16 03:52:38 -06:00
|
|
|
{
|
2015-11-26 04:08:38 -06:00
|
|
|
cvf::Vec3d p1 = m_adjustedPolyline[lIdx];
|
|
|
|
cvf::Vec3d p2 = m_adjustedPolyline[lIdx+1];
|
|
|
|
|
|
|
|
cvf::BoundingBox sectionBBox;
|
|
|
|
sectionBBox.add(p1);
|
|
|
|
sectionBBox.add(p2);
|
|
|
|
double maxSectionHeight = gridBBox.radius();
|
|
|
|
sectionBBox.add(p1 + m_extrusionDirection*maxSectionHeight);
|
|
|
|
sectionBBox.add(p1 - m_extrusionDirection*maxSectionHeight);
|
|
|
|
sectionBBox.add(p2 + m_extrusionDirection*maxSectionHeight);
|
|
|
|
sectionBBox.add(p2 - m_extrusionDirection*maxSectionHeight);
|
|
|
|
|
|
|
|
std::vector<size_t> columnCellCandidates;
|
|
|
|
m_hexGrid->findIntersectingCells(sectionBBox, &columnCellCandidates);
|
|
|
|
|
|
|
|
cvf::Plane plane;
|
|
|
|
plane.setFromPoints(p1, p2, p2 + m_extrusionDirection*maxSectionHeight);
|
|
|
|
|
|
|
|
cvf::Plane p1Plane;
|
|
|
|
p1Plane.setFromPoints(p1, p1 + m_extrusionDirection*maxSectionHeight, p1 + plane.normal());
|
|
|
|
cvf::Plane p2Plane;
|
|
|
|
p2Plane.setFromPoints(p2, p2 + m_extrusionDirection*maxSectionHeight, p2 - plane.normal());
|
|
|
|
|
|
|
|
|
2016-09-20 08:57:06 -05:00
|
|
|
std::vector<caf::HexGridIntersectionTools::ClipVx> hexPlaneCutTriangleVxes;
|
2015-11-26 04:08:38 -06:00
|
|
|
hexPlaneCutTriangleVxes.reserve(5*3);
|
|
|
|
std::vector<bool> isTriangleEdgeCellContour;
|
|
|
|
isTriangleEdgeCellContour.reserve(5*3);
|
|
|
|
cvf::Vec3d cellCorners[8];
|
|
|
|
size_t cornerIndices[8];
|
|
|
|
|
|
|
|
for (size_t cccIdx = 0; cccIdx < columnCellCandidates.size(); ++cccIdx)
|
|
|
|
{
|
|
|
|
size_t globalCellIdx = columnCellCandidates[cccIdx];
|
2015-11-16 03:52:38 -06:00
|
|
|
|
2015-11-26 04:08:38 -06:00
|
|
|
if (!m_hexGrid->useCell(globalCellIdx)) continue;
|
2015-11-16 03:52:38 -06:00
|
|
|
|
2015-11-26 04:08:38 -06:00
|
|
|
hexPlaneCutTriangleVxes.clear();
|
|
|
|
m_hexGrid->cellCornerVertices(globalCellIdx, cellCorners);
|
|
|
|
m_hexGrid->cellCornerIndices(globalCellIdx, cornerIndices);
|
2015-11-16 03:52:38 -06:00
|
|
|
|
2016-09-20 08:57:06 -05:00
|
|
|
caf::HexGridIntersectionTools::planeHexIntersectionMC(plane,
|
2015-11-27 09:37:26 -06:00
|
|
|
cellCorners,
|
|
|
|
cornerIndices,
|
|
|
|
&hexPlaneCutTriangleVxes,
|
|
|
|
&isTriangleEdgeCellContour);
|
2015-11-18 08:29:10 -06:00
|
|
|
|
2016-09-20 08:57:06 -05:00
|
|
|
std::vector<caf::HexGridIntersectionTools::ClipVx> clippedTriangleVxes;
|
2015-11-26 04:08:38 -06:00
|
|
|
std::vector<bool> isClippedTriEdgeCellContour;
|
2015-11-19 03:59:05 -06:00
|
|
|
|
2016-09-20 08:57:06 -05:00
|
|
|
caf::HexGridIntersectionTools::clipTrianglesBetweenTwoParallelPlanes(hexPlaneCutTriangleVxes, isTriangleEdgeCellContour, p1Plane, p2Plane,
|
2015-11-26 04:08:38 -06:00
|
|
|
&clippedTriangleVxes, &isClippedTriEdgeCellContour);
|
2015-11-18 08:29:10 -06:00
|
|
|
|
2015-11-26 04:08:38 -06:00
|
|
|
size_t clippedTriangleCount = clippedTriangleVxes.size()/3;
|
2015-11-20 01:45:23 -06:00
|
|
|
|
2015-11-26 04:08:38 -06:00
|
|
|
for (uint tIdx = 0; tIdx < clippedTriangleCount; ++tIdx)
|
|
|
|
{
|
|
|
|
uint triVxIdx = tIdx*3;
|
2015-11-19 03:59:05 -06:00
|
|
|
|
2015-11-26 04:08:38 -06:00
|
|
|
// Accumulate triangle vertices
|
2015-11-19 03:59:05 -06:00
|
|
|
|
2015-11-26 04:08:38 -06:00
|
|
|
cvf::Vec3f p0(clippedTriangleVxes[triVxIdx+0].vx - displayOffset);
|
|
|
|
cvf::Vec3f p1(clippedTriangleVxes[triVxIdx+1].vx - displayOffset);
|
|
|
|
cvf::Vec3f p2(clippedTriangleVxes[triVxIdx+2].vx - displayOffset);
|
2015-11-19 03:59:05 -06:00
|
|
|
|
2015-11-26 04:08:38 -06:00
|
|
|
triangleVertices.push_back(p0);
|
|
|
|
triangleVertices.push_back(p1);
|
|
|
|
triangleVertices.push_back(p2);
|
2015-11-18 08:29:10 -06:00
|
|
|
|
2015-11-19 03:59:05 -06:00
|
|
|
|
2015-11-26 04:08:38 -06:00
|
|
|
// Accumulate mesh lines
|
2015-11-19 03:59:05 -06:00
|
|
|
|
2015-11-26 04:08:38 -06:00
|
|
|
if (isClippedTriEdgeCellContour[triVxIdx])
|
|
|
|
{
|
|
|
|
cellBorderLineVxes.push_back(p0);
|
|
|
|
cellBorderLineVxes.push_back(p1);
|
|
|
|
}
|
|
|
|
if (isClippedTriEdgeCellContour[triVxIdx+1])
|
2015-11-19 06:33:50 -06:00
|
|
|
{
|
2015-11-26 04:08:38 -06:00
|
|
|
cellBorderLineVxes.push_back(p1);
|
|
|
|
cellBorderLineVxes.push_back(p2);
|
2015-11-19 06:33:50 -06:00
|
|
|
}
|
2015-11-26 04:08:38 -06:00
|
|
|
if (isClippedTriEdgeCellContour[triVxIdx+2])
|
2015-11-19 06:33:50 -06:00
|
|
|
{
|
2015-11-26 04:08:38 -06:00
|
|
|
cellBorderLineVxes.push_back(p2);
|
|
|
|
cellBorderLineVxes.push_back(p0);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Mapping to cell index
|
2015-11-19 06:33:50 -06:00
|
|
|
|
2015-11-26 04:08:38 -06:00
|
|
|
m_triangleToCellIdxMap.push_back(globalCellIdx);
|
2015-11-19 06:33:50 -06:00
|
|
|
|
2015-11-26 04:08:38 -06:00
|
|
|
// Interpolation from nodes
|
|
|
|
for (int i = 0; i < 3; ++i)
|
|
|
|
{
|
2016-09-20 08:57:06 -05:00
|
|
|
caf::HexGridIntersectionTools::ClipVx cvx = clippedTriangleVxes[triVxIdx + i];
|
2015-11-26 04:08:38 -06:00
|
|
|
if (cvx.isVxIdsNative)
|
|
|
|
{
|
|
|
|
m_triVxToCellCornerWeights.push_back(
|
2016-09-21 03:15:38 -05:00
|
|
|
RivIntersectionVertexWeights(cvx.clippedEdgeVx1Id, cvx.clippedEdgeVx2Id, cvx.normDistFromEdgeVx1));
|
2015-11-26 04:08:38 -06:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2016-09-20 08:57:06 -05:00
|
|
|
caf::HexGridIntersectionTools::ClipVx cvx1 = hexPlaneCutTriangleVxes[cvx.clippedEdgeVx1Id];
|
|
|
|
caf::HexGridIntersectionTools::ClipVx cvx2 = hexPlaneCutTriangleVxes[cvx.clippedEdgeVx2Id];
|
2015-11-26 04:08:38 -06:00
|
|
|
|
|
|
|
m_triVxToCellCornerWeights.push_back(
|
2016-09-21 03:15:38 -05:00
|
|
|
RivIntersectionVertexWeights(cvx1.clippedEdgeVx1Id, cvx1.clippedEdgeVx2Id, cvx1.normDistFromEdgeVx1,
|
2015-11-26 04:08:38 -06:00
|
|
|
cvx2.clippedEdgeVx1Id, cvx2.clippedEdgeVx2Id, cvx2.normDistFromEdgeVx1,
|
|
|
|
cvx.normDistFromEdgeVx1));
|
|
|
|
|
|
|
|
}
|
2015-11-19 06:33:50 -06:00
|
|
|
}
|
|
|
|
}
|
2015-11-16 03:52:38 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2015-11-16 05:12:42 -06:00
|
|
|
m_triangleVxes->assign(triangleVertices);
|
2015-11-18 08:29:10 -06:00
|
|
|
m_cellBorderLineVxes->assign(cellBorderLineVxes);
|
2015-11-16 05:12:42 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
/// Generate surface drawable geo from the specified region
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2016-09-21 03:36:11 -05:00
|
|
|
cvf::ref<cvf::DrawableGeo> RivIntersectionGeometryGenerator::generateSurface()
|
2015-11-16 05:12:42 -06:00
|
|
|
{
|
|
|
|
calculateArrays();
|
|
|
|
|
|
|
|
CVF_ASSERT(m_triangleVxes.notNull());
|
|
|
|
|
|
|
|
if (m_triangleVxes->size() == 0) return NULL;
|
|
|
|
|
|
|
|
cvf::ref<cvf::DrawableGeo> geo = new cvf::DrawableGeo;
|
|
|
|
geo->setFromTriangleVertexArray(m_triangleVxes.p());
|
|
|
|
|
|
|
|
return geo;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-11-17 02:23:33 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2016-09-21 03:36:11 -05:00
|
|
|
cvf::ref<cvf::DrawableGeo> RivIntersectionGeometryGenerator::createMeshDrawable()
|
2015-11-17 02:23:33 -06:00
|
|
|
{
|
2015-11-18 08:29:10 -06:00
|
|
|
if (!(m_cellBorderLineVxes.notNull() && m_cellBorderLineVxes->size() != 0)) return NULL;
|
|
|
|
|
2015-11-17 02:23:33 -06:00
|
|
|
cvf::ref<cvf::DrawableGeo> geo = new cvf::DrawableGeo;
|
2015-11-18 08:29:10 -06:00
|
|
|
geo->setVertexArray(m_cellBorderLineVxes.p());
|
|
|
|
|
|
|
|
|
|
|
|
cvf::ref<cvf::PrimitiveSetDirect> prim = new cvf::PrimitiveSetDirect(cvf::PT_LINES);
|
|
|
|
prim->setIndexCount(m_cellBorderLineVxes->size());
|
|
|
|
|
|
|
|
geo->addPrimitiveSet(prim.p());
|
2015-11-17 02:23:33 -06:00
|
|
|
return geo;
|
|
|
|
}
|
|
|
|
|
2015-11-30 01:10:10 -06:00
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2016-09-21 03:36:11 -05:00
|
|
|
cvf::ref<cvf::DrawableGeo> RivIntersectionGeometryGenerator::createLineAlongPolylineDrawable()
|
2016-10-18 07:25:31 -05:00
|
|
|
{
|
|
|
|
return createLineAlongPolylineDrawable(m_polyLines);
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
cvf::ref<cvf::DrawableGeo> RivIntersectionGeometryGenerator::createLineAlongPolylineDrawable(const std::vector<std::vector<cvf::Vec3d> >& polyLines)
|
2015-11-30 01:10:10 -06:00
|
|
|
{
|
|
|
|
std::vector<cvf::uint> lineIndices;
|
|
|
|
std::vector<cvf::Vec3f> vertices;
|
|
|
|
|
|
|
|
cvf::Vec3d displayOffset = m_hexGrid->displayOffset();
|
|
|
|
|
2016-10-18 07:25:31 -05:00
|
|
|
for (size_t pLineIdx = 0; pLineIdx < polyLines.size(); ++pLineIdx)
|
2015-11-30 01:10:10 -06:00
|
|
|
{
|
2016-10-18 07:25:31 -05:00
|
|
|
const std::vector<cvf::Vec3d>& polyLine = polyLines[pLineIdx];
|
|
|
|
if (polyLine.size() < 2) continue;
|
2015-11-30 01:10:10 -06:00
|
|
|
|
2016-10-18 07:25:31 -05:00
|
|
|
for (size_t i = 0; i < polyLine.size(); ++i)
|
2015-11-30 01:10:10 -06:00
|
|
|
{
|
2016-10-18 07:25:31 -05:00
|
|
|
vertices.push_back(cvf::Vec3f(polyLine[i] - displayOffset));
|
|
|
|
if (i < polyLine.size() - 1)
|
2015-11-30 01:10:10 -06:00
|
|
|
{
|
|
|
|
lineIndices.push_back(static_cast<cvf::uint>(i));
|
|
|
|
lineIndices.push_back(static_cast<cvf::uint>(i + 1));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (vertices.size() == 0) return NULL;
|
|
|
|
|
|
|
|
cvf::ref<cvf::Vec3fArray> vx = new cvf::Vec3fArray;
|
|
|
|
vx->assign(vertices);
|
|
|
|
cvf::ref<cvf::UIntArray> idxes = new cvf::UIntArray;
|
|
|
|
idxes->assign(lineIndices);
|
|
|
|
|
|
|
|
cvf::ref<cvf::PrimitiveSetIndexedUInt> prim = new cvf::PrimitiveSetIndexedUInt(cvf::PT_LINES);
|
|
|
|
prim->setIndices(idxes.p());
|
|
|
|
|
|
|
|
cvf::ref<cvf::DrawableGeo> polylineGeo = new cvf::DrawableGeo;
|
|
|
|
polylineGeo->setVertexArray(vx.p());
|
|
|
|
polylineGeo->addPrimitiveSet(prim.p());
|
|
|
|
|
|
|
|
return polylineGeo;
|
|
|
|
}
|
|
|
|
|
2015-11-30 06:54:56 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2016-09-21 03:36:11 -05:00
|
|
|
cvf::ref<cvf::DrawableGeo> RivIntersectionGeometryGenerator::createPointsFromPolylineDrawable()
|
2016-10-18 07:25:31 -05:00
|
|
|
{
|
|
|
|
return createPointsFromPolylineDrawable(m_polyLines);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
cvf::ref<cvf::DrawableGeo> RivIntersectionGeometryGenerator::createPointsFromPolylineDrawable(const std::vector<std::vector<cvf::Vec3d> >& polyLines)
|
2015-11-30 06:54:56 -06:00
|
|
|
{
|
|
|
|
std::vector<cvf::Vec3f> vertices;
|
|
|
|
|
|
|
|
cvf::Vec3d displayOffset = m_hexGrid->displayOffset();
|
|
|
|
|
2016-10-18 07:25:31 -05:00
|
|
|
for (size_t pLineIdx = 0; pLineIdx < polyLines.size(); ++pLineIdx)
|
2015-11-30 06:54:56 -06:00
|
|
|
{
|
2016-10-18 07:25:31 -05:00
|
|
|
const std::vector<cvf::Vec3d>& polyLine = polyLines[pLineIdx];
|
|
|
|
for (size_t i = 0; i < polyLine.size(); ++i)
|
2015-11-30 06:54:56 -06:00
|
|
|
{
|
2016-10-18 07:25:31 -05:00
|
|
|
vertices.push_back(cvf::Vec3f(polyLine[i] - displayOffset));
|
2015-11-30 06:54:56 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (vertices.size() == 0) return NULL;
|
|
|
|
|
|
|
|
cvf::ref<cvf::PrimitiveSetDirect> primSet = new cvf::PrimitiveSetDirect(cvf::PT_POINTS);
|
|
|
|
primSet->setStartIndex(0);
|
|
|
|
primSet->setIndexCount(vertices.size());
|
|
|
|
|
|
|
|
cvf::ref<cvf::DrawableGeo> geo = new cvf::DrawableGeo;
|
|
|
|
|
|
|
|
cvf::ref<cvf::Vec3fArray> vx = new cvf::Vec3fArray(vertices);
|
|
|
|
geo->setVertexArray(vx.p());
|
|
|
|
geo->addPrimitiveSet(primSet.p());
|
|
|
|
|
|
|
|
return geo;
|
|
|
|
|
2016-10-18 07:25:31 -05:00
|
|
|
}
|
2015-11-30 06:54:56 -06:00
|
|
|
|
2015-11-16 05:12:42 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2015-11-20 06:26:41 -06:00
|
|
|
/// Remove the lines from the polyline that is nearly parallel to the extrusion direction
|
2015-11-16 05:12:42 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2016-09-21 03:36:11 -05:00
|
|
|
void RivIntersectionGeometryGenerator::adjustPolyline(const std::vector<cvf::Vec3d>& polyLine,
|
2015-11-20 06:26:41 -06:00
|
|
|
const cvf::Vec3d extrDir,
|
|
|
|
std::vector<cvf::Vec3d>* adjustedPolyline)
|
2015-11-16 05:12:42 -06:00
|
|
|
{
|
2015-11-20 06:26:41 -06:00
|
|
|
size_t lineCount = polyLine.size();
|
|
|
|
if (!polyLine.size()) return;
|
2015-11-16 05:12:42 -06:00
|
|
|
|
2015-11-20 06:26:41 -06:00
|
|
|
adjustedPolyline->push_back(polyLine[0]);
|
|
|
|
cvf::Vec3d p1 = polyLine[0];
|
2015-11-16 05:12:42 -06:00
|
|
|
|
2015-11-20 06:26:41 -06:00
|
|
|
for (size_t lIdx = 1; lIdx < lineCount; ++lIdx)
|
2015-11-16 05:12:42 -06:00
|
|
|
{
|
2015-11-20 06:26:41 -06:00
|
|
|
cvf::Vec3d p2 = polyLine[lIdx];
|
|
|
|
cvf::Vec3d p1p2 = p2 - p1;
|
2015-11-16 05:12:42 -06:00
|
|
|
|
2015-11-20 06:26:41 -06:00
|
|
|
if ((p1p2 - (p1p2 * extrDir)*extrDir).length() > 0.1 )
|
|
|
|
{
|
|
|
|
adjustedPolyline->push_back(p2);
|
|
|
|
p1 = p2;
|
2015-11-16 05:12:42 -06:00
|
|
|
}
|
|
|
|
}
|
2015-11-16 03:52:38 -06:00
|
|
|
}
|
2015-11-17 10:21:53 -06:00
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2016-09-21 03:36:11 -05:00
|
|
|
const std::vector<size_t>& RivIntersectionGeometryGenerator::triangleToCellIndex() const
|
2015-11-17 10:21:53 -06:00
|
|
|
{
|
2015-11-20 06:26:41 -06:00
|
|
|
CVF_ASSERT(m_triangleVxes->size());
|
|
|
|
return m_triangleToCellIdxMap;
|
|
|
|
}
|
2015-11-17 10:21:53 -06:00
|
|
|
|
2015-11-20 06:26:41 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2016-09-21 03:36:11 -05:00
|
|
|
const std::vector<RivIntersectionVertexWeights>& RivIntersectionGeometryGenerator::triangleVxToCellCornerInterpolationWeights() const
|
2015-11-20 06:26:41 -06:00
|
|
|
{
|
|
|
|
CVF_ASSERT(m_triangleVxes->size());
|
|
|
|
return m_triVxToCellCornerWeights;
|
2015-11-17 10:21:53 -06:00
|
|
|
}
|
2015-11-20 05:02:43 -06:00
|
|
|
|
2016-10-20 03:49:44 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2016-10-20 09:09:27 -05:00
|
|
|
const cvf::Vec3fArray* RivIntersectionGeometryGenerator::triangleVxes() const
|
2016-10-20 03:49:44 -05:00
|
|
|
{
|
2016-10-20 09:09:27 -05:00
|
|
|
CVF_ASSERT(m_triangleVxes->size());
|
|
|
|
return m_triangleVxes.p();
|
2016-10-20 03:49:44 -05:00
|
|
|
}
|
|
|
|
|
2015-11-26 09:00:08 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2016-09-21 03:48:25 -05:00
|
|
|
const RimIntersection* RivIntersectionGeometryGenerator::crossSection() const
|
2015-11-26 09:00:08 -06:00
|
|
|
{
|
|
|
|
return m_crossSection;
|
|
|
|
}
|
2015-11-20 05:02:43 -06:00
|
|
|
|
2015-12-03 05:54:13 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2016-09-21 03:36:11 -05:00
|
|
|
bool RivIntersectionGeometryGenerator::isAnyGeometryPresent() const
|
2015-12-03 05:54:13 -06:00
|
|
|
{
|
|
|
|
if (m_triangleVxes->size() == 0)
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|