Skip to content

Commit

Permalink
fix polyface mesh vertices not being applied (#59)
Browse files Browse the repository at this point in the history
* fix polyface mesh vertices not being applied

* Update INSERT to have extrusion direction on R12

* fix tests
  • Loading branch information
tr3ysmith authored Jan 20, 2024
1 parent eabe4e3 commit 4e940ec
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 5 deletions.
2 changes: 1 addition & 1 deletion spec/EntitiesSpec.xml
Original file line number Diff line number Diff line change
Expand Up @@ -493,7 +493,7 @@
<Field Name="row_count" Code="71" Type="i16" DefaultValue="1" DisableWritingDefault="true" />
<Field Name="column_spacing" Code="44" Type="f64" DefaultValue="0.0" DisableWritingDefault="true" />
<Field Name="row_spacing" Code="45" Type="f64" DefaultValue="0.0" DisableWritingDefault="true" />
<Field Name="extrusion_direction" Code="210" Type="Vector" DefaultValue="Vector::z_axis()" CodeOverrides="210,220,230" MinVersion="R13" />
<Field Name="extrusion_direction" Code="210" Type="Vector" DefaultValue="Vector::z_axis()" CodeOverrides="210,220,230" MinVersion="R12" />
<Field Name="__attributes_and_handles" Code="10" Type="(Attribute, Handle)" DefaultValue="vec![]" AllowMultiples="true" GenerateReader="false" GenerateWriter="false" />
<WriteOrder>
<WriteSpecificValue Code="100" Value='&amp;String::from("AcDbBlockReference")' MinVersion="R13" />
Expand Down
34 changes: 30 additions & 4 deletions src/entity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1515,7 +1515,7 @@ impl Entity {
}
pairs.push(CodePair::new_i16(70, v.flags as i16));
pairs.push(CodePair::new_f64(50, v.curve_fit_tangent_direction));
if version >= AcadVersion::R13 {
if version >= AcadVersion::R12 {
if v.polyface_mesh_vertex_index1 != 0 {
pairs.push(CodePair::new_i16(71, v.polyface_mesh_vertex_index1 as i16));
}
Expand Down Expand Up @@ -1572,7 +1572,13 @@ impl Entity {
for (v, vertex_handle) in &poly.__vertices_and_handles {
let mut v = v.clone();
v.set_is_3d_polyline_vertex(poly.is_3d_polyline());
v.set_is_3d_polygon_mesh(poly.is_3d_polygon_mesh());
if v.polyface_mesh_vertex_index1 == 0
&& v.polyface_mesh_vertex_index2 == 0
&& v.polyface_mesh_vertex_index3 == 0
&& v.polyface_mesh_vertex_index4 == 0
{
v.set_is_3d_polygon_mesh(poly.is_3d_polygon_mesh());
}
let v = Entity {
common: EntityCommon {
handle: *vertex_handle,
Expand Down Expand Up @@ -2872,9 +2878,9 @@ mod tests {
}

#[test]
fn write_insert_no_extrusion_on_r12() {
fn write_insert_no_extrusion_on_r11() {
let mut drawing = Drawing::new();
drawing.header.version = AcadVersion::R12;
drawing.header.version = AcadVersion::R11;
let ins = Insert {
extrusion_direction: Vector::new(1.0, 2.0, 3.0),
..Default::default()
Expand All @@ -2891,6 +2897,26 @@ mod tests {
);
}

#[test]
fn write_insert_extrusion_on_r12() {
let mut drawing = Drawing::new();
drawing.header.version = AcadVersion::R12;
let ins = Insert {
extrusion_direction: Vector::new(1.0, 2.0, 3.0),
..Default::default()
};
let ent = Entity::new(EntityType::Insert(ins));
drawing.add_entity(ent);
assert_contains_pairs(
&drawing,
vec![
CodePair::new_f64(210, 1.0),
CodePair::new_f64(220, 2.0),
CodePair::new_f64(230, 3.0),
],
);
}

#[test]
fn write_insert_extrusion_on_r13() {
let mut drawing = Drawing::new();
Expand Down

0 comments on commit 4e940ec

Please sign in to comment.