1 /*
2 Open Asset Import Library (assimp)
3 ----------------------------------------------------------------------
4 
5 Copyright (c) 2006-2017, assimp team
6 
7 All rights reserved.
8 
9 Redistribution and use of this software in source and binary forms,
10 with or without modification, are permitted provided that the
11 following conditions are met:
12 
13 * Redistributions of source code must retain the above
14   copyright notice, this list of conditions and the
15   following disclaimer.
16 
17 * Redistributions in binary form must reproduce the above
18   copyright notice, this list of conditions and the
19   following disclaimer in the documentation and/or other
20   materials provided with the distribution.
21 
22 * Neither the name of the assimp team, nor the names of its
23   contributors may be used to endorse or promote products
24   derived from this software without specific prior
25   written permission of the assimp team.
26 
27 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
28 "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
29 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
30 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
31 OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
32 SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
33 LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
34 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
35 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
36 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
37 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
38 
39 ----------------------------------------------------------------------
40 */
41 
42 /** @file Defines a helper class to evaluate subdivision surfaces.*/
43 #pragma once
44 #ifndef AI_SUBDISIVION_H_INC
45 #define AI_SUBDISIVION_H_INC
46 
47 #include <cstddef>
48 #include <assimp/types.h>
49 
50 struct aiMesh;
51 
52 namespace Assimp    {
53 
54 // ------------------------------------------------------------------------------
55 /** Helper class to evaluate subdivision surfaces. Different algorithms
56  *  are provided for choice. */
57 // ------------------------------------------------------------------------------
58 class ASSIMP_API Subdivider {
59 public:
60 
61     /** Enumerates all supported subvidision algorithms */
62     enum Algorithm  {
63         CATMULL_CLARKE = 0x1
64     };
65 
66     virtual ~Subdivider();
67 
68     // ---------------------------------------------------------------
69     /** Create a subdivider of a specific type
70      *
71      *  @param algo Algorithm to be used for subdivision
72      *  @return Subdivider instance. */
73     static Subdivider* Create (Algorithm algo);
74 
75     // ---------------------------------------------------------------
76     /** Subdivide a mesh using the selected algorithm
77      *
78      *  @param mesh First mesh to be subdivided. Must be in verbose
79      *    format.
80      *  @param out Receives the output mesh, allocated by me.
81      *  @param num Number of subdivisions to perform.
82      *  @param discard_input If true is passed, the input mesh is
83      *    deleted after the subdivision is complete. This can
84      *    improve performance because it allows the optimization
85      *    to reuse the existing mesh for intermediate results.
86      *  @pre out!=mesh*/
87     virtual void Subdivide ( aiMesh* mesh,
88         aiMesh*& out, unsigned int num,
89         bool discard_input = false) = 0;
90 
91     // ---------------------------------------------------------------
92     /** Subdivide multiple meshes using the selected algorithm. This
93      *  avoids erroneous smoothing on objects consisting of multiple
94      *  per-material meshes. Usually, most 3d modellers smooth on a
95      *  per-object base, regardless the materials assigned to the
96      *  meshes.
97      *
98      *  @param smesh Array of meshes to be subdivided. Must be in
99      *    verbose format.
100      *  @param nmesh Number of meshes in smesh.
101      *  @param out Receives the output meshes. The array must be
102      *    sufficiently large (at least @c nmesh elements) and may not
103      *    overlap the input array. Output meshes map one-to-one to
104      *    their corresponding input meshes. The meshes are allocated
105      *    by the function.
106      *  @param discard_input If true is passed, input meshes are
107      *    deleted after the subdivision is complete. This can
108      *    improve performance because it allows the optimization
109      *    of reusing existing meshes for intermediate results.
110      *  @param num Number of subdivisions to perform.
111      *  @pre nmesh != 0, smesh and out may not overlap*/
112     virtual void Subdivide (
113         aiMesh** smesh,
114         size_t nmesh,
115         aiMesh** out,
116         unsigned int num,
117         bool discard_input = false) = 0;
118 
119 };
120 
121 inline
~Subdivider()122 Subdivider::~Subdivider() {
123     // empty
124 }
125 
126 } // end namespace Assimp
127 
128 
129 #endif // !!  AI_SUBDISIVION_H_INC
130 
131