ofPolyline.inl in 0.10.0 - compile?

Hi everyone, I’m currently trying to shift some projects I’m working on to 0.10.0. The Github repo has a “.ini” file in place of a “.cpp” for the ofPolyline.h class, which defines methods like; vector & getVertices(); as std::vector< T > & getVertices(); and breaks my implementation. My guess is that the .ini file is something precompiled and the < T > class defines a template. How do I compile the .ini into a .cpp?

Ah - need to use stable branch :wink:

Also, it’s probably not .ini but .inl, as in “inline”: https://stackoverflow.com/questions/1208028/significance-of-a-inl-file-in-c#1208062 :slight_smile:

No luck with the stable branch - seems to have different config projects for Android - is it 0.9.8?

Have you tried following this tutorial?

1 Like

I’ve got OF 0.9.8 running on Eclipse and OF 0.10.0 running on Android Studio. Problem is; Eclipse 0.9.8 is buggy and soon to be outdated methodology. Studio with 0.10.0 uses the ofPolyline.inl which breaks of vector points = polyline.getVertices(); alongside many other ofPolyline methods.

Short of rewriting my project and any addons using ofPolyline to use ofPath instead, it would be good to work out why the .inl exists and how it should be used. :\

Hi, I’ve been using ofPolyline from master for over a year and it’s working fine for me. There’s nothing needed to use that .inl file. As the StackOverflow post I shared above mentions, the extension of the file should be irrelevant.

If you share some code that is failing for you maybe we can help?

This is how I use .getVertices():

auto & points = line.getVertices();
// then I could take the last or first point:
auto S = points[line.size() - 1];
auto E = points[0];

// or you could iterate over the vertices:
for(auto & p : line.getVertices()) {
  ofDrawCircle(p.x, p.y, 10);
}

Maybe .getVertices() used to return a pointer and now it’s a reference to a vector?

vector<ofPoint> verts = polyline.getVertices();

Don’t have an error to hand, but it was mismatch with gl vec3 precise float definition across multiple project files. Will investigate…

Does setting OF_USE_LEGACY_VECTOR_MATH to 1 in https://github.com/openframeworks/openFrameworks/blob/master/libs/openFrameworks/utils/ofConstants.h#L11 help?

OF 0.10 switches it’s vectors internally to GLM. Some hints here http://openframeworks.cc/learning/02_graphics/how_to_use_glm/

@arturo is OF_USE_LEGACY_MESH now called OF_USE_LEGACY_VECTOR_MATH ? If so, the post linked above about GLM should be updated.

Hmm, setting the flag creates more glm errors than less;

This is the original error with flag set to 0 (in bakercp’s ofxClipper addon);

Using Studio 3.0.1, NDK r15c, Gradle 3.3 btw

With my limited knowledge I can only suggest to use glm::vec3 instead of ofPoint. That’s what I do in my project, but I guess how feasible that is depends on the complexity of your project.

ofPoint / ofVec3f has methods like distance(), normalize(), interpolate(), etc. I replaced these with the glm equivalents glm::distance(), glm::normalize(), glm::mix().

If I have some time I’ll add the missing methods to http://openframeworks.cc/learning/02_graphics/how_to_use_glm/

Can someone else hop in and say how to make it work with ofPoint?

Thanks for your help! This did the job for now;

//	vector<ofPoint> verts = polyline.getVertices();
//    vector<ofPoint>::iterator iter;
//    ClipperLib::Path polygon;
//    for(iter = verts.begin(); iter != verts.end(); iter++) {
//        ClipperLib::IntPoint ip((*iter).x * clipperGlobalScale,
//                                (*iter).y * clipperGlobalScale);
//        polygon.push_back(ip);
//    }

// Tempfix for OF_0.10.0

ClipperLib::Path polygon;
for(auto p : polyline.getVertices()) {
    ClipperLib::IntPoint ip(p.x * clipperGlobalScale,
                            p.y * clipperGlobalScale);
    polygon.push_back(ip);
}
return polygon;

Look forward to showing you what I’ve been up to when I’m back in BLN :wink:

1 Like