#3928 Coordinate transform : Add convert of vector of points

This commit is contained in:
Magne Sjaastad 2019-01-03 13:16:26 +01:00
parent ecb1b83dfa
commit f09fa727fa
12 changed files with 52 additions and 84 deletions

View File

@ -98,21 +98,17 @@ void Riv3dWellLogCurveGeometryGenerator::createCurveDrawables(const caf::Display
}
clipLocation = displayCoordTransform->transformToDisplayCoord(clipLocation);
std::vector<cvf::Vec3d> wellPathPoints = wellPathGeometry()->m_wellPathPoints;
for (cvf::Vec3d& wellPathPoint : wellPathPoints)
{
wellPathPoint = displayCoordTransform->transformToDisplayCoord(wellPathPoint);
}
std::vector<cvf::Vec3d> displayCoords = displayCoordTransform->transformToDisplayCoords(wellPathGeometry()->m_wellPathPoints);
std::vector<cvf::Vec3d> wellPathCurveNormals =
RigWellPathGeometryTools::calculateLineSegmentNormals(wellPathPoints, rim3dWellLogCurve->drawPlaneAngle(rim3dWellLogCurve->drawPlane()));
RigWellPathGeometryTools::calculateLineSegmentNormals(displayCoords, rim3dWellLogCurve->drawPlaneAngle(rim3dWellLogCurve->drawPlane()));
std::vector<cvf::Vec3d> interpolatedWellPathPoints;
std::vector<cvf::Vec3d> interpolatedCurveNormals;
// Iterate from bottom of well path and up to be able to stop at given Z max clipping height
for (auto md = resultMds.rbegin(); md != resultMds.rend(); md++)
{
cvf::Vec3d point = wellPathGeometry()->interpolatedVectorValuesAlongWellPath(wellPathPoints, *md);
cvf::Vec3d point = wellPathGeometry()->interpolatedVectorValuesAlongWellPath(displayCoords, *md);
cvf::Vec3d normal = wellPathGeometry()->interpolatedVectorValuesAlongWellPath(wellPathCurveNormals, *md);
if (point.z() > clipLocation.z()) break;

View File

@ -72,20 +72,20 @@ Riv3dWellLogDrawSurfaceGenerator::createDrawSurface(const caf::DisplayCoordTrans
RimWellPathCollection* wellPathCollection = nullptr;
m_wellPath->firstAncestorOrThisOfTypeAsserted(wellPathCollection);
std::vector<cvf::Vec3d> wellPathPoints = wellPathGeometry()->m_wellPathPoints;
if (wellPathPoints.size() < (size_t)2)
std::vector<cvf::Vec3d> wellPathDisplayCoords;
{
// Need at least two well path points to create a valid path.
return false;
}
std::vector<cvf::Vec3d> domainCoords = wellPathGeometry()->m_wellPathPoints;
if (domainCoords.size() < (size_t)2)
{
// Need at least two well path points to create a valid path.
return false;
}
for (cvf::Vec3d& wellPathPoint : wellPathPoints)
{
wellPathPoint = displayCoordTransform->transformToDisplayCoord(wellPathPoint);
wellPathDisplayCoords = displayCoordTransform->transformToDisplayCoords(domainCoords);
}
std::vector<cvf::Vec3d> wellPathSegmentNormals =
RigWellPathGeometryTools::calculateLineSegmentNormals(wellPathPoints, planeAngle);
RigWellPathGeometryTools::calculateLineSegmentNormals(wellPathDisplayCoords, planeAngle);
size_t indexToFirstVisibleSegment = 0u;
if (wellPathCollection->wellPathClip)
@ -95,27 +95,27 @@ Riv3dWellLogDrawSurfaceGenerator::createDrawSurface(const caf::DisplayCoordTrans
clipLocation = displayCoordTransform->transformToDisplayCoord(clipLocation);
double horizontalLengthAlongWellToClipPoint;
wellPathPoints = RigWellPath::clipPolylineStartAboveZ(
wellPathPoints, clipLocation.z(), &horizontalLengthAlongWellToClipPoint, &indexToFirstVisibleSegment);
wellPathDisplayCoords = RigWellPath::clipPolylineStartAboveZ(
wellPathDisplayCoords, clipLocation.z(), &horizontalLengthAlongWellToClipPoint, &indexToFirstVisibleSegment);
}
// Create curve normal vectors using the unclipped well path points and normals.
createCurveNormalVectors(displayCoordTransform, indexToFirstVisibleSegment, planeOffsetFromWellPathCenter, planeWidth, samplingIntervalSize, wellPathSegmentNormals);
// Note that normals are calculated on the full non-clipped well path. So we need to clip the start here.
wellPathSegmentNormals.erase(wellPathSegmentNormals.begin(), wellPathSegmentNormals.end() - wellPathPoints.size());
wellPathSegmentNormals.erase(wellPathSegmentNormals.begin(), wellPathSegmentNormals.end() - wellPathDisplayCoords.size());
if (wellPathPoints.size() < (size_t)2)
if (wellPathDisplayCoords.size() < (size_t)2)
{
// Need at least two well path points to create a valid path.
return false;
}
m_vertices.reserve(wellPathPoints.size() * 2);
for (size_t i = 0; i < wellPathPoints.size(); i++)
m_vertices.reserve(wellPathDisplayCoords.size() * 2);
for (size_t i = 0; i < wellPathDisplayCoords.size(); i++)
{
m_vertices.push_back(wellPathPoints[i] + wellPathSegmentNormals[i] * (planeOffsetFromWellPathCenter - 0.025*planeWidth));
m_vertices.push_back(wellPathPoints[i] + wellPathSegmentNormals[i] * (planeOffsetFromWellPathCenter + 1.025*planeWidth));
m_vertices.push_back(wellPathDisplayCoords[i] + wellPathSegmentNormals[i] * (planeOffsetFromWellPathCenter - 0.025*planeWidth));
m_vertices.push_back(wellPathDisplayCoords[i] + wellPathSegmentNormals[i] * (planeOffsetFromWellPathCenter + 1.025*planeWidth));
}
cvf::ref<cvf::Vec3fArray> vertexArray = new cvf::Vec3fArray(m_vertices.size());

View File

@ -95,11 +95,7 @@ void RivFishbonesSubsPartMgr::buildParts(const caf::DisplayCoordTransform* displ
{
std::vector<cvf::Vec3d> lateralDomainCoords = m_rimFishbonesSubs->coordsForLateral(sub.subIndex, lateralIndex);
std::vector<cvf::Vec3d> displayCoords;
for (auto domainCoord : lateralDomainCoords)
{
displayCoords.push_back(displayCoordTransform->transformToDisplayCoord(domainCoord));
}
std::vector<cvf::Vec3d> displayCoords = displayCoordTransform->transformToDisplayCoords(lateralDomainCoords);
geoGenerator.cylinderWithCenterLineParts(&m_parts, displayCoords, m_rimFishbonesSubs->fishbonesColor(), wellPath->combinedScaleFactor() * characteristicCellSize * 0.5);
}

View File

@ -120,7 +120,7 @@ void RivMeasurementPartMgr::clearGeometryCache()
//--------------------------------------------------------------------------------------------------
void RivMeasurementPartMgr::buildPolyLineParts(const caf::DisplayCoordTransform* displayCoordTransform)
{
auto pointsInDisplay = transformPolylinesPointsToDisplay(m_measurement->pointsInDomainCoords(), displayCoordTransform);
auto pointsInDisplay = displayCoordTransform->transformToDisplayCoords(m_measurement->pointsInDomainCoords());
// Measurement lines
{
@ -213,21 +213,6 @@ void RivMeasurementPartMgr::buildPolyLineParts(const caf::DisplayCoordTransform*
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::vector<RivMeasurementPartMgr::Vec3d>
RivMeasurementPartMgr::transformPolylinesPointsToDisplay(const std::vector<Vec3d>& pointsInDomain,
const caf::DisplayCoordTransform* displayXf)
{
std::vector<Vec3d> pointsInDisplay;
for (const auto& pt : pointsInDomain)
{
pointsInDisplay.push_back(displayXf->transformToDisplayCoord(pt));
}
return pointsInDisplay;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------

View File

@ -59,8 +59,6 @@ public:
private:
void buildPolyLineParts(const caf::DisplayCoordTransform* displayCoordTransform);
std::vector<Vec3d> transformPolylinesPointsToDisplay(const std::vector<Vec3d>& pointsInDomain,
const caf::DisplayCoordTransform* displayXf);
bool isPolylinesInBoundingBox(const cvf::BoundingBox& boundingBox);
private:

View File

@ -209,12 +209,9 @@ std::vector<std::vector<cvf::Vec3d>> RivPolylineAnnotationPartMgr::transformPoly
std::vector<std::vector<Vec3d>> pointsInDisplay;
for (const auto& pts : pointsInDomain)
{
std::vector<Vec3d> polyline;
for (const auto& pt : pts)
{
polyline.push_back(displayXf->transformToDisplayCoord(pt));
}
pointsInDisplay.push_back(polyline);
std::vector<cvf::Vec3d> displayCoords = displayXf->transformToDisplayCoords(pts);
pointsInDisplay.push_back(displayCoords);
}
return pointsInDisplay;

View File

@ -79,7 +79,7 @@ void RivReachCircleAnnotationPartMgr::buildParts(const caf::DisplayCoordTransfor
if(collection)
{
std::vector<Vec3d> pointsInDomain = computeCirclePointsInDomain(collection->snapAnnotations(), collection->annotationPlaneZ());
std::vector<Vec3d> points = transformCirclePointsToDisplay(pointsInDomain, displayXf);
std::vector<cvf::Vec3d> points = displayXf->transformToDisplayCoords(pointsInDomain);
cvf::ref<cvf::DrawableGeo> drawableGeo = RivPolylineGenerator::createLineAlongPolylineDrawable(points);
@ -207,17 +207,6 @@ std::vector<cvf::Vec3d> RivReachCircleAnnotationPartMgr::computeCirclePointsInDo
return points;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::vector<RivReachCircleAnnotationPartMgr::Vec3d>
RivReachCircleAnnotationPartMgr::transformCirclePointsToDisplay(const std::vector<Vec3d>& pointsInDomain,
const caf::DisplayCoordTransform* displayXf)
{
std::vector<Vec3d> pointsInDisplay;
for (const auto& pt : pointsInDomain) pointsInDisplay.push_back(displayXf->transformToDisplayCoord(pt));
return pointsInDisplay;
}
//--------------------------------------------------------------------------------------------------
///

View File

@ -65,8 +65,6 @@ private:
bool isCircleInBoundingBox(const cvf::BoundingBox& boundingBox);
std::vector<Vec3d> computeCirclePointsInDomain(bool snapToPlaneZ, double planeZ);
std::vector<Vec3d> transformCirclePointsToDisplay(const std::vector<Vec3d>& pointsInDomain,
const caf::DisplayCoordTransform* displayXf);
RimAnnotationInViewCollection* annotationCollection() const;

View File

@ -950,14 +950,8 @@ void RivWellFracturePartMgr::appendFracturePerforationLengthParts(const RimEclip
}
}
std::vector<cvf::Vec3d> displayCoords;
{
std::vector<cvf::Vec3d> perforationLengthCoord = m_rimFracture->perforationLengthCenterLineCoords();
for (const cvf::Vec3d& point : perforationLengthCoord)
{
displayCoords.push_back(displayCoordTransform->transformToDisplayCoord(point));
}
}
std::vector<cvf::Vec3d> displayCoords =
displayCoordTransform->transformToDisplayCoords(m_rimFracture->perforationLengthCenterLineCoords());
if (!displayCoords.empty())
{

View File

@ -255,11 +255,7 @@ void RivWellPathPartMgr::appendImportedFishbonesToModel(cvf::ModelBasicList* mod
{
if (!fbWellPath->isChecked()) continue;
std::vector<cvf::Vec3d> displayCoords;
for (const auto& lateralDomainCoords : fbWellPath->coordinates())
{
displayCoords.push_back(displayCoordTransform->transformToDisplayCoord(lateralDomainCoords));
}
std::vector<cvf::Vec3d> displayCoords = displayCoordTransform->transformToDisplayCoords(fbWellPath->coordinates());
cvf::ref<RivObjectSourceInfo> objectSourceInfo = new RivObjectSourceInfo(fbWellPath);

View File

@ -45,10 +45,25 @@ cvf::Vec3d caf::DisplayCoordTransform::transformToDisplayCoord(const cvf::Vec3d&
coord.x() *= m_scale.x();
coord.y() *= m_scale.y();
coord.z() *= m_scale.z();
return coord;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::vector<cvf::Vec3d> caf::DisplayCoordTransform::transformToDisplayCoords(const std::vector<cvf::Vec3d>& domainCoords) const
{
std::vector<cvf::Vec3d> displayCoords;
for (const auto& coord : domainCoords)
{
displayCoords.emplace_back(transformToDisplayCoord(coord));
}
return displayCoords;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------

View File

@ -5,8 +5,10 @@
#include "cvfObject.h"
#include "cvfVector3.h"
namespace caf {
#include <vector>
namespace caf
{
//==================================================================================================
//
//
@ -19,7 +21,9 @@ public:
void setScale(const cvf::Vec3d& scale);
void setTranslation(const cvf::Vec3d& translation);
cvf::Vec3d transformToDisplayCoord(const cvf::Vec3d& domainCoord) const;
cvf::Vec3d transformToDisplayCoord(const cvf::Vec3d& domainCoord) const;
std::vector<cvf::Vec3d> transformToDisplayCoords(const std::vector<cvf::Vec3d>& domainCoords) const;
cvf::Vec3d translateToDisplayCoord(const cvf::Vec3d& domainCoord) const;
cvf::Vec3d scaleToDisplaySize(const cvf::Vec3d& domainSize) const;
@ -33,4 +37,4 @@ private:
cvf::Vec3d m_translation;
};
}
} // namespace caf