MCPcopy Create free account
hub / github.com/assimp/assimp / Assimp_Extract

Function Assimp_Extract

tools/assimp_cmd/ImageExtractor.cpp:218–361  ·  view source on GitHub ↗

----------------------------------------------------------------------------------- Implementation of the assimp extract utility

Source from the content-addressed store, hash-verified

216// -----------------------------------------------------------------------------------
217// Implementation of the assimp extract utility
218int Assimp_Extract(const char *const *params, unsigned int num) {
219 const char *const invalid = "assimp extract: Invalid number of arguments. See \'assimp extract --help\'\n";
220 // assimp extract in out [options]
221 if (num < 1) {
222 printf(invalid);
223 return AssimpCmdError::InvalidNumberOfArguments;
224 }
225
226 // --help
227 if (!strcmp(params[0], "-h") || !strcmp(params[0], "--help") || !strcmp(params[0], "-?")) {
228 printf("%s", AICMD_MSG_DUMP_HELP_E);
229 return AssimpCmdError::Success;
230 }
231
232 std::string in = std::string(params[0]);
233 std::string out = (num > 1 ? std::string(params[1]) : "-");
234
235 // get import flags
236 ImportData import;
237 ProcessStandardArguments(import, params + 1, num - 1);
238
239 bool nosuffix = false;
240 unsigned int texIdx = 0xffffffff, flags = 0;
241
242 // process other flags
243 std::string extension = "bmp";
244 for (unsigned int i = (out[0] == '-' ? 1 : 2); i < num; ++i) {
245 if (!params[i]) {
246 continue;
247 }
248
249 if (!strncmp(params[i], "-f", 2)) {
250 extension = std::string(params[i] + 2);
251 } else if (!strncmp(params[i], "--format=", 9)) {
252 extension = std::string(params[i] + 9);
253 } else if (!strcmp(params[i], "--nosuffix") || !strcmp(params[i], "-s")) {
254 nosuffix = true;
255 } else if (!strncmp(params[i], "--texture=", 10)) {
256 texIdx = Assimp::strtoul10(params[i] + 10);
257 } else if (!strncmp(params[i], "-t", 2)) {
258 texIdx = Assimp::strtoul10(params[i] + 2);
259 } else if (!strcmp(params[i], "-ba") || !strcmp(params[i], "--bmp-with-alpha")) {
260 flags |= AI_EXTRACT_WRITE_BMP_ALPHA;
261 }
262#if 0
263 else {
264 printf("Unknown parameter: %s\n",params[i]);
265 return 10;
266 }
267#endif
268 }
269
270 std::transform(extension.begin(), extension.end(), extension.begin(), ai_tolower<char>);
271
272 if (out[0] == '-') {
273 // take file name from input file
274 std::string::size_type s = in.find_last_of('.');
275 if (s == std::string::npos)

Callers 1

mainFunction · 0.85

Calls 9

ProcessStandardArgumentsFunction · 0.85
strtoul10Function · 0.85
transformFunction · 0.85
ImportModelFunction · 0.85
ASSIMP_itoa10Function · 0.85
appendMethod · 0.80
DoExportFunction · 0.70
beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected