Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-02-21 09:30:07

0001 /*
0002 ---------------------------------------------------------------------------
0003 Open Asset Import Library (assimp)
0004 ---------------------------------------------------------------------------
0005 
0006 Copyright (c) 2006-2024, assimp team
0007 
0008 All rights reserved.
0009 
0010 Redistribution and use of this software in source and binary forms,
0011 with or without modification, are permitted provided that the following
0012 conditions are met:
0013 
0014 * Redistributions of source code must retain the above
0015 copyright notice, this list of conditions and the
0016 following disclaimer.
0017 
0018 * Redistributions in binary form must reproduce the above
0019 copyright notice, this list of conditions and the
0020 following disclaimer in the documentation and/or other
0021 materials provided with the distribution.
0022 
0023 * Neither the name of the assimp team, nor the names of its
0024 contributors may be used to endorse or promote products
0025 derived from this software without specific prior
0026 written permission of the assimp team.
0027 
0028 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
0029 "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
0030 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
0031 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
0032 OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
0033 SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
0034 LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
0035 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
0036 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
0037 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
0038 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
0039 ---------------------------------------------------------------------------
0040 */
0041 
0042 /** @file  cexport.h
0043 *  @brief Defines the C-API for the Assimp export interface
0044 */
0045 #pragma once
0046 #ifndef AI_EXPORT_H_INC
0047 #define AI_EXPORT_H_INC
0048 
0049 #ifdef __GNUC__
0050 #pragma GCC system_header
0051 #endif
0052 
0053 #ifndef ASSIMP_BUILD_NO_EXPORT
0054 
0055 #include <assimp/types.h>
0056 
0057 #ifdef __cplusplus
0058 extern "C" {
0059 #endif
0060 
0061 struct aiScene;
0062 struct aiFileIO;
0063 
0064 // --------------------------------------------------------------------------------
0065 /**
0066  *  @brief  Describes an file format which Assimp can export to.
0067  *
0068  *  Use #aiGetExportFormatCount() to learn how many export-formats are supported by
0069  *  the current Assimp-build and #aiGetExportFormatDescription() to retrieve the
0070  *  description of the export format option.
0071  */
0072 struct aiExportFormatDesc {
0073     /// a short string ID to uniquely identify the export format. Use this ID string to
0074     /// specify which file format you want to export to when calling #aiExportScene().
0075     /// Example: "dae" or "obj"
0076     const char *id;
0077 
0078     /// A short description of the file format to present to users. Useful if you want
0079     /// to allow the user to select an export format.
0080     const char *description;
0081 
0082     /// Recommended file extension for the exported file in lower case.
0083     const char *fileExtension;
0084 };
0085 
0086 // --------------------------------------------------------------------------------
0087 /** Returns the number of export file formats available in the current Assimp build.
0088  * Use aiGetExportFormatDescription() to retrieve infos of a specific export format.
0089  */
0090 ASSIMP_API size_t aiGetExportFormatCount(void);
0091 
0092 // --------------------------------------------------------------------------------
0093 /** Returns a description of the nth export file format. Use #aiGetExportFormatCount()
0094  * to learn how many export formats are supported. The description must be released by
0095  * calling aiReleaseExportFormatDescription afterwards.
0096  * @param pIndex Index of the export format to retrieve information for. Valid range is
0097  *    0 to #aiGetExportFormatCount()
0098  * @return A description of that specific export format. NULL if pIndex is out of range.
0099  */
0100 ASSIMP_API const C_STRUCT aiExportFormatDesc *aiGetExportFormatDescription(size_t pIndex);
0101 
0102 // --------------------------------------------------------------------------------
0103 /** Release a description of the nth export file format. Must be returned by
0104 * aiGetExportFormatDescription
0105 * @param desc Pointer to the description
0106 */
0107 ASSIMP_API void aiReleaseExportFormatDescription(const C_STRUCT aiExportFormatDesc *desc);
0108 
0109 // --------------------------------------------------------------------------------
0110 /** Create a modifiable copy of a scene.
0111  *  This is useful to import files via Assimp, change their topology and
0112  *  export them again. Since the scene returned by the various importer functions
0113  *  is const, a modifiable copy is needed.
0114  *  @param pIn Valid scene to be copied
0115  *  @param pOut Receives a modifiable copy of the scene. Use aiFreeScene() to
0116  *    delete it again.
0117  */
0118 ASSIMP_API void aiCopyScene(const C_STRUCT aiScene *pIn,
0119         C_STRUCT aiScene **pOut);
0120 
0121 // --------------------------------------------------------------------------------
0122 /** Frees a scene copy created using aiCopyScene() */
0123 ASSIMP_API void aiFreeScene(const C_STRUCT aiScene *pIn);
0124 
0125 // --------------------------------------------------------------------------------
0126 /** Exports the given scene to a chosen file format and writes the result file(s) to disk.
0127 * @param pScene The scene to export. Stays in possession of the caller, is not changed by the function.
0128 *   The scene is expected to conform to Assimp's Importer output format as specified
0129 *   in the @link data Data Structures Page @endlink. In short, this means the model data
0130 *   should use a right-handed coordinate systems, face winding should be counter-clockwise
0131 *   and the UV coordinate origin is assumed to be in the upper left. If your input data
0132 *   uses different conventions, have a look at the last parameter.
0133 * @param pFormatId ID string to specify to which format you want to export to. Use
0134 * aiGetExportFormatCount() / aiGetExportFormatDescription() to learn which export formats are available.
0135 * @param pFileName Output file to write
0136 * @param pPreprocessing Accepts any choice of the #aiPostProcessSteps enumerated
0137 *   flags, but in reality only a subset of them makes sense here. Specifying
0138 *   'preprocessing' flags is useful if the input scene does not conform to
0139 *   Assimp's default conventions as specified in the @link data Data Structures Page @endlink.
0140 *   In short, this means the geometry data should use a right-handed coordinate systems, face
0141 *   winding should be counter-clockwise and the UV coordinate origin is assumed to be in
0142 *   the upper left. The #aiProcess_MakeLeftHanded, #aiProcess_FlipUVs and
0143 *   #aiProcess_FlipWindingOrder flags are used in the import side to allow users
0144 *   to have those defaults automatically adapted to their conventions. Specifying those flags
0145 *   for exporting has the opposite effect, respectively. Some other of the
0146 *   #aiPostProcessSteps enumerated values may be useful as well, but you'll need
0147 *   to try out what their effect on the exported file is. Many formats impose
0148 *   their own restrictions on the structure of the geometry stored therein,
0149 *   so some preprocessing may have little or no effect at all, or may be
0150 *   redundant as exporters would apply them anyhow. A good example
0151 *   is triangulation - whilst you can enforce it by specifying
0152 *   the #aiProcess_Triangulate flag, most export formats support only
0153 *   triangulate data so they would run the step anyway.
0154 *
0155 *   If assimp detects that the input scene was directly taken from the importer side of
0156 *   the library (i.e. not copied using aiCopyScene and potentially modified afterwards),
0157 *   any post-processing steps already applied to the scene will not be applied again, unless
0158 *   they show non-idempotent behavior (#aiProcess_MakeLeftHanded, #aiProcess_FlipUVs and
0159 *   #aiProcess_FlipWindingOrder).
0160 * @return a status code indicating the result of the export
0161 * @note Use aiCopyScene() to get a modifiable copy of a previously
0162 *   imported scene.
0163 */
0164 ASSIMP_API aiReturn aiExportScene(const C_STRUCT aiScene *pScene,
0165         const char *pFormatId,
0166         const char *pFileName,
0167         unsigned int pPreprocessing);
0168 
0169 // --------------------------------------------------------------------------------
0170 /** Exports the given scene to a chosen file format using custom IO logic supplied by you.
0171 * @param pScene The scene to export. Stays in possession of the caller, is not changed by the function.
0172 * @param pFormatId ID string to specify to which format you want to export to. Use
0173 * aiGetExportFormatCount() / aiGetExportFormatDescription() to learn which export formats are available.
0174 * @param pFileName Output file to write
0175 * @param pIO custom IO implementation to be used. Use this if you use your own storage methods.
0176 *   If none is supplied, a default implementation using standard file IO is used. Note that
0177 *   #aiExportSceneToBlob is provided as convenience function to export to memory buffers.
0178 * @param pPreprocessing Please see the documentation for #aiExportScene
0179 * @return a status code indicating the result of the export
0180 * @note Include <aiFileIO.h> for the definition of #aiFileIO.
0181 * @note Use aiCopyScene() to get a modifiable copy of a previously
0182 *   imported scene.
0183 */
0184 ASSIMP_API aiReturn aiExportSceneEx(const C_STRUCT aiScene *pScene,
0185         const char *pFormatId,
0186         const char *pFileName,
0187         C_STRUCT aiFileIO *pIO,
0188         unsigned int pPreprocessing);
0189 
0190 // --------------------------------------------------------------------------------
0191 /** Describes a blob of exported scene data. Use #aiExportSceneToBlob() to create a blob containing an
0192 * exported scene. The memory referred by this structure is owned by Assimp.
0193 * to free its resources. Don't try to free the memory on your side - it will crash for most build configurations
0194 * due to conflicting heaps.
0195 *
0196 * Blobs can be nested - each blob may reference another blob, which may in turn reference another blob and so on.
0197 * This is used when exporters write more than one output file for a given #aiScene. See the remarks for
0198 * #aiExportDataBlob::name for more information.
0199 */
0200 struct aiExportDataBlob {
0201     /// Size of the data in bytes
0202     size_t size;
0203 
0204     /// The data.
0205     void *data;
0206 
0207     /** Name of the blob. An empty string always
0208       * indicates the first (and primary) blob,
0209       * which contains the actual file data.
0210       * Any other blobs are auxiliary files produced
0211       * by exporters (i.e. material files). Existence
0212       * of such files depends on the file format. Most
0213       * formats don't split assets across multiple files.
0214       *
0215       * If used, blob names usually contain the file
0216       * extension that should be used when writing
0217       * the data to disc.
0218       *
0219       * The blob names generated can be influenced by
0220       * setting the #AI_CONFIG_EXPORT_BLOB_NAME export
0221       * property to the name that is used for the master
0222       * blob. All other names are typically derived from
0223       * the base name, by the file format exporter.
0224      */
0225     C_STRUCT aiString name;
0226 
0227     /** Pointer to the next blob in the chain or NULL if there is none. */
0228     C_STRUCT aiExportDataBlob *next;
0229 
0230 #ifdef __cplusplus
0231     /// Default constructor
0232     aiExportDataBlob() {
0233         size = 0;
0234         data = next = nullptr;
0235     }
0236     /// Releases the data
0237     ~aiExportDataBlob() {
0238         delete[] static_cast<unsigned char *>(data);
0239         delete next;
0240     }
0241 
0242     aiExportDataBlob(const aiExportDataBlob &) = delete;
0243     aiExportDataBlob &operator=(const aiExportDataBlob &) = delete;
0244 
0245 #endif // __cplusplus
0246 };
0247 
0248 // --------------------------------------------------------------------------------
0249 /** Exports the given scene to a chosen file format. Returns the exported data as a binary blob which
0250 * you can write into a file or something. When you're done with the data, use #aiReleaseExportBlob()
0251 * to free the resources associated with the export.
0252 * @param pScene The scene to export. Stays in possession of the caller, is not changed by the function.
0253 * @param pFormatId ID string to specify to which format you want to export to. Use
0254 * #aiGetExportFormatCount() / #aiGetExportFormatDescription() to learn which export formats are available.
0255 * @param pPreprocessing Please see the documentation for #aiExportScene
0256 * @return the exported data or NULL in case of error
0257 */
0258 ASSIMP_API const C_STRUCT aiExportDataBlob *aiExportSceneToBlob(const C_STRUCT aiScene *pScene, const char *pFormatId,
0259         unsigned int pPreprocessing);
0260 
0261 // --------------------------------------------------------------------------------
0262 /** Releases the memory associated with the given exported data. Use this function to free a data blob
0263 * returned by aiExportScene().
0264 * @param pData the data blob returned by #aiExportSceneToBlob
0265 */
0266 ASSIMP_API void aiReleaseExportBlob(const C_STRUCT aiExportDataBlob *pData);
0267 
0268 #ifdef __cplusplus
0269 }
0270 #endif
0271 
0272 #endif // ASSIMP_BUILD_NO_EXPORT
0273 #endif // AI_EXPORT_H_INC