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(); }
228 KeyArray
const & key_path,
229 std::string
const & materialMappingKit,
234 KeyArray
const & key_path,
236 std::string
const & localMaterialMappingKit,
241 KeyArray
const & key_path,
242 std::string
const & materialMappingKit,
245 HC_KEY modelBuilderScratchSegment;
257 NetClipRegions() : loops_array(), spaces(), operations(), clip_region_key() {}
260 using ClipRegionArray = std::vector<PointArray>;
262 ClipRegionArray loops_array;
264 StringArray operations;
265 mutable SC::Store::ClipRegionKey clip_region_key;
270 bool operator() (SC::Store::Matrix3d
const & matrix1, SC::Store::Matrix3d
const & matrix2)
const;
275 size_t operator() (SC::Store::Matrix3d
const & matrix)
const;
280 size_t operator() (SC::Store::MaterialKeys
const & materialMap)
const;
284 size_t KeyHasher(
const HC_KEY & key)
const
286 size_t hash = (size_t)key;
287 hash = (hash ^ 61) ^ (hash >> 16);
288 hash = hash + (hash << 3);
289 hash = hash ^ (hash >> 4);
290 hash = hash * 0x27d4eb2d;
291 hash = hash ^ (hash >> 15);
295 size_t operator() (std::tuple<HC_KEY, PolygonHandedness, Visibility>
const & tuple)
const {
296 return KeyHasher(std::get<0>(tuple)) +
static_cast<size_t>(std::get<1>(tuple)) +
static_cast<uint32_t
>(std::get<2>(tuple));
302 size_t operator() (RGBColor
const & color)
const;
306 Visibility geometryVisibility;
307 Visibility lightingVisibility;
312 typedef std::vector<RGBA32Color> RGBA32ColorArray;
319 SC::Store::Logger & logger,
320 SC::Store::Model & model,
321 SC::Store::InclusionKey inclusionKey,
333 void UpdateBySegPath(
GrownKeyPath const & segPath,
HC_KEY segKey,
bool followReferences);
335 void FollowReference(
345 void TryInsertBatchedMeshes(
346 KeyArray
const & keyPath,
350 Visibility visibility,
351 Visibility lightingVisibility,
352 PolygonHandedness polygonHandedness,
356 KeyArray
const & keyPath,
363 std::string
const * localMaterialMappingKit,
364 Visibility visibility,
365 Visibility lightingVisibility,
366 PolygonHandedness polygonHandedness,
374 KeyArray
const & keyPath,
375 Visibility visibility,
376 PolygonHandedness polygonHandedness);
378 SC::Store::MeshKey ObtainMeshKey(
379 Visibility visibility,
384 KeyArray
const & keyPath,
385 PolygonHandedness polygonHandedness,
386 Visibility & usedVisibilities,
389 SC::Store::ImageKey ObtainImageKey(
HC_KEY imageKey);
390 SC::Store::MatrixKey ObtainMatrixKey(Matrix
const & matrixKit);
391 SC::Store::MaterialKey ObtainMaterialKey(
SimpleMaterial const & material, KeyArray
const & keyPath);
392 SC::Store::MaterialMapKey ObtainMaterialMapKey(SC::Store::MaterialKeys && materialMap);
394 SC::Store::Mesh * CreateShellWireframeMesh(
395 Visibility visibility,
398 PointArray
const & points,
399 std::vector<Line>
const & lines,
400 PolygonHandedness polygonHandedness);
402 SC::Store::Mesh * CreateLineMesh(
403 Visibility visibility,
405 PolygonHandedness polygonHandedness);
407 SC::Store::Mesh * CreateShellMesh(
408 Visibility visibility,
411 KeyArray
const & keyPath,
412 PolygonHandedness polygonHandedness);
414 SC::Store::Mesh * CreateTextMesh(
418 PolygonHandedness polygonHandedness);
420 SC::Store::Mesh * CreateMesh(
421 Visibility visibility,
426 KeyArray
const & keyPath,
427 PolygonHandedness polygonHandedness,
430 SC::Store::Mesh * CreateMassagedMesh(
431 Visibility visibility,
436 KeyArray
const & keyPath,
437 PolygonHandedness polygonHandedness);
439 VectorArray GetShellVertexNormals(
HC_KEY shellKey);
441 FloatArray GetShellVertexUVs(
HC_KEY shellKey);
443 RGBA32ColorArray GetVertexColors(
446 std::string component);
449 SC::Store::Material & faceMaterial,
450 std::string
const & textureDefinition,
451 KeyArray
const & keyPath);
453 SC::Store::MaterialKey InsertMaterial(
SimpleMaterial const & material, KeyArray
const & keyPath);
454 SC::Store::MatrixKey InsertMatrix(SC::Store::Matrix3d
const & matrix);
455 SC::Store::MeshKey InsertMesh(SC::Store::Mesh
const & mesh);
456 SC::Store::MaterialMapKey InsertMaterialMap(SC::Store::MaterialKeys
const & materialMap);
458 SC::Store::InstanceKey Instance(
459 SC::Store::MeshKey meshKey,
460 SC::Store::MatrixKey matrixKey,
462 Visibility visibility,
463 Visibility lightingVisibility,
466 KeyArray
const & keyPath);
468 void CanonicalizeElementIndexMapping(
469 SC::Store::MaterialKeys & materialMap,
470 std::vector<size_t> & faceToElementIndex);
472 std::vector<size_t> ObtainFaceToElementIndexMapping(
473 KeyArray
const & keyPath,
475 SC::Store::Mesh & mesh);
477 MeshEnvironment & ObtainCompatibleBatchedMesh(SC::Store::Mesh
const & overlayMesh,
bool isText);
478 void MergeIntoBatchedMesh(SC::Store::Mesh & overlayMesh,
bool isText);
479 void MergeSegmentLines(
HC_KEY & segKey);
481 SC::Store::Mesh & MeshFromCache(PolygonHandedness polygonHandedness);
482 void MeshElementsFromCache(std::vector<SC::Store::MeshElement> & meshElements,
size_t count);
483 void ReleaseToCache(SC::Store::Mesh & mesh);
484 void ReleaseToCache(std::vector<SC::Store::MeshElement> & meshElements);
485 void FinalizeTableDataKey();
493 SC::Store::Logger & logger;
494 SC::Store::Model & model;
495 SC::Store::InclusionKey inclusionKey;
499 std::unique_ptr<SC::Store::AssemblyTree> assemblyTree;
500 std::vector<Lazy<uint32_t>> assemblyTreePath;
501 std::unordered_map<HC_KEY, unsigned> generatedSegmentNameIds;
503 std::vector<MeshEnvironment> batchedMeshEnvironments;
504 std::unordered_set<HC_KEY> batchedLines;
505 std::vector<HC_KEY> createdShells;
507 SC::Store::Mesh cachedMesh;
508 std::vector<SC::Store::MeshElement> cachedMeshElements;
509 std::vector<size_t> cachedIndices1;
510 std::vector<size_t> cachedIndices2;
512 PointArray pointBuffer;
513 VectorArray vertexNormalBuffer;
514 FloatArray vertexUVBuffer;
515 RGBA32ColorArray vertexColorBuffer;
517 std::unordered_map<SimpleMaterial, SC::Store::MaterialKey, SimpleMaterialHasher> seenMaterials;
518 std::unordered_map<SC::Store::Matrix3d, SC::Store::MatrixKey, MatrixHasher, MatrixEq> seenMatrices;
519 std::unordered_map<HC_KEY, SC::Store::ImageKey> seenImages;
520 std::unordered_map<SC::Store::MaterialKeys, SC::Store::MaterialMapKey, MaterialKeysHasher> seenMaterialMaps;
523 std::tuple<HC_KEY, PolygonHandedness, Visibility>,
524 std::pair<SC::Store::MeshKey, Visibility>,
528 std::tuple<HC_KEY, PolygonHandedness, Visibility>,
529 std::vector<std::pair<SC::Store::MeshKey, Visibility>>,
532 std::vector<std::pair<MeshStatistics, MeshType>> meshesStats;
534 SC::Store::DataKey tableDataKey;
535 std::vector<std::pair<SC::Store::MeshKey, SC::Store::DataKey>> pendingDataKeys;
537 SC::Store::InstanceKey lastGeneratedInstanceKey;
541 std::string driverPath;
542 std::unordered_map<std::string, bool> fontOutlineability;
Definition: ModelBuilder.h:220
Definition: ModelBuilder.h:197
Definition: ModelBuilder.h:310
Definition: ModelBuilder.h:122
Definition: ModelBuilder.h:112
Definition: HDWFMisc.h:22
Definition: ModelBuilder.h:157
Definition: ModelBuilder.h:300
HOutputHandler an abstract base class for model and image output.
Definition: HIOManager.h:1247
Definition: ModelBuilder.h:215
Definition: ModelBuilder.h:282
Definition: ModelBuilder.h:47
Definition: GrownKeyPath.h:7
Definition: HIOManager.h:892
Definition: ModelBuilder.h:305
Definition: ModelBuilder.h:268
Definition: ModelBuilder.h:278
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:254
Definition: ModelBuilder.h:90
Definition: ModelBuilder.h:273