#2589 intersections. Show extrusion line fix

This commit is contained in:
Bjørn Erik Jensen 2018-03-12 15:14:22 +01:00
parent e13702a88a
commit 1e8f1bb95e
6 changed files with 58 additions and 22 deletions

View File

@ -23,11 +23,13 @@
#include "RigResultAccessor.h" #include "RigResultAccessor.h"
#include "RimIntersection.h" #include "RimIntersection.h"
#include "Rim3dView.h"
#include "RivHexGridIntersectionTools.h" #include "RivHexGridIntersectionTools.h"
#include "RivIntersectionPartMgr.h" #include "RivIntersectionPartMgr.h"
#include "cafHexGridIntersectionTools/cafHexGridIntersectionTools.h" #include "cafHexGridIntersectionTools/cafHexGridIntersectionTools.h"
#include "cafDisplayCoordTransform.h"
#include "cvfDrawableGeo.h" #include "cvfDrawableGeo.h"
#include "cvfGeometryTools.h" #include "cvfGeometryTools.h"
@ -40,6 +42,16 @@
#include "RivSectionFlattner.h" #include "RivSectionFlattner.h"
cvf::ref<caf::DisplayCoordTransform> displayCoordTransform(const RimIntersection* intersection)
{
Rim3dView* rimView = nullptr;
intersection->firstAncestorOrThisOfType(rimView);
CVF_ASSERT(rimView);
cvf::ref<caf::DisplayCoordTransform> transForm = rimView->displayCoordTransform();
return transForm;
}
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// isFlattened means to transform each flat section of the intersection onto the XZ plane /// isFlattened means to transform each flat section of the intersection onto the XZ plane
/// placed adjacent to each other as if they were rotated around the common extrusion line like a hinge /// placed adjacent to each other as if they were rotated around the common extrusion line like a hinge
@ -399,6 +411,22 @@ cvf::ref<cvf::DrawableGeo> RivIntersectionGeometryGenerator::createLineAlongPoly
return createLineAlongPolylineDrawable(m_flattenedOrOffsettedPolyLines); return createLineAlongPolylineDrawable(m_flattenedOrOffsettedPolyLines);
} }
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
cvf::ref<cvf::DrawableGeo> RivIntersectionGeometryGenerator::createLineAlongExtrusionLineDrawable(const std::vector<cvf::Vec3d>& extrusionLine)
{
cvf::ref<caf::DisplayCoordTransform> transform = displayCoordTransform(crossSection());
std::vector<cvf::Vec3d> displayCoords;
for (const auto& pt : extrusionLine)
{
displayCoords.push_back(transform->translateToDisplayCoord(pt));
}
return createLineAlongPolylineDrawable(std::vector<std::vector<cvf::Vec3d>>({ displayCoords }));
}
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
@ -407,8 +435,6 @@ cvf::ref<cvf::DrawableGeo> RivIntersectionGeometryGenerator::createLineAlongPoly
std::vector<cvf::uint> lineIndices; std::vector<cvf::uint> lineIndices;
std::vector<cvf::Vec3f> vertices; std::vector<cvf::Vec3f> vertices;
cvf::Vec3d displayOffset = m_hexGrid->displayOffset();
for (size_t pLineIdx = 0; pLineIdx < polyLines.size(); ++pLineIdx) for (size_t pLineIdx = 0; pLineIdx < polyLines.size(); ++pLineIdx)
{ {
const std::vector<cvf::Vec3d>& polyLine = polyLines[pLineIdx]; const std::vector<cvf::Vec3d>& polyLine = polyLines[pLineIdx];
@ -450,6 +476,21 @@ cvf::ref<cvf::DrawableGeo> RivIntersectionGeometryGenerator::createPointsFromPol
return createPointsFromPolylineDrawable(m_flattenedOrOffsettedPolyLines); return createPointsFromPolylineDrawable(m_flattenedOrOffsettedPolyLines);
} }
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
cvf::ref<cvf::DrawableGeo> RivIntersectionGeometryGenerator::createPointsFromExtrusionLineDrawable(const std::vector<cvf::Vec3d>& extrusionLine)
{
cvf::ref<caf::DisplayCoordTransform> transform = displayCoordTransform(crossSection());
std::vector<cvf::Vec3d> displayCoords;
for (const auto& pt : extrusionLine)
{
displayCoords.push_back(transform->translateToDisplayCoord(pt));
}
return createPointsFromPolylineDrawable(std::vector<std::vector<cvf::Vec3d>>({displayCoords}));
}
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
@ -458,8 +499,6 @@ cvf::ref<cvf::DrawableGeo> RivIntersectionGeometryGenerator::createPointsFromPol
{ {
std::vector<cvf::Vec3f> vertices; std::vector<cvf::Vec3f> vertices;
cvf::Vec3d displayOffset = m_hexGrid->displayOffset();
for (size_t pLineIdx = 0; pLineIdx < polyLines.size(); ++pLineIdx) for (size_t pLineIdx = 0; pLineIdx < polyLines.size(); ++pLineIdx)
{ {
const std::vector<cvf::Vec3d>& polyLine = polyLines[pLineIdx]; const std::vector<cvf::Vec3d>& polyLine = polyLines[pLineIdx];

View File

@ -61,10 +61,9 @@ public:
cvf::ref<cvf::DrawableGeo> generateSurface(); cvf::ref<cvf::DrawableGeo> generateSurface();
cvf::ref<cvf::DrawableGeo> createMeshDrawable(); cvf::ref<cvf::DrawableGeo> createMeshDrawable();
cvf::ref<cvf::DrawableGeo> createLineAlongPolylineDrawable(); cvf::ref<cvf::DrawableGeo> createLineAlongPolylineDrawable();
cvf::ref<cvf::DrawableGeo> createLineAlongExtrusionLineDrawable(const std::vector<cvf::Vec3d>& extrusionLine);
cvf::ref<cvf::DrawableGeo> createPointsFromPolylineDrawable(); cvf::ref<cvf::DrawableGeo> createPointsFromPolylineDrawable();
cvf::ref<cvf::DrawableGeo> createPointsFromExtrusionLineDrawable(const std::vector<cvf::Vec3d>& extrusionLine);
cvf::ref<cvf::DrawableGeo> createLineAlongPolylineDrawable(const std::vector<std::vector<cvf::Vec3d> >& polyLines);
cvf::ref<cvf::DrawableGeo> createPointsFromPolylineDrawable(const std::vector<std::vector<cvf::Vec3d> >& polyLines);
const std::vector<std::vector<cvf::Vec3d> >& flattenedOrOffsettedPolyLines() { return m_flattenedOrOffsettedPolyLines; } const std::vector<std::vector<cvf::Vec3d> >& flattenedOrOffsettedPolyLines() { return m_flattenedOrOffsettedPolyLines; }
@ -78,13 +77,16 @@ public:
cvf::Mat4d unflattenTransformMatrix(const cvf::Vec3d& intersectionPointFlat); cvf::Mat4d unflattenTransformMatrix(const cvf::Vec3d& intersectionPointFlat);
private: private:
cvf::ref<cvf::DrawableGeo> createLineAlongPolylineDrawable(const std::vector<std::vector<cvf::Vec3d> >& polyLines);
cvf::ref<cvf::DrawableGeo> createPointsFromPolylineDrawable(const std::vector<std::vector<cvf::Vec3d> >& polyLines);
void calculateArrays(); void calculateArrays();
void calculateSegementTransformPrLinePoint(); void calculateSegementTransformPrLinePoint();
void calculateFlattenedOrOffsetedPolyline(); void calculateFlattenedOrOffsetedPolyline();
static size_t indexToNextValidPoint(const std::vector<cvf::Vec3d>& polyLine, //static size_t indexToNextValidPoint(const std::vector<cvf::Vec3d>& polyLine,
const cvf::Vec3d extrDir, // const cvf::Vec3d extrDir,
size_t idxToStartOfLineSegment); // size_t idxToStartOfLineSegment);
RimIntersection* m_crossSection; RimIntersection* m_crossSection;
cvf::cref<RivIntersectionHexGridInterface> m_hexGrid; cvf::cref<RivIntersectionHexGridInterface> m_hexGrid;

View File

@ -647,7 +647,7 @@ void RivIntersectionPartMgr::createExtrusionDirParts(bool useBufferObjects)
if (m_rimCrossSection->direction() == RimIntersection::CS_TWO_POINTS) if (m_rimCrossSection->direction() == RimIntersection::CS_TWO_POINTS)
{ {
{ {
cvf::ref<cvf::DrawableGeo> polylineGeo = m_crossSectionGenerator->createLineAlongPolylineDrawable(m_rimCrossSection->polyLinesForExtrusionDirection()); cvf::ref<cvf::DrawableGeo> polylineGeo = m_crossSectionGenerator->createLineAlongExtrusionLineDrawable(m_rimCrossSection->polyLinesForExtrusionDirection());
if (polylineGeo.notNull()) if (polylineGeo.notNull())
{ {
if (useBufferObjects) if (useBufferObjects)
@ -679,7 +679,7 @@ void RivIntersectionPartMgr::createExtrusionDirParts(bool useBufferObjects)
} }
} }
cvf::ref<cvf::DrawableGeo> polylinePointsGeo = m_crossSectionGenerator->createPointsFromPolylineDrawable(m_rimCrossSection->polyLinesForExtrusionDirection()); cvf::ref<cvf::DrawableGeo> polylinePointsGeo = m_crossSectionGenerator->createPointsFromExtrusionLineDrawable(m_rimCrossSection->polyLinesForExtrusionDirection());
if (polylinePointsGeo.notNull()) if (polylinePointsGeo.notNull())
{ {
if (useBufferObjects) if (useBufferObjects)

View File

@ -477,13 +477,9 @@ RivIntersectionPartMgr* RimIntersection::intersectionPartMgr()
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
std::vector< std::vector <cvf::Vec3d> > RimIntersection::polyLinesForExtrusionDirection() const std::vector <cvf::Vec3d> RimIntersection::polyLinesForExtrusionDirection() const
{ {
std::vector< std::vector <cvf::Vec3d> > lines; return m_customExtrusionPoints;
lines.push_back(m_customExtrusionPoints);
return lines;
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------

View File

@ -90,7 +90,7 @@ public:
Rim2dIntersectionView* correspondingIntersectionView(); Rim2dIntersectionView* correspondingIntersectionView();
RivIntersectionPartMgr* intersectionPartMgr(); RivIntersectionPartMgr* intersectionPartMgr();
std::vector< std::vector <cvf::Vec3d> > polyLinesForExtrusionDirection() const; std::vector <cvf::Vec3d> polyLinesForExtrusionDirection() const;
void appendPointToExtrusionDirection(const cvf::Vec3d& point); void appendPointToExtrusionDirection(const cvf::Vec3d& point);
void appendPointToAzimuthLine(const cvf::Vec3d& point); void appendPointToAzimuthLine(const cvf::Vec3d& point);

View File

@ -20,15 +20,14 @@ public:
void setTranslation(const cvf::Vec3d& translation); void setTranslation(const cvf::Vec3d& translation);
cvf::Vec3d transformToDisplayCoord(const cvf::Vec3d& domainCoord) const; cvf::Vec3d transformToDisplayCoord(const cvf::Vec3d& domainCoord) const;
cvf::Vec3d translateToDisplayCoord(const cvf::Vec3d& domainCoord) const;
cvf::Vec3d scaleToDisplaySize(const cvf::Vec3d& domainSize) const; cvf::Vec3d scaleToDisplaySize(const cvf::Vec3d& domainSize) const;
cvf::Vec3d translateToDomainCoord(const cvf::Vec3d& displayCoord) const; cvf::Vec3d translateToDomainCoord(const cvf::Vec3d& displayCoord) const;
cvf::Vec3d transformToDomainCoord(const cvf::Vec3d& displayCoord) const; cvf::Vec3d transformToDomainCoord(const cvf::Vec3d& displayCoord) const;
cvf::Vec3d scaleToDomainSize(const cvf::Vec3d& displaySize) const; cvf::Vec3d scaleToDomainSize(const cvf::Vec3d& displaySize) const;
private:
cvf::Vec3d translateToDisplayCoord(const cvf::Vec3d& domainCoord) const;
private: private:
cvf::Vec3d m_scale; cvf::Vec3d m_scale;
cvf::Vec3d m_translation; cvf::Vec3d m_translation;