Welcome to mirror list, hosted at ThFree Co, Russian Federation.

triangle_soup_mesh_builder.h « mesh « draco « src « draco « draco « extern - git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 89466e1d849557ae5debe5db9e87809d5b549725 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
// Copyright 2016 The Draco Authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//      http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
#ifndef DRACO_MESH_TRIANGLE_SOUP_MESH_BUILDER_H_
#define DRACO_MESH_TRIANGLE_SOUP_MESH_BUILDER_H_

#include "draco/draco_features.h"
#include "draco/mesh/mesh.h"

namespace draco {

// Class for building meshes directly from attribute values that can be
// specified for each face corner. All attributes are automatically
// deduplicated.
class TriangleSoupMeshBuilder {
 public:
  // Starts mesh building for a given number of faces.
  // TODO(ostava): Currently it's necessary to select the correct number of
  // faces upfront. This should be generalized, but it will require us to
  // rewrite our attribute resizing functions.
  void Start(int num_faces);

  // Adds an empty attribute to the mesh. Returns the new attribute's id.
  int AddAttribute(GeometryAttribute::Type attribute_type,
                   int8_t num_components, DataType data_type);

  // Sets values for a given attribute on all corners of a given face.
  void SetAttributeValuesForFace(int att_id, FaceIndex face_id,
                                 const void *corner_value_0,
                                 const void *corner_value_1,
                                 const void *corner_value_2);

  // Sets value for a per-face attribute. If all faces of a given attribute are
  // set with this method, the attribute will be marked as per-face, otherwise
  // it will be marked as per-corner attribute.
  void SetPerFaceAttributeValueForFace(int att_id, FaceIndex face_id,
                                       const void *value);

  // Finalizes the mesh or returns nullptr on error.
  // Once this function is called, the builder becomes invalid and cannot be
  // used until the method Start() is called again.
  std::unique_ptr<Mesh> Finalize();

 private:
  std::vector<int8_t> attribute_element_types_;

  std::unique_ptr<Mesh> mesh_;
};

}  // namespace draco

#endif  // DRACO_MESH_TRIANGLE_SOUP_MESH_BUILDER_H_