本文整理汇总了C++中Contour类的典型用法代码示例。如果您正苦于以下问题:C++ Contour类的具体用法?C++ Contour怎么用?C++ Contour使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Contour类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: contour_to_segs_and_kinds
Py::Object TriContourGenerator::contour_to_segs_and_kinds(const Contour& contour)
{
Contour::const_iterator line;
ContourLine::const_iterator point;
// Find total number of points in all contour lines.
int n_points = 0;
for (line = contour.begin(); line != contour.end(); ++line)
n_points += line->size();
// Create segs array for point coordinates.
npy_intp segs_dims[2] = {n_points, 2};
PyArrayObject* segs = (PyArrayObject*)PyArray_SimpleNew(
2, segs_dims, PyArray_DOUBLE);
double* segs_ptr = (double*)PyArray_DATA(segs);
// Create kinds array for code types.
npy_intp kinds_dims[1] = {n_points};
PyArrayObject* kinds = (PyArrayObject*)PyArray_SimpleNew(
1, kinds_dims, PyArray_UBYTE);
unsigned char* kinds_ptr = (unsigned char*)PyArray_DATA(kinds);
for (line = contour.begin(); line != contour.end(); ++line) {
for (point = line->begin(); point != line->end(); point++) {
*segs_ptr++ = point->x;
*segs_ptr++ = point->y;
*kinds_ptr++ = (point == line->begin() ? MOVETO : LINETO);
}
}
Py::Tuple result(2);
result[0] = Py::asObject((PyObject*)segs);
result[1] = Py::asObject((PyObject*)kinds);
return result;
}
示例2: Slice
Slice* Mesh::getSlice()
{
Slice *s = new Slice();
Contour *c = new Contour();
while (!segments.empty())
{
segIt = segments.begin();
std::string lbl = static_cast<Point*>(segIt->second->getGeometry(0))->getLabel();
while (segments.count(lbl))
{
//if (lbl.compare("50.79235|15.27517|75.54418") == 0)
// std::cout << lbl << std::endl;
Rect *l = segments[lbl];
c->addGeometry(l);
segments.erase(segments.find(lbl));
Point *p2 = static_cast<Point*>(l->getGeometry(1));
lbl = p2->getLabel();
}
c->setInterface(new Graphics(static_cast<GraphicsImp*>(new OpenGLImp())));
s->addGeometry(c);
c = new Contour();
}
return s;
}
示例3: get_triangulation
void TriContourGenerator::find_boundary_lines(Contour& contour,
const double& level)
{
// Traverse boundaries to find starting points for all contour lines that
// intersect the boundaries. For each starting point found, follow the
// line to its end before continuing.
const Triangulation& triang = get_triangulation();
const Boundaries& boundaries = get_boundaries();
for (Boundaries::const_iterator it = boundaries.begin();
it != boundaries.end(); ++it) {
const Boundary& boundary = *it;
bool startAbove, endAbove = false;
for (Boundary::const_iterator itb = boundary.begin();
itb != boundary.end(); ++itb) {
if (itb == boundary.begin())
startAbove = get_z(triang.get_triangle_point(*itb)) >= level;
else
startAbove = endAbove;
endAbove = get_z(triang.get_triangle_point(itb->tri,
(itb->edge+1)%3)) >= level;
if (startAbove && !endAbove) {
// This boundary edge is the start point for a contour line,
// so follow the line.
contour.push_back(ContourLine());
ContourLine& contour_line = contour.back();
TriEdge tri_edge = *itb;
follow_interior(contour_line, tri_edge, true, level, false);
}
}
}
}
示例4: getValue
bool ContourNode::getValue (const String& strMemberName, String& strValue)
{
bool bValueSet = false;
Contour* pObject = dynamic_cast<Contour*>(m_pObject);
if (strMemberName == L"value")
{
ValueObject* pValueObj = dynamic_cast<ValueObject*>(m_pObject);
if (pValueObj)
{
if (!pValueObj->isNothing())
{
strValue = pValueObj->toString();
bValueSet = true;
}
}
}
else if (strMemberName == L"Elev")
{
if (pObject->hasValue_Elev())
{
strValue = (DoubleObjectImpl(pObject->getElev())).toString();
bValueSet = true;
}
}
return bValueSet;
}
示例5: OutArea
void FeaturesToLabelEngine::OutArea(StyleDef &styleDef, const std::vector<PolygonWithIds> &polygons, const TagMap &tags)
{
//Transfer area markers and labels to label engine
for(size_t j=0; j< styleDef.size(); j++)
{
StyleAndLayerDef &styleAndLayerDef = styleDef[j];
LayerDef &layerDef = styleAndLayerDef.first;
StyleAttributes &styleAttributes = styleAndLayerDef.second;
string textName = "";
TagMap::const_iterator attrIt = styleAttributes.find("text-name");
if(attrIt != styleAttributes.end()) {
textName = attrIt->second;
}
else
continue; //Don't draw if name not specified
//Get average position of outer ways
for(size_t i=0; i< polygons.size(); i++)
{
double px = 0.0, py = 0.0;
const ContourWithIds &outerWithIds = polygons[i].first;
for(size_t k=0;k<outerWithIds.size();k++)
{
px += outerWithIds[k].second.first;
py += outerWithIds[k].second.second;
}
px /= outerWithIds.size();
py /= outerWithIds.size();
Contour shape;
shape.push_back(Point(px, py));
poiLabels.push_back(PoiLabel(shape, textName, tags, styleAttributes));
}
}
}
示例6: serializeContour
void serializeContour(const Contour& contour,std::vector<int>& out) {
//for each point in the contour, put it in the blob
ContourConstIt cursor = contour.begin();
for(;cursor!=contour.end();cursor++) {
out.push_back(cursor->x);
out.push_back(cursor->y);
}
}
示例7: Contour
void ViewPort::DrawEditContour( double pixel_size, double offset_x, double offset_y )
{
HPEN pen, oldpen;
HBRUSH brush, oldbrush;
LOGBRUSH lbrush;
int oldmode, i, x, y, numpts;
Contour *c;
Point *p;
POINT *lpPoints;
if ( EditContour && viewDC )
if ( EditContour->points )
{
c = new Contour( *EditContour ); // copy the contour
c->Shift( -offset_x, -offset_y ); // shift into view
c->Scale( 1.0/pixel_size ); // scale to view's pixels
numpts = c->points->Number();
lpPoints = new POINT[ numpts ]; // create Window POINT array for drawing
i = 0;
p = c->points->first;
while ( p != NULL )
{
lpPoints[i].x = (int)floor(p->x);
lpPoints[i].y = height - (int)floor(p->y);
i++;
p = p->next;
}
// create pen for border of object
pen = CreatePen( PS_DOT, 1, c->border.ref() );
//pen = CreatePen( PS_SOLID, 1, c->border.ref() );
oldpen = (HPEN)SelectObject( viewDC, pen ); // set pen into device context
if ( (c->mode > 0) && c->closed )
{
brush = CreateSolidBrush( c->fill.ref() ); // interior will be filled
oldbrush = (HBRUSH)SelectObject( viewDC, brush );
SetROP2( viewDC, abs(c->mode) ); // using contour fill mode and color
Polygon( viewDC, lpPoints, numpts );
SelectObject( viewDC, oldbrush ); // clean up fill brush
DeleteObject(brush);
}
SelectObject( viewDC, (HBRUSH)GetStockObject(NULL_BRUSH) ); // without coloring interior
SetROP2( viewDC, R2_COPYPEN ); // draw contour border with pen
if ( c->closed ) Polygon( viewDC, lpPoints, numpts );
else Polyline( viewDC, lpPoints, numpts );
SelectObject( viewDC, oldpen ); // clean up pen
DeleteObject(pen);
delete[] lpPoints; // and dynamic memory
delete c;
}
}
示例8: mName
GUIButton::GUIButton(const Properties& properties) : mName(properties.mName), mPosition(properties.mPosition),
mWidth(static_cast<float>(properties.mWidth)),
mHeight(static_cast<float>(std::max(10u, properties.mHeight))),
mTextOffset(properties.mTextOffset) {
{ // create and setup the shapes and renderstring the represent the button
// create the contour that represents both button shapes
Contour contour;
contour.AddPoints({glm::vec2(0.0f, 0.0f), glm::vec2(mWidth, 0.0f), glm::vec2(mWidth, mHeight - 10.0f)});
contour.AddBezier({glm::vec2(mWidth, mHeight - 4.0f), glm::vec2(mWidth - 6.0f, mHeight - 4.0f)});
contour.AddPoint(glm::vec2(6.0f, mHeight - 4.0f));
contour.AddBezier({glm::vec2(0.0f, mHeight - 4.0f), glm::vec2(0.0f, mHeight - 10.0f)});
mButtonTop.AddContour(contour);
mButtonTop.SetOrigin(glm::vec2(0.0f, -2.0f)); // set the offset of the top button to be slightly higher than the base
mButtonTop.SetColour(properties.mButtonColourTop);
mButtonBottom.AddContour(contour);
mButtonBottom.SetOrigin(glm::vec2(0.0f, -4.0f));
mButtonBottom.SetColour(properties.mButtonColourBase);
mButtonText.SetFont(properties.mFont);
mButtonText.SetText(properties.mText);
mButtonText.SetSize(properties.mTextSize);
mButtonText.SetOrigin(glm::vec2(0.0f, -2.0f)); // set the offset of the button text to match the top button
mButtonText.SetColour(properties.mTextColour);
}
SetPosition(properties.mPosition); // store the position of the button
UpdateRenderState(1u); // update the button shapes and render string
if (auto mSharedInputManagerPtr = GUI::mInputManagerPtr.lock()) { // if the input manager pointer is valid...
// retrieve the current mouse cursor coordinates and update the button state depending on whether they
// are within the button's bounding box or not
auto mouseCoords = mSharedInputManagerPtr->GetMouseCoords(CoordinateSpace::Local);
if (mouseCoords.x > mPosition.x && mouseCoords.x < mPosition.x + mWidth &&
mouseCoords.y > mPosition.y && mouseCoords.y < mPosition.y + mHeight) {
mInArea = true;
UpdateRenderState(2u);
}
}
{ // serialise the clicked message now as it won't change and we can reuse it
std::stringstream strStream;
ClickedMessage msg(mName);
{
// create an output archive using cereal and our stringstream and serialise the message
cereal::BinaryOutputArchive archiveOutBinary(strStream);
archiveOutBinary(msg);
} // flush the archive on destruction
mMessage = strStream.str(); // store the serialised string
}
}
示例9: findBorderEdges
// container of connected component
void findBorderEdges( const fwVertexIndex &_vertexIndex , std::vector< std::vector< std::pair< int, int > > > &contours)
{
typedef std::pair< int, int > Edge;
typedef std::vector< Edge > Contour; // at Border
typedef std::vector< Contour> Contours;
std::map< Edge , int > edgesHistogram;
for ( fwVertexIndex::const_iterator iter=_vertexIndex.begin(); iter!= _vertexIndex.end(); ++iter )
{
assert (iter->size()>2 );
int i1= (*iter)[0];
int i2 = (*iter)[1];
int i3 = (*iter)[2];
edgesHistogram[std::make_pair(std::min(i1,i2),std::max(i1,i2) )]++;
edgesHistogram[std::make_pair(std::min(i1,i3),std::max(i1,i3) )]++;
edgesHistogram[std::make_pair(std::min(i3,i2),std::max(i3,i2) )]++;
}
for ( std::map< Edge , int >::const_iterator iter=edgesHistogram.begin(); iter!=edgesHistogram.end(); ++iter )
{
if (iter->second<2) // an orphan found
{
Contour contour;
contour.reserve(1000);
std::list< Edge > fifo;
Edge orphan = iter->first;
fifo.push_back(orphan);
while( !fifo.empty() )
{
Edge current = fifo.front();
contour.push_back( current );
fifo.pop_front();
edgesHistogram[current]=2; // to mark it processed;
// search neighboor at border and insert in fifo
for ( std::map< Edge , int >::const_iterator iterL=edgesHistogram.begin(); iterL!=edgesHistogram.end(); ++iterL )
{
Edge candidate= iterL->first;
if ( iterL->second < 2 ) // at border
{
if ( candidate.first == current.first || candidate.second == current.second || // neighboor
candidate.first == current.second || candidate.second == current.first
)
{
edgesHistogram[candidate]=2; // mark processed;
fifo.push_back( candidate );
}
}
}
}
// all neighboor processed
contours.push_back( contour );
}
}
}
示例10: cvClearMemStorage
void Process::findContours()
{
cvClearMemStorage(contourStorage);
contours.clear();
cvCvtColor(image, grayImage, CV_RGB2GRAY);
// if (param.contour.smooth) {
// cvSmooth(grayImage, grayImage, CV_BLUR, 3, 3);
// }
cvCanny(grayImage, hitImage, contourParam.threshold1, contourParam.threshold2, 3);
// находим контуры
cvFindContours(hitImage, contourStorage, &contoursSeq, sizeof(CvContour),
CV_RETR_LIST, CV_CHAIN_APPROX_SIMPLE, cvPoint(0,0));
for(CvSeq* seq = contoursSeq; seq != 0; seq = seq->h_next) {
Contour contour;
for( int i=0; i<seq->total; ++i ) {
CvPoint* cvP = (CvPoint*)cvGetSeqElem(seq, i);
ContourPt pt;
pt.x = cvP->x;
pt.y = cvP->y;
contour.push_back(pt);
//qDebug() << cvP->x << cvP->y;
}
contours.push_back(contour);
}
// пример работы с контуром
//for(CvSeq* seq = contours; seq != 0; seq = seq->h_next){
// нарисовать контур
// cvDrawContours(dstImage, seq, CV_RGB(255,216,0), CV_RGB(0,0,250), 0, 1, 8);
// Работаем с точками последовательности
//CvPoint* p = (CvPoint*)cvGetSeqElem ( seq, i );
//}
// рисуем обводку
// if (param.contour.isDrawHull) {
// CvMemStorage* hullStorage = cvCreateMemStorage(0);
// for(CvSeq* seq = contours; seq != 0; seq = seq->h_next){
// CvSeq *hulls = cvConvexHull2(seq, hullStorage, CV_CLOCKWISE, 1);
// //cvDrawContours(dstImage, hulls, CV_RGB(255, 0, 0), CV_RGB(100, 0, 0), 0, 2, 8);
// cvClearMemStorage(hullStorage);
// }
// cvReleaseMemStorage(&hullStorage);
// }
}
示例11: moveTo
Shape & Shape::lineTo(const glm::vec3 & p)
{
// Start if their is no current
if (!getCurrent())
moveTo(glm::vec3(0, 0, 0));
// Add Line
Contour * current = getCurrent();
if (current)
current->lineTo(glm::dvec3(p));
return *this;
}
示例12: deSerializeContour
void deSerializeContour(const std::vector<int>& in,Contour& out) {
out.clear();
//for each point in the contour, put it in the blob
std::vector<int>::const_iterator cursor = in.begin();
assert(in.size()%2==0);
for(;cursor!=in.end();) {
cv::Point pt(*(cursor++),*(cursor++));
int temp = pt.x;
pt.x = pt.y;
pt.y=temp;
out.push_back(pt);
}
}
示例13: build_path
void Triangulator::build_path(const Contour &contour, Path &path, int index_offset) {
// TODO: connect multiple contours
path.clear();
path.resize(contour.get_chunks().size());
for(int i = 0; i < (int)contour.get_chunks().size(); ++i) {
const Contour::Chunk &c = contour.get_chunks()[i];
Vertex &v = path[i];
v.index = i + index_offset;
v.p = c.p1;
v.next = &v + 1;
}
path.back().next = &path.front();
}
示例14: p
void
Hexagon::odbOutputLayerFeature(
OdbFeatureFile& file, QString polarity,
QPointF location, Xform *xform)
{
Contour surface;
QPointF p(0, 0.5 * m_length.inch());
surface.polygon().setPolyBegin(p);
for (int i = 0; i < 6; ++i) {
p = rotatePoint(p, 60);
surface.polygon().addSegment(p);
}
surface.odbOutputLayerFeature(file, polarity, location, xform);
}
示例15: c
Shape & Shape::moveTo(const glm::vec3 & p)
{
Contour c(p);
// Close Current Contour
Contour * current = getCurrent();
if (current)
current->close();
// Add new Contour
_contours.push_back(std::move(c));
return *this;
}