API Documentation
Loading...
Searching...
No Matches
EntityConverter.h
Go to the documentation of this file.
1/**--------------------------------------------------------------------------------------------
2Copyright (c) 2019, NDEVR LLC
3tyler.parke@ndevr.org
4 __ __ ____ _____ __ __ _______
5 | \ | | | __ \ | ___|\ \ / / | __ \
6 | \ | | | | \ \ | |___ \ \ / / | |__) |
7 | . \| | | |__/ / | |___ \ V / | _ /
8 | |\ |_|_____/__|_____|___\_/____| | \ \
9 |__| \__________________________________| \__\
10
11Subject to the terms of the Enterprise+ Agreement, NDEVR hereby grants
12Licensee a limited, non-exclusive, non-transferable, royalty-free license
13(without the right to sublicense) to use the API solely for the purpose of
14Licensee's internal development efforts to develop applications for which
15the API was provided.
16
17The above copyright notice and this permission notice shall be included in all
18copies or substantial portions of the Software.
19
20THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
21INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
22PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
23FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
24OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
25DEALINGS IN THE SOFTWARE.
26
27Library: CAD
28File: EntityConverter
29Included in API: True
30Author(s): Tyler Parke
31 *-----------------------------------------------------------------------------------------**/
32#pragma once
42#include "Design/Headers/Text.h"
44#include "Base/Headers/RWLock.h"
48namespace NDEVR
49{
50 static ConstPointer<Unit> ConvertFromCADUnit(uint04 cad_unit)
51 {
52 switch (cad_unit)
53 {
54 case 0: return ConstPointer<Unit>();//No units
55 case 1: return UnitDefinitions::Inches(); break;
56 case 2: return UnitDefinitions::Feet(); break;
57#if NDEVR_EXOTIC_UNITS
58 case 3: return UnitDefinitions::InternationalMiles(); break;
59 case 8: return UnitDefinitions::Microinches(); break;
60 case 9: return UnitDefinitions::Mils(); break;
61 case 11: return UnitDefinitions::Angstrom(); break;
62 case 12: return UnitDefinitions::Nanometers(); break;
63 case 13: return UnitDefinitions::Microns(); break;
64 case 14: return UnitDefinitions::Decimeters(); break;
65 case 15: return UnitDefinitions::Dekameters(); break;
66 case 16: return UnitDefinitions::Hectometers(); break;
67 case 17: return UnitDefinitions::Gigameters(); break;
68 case 18: return UnitDefinitions::AstronomicalUnits(); break;
69 case 19: return UnitDefinitions::LightYears(); break;
70 case 20: return UnitDefinitions::Parsecs(); break;
71#endif
72 case 4: return UnitDefinitions::Millimeters(); break;
73 case 5: return UnitDefinitions::Centimeters(); break;
74 case 6: return UnitDefinitions::Meters(); break;
75 case 7: return UnitDefinitions::Kilometers(); break;
76 case 10: return UnitDefinitions::Yards(); break;
77
78 default: lib_assert(false, "Unknown unit"); return ConstPointer<Unit>();
79 }
80 }
81 /*static uint04 ConvertToCADUnit(const ConstPointer<Unit>& cad_unit)
82 {
83 switch (cad_unit->name.hashLower())
84 {
85 default: return 0;
86 case String::hash("inches"): return 1;
87 case String::hash("feet"): return 2;
88 case String::hash("international miles"): return 3;
89 case String::hash("millimeters"): return 4;
90 case String::hash("centimeters"): return 5;
91 case String::hash("meters"): return 6;
92 case String::hash("kilometers"): return 7;
93 case String::hash("microinches"): return 8;
94 case String::hash("mils"): return 9;
95 case String::hash("yards"): return 10;
96 case String::hash("angstroms"): return 11;
97 case String::hash("nanometers"): return 12;
98 case String::hash("microns"): return 13;
99 case String::hash("decimeters"): return 14;
100 case String::hash("dekameters"): return 15;
101 case String::hash("hectometers"): return 16;
102 case String::hash("gigameters"): return 17;
103 case String::hash("astronomical_units"): return 18;
104 case String::hash("light_years"): return 19;
105 case String::hash("parsecs"): return 20;
106 }
107 }*/
130
131 class CADMeshVertexAttributeSetter : public VertexIterator<Vertex<3, fltp04>>
132 {
133 public:
134 CADMeshVertexAttributeSetter(VertexProperty vert_property, const Geometry& geo, const void* lock_ptr)
135 : VertexIterator<Vertex<3, fltp04>>(vert_property, geo)
137 {}
154 const void* lock_ptr;
155 };
157 {
158 public:
159 CADMeshVertexColorSetter(VertexProperty vert_property, const Geometry& geo, const void* lock_ptr)
160 : VertexIterator<RGBColor>(vert_property, geo)
162 {}
164 {
165 finish();
166 }
177 RGBColor vertex = RGBColor(255, 255, 255, 255);
179 const void* lock_ptr;
180 };
181
183 {
184 public:
185 EntityConverter(const File& relative_path, DesignObjectLookup* lookup, ProgressInfo* logger)
186 : CADEntityStreamer(logger)
187 , m_core_root(Constant<UUID>::NaN)
194 , m_model_lookup(lookup)
196 , m_relative_path(relative_path)
197 {}
199 {
200 m_handle_manager = handle_manager;
201 }
203 {
205 delete m_mesh_color_setter;
206 }
207 /*virtual void processCodeValuePair(unsigned int, const String& s) override
208 {
209 //int i = s.getAs<int>();
210 if(m_log_features) m_logger.addMessage("Code Value Pair");
211 }*/
213 {
216 mode = ColorMode::e_use;
218 {
219 Material mat = getMaterial();
224 }
225 else
226 {
227 switch (mode)
228 {
231 break;
234 break;
236 case ColorMode::e_use:
237 {
238 Material mat;
241 else
242 mat = getMaterial();
244 {
247 }
249 {
252 }
253 else
254 {
257 }
262
263 } break;
264 }
265 }
267
268 }
270 {
272 const bool using_tri_mesh = m_quad_position_data.size() == 0;
273 Geometry mesh = using_tri_mesh ? currentTriMesh() : currentPolyMesh();
274 Vector<3, fltp08> coord_offset(0.0);
275 if (mesh.vertexCount() == 0)
276 {
277 if(m_quad_position_data.size() > 0)
278 coord_offset = m_quad_position_data[0].as<3, fltp08>();
279 else if (m_tri_position_data.size() > 0)
280 coord_offset = m_tri_position_data[0].as<3, fltp08>();
281 if (distanceSquared(coord_offset, Vector<3, fltp08>(0.0)) > 1000 * 1000)
282 {
283 for (uint04 i = 0; i < m_quad_position_data.size(); i++)
284 m_quad_position_data[i] -= coord_offset;
285 for (uint04 i = 0; i < m_tri_position_data.size(); i++)
286 m_tri_position_data[i] -= coord_offset;
287 mesh.offset(coord_offset);
288
289 }
290 }
291 bool using_color = m_quad_color_data.size() > 0 || m_tri_color_data.size() > 0;
292 const uint04 quad_index_size = m_quad_position_data.size() / 4;
293 const uint04 tri_index_size = m_tri_position_data.size() / 3;
294 uint04 index_offset = using_tri_mesh ? mesh.addPrimitives(PrimitiveProperty::Outline, tri_index_size) : mesh.addPrimitives(PrimitiveProperty::Outline, 6 * quad_index_size + 4 * tri_index_size);
295 uint04 vertex_offset = mesh.addVertices(m_quad_position_data.size() + m_tri_position_data.size()) + mesh.vertexOffset();
296 Geometry::OptimizedPrimitiveDef primitive_setter = mesh.optimizedPrimitiveDef(PrimitiveProperty::Outline);
297
298 if (m_quad_position_data.size() > 0)
299 {
301 if(using_color)
303 for (uint04 i = 0; i < quad_index_size; i++)
304 {
305 for (uint04 n = 0; n < 4; n++)
306 Geometry::OptimizedSetPrimitive(primitive_setter, index_offset + 6 * i + n, vertex_offset + 4 * i + n);
307
308 Geometry::OptimizedSetPrimitive(primitive_setter, index_offset + 6 * i + 4U, vertex_offset + 4 * i + 0);
309 Geometry::OptimizedSetPrimitive(primitive_setter, index_offset + 6 * i + 5U, Constant<uint04>::NaN);
310 }
311 index_offset += quad_index_size * 6;
312 vertex_offset += m_quad_position_data.size();
313 }
314 if (m_tri_position_data.size() > 0)
315 {
317 if(using_color)
319 for (uint04 i = 0; i < tri_index_size; i++)
320 {
321 if (using_tri_mesh)
322 {
323 Geometry::OptimizedSetPrimitiveVec(primitive_setter, index_offset + i, Vector<3, uint04>(
324 vertex_offset + 3 * i + A
325 , vertex_offset + 3 * i + B
326 , vertex_offset + 3 * i + C));
327 }
328 else
329 {
330 for (uint04 n = 0; n < 3; n++)
331 Geometry::OptimizedSetPrimitive(primitive_setter, index_offset + 4 * i + n, vertex_offset + 3 * i + n);
332 Geometry::OptimizedSetPrimitive(primitive_setter, index_offset + 4 * i + 3U, Constant<uint04>::NaN);
333 }
334 }
335 }
336 m_quad_position_data.clear();
338 m_tri_position_data.clear();
340 lib_assert(mesh.validate(), "invalid geometry");
341 }
342 void endSection() final override
343 {
344 switch (m_current_mode)
345 {
349 break;
350 default:
351 break;
352 }
353
356 {
358 m_mesh_attribute_setter = nullptr;
359 }
361 {
362 delete m_mesh_color_setter;
363 m_mesh_color_setter = nullptr;
364 }
365 Geometry geo;
367 {
368 geo = m_current_points;
370 }
371 else if (m_current_linework.isValid())
372 {
373 geo = m_current_linework;
375 {
376 if (!isNaN(m_next_bulge) && m_next_bulge != 0.0)
377 {
378 uint04 vertex_count = geo.vertexCount();
379 //lib_assert(vertex_count > 1, "Bad vertex count");
380 if (vertex_count > 1)
381 {
384 addBulge(geo, m_next_bulge, p1, p2);
385 }
386 else
387 {
388 m_logger.addMessage(LogMessage(_t("Unexpected empty closed polyline"),LogMessage::e_warning));
389 }
391 }
392 else
393 {
395 }
396 }
398 {
399 //geo.add
400 }
401 //lib_assert(currentEntity().globalBounds().span()[Z] < 100.0, "Bad bounds");
403 }
404
405 else if (m_current_mesh.isValid())
406 {
407 geo = m_current_mesh;
409 }
411 lib_assert(!m_current_points.isValid(), "Bad valid");
412 lib_assert(!m_current_linework.isValid(), "Bad valid");
413 lib_assert(!m_current_mesh.isValid(), "Bad valid");
414 if (geo.isValid())
415 {
419 geo.updateModifiedTime();
420 lib_assert(geo.validate(), "invalid geometry");
421 if (!m_model_lookup->hasGeometryID(geo.uuid()))
425 }
429 m_color_by_vertex = false;
431 }
433 {
434 return m_unit;
435 }
437 {
439 {
441 }
442 else
443 {
445
446 m_materials_read.add(mat.uuid());
448 return mat;
449 }
450 }
451 void addLayer(const LayerData& layer) final override
452 {
453 lib_assert(!m_layers.hasKey(layer.name), "Duplicate layer added");
454 m_current_data = static_cast<EntityData>(layer);
455 _addLayer(layer);
456
457 }
458 void _addLayer(const LayerData& layer_data)
459 {
460 if(m_layers.hasKey(layer_data.name))
461 {
462 m_logger.addMessage(LogMessage(_td("dxf_duplicate_layer", "Unexpected duplicate layer").translation() +": "+ layer_data.name, LogMessage::e_warning));
463 return;
464 }
465 //lib_assert(!m_handle_manager->hasHandleIndex(layer_data.name), "Duplicate layer added");
466 if(!isNaN(layer_data.handle))
467 m_handle_manager->setHandleIndex(layer_data.name, layer_data.handle);
468
469
471 Model layer = getLayer(layer_data.name);
472 Material mat;
474 {
475 mat = generateNewMaterial();
478 }
479 else
480 {
482 }
484 {
485 case ColorMode::e_use:
493 break;
499 break;
500 }
503
505 //!layer_data.flags[LayerData::e_frozen] &&
506 layer.setDesignVisible(layer_data.visible && !layer_data.is_off);
507 layer.updateModifiedTime();
508 m_layers.add(layer_data.name, layer.uuid());
509
510
511 }
512 String convertFromCADName(const String& file_name, const TranslatedString& object_type, uint04 object_count)
513 {
514 String name;
515 if (!file_name.beginsWith("__unnamed__"))
516 name = file_name;
517 if (m_auto_name_objects && name.size() == 0)
518 {
519 TranslatedString cad_auto_name = _td("cad_auto_name", "[name]-[count]");
520 cad_auto_name.replace("[name]", object_type);
521 cad_auto_name.replace("[count]", String(object_count + 1));
522 name = String(cad_auto_name);
523 }
524 return name;
525 }
526
527 void addDictionary(const CADDictionaryObject& dictionary) override
528 {
529 if (m_mesh_object_dictionary_listeners.hasKey(dictionary.handle))
530 {
531 UUID geo_id = m_mesh_object_dictionary_listeners.get(dictionary.handle);
532 for (const CADVariable& iter : dictionary.data)
533 {
534 switch (iter.label.hash())
535 {
536 case String::hash("ADSK_XREC_SUBDVERTEXNORMALS"):
537 m_mesh_object_field_listeners.add(iter.values.last().second.getAs<uint04>(), { geo_id , VertexProperty::Normal});
538 break;
539 case String::hash("ADSK_XREC_SUBDVERTEXTEXCOORDS"):
540 m_mesh_object_field_listeners.add(iter.values.last().second.getAs<uint04>(), { geo_id , VertexProperty::Texture });
541 break;
542 case String::hash("ADSK_XREC_SUBDVERTEXCOLORS"):
543 m_mesh_object_color_listeners.add(iter.values.last().second.getAs<uint04>(), { geo_id , VertexProperty::Color });
544 break;
545 }
546 }
547 }
548 }
549
550 void addXRecord(const HandleData& record) override
551 {
553 return;
554 if (m_mesh_object_field_listeners.hasKey(record.handle))
555 {
557 VertexProperty vert_property = m_mesh_object_field_listeners.get(record.handle).second;
561 m_xdata_callback = [this](uint04 value, DXFValueManager* value_manager)
562 {
563 switch (value)
564 {
565 case 40: m_mesh_attribute_setter->vertex[X] = value_manager->getValue<40>(0.0f); break;
566 case 41: m_mesh_attribute_setter->vertex[Y] = value_manager->getValue<41>(0.0f); break;
567 case 42: m_mesh_attribute_setter->vertex[Z] = value_manager->getValue<42>(0.0f);
569 break;
570 case 43: m_mesh_attribute_setter->vertex[X] = value_manager->getValue<43>(0.0f); break;
571 case 44: m_mesh_attribute_setter->vertex[Y] = value_manager->getValue<44>(0.0f); break;
572 case 45: m_mesh_attribute_setter->vertex[Z] = value_manager->getValue<45>(0.0f);
574 break;
575 }
576 };
577 }
578 else if (m_mesh_object_color_listeners.hasKey(record.handle))
579 {
581 VertexProperty vert_property = m_mesh_object_color_listeners.get(record.handle).second;
582 delete m_mesh_color_setter;
585
586
587 m_xdata_callback = [this](uint04 value, DXFValueManager* value_manager)
588 {
589 switch (value)
590 {
591 case 70: m_mesh_color_setter->vertex[RGBColor::r_pos] = value_manager->getValue<70>(0U); break;
592 case 71: m_mesh_color_setter->vertex[RGBColor::g_pos] = value_manager->getValue<71>(0U); break;
593 case 72: m_mesh_color_setter->vertex[RGBColor::b_pos] = value_manager->getValue<72>(0U);
595 break;
596 }
597 };
599 Buffer<Model> parents = geo.getParents();
600 for (Model& model : parents)
601 {
602
604 ? model.getMaterial(PrimitiveProperty::Solid) : model.createChildMaterial(PrimitiveProperty::Solid);
607 solid_material.updateModifiedTime();
608
609 if (model.hasMaterial(PrimitiveProperty::Outline))
610 {
611 Material outine_material = model.getMaterial(PrimitiveProperty::Outline);
612
615 outine_material.updateModifiedTime();
616 }
617 else
618 {
619 model.setMaterial(PrimitiveProperty::Outline, solid_material);
620 }
623 model.updateModifiedTime();
624 }
625 }
626 else
627 {
628 m_xdata_callback = nullptr;
629 }
630 }
631 void addXRecordData(uint04 value, DXFValueManager* value_manager) override
632 {
633 if (m_xdata_callback != nullptr)
634 {
635 m_xdata_callback(value, value_manager);
636 }
637 else
638 {
639 if (value == 1001)
640 {
641 m_last_x_data_label = value_manager->getValue(value, m_last_x_data_label);
642 value_manager->setValue(value, String());
643 }
644 else
645 {
646 //lib_assert(m_last_x_data_label.size() > 0, "Unexpected X Data Missing");
647 if (m_last_x_data_label.size() > 0)
648 {
649 m_x_data[m_last_x_data_label] = value_manager->getValue(value, String());
650 value_manager->setValue(value, String());
652 }
653 }
654 }
655
656 };
657 void addDXFMaterial(DXFMaterial& mat) override
658 {
660 {
661 UUID uuid = m_handle_manager->getHandleUUID(mat.handle);
662 if (Material material = m_model_lookup->material(uuid))
663 {
664 m_materials.add(mat.handle, material);
665 return;
666 }
667 }
668 Material material = getMaterial(mat.handle);
669
670
671
674
675 if(!isNaN(mat.ambient.color))
676 material.setUVColor(UVType::e_KA, mat.ambient.color);
678 if (!isNaN(mat.diffuse.color))
679 material.setUVColor(UVType::e_KD, mat.diffuse.color);
681 File diffuse_map_file = mat.diffuse.map_file;
682 diffuse_map_file.replace(".\\", m_relative_path);
683 diffuse_map_file.replace("./", m_relative_path);
684 material.setUVImage(UVType::e_KD, diffuse_map_file);
685 if (diffuse_map_file.exists())
687 //else
688 //material.setUVMode(UVType::e_KD, Material::UVMode::e_solid_color);
690 material.setUVColor(UVType::e_KS, mat.specular.color);
692
693 File specular_map_file = mat.diffuse.map_file;
694 specular_map_file.replace(".\\", m_relative_path);
695 specular_map_file.replace("./", m_relative_path);
696 material.setUVImage(UVType::e_KS, specular_map_file);
697 if (specular_map_file.exists())
699 //else
700 //material.setUVMode(UVType::e_KS, Material::UVMode::e_solid_color);
703 material.updateModifiedTime();
704 m_materials.add(mat.handle, material);
705
706 }
707 Model getLayer(const String& layer_name)
708 {
709 Model layer;
710
711 if (m_layers.hasKey(layer_name))
712 {
713 return m_model_lookup->layer(m_layers.get(layer_name));
714 }
715 String actual_name = convertFromCADName(layer_name, _t("Layer"), m_layers.size());
716 Model layer_ptr = m_model_lookup->findLayer(actual_name);
717 if (layer_ptr.isValid())
718 {
719 m_layers.insert({ layer_name, layer_ptr.uuid() });
720 return layer_ptr;
721 }
722 else
723 {
724 UUID uuid = UUID::CreateUUID(layer_name);
725 if (!m_model_lookup->hasLayerID(uuid))
726 {
727 layer = currentRoot().createSceneLayer();
728 layer.setProperty(DesignObject::e_name, actual_name);
730 m_model_lookup->addLayer(layer);
731 m_layers.insert({ layer_name, layer.uuid() });
732 }
733 else
734 {
735 layer = m_model_lookup->layer(uuid);
737 }
738 }
739 return layer;
740 }
749 Material getMaterial(const uint04& material_handle)
750 {
751 UUID uuid = m_handle_manager->getHandleUUID(material_handle);
752 Material material = m_model_lookup->material(uuid);
753 if (!material.isValid())
754 {
756 lib_assert(!m_model_lookup->hasLayerID(uuid), "added layer?");
757 lib_assert(!m_model_lookup->hasModelID(uuid), "added model?");
758 lib_assert(!m_model_lookup->hasGeometryID(uuid), "added geometry?");
759 lib_assert(!m_model_lookup->hasMaterialID(uuid), "added material?");
760
761 material = generateNewMaterial();
762 lib_assert(!m_model_lookup->hasMaterialID(uuid), "added material?");
763 material.setProperty(DesignObject::e_guid, uuid);
764
765
766
767 m_model_lookup->addMaterial(material);
768 m_materials_read.add(uuid);
769 }
770 return material;
771 }
772 virtual void addLinetype(const LineTypeData&) override { if (m_log_features) m_logger.addMessage(_t("Add Line Type")); }
773 virtual void addLinetypeDash(double) override { if (m_log_features) m_logger.addMessage(_t("Add Line Type Dash")); }
774
775 Model getBlockModel(const String& block_name)
776 {
777 if (m_blocks.hasKey(block_name))
778 {
779 return m_model_lookup->model(m_blocks.get(block_name));
780 }
781 UUID uuid = UUID::CreateUUID();
782 if (m_handle_manager->hasHandleIndex(block_name))
783 {
784 uint04 handle = m_handle_manager->getHandleIndex(block_name);
785 uuid = m_handle_manager->getHandleUUID(handle);
786 lib_assert(!m_model_lookup->hasMaterialID(uuid), "added material?");
787 lib_assert(!m_model_lookup->hasGeometryID(uuid), "added geometry?");
788 lib_assert(!m_model_lookup->hasLayerID(uuid), "added layer?");
789 if (Model block = m_model_lookup->model(uuid))
790 {
791 block.updateTransform(Matrix<fltp08>(1.0));
792 //if (!block.hasParent())
793 //m_model_roots.add(block.uuid());
794 return block;
795 }
796 }
797 Model block_group;
798 if (isNaN(m_blocks_root))
799 {
800 if (m_group_import)
801 {
802 block_group = currentRoot().createChild();
803 }
804 else
805 {
806 block_group = currentRoot().createSceneModel();
807 m_model_roots.add(block_group.uuid());
808 }
809 block_group.setDesignVisible(false);
810 block_group.setProperty(DesignObject::e_name, _td("dxf_blocks_container_name", "Blocks"));
811 block_group.setProperty(DesignObject::e_icon, "database");
814 block_group.setProperty(DesignObject::e_tree_visible, false);
815 block_group.setModelProperty(Model::e_export_ignored, true);
816 m_blocks_root = block_group.uuid();
817 m_model_lookup->addModel(block_group);
818 }
819 else
820 {
821 block_group = m_model_lookup->model(m_blocks_root);
822 }
823 Model block = block_group.createChild();
825 m_blocks_read.add(uuid);
826 m_model_lookup->addModel(block);
827 return block;
828 }
829 void copyBlock(Model& model, Model& block)
830 {
831 Matrix<fltp08> transform = model.getTransform();
832
833 if (model != block)
834 {
835 uint04 layer_index = model.getDirectLayerIndex();
836 model.copyFrom(block, block.getScene() != model.getScene(), false);
837 if (!isNaN(layer_index))
838 model.setLayer(Model(layer_index, &model.base()));
839 else
840 model.clearLayer();
841 }
842 model.setTransform(transform);
843 Buffer<Model> block_children = block.getChildren();
844 Buffer<Model> model_children = model.getChildren();
845 for (uint04 i = 0; i < block_children.size(); i++)
846 {
847 if (m_child_blocks_to_insert.hasKey(block_children[i].uuid()))
848 {
849 String block_layer = m_child_blocks_to_insert.get(block_children[i].uuid());
850 if (m_handle_manager->hasHandleIndex(block_layer))
851 {
852 Model block = getBlockModel(block_layer);
853 copyBlock(model_children[i], block);
854 }
855 else
856 {
857 m_blocks_to_insert[block_layer].add(model_children[i]);
858 }
859 m_child_blocks_to_insert.erase(block_children[i].uuid());
860 }
861 }
862 }
863 virtual void addGroup(const DXFGroup& group_info) override
864 {
865 m_current_data = group_info;
866 Model model = currentEntity();
867 model.setDesignVisible(group_info.visible);
870 for (uint04 i = 0; i < group_info.group_objects.size(); i++)
871 {
872 UUID uuid = m_handle_manager->getHandleUUID(group_info.group_objects[i]);
873 Model child_model = m_model_lookup->model(uuid);
874 if (child_model.isValid())
875 {
876 model.addChild(child_model);
877 child_model.updateModifiedTime();
878 }
879
880 }
881 model.updateModifiedTime();
882 }
883 virtual void addBlock(const BlockData& block_info) override
884 {
885 endSection();
886 m_current_data = static_cast<EntityData>(block_info);
888
889 lib_assert(m_current_block_name.size() == 0, "Cannot have nested blocks");
890 m_current_block_name = block_info.name;
891 //if (block_info.name == "*Model_Space" || block_info.name == "*Paper_Space")
892 //return;
893 if (m_ignore_known_blocks && m_handle_manager->hasHandleIndex(block_info.name))
894 {
895 uint04 handle = m_handle_manager->getHandleIndex(block_info.name);
896 m_current_block = m_handle_manager->getHandleUUID(handle);
898 {
899 m_ignore_current = true;//will allow us to ingore any info in this block
900 return;
901 }
902 }
903 if (!isNaN(block_info.handle) && !m_handle_manager->hasHandleIndex(block_info.name))
904 m_handle_manager->setHandleIndex(block_info.name, block_info.handle);
905 Model block = getBlockModel(block_info.name);
906
907 block.setDesignVisible(block_info.visible);
910
911 setupEntityMaterial(block);
912 Matrix<fltp08> trans(1.0);
913 trans = trans.offset(block_info.offset);
914 block.updateTransform(trans);
915
916 m_current_block = block.uuid();
917 m_handle_manager->setHandleIndex(m_current_block, block_info.handle);
918
919 }
920 virtual void endBlock(const uint04&) override
921 {
922 endSection();
923
924 if (m_current_block_name.size() > 0)
925 {
926 /*if (m_current_block_name == "*Model_Space" || m_current_block_name == "*Paper_Space")
927 {
928 m_current_block_name.clear();
929 return;
930 }*/
932 m_ignore_current = false;
936 {
939 copyBlock(model, block);
941 }
945 }
946 else
947 {
948 lib_assert(false, "invalid dxf");
949 m_logger.addMessage(LogMessage(_t("Unexpected End Block"), LogMessage::e_warning));
950 }
951
952 }
978 virtual void addTextStyle(const StyleData& text_style) override
979 {
980 m_text_styles.insert({ text_style.name, text_style });
981 }
982 virtual void addPoint(const PointData& point) override
983 {
985 return;
986 if (isNaN(point.location))
987 {
988 m_logger.addMessage(LogMessage(_t("Invalid Point").translation() + ": " + String(point.file_line_number), LogMessage::e_warning));
989 return;
990 }
993 {
994 endSection();
995 m_current_data = point;
996 }
997 else if(m_current_data.color_info != point.color_info)
998 {
1000 }
1001 Geometry cloud_geo = currentCloud();
1003 {
1004 if (cloud_geo.vertexCount() == 0)
1005 {
1007 cloud_geo.offset(m_position_offset);
1008 }
1009 else
1010 {
1012 }
1013 }
1014 uint04 index = cloud_geo.addVertex();
1017 cloud_geo.setVertex(VertexProperty::Color, index, point.color_info.color);
1018
1019 /*Matrix<fltp08> mat = GetOrientation(point.extrusion);
1020 mat = mat.rotate(point.effect_angle, Vector<3, fltp08>(0, 0, 1));
1021 mat = mat.offset(offset);
1022 cloud_geo.setTransform(mat);*/
1023 m_x_data.clear();
1024 }
1025 void addLine(const LineData& line) override
1026 {
1027 if (m_ignore_current)
1028 return;
1029 if (isNaN(line.line))
1030 {
1031 m_logger.addMessage(LogMessage(_t("Invalid Line").translation() + ": " + String(line.file_line_number), LogMessage::e_warning));
1032 return;
1033 }
1035 {
1036 endSection();
1038 m_current_data = line;
1039 }
1040 else if (m_current_data.color_info != line.color_info)
1041 {
1043 }
1044 WLock lock = m_model_lookup->writeLock();
1046 if (currentEntity().getProperty<String>(DesignObject::e_icon).size() == 0)
1048
1049 //Matrix<fltp08> trans(1.0);// = GetOrientation(line.extrusion);
1050 //currentLinework().setTransform(trans);
1051
1052 Geometry line_geo = currentLinework();
1054 {
1055 if (line_geo.vertexCount() == 0)
1056 {
1057 m_position_offset = line.line[A];
1058 line_geo.offset(m_position_offset);
1059 }
1060 else
1061 {
1063 }
1064 }
1065 uint04 index = line_geo.addVertices(2);
1066 if (line.thickness > 0)
1067 {
1070 }
1071 if(index == 0)
1073 else
1074 lib_assert(line_geo.mode(PrimitiveProperty::Outline) == PrimitiveMode::e_lines, "Bad line object");
1075 line_geo.setVertex(VertexProperty::Position, index + A, line.line[A] - m_position_offset);
1076 line_geo.setVertex(VertexProperty::Position, index + B, line.line[B] - m_position_offset);
1078 {
1079 line_geo.setVertex(VertexProperty::Color, index + A, line.color_info.color);
1080 line_geo.setVertex(VertexProperty::Color, index + B, line.color_info.color);
1081 }
1082 line_geo.addPrimitive(PrimitiveProperty::Outline, Vector<2, uint04>(index + A, index + B));
1083 m_x_data.clear();
1084 }
1085 void addXLine(const LineData& line) override
1086 {
1087 if (m_ignore_current)
1088 return;
1089 endSection();
1090 if (isNaN(line.line))
1091 {
1092 m_logger.addMessage(LogMessage(_t("Invalid XLine").translation() + ": " + String(line.file_line_number), LogMessage::e_warning));
1093 return;
1094 }
1096 WLock lock = m_model_lookup->writeLock();
1097 Geometry geo = currentLinework();
1099 {
1100 if (geo.vertexCount() == 0)
1101 {
1102 m_position_offset = line.line[A];
1104 }
1105 else
1106 {
1108 }
1109 }
1111 uint04 index = geo.addVertices(2);
1112 if (index == 0)
1114 else
1119 {
1120 geo.setVertex(VertexProperty::Color, index + A, line.color_info.color);
1121 geo.setVertex(VertexProperty::Color, index + B, line.color_info.color);
1122 }
1124 m_x_data.clear();
1125 }
1126 void addRay(const LineData& ray) override
1127 {
1128 if (m_ignore_current)
1129 return;
1130 endSection();
1131 if (isNaN(ray.line))
1132 {
1133 m_logger.addMessage(LogMessage(_t("Invalid Ray").translation() + ": " + String(ray.file_line_number), LogMessage::e_warning));
1134 return;
1135 }
1137 WLock lock = m_model_lookup->writeLock();
1138 Geometry geo = currentLinework();
1140 {
1141 if (geo.vertexCount() == 0)
1142 {
1143 m_position_offset = ray.line[A];
1145 }
1146 else
1147 {
1149 }
1150 }
1151 uint04 index = geo.addVertices(2);
1155 }
1156
1157 virtual void addTrace(const TraceData& data) override
1158 {
1159 if (m_ignore_current)
1160 return;
1161 if (isNaN(data.points[A]))
1162 {
1163 m_logger.addMessage(LogMessage(_t("Invalid TraceData").translation() + ": " + String(data.file_line_number), LogMessage::e_warning));
1164 }
1166 {
1167 endSection();
1168 m_current_data = data;
1170 }
1171 else
1172 {
1175 }
1176 m_current_data = data;
1177 //mesh.setGeometryProperty(Geometry::e_thickness, data.thickness);
1178
1180 for(uint04 i = 0; i < 4; i++)
1181 m_quad_position_data.add(mat * data.points[i]);
1184 }
1185 virtual void add3dFace(const TraceData& data) override
1186 {
1187 if (m_ignore_current)
1188 return;
1189 if (isNaN(data.points[A]))
1190 {
1191 m_logger.addMessage(LogMessage(_t("Invalid 3DFace").translation() + ": " + String(data.file_line_number), LogMessage::e_warning));
1192 }
1194 {
1195 endSection();
1196 m_current_data = data;
1198 }
1199 else
1200 {
1203 }
1204 Vertex<3, fltp08> points[4];
1205 memmove(points, data.points, sizeof(data.points));
1206 bool has_duplicate = false;
1207 if (points[C] == points[D])
1208 {
1209 has_duplicate = true;
1210 }
1211 else if (points[D] == points[A])
1212 {
1213 has_duplicate = true;
1214 }
1215 else if (points[A] == points[B])
1216 {
1217 has_duplicate = true;
1218 std::swap(points[A], points[D]);
1219 }
1220 else if (points[B] == points[C])
1221 {
1222 has_duplicate = true;
1223 std::swap(points[C], points[D]);
1224 }
1225 uint04 num_of_sides = has_duplicate ? 3 : 4;
1226 if (num_of_sides == 4)
1227 {
1228 LineSegment<3, fltp08> a(data.points[A], data.points[B]);
1229 LineSegment<3, fltp08> b(data.points[B], data.points[C]);
1230 LineSegment<3, fltp08> c(data.points[C], data.points[D]);
1231 LineSegment<3, fltp08> e(data.points[D], data.points[A]);
1232 if (a.intersects<fltp08>(c) || b.intersects<fltp08>(e))
1233 {
1234 for (uint04 i = 0; i < 2; i++)
1235 m_quad_position_data.add(data.points[i]);
1236 m_quad_position_data.add(data.points[D]);
1237 m_quad_position_data.add(data.points[C]);
1238
1239 }
1240 else
1241 {
1242 for (uint04 i = 0; i < 4; i++)
1243 m_quad_position_data.add(data.points[i]);
1244 }
1246 {
1247 for(uint04 i = 0; i < 4; i++)
1249 }
1250 }
1251 else
1252 {
1253 for (uint04 i = 0; i < 3; i++)
1254 m_tri_position_data.add(points[i]);
1256 {
1257 for (uint04 i = 0; i < 3; i++)
1259 }
1260 }
1261 }
1262
1263 void addArc(const ArcData& arc) override
1264 {
1265 if (m_ignore_current)
1266 return;
1267 endSection();
1268 if (isNaN(arc.angle1) || isNaN(arc.angle2) || isNaN(arc.radius))
1269 {
1270 m_logger.addMessage(LogMessage(_t("Invalid Arc").translation() + ": " + String(arc.file_line_number), LogMessage::e_warning));
1271 return;
1272 }
1273 WLock lock = m_model_lookup->writeLock();
1274 m_current_data = arc;
1276 Model model = currentEntity();
1277
1278 //m_current_linework = model.uuid();
1279 //Geometry geo = model.createChildGeometry();
1280 //geo.setGeometryProperty(Geometry::e_thickness, arc.thickness);
1281
1282 ArcShape arc_shape(model);
1283 arc_shape.setupConicArc(arc.angle1, arc.angle2, arc.radius);
1285 trans = trans.offset(arc.offset);
1286 //trans = trans.scale(Vector<3, fltp08>(-1.0, 1.0, 1.0));
1287 model.setTransform(trans);
1288
1289 }
1290#if NDEVR_TEXT_MODEL
1291 void addAttribute(const Attrib& attribute) override
1292 {
1293 if (m_ignore_current)
1294 return;
1295 endSection();
1296 Attrib new_attribute(attribute);
1297 new_attribute.text = attribute.default_value;
1298 Text text;
1300 {
1301 UUID old_block = m_current_block;
1303 Buffer<Model> children = currentBlock().getChildrenByName(attribute.tag);
1304 if (children.size() > 0)
1305 {
1306 text = children.last();
1307 setupTextData(text, new_attribute);
1308 }
1309 else
1310 {
1311
1312 text = createFromTextData(new_attribute);
1313 }
1314
1315 text.setTransform(m_model_lookup->model(m_last_insert).getCompleteTransform().invert()* text.getTransform());
1316 text.setProperty(DesignObject::e_name, convertFromCADName(attribute.tag, _t("Attribute"), Constant<uint04>::NaN));
1317 m_current_block = old_block;
1318 }
1319 else
1320 {
1321 text = createFromTextData(new_attribute);
1322 text.setProperty(DesignObject::e_name, convertFromCADName(attribute.tag, _t("Attribute"), m_attribute_count++));
1323 }
1324 setupEntityMaterial(text);
1325 if (text.getProperty<String>(DesignObject::e_icon).size() == 0)
1326 text.setProperty(DesignObject::e_icon, "label");
1327 endSection();
1328 }
1329 void addAttributeDefintion(const Attrib& attribute) override
1330 {
1331 Attrib new_attribute(attribute);
1332 new_attribute.text = attribute.default_value;
1333 //addText(new_attribute);
1334 }
1335 Text createFromTextData(const TextData& data)
1336 {
1337
1338 TextData tex_data = data;
1339 m_current_data = data;
1340 DynamicPointer<TextConstructor> constructor;
1341 if (m_text_styles.hasKey(data.style))
1342 {
1343 const StyleData& style = m_text_styles.get(data.style);
1344 Font font;
1345 font.name = style.primary_font_file;
1346 constructor = getTextContructor(style.primary_font_file, font);
1347 if (!isNaN(style.width_factor) && style.width_factor != 0.0)
1348 tex_data.reference_width *= style.width_factor;
1349 if (isNaN(tex_data.height) && !isNaN(style.fixed_text_height) && style.fixed_text_height != 0.0)
1350 tex_data.height = style.fixed_text_height;
1351 }
1352 if (constructor.isNull())
1353 constructor = getTextContructor(FontEngine::DefaultFont);
1354 WLock lock = m_model_lookup->writeLock();
1355 Text text(currentEntity(), constructor);
1356 setupTextData(text, tex_data);
1357 return text;
1358 }
1359
1360 virtual void addText(const TextData& data) override
1361 {
1362 if (m_ignore_current)
1363 return;
1364 endSection();
1365 createFromTextData(data);
1366 m_x_data.clear();
1367 endSection();
1368 }
1369#endif
1370 void addCircle(const CircleData& c) override
1371 {
1372 if (m_ignore_current)
1373 return;
1374 endSection();
1375 if (isNaN(c.circle.center()) || isNaN(c.circle.radius()))
1376 {
1377 m_logger.addMessage(LogMessage(_t("Invalid Circle").translation() + ": " + String(c.file_line_number), LogMessage::e_warning));
1378 return;
1379 }
1380 WLock lock = m_model_lookup->writeLock();
1381 m_current_data = c;
1383 Model model = currentEntity();
1384 if (model.getProperty<String>(DesignObject::e_icon).size() == 0)
1385 model.setProperty(DesignObject::e_icon, "circle");
1386 if (model.getProperty<String>(DesignObject::e_name).size() == 0)
1396 trans = trans.offset(c.circle.center());
1397 trans = trans.scale(c.circle.radius());
1399 {
1401 }
1402 model.setTransform(trans);
1403 model.updateModifiedTime();
1404 }
1405 virtual void addEllipse(const EllipseData& e) override
1406 {
1407 if (m_ignore_current)
1408 return;
1409 /*if (isNaN(e.ellipse.axisPoint(A)) || isNaN(e.ellipse.axisPoint(B)) || isNaN(e.ellipse.radius()))
1410 {
1411 m_logger.addMessage(LogMessage(_t("Invalid Circle") + ": " + String(e.file_line_number), LogMessage::e_warning));
1412 return;
1413 }*/
1414 endSection();
1415 WLock lock = m_model_lookup->writeLock();
1416 m_current_data = e;
1418 Model model = currentEntity();
1419 if (model.getProperty<String>(DesignObject::e_icon).size() == 0)
1420 model.setProperty(DesignObject::e_icon, "oval");
1425 Angle<fltp08> start = e.angle1;
1426 Angle<fltp08> end = e.angle2;
1428
1429 Vertex<3, fltp08> major_axis_endpoint = trans.invert() * e.endpoint_of_major_axis;
1430
1431 const Vector<3, fltp08> center_point(e.center);
1432 fltp08 ratio = e.minor_to_major_ratio;
1433 fltp08 radius = ratio * major_axis_endpoint.magnitude<fltp08>();
1434 Vector<3, fltp08> dt = major_axis_endpoint - (ratio * major_axis_endpoint);
1435 Vector<3, fltp08> p1 = center_point - dt;
1436 Vector<3, fltp08> p2 = center_point + dt;
1437 BiRadialObject<3, fltp08> radial(p1, p2, radius);
1438 Vector<3, fltp08> axis = major_axis_endpoint.normalized<fltp08>();
1440
1441 start += offset_angle;
1442 end += offset_angle;
1443
1444
1445 if (end < start)
1446 end += Angle<fltp08>(DEGREES, 360.0);
1447 Angle<fltp08> phi = end - start;
1448 if (phi > Angle<fltp08>(DEGREES, 360.0))
1449 phi = Angle<fltp08>(DEGREES, 360.0);
1450 ShapeConstructors::Circle(m_current_linework, Matrix<fltp08>(1.0), 44, 1.0, start, phi, false);
1453
1454 BiRadialObject<3, fltp08> radial_obj(p1, p2, radius);
1455 trans *= trans.offset(radial_obj.center());
1456 trans *= radial_obj.fromCircleTransform();
1457 if(e.extrusion[Z] < 0)
1458 trans = trans.scale(Vector<3, fltp08>(-1.0, 1.0, 1.0));
1460 {
1462 }
1463 model.setTransform(trans);
1464 if (model.getProperty<String>(DesignObject::e_name).size() == 0)
1466 model.updateModifiedTime();
1467 }
1468 virtual void addPolyline(const PolylineData& poly) override
1469 {
1470 if (m_ignore_current)
1471 return;
1472 endSection();
1473 WLock lock = m_model_lookup->writeLock();
1474 m_current_data = poly;
1475 Geometry geo;
1477 {
1479 if (currentEntity().getProperty<String>(DesignObject::e_icon).size() == 0)
1481 geo = currentLinework();
1484 }
1486 {
1488 if (currentEntity().getProperty<String>(DesignObject::e_icon).size() == 0)
1490 geo = currentPolyMesh();
1492 }
1493 else
1494 {
1496
1497 if (currentEntity().getProperty<String>(DesignObject::e_icon).size() == 0)
1499 geo = currentLinework();
1502 }
1503 Matrix<fltp08> trans(1.0);
1504 //in OCS when 2D, WCS when 3D
1506 {
1507 trans = trans.offset(Vector<3, fltp08>(0.0, 0.0, poly.elevation));
1508 //trans *= GetOrientation(poly.extrusion);
1509 }
1510 else
1511 {
1512 trans *= GetOrientation(poly.extrusion).invert();
1513 trans = trans.offset(Vector<3, fltp08>(0.0, 0.0, poly.elevation));
1514 }
1516 {
1518 }
1519 geo.setTransform(trans);
1520 m_x_data.clear();
1521
1522 }
1523 virtual void addMesh(CADMeshData& mesh_data) override
1524 {
1525 if (m_ignore_current)
1526 return;
1527 endSection();
1528 WLock lock = m_model_lookup->writeLock();
1529 m_current_data = mesh_data;
1530
1531; Geometry geo;
1533 if (currentEntity().getProperty<String>(DesignObject::e_icon).size() == 0)
1535 geo = currentPolyMesh();
1536 if (isNaN(m_position_offset) && mesh_data.vertices.size() > 0)
1537 {
1538 if (geo.vertexCount() == 0)
1539 {
1540 m_position_offset = mesh_data.vertices[0];
1542 }
1543 else
1544 {
1546 }
1547 }
1548 geo.addVertices(mesh_data.vertices.size());
1549 uint04 vertex_offset = geo.vertexOffset();
1550 for (uint04 i = 0; i < mesh_data.vertices.size(); i++)
1551 mesh_data.vertices[i] -= m_position_offset;
1555 uint04 next_break_location = 0;
1556 uint04 last_break_location = 0;
1557 uint04 index_location = 0;
1558 for (uint04 i = 0; i < mesh_data.face_points.size(); i++)
1559 {
1560 if (i == next_break_location)
1561 {
1562 if (i > 0)
1563 {
1564 Geometry::OptimizedSetPrimitive(primitive_setter, index_location++, mesh_data.face_points[last_break_location] + vertex_offset);
1565 last_break_location = next_break_location + 1;
1567#ifdef _DEBUG
1568 primitive_setter.index_max_offset++;
1569#endif
1570 Geometry::OptimizedSetPrimitive(primitive_setter, index_location++, Constant<uint04>::NaN);
1571
1572 }
1573 next_break_location += (mesh_data.face_points[i] + 1);
1574 }
1575 else
1576 {
1577 Geometry::OptimizedSetPrimitive(primitive_setter, index_location++, mesh_data.face_points[i] + vertex_offset);
1578 }
1579 }
1580 if (!isNaN(mesh_data.data_dictionary_reference))
1582 m_x_data.clear();
1583 endSection();
1584
1585 }
1586 virtual void addVertex(const Vector<4, fltp08>& vertex) override
1587 {
1588 if (m_ignore_current)
1589 return;
1590 if (isNaN(vertex[X]) || isNaN(vertex[Y]))
1591 {
1593 return;
1594 }
1595 WLock lock = m_model_lookup->writeLock();
1596 switch (m_current_mode)
1597 {
1598 default:
1599 lib_assert(false, "Unexpected Object in add vertex");
1600 break;
1601 case DXFMode::e_leader:
1604 {
1605 Geometry geo = currentLinework();
1607 {
1608 m_position_offset = vertex.as<3, fltp08>();
1610 }
1611 if (isNaN(m_next_bulge) || m_next_bulge == 0.0)
1612 {
1613 uint04 index = geo.addVertex();
1614 geo.setVertex(VertexProperty::Position, index, vertex.as<3, fltp08>() - m_position_offset);
1616 }
1617 else// need to calculate bulge
1618 {
1619 fltp08 bulge = m_next_bulge;
1621 Vertex<3, fltp08> p2 = vertex.as<3, fltp08>() - m_position_offset;
1622 addBulge(geo, bulge, p1, p2);
1623 }
1624 m_next_bulge = vertex[D];
1625 } break;
1627 {
1628 Geometry geo = currentPolyMesh();
1629 if (geo.vertexCount() == 0)
1630 {
1631 geo.offset(vertex.as<3, fltp08>());
1632 }
1634 uint04 index = geo.addVertex();
1635
1636 geo.setVertex(VertexProperty::Position, index, vertex.as<3, fltp08>() - offset);
1637 } break;
1638 }
1639 }
1640 virtual void addIndex(const Vector<4, sint04>& vertex) override
1641 {
1642 if (m_ignore_current)
1643 return;
1644 WLock lock = m_model_lookup->writeLock();
1645 switch (m_current_mode)
1646 {
1649 case DXFMode::e_leader:
1650 {
1651
1652 } break;
1654 {
1655 for (uint04 i = 0; i < 4; i++)
1656 {
1657 if (vertex[i] == 0)
1658 break;
1659 if(!isNaN(vertex[i]) && abs(vertex[i]) - 1 < cast<sint04>(currentPolyMesh().vertexCount()))
1661 else
1662 m_logger.addMessage(LogMessage(_t("Invalid Vertex Index"), LogMessage::e_warning));
1663 }
1665 } break;
1666 default:
1667 {
1668 lib_assert(false, "Unexpected Object in add vertex");
1669 } break;
1670 }
1671 }
1672
1673 virtual void addInsert(const BlockInsert& data) override
1674 {
1675 if (m_ignore_current)
1676 return;
1677 endSection();
1678 if (data.block_name == m_current_block_name)
1679 {
1680 m_logger.addMessage(LogMessage(_t("Tried to add insert of block inside of block: [block]").replace("[block]",m_current_block_name), LogMessage::e_warning));
1681 return;
1682 }
1684 //if(m_handle_manager->hasHandleIndex(data.block_name))
1685 //m_current_data.handle = m_handle_manager->getHandleIndex(data.block_name);
1687 if (!isNaN(data.offset))
1688 mat = mat.offset(data.offset);
1689 if (!isNaN(data.azimuth))
1690 mat = mat.rotate(data.azimuth, Vector<3, fltp08>(0.0, 0.0, 1.0));
1691 if (!isNaN(data.scale) && data.scale != 1.0)
1692 mat = mat.scale(data.scale);
1694 {
1696 }
1697
1698 WLock lock = m_model_lookup->writeLock();
1699 Model current = currentEntity();
1700 current.setDesignVisible(data.visible);
1702
1703 current.setTransform(mat);
1704 if (!m_blocks.hasKey(data.block_name))
1705 {
1706 m_blocks_to_insert[data.block_name].add(current);
1707 m_child_blocks_to_insert.add(current.uuid(), data.block_name);
1708 }
1709 else
1710 {
1711 lib_assert(!m_blocks_to_insert.contains(data.block_name), "This should have been resolved");
1712 Model block = getBlockModel(data.block_name);
1713 copyBlock(current, block);
1714 }
1715 m_last_insert = current.uuid();
1716 m_x_data.clear();
1717 endSection();
1718 }
1719 virtual void addSpline(const SplineData&) override
1720 {
1721 if (m_ignore_current)
1722 return;
1723 endSection();
1724 }
1725 #if NDEVR_VIEWPORT && NDEVR_MEASURE_MODELS
1726 void addDimAlign(const DimAlignedData& dimension) override
1727 {
1728 if (m_ignore_current)
1729 return;
1730 endSection();
1731 WLock lock = m_model_lookup->writeLock();
1732 m_current_data = dimension;
1734 DistanceMeasureModel current_model = DistanceMeasureModel(currentEntity());
1735 BitFlag point_types(0);
1736 point_types(MeasurePointType::e_arrow, true);
1737 current_model.setPointTypes(point_types);
1738 current_model.setEndpoints(dimension.alignment_data[A], dimension.alignment_data[B], dimension.definition_point);
1740 current_model.setLabel(location);
1741 current_model.updateProperty(DesignObject::e_name, location);
1742 current_model.updateModifiedTime();
1743
1744 }
1745 void addDimLinear(const LinearDimension& dimension) override
1746 {
1747 if (m_ignore_current)
1748 return;
1749 endSection();
1750 WLock lock = m_model_lookup->writeLock();
1751 m_current_data = dimension;
1753 DistanceMeasureModel current_model = DistanceMeasureModel(currentEntity());
1754 BitFlag point_types(0);
1755 point_types(MeasurePointType::e_arrow, true);
1756 current_model.setPointTypes(point_types);
1757 current_model.setEndpoints(dimension.alignment_data[A], dimension.alignment_data[B], dimension.definition_point);
1758 TranslatedString location = TranslatedString(String(dimension.alignment_data.length<fltp08>()).formatNumberString(2));
1759 current_model.setLabel(location);
1760 current_model.updateProperty(DesignObject::e_name, location);
1761 current_model.updateModifiedTime();
1762 }
1763 #endif
1764 void addDimRadial(const RadialDimension&) override
1765 {
1766
1767 }
1769 {
1770 }
1772 {
1773 }
1775 {
1776 }
1777 void addDimOrdinate(const DimOrdinateData&) override
1778 {
1779 }
1780 virtual void addLeader(const LeaderData& data) override
1781 {
1782 if (m_ignore_current)
1783 return;
1784 endSection();
1785 WLock lock = m_model_lookup->writeLock();
1786 m_current_data = data;
1787 Geometry geo;
1789 if (currentEntity().getProperty<String>(DesignObject::e_icon).size() == 0)
1791 geo = currentLinework();
1793 Matrix<fltp08> trans(1.0);
1794 //in OCS when 2D, WCS when 3D
1795
1796 {
1797 //trans = trans.offset(Vector<3, fltp08>(0.0, 0.0, poly.elevation));
1798 //trans *= GetOrientation(poly.extrusion);
1799 }
1801 {
1803 }
1804 geo.setTransform(trans);
1805 }
1806
1807
1808 virtual void addComment(const String& comment) override
1809 {
1810 if (m_log_features)
1811 m_logger.addMessage(comment);
1812 }
1813#if NDEVR_TEXT_MODEL
1814 void setupTextData(Text& text, const TextData& data)
1815 {
1816 Buffer<TextBlock> text_block_data = parseString(data.text, data.height);
1817 WLock lock = m_model_lookup->writeLock();
1818 if (data.line_spacing_factor != 1.0)
1819 text.setLineSpaceFactor(data.line_spacing_factor);
1820 text.setText(text_block_data);
1823 || isNaN(data.align_b))
1824 mat = mat.offset(data.align_a);
1825 else
1826 mat = mat.offset(data.align_b);
1827 mat = mat.rotate(data.rotatation + Angle<fltp08>(DEGREES, 90.0), Vector<3, fltp08>(0, 0, 1));
1829 mat = mat.scale(0.001);
1830 if (!m_model_lookup->hasLayerID(text.textLayer().uuid(), currentRoot().uuid()))
1831 m_model_lookup->addLayer(text.textLayer());
1832 text.setConstrainedSize(Vector<2, fltp08>(Constant<fltp08>::NaN, data.height));
1833 text.setReferenceSize(Vector<2, fltp08>(data.reference_width, Constant<fltp08>::NaN));
1834 text.setAlignment(data.alignment);
1835 text.setInsertionAlignment(data.alignment);
1836 //text.textObject().setParentMatrixFlag(Model::ParentMatrixFlags::e_ignore_scale, true);
1838 {
1840 }
1841 text.setTransform(mat);
1842 text.setFaceCamera(m_text_face_camera);
1843 if (text_block_data.size() > 0)
1844 text.setProperty(DesignObject::e_name, text_block_data[0].text);
1845 text.update();
1846 }
1847 #endif
1848 virtual void endEntity() override
1849 {
1850 endSection();
1851 }
1852 void setAttributes(const DXFAttributes&) override
1853 {
1854 endEntity();
1855 }
1856
1857 void setExtrusion(fltp08 dx, fltp08 dy, fltp08 dz, fltp08 elevation) override
1858 {
1859 m_extrusion.setDirection(dx, dy, dz);
1860 m_extrusion.setElevation(elevation);
1861 }
1862
1864 return m_extrusion;
1865 }
1867 {
1870 else
1871 return Scene();
1872 }
1874 {
1875 Buffer<Model> roots;
1876 for (const UUID& id : m_model_roots)
1877 {
1878 roots.add(m_model_lookup->model(id));
1879 }
1880 return roots;
1881 }
1883 {
1885 {
1887 {
1888 WLock lock = m_model_lookup->writeLock();
1889 Scene scene(_t("Paper Space"));
1890 m_current_paper_root = scene.uuid();
1891 scene.createDefaultMaterial();
1892 m_model_lookup->addScene(scene);
1893 }
1895 }
1896 else
1897 {
1898 if (m_model_roots.size() == 0)
1899 {
1900 WLock lock = m_model_lookup->writeLock();
1901 Scene scene(_t("Model Space"));
1902 scene.setMetaData("is_cad_core", true);
1903 m_core_root = scene.uuid();
1904 if (m_group_import)
1906 else
1908 m_model_lookup->addScene(scene);
1909 }
1911 }
1912 }
1914 {
1915 if (!isNaN(m_current_block))
1916 {
1918 }
1919 if (m_current_block_name.size() > 0)
1920 {
1922 }
1923 return currentRoot();
1924 }
1925 Buffer<TextBlock> parseString(const String& text, fltp08 default_height)
1926 {
1927 Buffer<Font> font_stack;
1928 Buffer<TextBlock> blocks;
1929 blocks.add(TextBlock());
1931 blocks.last().font.point_size = default_height;
1932 for (uint04 i = 0; i < text.size(); i++)
1933 {
1934 switch (text[i])
1935 {
1936 case '{':
1937 {
1938 font_stack.add(blocks.last().font);
1939 } break;
1940 case '}':
1941 {
1942 lib_assert(font_stack.size() > 0, "unexpected \"}\"");
1943 if (font_stack.size() == 0)
1944 {
1945 m_logger.addMessage(LogMessage(_td("unexpected_dxf_text_close", "unexpected \"}\"").translation() + ": " + String::toHex(m_current_data.parent_handle) + " : " + String(m_current_data.file_line_number), LogMessage::e_warning));
1946 continue;
1947 }
1948 if (blocks.last().text.size() > 0)
1949 {
1950 blocks.add(TextBlock());
1951 blocks.last().font = font_stack.last();
1952 blocks.last().text.clear();
1953 }
1954 else
1955 {
1956 blocks.last().font = font_stack.last();
1957 }
1958 font_stack.removeLast();
1959 } break;
1960 case '\\':
1961 {
1962 Font f = blocks.last().font;
1963 i++;
1964 lib_assert(i < text.size(), "unexpected end of text");
1965 if (i >= text.size())
1966 {
1967 m_logger.addMessage(LogMessage(_td("unexpected_dxf_text", "Unexpected Font").translation() + ": " + String::toHex(m_current_data.parent_handle) + " : " + String(m_current_data.file_line_number), LogMessage::e_warning));
1968 break;
1969 }
1970 switch (text[i])
1971 {
1972 case 'f':
1973 case 'F':
1974 {
1975 i++;
1976 lib_assert(i < text.size(), "unexpected end of text");
1977 if (i >= text.size())
1978 {
1979 m_logger.addMessage(LogMessage(_td("unexpected_dxf_text", "Unexpected Font").translation() + ": " + String::toHex(m_current_data.parent_handle) + " : " + String(m_current_data.file_line_number), LogMessage::e_warning));
1980 break;
1981 }
1982 for (; i < text.size() && text[i] != ';' && text[i] != '|'; i++)
1983 {
1984 f.name.add(text[i]);
1985 }
1986 while (i < text.size() && text[i] != ';')
1987 {
1988 switch (text[i++])
1989 {
1990 case 'b': f.is_bold = text[i++] == '1'; break;
1991 case 'i': f.is_italic = text[i++] == '1'; break;
1992 case 'c': while (text[i] != ';' && text[i] != '|') i++; break;
1993 case 'p': while (text[i] != ';' && text[i] != '|') i++; break;
1994 }
1995 }
1996 blocks.last().font.getFile().clear();
1997 } break;
1998 case 's':
1999 case 'S':
2000 {
2001 i++;
2002 lib_assert(i < text.size(), "unexpected end of text");
2003 if (i >= text.size())
2004 {
2005 m_logger.addMessage(LogMessage(_td("unexpected_dxf_format", "Unexpected Text Format").translation() + ": " + String::toHex(m_current_data.parent_handle) + " : " + String(m_current_data.file_line_number), LogMessage::e_warning));
2006 break;
2007 }
2008 while (i < text.size() && text[i] != '#' && text[i] != '^' && text[i] != '/')
2009 blocks.last().text.add(text[i++]);
2010 blocks.last().text.add('/');
2011 while (i < text.size() && text[i] != ';')
2012 blocks.last().text.add(text[i++]);
2013 lib_assert(i < text.size(), "unexpected end of text");
2014 if (i >= text.size())
2015 {
2016 m_logger.addMessage(LogMessage(_td("unexpected_dxf_format", "Unexpected Text Format").translation() + ": " + String::toHex(m_current_data.parent_handle) + " : " + String(m_current_data.file_line_number), LogMessage::e_warning));
2017 break;
2018 }
2019 } break;
2020 case 'h':
2021 case 'H':
2022 {
2023 i++;
2024 String num;
2025 while (i < text.size() && text[i] != ';')
2026 num.add(text[i++]);
2027 f.point_size = num.getAs<fltp08>();
2028 }
2029 case 'w':
2030 case 'W':
2031 {
2032 i++;
2033 String num;
2034 while (i < text.size() && text[i] != ';')
2035 num.add(text[i++]);
2036 f.fixed_width = num.getAs<fltp08>();
2037 }
2038 case 'c':
2039 case 'C':
2040 {
2041 i++;
2042 String num;
2043 while (i < text.size() && text[i] != ';')
2044 num.add(text[i++]);
2045 f.color = RGBColor(ACIColor(abs(num.getAs<sint04>())));
2046 }
2047
2048 case 'L': f.is_underline = true; break;
2049 case 'l': f.is_underline = false; break;
2050 case 'O': f.is_overstrike = true; break;
2051 case 'o': f.is_overstrike = false; break;
2052 case 'K': f.is_strikethrough = true; break;
2053 case 'k': f.is_strikethrough = false; break;
2054 case 'A':
2055 {
2056 i++;
2057 lib_assert(i < text.size(), "unexpected end of text");
2058 if (i >= text.size())
2059 {
2060 m_logger.addMessage(LogMessage(_td("unexpected_dxf_format", "Unexpected Text Format").translation() + ": " + String::toHex(m_current_data.parent_handle) + " : " + String(m_current_data.file_line_number), LogMessage::e_warning));
2061 break;
2062 }
2063 switch (text[i])
2064 {
2067 case 2: f.alignment = cast<uint01>(TextAlignment::e_top); break;
2068 }
2069 if (i < text.size() - 1)
2070 {
2071 if (text[i + 1] == ';' || text[i + 1] == '|')
2072 {
2073 i++;
2074 }
2075 }
2076
2077 } break;
2078 case 'p':
2079 {
2080 String s;
2081 while (text[i] != ';' && text[i] != '|')
2082 s.add(text[i++]);
2083 switch (s.hashLower())
2084 {
2085 case String::hash("pxqc"): f.alignment |= cast<uint01>(TextAlignment::e_center); break;//center
2086 case String::hash("pxqr"): f.alignment |= cast<uint01>(TextAlignment::e_right); break;//right aligned
2087 case String::hash("pxql"): f.alignment |= cast<uint01>(TextAlignment::e_left); break;//left aligned
2088 }
2089 } break;
2090 case 'P': blocks.last().text.add('\n'); break;
2091 case '~': blocks.last().text.append(" "); break;
2092 default:
2093 {
2094 blocks.last().text.add(text[i]);
2095 }
2096 }
2097 if (f != blocks.last().font)
2098 {
2099 if (blocks.last().text.size() > 0)
2100 {
2101 blocks.add(TextBlock());
2102 blocks.last().font = f;
2103 blocks.last().text.clear();
2104 }
2105 else
2106 {
2107 blocks.last().font = f;
2108 }
2109 }
2110 } break;
2111 case '%':
2112 {
2113 if (i + 2 < text.size() && text[i + 1] == '%')
2114 {
2115 //Control Codes and Special Characters Reference
2116 i += 2;
2117 Font f = blocks.last().font;
2118 switch (text[i])
2119 {
2120 case 'o': f.is_overstrike = !f.is_overstrike; break;
2121 case 'u': f.is_underline = !f.is_underline; break;
2122 case 'd': blocks.last().text.append(UnitDefinitions::Degrees().get().abbreviation().translation()); break;
2123 //case 'p': blocks.last().text.append(""); break;
2124 //case 'c': blocks.last().text.append(""); break;
2125 case '%': blocks.last().text.append("%"); break;
2126 }
2127 if (f != blocks.last().font)
2128 {
2129 if (blocks.last().text.size() > 0)
2130 {
2131 blocks.add(TextBlock());
2132 blocks.last().font = f;
2133 blocks.last().text.clear();
2134 }
2135 else
2136 {
2137 blocks.last().font = f;
2138 }
2139 }
2140 }
2141 else
2142 {
2143 blocks.last().text.add(text[i]);
2144 }
2145 } break;
2146 default:
2147 {
2148 blocks.last().text.add(text[i]);
2149 } break;
2150 }
2151 }
2152 return blocks;
2153 }
2154 void addBulge(Geometry& geo, fltp08 bulge, const Vertex<3, fltp08>& p1, const Vertex<3, fltp08>& p2)
2155 {
2156 /*lib_assert(!isNaN(bulge) && bulge != 0.0, "Bad bulge");
2157 if (isNaN(bulge) || bulge == 0.0)
2158 {
2159 m_logger.addMessage(LogMessage(_t("Invalid Bulge") + ": " + String(m_current_data.file_line_number), LogMessage::e_warning));
2160 return;
2161 }
2162 Vertex<3, fltp08> arc_mid;
2163 Vertex<3, fltp08> arc_center;
2164 fltp08 radius;
2165 fltp08 chord;
2166 fltp08 chordMidX;
2167 fltp08 chordMidY;
2168 fltp08 sagitta;
2169 fltp08 apothem;
2170 Angle<fltp08> inc_angle;
2171 bool clockwise;
2172 ArcDataFromBulge(bulge, p1, p2, arc_mid
2173 , arc_center, radius, &chord, &chordMidX, &chordMidY
2174 , &sagitta, &apothem, inc_angle);
2175
2176 Angle start_angle = -AngleDefinitions::Heading<sint04>(p1 - arc_center);
2177 Matrix<fltp08> mat(1.0);
2178 mat = mat.offset(arc_center);
2179 mat = mat.scale(Vector<3, fltp08>(-1.0, 1.0, 1.0));
2180 ShapeConstructors::Circle(geo, mat, 42, radius, start_angle, inc_angle.toTypeAngle<sint04>(), false);
2181 */
2182
2183 lib_assert(!isNaN(bulge) && bulge != 0.0, "Bad bulge");
2184 if (isNaN(bulge) || bulge == 0.0)
2185 {
2187 return;
2188 }
2189 fltp08 dist = distance<fltp08>(p1, p2);
2190 fltp08 H = abs(bulge) * dist / 2.0;
2191 fltp08 r = H / 2.0 + dist / abs(bulge * 4.0);
2192
2193 fltp08 mag_x = (p2[X] - p1[X]) / dist;
2194 fltp08 mag_y = (p2[Y] - p1[Y]) / dist;
2195 fltp08 dx = dist / 2.0;
2196 fltp08 dy = (r - H) * (bulge < 0 ? -1 : 1);
2197
2198 Vector<3, fltp08> center;
2199 center[X] = mag_x * dx - mag_y * dy + p1[X];
2200 center[Y] = mag_y * dx + mag_x * dy + p1[Y];
2201 center[Z] = p1[Z];
2202
2203 //Vector<3, fltp08> p1_ray = p1 - center;
2204 //fltp08 norm = p1_ray.magnitude<fltp08>();
2205
2206 //Angle start_angle = -Angle::acos(cast<fltp04>(p1_ray[X] / norm));
2207 //if (p1_ray[Y] < 0.0)
2208 //start_angle = Angle(DEGREES, 360.0) - start_angle;
2209
2210 Angle<fltp08> start_angle = AngleDefinitions::Heading<fltp08>(p1 - center);
2211 Angle<fltp08> end_angle = AngleDefinitions::Heading<fltp08>(p2 - center);
2212 if (end_angle < start_angle)
2213 end_angle += Angle<fltp08>(DEGREES, 360.0);
2214 Angle<fltp08> phi = end_angle - start_angle;//-4.0f * Angle::atan(cast<fltp04>(bulge));
2215
2216 if (bulge < 0.0)
2217 phi = -(Angle<fltp08>(DEGREES, 360.0) - phi);//-4.0f * Angle::atan(cast<fltp04>(bulge));
2218
2219 //start_angle -= phi / 44;//since first vertex is already in polyline, skip it
2220 //phi -= phi / 22;//subtract the extra from phi, as we are including the start and end vertex manually
2222 ShapeConstructors::Circle(geo, mat, 42, r, start_angle, phi, false);
2223 const uint04 index = geo.addVertex();
2224 geo.setVertex(VertexProperty::Position, index, p2);
2226 }
2228 {
2229 Model model = currentEntity();
2230 Geometry geo = model.getGeometry();
2231 if(geo.isValid() && m_current_geometry == model.getGeometry())
2232 {
2235 }
2236 else
2237 {
2239 }
2240 return m_current_geometry;
2241 }
2243 {
2245 {
2246 Model model;
2249 {
2250 uuid = m_handle_manager->getHandleUUID(m_current_data.handle);
2251 model = m_model_lookup->model(uuid);
2252 if (model.isValid())
2253 {
2254 model.updateTransform(Matrix<fltp08>(1.0));
2256 if(!model.getParent().isValid())
2257 m_model_roots.add(model.uuid());
2258 //model.removeChild()
2259 }
2260 }
2262 {
2263 Model block = currentBlock();
2264 if (!model.isValid())
2265 model = block.createChild();
2266 else if (model.getParent() != block)
2267 block.addChild(model);
2268 }
2269 else if (!model.isValid())
2270 {
2271 model = currentRoot().createSceneModel();
2272 m_model_roots.add(model.uuid());
2273 }
2274 if(!isNaN(uuid))
2275 model.setProperty(DesignObject::e_guid, uuid);
2277 setupEntityMaterial(model);
2278 setupLayer(model);
2279 model.updateModifiedTime();
2280 if(!m_model_lookup->hasModelID(model.uuid()))
2281 m_model_lookup->addModel(model);
2282 m_current_entity = model.uuid();
2283
2284 //lib_assert(m_current_data.block.size() > 0 || !model.getRootMaterial(PrimitiveProperty::Solid).isValid(), "Entity missing material");
2285 /*if (!isNaN(m_current_data.parent_handle) && !model.getRootMaterial(PrimitiveProperty::Solid).isValid())
2286 {
2287 model.getScene().createDefaultMaterial();
2288 m_logger.addMessage(LogMessage(_t("Entity Missing Material").translation() + ": " + String(m_current_data.file_line_number), LogMessage::e_warning));
2289 }*/
2290 return model;
2291 }
2293 }
2294
2295 void setVariableInt(const String& label, int value, int key_label) override
2296 {
2297 UNUSED(key_label);
2298 switch (label.hash())
2299 {
2300 case String::hash("$INSUNITS"):
2301 {
2302 ConstPointer<Unit> unit = ConvertFromCADUnit(value);
2303 if(!unit.isNull())
2305 } break;
2306
2307 case String::hash("$DIMAUNIT"):
2308 {
2309 switch (value)
2310 {
2315 }
2316
2317 } break;
2318 /*case String::hash("$MEASUREMENT"):
2319 {
2320 if (m_unit.isNull())
2321 {
2322 switch (value)
2323 {
2324 case 0: m_unit = UnitManager::EastingNorthingElevation(UnitManager::Feet().get()); break;
2325 case 1: m_unit = UnitManager::EastingNorthingElevation(UnitManager::Meters().get()); break;
2326 default: lib_assert(false, "Unknown MEASUREMENT Unit"); break;
2327 }
2328 }
2329 } break;*/
2330 }
2331 }
2332 /*void setVariableString(const String& label, const String& value, int key_label) override
2333 {
2334 switch (label.hash())
2335 {
2336 case String::hash("$INSUNITS"):
2337 {
2338 String unit = label;
2339 } break;
2340 }
2341 }*/
2414 const Buffer<UUID>& pointsRead() const { return m_points_read; }
2415 const Buffer<UUID>& lineworkRead() const { return m_linework_read; }
2416 const Buffer<UUID>& meshesRead() const { return m_meshes_read; }
2417
2419 {
2420 if (equals(extrusion, Vector<3, fltp08>(0.0, 0.0, 1.0), 0.00001))
2421 return Matrix<fltp08>(1.0);
2422 if (equals(extrusion, Vector<3, fltp08>(0.0, 0.0, -1.0), 0.00001))
2423 return Matrix<fltp08>(-1.0);
2424 if (abs(extrusion[Y]) < 1.0)
2425 return Plane<3, fltp08>(extrusion, Vector<3, fltp08>(0.0)).projectionMatrix(Vector<3, fltp08>(0.0, 0.0, -1.0));
2426 else
2427 return Plane<3, fltp08>(extrusion, Vector<3, fltp08>(0.0)).projectionMatrix(Vector<3, fltp08>(0.0, 0.0, -1.0));
2428 }
2429 public:
2430 void setGroupImport(bool group_import)
2431 {
2432 m_group_import = group_import;
2433 }
2434 void setTextFacingCamera(bool text_face_camera)
2435 {
2436 m_text_face_camera = text_face_camera;
2437 }
2438 void setAutoNameObjects(bool auto_name_objects)
2439 {
2440 m_auto_name_objects = auto_name_objects;
2441 }
2442 void setIgnoreKnownBlocks(bool ignore_known_blocks)
2443 {
2444 m_ignore_known_blocks = ignore_known_blocks;
2445 }
2446
2447 [[nodiscard]] Buffer<UUID> getAllReadEntities() const
2448 {
2449 Buffer<UUID> ids;
2450 ids.addAll(m_model_roots);
2453 ids.addAll(m_points_read);
2454 ids.addAll(m_meshes_read);
2455 for (const auto& id : m_layers)
2456 {
2457 ids.add(id.second);
2458 }
2459 for (const UUID& id : m_materials_read)
2460 {
2461 ids.add(id);
2462 }
2463 for (const UUID& id : m_blocks_read)
2464 {
2465 ids.add(id);
2466 }
2467 return ids;
2468 }
2469 protected:
2470 void setupLayer(Model& model)
2471 {
2472 if (m_current_data.layer.size() > 0)
2473 {
2474 if (m_current_data.layer != "1" && !m_layers.hasKey(m_current_data.layer))
2475 {
2476 m_logger.addMessage(LogMessage(_t("Entity Missing Layer").translation() + ": " + String(m_current_data.file_line_number), LogMessage::e_warning));
2477 }
2478 if (!m_layers.hasKey(m_current_data.layer))
2479 {
2481 }
2482 Model core_layer = getLayer(m_current_data.layer);
2483 Model layer;
2484 if (!m_model_lookup->hasLayerID(core_layer.uuid(), model.getScene().uuid()))
2485 {
2486 layer = model.createSceneLayer();
2487 layer.copyFrom(core_layer, false, true);
2488 m_model_lookup->addLayer(layer);
2489 }
2490 else
2491 {
2492 layer = m_model_lookup->layer(core_layer.uuid(), model.getScene().uuid());
2493 }
2494 model.setLayer(layer);
2495 }
2496 }
2497 #if NDEVR_TEXT_MODEL
2498 DynamicPointer<TextConstructor> getTextContructor(const String& font_name, const Font& font)
2499 {
2500 if (!m_text_constructors.hasKey(font_name))
2501 {
2502 DynamicPointer<TextConstructor> engine = new TextConstructor(font);
2503
2504 m_text_constructors.insert({ font_name, engine });
2505 return engine;
2506 }
2507 return m_text_constructors.get(font_name);
2508 }
2509 DynamicPointer<TextConstructor> getTextContructor(const String& font)
2510 {
2511 if (!m_text_constructors.hasKey(font))
2512 {
2513 DynamicPointer<TextConstructor> engine = new TextConstructor(FontEngine::ApplicationFont(font));
2514
2515 m_text_constructors.insert({ font, engine });
2516 return engine;
2517 }
2518 return m_text_constructors.get(font);
2519 }
2520 #endif
2521 protected:
2535 #if NDEVR_TEXT_MODEL
2537 #endif
2571
2580 bool m_color_by_vertex = false;
2581 bool m_group_import = true;
2586 bool m_ignore_current = false;//when true, ignores any information
2588 std::function<void(uint04 value, DXFValueManager* manager)> m_xdata_callback;
2597 };
2598}
2599
#define UNUSED(expr)
Definition BaseValues.hpp:433
#define lib_assert(expression, message)
Asserts some logic in the code. Disabled in non debug mode by default. Can be re-enabled in release u...
Definition LibAssert.h:70
#define _t(english_string)
Definition Translator.h:87
#define _td(def, english_string)
Definition Translator.h:91
ACI colors are the standard colors used in AutoCAD-based products. Each color is identified by an ACI...
Definition ACIColor.h:58
static constexpr Angle< t_angle_type > Heading(const Vector< t_dims, t_type > ray)
Definition AngleFunctions.h:850
Stores an angle in an optimized format.
Definition StringStream.h:352
Model class for storing, rendering, and logically modifying a 3D conic arc.
Definition ArcShape.h:11
void setupConicArc(const Angle< fltp08 > &start, const Angle< fltp08 > &end, fltp08 radius)
Definition ArcShape.cpp:27
Definition RadialObject.hpp:203
static BiRadialObject< t_dims, t_type, t_vertex > fromCircleTransform(const Matrix< t_matrix_type > &mat)
Definition RadialObject.hpp:216
constexpr t_vertex center() const
Definition RadialObject.hpp:297
A bitset that stores 8 bits (elements with only two possible values: 0 or 1, true or false,...
Definition BitFlag.hpp:68
A specification of upper and lower bounds in N-dimensions.
Definition Bounds.hpp:57
The equivelent of std::vector but with a bit more control. The basic array unit of the library.
Definition Buffer.hpp:64
void add(t_type &&object)
Definition Buffer.hpp:199
constexpr t_index_type size() const
Definition Buffer.hpp:1461
decltype(auto) last()
Definition Buffer.hpp:977
void addAll(const Buffer< t_type, t_other_index_type, t_other_memory_allocator, t_other_memory_manager > &buffer)
Definition Buffer.hpp:248
void clear()
Definition Buffer.hpp:572
decltype(auto) get(t_index_type index)
Definition Buffer.hpp:857
void removeLast()
Definition Buffer.hpp:1099
Definition CADEntityStreamer.h:42
virtual void addDimAlign(const DimAlignedData &)
Definition CADEntityStreamer.h:82
Extrusion m_extrusion
Definition CADEntityStreamer.h:137
ProgressInfo & m_logger
Definition CADEntityStreamer.h:138
bool m_log_features
Definition CADEntityStreamer.h:136
virtual void addDimLinear(const LinearDimension &)
Definition CADEntityStreamer.h:83
virtual void addAttribute(const Attrib &)
Definition CADEntityStreamer.h:63
virtual void addText(const TextData &)
Definition CADEntityStreamer.h:81
virtual void addAttributeDefintion(const Attrib &)
Definition CADEntityStreamer.h:64
Definition EntityConverter.h:132
~CADMeshVertexAttributeSetter()
Definition EntityConverter.h:138
void setValue()
Definition EntityConverter.h:142
CADMeshVertexAttributeSetter(VertexProperty vert_property, const Geometry &geo, const void *lock_ptr)
Definition EntityConverter.h:134
void finish()
Definition EntityConverter.h:146
uint04 current_value
Definition EntityConverter.h:153
const void * lock_ptr
Definition EntityConverter.h:154
Vertex< 3, fltp04 > vertex
Definition EntityConverter.h:152
Definition EntityConverter.h:157
RGBColor vertex
Definition EntityConverter.h:177
void setValue()
Definition EntityConverter.h:167
CADMeshVertexColorSetter(VertexProperty vert_property, const Geometry &geo, const void *lock_ptr)
Definition EntityConverter.h:159
void finish()
Definition EntityConverter.h:171
uint04 current_value
Definition EntityConverter.h:178
const void * lock_ptr
Definition EntityConverter.h:179
~CADMeshVertexColorSetter()
Definition EntityConverter.h:163
Definition GraphicsPipeline.h:42
Definition DXFAttributes.h:39
Definition DXFValueManager.h:42
t_type getValue(const t_type &default_value) const
Definition DXFValueManager.h:228
bool setValue(uint04 location, const String &value)
Definition DXFValueManager.cpp:6
Scene getScene() const
Definition DesignObject.cpp:599
bool isValid() const
Definition DesignObject.h:362
UUID uuid() const
Definition DesignObject.cpp:533
void updateProperty(DesignProperty property, const t_type &value, const void *lock=nullptr)
Definition DesignObject.h:251
t_type getProperty(DesignProperty property) const
Definition DesignObject.h:263
void offset(const Vector< 3, fltp08 > &offset)
Definition DesignObject.cpp:391
void setMetaData(const JSONNode &node)
Definition DesignObject.cpp:409
void setDesignVisible(bool is_visible)
Definition DesignObject.cpp:566
Matrix< fltp08 > getTransform() const
Definition DesignObject.cpp:593
void setProperty(DesignProperty property, const t_type &value)
Definition DesignObject.h:184
@ e_transform
Definition DesignObject.h:97
@ e_name
Definition DesignObject.h:100
@ e_is_frozen
Definition DesignObject.h:132
@ e_is_application_owned
Definition DesignObject.h:122
@ e_tree_visible
Definition DesignObject.h:111
@ e_bounds_ignored
Definition DesignObject.h:123
@ e_guid
Definition DesignObject.h:95
@ e_icon
Definition DesignObject.h:112
@ e_is_deleted
Definition DesignObject.h:120
@ e_description
Definition DesignObject.h:101
DesignObjectBase & base() const
Definition DesignObject.h:356
Definition DesignObjectLookup.h:61
bool hasLayerID(const UUID &id, bool allow_deleted=false) const
Definition DesignObjectLookup.cpp:1836
Scene scene(const UUID &id, bool allow_deleted=false) const
Definition DesignObjectLookup.cpp:1665
Model findLayer(const String &layer, bool use_translation=true) const
Definition DesignObjectLookup.cpp:1725
bool hasModelID(const UUID &id, bool allow_deleted=false) const
Definition DesignObjectLookup.cpp:1815
bool hasGeometryID(const UUID &id) const
Definition DesignObjectLookup.cpp:1808
virtual void addScene(Scene scene, bool ignore_application_scene=false)
Definition DesignObjectLookup.cpp:215
const void * lockPtr() const
Definition DesignObjectLookup.cpp:1027
WLock writeLock()
Definition DesignObjectLookup.cpp:965
Geometry geometry(const UUID &id, bool allow_deleted=false) const
Definition DesignObjectLookup.cpp:1656
bool hasMaterialID(const UUID &id) const
Definition DesignObjectLookup.cpp:1801
virtual void addGeometry(Geometry object)
Definition DesignObjectLookup.cpp:173
Model model(const UUID &id, bool allow_deleted=false) const
Definition DesignObjectLookup.cpp:1683
virtual void addLayer(Model layer)
Definition DesignObjectLookup.cpp:381
virtual void addModel(Model object)
Definition DesignObjectLookup.cpp:268
Model layer(const UUID &id, bool allow_deleted=false) const
Definition DesignObjectLookup.cpp:1695
Material material(const UUID &id, bool allow_deleted=false) const
Definition DesignObjectLookup.cpp:1647
virtual void addMaterial(Material object)
Definition DesignObjectLookup.cpp:887
Definition Dictionary.h:48
Definition Pointer.hpp:303
constexpr t_type & get() const
Definition Pointer.hpp:321
Definition EntityConverter.h:183
Buffer< Vertex< 3, fltp08 > > m_quad_position_data
Definition EntityConverter.h:2548
void addDictionary(const CADDictionaryObject &dictionary) override
Definition EntityConverter.h:527
EntityData m_current_data
Definition EntityConverter.h:2547
Geometry m_current_geometry
Definition EntityConverter.h:2560
void setupLayer(Model &model)
Definition EntityConverter.h:2470
Buffer< UUID > m_linework_read
Definition EntityConverter.h:2565
Geometry createGeometry()
Definition EntityConverter.h:2227
uint04 m_circle_count
Definition EntityConverter.h:2589
const Buffer< UUID > & lineworkRead() const
Definition EntityConverter.h:2415
Scene paperRoot()
Definition EntityConverter.h:1866
virtual void addIndex(const Vector< 4, sint04 > &vertex) override
Definition EntityConverter.h:1640
std::function< void(uint04 value, DXFValueManager *manager)> m_xdata_callback
Definition EntityConverter.h:2588
EntityConverter(const File &relative_path, DesignObjectLookup *lookup, ProgressInfo *logger)
Definition EntityConverter.h:185
Geometry & currentTriMesh()
Definition EntityConverter.h:2362
String m_current_block_name
Definition EntityConverter.h:2545
uint04 m_ellipse_count
Definition EntityConverter.h:2590
Dictionary< String, StyleData > m_text_styles
Definition EntityConverter.h:2573
virtual void addLinetypeDash(double) override
Definition EntityConverter.h:773
Dictionary< uint04, std::pair< UUID, VertexProperty > > m_mesh_object_field_listeners
Definition EntityConverter.h:2543
UUID m_last_insert
Definition EntityConverter.h:2559
void addDXFMaterial(DXFMaterial &mat) override
Definition EntityConverter.h:657
DesignObjectLookup * m_model_lookup
Definition EntityConverter.h:2577
void endFaceSection()
Definition EntityConverter.h:269
Buffer< UUID > getAllReadEntities() const
Definition EntityConverter.h:2447
void addLayer(const LayerData &layer) final override
Definition EntityConverter.h:451
Dictionary< String, Buffer< Model > > m_blocks_to_insert
Definition EntityConverter.h:2575
void setGroupImport(bool group_import)
Definition EntityConverter.h:2430
virtual void endBlock(const uint04 &) override
Definition EntityConverter.h:920
Dictionary< String, UUID > m_blocks
Definition EntityConverter.h:2574
Geometry & currentPolyMesh()
Definition EntityConverter.h:2377
const ConstPointer< Unit > & unit() const
Definition EntityConverter.h:432
void setVariableInt(const String &label, int value, int key_label) override
Definition EntityConverter.h:2295
Buffer< UUID > m_blocks_read
Definition EntityConverter.h:2568
fltp08 m_next_bulge
Definition EntityConverter.h:2570
Geometry currentLinework()
Definition EntityConverter.h:2342
Buffer< UUID > m_materials_read
Definition EntityConverter.h:2569
Scene currentRoot()
Definition EntityConverter.h:1882
virtual ~EntityConverter()
Definition EntityConverter.h:202
void setExtrusion(fltp08 dx, fltp08 dy, fltp08 dz, fltp08 elevation) override
Definition EntityConverter.h:1857
void setupEntityMaterial(Model model)
Definition EntityConverter.h:212
Dictionary< uint04, UUID > m_mesh_object_dictionary_listeners
Definition EntityConverter.h:2542
void copyBlock(Model &model, Model &block)
Definition EntityConverter.h:829
virtual void addSpline(const SplineData &) override
Definition EntityConverter.h:1719
void addXRecord(const HandleData &record) override
Definition EntityConverter.h:550
void setHandleManager(const DynamicPointer< CADHandleManager > &handle_manager)
Definition EntityConverter.h:198
DimensionOptions m_dim_options
Definition EntityConverter.h:2596
void setupColorForGeoVertices()
Definition EntityConverter.h:953
virtual void addGroup(const DXFGroup &group_info) override
Definition EntityConverter.h:863
bool m_ignore_known_blocks
Definition EntityConverter.h:2584
Dictionary< uint04, std::pair< UUID, VertexProperty > > m_mesh_object_color_listeners
Definition EntityConverter.h:2544
bool m_color_by_vertex
Definition EntityConverter.h:2580
void addBulge(Geometry &geo, fltp08 bulge, const Vertex< 3, fltp08 > &p1, const Vertex< 3, fltp08 > &p2)
Definition EntityConverter.h:2154
bool m_read_paper_space
Definition EntityConverter.h:2579
Buffer< TextBlock > parseString(const String &text, fltp08 default_height)
Definition EntityConverter.h:1925
Buffer< Model > modelRoots() const
Definition EntityConverter.h:1873
UUID m_current_entity
Definition EntityConverter.h:2558
UUID m_current_material
Definition EntityConverter.h:2564
void addXRecordData(uint04 value, DXFValueManager *value_manager) override
Definition EntityConverter.h:631
DynamicPointer< CADHandleManager > m_handle_manager
Definition EntityConverter.h:2572
UUID m_blocks_root
Definition EntityConverter.h:2556
Buffer< RGBColor > m_quad_color_data
Definition EntityConverter.h:2550
CADMeshVertexAttributeSetter * m_mesh_attribute_setter
Definition EntityConverter.h:2593
virtual void addBlock(const BlockData &block_info) override
Definition EntityConverter.h:883
virtual void addTextStyle(const StyleData &text_style) override
Definition EntityConverter.h:978
Buffer< UUID > m_points_read
Definition EntityConverter.h:2566
void addXLine(const LineData &line) override
Definition EntityConverter.h:1085
virtual void add3dFace(const TraceData &data) override
Definition EntityConverter.h:1185
Geometry m_current_linework
Definition EntityConverter.h:2561
void setAutoNameObjects(bool auto_name_objects)
Definition EntityConverter.h:2438
void addLine(const LineData &line) override
Definition EntityConverter.h:1025
Buffer< Vertex< 3, fltp08 > > m_tri_position_data
Definition EntityConverter.h:2549
Dictionary< UUID, String > m_child_blocks_to_insert
Definition EntityConverter.h:2576
bool m_group_import
Definition EntityConverter.h:2581
Extrusion & getExtrusion()
Definition EntityConverter.h:1863
Model getLayer(const String &layer_name)
Definition EntityConverter.h:707
void setIgnoreKnownBlocks(bool ignore_known_blocks)
Definition EntityConverter.h:2442
Buffer< RGBColor > m_tri_color_data
Definition EntityConverter.h:2551
void addRay(const LineData &ray) override
Definition EntityConverter.h:1126
void addDimRadial(const RadialDimension &) override
Definition EntityConverter.h:1764
DXFMode
Definition EntityConverter.h:2523
@ e_measurement
Definition EntityConverter.h:2533
@ e_3D_trace
Definition EntityConverter.h:2532
@ e_polyline
Definition EntityConverter.h:2526
@ e_closed_polyline
Definition EntityConverter.h:2529
@ e_leader
Definition EntityConverter.h:2527
@ e_line
Definition EntityConverter.h:2528
@ e_3D_face
Definition EntityConverter.h:2531
@ e_points
Definition EntityConverter.h:2525
@ e_none
Definition EntityConverter.h:2524
@ e_polyface
Definition EntityConverter.h:2530
virtual void addPolyline(const PolylineData &poly) override
Definition EntityConverter.h:1468
Buffer< UUID > m_model_roots
Definition EntityConverter.h:2553
virtual void addLeader(const LeaderData &data) override
Definition EntityConverter.h:1780
virtual void addLinetype(const LineTypeData &) override
Definition EntityConverter.h:772
Vertex< 3, fltp08 > m_position_offset
Definition EntityConverter.h:2587
Material getMaterial()
Definition EntityConverter.h:436
Geometry m_current_mesh
Definition EntityConverter.h:2562
void addDimDiametric(const DiametricDimension &) override
Definition EntityConverter.h:1768
UUID m_current_paper_root
Definition EntityConverter.h:2555
void addDimOrdinate(const DimOrdinateData &) override
Definition EntityConverter.h:1777
DXFMode m_current_mode
Definition EntityConverter.h:2578
File m_relative_path
Definition EntityConverter.h:2595
Model getBlockModel(const String &block_name)
Definition EntityConverter.h:775
Geometry currentCloud()
Definition EntityConverter.h:2392
void addCircle(const CircleData &c) override
Definition EntityConverter.h:1370
bool m_auto_name_objects
Definition EntityConverter.h:2583
virtual void addPoint(const PointData &point) override
Definition EntityConverter.h:982
bool m_ignore_known_materials
Definition EntityConverter.h:2585
String m_last_x_data_label
Definition EntityConverter.h:2541
bool m_ignore_current
Definition EntityConverter.h:2586
Material generateNewMaterial()
Definition EntityConverter.h:741
virtual void addVertex(const Vector< 4, fltp08 > &vertex) override
Definition EntityConverter.h:1586
UUID m_core_root
Definition EntityConverter.h:2554
virtual void addTrace(const TraceData &data) override
Definition EntityConverter.h:1157
Model currentBlock()
Definition EntityConverter.h:1913
Buffer< UUID > m_meshes_read
Definition EntityConverter.h:2567
void endSection() final override
Definition EntityConverter.h:342
const Buffer< UUID > & meshesRead() const
Definition EntityConverter.h:2416
virtual void endEntity() override
Definition EntityConverter.h:1848
bool m_text_face_camera
Definition EntityConverter.h:2582
Dictionary< uint04, Material > m_materials
Definition EntityConverter.h:2538
void addDimAngular(const AngularDimensionData< 3 > &) override
Definition EntityConverter.h:1771
virtual void addComment(const String &comment) override
Definition EntityConverter.h:1808
void setTextFacingCamera(bool text_face_camera)
Definition EntityConverter.h:2434
void addArc(const ArcData &arc) override
Definition EntityConverter.h:1263
virtual void addEllipse(const EllipseData &e) override
Definition EntityConverter.h:1405
const Buffer< UUID > & pointsRead() const
Definition EntityConverter.h:2414
Material getMaterial(const uint04 &material_handle)
Definition EntityConverter.h:749
Dictionary< String, String > m_x_data
Definition EntityConverter.h:2539
uint04 m_insert_count
Definition EntityConverter.h:2591
void setAttributes(const DXFAttributes &) override
Definition EntityConverter.h:1852
UUID m_current_block
Definition EntityConverter.h:2557
Geometry m_current_points
Definition EntityConverter.h:2563
Model currentEntity()
Definition EntityConverter.h:2242
CADMeshVertexColorSetter * m_mesh_color_setter
Definition EntityConverter.h:2594
static Matrix< fltp08 > GetOrientation(const Vector< 3, fltp08 > &extrusion)
Definition EntityConverter.h:2418
uint04 m_attribute_count
Definition EntityConverter.h:2592
void addDimAngular(const AngularDimensionData< 4 > &) override
Definition EntityConverter.h:1774
void _addLayer(const LayerData &layer_data)
Definition EntityConverter.h:458
virtual void addInsert(const BlockInsert &data) override
Definition EntityConverter.h:1673
Dictionary< String, UUID > m_point_name_data
Definition EntityConverter.h:2540
ConstPointer< Unit > m_unit
Definition EntityConverter.h:2546
String convertFromCADName(const String &file_name, const TranslatedString &object_type, uint04 object_count)
Definition EntityConverter.h:512
Dictionary< String, UUID > m_layers
Definition EntityConverter.h:2552
virtual void addMesh(CADMeshData &mesh_data) override
Definition EntityConverter.h:1523
logic for storing a extrusion data in a CAD-friendly way for exporting and importing.
Definition CADEntities.h:1004
void setDirection(fltp08 dx, fltp08 dy, fltp08 dz)
Definition CADEntities.h:1016
void setElevation(double elevation)
Definition CADEntities.h:1024
Definition File.h:47
NDEVR_BASE_API bool exists() const
Definition File.cpp:1010
static NDEVR_BASE_API const Font & ApplicationFont(const String &app_font)
Definition Font.cpp:209
static constexpr char DefaultFont[8]
Definition Font.h:66
Definition Geometry.h:64
static void OptimizedSetPrimitiveVec(const OptimizedPrimitiveDef &ref, uint04 index, t_vec_type index_value)
Definition Geometry.h:421
OptimizedPrimitiveDef optimizedPrimitiveDef(PrimitiveProperty property)
Definition Geometry.h:394
void setTransform(const Matrix< fltp08 > &transform)
Definition Geometry.cpp:2708
void updateModifiedTime(Time time=Time::SystemTime())
Definition Geometry.cpp:2008
bool validate() const
Definition Geometry.cpp:2386
void updateVertexColumns(bool invalidate_bounds=true, bool erase_kd_tree=true)
Definition Geometry.cpp:2206
void setPrimitive(PrimitiveProperty property, uint04 index, t_type index_value)
Definition Geometry.h:335
void setGeometryProperty(GeometryProperty property, const t_type &value)
Definition Geometry.h:147
static void OptimizedSetPrimitive(const OptimizedPrimitiveDef &ref, uint04 index, t_vec_type index_value)
Definition Geometry.h:408
void setThicknessMode(ThicknessMode mode)
Definition Geometry.cpp:494
t_type vertex(VertexProperty property, uint04 index) const
Definition Geometry.h:919
Buffer< Model, uint04, ObjectAllocator< DESIGN_PRIM > > getParents() const
Definition Geometry.cpp:1230
void setVertices(VertexProperty property, const Buffer< t_type > &vertices, uint04 offset=0)
Definition Geometry.h:885
uint04 addVertices(uint04 size)
Definition Geometry.h:686
@ e_color_rgb
Definition Geometry.h:89
@ e_cartesian_3F
Definition Geometry.h:74
@ e_no_vertex
Definition Geometry.h:69
void updateTransform(const Matrix< fltp08 > &transform, const void *lock_ptr=nullptr)
Definition Geometry.cpp:2719
uint04 vertexCount() const
Definition Geometry.h:713
void setupVertexTable(uint04 vertex_size, VertexMode position, VertexMode normal=VertexMode::e_no_vertex, VertexMode color=VertexMode::e_no_vertex, VertexMode texture=VertexMode::e_no_vertex, VertexMode tangent=VertexMode::e_no_vertex, VertexMode bitangent=VertexMode::e_no_vertex, VertexMode bones=VertexMode::e_no_vertex)
Definition Geometry.cpp:1203
void setGeometryType(GeometryType geometry_type)
Definition Geometry.cpp:1016
void autoCalculateIndices(PrimitiveProperty property, const void *lock=nullptr, ProgressInfo *log=nullptr, const Matrix< fltp08 > &transform=Matrix< fltp08 >(1.0))
Definition Geometry.cpp:2913
uint04 primitiveCount(PrimitiveProperty property) const
Definition Geometry.h:669
void setVertexMode(VertexProperty property, VertexMode mode)
Definition Geometry.cpp:1837
void updatePrimitiveColumns(bool remove_tree=true)
Definition Geometry.cpp:1999
uint04 vertexOffset() const
Definition Geometry.h:709
void setVertex(VertexProperty property, uint04 index, const t_type &vector)
Definition Geometry.h:871
@ e_flat_single
Definition Geometry.h:133
void updateVertexColumn(VertexProperty property)
Definition Geometry.cpp:2143
@ e_shape_type
Definition Geometry.h:116
@ e_thickness
Definition Geometry.h:101
uint04 addPrimitive(PrimitiveProperty index_property, const t_type &primitive)
Definition Geometry.h:648
void clearVerticesAndPrimitives()
Definition Geometry.cpp:1059
void setPrimitiveMode(PrimitiveProperty property, PrimitiveMode mode)
Definition Geometry.cpp:1981
PrimitiveMode mode(PrimitiveProperty property) const
Definition Geometry.h:309
uint04 addPrimitives(PrimitiveProperty index_property, uint04 insersion_size)
Definition Geometry.h:655
uint04 addVertex()
Definition Geometry.h:680
void closePolyline(PrimitiveProperty property)
Definition Geometry.cpp:2889
A line segment represented by two vertices, a start and end.
Definition Line.hpp:55
constexpr t_precision length() const
Definition Line.hpp:488
constexpr bool intersects(const LineSegment &segment, t_precision epsilon=cast< t_precision >(0.001)) const
Definition Line.hpp:578
Definition LogMessage.h:40
@ e_warning
Definition LogMessage.h:48
Definition Material.h:45
@ e_gouraud
Definition Material.h:50
void setMaterialProperty(MaterialProperties mat_index, const t_type &type)
Definition Material.h:173
void updateModifiedTime(const Time &time=Time::SystemTime())
Definition Material.cpp:871
@ e_shininess
Definition Material.h:113
@ e_two_sided
Definition Material.h:109
void setUVColor(const t_type &type)
Definition Material.h:202
void setShadingModel(ShadingModel model)
Definition Material.cpp:516
@ e_background_contrast
Definition Material.h:75
@ e_color_by_model
Definition Material.h:73
@ e_color_by_layer
Definition Material.h:78
@ e_color_channel
Definition Material.h:71
@ e_image
Definition Material.h:77
void setUVMode(UVType uv_index, const UVMode &type)
Definition Material.cpp:877
void setUVImage(UVType uv_index, const t_type &type)
Definition Material.h:196
void setUVIntensity(UVType uv_index, const t_type &type)
Definition Material.h:231
Definition Matrix.hpp:173
constexpr Matrix offset(const Vector< 2, t_type > &translation) const
Definition Matrix.hpp:561
constexpr Matrix scale(t_type scale) const
Definition Matrix.hpp:579
static constexpr Matrix< t_type > OffsetMatrix(const Vector< 3, t_type > &translation)
Definition Matrix.hpp:294
Matrix< t_type, t_cols, t_rows > invert() const
Definition Matrix.hpp:649
constexpr Vector< 3, t_type > decomposeOffset() const
Definition Matrix.hpp:440
constexpr Matrix rotate(const Vector< 3, Angle< t_angle_type > > &orientation) const
Definition Matrix.hpp:623
Definition Model.h:54
void invalidateBounds()
Definition Model.cpp:840
Matrix< fltp08 > getCompleteTransform() const
Definition Model.cpp:117
Dictionary< UUID, DesignObject > copyFrom(const Model &model, bool deep_copy, bool copy_ids=false, bool recursive=true)
Definition Model.cpp:1511
void setTransform(const Matrix< fltp08 > &transform)
Definition Model.cpp:3360
Geometry getGeometry() const
Definition Model.cpp:427
void setMaterialMode(MaterialMode vertex, MaterialMode outline, MaterialMode solid)
Definition Model.cpp:1882
void updateModifiedTime(Time time=Time::SystemTime())
Definition Model.cpp:2289
Material getMaterial(PrimitiveProperty property) const
Definition Model.cpp:465
Material createSceneMaterial() const
Definition Model.cpp:3209
uint04 getDirectLayerIndex() const
Definition Model.cpp:2355
Buffer< Model, uint04, ObjectAllocator< DESIGN_PRIM > > getChildren() const
Definition Model.cpp:2733
void addChild(Model &child)
Definition Model.cpp:3301
Model createChild()
Definition Model.cpp:3020
Model getParent() const
Definition Model.cpp:2057
Buffer< Model, uint04, ObjectAllocator< DESIGN_PRIM > > getChildrenByName(const String &name) const
Definition Model.cpp:2793
void setModelProperty(ModelProperty property, const t_type &value)
Definition Model.h:137
Geometry createChildGeometry()
Definition Model.cpp:1903
bool hasMaterial() const
Definition Model.cpp:436
void updateTransform(const Matrix< fltp08 > &transform, const void *lock=nullptr)
Definition Model.cpp:2118
Model createSceneModel() const
Definition Model.cpp:3189
void setMaterial(PrimitiveProperty property, uint04 material_index)
Definition Model.cpp:792
@ e_fixed_bounding_box
Definition Model.h:101
@ e_export_ignored
Definition Model.h:115
@ e_model_color
Definition Model.h:112
void setLayer(Model layer)
Definition Model.cpp:2359
void clearLayer()
Definition Model.cpp:2375
Model createSceneLayer() const
Definition Model.cpp:3195
Definition Geometry.h:41
Matrix< t_type > projectionMatrix(const Vector< 3, t_type > &up) const
Definition Plane.hpp:134
Definition ProgressInfo.hpp:43
virtual bool addMessage(const LogMessage &message)=0
Represents a color in the RGB space with optional alpha transparency.
Definition RGBColor.h:53
static const uint01 r_pos
Definition RGBColor.h:55
static const uint01 g_pos
Definition RGBColor.h:56
static const uint01 b_pos
Definition RGBColor.h:57
constexpr t_type radius() const
Definition RadialObject.hpp:134
constexpr const t_vertex & center() const
Definition RadialObject.hpp:167
Definition Model.h:491
void createDefaultMaterial()
Definition Model.cpp:3478
static void Circle(Geometry &mesh, const Matrix< fltp08 > &trans=Matrix< fltp08 >(1), uint04 width_segments=128, fltp08 radius=1.0f, Angle< fltp08 > phi_start=Angle< fltp08 >(DEGREES, 0.0f), Angle< fltp08 > phi_length=Angle< fltp08 >(DEGREES, 360.0f), bool join=true)
Definition ShapeConstructors.cpp:250
Definition String.h:40
NDEVR_BASE_API uint08 hashLower() const
Definition String.cpp:513
static NDEVR_BASE_API String toHex(uint01 value)
Definition String.cpp:1150
t_type getAs() const
Definition String.h:334
NDEVR_BASE_API String & replace(const String &sub_string, const String &replace_sub_string, bool ignore_case=false)
Definition String.cpp:343
NDEVR_BASE_API String & formatNumberString(uint04 decimals)
Definition String.cpp:591
NDEVR_BASE_API uint08 hash() const
Definition String.cpp:494
NDEVR_BASE_API bool beginsWith(const String &s, bool ignore_case=false) const
Definition String.cpp:412
Definition TranslatedString.h:9
NDEVR_BASE_API TranslatedString & replace(const String &sub_string, const TranslatedString &replacement)
Definition TranslatedString.cpp:51
Definition UUID.h:66
static NDEVR_BASE_API UUID CreateUUID()
Definition UUID.cpp:150
static ConstPointer< Unit > Kilometers()
Definition UnitDefinitions.cpp:43
static ConstPointer< Unit > InternationalMiles()
static ConstPointer< Unit > Meters()
Definition UnitDefinitions.cpp:13
static ConstPointer< Unit > Feet()
Definition UnitDefinitions.cpp:19
static ConstPointer< Unit > EastingNorthingElevation(const Unit &length_unit)
Definition UnitDefinitions.cpp:686
static ConstPointer< Unit > Gradians()
Definition UnitDefinitions.cpp:490
static ConstPointer< Unit > Centimeters()
Definition UnitDefinitions.cpp:31
static ConstPointer< Unit > Dekameters()
static ConstPointer< Unit > Yards()
Definition UnitDefinitions.cpp:66
static ConstPointer< Unit > Angstrom()
static ConstPointer< Unit > Degrees()
Angle Units.
Definition UnitDefinitions.cpp:460
static ConstPointer< Unit > Parsecs()
static ConstPointer< Unit > LightYears()
static ConstPointer< Unit > Microns()
static ConstPointer< Unit > Inches()
Definition UnitDefinitions.cpp:26
static ConstPointer< Unit > Microinches()
static ConstPointer< Unit > Decimeters()
static ConstPointer< Unit > AstronomicalUnits()
static ConstPointer< Unit > Millimeters()
Definition UnitDefinitions.cpp:49
static ConstPointer< Unit > Nanometers()
static ConstPointer< Unit > Radians()
Definition UnitDefinitions.cpp:485
static ConstPointer< Unit > Hectometers()
static ConstPointer< Unit > DegreesMinutesSeconds()
Definition UnitDefinitions.cpp:473
static ConstPointer< Unit > Gigameters()
static ConstPointer< Unit > Mils()
An element of a vector space. An element of the real coordinate space Rn Basis vector,...
Definition Vector.hpp:62
constexpr t_magnitude_type magnitude() const
Definition Vector.hpp:482
constexpr Vector< t_dims, t_norm_type > normalized(Vector< t_dims, t_norm_type > value_if_nan=Constant< Vector< t_dims, t_norm_type > >::NaN) const
Definition Vector.hpp:500
constexpr Vector< t_dims, t_new_type > as() const
Definition Vector.hpp:324
A vertex.
Definition Vertex.hpp:54
Definition Geometry.h:1452
void setVertex(uint04 index, const Vertex< 3, fltp04 > &value)
Definition Geometry.h:1484
Geometry m_geo
Definition Geometry.h:1496
const VertexProperty m_vertex_property
Definition Geometry.h:1501
Definition RWLock.h:99
#define H(x, y, z)
Definition md5.cpp:17
Definition ACIColor.h:37
int32_t sint04
-Defines an alias representing a 4 byte, signed integer. -Can represent exact integer values -2147483...
Definition BaseValues.hpp:76
VertexProperty
Definition DesignObjectBase.h:52
ColorMode
Definition CADEntities.h:42
@ e_background_contrast
Definition CADEntities.h:46
@ e_by_layer
Definition CADEntities.h:45
@ e_by_block
Definition CADEntities.h:44
@ e_use
Definition CADEntities.h:43
float fltp04
Defines an alias representing a 4 byte floating-point number.
Definition BaseValues.hpp:157
@ DEGREES
Definition Angle.h:66
QAction * solid_material(nullptr)
t_type distanceSquared(const Bounds< t_dims, t_type, t_vertex > &bounds, const Vector< t_dims, t_type > &vertex)
Definition Distance.hpp:42
uint32_t uint04
-Defines an alias representing a 4 byte, unsigned integer -Can represent exact integer values 0 throu...
Definition BaseValues.hpp:120
constexpr t_to cast(const Angle< t_from > &value)
Definition Angle.h:514
constexpr t_type distance(const t_vertex &vertex, const LineSegment< t_dims, t_type, t_vertex > &line)
Definition Distance.hpp:250
constexpr bool equals(const LineSegment< t_dims, t_type, t_vertex > &left, const LineSegment< t_dims, t_type, t_vertex > &right, const t_type &epsilon=cast< t_type >(0))
Definition Line.hpp:819
constexpr Angle< t_angle_type > abs(const Angle< t_angle_type > &value)
Definition AngleFunctions.h:750
constexpr bool isNaN(const t_type &value)
Query if 'value' is valid or invalid.
Definition BaseFunctions.hpp:200
QAction * mesh(nullptr)
@ B
Definition BaseValues.hpp:203
@ A
Definition BaseValues.hpp:201
@ Y
Definition BaseValues.hpp:202
@ X
Definition BaseValues.hpp:200
@ C
Definition BaseValues.hpp:205
@ D
Definition BaseValues.hpp:207
@ Z
Definition BaseValues.hpp:204
double fltp08
Defines an alias representing an 8 byte floating-point number.
Definition BaseValues.hpp:181
logic for storing an angular dimension in a CAD-friendly way for exporting and importing.
Definition CADEntities.h:621
logic for storing a arc data in a CAD-friendly way for exporting and importing.
Definition CADEntities.h:271
fltp08 radius
Definition CADEntities.h:281
Angle< fltp08 > angle1
Definition CADEntities.h:283
Angle< fltp08 > angle2
Definition CADEntities.h:284
Vector< 3, fltp08 > offset
Definition CADEntities.h:280
logic for storing a attribue data in a CAD-friendly way for exporting and importing.
Definition CADEntities.h:458
String tag
Definition CADEntities.h:466
String default_value
Definition CADEntities.h:467
Definition CADEntities.h:172
Vertex< 3, fltp08 > offset
Definition CADEntities.h:178
String description
Definition CADEntities.h:179
Definition CADEntities.h:502
String block_name
Definition CADEntities.h:503
ColorMode mode
Definition CADEntities.h:69
RGBColor color
Definition CADEntities.h:70
Definition CADEntities.h:572
Buffer< CADVariable > data
Definition CADEntities.h:576
uint04 handle
Definition CADEntities.h:573
Definition CADEntities.h:366
uint04 data_dictionary_reference
Definition CADEntities.h:393
Buffer< Vertex< 3, fltp08 > > vertices
Definition CADEntities.h:383
Buffer< uint04 > face_points
Definition CADEntities.h:387
Definition CADEntities.h:82
Buffer< std::pair< sint04, String > > values
Definition CADEntities.h:129
String label
Definition CADEntities.h:128
logic for storing a circle data in a CAD-friendly way for exporting and importing.
Definition CADEntities.h:477
RadialObject< 3, fltp08 > circle
Definition CADEntities.h:478
fltp08 thickness
Definition CADEntities.h:479
Definition BaseValues.hpp:272
static const t_type NaN
Definition BaseValues.hpp:274
Definition CADEntities.h:982
String description
Definition CADEntities.h:984
String name
Definition CADEntities.h:983
Buffer< uint04 > group_objects
Definition CADEntities.h:987
Definition CADEntities.h:970
String description
Definition CADEntities.h:972
MaterialUVOptions ambient
Definition CADEntities.h:973
String name
Definition CADEntities.h:971
MaterialUVImageOptions diffuse
Definition CADEntities.h:974
Matrix< fltp08 > mat_matrix
Definition CADEntities.h:978
fltp08 specular_gloss_factor
Definition CADEntities.h:976
MaterialUVImageOptions specular
Definition CADEntities.h:975
logic for storing an diametric dimension in a CAD-friendly way for exporting and importing.
Definition CADEntities.h:605
Definition CADEntities.h:553
LineSegment< 3, fltp08 > alignment_data
Definition CADEntities.h:558
Definition CADEntities.h:642
Vector< 3, fltp08 > definition_point
Definition CADEntities.h:516
Definition EntityConverter.h:109
char decimal_seperator
Definition EntityConverter.h:127
String arrow_block_name
Definition EntityConverter.h:128
ConstPointer< Unit > angle_unit
Definition EntityConverter.h:121
ConstPointer< Unit > distance_unit
Definition EntityConverter.h:123
fltp08 dimension_scale_factor
Definition EntityConverter.h:126
fltp08 arrow_size
Definition EntityConverter.h:125
uint04 angle_min_decimals
Definition EntityConverter.h:122
DimensionMode
Definition EntityConverter.h:111
@ e_decimal
Definition EntityConverter.h:113
@ e_fractional_stacked
Definition EntityConverter.h:116
@ e_fractional
Definition EntityConverter.h:118
@ e_architectural_stacked
Definition EntityConverter.h:115
@ e_ngineering
Definition EntityConverter.h:114
@ e_scientific
Definition EntityConverter.h:112
@ e_architectural
Definition EntityConverter.h:117
DimensionMode display_mode
Definition EntityConverter.h:124
Definition CADEntities.h:482
Vertex< 3, fltp08 > endpoint_of_major_axis
Definition CADEntities.h:484
fltp08 minor_to_major_ratio
Definition CADEntities.h:486
Vertex< 3, fltp08 > center
Definition CADEntities.h:483
Angle< fltp08 > angle1
Definition CADEntities.h:487
Angle< fltp08 > angle2
Definition CADEntities.h:488
fltp08 thickness
Definition CADEntities.h:485
Definition CADEntities.h:139
uint04 file_line_number
Definition CADEntities.h:146
uint04 material_handle
Definition CADEntities.h:145
bool paper_space
Definition CADEntities.h:149
bool visible
Definition CADEntities.h:148
CADColorInfo color_info
Definition CADEntities.h:142
PaperSpace paper_space_info
Definition CADEntities.h:144
bool is_off
Definition CADEntities.h:147
String layer
Definition CADEntities.h:140
fltp08 elevation
Definition CADEntities.h:185
Vector< 3, fltp08 > extrusion
Definition CADEntities.h:184
Definition Font.h:41
bool is_bold
Definition Font.h:51
fltp08 point_size
Definition Font.h:44
RGBColor color
Definition Font.h:49
bool is_strikethrough
Definition Font.h:55
bool is_italic
Definition Font.h:52
String name
Definition Font.h:42
uint01 alignment
Definition Font.h:50
bool is_underline
Definition Font.h:53
bool is_overstrike
Definition Font.h:54
fltp08 fixed_width
Definition Font.h:46
Definition CADEntities.h:133
uint04 parent_handle
Definition CADEntities.h:135
uint04 handle
Definition CADEntities.h:134
Definition CADEntities.h:154
@ e_locked
Definition CADEntities.h:159
Vector< 8, bool > flags
Definition CADEntities.h:168
String name
Definition CADEntities.h:167
logic for storing a leader in a CAD-friendly way for exporting and importing.
Definition CADEntities.h:660
Definition CADEntities.h:491
LineSegment< 3, fltp08 > line
Definition CADEntities.h:492
fltp08 thickness
Definition CADEntities.h:493
Definition CADEntities.h:188
RGBColor color
Definition CADEntities.h:967
File map_file
Definition CADEntities.h:966
RGBColor color
Definition CADEntities.h:960
fltp08 color_intensity
Definition CADEntities.h:959
Matrix< fltp08 > paperToModelMatrix() const
Definition CADEntities.h:53
Vector< 3, fltp08 > scale
Definition CADEntities.h:498
Angle< fltp08 > azimuth
Definition CADEntities.h:499
Vector< 3, fltp08 > offset
Definition CADEntities.h:497
Definition CADEntities.h:509
Vector< 3, fltp08 > location
Definition CADEntities.h:510
logic for storing a polyline data in a CAD-friendly way for exporting and importing.
Definition CADEntities.h:293
Vector< 32, bool > flags
Definition CADEntities.h:329
@ e_is_3D_polyline
Definition CADEntities.h:299
@ e_is_3D_polygon
Definition CADEntities.h:300
@ e_closed
Definition CADEntities.h:296
@ e_is_polyface_mesh
Definition CADEntities.h:302
fltp08 thickness
Definition CADEntities.h:312
logic for storing a radial dimension in a CAD-friendly way for exporting and importing.
Definition CADEntities.h:590
logic for storing a spline data in a CAD-friendly way for exporting and importing.
Definition CADEntities.h:352
logic for storing a style data in a CAD-friendly way for exporting and importing.
Definition CADEntities.h:217
String name
Definition CADEntities.h:253
Definition Font.h:90
logic for storing a text data in a CAD-friendly way for exporting and importing.
Definition CADEntities.h:437
fltp08 height
Definition CADEntities.h:442
fltp08 reference_width
Definition CADEntities.h:443
Angle< fltp08 > rotatation
Definition CADEntities.h:445
fltp08 line_spacing_factor
Definition CADEntities.h:448
String text
Definition CADEntities.h:438
uint01 alignment
Definition CADEntities.h:450
Vertex< 3, fltp08 > align_a
Definition CADEntities.h:440
Vertex< 3, fltp08 > align_b
Definition CADEntities.h:441
logic for storing a trace data in a CAD-friendly way for exporting and importing.
Definition CADEntities.h:337
Vertex< 3, fltp08 > points[4]
Definition CADEntities.h:342