mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-13 02:47:48 +00:00
--circle-segments conversion setting instead of hardcoded number in cgal kernel
This commit is contained in:
@@ -300,6 +300,12 @@ namespace ifcopenshell {
|
||||
static constexpr const char* const description = "Overrides transparency of spaces in geometry output.";
|
||||
};
|
||||
|
||||
struct CircleSegments : public SettingBase<CircleSegments, int> {
|
||||
static constexpr const char* const name = "circle-segments";
|
||||
static constexpr const char* const description = "Number of segments to approximate full circles in CGAL kernel.";
|
||||
static constexpr int defaultvalue = 16;
|
||||
};
|
||||
|
||||
enum PiecewiseStepMethod {
|
||||
MAXSTEPSIZE,
|
||||
MINSTEPS };
|
||||
@@ -402,7 +408,7 @@ namespace ifcopenshell {
|
||||
};
|
||||
|
||||
class IFC_GEOM_API Settings : public SettingsContainer<
|
||||
std::tuple<MesherLinearDeflection, MesherAngularDeflection, ReorientShells, LengthUnit, PlaneUnit, Precision, IncludeCurves, IncludeSurfaces, LayersetFirst, DisableBooleanResult, NoWireIntersectionCheck, NoWireIntersectionTolerance, PrecisionFactor, DebugBooleanOperations, BooleanAttempt2d, WeldVertices, UseWorldCoords, ConvertBackUnits, ContextIds, IteratorOutput, DisableOpeningSubtractions, ApplyDefaultMaterials, DontEmitNormals, GenerateUvs, ApplyLayerSets, UseElementHierarchy, ValidateQuantities, EdgeArrows, BuildingLocalPlacement, SiteLocalPlacement, ForceSpaceTransparency, PiecewiseStepType, PiecewiseStepParam>
|
||||
std::tuple<MesherLinearDeflection, MesherAngularDeflection, ReorientShells, LengthUnit, PlaneUnit, Precision, IncludeCurves, IncludeSurfaces, LayersetFirst, DisableBooleanResult, NoWireIntersectionCheck, NoWireIntersectionTolerance, PrecisionFactor, DebugBooleanOperations, BooleanAttempt2d, WeldVertices, UseWorldCoords, ConvertBackUnits, ContextIds, IteratorOutput, DisableOpeningSubtractions, ApplyDefaultMaterials, DontEmitNormals, GenerateUvs, ApplyLayerSets, UseElementHierarchy, ValidateQuantities, EdgeArrows, BuildingLocalPlacement, SiteLocalPlacement, ForceSpaceTransparency, CircleSegments, PiecewiseStepType, PiecewiseStepParam>
|
||||
>
|
||||
{};
|
||||
}
|
||||
|
||||
@@ -364,13 +364,13 @@ namespace {
|
||||
};
|
||||
|
||||
struct cgal_curve_creation_visitor {
|
||||
static const int FULL_CIRCLE_NUM_SEGMENTS = 32;
|
||||
Settings& settings_;
|
||||
parameter_range param;
|
||||
|
||||
std::vector<taxonomy::point3> points;
|
||||
|
||||
cgal_curve_creation_visitor() : param(unbounded) {}
|
||||
cgal_curve_creation_visitor(const parameter_range& p) : param(p) {}
|
||||
cgal_curve_creation_visitor(Settings& s) : settings_(s), param(unbounded) {}
|
||||
cgal_curve_creation_visitor(Settings& s, const parameter_range& p) : settings_(s), param(p) {}
|
||||
|
||||
void operator()(const taxonomy::line::ptr& l) {
|
||||
if (param == unbounded) {
|
||||
@@ -397,7 +397,7 @@ namespace {
|
||||
if (b <= a) {
|
||||
b += 2 * M_PI;
|
||||
}
|
||||
int num_segments = (int)std::ceil(std::fabs(a - b) / (2 * M_PI) * FULL_CIRCLE_NUM_SEGMENTS);
|
||||
int num_segments = (int)std::ceil(std::fabs(a - b) / (2 * M_PI) * settings_.get<settings::CircleSegments>().get());
|
||||
double du = (b - a) / num_segments;
|
||||
taxonomy::point3 P;
|
||||
// @nb for loop is not inclusive of the both end points
|
||||
@@ -429,7 +429,7 @@ namespace {
|
||||
std::swap(v1.u, v2.u);
|
||||
}
|
||||
|
||||
cgal_curve_creation_visitor v({ v1.u, v2.u });
|
||||
cgal_curve_creation_visitor v(settings_, { v1.u, v2.u });
|
||||
|
||||
dispatch_curve_creation<cgal_curve_creation_visitor>::dispatch(e->basis, v);
|
||||
this->points = v.points;
|
||||
@@ -448,8 +448,8 @@ namespace {
|
||||
}
|
||||
};
|
||||
|
||||
void convert_curve(taxonomy::ptr i, std::vector<taxonomy::point3>& points) {
|
||||
cgal_curve_creation_visitor v;
|
||||
void convert_curve(Settings& s, taxonomy::ptr i, std::vector<taxonomy::point3>& points) {
|
||||
cgal_curve_creation_visitor v(s);
|
||||
dispatch_curve_creation<cgal_curve_creation_visitor>::dispatch(i, v);
|
||||
points = v.points;
|
||||
}
|
||||
@@ -647,7 +647,7 @@ bool CgalKernel::convert(const taxonomy::loop::ptr loop, cgal_wire_t& result) {
|
||||
for (auto& e : loop->children) {
|
||||
std::vector<taxonomy::point3> edge;
|
||||
if (e->basis) {
|
||||
convert_curve(e, edge);
|
||||
convert_curve(settings_, e, edge);
|
||||
if (!e->orientation_2.get_value_or(true)) {
|
||||
std::reverse(edge.begin(), edge.end());
|
||||
}
|
||||
|
||||
@@ -70,8 +70,6 @@ namespace ifcopenshell {
|
||||
|
||||
class IFC_GEOM_API CgalKernel : public AbstractKernel {
|
||||
private:
|
||||
size_t circle_segments_;
|
||||
|
||||
#ifndef IFOPSH_SIMPLE_KERNEL
|
||||
enum boolean_operand_preprocess {
|
||||
PP_MINKOWSKY_DILATE,
|
||||
@@ -94,7 +92,6 @@ namespace ifcopenshell {
|
||||
|
||||
CgalKernel(const Settings& settings)
|
||||
: AbstractKernel("cgal", settings)
|
||||
, circle_segments_(32)
|
||||
{}
|
||||
|
||||
void remove_duplicate_points_from_loop(cgal_wire_t& polygon);
|
||||
|
||||
Reference in New Issue
Block a user