Skip to content

Commit

Permalink
[Raytracing] attempt to fix compilation on Arch linux
Browse files Browse the repository at this point in the history
by adding all used STL headers

- also uniform std handling (either using namespace and then omit or use it always and no namespace
  • Loading branch information
donovaly committed Dec 6, 2022
1 parent 6f0afb4 commit c6c273e
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 22 deletions.
14 changes: 8 additions & 6 deletions src/Mod/Raytracing/App/LuxProject.cpp
Expand Up @@ -24,7 +24,9 @@

#ifndef _PreComp_
# include <Standard.hxx>
# include <iosfwd>
# include <string>
# include <vector>
#endif

#include <App/Application.h>
Expand Down Expand Up @@ -58,7 +60,7 @@ void LuxProject::onDocumentRestored()
Base::FileInfo fi(Template.getValue());
if (fi.fileName().empty())
fi.setFile(PageResult.getValue());
std::string path = App::Application::getResourceDir() + "Mod/Raytracing/Templates/" + fi.fileName();
string path = App::Application::getResourceDir() + "Mod/Raytracing/Templates/" + fi.fileName();
// try to find the template in user dir/Templates first
Base::FileInfo tempfi(App::Application::getUserAppDataDir() + "data/Mod/Raytracing/Templates/" + fi.fileName());
if (tempfi.exists())
Expand All @@ -69,18 +71,18 @@ void LuxProject::onDocumentRestored()

App::DocumentObjectExecReturn *LuxProject::execute(void)
{
if (std::string(PageResult.getValue()).empty())
if (string(PageResult.getValue()).empty())
PageResult.setValue(Template.getValue());

Base::FileInfo fi(Template.getValue());
if (!fi.isReadable()) {
Base::Console().Log("LuxProject::execute() not able to open %s!\n",Template.getValue());
std::string error = std::string("Cannot open file ") + Template.getValue();
string error = string("Cannot open file ") + Template.getValue();
return new App::DocumentObjectExecReturn(error);
}
// open Template file
string line;
ifstream file ( fi.filePath().c_str() );
ifstream file (fi.filePath().c_str());

// make a temp file for FileIncluded Property
string tempName = PageResult.getExchangeTempFile();
Expand All @@ -101,8 +103,8 @@ App::DocumentObjectExecReturn *LuxProject::execute(void)
// get through the children and collect all the views
ofile << "# declares FreeCAD objects" << endl
<< "# Generated by FreeCAD (http://www.freecadweb.org/)" << endl << endl;
const std::vector<App::DocumentObject*> &Grp = Group.getValues();
for (std::vector<App::DocumentObject*>::const_iterator It= Grp.begin();It!=Grp.end();++It) {
const vector<App::DocumentObject*> &Grp = Group.getValues();
for (vector<App::DocumentObject*>::const_iterator It= Grp.begin();It!=Grp.end();++It) {
if ((*It)->getTypeId().isDerivedFrom(Raytracing::RaySegment::getClassTypeId())) {
Raytracing::RaySegment *View = static_cast<Raytracing::RaySegment *>(*It);
ofile << View->Result.getValue();
Expand Down
30 changes: 14 additions & 16 deletions src/Mod/Raytracing/App/LuxTools.cpp
Expand Up @@ -29,7 +29,6 @@
# include <TopExp_Explorer.hxx>
# include <TopoDS.hxx>
# include <TopoDS_Face.hxx>

#endif

#include <Base/Console.h>
Expand All @@ -41,22 +40,21 @@


using Base::Console;

using namespace Raytracing;
using namespace std;

std::string LuxTools::getCamera(const CamDef& Cam)
{
std::stringstream out;
out << "# declares position and view direction" << endl
<< "# Generated by FreeCAD (http://www.freecadweb.org/)" << endl
out << "# declares position and view direction" << std::endl
<< "# Generated by FreeCAD (http://www.freecadweb.org/)"
<< std::endl

// writing Camera positions
<< "LookAt " << Cam.CamPos.X() << " " << Cam.CamPos.Y() << " " << Cam.CamPos.Z() << " "
// writing lookat
<< Cam.LookAt.X() << " " << Cam.LookAt.Y() << " " << Cam.LookAt.Z() << " "
// writing the Up Vector
<< Cam.Up.X() << " " << Cam.Up.Y() << " " << Cam.Up.Z() << endl;
<< Cam.Up.X() << " " << Cam.Up.Y() << " " << Cam.Up.Z() << std::endl;

return out.str();
}
Expand All @@ -74,10 +72,10 @@ void LuxTools::writeShape(std::ostream &out, const char *PartName, const TopoDS_
Base::SequencerLauncher seq("Writing file", l);

// write object
out << "AttributeBegin # \"" << PartName << "\"" << endl;
out << "Transform [1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1]" << endl;
out << "NamedMaterial \"FreeCADMaterial_" << PartName << "\"" << endl;
out << "Shape \"mesh\"" << endl;
out << "AttributeBegin # \"" << PartName << "\"" << std::endl;
out << "Transform [1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1]" << std::endl;
out << "NamedMaterial \"FreeCADMaterial_" << PartName << "\"" << std::endl;
out << "Shape \"mesh\"" << std::endl;

// gather vertices, normals and face indices
std::stringstream triindices;
Expand Down Expand Up @@ -124,10 +122,10 @@ void LuxTools::writeShape(std::ostream &out, const char *PartName, const TopoDS_
} // end of face loop

// write mesh data
out << " \"integer triindices\" [" << triindices.str() << "]" << endl;
out << " \"point P\" [" << P.str() << "]" << endl;
out << " \"normal N\" [" << N.str() << "]" << endl;
out << " \"bool generatetangents\" [\"false\"]" << endl;
out << " \"string name\" [\"" << PartName << "\"]" << endl;
out << "AttributeEnd # \"\"" << endl;
out << " \"integer triindices\" [" << triindices.str() << "]" << std::endl;
out << " \"point P\" [" << P.str() << "]" << std::endl;
out << " \"normal N\" [" << N.str() << "]" << std::endl;
out << " \"bool generatetangents\" [\"false\"]" << std::endl;
out << " \"string name\" [\"" << PartName << "\"]" << std::endl;
out << "AttributeEnd # \"\"" << std::endl;
}
1 change: 1 addition & 0 deletions src/Mod/Raytracing/App/PreCompiled.h
Expand Up @@ -28,6 +28,7 @@
#ifdef _PreComp_

// STL
#include <iosfwd>
#include <sstream>
#include <vector>

Expand Down

4 comments on commit c6c273e

@AjinkyaDahale
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@AjinkyaDahale
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately just this present commit doesn't work. I'll make a PR.

@adrianinsaval
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

still not compiling for me either

FAILED: src/Mod/Raytracing/App/CMakeFiles/Raytracing.dir/LuxProject.cpp.o 
/usr/sbin/ccache /usr/lib/ccache/bin/c++ -DBOOST_ATOMIC_DYN_LINK -DBOOST_ATOMIC_NO_LIB -DBOOST_DATE_TIME_DYN_LINK -DBOOST_DATE_TIME_NO_LIB -DBOOST_FILESYSTEM_DYN_LINK -DBOOST_FILESYSTEM_NO_LIB -DBOOST_PROGRAM_OPTIONS_DYN_LINK -DBOOST_PROGRAM_OPTIONS_NO_LIB -DBOOST_REGEX_DYN_LINK -DBOOST_REGEX_NO_LIB -DBOOST_SYSTEM_DYN_LINK -DBOOST_SYSTEM_NO_LIB -DBOOST_THREAD_DYN_LINK -DBOOST_THREAD_NO_LIB -DHAVE_CONFIG_H -DHAVE_LIMITS_H -DPYCXX_6_2_COMPATIBILITY -DQT_CORE_LIB -DQT_NO_DEBUG -DQT_XML_LIB -DRaytracing_EXPORTS -D_OCC64 -I/__w/pacman-repo/pacman-repo/PKGBUILD/freecad-git/src/FreeCAD/build/src/Mod/Raytracing/App/Raytracing_autogen/include -I/__w/pacman-repo/pacman-repo/PKGBUILD/freecad-git/src/FreeCAD/build -I/__w/pacman-repo/pacman-repo/PKGBUILD/freecad-git/src/FreeCAD/build/src -I/__w/pacman-repo/pacman-repo/PKGBUILD/freecad-git/src/FreeCAD/src -I/__w/pacman-repo/pacman-repo/PKGBUILD/freecad-git/src/FreeCAD/build/src/Mod/Raytracing/App -I/usr/include/opencascade -I/usr/include/python3.10 -isystem /usr/include/qt -isystem /usr/include/qt/QtCore -isystem /usr/lib/qt/mkspecs/linux-g++ -isystem /usr/include/qt/QtXml -Wall -Wextra -Wno-write-strings -march=x86-64 -mtune=generic -O2 -pipe -fno-plt -fexceptions         -Wp,-D_FORTIFY_SOURCE=2 -Wformat -Werror=format-security         -fstack-clash-protection -fcf-protection -Wp,-D_GLIBCXX_ASSERTIONS -fPIC -w -fPIC -fPIC -std=gnu++17 -MD -MT src/Mod/Raytracing/App/CMakeFiles/Raytracing.dir/LuxProject.cpp.o -MF src/Mod/Raytracing/App/CMakeFiles/Raytracing.dir/LuxProject.cpp.o.d -o src/Mod/Raytracing/App/CMakeFiles/Raytracing.dir/LuxProject.cpp.o -c /__w/pacman-repo/pacman-repo/PKGBUILD/freecad-git/src/FreeCAD/src/Mod/Raytracing/App/LuxProject.cpp
/__w/pacman-repo/pacman-repo/PKGBUILD/freecad-git/src/FreeCAD/src/Mod/Raytracing/App/LuxProject.cpp: In member function ‘virtual App::DocumentObjectExecReturn* Raytracing::LuxProject::execute()’:
/__w/pacman-repo/pacman-repo/PKGBUILD/freecad-git/src/FreeCAD/src/Mod/Raytracing/App/LuxProject.cpp:85:20: error: variable ‘std::ifstream file’ has initializer but incomplete type
   85 |     ifstream file (fi.filePath().c_str());
      |                    ^~
/__w/pacman-repo/pacman-repo/PKGBUILD/freecad-git/src/FreeCAD/src/Mod/Raytracing/App/LuxProject.cpp:89:20: error: variable ‘std::ofstream ofile’ has initializer but incomplete type
   89 |     ofstream ofile(tempName.c_str());
      |                    ^~~~~~~~
[2988/4168] Building CXX object src/Mod/Sketcher/App/CMakeFiles/Sketcher.dir/Sketch.cpp.o
[2989/4168] Automatic MOC and UIC for target FreeCADGui
AutoMoc: /__w/pacman-repo/pacman-repo/PKGBUILD/freecad-git/src/FreeCAD/src/Gui/UiLoader.h:0: Note: No relevant classes found. No output generated.
ninja: build stopped: subcommand failed.

@AjinkyaDahale
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Made #7963.

Please sign in to comment.