Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fs::path <> string interoperability #7817

Open
wants to merge 54 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
361d467
test
dimitre Dec 12, 2023
68496cc
test FS direct to c_str
dimitre Dec 12, 2023
ecd5d69
updates
dimitre Dec 12, 2023
fd6a7e1
more
dimitre Dec 12, 2023
27da3c5
Merge branch 'openframeworks:master' into fscxx
dimitre Jan 5, 2024
af1438d
test removing convertNarrowToWide from fs::path
dimitre Jan 5, 2024
1cc6400
fix haar
dimitre Jan 5, 2024
3a8c985
fix cascade.load
dimitre Jan 5, 2024
4f1e287
ofxXmlSettings load save to fs::path
dimitre Jan 6, 2024
31bed4a
change tests
dimitre Jan 6, 2024
618ef50
one more fix and more fs changes
dimitre Jan 6, 2024
6ff0044
more fs
dimitre Jan 6, 2024
78ac547
more fs fix
dimitre Jan 6, 2024
3097e09
revert getBaseName to string
dimitre Jan 6, 2024
f6127b8
fix one more
dimitre Jan 6, 2024
21116c6
fix one more
dimitre Jan 6, 2024
9e3fcce
more
dimitre Jan 6, 2024
ab93ad0
some ofShader fixes
dimitre Jan 6, 2024
1da4c33
ofMediaFoundationPlayer
dimitre Jan 6, 2024
394e516
ofMediaFoundationPlayer
dimitre Jan 6, 2024
b42264d
BSTR fix
dimitre Jan 6, 2024
31ffdc5
fix assimpmodelloader
dimitre Jan 6, 2024
6bc077d
assimp
dimitre Jan 6, 2024
da6a5a3
Merge branch 'openframeworks:master' into fscxx
dimitre Feb 6, 2024
a2da9fc
Merge branch 'openframeworks:master' into fscxx
dimitre May 9, 2024
49726bd
now real debug begins
dimitre May 9, 2024
87a4b55
more updates testing implicit c_str
dimitre May 9, 2024
e135051
fix FS
dimitre May 9, 2024
acba730
up
dimitre May 10, 2024
ce53d43
test
dimitre May 10, 2024
24f72ef
tests
dimitre May 10, 2024
b01f3e8
xml
dimitre May 10, 2024
e4277ee
test
dimitre May 10, 2024
4707efd
up
dimitre May 10, 2024
75d016e
up
dimitre May 10, 2024
03b0858
up
dimitre May 10, 2024
0134910
correction
dimitre May 10, 2024
0ab220f
fix
dimitre May 10, 2024
5af74c9
best
dimitre May 10, 2024
a8593e8
ok
dimitre May 10, 2024
c1edc49
update
dimitre May 10, 2024
87f6529
assimpmodelloader improvements
dimitre May 10, 2024
b553d56
update
dimitre May 10, 2024
61e6fd7
more
dimitre May 10, 2024
4ea04d9
xml load save
dimitre May 10, 2024
1715f27
Merge branch 'openframeworks:master' into fscxx
dimitre May 10, 2024
f7be936
up
dimitre May 11, 2024
0f07b51
Merge branch 'openframeworks:master' into fscxx
dimitre May 11, 2024
97a7b5b
Merge branch 'openframeworks:master' into fscxx
dimitre May 13, 2024
0bfcbc1
remove tests
dimitre May 13, 2024
b9868fa
cleanup
dimitre May 13, 2024
25eed62
Merge branch 'master' into fscxx
dimitre May 16, 2024
4484641
Merge branch 'openframeworks:master' into fscxx
dimitre May 17, 2024
9f9b2e1
Merge branch 'openframeworks:master' into fscxx
dimitre May 18, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 20 additions & 21 deletions addons/ofxAssimpModelLoader/src/ofxAssimpModelLoader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@ ofxAssimpModelLoader::~ofxAssimpModelLoader(){


// DEPRECATED
bool ofxAssimpModelLoader::load(string modelName, bool optimize){
bool ofxAssimpModelLoader::load(const of::filesystem::path & fileName, bool optimize){
int optimizeFlags = OPTIMIZE_DEFAULT;
if( optimize ){
optimizeFlags = OPTIMIZE_HIGH;
}
return load(modelName, optimizeFlags);
return load(fileName, optimizeFlags);
}

// DEPRECATED
Expand All @@ -44,8 +44,8 @@ bool ofxAssimpModelLoader::load(ofBuffer & buffer, bool optimize, const char * e
}

// DEPRECATED
bool ofxAssimpModelLoader::loadModel(string modelName, bool optimize){
return load(modelName, optimize);
bool ofxAssimpModelLoader::loadModel(const of::filesystem::path & fileName, bool optimize){
return load(fileName, optimize);
}

// DEPRECATED
Expand All @@ -54,16 +54,14 @@ bool ofxAssimpModelLoader::loadModel(ofBuffer & buffer, bool optimize, const cha
}

//------------------------------------------
bool ofxAssimpModelLoader::load(string modelName, int assimpOptimizeFlags){

file.open(modelName, ofFile::ReadOnly, true); // Since it may be a binary file we should read it in binary -Ed
if(!file.exists()) {
ofLogVerbose("ofxAssimpModelLoader") << "load(): model does not exist: \"" << modelName << "\"";
bool ofxAssimpModelLoader::load(const of::filesystem::path & fileName, int assimpOptimizeFlags){
file = ofToDataPath(fileName);
if (!of::filesystem::exists(file)) {
ofLogVerbose("ofxAssimpModelLoader") << "load(): model does not exist: " << fileName ;
return false;
}

ofLogVerbose("ofxAssimpModelLoader") << "load(): loading \"" << file.getFileName()
<< "\" from \"" << file.getEnclosingDirectory() << "\"";

ofLogVerbose("ofxAssimpModelLoader") << "load(): loading " << fileName;

if(scene.get() != nullptr){
clear();
Expand All @@ -82,8 +80,7 @@ bool ofxAssimpModelLoader::load(string modelName, int assimpOptimizeFlags){
// }

// loads scene from file
std::string path = file.getAbsolutePath();
const aiScene * scenePtr = importer.ReadFile(path.c_str(), flags);
const aiScene * scenePtr = importer.ReadFile(ofPathToString(file), flags);

//this is funky but the scenePtr is managed by assimp and so we can't put it in our shared_ptr without disabling the deleter with: [](const aiScene*){}
scene = shared_ptr<const aiScene>(scenePtr,[](const aiScene*){});
Expand Down Expand Up @@ -374,6 +371,7 @@ void ofxAssimpModelLoader::loadGLResources(){
bool bWrap = (texMapMode[0]==aiTextureMapMode_Wrap);

std::string texPathStr = texPath.C_Str();


//deal with Blender putting "//" in front of local file paths
if( texPathStr.size() > 2 && texPathStr.substr(0, 2) == "//" ){
Expand All @@ -390,7 +388,8 @@ void ofxAssimpModelLoader::loadGLResources(){
auto ogPath = texPathStr;
bool bHasEmbeddedTexture = false;

auto modelFolder = ofFilePath::getEnclosingDirectory( file.path() );
auto modelFolder { file.parent_path() };
// auto modelFolder = ofFilePath::getEnclosingDirectory( file.path() );
auto relTexPath = ofFilePath::getEnclosingDirectory(texPathStr,false);
auto realPath = modelFolder / of::filesystem::path{ texPathStr };

Expand All @@ -402,8 +401,8 @@ void ofxAssimpModelLoader::loadGLResources(){
bHasEmbeddedTexture = true;
ofLogVerbose("ofxAssimpModelLoader") << "loadGLResource() texture " << realPath.filename() << " is embedded ";
}else{
ofLogError("ofxAssimpModelLoader") << "loadGLResource(): texture doesn't exist: \""
<< file.getFileName() + "\" in \"" << realPath.string() << "\"";
ofLogError("ofxAssimpModelLoader") << "loadGLResource(): texture doesn't exist: "
<< file << " in \"" << realPath.string() << "\"";
}
}
#endif
Expand All @@ -420,8 +419,8 @@ void ofxAssimpModelLoader::loadGLResources(){
assimpTexture.setTextureType((aiTextureType)d);
meshHelper.addTexture(assimpTexture);

ofLogVerbose("ofxAssimpModelLoader") << "loadGLResource(): texture already loaded: \""
<< file.getFileName() + "\" from \"" << realPath.string() << "\"" << " adding texture as " << assimpTexture.getTextureTypeAsString() ;
ofLogVerbose("ofxAssimpModelLoader") << "loadGLResource(): texture already loaded: "
<< file << " from \"" << realPath.string() << "\"" << " adding texture as " << assimpTexture.getTextureTypeAsString() ;
} else {

shared_ptr<ofTexture> texture = std::make_shared<ofTexture>();
Expand Down Expand Up @@ -464,8 +463,8 @@ void ofxAssimpModelLoader::loadGLResources(){

ofLogVerbose("ofxAssimpModelLoader") << "loadGLResource(): texture " << tmpTex.getTextureTypeAsString() << " loaded, dimensions: " << texture->getWidth() << "x" << texture->getHeight();
}else{
ofLogError("ofxAssimpModelLoader") << "loadGLResource(): couldn't load texture: \""
<< file.getFileName() + "\" from \"" << realPath.string() << "\"";
ofLogError("ofxAssimpModelLoader") << "loadGLResource(): couldn't load texture: "
<< file << " from \"" << realPath.string() << "\"";
}
}
}
Expand Down
13 changes: 7 additions & 6 deletions addons/ofxAssimpModelLoader/src/ofxAssimpModelLoader.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,16 +44,16 @@ class ofxAssimpModelLoader{

//use the default OF selected flags ( from the options above ) or pass in the exact assimp flags you want
//note: you will probably want to |= aiProcess_ConvertToLeftHanded to anything you pass in
bool load(std::string modelName, int assimpOptimizeFlags=OPTIMIZE_DEFAULT);
bool load(const of::filesystem::path & fileName, int assimpOptimizeFlags=OPTIMIZE_DEFAULT);
bool load(ofBuffer & buffer, int assimpOptimizeFlags=OPTIMIZE_DEFAULT, const char * extension="");

[[deprecated("use load(std::string modelName, int assimpOptimizeFlags)")]]
bool load(std::string modelName, bool optimize);
[[deprecated("use load(std::string modelName, int assimpOptimizeFlags)")]]
[[deprecated("use load(const of::filesystem::path & fileName, int assimpOptimizeFlags)")]]
bool load(const of::filesystem::path & fileName, bool optimize);
[[deprecated("use load(const of::filesystem::path & fileName, int assimpOptimizeFlags)")]]
bool load(ofBuffer & buffer, bool optimize, const char * extension);

[[deprecated("use load()")]]
bool loadModel(std::string modelName, bool optimize=false);
bool loadModel(const of::filesystem::path & fileName, bool optimize=false);
[[deprecated("use load()")]]
bool loadModel(ofBuffer & buffer, bool optimize=false, const char * extension="");

Expand Down Expand Up @@ -175,7 +175,8 @@ class ofxAssimpModelLoader{
void getBoundingBoxWithMinVector( aiVector3D* min, aiVector3D* max);
void getBoundingBoxForNode(const ofxAssimpMeshHelper & mesh, aiVector3D* min, aiVector3D* max);

ofFile file;
of::filesystem::path file;
// ofFile file;

aiVector3D scene_min, scene_max, scene_center;

Expand Down
14 changes: 5 additions & 9 deletions addons/ofxOpenCv/src/ofxCvHaarFinder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,8 @@ void ofxCvHaarFinder::setNeighbors(unsigned neighbors) {
this->neighbors = neighbors;
}

// FIXME: convert to of::filesystem::path
void ofxCvHaarFinder::setup(std::string haarFile) {

this->haarFile = haarFile;

haarFile = ofToDataPath(haarFile);
void ofxCvHaarFinder::setup(const of::filesystem::path & fileName) {
haarFile = ofToDataPath(fileName);
#ifdef USE_OLD_CV
if(cascade != NULL)
cvReleaseHaarClassifierCascade(&cascade);
Expand All @@ -72,11 +68,11 @@ void ofxCvHaarFinder::setup(std::string haarFile) {
#endif

if (!cascade)
ofLogError("ofxCvHaarFinder") << "setup(): couldn't load Haar cascade file: \"" << haarFile << "\"";
ofLogError("ofxCvHaarFinder") << "setup(): couldn't load Haar cascade file: " << haarFile;
#else
cascade.load( haarFile );
cascade.load( ofPathToString(haarFile) );
if( cascade.empty() )
ofLogError("ofxCvHaarFinder") << "setup(): couldn't load Haar cascade file: \"" << haarFile << "\"";
ofLogError("ofxCvHaarFinder") << "setup(): couldn't load Haar cascade file: " << haarFile ;
#endif //USE_OLD_CV
}

Expand Down
16 changes: 8 additions & 8 deletions addons/ofxOpenCv/src/ofxCvHaarFinder.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,23 +22,23 @@ class ofxCvHaarFinder {
std::vector<ofxCvBlob> blobs;

ofxCvHaarFinder();
ofxCvHaarFinder(const ofxCvHaarFinder& finder);
ofxCvHaarFinder(const ofxCvHaarFinder & finder);
~ofxCvHaarFinder();

void setup(std::string haarFile);
void setup(const of::filesystem::path & fileName);

// The default value is 1.2. For accuracy, bring it closer but not equal to 1.0. To make it faster, use a larger value.
void setScaleHaar(float scaleHaar);
// How many neighbors can be grouped into a face? Default value is 2. If set to 0, no grouping will be done.
void setNeighbors(unsigned neighbors);

int findHaarObjects(ofImage& input, int minWidth = 0, int minHeight = 0);
int findHaarObjects(const ofxCvGrayscaleImage& input, int minWidth = 0, int minHeight = 0);
int findHaarObjects(ofImage & input, int minWidth = 0, int minHeight = 0);
int findHaarObjects(const ofxCvGrayscaleImage & input, int minWidth = 0, int minHeight = 0);

int findHaarObjects(const ofxCvGrayscaleImage& input, ofRectangle& roi, int minWidth = 0, int minHeight = 0);
int findHaarObjects(const ofxCvGrayscaleImage&, int x, int y, int w, int h, int minWidth = 0, int minHeight = 0);
int findHaarObjects(const ofxCvGrayscaleImage & input, ofRectangle& roi, int minWidth = 0, int minHeight = 0);
int findHaarObjects(const ofxCvGrayscaleImage &, int x, int y, int w, int h, int minWidth = 0, int minHeight = 0);

int findHaarObjects(ofPixels& input, int minWidth = 0, int minHeight = 0);
int findHaarObjects(ofPixels & input, int minWidth = 0, int minHeight = 0);

float getWidth();
float getHeight();
Expand All @@ -51,7 +51,7 @@ class ofxCvHaarFinder {
#else
cv::CascadeClassifier cascade;
#endif //USE_OLD_CV
std::string haarFile;
of::filesystem::path haarFile;
ofxCvGrayscaleImage img;
float scaleHaar;
unsigned neighbors;
Expand Down
Loading