acadrust 0.3.3

A pure Rust library for reading and writing CAD files in DXF format (ASCII and Binary) and DWG format (Binary).
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
//! Dimension entity types

use crate::entities::EntityCommon;
use crate::types::Vector3;

/// Dimension type flags
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub enum DimensionType {
    /// Rotated, horizontal, or vertical linear dimension
    Linear = 0,
    /// Aligned dimension
    Aligned = 1,
    /// Angular 2 lines dimension
    Angular = 2,
    /// Diameter dimension
    Diameter = 3,
    /// Radius dimension
    Radius = 4,
    /// Angular 3 points dimension
    Angular3Point = 5,
    /// Ordinate dimension
    Ordinate = 6,
}

/// Attachment point type for dimension text
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub enum AttachmentPointType {
    TopLeft = 1,
    TopCenter = 2,
    TopRight = 3,
    MiddleLeft = 4,
    MiddleCenter = 5,
    MiddleRight = 6,
    BottomLeft = 7,
    BottomCenter = 8,
    BottomRight = 9,
}

/// Base dimension entity
/// 
/// All dimension types share common properties and behavior.
/// Specific dimension types extend this base with additional properties.
#[derive(Debug, Clone, PartialEq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct DimensionBase {
    pub common: EntityCommon,
    /// Definition point for the dimension line (in WCS)
    pub definition_point: Vector3,
    /// Middle point of dimension text (in WCS)
    pub text_middle_point: Vector3,
    /// Insertion point for clones of a dimension (in OCS)
    pub insertion_point: Vector3,
    /// Dimension type
    pub dimension_type: DimensionType,
    /// Attachment point
    pub attachment_point: AttachmentPointType,
    /// Dimension text explicitly entered by the user
    pub text: String,
    /// User text override (alternative to text field)
    pub user_text: Option<String>,
    /// Normal vector (extrusion direction)
    pub normal: Vector3,
    /// Rotation angle of dimension text
    pub text_rotation: f64,
    /// Horizontal direction for the dimension entity
    pub horizontal_direction: f64,
    /// Dimension style name
    pub style_name: String,
    /// Actual measurement (computed)
    pub actual_measurement: f64,
    /// Version number
    pub version: u8,
    /// Block name that contains the dimension geometry
    pub block_name: String,
    /// Line spacing factor
    pub line_spacing_factor: f64,
}

impl DimensionBase {
    /// Create a new dimension base
    pub fn new(dim_type: DimensionType) -> Self {
        Self {
            common: EntityCommon::default(),
            definition_point: Vector3::new(0.0, 0.0, 0.0),
            text_middle_point: Vector3::new(0.0, 0.0, 0.0),
            insertion_point: Vector3::new(0.0, 0.0, 0.0),
            dimension_type: dim_type,
            attachment_point: AttachmentPointType::MiddleCenter,
            text: String::new(),
            user_text: None,
            normal: Vector3::new(0.0, 0.0, 1.0),
            text_rotation: 0.0,
            horizontal_direction: 0.0,
            style_name: "Standard".to_string(),
            actual_measurement: 0.0,
            version: 0,
            block_name: String::new(),
            line_spacing_factor: 1.0,
        }
    }

    /// Builder: Set the text override
    pub fn with_text(mut self, text: impl Into<String>) -> Self {
        self.text = text.into();
        self
    }

    /// Builder: Set the style name
    pub fn with_style(mut self, style: impl Into<String>) -> Self {
        self.style_name = style.into();
        self
    }

    /// Builder: Set the normal vector
    pub fn with_normal(mut self, normal: Vector3) -> Self {
        self.normal = normal;
        self
    }

    /// Check if this is an angular dimension
    pub fn is_angular(&self) -> bool {
        matches!(
            self.dimension_type,
            DimensionType::Angular | DimensionType::Angular3Point
        )
    }
}

impl Default for DimensionBase {
    fn default() -> Self {
        Self::new(DimensionType::Linear)
    }
}

/// Aligned dimension entity
/// 
/// Measures the distance between two points along a line parallel to those points.
#[derive(Debug, Clone, PartialEq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct DimensionAligned {
    pub base: DimensionBase,
    /// First definition point (in WCS)
    pub first_point: Vector3,
    /// Second definition point (in WCS)
    pub second_point: Vector3,
    /// Definition point on dimension line
    pub definition_point: Vector3,
    /// Extension line rotation (optional)
    pub ext_line_rotation: f64,
}

impl DimensionAligned {
    /// Create a new aligned dimension
    pub fn new(first_point: Vector3, second_point: Vector3) -> Self {
        let mut base = DimensionBase::new(DimensionType::Aligned);

        // Calculate measurement
        base.actual_measurement = first_point.distance(&second_point);

        Self {
            base,
            first_point,
            second_point,
            definition_point: Vector3::ZERO,
            ext_line_rotation: 0.0,
        }
    }

    /// Get the measurement value
    pub fn measurement(&self) -> f64 {
        self.first_point.distance(&self.second_point)
    }

    /// Set the offset distance from the second point
    pub fn set_offset(&mut self, offset: f64) {
        let dir = self.second_point - self.first_point;
        let perpendicular = Vector3::new(-dir.y, dir.x, 0.0).normalize();
        self.definition_point = self.second_point + perpendicular * offset;
    }

    /// Get the offset distance
    pub fn offset(&self) -> f64 {
        self.second_point.distance(&self.definition_point)
    }
}

impl Default for DimensionAligned {
    fn default() -> Self {
        Self {
            base: DimensionBase::new(DimensionType::Aligned),
            first_point: Vector3::ZERO,
            second_point: Vector3::ZERO,
            definition_point: Vector3::ZERO,
            ext_line_rotation: 0.0,
        }
    }
}

/// Linear dimension entity
///
/// Measures the horizontal or vertical distance between two points,
/// or the distance along a rotated axis.
#[derive(Debug, Clone, PartialEq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct DimensionLinear {
    pub base: DimensionBase,
    /// First definition point (in WCS)
    pub first_point: Vector3,
    /// Second definition point (in WCS)
    pub second_point: Vector3,
    /// Definition point on dimension line
    pub definition_point: Vector3,
    /// Rotation angle of the dimension line
    pub rotation: f64,
    /// Extension line rotation
    pub ext_line_rotation: f64,
}

impl DimensionLinear {
    /// Create a new linear dimension
    pub fn new(first_point: Vector3, second_point: Vector3) -> Self {
        let mut base = DimensionBase::new(DimensionType::Linear);
        base.actual_measurement = first_point.distance(&second_point);
        
        Self {
            base,
            first_point,
            second_point,
            definition_point: Vector3::ZERO,
            rotation: 0.0,
            ext_line_rotation: 0.0,
        }
    }

    /// Create a horizontal linear dimension
    pub fn horizontal(first_point: Vector3, second_point: Vector3) -> Self {
        Self::new(first_point, second_point)
    }

    /// Create a vertical linear dimension
    pub fn vertical(first_point: Vector3, second_point: Vector3) -> Self {
        let mut dim = Self::new(first_point, second_point);
        dim.rotation = std::f64::consts::FRAC_PI_2; // 90 degrees
        dim
    }

    /// Create a rotated linear dimension
    pub fn rotated(first_point: Vector3, second_point: Vector3, angle: f64) -> Self {
        let mut dim = Self::new(first_point, second_point);
        dim.rotation = angle;
        dim
    }

    /// Get the measurement value (projected onto rotation axis)
    pub fn measurement(&self) -> f64 {
        let angle_vec = Vector3::new(self.rotation.cos(), self.rotation.sin(), 0.0);
        let diff = self.second_point - self.first_point;
        let normalized = diff.normalize();
        let dot = angle_vec.dot(&normalized).abs();
        self.first_point.distance(&self.second_point) * dot
    }

    /// Set the offset distance
    pub fn set_offset(&mut self, offset: f64) {
        let axis_y = Vector3::new(-self.rotation.sin(), self.rotation.cos(), 0.0);
        self.definition_point = self.second_point + axis_y * offset;
    }
}

impl Default for DimensionLinear {
    fn default() -> Self {
        Self {
            base: DimensionBase::new(DimensionType::Linear),
            first_point: Vector3::ZERO,
            second_point: Vector3::ZERO,
            definition_point: Vector3::ZERO,
            rotation: 0.0,
            ext_line_rotation: 0.0,
        }
    }
}

/// Radius dimension entity
///
/// Measures the radius of a circle or arc.
#[derive(Debug, Clone, PartialEq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct DimensionRadius {
    pub base: DimensionBase,
    /// Definition point (point on arc/circle) - in WCS
    pub definition_point: Vector3,
    /// Center point of the arc/circle (in WCS)
    pub angle_vertex: Vector3,
    /// Leader length
    pub leader_length: f64,
}

impl DimensionRadius {
    /// Create a new radius dimension
    pub fn new(center: Vector3, point_on_arc: Vector3) -> Self {
        let mut base = DimensionBase::new(DimensionType::Radius);
        base.actual_measurement = center.distance(&point_on_arc);

        Self {
            base,
            definition_point: point_on_arc,
            angle_vertex: center,
            leader_length: 0.0,
        }
    }

    /// Get the radius measurement
    pub fn measurement(&self) -> f64 {
        self.definition_point.distance(&self.angle_vertex)
    }
}

impl Default for DimensionRadius {
    fn default() -> Self {
        Self {
            base: DimensionBase::new(DimensionType::Radius),
            definition_point: Vector3::ZERO,
            angle_vertex: Vector3::ZERO,
            leader_length: 0.0,
        }
    }
}

/// Diameter dimension entity
///
/// Measures the diameter of a circle or arc.
#[derive(Debug, Clone, PartialEq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct DimensionDiameter {
    pub base: DimensionBase,
    /// Definition point (opposite side of diameter) - in WCS
    pub definition_point: Vector3,
    /// Point on arc/circle (in WCS)
    pub angle_vertex: Vector3,
    /// Leader length
    pub leader_length: f64,
}

impl DimensionDiameter {
    /// Create a new diameter dimension
    pub fn new(center: Vector3, point_on_arc: Vector3) -> Self {
        let mut base = DimensionBase::new(DimensionType::Diameter);
        base.actual_measurement = center.distance(&point_on_arc) * 2.0;

        Self {
            base,
            definition_point: point_on_arc,
            angle_vertex: center,
            leader_length: 0.0,
        }
    }

    /// Get the diameter measurement
    pub fn measurement(&self) -> f64 {
        self.definition_point.distance(&self.angle_vertex) * 2.0
    }

    /// Get the center point
    pub fn center(&self) -> Vector3 {
        (self.angle_vertex + self.definition_point) * 0.5
    }
}

impl Default for DimensionDiameter {
    fn default() -> Self {
        Self {
            base: DimensionBase::new(DimensionType::Diameter),
            definition_point: Vector3::ZERO,
            angle_vertex: Vector3::ZERO,
            leader_length: 0.0,
        }
    }
}

/// Angular 2-line dimension entity
///
/// Measures the angle between two lines.
#[derive(Debug, Clone, PartialEq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct DimensionAngular2Ln {
    pub base: DimensionBase,
    /// Arc definition point (dimension arc location) - in WCS
    pub dimension_arc: Vector3,
    /// First point (line 1 start) - in WCS
    pub first_point: Vector3,
    /// Second point (line 1 end / angle vertex for line 1) - in WCS
    pub second_point: Vector3,
    /// Angle vertex (line 2 vertex) - in WCS
    pub angle_vertex: Vector3,
    /// Definition point (line 2 point defining angle) - in WCS
    pub definition_point: Vector3,
}

impl DimensionAngular2Ln {
    /// Create a new angular 2-line dimension
    pub fn new(vertex: Vector3, first_point: Vector3, second_point: Vector3) -> Self {
        let mut base = DimensionBase::new(DimensionType::Angular);

        // Calculate angle between the two lines
        let v1 = (first_point - vertex).normalize();
        let v2 = (second_point - vertex).normalize();
        let angle = v1.dot(&v2).acos();
        base.actual_measurement = angle.to_degrees();

        Self {
            base,
            dimension_arc: Vector3::ZERO,
            first_point,
            second_point,
            angle_vertex: vertex,
            definition_point: Vector3::ZERO,
        }
    }

    /// Get the angle measurement in radians
    pub fn measurement_radians(&self) -> f64 {
        let v1 = (self.first_point - self.angle_vertex).normalize();
        let v2 = (self.second_point - self.angle_vertex).normalize();
        v1.dot(&v2).acos()
    }

    /// Get the angle measurement in degrees
    pub fn measurement_degrees(&self) -> f64 {
        self.measurement_radians().to_degrees()
    }
}

impl Default for DimensionAngular2Ln {
    fn default() -> Self {
        Self {
            base: DimensionBase::new(DimensionType::Angular),
            dimension_arc: Vector3::ZERO,
            first_point: Vector3::ZERO,
            second_point: Vector3::ZERO,
            angle_vertex: Vector3::ZERO,
            definition_point: Vector3::ZERO,
        }
    }
}

/// Type alias for backward compatibility
pub type DimensionAngular2Line = DimensionAngular2Ln;

/// Angular 3-point dimension entity
///
/// Measures the angle defined by three points.
#[derive(Debug, Clone, PartialEq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct DimensionAngular3Pt {
    pub base: DimensionBase,
    /// Definition point (arc location) - in WCS
    pub definition_point: Vector3,
    /// First point on first line - in WCS
    pub first_point: Vector3,
    /// Second point on second line - in WCS
    pub second_point: Vector3,
    /// Angle vertex - in WCS
    pub angle_vertex: Vector3,
}

impl DimensionAngular3Pt {
    /// Create a new angular 3-point dimension
    pub fn new(vertex: Vector3, first_point: Vector3, second_point: Vector3) -> Self {
        let mut base = DimensionBase::new(DimensionType::Angular3Point);

        // Calculate angle
        let v1 = (first_point - vertex).normalize();
        let v2 = (second_point - vertex).normalize();
        let angle = v1.dot(&v2).acos();
        base.actual_measurement = angle.to_degrees();

        Self {
            base,
            definition_point: Vector3::ZERO,
            angle_vertex: vertex,
            first_point,
            second_point,
        }
    }

    /// Get the angle measurement in radians
    pub fn measurement_radians(&self) -> f64 {
        let v1 = (self.first_point - self.angle_vertex).normalize();
        let v2 = (self.second_point - self.angle_vertex).normalize();
        v1.dot(&v2).acos()
    }

    /// Get the angle measurement in degrees
    pub fn measurement_degrees(&self) -> f64 {
        self.measurement_radians().to_degrees()
    }
}

impl Default for DimensionAngular3Pt {
    fn default() -> Self {
        Self {
            base: DimensionBase::new(DimensionType::Angular3Point),
            definition_point: Vector3::ZERO,
            first_point: Vector3::ZERO,
            second_point: Vector3::ZERO,
            angle_vertex: Vector3::ZERO,
        }
    }
}

/// Type alias for backward compatibility
pub type DimensionAngular3Point = DimensionAngular3Pt;

/// Ordinate dimension entity
///
/// Measures the X or Y ordinate of a point.
#[derive(Debug, Clone, PartialEq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct DimensionOrdinate {
    pub base: DimensionBase,
    /// Definition point (origin) - in WCS
    pub definition_point: Vector3,
    /// Feature location point (in WCS)
    pub feature_location: Vector3,
    /// Leader endpoint (in WCS)
    pub leader_endpoint: Vector3,
    /// True if this is an X-ordinate, false for Y-ordinate
    pub is_ordinate_type_x: bool,
}

impl DimensionOrdinate {
    /// Create a new ordinate dimension
    pub fn new(feature_location: Vector3, leader_endpoint: Vector3, is_x_type: bool) -> Self {
        let mut base = DimensionBase::new(DimensionType::Ordinate);
        base.actual_measurement = if is_x_type {
            feature_location.x
        } else {
            feature_location.y
        };

        Self {
            base,
            definition_point: Vector3::ZERO,
            feature_location,
            leader_endpoint,
            is_ordinate_type_x: is_x_type,
        }
    }

    /// Create a new X-ordinate dimension
    pub fn x_ordinate(feature_location: Vector3, leader_endpoint: Vector3) -> Self {
        Self::new(feature_location, leader_endpoint, true)
    }

    /// Create a new Y-ordinate dimension
    pub fn y_ordinate(feature_location: Vector3, leader_endpoint: Vector3) -> Self {
        Self::new(feature_location, leader_endpoint, false)
    }

    /// Get the ordinate measurement
    pub fn measurement(&self) -> f64 {
        if self.is_ordinate_type_x {
            self.feature_location.x
        } else {
            self.feature_location.y
        }
    }
}

impl Default for DimensionOrdinate {
    fn default() -> Self {
        Self {
            base: DimensionBase::new(DimensionType::Ordinate),
            definition_point: Vector3::ZERO,
            feature_location: Vector3::ZERO,
            leader_endpoint: Vector3::ZERO,
            is_ordinate_type_x: true,
        }
    }
}

/// Unified dimension enum for all dimension types
#[derive(Debug, Clone, PartialEq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub enum Dimension {
    Aligned(DimensionAligned),
    Linear(DimensionLinear),
    Radius(DimensionRadius),
    Diameter(DimensionDiameter),
    Angular2Ln(DimensionAngular2Ln),
    Angular3Pt(DimensionAngular3Pt),
    Ordinate(DimensionOrdinate),
}

impl Dimension {
    /// Get the base dimension data
    pub fn base(&self) -> &DimensionBase {
        match self {
            Dimension::Aligned(d) => &d.base,
            Dimension::Linear(d) => &d.base,
            Dimension::Radius(d) => &d.base,
            Dimension::Diameter(d) => &d.base,
            Dimension::Angular2Ln(d) => &d.base,
            Dimension::Angular3Pt(d) => &d.base,
            Dimension::Ordinate(d) => &d.base,
        }
    }

    /// Get mutable base dimension data
    pub fn base_mut(&mut self) -> &mut DimensionBase {
        match self {
            Dimension::Aligned(d) => &mut d.base,
            Dimension::Linear(d) => &mut d.base,
            Dimension::Radius(d) => &mut d.base,
            Dimension::Diameter(d) => &mut d.base,
            Dimension::Angular2Ln(d) => &mut d.base,
            Dimension::Angular3Pt(d) => &mut d.base,
            Dimension::Ordinate(d) => &mut d.base,
        }
    }

    /// Get the measurement value
    pub fn measurement(&self) -> f64 {
        match self {
            Dimension::Aligned(d) => d.measurement(),
            Dimension::Linear(d) => d.measurement(),
            Dimension::Radius(d) => d.measurement(),
            Dimension::Diameter(d) => d.measurement(),
            Dimension::Angular2Ln(d) => d.measurement_degrees(),
            Dimension::Angular3Pt(d) => d.measurement_degrees(),
            Dimension::Ordinate(d) => d.measurement(),
        }
    }
}

impl super::Entity for Dimension {
    fn handle(&self) -> crate::types::Handle {
        self.base().common.handle
    }

    fn set_handle(&mut self, handle: crate::types::Handle) {
        self.base_mut().common.handle = handle;
    }

    fn layer(&self) -> &str {
        &self.base().common.layer
    }

    fn set_layer(&mut self, layer: String) {
        self.base_mut().common.layer = layer;
    }

    fn color(&self) -> crate::types::Color {
        self.base().common.color
    }

    fn set_color(&mut self, color: crate::types::Color) {
        self.base_mut().common.color = color;
    }

    fn line_weight(&self) -> crate::types::LineWeight {
        self.base().common.line_weight
    }

    fn set_line_weight(&mut self, weight: crate::types::LineWeight) {
        self.base_mut().common.line_weight = weight;
    }

    fn transparency(&self) -> crate::types::Transparency {
        self.base().common.transparency
    }

    fn set_transparency(&mut self, transparency: crate::types::Transparency) {
        self.base_mut().common.transparency = transparency;
    }

    fn is_invisible(&self) -> bool {
        self.base().common.invisible
    }

    fn set_invisible(&mut self, invisible: bool) {
        self.base_mut().common.invisible = invisible;
    }

    fn bounding_box(&self) -> crate::types::BoundingBox3D {
        use crate::types::BoundingBox3D;
        match self {
            Dimension::Aligned(d) => BoundingBox3D::from_points(&[d.first_point, d.second_point, d.definition_point]).unwrap_or_default(),
            Dimension::Linear(d) => BoundingBox3D::from_points(&[d.first_point, d.second_point, d.definition_point]).unwrap_or_default(),
            Dimension::Radius(d) => BoundingBox3D::from_points(&[d.angle_vertex, d.definition_point]).unwrap_or_default(),
            Dimension::Diameter(d) => BoundingBox3D::from_points(&[d.angle_vertex, d.definition_point]).unwrap_or_default(),
            Dimension::Angular2Ln(d) => BoundingBox3D::from_points(&[d.angle_vertex, d.first_point, d.second_point, d.definition_point]).unwrap_or_default(),
            Dimension::Angular3Pt(d) => BoundingBox3D::from_points(&[d.angle_vertex, d.first_point, d.second_point, d.definition_point]).unwrap_or_default(),
            Dimension::Ordinate(d) => BoundingBox3D::from_points(&[d.feature_location, d.leader_endpoint, d.definition_point]).unwrap_or_default(),
        }
    }

    fn translate(&mut self, offset: Vector3) {
        super::translate::translate_dimension(self, offset);
    }

    fn entity_type(&self) -> &'static str {
        match self {
            Dimension::Aligned(_) => "DIMENSION_ALIGNED",
            Dimension::Linear(_) => "DIMENSION_LINEAR",
            Dimension::Radius(_) => "DIMENSION_RADIUS",
            Dimension::Diameter(_) => "DIMENSION_DIAMETER",
            Dimension::Angular2Ln(_) => "DIMENSION_ANGULAR_2LINE",
            Dimension::Angular3Pt(_) => "DIMENSION_ANGULAR_3POINT",
            Dimension::Ordinate(_) => "DIMENSION_ORDINATE",
        }
    }
}