|
35 | 35 | PackageExport["$OpenVDBInstallationDirectory"] |
36 | 36 |
|
37 | 37 |
|
| 38 | +PackageExport["OpenVDBDocumentation"] |
| 39 | + |
| 40 | + |
38 | 41 | $OpenVDBLibrary::usage = "$OpenVDBLibrary is the full path to the OpenVDB Library loaded by OpenVDBLink."; |
39 | 42 | $OpenVDBInstallationDirectory::usage = "$OpenVDBInstallationDirectory gives the top-level directory in which your OpenVDB installation resides."; |
40 | 43 |
|
41 | 44 |
|
| 45 | +OpenVDBDocumentation::usage = "OpenVDBDocumentation[] opens the OpenVDBLink documentation.\nOpenVDBDocumentation[\"Web\"] opens the OpenVDBLink in a web browser."; |
| 46 | + |
| 47 | + |
42 | 48 | OpenVDBLink`Developer`Recompile::usage = "OpenVDBLink`Developer`Recompile[] recompiles the OpenVDB library and reloads the functions."; |
43 | 49 |
|
44 | 50 |
|
|
1214 | 1220 |
|
1215 | 1221 |
|
1216 | 1222 | carefulPixelGridQ[vdb_] := OpenVDBGridQ[vdb] && pixelGridQ[vdb] |
| 1223 | + |
| 1224 | + |
| 1225 | +(* ::Section:: *) |
| 1226 | +(*Documentation*) |
| 1227 | + |
| 1228 | + |
| 1229 | +(* ::Subsection::Closed:: *) |
| 1230 | +(*OpenVDBDocumentation*) |
| 1231 | + |
| 1232 | + |
| 1233 | +(* ::Subsubsection::Closed:: *) |
| 1234 | +(*OpenVDBDocumentation*) |
| 1235 | + |
| 1236 | + |
| 1237 | +OpenVDBDocumentation[args___] /; !CheckArgs[OpenVDBDocumentation[args], {0, 1}] = $Failed; |
| 1238 | + |
| 1239 | + |
| 1240 | +OpenVDBDocumentation[args___] := |
| 1241 | + With[{res = iOpenVDBDocumentation[args]}, |
| 1242 | + res /; res =!= $Failed |
| 1243 | + ] |
| 1244 | + |
| 1245 | + |
| 1246 | +OpenVDBDocumentation[args___] := mOpenVDBDocumentation[args] |
| 1247 | + |
| 1248 | + |
| 1249 | +(* ::Subsubsection::Closed:: *) |
| 1250 | +(*iOpenVDBDocumentation*) |
| 1251 | + |
| 1252 | + |
| 1253 | +iOpenVDBDocumentation[] := iOpenVDBDocumentation["Notebook"] |
| 1254 | + |
| 1255 | + |
| 1256 | +iOpenVDBDocumentation["Web"] := SystemOpen[$vdbWebDocURL] |
| 1257 | + |
| 1258 | + |
| 1259 | +iOpenVDBDocumentation["Notebook"] := notebookDocumentation[] |
| 1260 | + |
| 1261 | + |
| 1262 | +iOpenVDBDocumentation["Update"] := |
| 1263 | + ( |
| 1264 | + Quiet[DeleteFile[$vdbDoc]]; |
| 1265 | + notebookDocumentation[] |
| 1266 | + ) |
| 1267 | + |
| 1268 | + |
| 1269 | +iOpenVDBDocumentation[___] = $Failed; |
| 1270 | + |
| 1271 | + |
| 1272 | +(* ::Subsubsection::Closed:: *) |
| 1273 | +(*Argument conform & completion*) |
| 1274 | + |
| 1275 | + |
| 1276 | +SyntaxInformation[OpenVDBDocumentation] = {"ArgumentsPattern" -> {_.}}; |
| 1277 | + |
| 1278 | + |
| 1279 | +addCodeCompletion[OpenVDBDocumentation][{"Web", "Notebook", "Update"}]; |
| 1280 | + |
| 1281 | + |
| 1282 | +(* ::Subsubsection::Closed:: *) |
| 1283 | +(*notebookDocumentation*) |
| 1284 | + |
| 1285 | + |
| 1286 | +notebookDocumentation[] /; FileExistsQ[$vdbDoc] := NotebookOpen[$vdbDoc] |
| 1287 | + |
| 1288 | + |
| 1289 | +notebookDocumentation[] := |
| 1290 | + Block[{zip}, |
| 1291 | + If[!FileExistsQ[$vdbDocDir], |
| 1292 | + CreateDirectory[$vdbDocDir]; |
| 1293 | + ]; |
| 1294 | + |
| 1295 | + zip = URLDownload[$vdbDocURL, $vdbDocDir]; |
| 1296 | + ( |
| 1297 | + Quiet[ |
| 1298 | + ExtractArchive[zip, $vdbDocDir, FileNameTake[$vdbDoc]]; |
| 1299 | + DeleteFile[zip]; |
| 1300 | + ]; |
| 1301 | + |
| 1302 | + NotebookOpen[$vdbDoc] /; FileExistsQ[$vdbDoc] |
| 1303 | + |
| 1304 | + ) /; FileExistsQ[zip] |
| 1305 | + ] |
| 1306 | + |
| 1307 | + |
| 1308 | +notebookDocumentation[___] = $Failed; |
| 1309 | + |
| 1310 | + |
| 1311 | +(* ::Subsubsection::Closed:: *) |
| 1312 | +(*Documentation paths and URLs*) |
| 1313 | + |
| 1314 | + |
| 1315 | +$vdbDocDir = FileNameJoin[{$UserBaseDirectory, "ApplicationData", "OpenVDBLink"}]; |
| 1316 | + |
| 1317 | + |
| 1318 | +$vdbDoc = FileNameJoin[{$vdbDocDir, "OpenVDBLink.nb"}]; |
| 1319 | + |
| 1320 | + |
| 1321 | +$vdbDocURL = "https://www.openvdb.org/download/files/OpenVDBLink.nb.zip"; |
| 1322 | + |
| 1323 | + |
| 1324 | +$vdbWebDocURL = "https://www.openvdb.org/documentation/wolfram"; |
| 1325 | + |
| 1326 | + |
| 1327 | +(* ::Subsubsection::Closed:: *) |
| 1328 | +(*Messages*) |
| 1329 | + |
| 1330 | + |
| 1331 | +mOpenVDBDocumentation[type_] := |
| 1332 | + ( |
| 1333 | + If[type =!= "Web" && type =!= "Notebook", |
| 1334 | + Message[OpenVDBDocumentation::type, type, 1]; |
| 1335 | + ]; |
| 1336 | + |
| 1337 | + $Failed |
| 1338 | + ) |
| 1339 | + |
| 1340 | + |
| 1341 | +mOpenVDBDocumentation[___] = $Failed; |
| 1342 | + |
| 1343 | + |
| 1344 | +OpenVDBDocumentation::type = "`1` at position `2` is not one of \"Web\", \"Notebook\", or \"Update\"."; |
0 commit comments