本文整理汇总了C++中ofPolyline::isClosed方法的典型用法代码示例。如果您正苦于以下问题:C++ ofPolyline::isClosed方法的具体用法?C++ ofPolyline::isClosed怎么用?C++ ofPolyline::isClosed使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ofPolyline
的用法示例。
在下文中一共展示了ofPolyline::isClosed方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: V
void ofxPolyline2Mesh::updateShape(const ofPolyline &polyline)
{
shape.clear();
norm.clear();
for (int i = 0; i < polyline.size(); i++)
{
shape.push_back(polyline[i]);
}
if (polyline.isClosed())
shape.push_back(polyline[0]);
const ofVec3f V(0, 0, -1);
for (int i = 0; i < shape.size() - 1; i++)
{
const ofVec3f& p1 = shape[i];
const ofVec3f& p2 = shape[i + 1];
const ofVec3f& n21 = (p2 - p1).normalized();
norm.push_back(n21.crossed(V));
}
{
const ofVec3f& p1 = shape[shape.size() - 1];
const ofVec3f& p2 = shape[0];
const ofVec3f& n21 = (p2 - p1).normalized();
norm.push_back(n21.crossed(V));
}
current_segments.resize(shape.size());
last_segments.resize(shape.size());
}
示例2: draw
void ofCairoRenderer::draw(ofPolyline & poly){
cairo_new_path(cr);
for(int i=0;i<(int)poly.size();i++){
cairo_line_to(cr,poly.getVertices()[i].x,poly.getVertices()[i].y);
}
if(poly.isClosed())
cairo_close_path(cr);
cairo_stroke( cr );
}
示例3: keyPressed
//--------------------------------------------------------------
void ofApp::keyPressed(int key){
switch(key) {
case 'R': bRotate ^= true; if(!bRotate) rotAngle = 0; break;
case 'r': poly.clear(); break;
case 'c': poly.curveTo(mouseX, mouseY); break;
case 'a': poly.arc(mouseX, mouseY, 50, 50, 0, 180); break;
case 'o': poly.setClosed(!poly.isClosed()); break;
case 'F': poly.simplify(10); break;
case 'M': poly = poly.getSmoothed(5); break;
case 'S': poly = poly.getResampledBySpacing(30); break;
case 'C': poly = poly.getResampledByCount(50); break;
case 'l': poly.setClosed(!poly.isClosed());
case 'i': poly.insertVertex(ofPoint(mouseX, mouseY, 0), nearestIndex); break;
}
}
示例4: draw
//----------------------------------------------------------
void ofGLRenderer::draw(ofPolyline & poly){
// use smoothness, if requested:
if (bSmoothHinted) startSmoothing();
glEnableClientState(GL_VERTEX_ARRAY);
glVertexPointer(3, GL_FLOAT, sizeof(ofVec3f), &poly.getVertices()[0].x);
glDrawArrays(poly.isClosed()?GL_LINE_LOOP:GL_LINE_STRIP, 0, poly.size());
// use smoothness, if requested:
if (bSmoothHinted) endSmoothing();
}
示例5: ofxPolylineSave
void ofxPolylineSave(ofPolyline & poly, string xmlPath) {
ofXml xml;
xml.addChild("poly");
xml.setAttribute("closed", ofToString(poly.isClosed()));
for(int i=0; i<poly.size(); i++) {
ofPoint & point = poly.getVertices()[i];
xml.addChild("point");
xml.setToChild(i);
xml.setAttribute("x", ofToString(point.x));
xml.setAttribute("y", ofToString(point.y));
xml.setToParent();
}
xml.save(xmlPath);
}
示例6: setup
void Rift::setup(ofPolyline initial)
{
if (!initial.isClosed())
{
do_open = true;
initial_line = initial;
points.clear();
points.addVertex(initial_line.getPointAtPercent(0.49));
points.addVertex(initial_line.getPointAtPercent(0.51));
points.close();
}
else
{
do_open = false;
points = initial;
}
meta.clear();
float current_time = ofGetElapsedTimef();
for (int i = 0; i < points.size(); i ++)
{
meta.push_back( (PointMeta) {false, current_time} );
}
resample();
}
示例7: draw
//--------------------------------------------------------------
void ofApp::draw(){
if(poly.size() < 2) return;
ofPushMatrix();
ofTranslate(ofGetWidth()/2, ofGetHeight()/2);
ofRotateY(rotAngle);
ofSetColor(255, 255, 255);
poly.draw();
ofSetColor(0, 255, 0);
ofSetRectMode(OF_RECTMODE_CENTER);
glPointSize(5);
glBegin(GL_POINTS);
for(int i=0; i<poly.size(); i++) {
ofPoint p = poly[i];
glVertex3f(p.x, p.y, p.z);
}
glEnd();
for(int i=0; i<poly.size(); i++) {
ofPoint p = poly[i];
ofSetColor(255, 0, 0);
ofLine(p, p + poly.getTangentAtIndex(i) * 20);
ofSetColor(0, 255, 0);
ofLine(p, p + poly.getNormalAtIndex(i) * 20);
ofSetColor(0, 128, 255);
ofLine(p, p + poly.getRotationAtIndex(i) * 20);
}
float totalLength = poly.getPerimeter();
float totalArea = poly.getArea();
ofPoint nearestPoint = poly.getClosestPoint(ofPoint(mouseX-ofGetWidth()/2, mouseY-ofGetHeight()/2), &nearestIndex);
ofPoint nearestDataPoint = poly[nearestIndex];
float lengthAtIndex = poly.getLengthAtIndex(nearestIndex);
ofPoint pointAtIndex = poly.getPointAtIndexInterpolated(nearestIndex);
ofPoint pointAtLength = poly.getPointAtLength(lengthAtIndex);
ofPoint pointAtPercent = poly.getPointAtPercent(lengthAtIndex / totalLength);
float indexAtLength = poly.getIndexAtLength(lengthAtIndex);
float sinTime = ofMap(sin(ofGetElapsedTimef() * 0.5), -1, 1, 0, 1);
float sinIndex = sinTime * (poly.isClosed() ? poly.size() : (poly.size()-1)); // sinTime mapped to indices direct
float sinIndexLength = poly.getIndexAtPercent(sinTime); // sinTime mapped to indices based on length
float lengthAtIndexSin = poly.getLengthAtIndexInterpolated(sinIndex);
ofPoint pointAtIndexSin = poly.getPointAtIndexInterpolated(sinIndex);
ofPoint pointAtPercentSin = poly.getPointAtPercent(sinTime);
float angleAtIndex = poly.getAngleAtIndex(nearestIndex);
float angleAtIndexSin = poly.getAngleAtIndexInterpolated(sinIndex);
ofVec3f rotAtIndex = poly.getRotationAtIndex(nearestIndex);
ofVec3f rotAtIndexSin = poly.getRotationAtIndexInterpolated(sinIndex);
float rotMagAtIndex = rotAtIndex.length();
float rotMagAtIndexSin = rotAtIndexSin.length();
ofVec3f normalAtIndex = poly.getNormalAtIndex(nearestIndex);
ofVec3f tangentAtIndexSin = poly.getTangentAtIndexInterpolated(sinIndex);
ofVec3f normalAtIndexSin = poly.getNormalAtIndexInterpolated(sinIndex);
ofVec3f rotationAtIndexSin = poly.getRotationAtIndexInterpolated(sinIndex);
ofNoFill();
ofSetLineWidth(2);
ofSetColor(255, 0, 0);
ofCircle(nearestPoint, 5);
ofSetColor(255, 255, 0);
ofCircle(nearestDataPoint, 7);
// interpolating on indices
{
ofPoint p = poly.getPointAtIndexInterpolated(sinIndex);
ofSetColor(0, 255, 255);
ofCircle(p, 10);
ofSetColor(255, 0, 0);
ofLine(p, p + poly.getTangentAtIndexInterpolated(sinIndex) * 60);
ofSetColor(0, 255, 0);
ofLine(p, p + poly.getNormalAtIndexInterpolated(sinIndex) * 60);
ofSetColor(0, 128, 255);
ofLine(p, p + poly.getRotationAtIndexInterpolated(sinIndex) * 60);
}
// interpolating on length percentages
{
ofPoint p = poly.getPointAtIndexInterpolated(sinIndexLength);
ofSetColor(255, 0, 255);
//.........这里部分代码省略.........
示例8: draw
void ofGLRenderer::draw(ofPolyline & poly){
glVertexPointer(poly.is3D()?3:2, GL_FLOAT, sizeof(ofVec3f), &poly.getVertices()[0].x);
glDrawArrays(poly.isClosed()?GL_LINE_LOOP:GL_LINE_STRIP, 0, poly.size());;
}