本文整理汇总了C++中PolyLine::end方法的典型用法代码示例。如果您正苦于以下问题:C++ PolyLine::end方法的具体用法?C++ PolyLine::end怎么用?C++ PolyLine::end使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PolyLine
的用法示例。
在下文中一共展示了PolyLine::end方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: draw
void draw()
{
glPushMatrix();
gl::translate(pos);
gl::color(TILECOLOR);
gl::draw(*hex);
gl::color(TILECOLOR2);
glBegin(GL_TRIANGLE_FAN);
PolyLine<Vec2f>::iterator pt;
for(pt = hex->begin(); pt < hex->end(); pt++)
{
gl::vertex(*pt);
}
glEnd();
/*
gl::color(Color(1.0f, .0f, .0f));
for(pt = hex->begin(); pt < hex->end() - 1; pt++)
{
gl::vertex(*pt);
}
*/
for(int i = 0; i < 6; i++)
{
if(connections[i])
{
Vec2f v = (connections[i]->pos - pos)/2.0f;
gl::color(Color(.0f, 1.0f, .0f));
gl::drawLine(Vec2f(.0f, .0f), v);
}
if(state[i])
{
Vec2f p = cart(TILERAD_MIN - 2.0f, -M_PI/2 - i * M_PI/3.0f);
gl::color(Color(1.0f, .0f, .0f));
// gl::drawSolidCircle(p, 5.0f, 32);
Vec2f pnorm = p.normalized();
pnorm.rotate(-M_PI/2.0f);
Vec2f p0 = p - 22.0f * pnorm;
Vec2f p1 = p + 22.0f * pnorm;
gl::drawLine(p0, p1);
}
}
glPopMatrix();
}
示例2:
void mitk::PlanarFigureVtkMapper3D::GenerateDataForRenderer(BaseRenderer* renderer)
{
typedef PlanarFigure::PolyLineType PolyLine;
DataNode* node = this->GetDataNode();
if (node == NULL)
return;
PlanarFigure* planarFigure = dynamic_cast<PlanarFigure*>(node->GetData());
if (planarFigure == NULL || !planarFigure->IsPlaced())
return;
LocalStorage* localStorage = m_LocalStorageHandler.GetLocalStorage(renderer);
unsigned long mTime = planarFigure->GetMTime();
if (mTime > localStorage->m_LastMTime)
{
localStorage->m_LastMTime = mTime;
const PlaneGeometry* planeGeometry = dynamic_cast<const PlaneGeometry*>(planarFigure->GetPlaneGeometry());
const AbstractTransformGeometry* abstractTransformGeometry = dynamic_cast<const AbstractTransformGeometry*>(planarFigure->GetPlaneGeometry());
if (planeGeometry == NULL && abstractTransformGeometry == NULL)
return;
size_t numPolyLines = planarFigure->GetPolyLinesSize();
if (numPolyLines == 0)
return;
vtkSmartPointer<vtkPoints> points = vtkSmartPointer<vtkPoints>::New();
vtkSmartPointer<vtkCellArray> cells = vtkSmartPointer<vtkCellArray>::New();
vtkIdType baseIndex = 0;
for (size_t i = 0; i < numPolyLines; ++i)
{
PolyLine polyLine = planarFigure->GetPolyLine(i);
vtkIdType numPoints = polyLine.size();
if (numPoints < 2)
continue;
PolyLine::const_iterator polyLineEnd = polyLine.end();
for (PolyLine::const_iterator polyLineIt = polyLine.begin(); polyLineIt != polyLineEnd; ++polyLineIt)
{
Point3D point;
planeGeometry->Map(*polyLineIt, point);
points->InsertNextPoint(point.GetDataPointer());
}
vtkSmartPointer<vtkPolyLine> line = vtkSmartPointer<vtkPolyLine>::New();
vtkIdList* pointIds = line->GetPointIds();
if (planarFigure->IsClosed() && numPoints > 2)
{
pointIds->SetNumberOfIds(numPoints + 1);
pointIds->SetId(numPoints, baseIndex);
}
else
{
pointIds->SetNumberOfIds(numPoints);
}
for (vtkIdType j = 0; j < numPoints; ++j)
pointIds->SetId(j, baseIndex + j);
cells->InsertNextCell(line);
baseIndex += points->GetNumberOfPoints();
}
vtkSmartPointer<vtkPolyData> polyData = vtkSmartPointer<vtkPolyData>::New();
polyData->SetPoints(points);
polyData->SetLines(cells);
vtkSmartPointer<vtkPolyDataMapper> mapper = vtkSmartPointer<vtkPolyDataMapper>::New();
mapper->SetInputData(polyData);
localStorage->m_Actor->SetMapper(mapper);
}
this->ApplyColorAndOpacityProperties(renderer, localStorage->m_Actor);
this->ApplyPlanarFigureProperties(renderer, localStorage->m_Actor);
}
示例3: mitkThrow
void mitk::ExtrudePlanarFigureFilter::GenerateData()
{
typedef PlanarFigure::PolyLineType PolyLine;
typedef PolyLine::const_iterator PolyLineConstIter;
if (m_Length <= 0)
mitkThrow() << "Length is not positive!";
if (m_NumberOfSegments == 0)
mitkThrow() << "Number of segments is zero!";
if (m_BendAngle != 0 && m_BendDirection[0] == 0 && m_BendDirection[1] == 0)
mitkThrow() << "Bend direction is zero-length vector!";
PlanarFigure* input = dynamic_cast<PlanarFigure*>(this->GetPrimaryInput());
if (input == NULL)
mitkThrow() << "Primary input is not a planar figure!";
size_t numPolyLines = input->GetPolyLinesSize();
if (numPolyLines == 0)
mitkThrow() << "Primary input does not contain any poly lines!";
const PlaneGeometry* planeGeometry = dynamic_cast<const PlaneGeometry*>(input->GetPlaneGeometry());
if (planeGeometry == NULL)
mitkThrow() << "Could not get plane geometry from primary input!";
Vector3D planeNormal = planeGeometry->GetNormal();
planeNormal.Normalize();
Point2D centerPoint2d = GetCenterPoint(input);
Point3D centerPoint3d;
planeGeometry->Map(centerPoint2d, centerPoint3d);
Vector3D bendDirection3d = m_BendAngle != 0
? ::GetBendDirection(planeGeometry, centerPoint2d, m_BendDirection)
: Vector3D();
ScalarType radius = m_Length * (360 / m_BendAngle) / (2 * vnl_math::pi);
Vector3D scaledBendDirection3d = bendDirection3d * radius;
Vector3D bendAxis = itk::CrossProduct(planeNormal, bendDirection3d);
bendAxis.Normalize();
vtkSmartPointer<vtkPoints> points = vtkSmartPointer<vtkPoints>::New();
vtkSmartPointer<vtkCellArray> cells = vtkSmartPointer<vtkCellArray>::New();
vtkIdType baseIndex = 0;
for (size_t i = 0; i < numPolyLines; ++i)
{
PolyLine polyLine = input->GetPolyLine(i);
size_t numPoints = polyLine.size();
if (numPoints < 2)
mitkThrow() << "Poly line " << i << " of primary input consists of less than two points!";
std::vector<mitk::Point3D> crossSection;
PolyLineConstIter polyLineEnd = polyLine.end();
for (PolyLineConstIter polyLineIter = polyLine.begin(); polyLineIter != polyLineEnd; ++polyLineIter)
{
Point3D point;
planeGeometry->Map(*polyLineIter, point);
crossSection.push_back(point);
}
ScalarType segmentLength = m_Length / m_NumberOfSegments;
Vector3D translation = planeNormal * segmentLength;
bool bend = std::abs(m_BendAngle) > mitk::eps;
bool twist = std::abs(m_TwistAngle) > mitk::eps;
ScalarType twistAngle = twist
? m_TwistAngle / m_NumberOfSegments * vnl_math::pi / 180
: 0;
ScalarType bendAngle = bend
? m_BendAngle / m_NumberOfSegments * vnl_math::pi / 180
: 0;
if (m_FlipDirection)
{
translation *= -1;
bendAngle *= -1;
}
for (size_t k = 0; k < numPoints; ++k)
points->InsertNextPoint(crossSection[k].GetDataPointer());
for (size_t j = 1; j <= m_NumberOfSegments; ++j)
{
mitk::AffineTransform3D::Pointer transform = mitk::AffineTransform3D::New();
if (bend || twist)
transform->Translate(centerPoint3d.GetVectorFromOrigin(), true);
//.........这里部分代码省略.........