|
10 | 10 | #include "MRConstants.h" |
11 | 11 | #include "MRCube.h" |
12 | 12 | #include "MREdgeIterator.h" |
13 | | -#include "MRGTest.h" |
14 | 13 | #include "MRLine3.h" |
15 | 14 | #include "MRLineSegm.h" |
| 15 | +#include "MRPlane3.h" |
16 | 16 | #include "MRMeshBuilder.h" |
17 | 17 | #include "MRMeshIntersect.h" |
18 | 18 | #include "MRMeshTriPoint.h" |
|
27 | 27 | #include "MRMeshFillHole.h" |
28 | 28 | #include "MRTriMesh.h" |
29 | 29 | #include "MRDipole.h" |
30 | | -#include "MRPch/MRTBB.h" |
31 | 30 |
|
32 | 31 | namespace MR |
33 | 32 | { |
@@ -605,115 +604,4 @@ void Mesh::mirror( const Plane3f& plane ) |
605 | 604 | invalidateCaches(); |
606 | 605 | } |
607 | 606 |
|
608 | | -TEST( MRMesh, BasicExport ) |
609 | | -{ |
610 | | - Mesh mesh = makeCube(); |
611 | | - |
612 | | - const std::vector<ThreeVertIds> triangles = mesh.topology.getAllTriVerts(); |
613 | | - |
614 | | - const std::vector<Vector3f> & points = mesh.points.vec_; |
615 | | - const int * vertexTripples = reinterpret_cast<const int*>( triangles.data() ); |
616 | | - |
617 | | - (void)points; |
618 | | - (void)vertexTripples; |
619 | | -} |
620 | | - |
621 | | -TEST(MRMesh, SplitEdge) |
622 | | -{ |
623 | | - Triangulation t{ |
624 | | - { VertId{0}, VertId{1}, VertId{2} }, |
625 | | - { VertId{0}, VertId{2}, VertId{3} } |
626 | | - }; |
627 | | - Mesh mesh; |
628 | | - mesh.topology = MeshBuilder::fromTriangles( t ); |
629 | | - mesh.points.emplace_back( 0.f, 0.f, 0.f ); |
630 | | - mesh.points.emplace_back( 1.f, 0.f, 0.f ); |
631 | | - mesh.points.emplace_back( 1.f, 1.f, 0.f ); |
632 | | - mesh.points.emplace_back( 0.f, 1.f, 0.f ); |
633 | | - |
634 | | - EXPECT_EQ( mesh.topology.numValidVerts(), 4 ); |
635 | | - EXPECT_EQ( mesh.points.size(), 4 ); |
636 | | - EXPECT_EQ( mesh.topology.numValidFaces(), 2 ); |
637 | | - EXPECT_EQ( mesh.topology.lastNotLoneEdge(), EdgeId(9) ); // 5*2 = 10 half-edges in total |
638 | | - |
639 | | - FaceBitSet region( 2 ); |
640 | | - region.set( 0_f ); |
641 | | - |
642 | | - auto e02 = mesh.topology.findEdge( VertId{0}, VertId{2} ); |
643 | | - EXPECT_TRUE( e02.valid() ); |
644 | | - auto ex = mesh.splitEdge( e02, ®ion ); |
645 | | - VertId v02 = mesh.topology.org( e02 ); |
646 | | - EXPECT_EQ( mesh.topology.dest( ex ), v02 ); |
647 | | - EXPECT_EQ( mesh.topology.numValidVerts(), 5 ); |
648 | | - EXPECT_EQ( mesh.points.size(), 5 ); |
649 | | - EXPECT_EQ( mesh.topology.numValidFaces(), 4 ); |
650 | | - EXPECT_EQ( mesh.topology.lastNotLoneEdge(), EdgeId(15) ); // 8*2 = 16 half-edges in total |
651 | | - EXPECT_EQ( mesh.points[v02], ( Vector3f(.5f, .5f, 0.f) ) ); |
652 | | - EXPECT_EQ( region.count(), 2 ); |
653 | | - |
654 | | - auto e01 = mesh.topology.findEdge( VertId{0}, VertId{1} ); |
655 | | - EXPECT_TRUE( e01.valid() ); |
656 | | - auto ey = mesh.splitEdge( e01, ®ion ); |
657 | | - VertId v01 = mesh.topology.org( e01 ); |
658 | | - EXPECT_EQ( mesh.topology.dest( ey ), v01 ); |
659 | | - EXPECT_EQ( mesh.topology.numValidVerts(), 6 ); |
660 | | - EXPECT_EQ( mesh.points.size(), 6 ); |
661 | | - EXPECT_EQ( mesh.topology.numValidFaces(), 5 ); |
662 | | - EXPECT_EQ( mesh.topology.lastNotLoneEdge(), EdgeId(19) ); // 10*2 = 20 half-edges in total |
663 | | - EXPECT_EQ( mesh.points[v01], ( Vector3f(.5f, 0.f, 0.f) ) ); |
664 | | - EXPECT_EQ( region.count(), 3 ); |
665 | | -} |
666 | | - |
667 | | -TEST(MRMesh, SplitEdge1) |
668 | | -{ |
669 | | - Mesh mesh; |
670 | | - const auto e01 = mesh.topology.makeEdge(); |
671 | | - mesh.topology.setOrg( e01, mesh.topology.addVertId() ); |
672 | | - mesh.topology.setOrg( e01.sym(), mesh.topology.addVertId() ); |
673 | | - mesh.points.emplace_back( 0.f, 0.f, 0.f ); |
674 | | - mesh.points.emplace_back( 1.f, 0.f, 0.f ); |
675 | | - |
676 | | - EXPECT_EQ( mesh.topology.numValidVerts(), 2 ); |
677 | | - EXPECT_EQ( mesh.points.size(), 2 ); |
678 | | - EXPECT_EQ( mesh.topology.lastNotLoneEdge(), EdgeId(1) ); // 1*2 = 2 half-edges in total |
679 | | - |
680 | | - auto ey = mesh.splitEdge( e01 ); |
681 | | - VertId v01 = mesh.topology.org( e01 ); |
682 | | - EXPECT_EQ( mesh.topology.dest( ey ), v01 ); |
683 | | - EXPECT_EQ( mesh.topology.numValidVerts(), 3 ); |
684 | | - EXPECT_EQ( mesh.points.size(), 3 ); |
685 | | - EXPECT_EQ( mesh.topology.lastNotLoneEdge(), EdgeId(3) ); // 2*2 = 4 half-edges in total |
686 | | - EXPECT_EQ( mesh.points[v01], ( Vector3f( .5f, 0.f, 0.f ) ) ); |
687 | | -} |
688 | | - |
689 | | -TEST(MRMesh, SplitFace) |
690 | | -{ |
691 | | - Triangulation t{ |
692 | | - { VertId{0}, VertId{1}, VertId{2} } |
693 | | - }; |
694 | | - Mesh mesh; |
695 | | - mesh.topology = MeshBuilder::fromTriangles( t ); |
696 | | - mesh.points.emplace_back( 0.f, 0.f, 0.f ); |
697 | | - mesh.points.emplace_back( 0.f, 0.f, 1.f ); |
698 | | - mesh.points.emplace_back( 0.f, 1.f, 0.f ); |
699 | | - |
700 | | - EXPECT_EQ( mesh.topology.numValidVerts(), 3 ); |
701 | | - EXPECT_EQ( mesh.points.size(), 3 ); |
702 | | - EXPECT_EQ( mesh.topology.numValidFaces(), 1 ); |
703 | | - EXPECT_EQ( mesh.topology.lastNotLoneEdge(), EdgeId(5) ); // 3*2 = 6 half-edges in total |
704 | | - |
705 | | - mesh.splitFace( 0_f ); |
706 | | - EXPECT_EQ( mesh.topology.numValidVerts(), 4 ); |
707 | | - EXPECT_EQ( mesh.points.size(), 4 ); |
708 | | - EXPECT_EQ( mesh.topology.numValidFaces(), 3 ); |
709 | | - EXPECT_EQ( mesh.topology.lastNotLoneEdge(), EdgeId(11) ); // 6*2 = 12 half-edges in total |
710 | | -} |
711 | | - |
712 | | -TEST( MRMesh, isOutside ) |
713 | | -{ |
714 | | - Mesh mesh = makeCube(); |
715 | | - EXPECT_TRUE( mesh.isOutside( Vector3f( 2, 0, 0 ) ) ); |
716 | | - EXPECT_FALSE( mesh.isOutside( Vector3f( 0, 0, 0 ) ) ); |
717 | | -} |
718 | | - |
719 | 607 | } //namespace MR |
0 commit comments