Files
茂之钳 93852075dd
CI / Build & Test (push) Failing after 32s
CI / Release Build (push) Failing after 16m59s
Build & Test / build-and-test (push) Has been cancelled
Build & Test / python-bindings (push) Has been cancelled
feat(v4.3): offset_section_view — stepped section with multiple parallel planes
- offset_section_view(body, normal, offsets): combines section profiles at each offset
- Step lines connect boundaries between adjacent planes
- 4 new tests
2026-07-25 07:18:49 +00:00

69 lines
2.4 KiB
C++

#pragma once
/**
* @file brep_drawing.h
* @brief Engineering drawing: 2D projection views + section + DXF export
*
* Orthographic projection views from B-Rep models with hidden-line
* removal via mesh ray-casting. Supports section (cross-section) views
* and AutoCAD R12 DXF format export.
*
* @ingroup brep
*/
#include "vde/brep/brep.h"
#include "vde/core/point.h"
#include <vector>
#include <string>
namespace vde::brep {
/// 2D line segment for drawing output
struct DrawSegment {
double x1, y1, x2, y2;
bool hidden = false; ///< true = dashed hidden line
};
/// Projection view of a B-Rep body
struct ProjectionView {
std::string name; ///< "front", "top", "right", "iso"
std::vector<DrawSegment> segments; ///< visible lines
std::vector<DrawSegment> hidden_lines; ///< dashed hidden lines
double scale = 1.0;
core::Point3D view_direction; ///< camera direction
[[nodiscard]] size_t total_segments() const {
return segments.size() + hidden_lines.size();
}
};
/// Generate orthographic projection views
/// @param body B-Rep model to project
/// @return Vector of projection views (front, top, right, iso)
[[nodiscard]] std::vector<ProjectionView> generate_views(const BrepModel& body);
/// Generate a section view (cross-section)
/// @param body Body to slice
/// @param point Point on section plane
/// @param normal Section plane normal
/// @return Section view with cut edges and hatch lines
[[nodiscard]] ProjectionView section_view(const BrepModel& body,
const core::Point3D& point, const core::Vector3D& normal);
/// Offset (stepped) section view — multiple parallel cutting planes
/// Each offset defines a cutting plane at a different position along the normal
/// direction. Results are merged with step lines at plane boundaries.
/// @param body Body to slice
/// @param normal Section direction (all planes share this normal)
/// @param offsets Vector of plane positions (distance along normal from origin)
/// @return Combined section view
[[nodiscard]] ProjectionView offset_section_view(const BrepModel& body,
const core::Vector3D& normal, const std::vector<double>& offsets);
/// Export views to DXF format (R12 compatible)
/// @param filepath Output file path (.dxf)
/// @param views Vector of views to export
/// @return true on success
bool export_dxf(const std::string& filepath,
const std::vector<ProjectionView>& views);
} // namespace vde::brep