/
spivag
/
command_occ
Обзор
Документация
Войти
/
spivag
/
command_occ
Код
Запросы
1
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
initial
commands/brep_sections.cpp
285 строк
9 KB
spivag
Запрос на слияние 'c3d_sdk_removal' (
#2
) из c3d_sdk_removal в initial
16 апр 2026, 15:34
Верифицирован
16 апр 2026, 15:34
e04e876
Код
Авторство
О чём код?
#include "brep_sections.h" #include <shape_iterator.h> #include <vector> #include <algorithm> #include <iterator> SweptEntity::Sketch::Sketch::Sketch( R3::Placement const& location, std::shared_ptr< IPlanarContourBuilder > const& contour ) : m_placement{ location } { if ( contour != nullptr ) m_profiles.push_back( contour ); } SweptEntity::Sketch::Sketch::Sketch( R3::Placement const& location, std::vector< std::shared_ptr< IPlanarContourBuilder > > const& contours ) : m_placement{ location } { if ( !contours.empty() ) { std::copy_if( cbegin( contours ), cend( contours ), std::back_inserter( m_profiles ), []( auto const& contour ) { return contour != nullptr; } ); } } bool SweptEntity::Sketch::AreParametersValid() const { return ( !m_profiles.empty() ) && std::all_of( cbegin( m_profiles ), cend( m_profiles ), []( auto const& profile ) { return profile != nullptr; } ); } WallThickness::ToOuterSide::ToOuterSide( double depth ) : m_depth( depth ) { } WallThickness::ToInnerSide::ToInnerSide( double depth ) : m_depth( depth ) { } WallThickness::WallThickness( std::optional< ToOuterSide > const& outer, std::optional< ToInnerSide > const& inner ) : m_depthOuter{} , m_depthInner{} { if ( outer.has_value() && outer.value().m_depth > 0. ) m_depthOuter.emplace( outer.value().m_depth ); if ( inner.has_value() && inner.value().m_depth > 0. ) m_depthInner.emplace( inner.value().m_depth ); } bool SweptEntity::Sketch2D::AreParametersValid() const { return m_baseSketch.m_sweptEntity.AreParametersValid(); } bool BuildExtrusionSolid::DepthAngle::AreParametersValid() const { return ( m_depth > 0.0 ) && m_angle.IsValid(); } SweptEntity::Sketch2D::Parameters::Parameters( R3::Placement const& location, std::vector< std::shared_ptr< IPlanarContourBuilder > > const& contours, std::optional< WallThickness > const& thinWall ) : m_sweptEntity{ location, contours } , m_thinWall{ thinWall } { } SweptEntity::Sketch2D::Sketch2D( R3::Placement const& location, std::shared_ptr< IPlanarContourBuilder > const& contour, std::optional< WallThickness > const& thinWall ) : m_baseSketch{ location, { contour }, thinWall } { } SweptEntity::Sketch2D::Sketch2D( R3::Placement const& location, std::vector< std::shared_ptr< IPlanarContourBuilder > > const& contours, std::optional< WallThickness > const& thinWall ) : m_baseSketch{ location, contours, thinWall } { } BuildExtrusionSolid::ToExtrude::ToExtrude( SweptEntity::Sketch2D const& profile, R3::Vector const& direction ) : m_profile{ profile } , m_direction{ direction } { } BuildExtrusionSolid::DepthAngle::DepthAngle( double depth, std::optional< R1::AngleModPi2 > angle ) : m_depth{ depth } , m_angle{ angle.has_value() ? angle.value() : R1::AngleModPi2{} } { } BuildExtrusionSolid::DepthAngleForward::DepthAngleForward( double depth ) : m_depthAngle{ depth, {} } { } BuildExtrusionSolid::DepthAngleForward::DepthAngleForward( double depth, R1::AngleModPi2 angle ) : m_depthAngle{ depth, angle } { } BuildExtrusionSolid::DepthAngleBackward::DepthAngleBackward( double depth ) : m_depthAngle{ depth, {} } { } BuildExtrusionSolid::DepthAngleBackward::DepthAngleBackward( double depth, R1::AngleModPi2 angle ) : m_depthAngle{ depth, angle } { } BuildExtrusionSolid::ExtrusionBothSides::ExtrusionBothSides( DepthAngle const& positiveDepthAngle, DepthAngle const& negativeDepthAngle ) : m_PositiveDepthAngle{ positiveDepthAngle } , m_NegativeDepthAngle{ negativeDepthAngle } { } BuildExtrusionSolid::BuildExtrusionSolid( SweptEntity::Sketch2D const& profile, R3::Vector const& direction, DepthAngleForward const& swepthDepthAngle ) : m_originConstruction{ swepthDepthAngle } , m_profileDirection{ profile, direction } { } BuildExtrusionSolid::BuildExtrusionSolid( SweptEntity::Sketch2D const& profile, R3::Vector const& direction, DepthAngleBackward const& swepthDepthAngle ) : m_originConstruction{ swepthDepthAngle } , m_profileDirection{ profile, direction } { } BuildExtrusionSolid::BuildExtrusionSolid( SweptEntity::Sketch2D const& profile, R3::Vector const& direction, DepthAngleForward const& positiveSweptDepthAngle, DepthAngleBackward const& negativeSwepthDepthAngle ) : m_originConstruction{ ExtrusionBothSides{ positiveSweptDepthAngle.m_depthAngle, negativeSwepthDepthAngle.m_depthAngle } } , m_profileDirection{ profile, direction } { } void BuildExtrusionSolid::Accept( ShapeVisitor& visitor ) const { visitor.Visit( *this ); } BuildExtrusionSolid::Dimensions BuildExtrusionSolid::GetDimensions() const { return m_originConstruction; } BuildExtrusionSolid::ToExtrude BuildExtrusionSolid::GetExtruded() const { return m_profileDirection; } BuildRevolutionSolid::Parameters::Parameters( SweptEntity::Sketch2D const& profile, R3::Axis const& axis, std::optional< R1::AngleCcw< R1::Angle02pi > > angleCcw, std::optional< R1::AngleCw< R1::Angle02pi > > angleCw ) : m_profile{ profile } , m_axis{ axis } , m_angleCcw{ angleCcw } , m_angleCw{ angleCw } { } BuildRevolutionSolid::BuildRevolutionSolid( SweptEntity::Sketch2D const& profile, R3::Axis const& axis, R1::AngleCcw< R1::Angle02pi > const& angleCcw ) : m_originConstruction{ profile, axis, angleCcw, {} } { } BuildRevolutionSolid::BuildRevolutionSolid( SweptEntity::Sketch2D const& profile, R3::Axis const& axis, R1::AngleCw< R1::Angle02pi > const& angleCw ) : m_originConstruction{ profile, axis, {}, angleCw } { } BuildRevolutionSolid::BuildRevolutionSolid( SweptEntity::Sketch2D const& profile, R3::Axis const& axis, R1::AngleCcw< R1::Angle02pi > const& angleCcw, R1::AngleCw< R1::Angle02pi > const& angleCw ) : m_originConstruction{ profile, axis, angleCcw, angleCw } { } void BuildRevolutionSolid::Accept( ShapeVisitor& visitor ) const { visitor.Visit( *this ); } BuildRevolutionSolid::Parameters BuildRevolutionSolid::GetParameters() const { return m_originConstruction; } //BuildSweptSolid::BuildSweptSolid( SweptEntity::Sketch const& sweptItem, // std::shared_ptr< ISpatialCurveBuilder > const& path, // SectionOrientation interposition ) // : m_sweptItem{ sweptItem } // , m_path{ path } // , m_sweptPathInterposition{ interposition } //{ //} void BuildSweptSolid::Accept( ShapeVisitor& visitor ) const { visitor.Visit( *this ); } BuildSolidBySections::Parameters::Parameters( BuildSolidBySections::Ruled const& ruledParameters, std::optional< WallThickness > const wallThickness ) : m_originConstruction{ ruledParameters } , m_wallThickness{ wallThickness } { } BuildSolidBySections::Parameters::Parameters( BuildSolidBySections::Loft const& loftParameters, std::optional< WallThickness > const wallThickness ) : m_originConstruction{ loftParameters } , m_wallThickness{ wallThickness } { } BuildSolidBySections::BuildSolidBySections( Ruled const& ruledParameters ) : m_originConstruction{ ruledParameters, {} } { } BuildSolidBySections::BuildSolidBySections( Loft const& ruledParameters, std::optional< WallThickness > const& wallThickness ) : m_originConstruction{ ruledParameters, wallThickness } { } void BuildSolidBySections::Accept( ShapeVisitor& visitor ) const { visitor.Visit( *this ); } BuildSolidBySections::Parameters BuildSolidBySections::GetParameters() const { return m_originConstruction; } BuildSolidBySections::Ruled::Ruled( SweptEntity::Sketch const& section0, SweptEntity::Sketch const& section1 ) : m_sections{ section0, section1 } { } bool BuildSolidBySections::Ruled::AreParametersValid() const { return ( m_sections.size() > 1 ) && ( std::all_of( cbegin( m_sections ), cend( m_sections ), []( auto const& s ) { return s.AreParametersValid() && s.m_profiles.size() == 1; } ) ); } BuildSolidBySections::Loft::Loft( std::vector< SweptEntity::Sketch > const& sections ) { std::copy_if( cbegin( sections ), cend( sections ), std::back_inserter( m_sections ), []( auto const& s ) { return s.AreParametersValid() && s.m_profiles.size() == 1; } ); } bool BuildSolidBySections::Loft::AreParametersValid() const { return ( m_sections.size() > 1 ) && std::all_of( cbegin( m_sections ), cend( m_sections ), []( auto const& s ) { return s.AreParametersValid(); } ); }