|
| 1 | +// |
| 2 | +// SPDX-License-Identifier: Apache-2.0 |
| 3 | +// |
| 4 | +// PicoGK ("peacock") is a compact software kernel for computational geometry, |
| 5 | +// specifically for use in Computational Engineering Models (CEM). |
| 6 | +// |
| 7 | +// For more information, please visit https://picogk.org |
| 8 | +// |
| 9 | +// PicoGK is developed and maintained by LEAP 71 - © 2023 by LEAP 71 |
| 10 | +// https://leap71.com |
| 11 | +// |
| 12 | +// Computational Engineering will profoundly change our physical world in the |
| 13 | +// years ahead. Thank you for being part of the journey. |
| 14 | +// |
| 15 | +// We have developed this library to be used widely, for both commercial and |
| 16 | +// non-commercial projects alike. Therefore, have released it under a permissive |
| 17 | +// open-source license. |
| 18 | +// |
| 19 | +// The foundation of PicoGK is a thin layer on top of the powerful open-source |
| 20 | +// OpenVDB project, which in turn uses many other Free and Open Source Software |
| 21 | +// libraries. We are grateful to be able to stand on the shoulders of giants. |
| 22 | +// |
| 23 | +// LEAP 71 licenses this file to you under the Apache License, Version 2.0 |
| 24 | +// (the "License"); you may not use this file except in compliance with the |
| 25 | +// License. You may obtain a copy of the License at |
| 26 | +// |
| 27 | +// http://www.apache.org/licenses/LICENSE-2.0 |
| 28 | +// |
| 29 | +// Unless required by applicable law or agreed to in writing, THE SOFTWARE IS |
| 30 | +// PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED. |
| 31 | +// |
| 32 | +// See the License for the specific language governing permissions and |
| 33 | +// limitations under the License. |
| 34 | +// |
| 35 | + |
| 36 | +#ifndef PICOGKGL_H_ |
| 37 | +#define PICOGKGL_H_ |
| 38 | + |
| 39 | +#include "PicoGKApiTypes.h" |
| 40 | + |
| 41 | +#ifdef __cplusplus |
| 42 | + #define PICOGK_EXTC extern "C" |
| 43 | +#else |
| 44 | + #define PICOGK_EXTC |
| 45 | +#endif |
| 46 | + |
| 47 | +#ifdef PICOGK_BUILD_LIBRARY // set in compiler when building a library |
| 48 | + #if defined _WINDOWS |
| 49 | + #define PICOGK_API PICOGK_EXTC __declspec(dllexport) |
| 50 | + #else |
| 51 | + #define PICOGK_API PICOGK_EXTC __attribute__ ((visibility ("default"))) |
| 52 | + #endif |
| 53 | +#else // we are using the library |
| 54 | +#if defined _WINDOWS |
| 55 | + #define PICOGK_API PICOGK_EXTC __declspec(dllimport) |
| 56 | +#else |
| 57 | + #define PICOGK_API PICOGK_EXTC |
| 58 | +#endif |
| 59 | +#endif |
| 60 | + |
| 61 | +#include "PicoGKApiTypes.h" |
| 62 | + |
| 63 | +// Library information |
| 64 | + |
| 65 | +#define PKINFOSTRINGLEN 255 |
| 66 | + |
| 67 | +PICOGK_API void Library_Init( float fVoxelSizeMM); |
| 68 | + |
| 69 | +PICOGK_API void Library_GetName( char psz[PKINFOSTRINGLEN]); |
| 70 | + |
| 71 | +PICOGK_API void Library_GetVersion( char psz[PKINFOSTRINGLEN]); |
| 72 | + |
| 73 | +PICOGK_API void Library_GetBuildInfo( char psz[PKINFOSTRINGLEN]); |
| 74 | + |
| 75 | +#define PKHANDLE void* |
| 76 | +#define PKMESH PKHANDLE |
| 77 | +#define PKLATTICE PKHANDLE |
| 78 | +#define PKPOLYLINE PKHANDLE |
| 79 | +#define PKVOXELS PKHANDLE |
| 80 | +#define PKVIEWER PKHANDLE |
| 81 | + |
| 82 | +// MESH |
| 83 | + |
| 84 | +PICOGK_API PKMESH Mesh_hCreate(); |
| 85 | + |
| 86 | +PICOGK_API PKMESH Mesh_hCreateFromVoxels( PKVOXELS hVoxels); |
| 87 | + |
| 88 | +PICOGK_API bool Mesh_bIsValid( PKMESH hThis); |
| 89 | + |
| 90 | +PICOGK_API void Mesh_Destroy( PKMESH hThis); |
| 91 | + |
| 92 | +PICOGK_API int32_t Mesh_nAddVertex( PKMESH hThis, |
| 93 | + const PKVector3* pvecVertex); |
| 94 | + |
| 95 | +PICOGK_API int32_t Mesh_nVertexCount( PKMESH hThis); |
| 96 | + |
| 97 | +PICOGK_API void Mesh_GetVertex( PKMESH hThis, |
| 98 | + int32_t nVertex, |
| 99 | + PKVector3* pvecVertex); |
| 100 | + |
| 101 | +PICOGK_API int32_t Mesh_nAddTriangle( PKMESH hThis, |
| 102 | + const PKTriangle* psTri); |
| 103 | + |
| 104 | +PICOGK_API int32_t Mesh_nTriangleCount( PKMESH hThis); |
| 105 | + |
| 106 | +PICOGK_API void Mesh_GetTriangle( PKMESH hThis, |
| 107 | + int32_t nTriangle, |
| 108 | + PKTriangle* psTri); |
| 109 | + |
| 110 | +PICOGK_API void Mesh_GetTriangleV( PKMESH hThis, |
| 111 | + int32_t nTriangle, |
| 112 | + PKVector3* pvecA, |
| 113 | + PKVector3* pvecB, |
| 114 | + PKVector3* pvecC); |
| 115 | + |
| 116 | +PICOGK_API void Mesh_GetBoundingBox( PKMESH hThis, |
| 117 | + PKBBox3* poBox); |
| 118 | + |
| 119 | +// LATTICE |
| 120 | + |
| 121 | +PICOGK_API PKLATTICE Lattice_hCreate(); |
| 122 | + |
| 123 | + |
| 124 | +PICOGK_API bool Lattice_bIsValid( PKLATTICE hThis); |
| 125 | + |
| 126 | + |
| 127 | +PICOGK_API void Lattice_Destroy( PKLATTICE hThis); |
| 128 | + |
| 129 | + |
| 130 | +PICOGK_API void Lattice_AddSphere( PKLATTICE hThis, |
| 131 | + const PKVector3* vecCenter, |
| 132 | + float fRadius); |
| 133 | + |
| 134 | + |
| 135 | +PICOGK_API void Lattice_AddBeam( PKLATTICE hThis, |
| 136 | + const PKVector3* pvecA, |
| 137 | + const PKVector3* pvecB, |
| 138 | + float fRadiusA, |
| 139 | + float fRadiusB, |
| 140 | + bool bRoundCap); |
| 141 | + |
| 142 | +// VOXELS |
| 143 | + |
| 144 | +PICOGK_API PKVOXELS Voxels_hCreate(); |
| 145 | + |
| 146 | +PICOGK_API PKVOXELS Voxels_hCreateCopy( PKVOXELS hSource); |
| 147 | + |
| 148 | +PICOGK_API bool Voxels_bIsValid( PKVOXELS hThis); |
| 149 | + |
| 150 | +PICOGK_API void Voxels_Destroy( PKVOXELS hThis); |
| 151 | + |
| 152 | +PICOGK_API void Voxels_BoolAdd( PKVOXELS hThis, |
| 153 | + PKVOXELS hOther); |
| 154 | + |
| 155 | +PICOGK_API void Voxels_BoolSubtract( PKVOXELS hThis, |
| 156 | + PKVOXELS hOther); |
| 157 | + |
| 158 | +PICOGK_API void Voxels_BoolIntersect( PKVOXELS hThis, |
| 159 | + PKVOXELS hOther); |
| 160 | + |
| 161 | +PICOGK_API void Voxels_Offset( PKVOXELS hThis, |
| 162 | + float fDist); |
| 163 | + |
| 164 | +PICOGK_API void Voxels_DoubleOffset( PKVOXELS hThis, |
| 165 | + float fDist1, |
| 166 | + float fDist2); |
| 167 | + |
| 168 | +PICOGK_API void Voxels_TripleOffset( PKVOXELS hThis, |
| 169 | + float fDist); |
| 170 | + |
| 171 | +PICOGK_API void Voxels_RenderMesh( PKVOXELS hThis, |
| 172 | + PKMESH hMesh); |
| 173 | + |
| 174 | +PICOGK_API void Voxels_RenderImplicit( PKVOXELS hThis, |
| 175 | + const PKBBox3* poBBox, |
| 176 | + PKPFnfSdf pfnSDF); |
| 177 | + |
| 178 | +PICOGK_API void Voxels_IntersectImplicit( PKVOXELS hThis, |
| 179 | + PKPFnfSdf pfnSDF); |
| 180 | + |
| 181 | +PICOGK_API void Voxels_RenderLattice( PKVOXELS hThis, |
| 182 | + PKLATTICE hLattice); |
| 183 | + |
| 184 | +PICOGK_API void Voxels_ProjectZSlice( PKVOXELS hThis, |
| 185 | + float fStartZ, |
| 186 | + float fEndZ); |
| 187 | + |
| 188 | +PICOGK_API bool Voxels_bIsInside( PKVOXELS hThis, |
| 189 | + const PKVector3* pvecTestPoint); |
| 190 | + |
| 191 | +PICOGK_API bool Voxels_bIsEqual( PKVOXELS hThis, |
| 192 | + PKVOXELS hOther); |
| 193 | + |
| 194 | +PICOGK_API void Voxels_CalculateProperties( PKVOXELS hThis, |
| 195 | + float* pfVolume, |
| 196 | + PKBBox3* poBBox); |
| 197 | + |
| 198 | +PICOGK_API bool Voxels_bClosestPointOnSurface( PKVOXELS hThis, |
| 199 | + const PKVector3* pvecSearch, |
| 200 | + PKVector3* pvecSurfacePoint); |
| 201 | + |
| 202 | +PICOGK_API bool Voxels_bRayCastToSurface( PKVOXELS hThis, |
| 203 | + const PKVector3* pvecSearch, |
| 204 | + const PKVector3* pvecDirection, |
| 205 | + PKVector3* pvecSurfacePoint); |
| 206 | + |
| 207 | +PICOGK_API void Voxels_GetVoxelDimensions( PKVOXELS hThis, |
| 208 | + int32_t* pnXSize, |
| 209 | + int32_t* pnYSize, |
| 210 | + int32_t* pnZSize); |
| 211 | + |
| 212 | +PICOGK_API void Voxels_GetSlice( PKVOXELS hThis, |
| 213 | + int32_t nZSlice, |
| 214 | + float* pfBuffer); |
| 215 | + |
| 216 | +// POLYLINE |
| 217 | + |
| 218 | +PICOGK_API PKPOLYLINE PolyLine_hCreate( const PKColorFloat* pclr); |
| 219 | + |
| 220 | +PICOGK_API bool PolyLine_bIsValid( PKHANDLE hThis); |
| 221 | + |
| 222 | +PICOGK_API void PolyLine_Destroy( PKHANDLE hThis); |
| 223 | + |
| 224 | +PICOGK_API int32_t PolyLine_nAddVertex( PKPOLYLINE hThis, |
| 225 | + const PKVector3* pvec); |
| 226 | + |
| 227 | +PICOGK_API int32_t PolyLine_nVertexCount( PKPOLYLINE hThis); |
| 228 | + |
| 229 | +PICOGK_API void PolyLine_GetVertex( PKPOLYLINE hThis, |
| 230 | + int32_t nIndex, |
| 231 | + PKVector3* pvec); |
| 232 | + |
| 233 | +PICOGK_API void PolyLine_GetColor( PKPOLYLINE hThis, |
| 234 | + PKColorFloat* pclr); |
| 235 | + |
| 236 | +// VIEWER |
| 237 | + |
| 238 | +PICOGK_API PKVIEWER Viewer_hCreate( const char* pszWindowTitle, |
| 239 | + const PKVector2* pvecSize, |
| 240 | + PKFInfo pfnInfoCallback, |
| 241 | + PKPFUpdateRequested pfnUpdateCallback, |
| 242 | + PKPFKeyPressed pfnKeyPressedCallback, |
| 243 | + PKPFMouseMoved pfnMouseMoveCallback, |
| 244 | + PKPFMouseButton pfnMouseButtonCallback, |
| 245 | + PKPFScrollWheel pfnScrollWheelCallback, |
| 246 | + PKPFWindowSize pfnWindowSize); |
| 247 | + |
| 248 | +PICOGK_API bool Viewer_bIsValid( PKVIEWER hThis); |
| 249 | + |
| 250 | +PICOGK_API void Viewer_Destroy( PKVIEWER hThis); |
| 251 | + |
| 252 | +PICOGK_API void Viewer_RequestUpdate( PKVIEWER hThis); |
| 253 | + |
| 254 | +PICOGK_API bool Viewer_bPoll( PKVIEWER hThis); |
| 255 | + |
| 256 | +PICOGK_API void Viewer_RequestScreenShot( PKVIEWER hThis, |
| 257 | + const char* pszScreenShotPath); |
| 258 | + |
| 259 | +PICOGK_API void Viewer_RequestClose( PKVIEWER hThis); |
| 260 | + |
| 261 | +PICOGK_API bool Viewer_bLoadLightSetup( PKVIEWER hThis, |
| 262 | + const char* pDiffTextureDDS, |
| 263 | + int32_t nDiffTextureSize, |
| 264 | + const char* pSpecTextureDDS, |
| 265 | + int32_t nSpecTextureSize); |
| 266 | + |
| 267 | +PICOGK_API void Viewer_AddMesh( PKVIEWER hThis, |
| 268 | + int32_t nGroupID, |
| 269 | + PKMESH hMesh); |
| 270 | + |
| 271 | +PICOGK_API void Viewer_RemoveMesh( PKVIEWER hThis, |
| 272 | + PKMESH hMesh); |
| 273 | + |
| 274 | +PICOGK_API void Viewer_AddPolyLine( PKVIEWER hThis, |
| 275 | + int32_t nGroupID, |
| 276 | + PKPOLYLINE hPolyLine); |
| 277 | + |
| 278 | +PICOGK_API void Viewer_RemovePolyLine( PKVIEWER hThis, |
| 279 | + PKPOLYLINE hPolyLine); |
| 280 | + |
| 281 | +PICOGK_API void Viewer_SetGroupVisible( PKVIEWER hThis, |
| 282 | + int32_t nGroupID, |
| 283 | + bool bVisible); |
| 284 | + |
| 285 | +PICOGK_API void Viewer_SetGroupStatic( PKVIEWER hThis, |
| 286 | + int32_t nGroupID, |
| 287 | + bool bStatic); |
| 288 | + |
| 289 | +PICOGK_API void Viewer_SetGroupMaterial( PKVIEWER hThis, |
| 290 | + int32_t nGroupID, |
| 291 | + const PKColorFloat* pclr, |
| 292 | + float fMetallic, |
| 293 | + float fRoughness); |
| 294 | + |
| 295 | +PICOGK_API void Viewer_SetGroupMatrix( PKVIEWER hThis, |
| 296 | + int32_t nGroupID, |
| 297 | + const PKMatrix4x4* pmat); |
| 298 | +#endif |
| 299 | + |
| 300 | + |
0 commit comments