/
spivag
/
command_occ
Обзор
Документация
Войти
/
spivag
/
command_occ
Код
Запросы
1
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
initial
tests/gtest_swept_solid.cpp
93 строки
4 KB
Spivakov
Initial
10 апр 2026, 13:45
10 апр 2026, 13:45
b2ad868
Код
Авторство
О чём код?
#include <brep_sections.h> #include <gtest/gtest.h> #include <planar_contour.h> #include <shape_command.h> #include <spatial_curve.h> #include <demo_brep_swept.hxx> static std::vector< R2::Point > CreatePointsToFit() { return { R2::Point{ 10., 0. }, R2::Point{ 12., 8 }, R2::Point{ 4., 11. }, R2::Point{ -3., 2. } }; }; static std::shared_ptr< IPlanarContourBuilder > CreateContourFitCurve() { std::vector< R2::Point > curvePoints{ CreatePointsToFit() }; std::vector< R2::Vector > hermitVectors{ R2::Vector{ 0.5, -0.5 }, R2::Vector{ 0.5, 0.5 }, R2::Vector{ -0.5, 0.5 }, R2::Vector{ -0.5, -0.5 } }; std::shared_ptr< IPlanarCurveBuilder > lineSeg{ new PlanarLineSegment{ curvePoints.back(), curvePoints.front() } }; std::shared_ptr< IPlanarCurveBuilder > fitCurve{ new PlanarFitPoints{ curvePoints, PointsFit::OnEnds::closed, PointsFit::HermitSpline< R2::Vector >{ { 0., 1., 2.5, 4. }, hermitVectors } } }; return std::make_shared< PlanarCurveSetContour >( fitCurve ); } static std::shared_ptr< IPlanarContourBuilder > CreateContourFitCurveSegment() { std::vector< R2::Point > curvePoints{ CreatePointsToFit() }; std::shared_ptr< IPlanarCurveBuilder > lineSeg{ new PlanarLineSegment{ curvePoints.back(), curvePoints.front() } }; std::shared_ptr< IPlanarCurveBuilder > fitCurve{ new PlanarFitPoints{ curvePoints, PointsFit::OnEnds::open, PointsFit::CubicSpline{} } }; return std::make_shared< PlanarCurveSetContour >( std::vector< std::shared_ptr< IPlanarCurveBuilder > >{ fitCurve, lineSeg } ); } static std::shared_ptr< IPlanarContourBuilder > CreateContourInner() { std::shared_ptr< IPlanarContourBuilder > innerContour{ new PlanarEllipseCreate{ 2.5, R2::Placement{ R2::Point{ 6., 8. } } } }; return innerContour; } static std::shared_ptr< ISpatialCurveBuilder > CreatePath() { std::shared_ptr< ISpatialCurveBuilder > path{ new SpatialFitPoints{ { R3::Point{ 0., 3., 0. }, R3::Point{ 0., 4., 3. }, R3::Point{ 1., 5., 9. }, R3::Point{ 0., 3., 15. } }, PointsFit::OnEnds::open, PointsFit::Bezier{} } }; return path; } TEST( SweptSolid, FixedDirectionContourOneCurve ) { std::shared_ptr< IShapeBuilder > sweptBrep{ new BuildSweptSolid{ SweptEntity::Sketch{ R3::Placement::World(), CreateContourFitCurve() }, CreatePath(), BuildSweptSolid::SectionOrientation::fixOriginal } }; sweptBrep->Execute(); ASSERT_FALSE( sweptBrep->GetMbItem().is_null() ); } TEST( SweptSolid, FixedDirectionContourTwoCurves ) { std::shared_ptr< IShapeBuilder > sweptBrep{ new BuildSweptSolid{ SweptEntity::Sketch{ R3::Placement::World(), CreateContourFitCurveSegment() }, CreatePath(), BuildSweptSolid::SectionOrientation::fixOriginal } }; sweptBrep->Execute(); ASSERT_FALSE( sweptBrep->GetMbItem().is_null() ); } TEST( RevolutionSolid, DemoPentagon ) { auto pentaRevolution = demo::SweptBrep::RevolvePentagon(); ASSERT_NE( nullptr, pentaRevolution.get() ); pentaRevolution->Execute(); ASSERT_FALSE( pentaRevolution->GetMbItem().is_null() ); } TEST( RevolutionSolid, DemoPentagonThinWall ) { auto pentaRevolution = demo::SweptBrep::RevolvePentagonThinWall(); ASSERT_NE( nullptr, pentaRevolution.get() ); pentaRevolution->Execute(); ASSERT_FALSE( pentaRevolution->GetMbItem().is_null() ); }