ACloudViewer  3.9.4
A Modern Library for 3D Data Processing
ecvMeshGroup.cpp
Go to the documentation of this file.
1 // ----------------------------------------------------------------------------
2 // - CloudViewer: www.cloudViewer.org -
3 // ----------------------------------------------------------------------------
4 // Copyright (c) 2018-2024 www.cloudViewer.org
5 // SPDX-License-Identifier: MIT
6 // ----------------------------------------------------------------------------
7 
8 #include "ecvMeshGroup.h"
9 
10 // system
11 #include <assert.h>
12 
14  // does nothing
15  return;
16 }
17 
18 bool ccMeshGroup::toFile_MeOnly(QFile& out, short dataVersion) const {
19  CVLog::Error("[Mesh groups are not handled any more!");
20  return false;
21 }
22 
24  return std::max(static_cast<short>(29),
26 }
27 
29  short dataVersion,
30  int flags,
31  LoadedIDMap& oldToNewIDMap) {
32  // Mesh groups are deprecated since version 2.9
33  assert(dataVersion < 29);
34  if (dataVersion >= 29) return false;
35 
36  if (!ccGenericMesh::fromFile_MeOnly(in, dataVersion, flags, oldToNewIDMap))
37  return false;
38 
39  /*** we simply read the data as it was before, so as to be able to read the
40  * other entities from the file! ***/
41 
42  // as the associated cloud (=vertices) can't be saved directly (as it may be
43  // shared by multiple meshes) we only store its unique ID (dataVersion>=20)
44  // --> we hope we will find it at loading time (i.e. this is the
45  // responsibility of the caller to make sure that all dependencies are saved
46  // together)
47  uint32_t vertUniqueID = 0;
48  if (in.read((char*)&vertUniqueID, 4) < 0) return ReadError();
49  //[DIRTY] WARNING: temporarily, we set the vertices unique ID in the
50  //'m_associatedCloud' pointer!!!
51  //*(uint32_t*)(&m_associatedCloud) = vertUniqueID;
52 
53  // per-triangle normals array (dataVersion>=20)
54  {
55  // as the associated normals array can't be saved directly (as it may be
56  // shared by multiple meshes) we only store its unique ID
57  // (dataVersion>=20) --> we hope we will find it at loading time (i.e.
58  // this is the responsibility of the caller to make sure that all
59  // dependencies are saved together)
60  uint32_t normArrayID = 0;
61  if (in.read((char*)&normArrayID, 4) < 0) return ReadError();
62  //[DIRTY] WARNING: temporarily, we set the array unique ID in the
63  //'m_triNormals' pointer!!!
64  //*(uint32_t*)(&m_triNormals) = normArrayID;
65  }
66 
67  // texture coordinates array (dataVersion>=20)
68  {
69  // as the associated texture coordinates array can't be saved directly
70  // (as it may be shared by multiple meshes) we only store its unique ID
71  // (dataVersion>=20) --> we hope we will find it at loading time (i.e.
72  // this is the responsibility of the caller to make sure that all
73  // dependencies are saved together)
74  uint32_t texCoordArrayID = 0;
75  if (in.read((char*)&texCoordArrayID, 4) < 0) return ReadError();
76  //[DIRTY] WARNING: temporarily, we set the array unique ID in the
77  //'m_texCoords' pointer!!!
78  //*(uint32_t*)(&m_texCoords) = texCoordArrayID;
79  }
80 
81  // materials
82  {
83  // as the associated materials can't be saved directly (as it may be
84  // shared by multiple meshes) we only store its unique ID
85  // (dataVersion>=20) --> we hope we will find it at loading time (i.e.
86  // this is the responsibility of the caller to make sure that all
87  // dependencies are saved together)
88  uint32_t matSetID = 0;
89  if (in.read((char*)&matSetID, 4) < 0) return ReadError();
90  //[DIRTY] WARNING: temporarily, we set the array unique ID in the
91  //'m_materials' pointer!!!
92  //*(uint32_t*)(&m_materials) = matSetID;
93  }
94 
95  return true;
96 }
static bool Error(const char *format,...)
Display an error dialog with formatted message.
Definition: CVLog.cpp:143
bool fromFile_MeOnly(QFile &in, short dataVersion, int flags, LoadedIDMap &oldToNewIDMap) override
Loads own object data.
short minimumFileVersion_MeOnly() const override
bool fromFile_MeOnly(QFile &in, short dataVersion, int flags, LoadedIDMap &oldToNewIDMap) override
Loads own object data.
virtual void drawMeOnly(CC_DRAW_CONTEXT &context) override
Enables (OpenGL) stipple mask.
short minimumFileVersion_MeOnly() const override
bool toFile_MeOnly(QFile &out, short dataVersion) const override
Save own object data.
QMultiMap< unsigned, unsigned > LoadedIDMap
Map of loaded unique IDs (old ID --> new ID)
static bool ReadError()
Sends a custom error message (read error) and returns 'false'.
ImGuiContext * context
Definition: Window.cpp:76
Display context.