3 #include <unordered_map>
4 #include <unordered_set>
6 #include "HIOUtilityHTML.h"
7 #include "GrownKeyPath.h"
12 #include "sc_store_utils.h"
13 #include "sc_store_utils_text.h"
14 #include "sc_assemblytree.h"
16 namespace hio_html_internal
24 static void ReportProgress(std::string
const & message);
25 static void ReportProgress(
float percent);
31 static inline unsigned char unit_to_byte(
float const & a)
33 uint32_t v = extract_uint32_t(a);
41 uint32_t exp = v >> 23;
42 uint32_t man = (v & 0x007FFFFF) | 0x00800000;
44 return (
unsigned char)(man >> (16 + 126 - exp));
54 r = unit_to_byte(c[0]);
55 g = unit_to_byte(c[1]);
56 b = unit_to_byte(c[2]);
57 a = unit_to_byte(c[3]);
62 r = unit_to_byte(c[0]);
63 g = unit_to_byte(c[1]);
64 b = unit_to_byte(c[2]);
82 enum class MaterialType : char
101 void PatchMeshPointers();
102 bool IsValid()
const;
104 SC::Store::Mesh mesh;
106 std::vector<SC::Store::Point> points;
107 std::vector<SC::Store::Normal> normals;
108 std::vector<SC::Store::UV> uvs;
109 std::vector<SC::Store::RGBA32> rgba32s;
117 size_t triangleCount;
118 size_t polylineCount;
119 size_t freePointCount;
124 virtual void Message(
const char * message)
const
126 printf(
"%s\n", message);
135 size_t instanceCount;
137 size_t uniqueFaceMeshCount;
138 size_t uniqueLineMeshCount;
139 size_t uniquePointMeshCount;
140 size_t uniqueMiscMeshCount;
141 size_t uniqueImageCount;
143 size_t faceMeshCount;
144 size_t lineMeshCount;
145 size_t pointMeshCount;
146 size_t miscMeshCount;
149 enum class Visibility : uint32_t {
160 enum class Batching {
169 std::function<bool(HC_KEY)> assemblyTreeGenerateChild;
171 SC::Store::Color defaultColor;
173 bool excludeInvisibleGeometry;
175 bool excludeVertexNormals;
176 bool excludeVertexUVs;
177 bool excludeVertexColors;
178 bool generateImplicitEdges;
181 bool storeGeometryUserData;
182 bool forceCounterClockwiseWinding;
183 bool groupAllMeshInstances;
184 bool generateAssemblyTree;
185 bool markMeshesAsManifold;
188 enum class PolygonHandedness : size_t
202 SimpleMaterial(SC::Store::Color
const & color,
float mirror,
float specular,
float gloss, std::string texture);
208 SC::Store::Color color;
217 size_t operator() (
SimpleMaterial const & material)
const {
return material.Hash(); }
227 KeyArray
const & key_path,
228 std::string
const & materialMappingKit,
232 KeyArray
const & key_path,
234 std::string
const & localMaterialMappingKit,
239 KeyArray
const & key_path,
240 std::string
const & materialMappingKit,
253 NetClipRegions() : loops_array(), spaces(), operations(), clip_region_key() {}
256 using ClipRegionArray = std::vector<PointArray>;
258 ClipRegionArray loops_array;
260 StringArray operations;
261 mutable SC::Store::ClipRegionKey clip_region_key;
266 bool operator() (SC::Store::Matrix3d
const & matrix1, SC::Store::Matrix3d
const & matrix2)
const;
271 size_t operator() (SC::Store::Matrix3d
const & matrix)
const;
276 size_t operator() (SC::Store::MaterialKeys
const & materialMap)
const;
280 size_t KeyHasher(
const HC_KEY & key)
const
282 size_t hash = (size_t)key;
283 hash = (hash ^ 61) ^ (hash >> 16);
284 hash = hash + (hash << 3);
285 hash = hash ^ (hash >> 4);
286 hash = hash * 0x27d4eb2d;
287 hash = hash ^ (hash >> 15);
291 size_t operator() (std::tuple<HC_KEY, PolygonHandedness, Visibility>
const & tuple)
const {
292 return KeyHasher(std::get<0>(tuple)) +
static_cast<size_t>(std::get<1>(tuple)) +
static_cast<uint32_t
>(std::get<2>(tuple));
298 size_t operator() (RGBColor
const & color)
const;
302 Visibility geometryVisibility;
303 Visibility lightingVisibility;
308 typedef std::vector<RGBA32Color> RGBA32ColorArray;
315 SC::Store::Logger & logger,
316 SC::Store::Model & model,
317 SC::Store::InclusionKey inclusionKey,
329 void UpdateBySegPath(
GrownKeyPath const & segPath,
HC_KEY segKey,
bool followReferences);
331 void FollowReference(
341 void TryInsertBatchedMeshes(
342 KeyArray
const & keyPath,
346 Visibility visibility,
347 Visibility lightingVisibility,
348 PolygonHandedness polygonHandedness,
352 KeyArray
const & keyPath,
359 std::string
const * localMaterialMappingKit,
360 Visibility visibility,
361 Visibility lightingVisibility,
362 PolygonHandedness polygonHandedness,
370 KeyArray
const & keyPath,
371 Visibility visibility,
372 PolygonHandedness polygonHandedness);
374 SC::Store::MeshKey ObtainMeshKey(
375 Visibility visibility,
380 KeyArray
const & keyPath,
381 PolygonHandedness polygonHandedness,
382 Visibility & usedVisibilities,
385 SC::Store::ImageKey ObtainImageKey(
HC_KEY imageKey);
386 SC::Store::MatrixKey ObtainMatrixKey(Matrix
const & matrixKit);
387 SC::Store::MaterialKey ObtainMaterialKey(
SimpleMaterial const & material, KeyArray
const & keyPath);
388 SC::Store::MaterialMapKey ObtainMaterialMapKey(SC::Store::MaterialKeys && materialMap);
390 SC::Store::Mesh * CreateShellWireframeMesh(
391 Visibility visibility,
394 PointArray
const & points,
395 std::vector<Line>
const & lines,
396 PolygonHandedness polygonHandedness);
398 SC::Store::Mesh * CreateLineMesh(
399 Visibility visibility,
401 PolygonHandedness polygonHandedness);
403 SC::Store::Mesh * CreateShellMesh(
404 Visibility visibility,
407 KeyArray
const & keyPath,
408 PolygonHandedness polygonHandedness);
410 SC::Store::Mesh * CreateTextMesh(
414 PolygonHandedness polygonHandedness);
416 SC::Store::Mesh * CreateMesh(
417 Visibility visibility,
422 KeyArray
const & keyPath,
423 PolygonHandedness polygonHandedness,
426 SC::Store::Mesh * CreateMassagedMesh(
427 Visibility visibility,
432 KeyArray
const & keyPath,
433 PolygonHandedness polygonHandedness);
435 VectorArray GetShellVertexNormals(
HC_KEY shellKey);
437 FloatArray GetShellVertexUVs(
HC_KEY shellKey);
439 RGBA32ColorArray GetVertexColors(
442 std::string component);
445 SC::Store::Material & faceMaterial,
446 std::string
const & textureDefinition,
447 KeyArray
const & keyPath);
449 SC::Store::MaterialKey InsertMaterial(
SimpleMaterial const & material, KeyArray
const & keyPath);
450 SC::Store::MatrixKey InsertMatrix(SC::Store::Matrix3d
const & matrix);
451 SC::Store::MeshKey InsertMesh(SC::Store::Mesh
const & mesh);
452 SC::Store::MaterialMapKey InsertMaterialMap(SC::Store::MaterialKeys
const & materialMap);
454 SC::Store::InstanceKey Instance(
455 SC::Store::MeshKey meshKey,
456 SC::Store::MatrixKey matrixKey,
458 Visibility visibility,
459 Visibility lightingVisibility,
462 KeyArray
const & keyPath);
464 void CanonicalizeElementIndexMapping(
465 SC::Store::MaterialKeys & materialMap,
466 std::vector<size_t> & faceToElementIndex);
468 std::vector<size_t> ObtainFaceToElementIndexMapping(
469 KeyArray
const & keyPath,
471 SC::Store::Mesh & mesh);
473 MeshEnvironment & ObtainCompatibleBatchedMesh(SC::Store::Mesh
const & overlayMesh,
bool isText);
474 void MergeIntoBatchedMesh(SC::Store::Mesh & overlayMesh,
bool isText);
475 void MergeSegmentLines(
HC_KEY & segKey);
477 SC::Store::Mesh & MeshFromCache(PolygonHandedness polygonHandedness);
478 void MeshElementsFromCache(std::vector<SC::Store::MeshElement> & meshElements,
size_t count);
479 void ReleaseToCache(SC::Store::Mesh & mesh);
480 void ReleaseToCache(std::vector<SC::Store::MeshElement> & meshElements);
481 void FinalizeTableDataKey();
489 SC::Store::Logger & logger;
490 SC::Store::Model & model;
491 SC::Store::InclusionKey inclusionKey;
495 std::unique_ptr<SC::Store::AssemblyTree> assemblyTree;
496 std::vector<Lazy<uint32_t>> assemblyTreePath;
497 std::unordered_map<HC_KEY, unsigned> generatedSegmentNameIds;
499 std::vector<MeshEnvironment> batchedMeshEnvironments;
500 std::unordered_set<HC_KEY> batchedLines;
501 std::vector<HC_KEY> createdShells;
503 SC::Store::Mesh cachedMesh;
504 std::vector<SC::Store::MeshElement> cachedMeshElements;
505 std::vector<size_t> cachedIndices1;
506 std::vector<size_t> cachedIndices2;
508 PointArray pointBuffer;
509 VectorArray vertexNormalBuffer;
510 FloatArray vertexUVBuffer;
511 RGBA32ColorArray vertexColorBuffer;
513 std::unordered_map<SimpleMaterial, SC::Store::MaterialKey, SimpleMaterialHasher> seenMaterials;
514 std::unordered_map<SC::Store::Matrix3d, SC::Store::MatrixKey, MatrixHasher, MatrixEq> seenMatrices;
515 std::unordered_map<HC_KEY, SC::Store::ImageKey> seenImages;
516 std::unordered_map<SC::Store::MaterialKeys, SC::Store::MaterialMapKey, MaterialKeysHasher> seenMaterialMaps;
519 std::tuple<HC_KEY, PolygonHandedness, Visibility>,
520 std::pair<SC::Store::MeshKey, Visibility>,
524 std::tuple<HC_KEY, PolygonHandedness, Visibility>,
525 std::vector<std::pair<SC::Store::MeshKey, Visibility>>,
528 std::vector<std::pair<MeshStatistics, MeshType>> meshesStats;
530 SC::Store::DataKey tableDataKey;
531 std::vector<std::pair<SC::Store::MeshKey, SC::Store::DataKey>> pendingDataKeys;
533 SC::Store::InstanceKey lastGeneratedInstanceKey;
537 std::string driverPath;
538 std::unordered_map<std::string, bool> fontOutlineability;
Definition: ModelBuilder.h:220
Definition: ModelBuilder.h:197
Definition: ModelBuilder.h:306
Definition: ModelBuilder.h:122
Definition: ModelBuilder.h:112
Definition: HDWFMisc.h:22
Definition: ModelBuilder.h:157
Definition: ModelBuilder.h:296
HOutputHandler an abstract base class for model and image output.
Definition: HIOManager.h:1220
Definition: ModelBuilder.h:215
Definition: ModelBuilder.h:278
Definition: ModelBuilder.h:47
Definition: GrownKeyPath.h:7
Definition: HIOManager.h:865
Definition: ModelBuilder.h:301
Definition: ModelBuilder.h:264
Definition: ModelBuilder.h:274
Definition: ModelBuilder.h:18
A class used to denote a line segment by its front and back indices.
Definition: Line.h:8
Definition: ModelBuilder.h:130
Definition: ModelBuilder.h:250
Definition: ModelBuilder.h:90
Definition: ModelBuilder.h:269