API Documentation
Loading...
Searching...
No Matches
CADDimensionWriteModifier.h
Go to the documentation of this file.
1#pragma once
3#if NDEVR_VIEWPORT && NDEVR_MEASURE_MODELS
5namespace NDEVR
6{
7 class Model;
8 struct CADGeometryWriter;
9 class DXFTableWriteIterator;
10 class DXFBlockWriter;
12 {
13 public:
14 static void WriteDistance(DXFBlockWriter& options, const Matrix<fltp08>& transform, const DistanceMeasureModel& dim, uint04 parent_handle)
15 {
16 auto iter = options.block_data.find(dim.uuid());
17 if (iter == options.block_data.end())
18 return;
19 DimAlignedData dim_data;
20 FillOutData(dim, dim_data);
21 dim_data.color_info = GenerateDXFColorInfo(dim, false, false);
22 options.writer.cleanupCADName(dim_data.layer);
23 dim_data.handle = options.writer.handleManager()->getHandleIndex(dim.uuid());
24 dim_data.dimension_block_name = iter.value().name;
25 dim_data.parent_handle = parent_handle;
26 dim_data.alignment_data = transform * dim.measurementLine();
27 dim_data.definition_point = dim_data.alignment_data[B];
28 dim_data.text_middle_point = (dim_data.alignment_data[A] + dim_data.alignment_data[B]) / 2.0;
29
30 //dim_data.extrusion = orientation.first;
31 options.writer.addDimAligned(dim_data);
32 }
33 bool canHandleBlock(const Model&) final override
34 {
35 return false;
36 //return model.isOfType(DistanceMeasureModel::TypeName());
37 }
39 {
40 BlockData data = options.convertToBlock(model);
41 data.handle = options.handle_manager->getHandleIndex(data.name);
42 options.handle_manager->setHandleToUUID(model.uuid(), data.handle);
43 options.handle_manager->setTransfromCoords(data.handle
44 , options.params.options.units.coordinate_space_unit.get()->matrix() * model.getCompleteTransform());
45 options.block_data.insert({ model.uuid(), data });
47 }
48 ModelIterator::ParseResult handleBlock(const Model& model, DXFBlockWriter& options) final override
49 {
50 const BlockData& block = options.block_data.get(model.uuid());
51 options.writer.startBlock(block);
52
53 DistanceMeasureModel distance(model);
54 Matrix<fltp08> transform = options.writer.handleManager()->transfromCoords(block.handle).invert()
55 * options.params.options.units.coordinate_space_unit.get()->matrix() * model.getCompleteTransform();
56 LineData data;
58 data.layer = block.layer;
59
60 FillOutData(model, data);
61 data.handle = options.writer.handleManager()->generateTempHandleIndex();
62 data.parent_handle = block.handle;
63 data.line = transform * distance.measurementLine();
64 options.writer.addLine(data);
65 options.writer.endBlock(block);
67 }
68 bool canHandleInsert(const Model& model) final override
69 {
70 return model.isOfType(DistanceMeasureModel::TypeName());
71 }
72 void handleInsert(const Matrix<fltp08>& parent_transform, const Model& model, uint04 parent_handle, DXFBlockWriter& options) final override
73 {
74 DistanceMeasureModel distance(model);
75 WriteDistance(options, parent_transform, distance, parent_handle);
76 }
77 void handleInsert(const Matrix<fltp08>&, const Model&, uint04, CADGeometryWriter&) final override
78 {
79
80 }
81 };
82}
83#endif
Definition CADDimensionWriteModifier.h:12
void handleInsert(const Matrix< fltp08 > &, const Model &, uint04, CADGeometryWriter &) final override
Definition CADDimensionWriteModifier.h:77
bool canHandleBlock(const Model &) final override
Definition CADDimensionWriteModifier.h:33
void handleInsert(const Matrix< fltp08 > &parent_transform, const Model &model, uint04 parent_handle, DXFBlockWriter &options) final override
Definition CADDimensionWriteModifier.h:72
ModelIterator::ParseResult handleBlock(const Model &model, DXFBlockWriter &options) final override
Definition CADDimensionWriteModifier.h:48
bool canHandleInsert(const Model &model) final override
Definition CADDimensionWriteModifier.h:68
static void WriteDistance(DXFBlockWriter &options, const Matrix< fltp08 > &transform, const DistanceMeasureModel &dim, uint04 parent_handle)
Definition CADDimensionWriteModifier.h:14
ModelIterator::ParseResult handleBlock(const Model &model, DXFTableWriteIterator &options) final override
Definition CADDimensionWriteModifier.h:38
Definition CADWriteModifier.h:11
Definition DXFBlockWriter.h:368
DXFWriter & writer
Definition DXFBlockWriter.h:372
const Dictionary< UUID, BlockData > & block_data
Definition DXFBlockWriter.h:370
Definition DXFBlockWriter.h:56
void addDimAligned(const DimAlignedData &alignment)
Definition DXFWriter.cpp:1790
void cleanupCADName(String &name)
Definition DXFWriter.cpp:1503
const DynamicPointer< CADHandleManager > & handleManager() const
Definition DXFWriter.h:56
Definition Matrix.hpp:173
Matrix< t_type, t_cols, t_rows > invert() const
Definition Matrix.hpp:649
Definition Model.h:54
ParseResult
Definition ModelIterator.h:42
@ e_continue_parsing
Definition ModelIterator.h:43
@ e_do_not_parse_children
Definition ModelIterator.h:44
Definition ACIColor.h:37
@ e_by_block
Definition CADEntities.h:44
CADColorInfo GenerateDXFColorInfo(const Model &model, bool is_flat, bool is_vertex)
Definition CADGeometryWriter.h:22
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_type distance(const t_vertex &vertex, const LineSegment< t_dims, t_type, t_vertex > &line)
Definition Distance.hpp:250
@ B
Definition BaseValues.hpp:203
@ A
Definition BaseValues.hpp:201
void FillOutData(const Model &model, EntityData &data)
Definition CADGeometryWriter.h:117
Definition CADEntities.h:172
ColorMode mode
Definition CADEntities.h:69
Definition CADGeometryWriter.h:126
Definition CADEntities.h:553
LineSegment< 3, fltp08 > alignment_data
Definition CADEntities.h:558
Vector< 3, fltp08 > text_middle_point
Definition CADEntities.h:517
Vector< 3, fltp08 > definition_point
Definition CADEntities.h:516
String dimension_block_name
Definition CADEntities.h:548
CADColorInfo color_info
Definition CADEntities.h:142
String layer
Definition CADEntities.h:140
uint04 parent_handle
Definition CADEntities.h:135
uint04 handle
Definition CADEntities.h:134
String name
Definition CADEntities.h:167
Definition CADEntities.h:491
LineSegment< 3, fltp08 > line
Definition CADEntities.h:492