public function write($ps_filepath, $ps_mimetype) { if (!$this->handle) { return false; } $this->properties["width"] = $this->properties["version_width"]; $this->properties["height"] = $this->properties["version_height"]; # is mimetype valid? if (!($vs_ext = $this->info["EXPORT"][$ps_mimetype])) { $this->postError(1610, _t("Can't convert file to %1", $ps_mimetype), "WLPlugMediaMesh->write()"); return false; } switch ($ps_mimetype) { case 'application/ctm': if (file_exists($this->filepath) && caOpenCTMInstalled()) { exec(caGetExternalApplicationPath('openctm') . ' ' . caEscapeShellArg($this->filepath) . " " . caEscapeShellArg($ps_filepath) . ".ctm --method MG2 --level 9 2>&1", $va_output); return "{$ps_filepath}.ctm"; } else { @unlink("{$ps_filepath}.ctm"); //$this->postError(1610, _t("Couldn't convert %1 model to ctm", $this->properties['mimetype']), "WLPlugMediaMesh->write()"); //return false; } break; default: # pretty restricted, but we can convert ply to stl! if ($this->properties['mimetype'] == 'application/ply' && $ps_mimetype == 'application/stl') { if (file_exists($this->filepath)) { if (caMeshlabServerInstalled()) { putenv("DISPLAY=:0"); chdir('/usr/local/bin'); exec(caGetExternalApplicationPath('meshlabserver') . " -i " . caEscapeShellArg($this->filepath) . " -o " . caEscapeShellArg($ps_filepath) . ".stl 2>&1", $va_output); return "{$ps_filepath}.stl"; } elseif (PlyToStl::convert($this->filepath, $ps_filepath . '.stl')) { return "{$ps_filepath}.stl"; } else { @unlink("{$ps_filepath}.stl"); $this->postError(1610, _t("Couldn't convert ply model to stl"), "WLPlugMediaMesh->write()"); return false; } } } break; } # use default media icons return __CA_MEDIA_3D_DEFAULT_ICON__; }
public function write($ps_filepath, $ps_mimetype) { if (!$this->handle) { return false; } $this->properties["width"] = $this->properties["version_width"]; $this->properties["height"] = $this->properties["version_height"]; # is mimetype valid? if (!($vs_ext = $this->info["EXPORT"][$ps_mimetype])) { $this->postError(1610, _t("Can't convert file to %1", $ps_mimetype), "WLPlugMediaMesh->write()"); return false; } # pretty restricted, but we can convert ply to stl! if ($this->properties['mimetype'] == 'application/ply' && $ps_mimetype == 'application/stl') { if (file_exists($this->filepath)) { if (PlyToStl::convert($this->filepath, $ps_filepath . '.stl')) { return $ps_filepath . '.stl'; } else { @unlink($ps_filepath . '.stl'); $this->postError(1610, _t("Couldn't convert ply model to stl"), "WLPlugMediaMesh->write()"); return false; } } } # use default media icons return __CA_MEDIA_3D_DEFAULT_ICON__; }