#3869 Annotations. Closing polyline support

This commit is contained in:
Bjørn Erik Jensen
2018-12-13 15:58:17 +01:00
parent a87c4efd93
commit 9c750c5287
8 changed files with 30 additions and 6 deletions

View File

@@ -79,7 +79,7 @@ void RivPolylineAnnotationPartMgr::buildPolylineAnnotationParts(const caf::Displ
auto linesInDomain = getPolylinesPointsInDomain(collection->snapAnnotations(), collection->annotationPlaneZ());
auto linesInDisplay = transformPolylinesPointsToDisplay(linesInDomain, displayXf);
cvf::ref<cvf::DrawableGeo> drawableGeo = RivPolylineGenerator::createLineAlongPolylineDrawable(linesInDisplay);
cvf::ref<cvf::DrawableGeo> drawableGeo = RivPolylineGenerator::createLineAlongPolylineDrawable(linesInDisplay, rimAnnotation->closePolyline());
cvf::ref<cvf::Part> part = new cvf::Part;
part->setName("RivPolylineAnnotationPartMgr");
part->setDrawable(drawableGeo.p());

View File

@@ -26,18 +26,18 @@
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
cvf::ref<cvf::DrawableGeo> RivPolylineGenerator::createLineAlongPolylineDrawable(const std::vector<cvf::Vec3d>& polyLine)
cvf::ref<cvf::DrawableGeo> RivPolylineGenerator::createLineAlongPolylineDrawable(const std::vector<cvf::Vec3d>& polyLine, bool closeLine)
{
std::vector<std::vector<cvf::Vec3d>> polyLines;
polyLines.push_back(polyLine);
return createLineAlongPolylineDrawable(polyLines);
return createLineAlongPolylineDrawable(polyLines, closeLine);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
cvf::ref<cvf::DrawableGeo>
RivPolylineGenerator::createLineAlongPolylineDrawable(const std::vector<std::vector<cvf::Vec3d>>& polyLines)
RivPolylineGenerator::createLineAlongPolylineDrawable(const std::vector<std::vector<cvf::Vec3d>>& polyLines, bool closeLine)
{
std::vector<cvf::uint> lineIndices;
std::vector<cvf::Vec3f> vertices;
@@ -57,6 +57,12 @@ cvf::ref<cvf::DrawableGeo>
lineIndices.push_back(static_cast<cvf::uint>(verticesCount + i + 1));
}
}
if (closeLine && vertices.front() != vertices.back())
{
lineIndices.push_back(static_cast<cvf::uint>(verticesCount + polyLine.size() - 1));
lineIndices.push_back(static_cast<cvf::uint>(verticesCount));
}
}
if (vertices.empty()) return nullptr;

View File

@@ -35,8 +35,8 @@ namespace cvf
class RivPolylineGenerator : public cvf::Object
{
public:
static cvf::ref<cvf::DrawableGeo> createLineAlongPolylineDrawable(const std::vector<cvf::Vec3d>& polyLine);
static cvf::ref<cvf::DrawableGeo> createLineAlongPolylineDrawable(const std::vector<std::vector<cvf::Vec3d>>& polyLines);
static cvf::ref<cvf::DrawableGeo> createLineAlongPolylineDrawable(const std::vector<cvf::Vec3d>& polyLine, bool closeLine = false);
static cvf::ref<cvf::DrawableGeo> createLineAlongPolylineDrawable(const std::vector<std::vector<cvf::Vec3d>>& polyLines, bool closeLine = false);
static cvf::ref<cvf::DrawableGeo> createPointsFromPolylineDrawable(const std::vector<cvf::Vec3d>& polyLine);
static cvf::ref<cvf::DrawableGeo> createPointsFromPolylineDrawable(const std::vector<std::vector<cvf::Vec3d>>& polyLines);