Ejemplo n.º 1
0
template<typename ReaderT> void load_file(const k3d::filesystem::path& FilePath, const TCollection_ExtendedString& TypeName, implementation* Implementation)
{
	ReaderT reader; // create a CAF reader, which supports reading attributes like shape names, colors, ...
	reader.SetNameMode(true); // Make sure we read names
	IFSelect_ReturnStatus status = reader.ReadFile(const_cast<char*>(FilePath.native_filesystem_string().c_str())); // Read the file
	if(status != IFSelect_RetDone)
	{
		k3d::log() << error << k3d_file_reference << ": error opening [" << FilePath.native_console_string() << "]" << std::endl;
		throw std::exception();
	}

	Implementation->xde_doc = new TDocStd_Document(TypeName); // initialise an empty document
	if (!reader.Transfer(Implementation->xde_doc)) // attempt to transfer the STEP file contents to the document
	{
		k3d::log() << error << "Failed to transfer OpenCascade file" << std::endl;
		throw std::exception();
	}

	if(!XCAFDoc_DocumentTool::IsXCAFDocument(Implementation->xde_doc)) // sanity check
	{
		k3d::log() << error << "Invalid document" << std::endl;
		throw std::exception();
	}

	TDF_Label shaperoot = XCAFDoc_DocumentTool::ShapesLabel(Implementation->xde_doc->Main()); // get the root node for the geometric shapes
	Implementation->shapes.push(TDF_ChildIterator(shaperoot));
}
Ejemplo n.º 2
0
    k3d::bool_t render(k3d::inetwork_render_frame& Frame, const k3d::filesystem::path& RIB)
    {
        k3d::inetwork_render_frame::environment environment;

        k3d::inetwork_render_frame::arguments arguments;
        arguments.push_back(k3d::inetwork_render_frame::argument(RIB.native_filesystem_string()));

        Frame.add_exec_command("air", environment, arguments);

        return true;
    }
Ejemplo n.º 3
0
    k3d::bool_t compile_shader(const k3d::filesystem::path& Shader)
    {
        // Compute some paths that will be used by the compiler ...
        const k3d::filesystem::path shader_source_path = Shader;
        const k3d::filesystem::path shader_binary_path = k3d::shader_cache_path() / k3d::filesystem::generic_path(k3d::filesystem::replace_extension(Shader, ".slb").leaf());
        const k3d::filesystem::path shader_source_directory = Shader.branch_path();
        const k3d::filesystem::path global_source_directory = k3d::share_path() / k3d::filesystem::generic_path("shaders");

        if(k3d::filesystem::up_to_date(shader_source_path, shader_binary_path))
            return true;

        std::ostringstream command_line;
        command_line << "shaded";
        command_line << " -I\"" << shader_source_directory.native_filesystem_string()  << "\"";
        command_line << " -I\"" << global_source_directory.native_filesystem_string()  << "\"";
        command_line << " -o \"" << shader_binary_path.native_filesystem_string() << "\"";
        command_line << " \"" << shader_source_path.native_filesystem_string() << "\"";

        // Make it happen ...
        return_val_if_fail(k3d::system::spawn_sync(command_line.str()), false);

        return true;
    }
Ejemplo n.º 4
0
	bool read_file(const k3d::filesystem::path& Path, k3d::bitmap& Bitmap)
	{
		try
		{
			k3d::log() << info << "Reading " << Path.native_console_string() << " using " << get_factory().name() << std::endl;
			boost::gil::read_and_convert_image(Path.native_filesystem_string(), Bitmap, boost::gil::jpeg_tag());
			return true;
		}
		catch(std::exception& e)
		{
			k3d::log() << error << k3d_file_reference << ": caught exception: " << e.what() << std::endl;
			return false;
		}
		catch(...)
		{
			k3d::log() << error << k3d_file_reference << ": caught unknown exception" << std::endl;
			return false;
		}
	}
Ejemplo n.º 5
0
Glib::RefPtr<Gdk::Pixbuf> load_pixbuf(const k3d::filesystem::path& SharePath, const k3d::filesystem::path& Path)
{
	Glib::RefPtr<Gdk::Pixbuf> result;
	const k3d::filesystem::path path = SharePath / Path;
	try
	{
		result = Gdk::Pixbuf::create_from_file(path.native_filesystem_string());
	}
	catch(Glib::Exception& e)
	{
		k3d::log() << error << e.what() << std::endl;
	}
	catch(std::exception& e)
	{
		k3d::log() << error << e.what() << std::endl;
	}
	catch(...)
	{
		k3d::log() << error << "Unknown exception loading [" << path.native_console_string() << "]" << std::endl;
	}

	return result;
}