Repository: Scrawk/CGALDotNet Branch: master Commit: c8012c4dd4d3 Files: 518 Total size: 4.9 MB Directory structure: gitextract_jbq1twz1/ ├── .editorconfig ├── .gitattributes ├── .gitignore ├── Binaries/ │ ├── CGALDotNet.pdb │ ├── CGALDotNet.xml │ ├── CGALDotNetGeometry.pdb │ └── CGALDotNetGeometry.xml ├── CGALDotNet/ │ ├── Arrangements/ │ │ ├── ArrFace2.cs │ │ ├── ArrHalfEdge2.cs │ │ ├── ArrQuery.cs │ │ ├── ArrVertex2.cs │ │ ├── Arrangement2.cs │ │ ├── ArrangementKernel2.cs │ │ ├── ArrangementKernel2_EEK.cs │ │ ├── SweepLine.cs │ │ ├── SweepLineKernel.cs │ │ ├── SweepLineKernel_EEK.cs │ │ └── SweepLineKernel_EIK.cs │ ├── CGALDotNet.csproj │ ├── CGALDotNet.xml │ ├── CGALGlobal.cs │ ├── CGALKernel.cs │ ├── CGALObject.cs │ ├── CGALObjectKernel.cs │ ├── Collections/ │ │ └── NativeList.cs │ ├── Eigen/ │ │ ├── EigenColumnVector.cs │ │ ├── EigenMatrix.cs │ │ ├── EigenRowVector.cs │ │ └── EigenVector.cs │ ├── Extensions/ │ │ ├── ArrayExtensions.cs │ │ ├── EnumExtensions.cs │ │ └── PrimativeExtensions.cs │ ├── Geometry/ │ │ ├── Box2.cs │ │ ├── CGALIntersections_Geometry_EEK.cs │ │ ├── CGALIntersections_Geometry_EIK.cs │ │ ├── CGALIntersections_Shapes.cs │ │ ├── GeometryKernel2.cs │ │ ├── GeometryKernel2_EEK.cs │ │ ├── GeometryKernel2_EIK.cs │ │ ├── HPoint2.cs │ │ ├── IntersectionResult2d.cs │ │ ├── Line2.cs │ │ ├── Point2.cs │ │ ├── Ray2.cs │ │ ├── Segment2.cs │ │ ├── Triangle2.cs │ │ └── Vector2.cs │ ├── Hulls/ │ │ ├── ConvexHull2.cs │ │ ├── ConvexHull3.cs │ │ ├── ConvexHullKernel2.cs │ │ ├── ConvexHullKernel2_EEK.cs │ │ ├── ConvexHullKernel2_EIK.cs │ │ ├── ConvexHullKernel3.cs │ │ ├── ConvexHullKernel3_EEK.cs │ │ └── ConvexHullKernel3_EIK.cs │ ├── Meshing/ │ │ ├── ConformingTriangulation2.cs │ │ ├── ConformingTriangulationKernel2.cs │ │ ├── ConformingTriangulationKernel2_EEK.cs │ │ ├── ConformingTriangulationKernel2_EIK.cs │ │ ├── SkinSurfaceMeshing.cs │ │ ├── SkinSurfaceMeshingKernel.cs │ │ ├── SkinSurfaceMeshingKernel_EEK.cs │ │ ├── TetrahedralRemeshing.cs │ │ ├── TetrahedralRemeshingKernel.cs │ │ └── TetrahedralRemeshingKernel_EEK.cs │ ├── Polygons/ │ │ ├── Polygon2.cs │ │ ├── PolygonAlgorithm.cs │ │ ├── PolygonBoolean2.cs │ │ ├── PolygonBooleanKernel2.cs │ │ ├── PolygonBooleanKernel2_EEK.cs │ │ ├── PolygonBooleanKernel2_EIK.cs │ │ ├── PolygonFactory.cs │ │ ├── PolygonKernel2.cs │ │ ├── PolygonKernel2_EEK.cs │ │ ├── PolygonKernel2_EIK.cs │ │ ├── PolygonMinkowski.cs │ │ ├── PolygonMinkowskiKernel.cs │ │ ├── PolygonMinkowskiKernel_EEK.cs │ │ ├── PolygonMinkowskiKernel_EIK.cs │ │ ├── PolygonOffset2.cs │ │ ├── PolygonOffsetKernel2.cs │ │ ├── PolygonOffsetKernel2_EEK.cs │ │ ├── PolygonOffsetKernel2_EIK.cs │ │ ├── PolygonPartition2.cs │ │ ├── PolygonPartitionKernel2.cs │ │ ├── PolygonPartitionKernel2_EEK.cs │ │ ├── PolygonPartitionKernel2_EIK.cs │ │ ├── PolygonSimplification2.cs │ │ ├── PolygonSimplificationKernel2.cs │ │ ├── PolygonSimplificationKernel2_EEK.cs │ │ ├── PolygonSimplificationKernel2_EIK.cs │ │ ├── PolygonVisibility.cs │ │ ├── PolygonVisibilityKernel.cs │ │ ├── PolygonVisibilityKernel_EEK.cs │ │ ├── PolygonVisibilityKernel_EIK.cs │ │ ├── PolygonWithHoles2.cs │ │ ├── PolygonWithHolesKernel2.cs │ │ ├── PolygonWithHolesKernel2_EEK.cs │ │ └── PolygonWithHolesKernel2_EIK.cs │ ├── Polyhedra/ │ │ ├── IMesh.cs │ │ ├── MeshFace3.cs │ │ ├── MeshFactory.cs │ │ ├── MeshHalfedge3.cs │ │ ├── MeshHitResult.cs │ │ ├── MeshVertex3.cs │ │ ├── NefPolyhedron3.cs │ │ ├── NefPolyhedronKernel3.cs │ │ ├── NefPolyhedronKernel3_EEK.cs │ │ ├── NefPolyhedronKernel3_EIK.cs │ │ ├── PolygonalCount.cs │ │ ├── PolygonalIndices.cs │ │ ├── PolyhedraAlgorithm.cs │ │ ├── Polyhedron3.cs │ │ ├── PolyhedronFactory.cs │ │ ├── PolyhedronKernel3.cs │ │ ├── PolyhedronKernel3_EEK.cs │ │ ├── PolyhedronKernel3_EIK.cs │ │ ├── SurfaceMesh3.cs │ │ ├── SurfaceMeshFactory.cs │ │ ├── SurfaceMeshKernel3.cs │ │ ├── SurfaceMeshKernel3_EEK.cs │ │ └── SurfaceMeshKernel3_EIK.cs │ ├── Polylines/ │ │ ├── Polyline2.cs │ │ ├── Polyline3.cs │ │ ├── PolylineKernel2.cs │ │ ├── PolylineKernel2_EEK.cs │ │ ├── PolylineKernel2_EIK.cs │ │ ├── PolylineKernel3.cs │ │ ├── PolylineKernel3_EEK.cs │ │ └── PolylineKernel3_EIK.cs │ ├── Processing/ │ │ ├── HeatMethod.cs │ │ ├── HeatMethodKernel.cs │ │ ├── HeatMethodKernel_EEK.cs │ │ ├── HeatMethodKernel_EIK.cs │ │ ├── MeshProcessingBoolean.cs │ │ ├── MeshProcessingBooleanKernel.cs │ │ ├── MeshProcessingBooleanKernel_EEK.cs │ │ ├── MeshProcessingBooleanKernel_EIK.cs │ │ ├── MeshProcessingConnections.cs │ │ ├── MeshProcessingConnectionsKernel.cs │ │ ├── MeshProcessingConnectionsKernel_EEK.cs │ │ ├── MeshProcessingConnectionsKernel_EIK.cs │ │ ├── MeshProcessingFeatures.cs │ │ ├── MeshProcessingFeaturesKernel.cs │ │ ├── MeshProcessingFeaturesKernel_EEK.cs │ │ ├── MeshProcessingFeaturesKernel_EIK.cs │ │ ├── MeshProcessingLocate.cs │ │ ├── MeshProcessingLocateKernel.cs │ │ ├── MeshProcessingLocateKernel_EEK.cs │ │ ├── MeshProcessingLocateKernel_EIK.cs │ │ ├── MeshProcessingMeshing.cs │ │ ├── MeshProcessingMeshingKernel.cs │ │ ├── MeshProcessingMeshingKernel_EEK.cs │ │ ├── MeshProcessingMeshingKernel_EIK.cs │ │ ├── MeshProcessingOrientation.cs │ │ ├── MeshProcessingOrientationKernel.cs │ │ ├── MeshProcessingOrientationKernel_EEK.cs │ │ ├── MeshProcessingOrientationKernel_EIK.cs │ │ ├── MeshProcessingRepair.cs │ │ ├── MeshProcessingRepairKernel.cs │ │ ├── MeshProcessingRepairKernel_EEK.cs │ │ ├── MeshProcessingRepairKernel_EIK.cs │ │ ├── MeshProcessingSlicer.cs │ │ ├── MeshProcessingSlicerKernel.cs │ │ ├── MeshProcessingSlicerKernel_EEK.cs │ │ ├── MeshProcessingSlicerKernel_EIK.cs │ │ ├── SurfaceSimplification.cs │ │ ├── SurfaceSimplificationKernel.cs │ │ ├── SurfaceSimplificationKernel_EIK.cs │ │ ├── SurfaceSubdivision.cs │ │ ├── SurfaceSubdivisionKernel.cs │ │ ├── SurfaceSubdivisionKernel_EEK.cs │ │ └── SurfaceSubdivisionKernel_EIK.cs │ ├── Properties/ │ │ └── launchSettings.json │ ├── Triangulations/ │ │ ├── BaseTriangulation2.cs │ │ ├── BaseTriangulation3.cs │ │ ├── BaseTriangulationKernel2.cs │ │ ├── BaseTriangulationKernel3.cs │ │ ├── ConstrainedDelaunayTriangulation2.cs │ │ ├── ConstrainedDelaunayTriangulationKernel2.cs │ │ ├── ConstrainedDelaunayTriangulationKernel2_EEK.cs │ │ ├── ConstrainedDelaunayTriangulationKernel2_EIK.cs │ │ ├── ConstrainedTriangulation2.cs │ │ ├── ConstrainedTriangulationKernel2.cs │ │ ├── ConstrainedTriangulationKernel2_EEK.cs │ │ ├── ConstrainedTriangulationKernel2_EIK.cs │ │ ├── DelaunayTriangulation2.cs │ │ ├── DelaunayTriangulation3.cs │ │ ├── DelaunayTriangulationKernel2.cs │ │ ├── DelaunayTriangulationKernel2_EEK.cs │ │ ├── DelaunayTriangulationKernel2_EIK.cs │ │ ├── DelaunayTriangulationKernel3.cs │ │ ├── DelaunayTriangulationKernel3_EEK.cs │ │ ├── TriCell3.cs │ │ ├── TriEdge2.cs │ │ ├── TriFace2.cs │ │ ├── TriVertex2.cs │ │ ├── TriVertex3.cs │ │ ├── Triangulation2.cs │ │ ├── Triangulation3.cs │ │ ├── TriangulationKernel2.cs │ │ ├── TriangulationKernel2_EEK.cs │ │ ├── TriangulationKernel2_EIK.cs │ │ ├── TriangulationKernel3.cs │ │ └── TriangulationKernel3_EEK.cs │ └── Util/ │ ├── ArrayCache.cs │ ├── CGALEnums.cs │ └── ErrorUtil.cs ├── CGALDotNet.sln ├── CGALDotNetConsole/ │ ├── CGALDotNetConsole.csproj │ ├── Program.cs │ ├── Properties/ │ │ ├── Resources.Designer.cs │ │ ├── Resources.resx │ │ └── launchSettings.json │ └── Timer.cs ├── CGALDotNetTest/ │ ├── AssertX.cs │ ├── CGALDotNetTest.csproj │ ├── CGALGlobalTest.cs │ ├── Eigen/ │ │ └── EigenMatrix_Test.cs │ ├── Geometry/ │ │ ├── Box2_EEK_Test.cs │ │ ├── Box2_EIK_Test.cs │ │ ├── HPoint2_EEK_Test.cs │ │ ├── HPoint2_EIK_Test.cs │ │ ├── Line2_EIK_Test.cs │ │ ├── Point2_EEK_Test.cs │ │ ├── Point2_EIK_Test.cs │ │ ├── Ray2_EIK_Test.cs │ │ ├── Segment2_EIK_Test.cs │ │ ├── Triangle2_EIK_Test.cs │ │ ├── Vector2_EEK_Test.cs │ │ └── Vector2_EIK_Test.cs │ ├── Polygons/ │ │ ├── Polygon2_EEK_Test.cs │ │ ├── Polygon2_EIK_Test.cs │ │ ├── PolygonWithHoles2_EEK_Test.cs │ │ └── PolygonWithHoles2_EIK_Test.cs │ ├── Polyhedra/ │ │ ├── Polyhedron3_EEK_Test.cs │ │ └── SurfaceMesh3_EEK_Test.cs │ └── Processing/ │ ├── MeshProcessingConnectionsPolyhedronTest.cs │ ├── MeshProcessingConnectionsSurfaceMeshTest.cs │ ├── MeshProcessingFeaturesPolyhedronTest.cs │ ├── MeshProcessingFeaturesSurfaceMeshTest.cs │ ├── MeshProcessingLocatePolyhedronTest.cs │ ├── MeshProcessingLocateSurfaceMeshTest.cs │ ├── MeshProcessingMeshingPolyhedronTest.cs │ ├── MeshProcessingMeshingSurfaceMeshTest.cs │ ├── MeshProcessingOrientationPolyhedronTest.cs │ ├── MeshProcessingOrientationSurfaceMeshTest.cs │ ├── MeshProcessingRepairPolyhedronTest.cs │ └── MeshProcessingRepairSurfaceMeshTest.cs ├── CGALWrapper/ │ ├── Arrangments/ │ │ ├── ArrFace2.h │ │ ├── ArrHalfEdge2.h │ │ ├── ArrMultiLocator.h │ │ ├── ArrVertex2.h │ │ ├── Arrangement2.h │ │ ├── Arrangement2_EEK.cpp │ │ ├── Arrangement2_EEK.h │ │ ├── ArrangementMap.h │ │ ├── SweepLine.h │ │ ├── SweepLine_EEK.cpp │ │ ├── SweepLine_EEK.h │ │ ├── SweepLine_EIK.cpp │ │ └── SweepLine_EIK.h │ ├── CGALWrapper.h │ ├── CGALWrapper.rc │ ├── CGALWrapper.vcxproj │ ├── CGALWrapper.vcxproj.filters │ ├── Circlar/ │ │ ├── Circle2.h │ │ ├── Circle2_EEK.cpp │ │ └── Circle2_EEK.h │ ├── Collections/ │ │ ├── IndexMap.h │ │ ├── NativeList.cpp │ │ └── NativeList.h │ ├── Eigen/ │ │ ├── EigenColumnVector.cpp │ │ ├── EigenColumnVector.h │ │ ├── EigenMatrix.cpp │ │ ├── EigenMatrix.h │ │ ├── EigenRowVector.cpp │ │ └── EigenRowVector.h │ ├── Geometry/ │ │ ├── Box2_EEK.cpp │ │ ├── Box2_EEK.h │ │ ├── Box2_EIK.cpp │ │ ├── Box2_EIK.h │ │ ├── Geometry2.h │ │ ├── Geometry3.h │ │ ├── HPoint2_EEK.cpp │ │ ├── HPoint2_EEK.h │ │ ├── HPoint2_EIK.cpp │ │ ├── HPoint2_EIK.h │ │ ├── Index.h │ │ ├── IntersectionResult.h │ │ ├── Intersections_geometry.h │ │ ├── Intersections_geometry_EEK.cpp │ │ ├── Intersections_geometry_EEK.h │ │ ├── Intersections_geometry_EIK.cpp │ │ ├── Intersections_geometry_EIK.h │ │ ├── Intersections_shapes.h │ │ ├── Intersections_shapes_EIK.cpp │ │ ├── Intersections_shapes_EIK.h │ │ ├── Line2_EEK.cpp │ │ ├── Line2_EEK.h │ │ ├── Line2_EIK.cpp │ │ ├── Line2_EIK.h │ │ ├── Matrices.h │ │ ├── MinMax.h │ │ ├── Point2_EEK.cpp │ │ ├── Point2_EEK.h │ │ ├── Point2_EIK.cpp │ │ ├── Point2_EIK.h │ │ ├── Ray2_EEK.cpp │ │ ├── Ray2_EEK.h │ │ ├── Ray2_EIK.cpp │ │ ├── Ray2_EIK.h │ │ ├── Segment2_EEK.cpp │ │ ├── Segment2_EEK.h │ │ ├── Segment2_EIK.cpp │ │ ├── Segment2_EIK.h │ │ ├── Triangle2_EEK.cpp │ │ ├── Triangle2_EEK.h │ │ ├── Triangle2_EIK.cpp │ │ ├── Triangle2_EIK.h │ │ ├── Vector2_EEK.cpp │ │ ├── Vector2_EEK.h │ │ ├── Vector2_EIK.cpp │ │ └── Vector2_EIK.h │ ├── Hull/ │ │ ├── ConvexHull2.h │ │ ├── ConvexHull2_EEK.cpp │ │ ├── ConvexHull2_EEK.h │ │ ├── ConvexHull2_EIK.cpp │ │ ├── ConvexHull2_EIK.h │ │ ├── ConvexHull3.h │ │ ├── ConvexHull3_EEK.cpp │ │ ├── ConvexHull3_EEK.h │ │ ├── ConvexHull3_EIK.cpp │ │ └── ConvexHull3_EIK.h │ ├── Meshing/ │ │ ├── ConformingTriangulation2.h │ │ ├── ConformingTriangulation2_EEK.cpp │ │ ├── ConformingTriangulation2_EEK.h │ │ ├── ConformingTriangulation2_EIK.cpp │ │ ├── ConformingTriangulation2_EIK.h │ │ ├── SkinSurfaceMeshing_EEK.cpp │ │ ├── SkinSurfaceMeshing_EEK.h │ │ ├── SkinSurfaceMesing.h │ │ ├── TetrahedralRemeshing.h │ │ ├── TetrahedralRemeshing_EEK.cpp │ │ └── TetrahedralRemeshing_EEK.h │ ├── Polygons/ │ │ ├── Polygon2.h │ │ ├── Polygon2_EEK.cpp │ │ ├── Polygon2_EEK.h │ │ ├── Polygon2_EIK.cpp │ │ ├── Polygon2_EIK.h │ │ ├── PolygonBoolean2.h │ │ ├── PolygonBoolean2_EEK.cpp │ │ ├── PolygonBoolean2_EEK.h │ │ ├── PolygonBoolean2_EIK.cpp │ │ ├── PolygonBoolean2_EIK.h │ │ ├── PolygonMinkowski.h │ │ ├── PolygonMinkowski_EEK.cpp │ │ ├── PolygonMinkowski_EEK.h │ │ ├── PolygonMinkowski_EIK.cpp │ │ ├── PolygonMinkowski_EIK.h │ │ ├── PolygonOffset2.h │ │ ├── PolygonOffset2_EEK.cpp │ │ ├── PolygonOffset2_EEK.h │ │ ├── PolygonOffset2_EIK.cpp │ │ ├── PolygonOffset2_EIK.h │ │ ├── PolygonPartition2.h │ │ ├── PolygonPartition2_EEK.cpp │ │ ├── PolygonPartition2_EEK.h │ │ ├── PolygonPartition2_EIK.cpp │ │ ├── PolygonPartition2_EIK.h │ │ ├── PolygonSimplification2.h │ │ ├── PolygonSimplification2_EEK.cpp │ │ ├── PolygonSimplification2_EEK.h │ │ ├── PolygonSimplification2_EIK.cpp │ │ ├── PolygonSimplification2_EIK.h │ │ ├── PolygonVisibility_EEK.cpp │ │ ├── PolygonVisibility_EEK.h │ │ ├── PolygonVisibility_EIK.cpp │ │ ├── PolygonVisibility_EIK.h │ │ ├── PolygonVisiblity.h │ │ ├── PolygonWithHoles2.h │ │ ├── PolygonWithHoles2_EEK.cpp │ │ ├── PolygonWithHoles2_EEK.h │ │ ├── PolygonWithHoles2_EIK.cpp │ │ └── PolygonWithHoles2_EIK.h │ ├── Polyhedra/ │ │ ├── MeshBuilders.h │ │ ├── MeshFace3.h │ │ ├── MeshHalfedge3.h │ │ ├── MeshHitResult.h │ │ ├── MeshVertex3.h │ │ ├── NefPolyhedron3.h │ │ ├── NefPolyhedron3_EEK.cpp │ │ ├── NefPolyhedron3_EEK.h │ │ ├── NefPolyhedron3_EIK.cpp │ │ ├── NefPolyhedron3_EIK.h │ │ ├── PolygonalCount.h │ │ ├── Polyhedron3.h │ │ ├── Polyhedron3_EEK.cpp │ │ ├── Polyhedron3_EEK.h │ │ ├── Polyhedron3_EIK.cpp │ │ ├── Polyhedron3_EIK.h │ │ ├── PolyhedronMap.h │ │ ├── SurfaceMesh3.h │ │ ├── SurfaceMesh3_EEK.cpp │ │ ├── SurfaceMesh3_EEK.h │ │ ├── SurfaceMesh3_EIK.cpp │ │ ├── SurfaceMesh3_EIK.h │ │ └── SurfaceMeshMap.h │ ├── Polylines/ │ │ ├── Polyline2.h │ │ ├── Polyline2_EEK.cpp │ │ ├── Polyline2_EEK.h │ │ ├── Polyline2_EIK.cpp │ │ ├── Polyline2_EIK.h │ │ ├── Polyline3.h │ │ ├── Polyline3_EEK.cpp │ │ ├── Polyline3_EEK.h │ │ ├── Polyline3_EIK.cpp │ │ └── Polyline3_EIK.h │ ├── Processing/ │ │ ├── HeatMethod.h │ │ ├── HeatMethod_EEK.cpp │ │ ├── HeatMethod_EEK.h │ │ ├── HeatMethod_EIK.cpp │ │ ├── HeatMethod_EIK.h │ │ ├── MeshProcessingBoolean.h │ │ ├── MeshProcessingBoolean_EEK.cpp │ │ ├── MeshProcessingBoolean_EEK.h │ │ ├── MeshProcessingBoolean_EIK.cpp │ │ ├── MeshProcessingBoolean_EIK.h │ │ ├── MeshProcessingConnections.h │ │ ├── MeshProcessingConnections_EEK.cpp │ │ ├── MeshProcessingConnections_EEK.h │ │ ├── MeshProcessingConnections_EIK.cpp │ │ ├── MeshProcessingConnections_EIK.h │ │ ├── MeshProcessingFeatures.h │ │ ├── MeshProcessingFeatures_EEK.cpp │ │ ├── MeshProcessingFeatures_EEK.h │ │ ├── MeshProcessingFeatures_EIK.cpp │ │ ├── MeshProcessingFeatures_EIK.h │ │ ├── MeshProcessingLocate.h │ │ ├── MeshProcessingLocate_EEK.cpp │ │ ├── MeshProcessingLocate_EEK.h │ │ ├── MeshProcessingLocate_EIK.cpp │ │ ├── MeshProcessingLocate_EIK.h │ │ ├── MeshProcessingMeshing.h │ │ ├── MeshProcessingMeshing_EEK.cpp │ │ ├── MeshProcessingMeshing_EEK.h │ │ ├── MeshProcessingMeshing_EIK.cpp │ │ ├── MeshProcessingMeshing_EIK.h │ │ ├── MeshProcessingOrientation.h │ │ ├── MeshProcessingOrientation_EEK.cpp │ │ ├── MeshProcessingOrientation_EEK.h │ │ ├── MeshProcessingOrientation_EIK.cpp │ │ ├── MeshProcessingOrientation_EIK.h │ │ ├── MeshProcessingRepair.h │ │ ├── MeshProcessingRepair_EEK.cpp │ │ ├── MeshProcessingRepair_EEK.h │ │ ├── MeshProcessingRepair_EIK.cpp │ │ ├── MeshProcessingRepair_EIK.h │ │ ├── MeshProcessingSlicer.h │ │ ├── MeshProcessingSlicer_EEK.cpp │ │ ├── MeshProcessingSlicer_EEK.h │ │ ├── MeshProcessingSlicer_EIK.cpp │ │ ├── MeshProcessingSlicer_EIK.h │ │ ├── SurfaceSimplification.h │ │ ├── SurfaceSimplification_EIK.cpp │ │ ├── SurfaceSimplification_EIK.h │ │ ├── SurfaceSubdivision.h │ │ ├── SurfaceSubdivision_EEK.cpp │ │ ├── SurfaceSubdivision_EEK.h │ │ ├── SurfaceSubdivision_EIK.cpp │ │ └── SurfaceSubdivision_EIK.h │ ├── Triangulations/ │ │ ├── BaseTriangulation2.h │ │ ├── BaseTriangulation3.h │ │ ├── ConstrainedDelaunayTriangulation2.h │ │ ├── ConstrainedDelaunayTriangulation2_EEK.cpp │ │ ├── ConstrainedDelaunayTriangulation2_EEK.h │ │ ├── ConstrainedDelaunayTriangulation2_EIK.cpp │ │ ├── ConstrainedDelaunayTriangulation2_EIK.h │ │ ├── ConstrainedTriangulation2.h │ │ ├── ConstrainedTriangulation2_EEK.cpp │ │ ├── ConstrainedTriangulation2_EEK.h │ │ ├── ConstrainedTriangulation2_EIK.cpp │ │ ├── ConstrainedTriangulation2_EIK.h │ │ ├── DelaunayTriangulation2.h │ │ ├── DelaunayTriangulation2_EEK.cpp │ │ ├── DelaunayTriangulation2_EEK.h │ │ ├── DelaunayTriangulation2_EIK.cpp │ │ ├── DelaunayTriangulation2_EIK.h │ │ ├── DelaunayTriangulation3.h │ │ ├── DelaunayTriangulation3_EEK.cpp │ │ ├── DelaunayTriangulation3_EEK.h │ │ ├── TriCell3.h │ │ ├── TriEdge2.h │ │ ├── TriFace2.h │ │ ├── TriUtil.h │ │ ├── TriVertex2.h │ │ ├── TriVertex3.h │ │ ├── Triangulation2.h │ │ ├── Triangulation2_EEK.cpp │ │ ├── Triangulation2_EEK.h │ │ ├── Triangulation2_EIK.cpp │ │ ├── Triangulation2_EIK.h │ │ ├── Triangulation3.h │ │ ├── Triangulation3_EEK.cpp │ │ ├── Triangulation3_EEK.h │ │ └── TriangulationMap2.h │ ├── Utility/ │ │ ├── ArrayUtil.h │ │ ├── CGALGlobal.h │ │ ├── CGALGlobal_EIK_EEK.cpp │ │ ├── CGALGlobal_EIK_EEK.h │ │ ├── VersionNumber.cpp │ │ └── VersionNumber.h │ ├── framework.h │ ├── pch.cpp │ ├── pch.h │ └── resource.h ├── LICENSE └── README.md ================================================ FILE CONTENTS ================================================ ================================================ FILE: .editorconfig ================================================ [*.cs] # CS1591: Missing XML comment for publicly visible type or member dotnet_diagnostic.CS1591.severity = none ================================================ FILE: .gitattributes ================================================ ############################################################################### # Set default behavior to automatically normalize line endings. ############################################################################### * text=auto ############################################################################### # Set default behavior for command prompt diff. # # This is need for earlier builds of msysgit that does not have it on by # default for csharp files. # Note: This is only used by command line ############################################################################### #*.cs diff=csharp ############################################################################### # Set the merge driver for project and solution files # # Merging from the command prompt will add diff markers to the files if there # are conflicts (Merging from VS is not affected by the settings below, in VS # the diff markers are never inserted). Diff markers may cause the following # file extensions to fail to load in VS. An alternative would be to treat # these files as binary and thus will always conflict and require user # intervention with every merge. To do so, just uncomment the entries below ############################################################################### #*.sln merge=binary #*.csproj merge=binary #*.vbproj merge=binary #*.vcxproj merge=binary #*.vcproj merge=binary #*.dbproj merge=binary #*.fsproj merge=binary #*.lsproj merge=binary #*.wixproj merge=binary #*.modelproj merge=binary #*.sqlproj merge=binary #*.wwaproj merge=binary ############################################################################### # behavior for image files # # image files are treated as binary by default. ############################################################################### #*.jpg binary #*.png binary #*.gif binary ############################################################################### # diff behavior for common document formats # # Convert binary document formats to text before diffing them. This feature # is only available from the command line. Turn it on by uncommenting the # entries below. ############################################################################### #*.doc diff=astextplain #*.DOC diff=astextplain #*.docx diff=astextplain #*.DOCX diff=astextplain #*.dot diff=astextplain #*.DOT diff=astextplain #*.pdf diff=astextplain #*.PDF diff=astextplain #*.rtf diff=astextplain #*.RTF diff=astextplain ================================================ FILE: .gitignore ================================================ ## Ignore Visual Studio temporary files, build results, and ## files generated by popular Visual Studio add-ons. ## ## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore # User-specific files *.rsuser *.suo *.user *.userosscache *.sln.docstates # User-specific files (MonoDevelop/Xamarin Studio) *.userprefs # Mono auto generated files mono_crash.* # Build results [Dd]ebug/ [Dd]ebugPublic/ [Rr]elease/ [Rr]eleases/ x64/ x86/ [Ww][Ii][Nn]32/ [Aa][Rr][Mm]/ [Aa][Rr][Mm]64/ bld/ [Bb]in/ [Oo]bj/ [Oo]ut/ [Ll]og/ [Ll]ogs/ # Visual Studio 2015/2017 cache/options directory .vs/ # Uncomment if you have tasks that create the project's static files in wwwroot #wwwroot/ # Visual Studio 2017 auto generated files Generated\ Files/ # MSTest test Results [Tt]est[Rr]esult*/ [Bb]uild[Ll]og.* # NUnit *.VisualState.xml TestResult.xml nunit-*.xml # Build Results of an ATL Project [Dd]ebugPS/ [Rr]eleasePS/ dlldata.c # Benchmark Results BenchmarkDotNet.Artifacts/ # .NET Core project.lock.json project.fragment.lock.json artifacts/ # ASP.NET Scaffolding ScaffoldingReadMe.txt # StyleCop StyleCopReport.xml # Files built by Visual Studio *_i.c *_p.c *_h.h *.ilk *.meta *.obj *.iobj *.pch *.ipdb *.pgc *.pgd *.rsp *.sbr *.tlb *.tli *.tlh *.tmp *.tmp_proj *_wpftmp.csproj *.log *.vspscc *.vssscc .builds *.pidb *.svclog *.scc # Chutzpah Test files _Chutzpah* # Visual C++ cache files ipch/ *.aps *.ncb *.opendb *.opensdf *.sdf *.cachefile *.VC.db *.VC.VC.opendb # Visual Studio profiler *.psess *.vsp *.vspx *.sap # Visual Studio Trace Files *.e2e # TFS 2012 Local Workspace $tf/ # Guidance Automation Toolkit *.gpState # ReSharper is a .NET coding add-in _ReSharper*/ *.[Rr]e[Ss]harper *.DotSettings.user # TeamCity is a build add-in _TeamCity* # DotCover is a Code Coverage Tool *.dotCover # AxoCover is a Code Coverage Tool .axoCover/* !.axoCover/settings.json # Coverlet is a free, cross platform Code Coverage Tool coverage*.json coverage*.xml coverage*.info # Visual Studio code coverage results *.coverage *.coveragexml # NCrunch _NCrunch_* .*crunch*.local.xml nCrunchTemp_* # MightyMoose *.mm.* AutoTest.Net/ # Web workbench (sass) .sass-cache/ # Installshield output folder [Ee]xpress/ # DocProject is a documentation generator add-in DocProject/buildhelp/ DocProject/Help/*.HxT DocProject/Help/*.HxC DocProject/Help/*.hhc DocProject/Help/*.hhk DocProject/Help/*.hhp DocProject/Help/Html2 DocProject/Help/html # Click-Once directory publish/ # Publish Web Output *.[Pp]ublish.xml *.azurePubxml # Note: Comment the next line if you want to checkin your web deploy settings, # but database connection strings (with potential passwords) will be unencrypted *.pubxml *.publishproj # Microsoft Azure Web App publish settings. Comment the next line if you want to # checkin your Azure Web App publish settings, but sensitive information contained # in these scripts will be unencrypted PublishScripts/ # NuGet Packages *.nupkg # NuGet Symbol Packages *.snupkg # The packages folder can be ignored because of Package Restore **/[Pp]ackages/* # except build/, which is used as an MSBuild target. !**/[Pp]ackages/build/ # Uncomment if necessary however generally it will be regenerated when needed #!**/[Pp]ackages/repositories.config # NuGet v3's project.json files produces more ignorable files *.nuget.props *.nuget.targets # Microsoft Azure Build Output csx/ *.build.csdef # Microsoft Azure Emulator ecf/ rcf/ # Windows Store app package directories and files AppPackages/ BundleArtifacts/ Package.StoreAssociation.xml _pkginfo.txt *.appx *.appxbundle *.appxupload # Visual Studio cache files # files ending in .cache can be ignored *.[Cc]ache # but keep track of directories ending in .cache !?*.[Cc]ache/ # Others ClientBin/ ~$* *~ *.dbmdl *.dbproj.schemaview *.jfm *.pfx *.publishsettings orleans.codegen.cs # Including strong name files can present a security risk # (https://github.com/github/gitignore/pull/2483#issue-259490424) #*.snk # Since there are multiple workflows, uncomment next line to ignore bower_components # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) #bower_components/ # RIA/Silverlight projects Generated_Code/ # Backup & report files from converting an old project file # to a newer Visual Studio version. Backup files are not needed, # because we have git ;-) _UpgradeReport_Files/ Backup*/ UpgradeLog*.XML UpgradeLog*.htm ServiceFabricBackup/ *.rptproj.bak # SQL Server files *.mdf *.ldf *.ndf # Business Intelligence projects *.rdl.data *.bim.layout *.bim_*.settings *.rptproj.rsuser *- [Bb]ackup.rdl *- [Bb]ackup ([0-9]).rdl *- [Bb]ackup ([0-9][0-9]).rdl # Microsoft Fakes FakesAssemblies/ # GhostDoc plugin setting file *.GhostDoc.xml # Node.js Tools for Visual Studio .ntvs_analysis.dat node_modules/ # Visual Studio 6 build log *.plg # Visual Studio 6 workspace options file *.opt # Visual Studio 6 auto-generated workspace file (contains which files were open etc.) *.vbw # Visual Studio LightSwitch build output **/*.HTMLClient/GeneratedArtifacts **/*.DesktopClient/GeneratedArtifacts **/*.DesktopClient/ModelManifest.xml **/*.Server/GeneratedArtifacts **/*.Server/ModelManifest.xml _Pvt_Extensions # Paket dependency manager .paket/paket.exe paket-files/ # FAKE - F# Make .fake/ # CodeRush personal settings .cr/personal # Python Tools for Visual Studio (PTVS) __pycache__/ *.pyc # Cake - Uncomment if you are using it # tools/** # !tools/packages.config # Tabs Studio *.tss # Telerik's JustMock configuration file *.jmconfig # BizTalk build output *.btp.cs *.btm.cs *.odx.cs *.xsd.cs # OpenCover UI analysis results OpenCover/ # Azure Stream Analytics local run output ASALocalRun/ # MSBuild Binary and Structured Log *.binlog # NVidia Nsight GPU debugger configuration file *.nvuser # MFractors (Xamarin productivity tool) working folder .mfractor/ # Local History for Visual Studio .localhistory/ # BeatPulse healthcheck temp database healthchecksdb # Backup folder for Package Reference Convert tool in Visual Studio 2017 MigrationBackup/ # Ionide (cross platform F# VS Code tools) working folder .ionide/ # Fody - auto-generated XML schema FodyWeavers.xsd ================================================ FILE: Binaries/CGALDotNet.xml ================================================ CGALDotNet The generic arrangment class. The kernel type. The default constructor. Create a arrangement from a unmanaged ptr. The unmanaged pointer. The arrangement as a string. Assigns the contents of another arrangement. The other arrangement. Computes the overlay of two arrangements and return as a new arrangement. The other arrangement. The overlay of both arrangements. Create a deep copy of this arrangment. The deep copy. Insert the polygon into this arrangement. The polygon. If the polygon intersects anything else in the arramgement. Insert the polygon into this arrangement. The polygon. If the polygon intersects anything else in the arramgement. The abstract base class. The default constructor. Create a arrangement from the kernel. The kernel. Create a arrangement from the kernel and unmanaged pointer. The kernel. The unmanaged pointer. The arrangements kernel. The number of vertices in the arrangement. The number of vertices in the arrangement that are i returns the number of arrangement vertices that lie at infinity a nd are not associated with valid points. Such vertices are not considered to be regular arrangement vertices and VertexCount does not count them. The number of half edges. The number of edges. two half edges count as one edge. The number of faces in the arrangement not counting the unbounded face. returns the number of unbounded faces in the arrangement. Such faces are not considered to be regular arrangement faces and FaceCount does not count them. The type of locator used to find element in the arrangement when queried. Default is walk which is the best in most cases Is the arrangement empty. A number that will change if the unmanaged arrangement model changes. Clear the arrangement. In particular, the functions checks the topological structure of the arrangement and assures that it is valid. In addition, the function performs several simple geometric tests to ensure the validity of some of the geometric properties of the arrangement. Namely, it checks that all arrangement vertices are associated with distinct points, and that the halfedges around every vertex are ordered clockwise. Get a copy of all the points in the arrangement. A point array that is the length of the vertex count. The ararys length. Get a copy of all the segments in the arrangment. A segment array that is the length of the edge count. The ararys length. Get a copy of all the vertices in the arrangement. A vertices array that is the length of the vertex count. The ararys length. Get the vertex from the arrangement. The index of the vertex. The vertex. True if the vertex was found. Get a copy of all the half edges in the arrangement. A half edge array that is the length of the half edge count. The ararys length. Get the half edge from the arrangement. The index of the half edge. The half edge. True if the half edge was found. Get a copy of all the faces in the arrangement. A face array that is the length of the facee count. The ararys length. Get the face from the arrangement. The index of the half edge. The face. True if the face was found. Create the locator used to find query the arrangement. The locator type. Release the locator. Default will be used.. Default is walk which is the best in most cases. Query what the point hits in the arrangment. The point to query. What was hit. True if something was hit. Query multiple points in the arrangment. The points to query. The results for each point. True if any point hit something. Query using a ray going up or down (y axis) from the query point. The point to start at. True to shoot ray up, false to shoot down. The result of what was hits. True if some thing was hit. Locate the vertex at this point. The point to locate vertex at. The vertex. True if a vertex was located. Locate the closest vertex in the hit face The point The radius te closest vertex has to be within. The closest vertex. True if point hit a face and found a vertex. Locate the edge at this point. The point to locate edge at. The edge. True if a edge was located. Locate the closest edge in the hit face. The point The closest edge. The radius from the point a edge counts as being clicked on. True if the point hit a face and found a edge. Locate the faces at this point. The point to locate face at. The face. True if a face was located. Find if the arrangement has a element that intersects the segment. The segment. True if the segment intersects something in the arrangement. Inserts a given point into a given arrangement. It uses a given point-location object to locate the given point in the given arrangement. If the point conincides with an existing vertex, there is nothing left to do. if it lies on an edge, the edge is split at the point. Otherwise, the point is contained inside a face, and is inserted as an isolated vertex inside this face. The point to insert. Insert the segment in to the arrangement. The segments start point. The segments end point. True if the segment is know not to hit anything currently in the arrangement. Insert a segment into the arrangement. True if the segment is know not to hit anything currently in the arrangement. Insert a array of segments into the arrangement. The segment array The segment arrays length. True if the segments are known not to hit anything currently in the arrangement. Attempts to removed a given vertex from a given arrangement. The vertex can be removed if it is either an isolated vertex, (and has no incident edge,) or if it is a redundant vertex.That is, it has exactly two incident edges, whose associated curves can be merged to form a single x-monotone curve.The function returns a boolean value that indicates whether it succeeded removing the vertex from the arrangement. The index of the vertex in the arrangement. True if the vertex was removed. Attempts to removed a given vertex from a given arrangement. The vertex can be removed if it is either an isolated vertex, (and has no incident edge,) or if it is a redundant vertex.That is, it has exactly two incident edges, whose associated curves can be merged to form a single x-monotone curve.The function returns a boolean value that indicates whether it succeeded removing the vertex from the arrangement. The poisition of the vertex in the arrangement. True if the vertex was removed. Removes an edge at the index from the arrangement. Once the edge is removed, if the vertices associated with its endpoints become isolated, they are removed as well. The index of the one of the half edges in the arrangement. True if the edge was removed. Removes an edge at the index from the arrangement. Once the edge is removed, if the vertices associated with its endpoints become isolated, they are removed as well. A segment with the same positions as the edge in the arrangement. True if the edge was removed. Release any unmanaged resources. The generic sweep line class. The kernel. A static instanceof a sweep line. Default constructor. Create from a unmanaged pointer. The sweep line as a string. The abstract sweep line. The default sweep line. Create from the kernel. A kernel that implements a sweep line. Create from the kernel and unmanaged pointer. A kernel that implements a sweep line. A unmanaged pointer to a sweep line. The sweep line kernel. Do any of the segments in the array intersect. The segment array. The ararys length. Do any of the segments in the array intersect. Compute all the sub segemnts from the intersection of the segments in the array. The segment array. The ararys length. The sub segments. Compute all the intersection points from the segments in the array. The segment array. The ararys length. The intersection points. Get all the points in the point buffer. A point array the size of the point buffer. The ararys length. Get all the segments in the point buffer. A segment array the size of the segment buffer. The ararys length. Clear the point buffer. Clear the segment buffer. Release any unmanaged resources. Global utility functions. Get the version of CGAL in use. Get the version of eigen being used. Returns OBTUSE, RIGHT or ACUTE depending on the angle formed by the two vectors u and v. The first vector. The second vector. OBTUSE, RIGHT or ACUTE depending on the angle formed by the two vectors u and v. Returns OBTUSE, RIGHT or ACUTE depending on the angle formed by the two vectors u and v. The first vector. The second vector. OBTUSE, RIGHT or ACUTE depending on the angle formed by the two vectors u and v. Returns OBTUSE, RIGHT or ACUTE depending on the angle formed by the two vectors u and v. The first vector. The second vector. OBTUSE, RIGHT or ACUTE depending on the angle formed by the two vectors u and v. returns OBTUSE, RIGHT or ACUTE depending on the angle formed by the two vectors u and v. The first vector. The second vector. OBTUSE, RIGHT or ACUTE depending on the angle formed by the two vectors u and v. Returns an approximation of the angle between u and v. The first vector. The second vector. The angle is given in degrees. Returns an approximation of the angle between p-q and r-q. The first tetrahedrons point. The second tetrahedrons point. The third tetrahedrons point. The angle is given in degrees. Returns an approximation of the angle between u and v. The first vector. The second vector. The angle is given in degrees. Returns an approximation of the angle between p-q and r-q. The first tetrahedrons point. The second tetrahedrons point. The third tetrahedrons point. The angle is given in degrees. Returns an approximation of the signed dihedral angle in the tetrahedron pqrs of edge pq. p,q,r and p,q,s are not collinear. The first tetrahedrons point. The second tetrahedrons point. The third tetrahedrons point. The fourth tetrahedrons point. The sign is negative if orientation(p,q,r,s) is CGAL::NEGATIVE and positive otherwise. The angle is given in degrees. Returns true, if the three points are collinear and q lies between p and r. Note that true is returned, if q==p or q==r. The first point. The second point. The third point. Returns true, if the three points are collinear and q lies between p and r. Returns true, if the three points are collinear and q lies between p and r. Note that true is returned, if q==p or q==r. The first point. The second point. The third point. Returns true, if the three points are collinear and q lies between p and r. Returns true, if the three points are collinear and q lies between p and r. Note that true is returned, if q==p or q==r. The first point. The second point. The third point. Returns true, if the three points are collinear and q lies between p and r. Returns true, if the three points are collinear and q lies between p and r. Note that true is returned, if q==p or q==r. The first point. The second point. The third point. Returns true, if the three points are collinear and q lies between p and r. returns true, if the three points are collinear and q lies strictly between p and r. Note that false is returned, if q==p or q==r. The first point. The second point. The third point. returns true, iff the three points are collinear and q lies strictly between p and r. returns true, if the three points are collinear and q lies strictly between p and r. Note that false is returned, if q==p or q==r. The first point. The second point. The third point. returns true, iff the three points are collinear and q lies strictly between p and r. returns true, if the three points are collinear and q lies strictly between p and r. Note that false is returned, if q==p or q==r. The first point. The second point. The third point. returns true, iff the three points are collinear and q lies strictly between p and r. returns true, if the three points are collinear and q lies strictly between p and r. Note that false is returned, if q==p or q==r. The first point. The second point. The third point. returns true, iff the three points are collinear and q lies strictly between p and r. Returns true, if p, q, and r are collinear The first point. The second point. The third point. returns true, if p, q, and r are collinear Returns true, if p, q, and r are collinear The first point. The second point. The third point. returns true, if p, q, and r are collinear Returns true, if p, q, and r are collinear The first point. The second point. The third point. returns true, if p, q, and r are collinear Returns true, if p, q, and r are collinear The first point. The second point. The third point. Returns true, iff p, q, and r are collinear Compute the barycenter of the points p1, p2 and p3 with corresponding weights w1, w2 and w3 as 1. The first point. The second point. The third point. Compute the barycenter of the points. Compute the barycenter of the points p1, p2 and p3 with corresponding weights w1, w2 and w3 as 1. The first point. The second point. The third point. Compute the barycenter of the points. Compute the barycenter of the points p1, p2 and p3 with corresponding weights w1, w2 and w3 as 1. The first point. The second point. The third point. Compute the barycenter of the points. Compute the barycenter of the points p1, p2 and p3 with corresponding weights w1, w2 and w3 as 1. The first point. The second point. The third point. Compute the barycenter of the points. Constructs the bisector line of the two points p and q. The bisector is oriented in such a way that p lies on its positive side. The first point. The second point. Constructs the bisector line of the two points p and q. Constructs the bisector of the two lines l1 and l2. In the general case, the bisector has the direction of the vector which is the sum of the normalized directions of the two lines, and which passes through the intersection of l1 and l2. If l1 and l2 are parallel, then the bisector is defined as the line which has the same direction as l1, and which is at the same distance from l1 and l2. If Kernel::FT is not a model of FieldWithSqrt an approximation of the square root will be used in this function, impacting the exactness of the result even with an (exact) multiprecision number type. The first line. The second line. Constructs the bisector of the two lines l1 and l2. Constructs the bisector of the two lines l1 and l2. In the general case, the bisector has the direction of the vector which is the sum of the normalized directions of the two lines, and which passes through the intersection of l1 and l2. If l1 and l2 are parallel, then the bisector is defined as the line which has the same direction as l1, and which is at the same distance from l1 and l2. If Kernel::FT is not a model of FieldWithSqrt an approximation of the square root will be used in this function, impacting the exactness of the result even with an (exact) multiprecision number type. The first line. The second line. Constructs the bisector of the two lines l1 and l2. Constructs the bisector of the two lines l1 and l2. In the general case, the bisector has the direction of the vector which is the sum of the normalized directions of the two lines, and which passes through the intersection of l1 and l2. If l1 and l2 are parallel, then the bisector is defined as the line which has the same direction as l1, and which is at the same distance from l1 and l2. If Kernel::FT is not a model of FieldWithSqrt an approximation of the square root will be used in this function, impacting the exactness of the result even with an (exact) multiprecision number type. The first line. The second line. Constructs the bisector of the two lines l1 and l2. Returns true, if p, q, r, and s are coplanar. The first point. The second point. The third point. The fourth point Returns true, if p, q, r, and s are coplanar. If p,q,r are collinear, then CGAL_COLLINEAR is returned. If not, then p,q,r define a plane p. The return value in this case is either CGAL_POSITIVE or CGAL_NEGATIVE, but we don't specify it explicitly. However, we guarantee that all calls to this predicate over 3 points in p will return a coherent orientation if considered a 2D orientation in p The first point. The second point. The third point. If p,q,r are collinear, then CGAL_COLLINEAR is returned. Let P be the plane defined by the points p, q, and r. Note that the order defines the orientation of P. The function computes the orientation of points p, q, and s in P: If p, q, s are collinear, CGAL_COLLINEAR is returned. If P and the plane defined by p, q, and s have the same orientation, CGAL_POSITIVE is returned; otherwise CGAL_NEGATIVE is returned. p, q, r, and s are coplanar and p, q, and r are not collinear. The first point. The second point. The third point. The fourth point Constructs the line which is at the same distance from the three points p, q and r. p, q and r are not collinear. Constructs the line which is at the same distance from the three points p, q and r. Returns true if p, q, and r form a left turn. The first point. The second point. The third point. Returns true if p, q, and r form a left turn. Returns true if p, q, and r form a left turn. The first point. The second point. The third point. Returns true if p, q, and r form a left turn. Returns true if p, q, and r form a left turn. The first point. The second point. The third point. Returns true if p, q, and r form a left turn. Returns true if p, q, and r form a right turn. The first point. The second point. The third point. Returns true if p, q, and r form a right turn. Returns true if p, q, and r form a right turn. The first point. The second point. The third point. Returns true if p, q, and r form a right turn. Returns true if p, q, and r form a right turn. The first point. The second point. The third point. Returns true if p, q, and r form a right turn. Returns LEFT_TURN, if r lies to the left of the oriented line l defined by p and q, returns RIGHT_TURN if r lies to the right of l, and returns COLLINEAR if r lies on l. The first point. The second point. The third point. Returns LEFT_TURN, if r lies to the left of the oriented line l defined by p and q, returns RIGHT_TURN if r lies to the right of l, and returns COLLINEAR if r lies on l. The first point. The second point. The third point. Returns LEFT_TURN, if r lies to the left of the oriented line l defined by p and q, returns RIGHT_TURN if r lies to the right of l, and returns COLLINEAR if r lies on l. The first point. The second point. The third point. returns LEFT_TURN if u and v form a left turn, returns RIGHT_TURN if u and v form a right turn, and returns COLLINEAR if u and v are collinear. Returns LEFT_TURN, if r lies to the left of the oriented line l defined by p and q, returns RIGHT_TURN if r lies to the right of l, and returns COLLINEAR if r lies on l. The first point. The second point. Returns LEFT_TURN, if r lies to the left of the oriented line l defined by p and q, returns RIGHT_TURN if r lies to the right of l, and returns COLLINEAR if r lies on l. The first point. The second point. returns POSITIVE, if s lies on the positive side of the oriented plane h defined by p, q, and r, returns NEGATIVE if s lies on the negative side of h, and returns COPLANAR if s lies on h. The first point. The second point. The third point. The fourth point returns NEGATIVE if u, v and w are negatively oriented, POSITIVE if u, v and w are positively oriented, and COPLANAR if u, v and w are coplanar. computes an orthogonal vector of the plane defined by p, q and r, which is directed to the positive side of this plane. The first point. The second point. The third point. computes an orthogonal vector of the plane returns true, if l1 and l2 are parallel or if one of those (or both) is degenerate. The first line. The seconed line. returns true, if l1 and l2 are parallel returns true, if l1 and l2 are parallel or if one of those (or both) is degenerate. The first line. The seconed line. returns true, if l1 and l2 are parallel returns true, if l1 and l2 are parallel or if one of those (or both) is degenerate. The first line. The seconed line. returns true, if l1 and l2 are parallel returns true, if r1 and r2 are parallel or if one of those (or both) is degenerate. The first ray. The second ray. returns true, if r1 and r2 are parallel returns true, if r1 and r2 are parallel or if one of those (or both) is degenerate. The first ray. The second ray. returns true, if r1 and r2 are parallel returns true, if r1 and r2 are parallel or if one of those (or both) is degenerate. The first ray. The second ray. returns true, if r1 and r2 are parallel returns true, if s1 and s2 are parallel or if one of those (or both) is degenerate. The first segment. The secong segment. returns true, if s1 and s2 are parallel returns true, if s1 and s2 are parallel or if one of those (or both) is degenerate. The first segment. The secong segment. returns true, if s1 and s2 are parallel returns true, if s1 and s2 are parallel or if one of those (or both) is degenerate. The first segment. The secong segment. returns true, if s1 and s2 are parallel Base class for objects that referrence a CGAL object. The pointer to the unmanged CGAL object. Default constructor. Constructor taking a referrence to a CGAL object. A pointer to a CGAL object. The destuctor. Has the object been disposed. Get the ptr to the CGAL object. Dispose the CGAL object. Print some information about the object. Print some information about the object. Print the object into the console. Print the object into a string builder. The builder to print into. Release the CGAL object. Swap the unmanaged pointer with another. The old ptr will be released first. The new ptr. The old ptr will be released first. Allow derived class to release the unmanaged memory. Allow derived class to release the unmanaged memory. Check if the object is still valid. enum for egien solvers. Create a new matrix filled with zeros. The number of rows. The number of columns. Create a new matrix fill with the array contents. The array. Create a new matrix filled with the contents of the column vectors. All column vectors must have the same dimension. Create a 2 x 2 matrix. Create a 3 x 3 matrix. Create a 4 x 4 matrix. Create a new matrix from a pointer. Create a identity matrix. The number of rows and columns of the matrix. Must be square. The identity matrix. Create a matrix filled with the numbers 1, 2. 3, etc to end. Used for debugging. The number of rows. The number columns. The Matrix. Create a new matrix fill with random numbers. The number of rows. The number columns. The minimum random number generated. The maximum random number generated. The random generators seed. The matrix. The number of rows in the matrix. The number of columns in the matrix. The total size of the matrix which is the rows times the number of columns. The single dimension array accessor. The array index. The value at the index i. The double dimension array accessor. The row index. The column index. The value at the index i,j. The matrix string info. The matrix string info. The matrix transposed. Flips a matrix over its diagonal that is, it switches the row and column indices of the matrix. The matrices conjugate. The matrix obtained by replacing each element a(ij) with its complex conjugate, A^=(a^(ij)). The matrices adjoint. The transpose of its cofactor matrix. Is the matrix invertible. The inverse of a square matrix A, sometimes called a reciprocal matrix, is a matrix A^(-1) such that AA^(-1)=I. DOes not check if the matrix is invertible. The determinant is a scalar value that is a function of the entries of a square matrix. The trace of a square matrix is defined to be the sum of elements on the main diagonal from the upper left to the lower right. A square matrix has the same number of rows and columns. A diagonal matrix is a matrix in which the entries outside the main diagonal are all zero. A square matrix is called upper triangular if all the entries below the main diagonal are zero. A square matrix is called lower triangular if all the entries above the main diagonal are zero. Multiple each component in matrix by the scalar. The matrix. The scalar. The matrix with each component multiplied by the scalar. Divide each component in matrix by the scalar. The matrix. The scalar. The matrix with each component divided by the scalar. Multiple the two matrices. The first matrices number of columns must the same as the second matrices number of rows. The first matrix. The second matrix. The product matrix. Add two matrices. The matrices must be the same size. The first matrix. The second matrix. A matrix where each compoent is the sum of the other two matrices. Subtract two matrices. The matrices must be the same size. The first matrix. The second matrix. A matrix where each compoent is the difference of the other two matrices. Multiple a matrix and a column vector. The matrix. The column vector. The product column vector. Is this matrix the identity matrix. The threshold the values in the matrix can be to the expected value. Is this matrix the identity matrix. Is this matrix filled with zeros. The threshold the values in the matrix can be to the expected value. Is this matrix filled with zeros. Are all the values in this matrix positive. Are all the values in this matrix positive. Does the matrix have a component that is nan. Does the matrix have a component that is nan. Replaces all nan values in the matrix with 0. Are all the values in the matrix finite (non-infinite and non-nan). Are all the values in the matrix finite (non-infinite and non-nan). Replaces all infinite and nan values in matrix with 0. Are all the values in the matrix the same. The threshold the values in the matrix can be to the expected value. Are all the values in the matrix the same. Create a sub matrix from this matrix. The row to start at. THe column to start at. The number of rows. The number of columns. A sub matrix from this matrix. Create a sub matrix from this matrix. The number of rows. The number of columns. A sub matrix from this matrix. Solve the linear system. The vector to solve. The solver type. The solution vector. Solve the linear system. The vector to solve. The solver type. The solution vector. Find the relative error from the linear system. The vector that was solved. The vector that was the solution. The relative error. Find the relative error from the linear system. The vector that was solved. The vector that was the solution. The relative error. Find the eigen values of the matrix. The eigen values if found, null otherwise. True if the values could be determined. Find the eigen vectors of the matrix. The eigen vectors if found, null otherwise. True if the vectors could be determined. Try and find the inverse of the matrix. The inverse if found, null otherwise. True if the inverse was found. Create a rotation from a angle and the rotation axis. The rotation amount. The axis to rotate on. The rotation matrix. / The first value in the vector. The second value in the vector. The third value in the vector. The fourth value in the vector. The generic Box wrapper for a CGAL object. The kernel type. Create box from min and max values. The min x and y value. The max x and y value. Create box from min and max points. The min point. The max point. Create from a pointer. The iso rectangle pointer. The type of kernel object uses. The iso rectangle as a string. The iso rectangle as a string. Translate the shape. The amount to translate. Rotate the shape. The amount to rotate. Scale the shape. The amount to scale. Transform the rectangle. The amount to translate. The amount to rotate The amount to scale. Create a deep copy of the rectangle. The deep copy. The abstract iso rectangle definition. Default constructor. Construct with a new kernel. The geometry kernel. The Box pointer. The iso rectangle kernel. Contains the functions to the unmanaged CGAL object. Convert to shape struct. The rectangles min point. The rectangles max point. The rectangles area. Is the rectangle degenerate. The side the rectangle the point is on. The point. If the point is iside, outside or on boundary. Does the rectangle contain the point. The point Should a point on the boundary count as being inside. Does the rectangle contain the point Release the unmanaged pointer. Round the shape. The number of digits to round to. Convert to another kernel. Must provide a different kernel to convert to or just a deep copy will be returned. The shape with another kernel type. The static intersection class. The static intersection class. The static intersection class. -------------------------------------------------------- The Point DoIntersect functions -------------------------------------------------------- -------------------------------------------------------- The Line DoIntersect functions -------------------------------------------------------- -------------------------------------------------------- The Ray DoIntersect functions -------------------------------------------------------- -------------------------------------------------------- The Segment DoIntersect functions -------------------------------------------------------- -------------------------------------------------------- The Triangle DoIntersect functions -------------------------------------------------------- -------------------------------------------------------- The Box DoIntersect functions -------------------------------------------------------- -------------------------------------------------------- The Point Intersection functions -------------------------------------------------------- -------------------------------------------------------- The Line Intersection functions ----------------------------------------------------- -------------------------------------------------------- The Ray Intersection functions ----------------------------------------------------- -------------------------------------------------------- The Segment Intersection functions ----------------------------------------------------- -------------------------------------------------------- The Triangle Intersection functions ----------------------------------------------------- -------------------------------------------------------- The Box Intersection functions ----------------------------------------------------- -------------------------------------------------------- The Point SqrDistance functions ----------------------------------------------------- -------------------------------------------------------- The Line SqrDistance functions -------------------------------------------------------- -------------------------------------------------------- The Ray SqrDistance functions -------------------------------------------------------- -------------------------------------------------------- The Segment SqrDistance functions ----------------------------------------------------- -------------------------------------------------------- The Triangle SqrDistance functions ----------------------------------------------------- -------------------------------------------------------- The Point DoIntersect extern functions ------------------------------------------------------ -------------------------------------------------------- The Linet DoIntersect extern functions ------------------------------------------------------ -------------------------------------------------------- The Ray DoIntersect extern functions ------------------------------------------------------ -------------------------------------------------------- The Segment DoIntersect extern functions ------------------------------------------------------ -------------------------------------------------------- The Triangle DoIntersect extern functions ------------------------------------------------------ -------------------------------------------------------- The Box DoIntersect extern functions ------------------------------------------------------ -------------------------------------------------------- The Point Intersection extern functions ------------------------------------------------------- -------------------------------------------------------- The Line Intersection extern functions ------------------------------------------------------- -------------------------------------------------------- The Ray Intersection extern functions ------------------------------------------------------- -------------------------------------------------------- The Segment Intersection extern functions ------------------------------------------------------- -------------------------------------------------------- The Triangle Intersection extern functions ------------------------------------------------------- -------------------------------------------------------- The Box Intersection extern functions ------------------------------------------------------- -------------------------------------------------------- The Point SqrDistance extern functions ------------------------------------------------------- -------------------------------------------------------- The Line SqrDistance extern functions ------------------------------------------------------ -------------------------------------------------------- The Ray SqrDistance extern functions ------------------------------------------------------ -------------------------------------------------------- The Segment SqrDistance extern functions ------------------------------------------------------ -------------------------------------------------------- The Triangle SqrDistance extern functions ------------------------------------------------------ -------------------------------------------------------- The Point DoIntersect functions -------------------------------------------------------- -------------------------------------------------------- The Line DoIntersect functions -------------------------------------------------------- -------------------------------------------------------- The Ray DoIntersect functions -------------------------------------------------------- -------------------------------------------------------- The Segment DoIntersect functions -------------------------------------------------------- -------------------------------------------------------- The Triangle DoIntersect functions -------------------------------------------------------- -------------------------------------------------------- The Box DoIntersect functions -------------------------------------------------------- -------------------------------------------------------- The Point Intersection functions -------------------------------------------------------- -------------------------------------------------------- The Line Intersection functions ----------------------------------------------------- -------------------------------------------------------- The Ray Intersection functions ----------------------------------------------------- -------------------------------------------------------- The Segment Intersection functions ----------------------------------------------------- -------------------------------------------------------- The Triangle Intersection functions ----------------------------------------------------- -------------------------------------------------------- The Box Intersection functions ----------------------------------------------------- -------------------------------------------------------- The Point SqrDistance functions ----------------------------------------------------- -------------------------------------------------------- The Line SqrDistance functions -------------------------------------------------------- -------------------------------------------------------- The Ray SqrDistance functions -------------------------------------------------------- -------------------------------------------------------- The Segment SqrDistance functions ----------------------------------------------------- -------------------------------------------------------- The Triangle SqrDistance functions ----------------------------------------------------- -------------------------------------------------------- The Point DoIntersect extern functions ------------------------------------------------------ -------------------------------------------------------- The Linet DoIntersect extern functions ------------------------------------------------------ -------------------------------------------------------- The Ray DoIntersect extern functions ------------------------------------------------------ -------------------------------------------------------- The Segment DoIntersect extern functions ------------------------------------------------------ -------------------------------------------------------- The Triangle DoIntersect extern functions ------------------------------------------------------ -------------------------------------------------------- The Box DoIntersect extern functions ------------------------------------------------------ -------------------------------------------------------- The Point Intersection extern functions ------------------------------------------------------- -------------------------------------------------------- The Line Intersection extern functions ------------------------------------------------------- -------------------------------------------------------- The Ray Intersection extern functions ------------------------------------------------------- -------------------------------------------------------- The Segment Intersection extern functions ------------------------------------------------------- -------------------------------------------------------- The Triangle Intersection extern functions ------------------------------------------------------- -------------------------------------------------------- The Box Intersection extern functions ------------------------------------------------------- -------------------------------------------------------- The Point SqrDistance extern functions ------------------------------------------------------- -------------------------------------------------------- The Line SqrDistance extern functions ------------------------------------------------------ -------------------------------------------------------- The Ray SqrDistance extern functions ------------------------------------------------------ -------------------------------------------------------- The Segment SqrDistance extern functions ------------------------------------------------------ -------------------------------------------------------- The Triangle SqrDistance extern functions ------------------------------------------------------ -------------------------------------------------------- The Point DoIntersect functions -------------------------------------------------------- -------------------------------------------------------- The Line DoIntersect functions -------------------------------------------------------- -------------------------------------------------------- The Ray DoIntersect functions -------------------------------------------------------- -------------------------------------------------------- The Segment DoIntersect functions -------------------------------------------------------- -------------------------------------------------------- The Triangle DoIntersect functions -------------------------------------------------------- -------------------------------------------------------- The Box DoIntersect functions -------------------------------------------------------- -------------------------------------------------------- The Point Intersection functions -------------------------------------------------------- -------------------------------------------------------- The Line Intersection functions ----------------------------------------------------- -------------------------------------------------------- The Ray Intersection functions ----------------------------------------------------- -------------------------------------------------------- The Segment Intersection functions ----------------------------------------------------- -------------------------------------------------------- The Triangle Intersection functions ----------------------------------------------------- -------------------------------------------------------- The Box Intersection functions ----------------------------------------------------- -------------------------------------------------------- The Point SqrDistance functions ----------------------------------------------------- -------------------------------------------------------- The Line SqrDistance functions -------------------------------------------------------- -------------------------------------------------------- The Ray SqrDistance functions -------------------------------------------------------- -------------------------------------------------------- The Segment SqrDistance functions ----------------------------------------------------- -------------------------------------------------------- The Triangle SqrDistance functions ----------------------------------------------------- -------------------------------------------------------- The Point DoIntersect extern functions ------------------------------------------------------ -------------------------------------------------------- The Linet DoIntersect extern functions ------------------------------------------------------ -------------------------------------------------------- The Ray DoIntersect extern functions ------------------------------------------------------ -------------------------------------------------------- The Segment DoIntersect extern functions ------------------------------------------------------ -------------------------------------------------------- The Triangle DoIntersect extern functions ------------------------------------------------------ -------------------------------------------------------- The Box DoIntersect extern functions ------------------------------------------------------ -------------------------------------------------------- The Point Intersection extern functions ------------------------------------------------------- -------------------------------------------------------- The Line Intersection extern functions ------------------------------------------------------- -------------------------------------------------------- The Ray Intersection extern functions ------------------------------------------------------- -------------------------------------------------------- The Segment Intersection extern functions ------------------------------------------------------- -------------------------------------------------------- The Triangle Intersection extern functions ------------------------------------------------------- -------------------------------------------------------- The Box Intersection extern functions ------------------------------------------------------- -------------------------------------------------------- The Point SqrDistance extern functions ------------------------------------------------------- -------------------------------------------------------- The Line SqrDistance extern functions ------------------------------------------------------ -------------------------------------------------------- The Ray SqrDistance extern functions ------------------------------------------------------ -------------------------------------------------------- The Segment SqrDistance extern functions ------------------------------------------------------ -------------------------------------------------------- The Triangle SqrDistance extern functions ------------------------------------------------------ -------------------------------------------------------- The Point2 Class Functions ------------------------------------------------------- -------------------------------------------------------- The Vector2 Class Functions ------------------------------------------------------- -------------------------------------------------------- The HPoint2 Class Functions ------------------------------------------------------- -------------------------------------------------------- The Line2 Class Functions ------------------------------------------------------- -------------------------------------------------------- The Ray2 Class Functions ------------------------------------------------------- -------------------------------------------------------- The Segment2 Class Functions ------------------------------------------------------- -------------------------------------------------------- The Triangle2 Class Functions ------------------------------------------------------- -------------------------------------------------------- The Box2 Class Functions ------------------------------------------------------- -------------------------------------------------------- The Point2 Class Functions ------------------------------------------------------- -------------------------------------------------------- The Vector2 Class Functions ------------------------------------------------------- -------------------------------------------------------- The HPoint2 Class Functions ------------------------------------------------------- -------------------------------------------------------- The Line2 Class Functions ------------------------------------------------------- -------------------------------------------------------- The Ray2 Class Functions ------------------------------------------------------- -------------------------------------------------------- The Segment Class Functions ------------------------------------------------------- -------------------------------------------------------- The Triangle2 Class Functions ------------------------------------------------------- -------------------------------------------------------- The IsoRectancle2 Class Functions ------------------------------------------------------- -------------------------------------------------------- The Point2 extern functions ------------------------------------------------------- -------------------------------------------------------- The Vector2 extern functions ------------------------------------------------------- -------------------------------------------------------- The HPoint2 extern functions ------------------------------------------------------- -------------------------------------------------------- The Line2 extern functions ------------------------------------------------------- -------------------------------------------------------- The Ray2 extern functions ------------------------------------------------------- -------------------------------------------------------- The Segment2 extern functions ------------------------------------------------------- -------------------------------------------------------- The Triangle2 extern functions ------------------------------------------------------- -------------------------------------------------------- The Box2 extern functions ------------------------------------------------------- -------------------------------------------------------- The Point2 Class Functions ------------------------------------------------------- -------------------------------------------------------- The Vector2 Class Functions ------------------------------------------------------- -------------------------------------------------------- The HPoint2 Class Functions ------------------------------------------------------- -------------------------------------------------------- The Line2 Class Functions ------------------------------------------------------- -------------------------------------------------------- The Ray2 Class Functions ------------------------------------------------------- -------------------------------------------------------- The Segment Class Functions ------------------------------------------------------- -------------------------------------------------------- The Triangle2 Class Functions ------------------------------------------------------- -------------------------------------------------------- The IsoRectancle2 Class Functions ------------------------------------------------------- -------------------------------------------------------- The Point2 extern functions ------------------------------------------------------- -------------------------------------------------------- The Vector2 extern functions ------------------------------------------------------- -------------------------------------------------------- The HPoint2 extern functions ------------------------------------------------------- -------------------------------------------------------- The Line2 extern functions ------------------------------------------------------- -------------------------------------------------------- The Ray2 extern functions ------------------------------------------------------- -------------------------------------------------------- The Segment2 extern functions ------------------------------------------------------- -------------------------------------------------------- The Triangle2 extern functions ------------------------------------------------------- -------------------------------------------------------- The Box2 extern functions ------------------------------------------------------- Weighted point class Create a new weighted point. Create a new weighted point from a value and weight as 1. The points value. Create a new weighted point from a x, y value and weight as 1. The points x value. The points y value. Create a new weighted point from a x, y value and weight as the w value. The points x value. The points y value. The points weight value. Create a new weighted point from a pointer. The pointer. The type of kernel object uses. Create a deep copy of the point. The deep copy. Create a new weighted point. The points kernel. Create a new weighted point from a x, y value and weight as the w value. The points x value. The points y value. The points weight value. The points kernel. Create a new weighted point from a existing ponter and kernel. The points kernel. The points pointer The points kernel. Release the pointer. Release the pointer. The pointer to release. Accessor or the points x value. ccessor or the points y value. Round the point. The number of digits to round to. Clamp the point. The points min value. The points max value. Clamp the point. Convert to another kernel. Must provide a different kernel to convert to or just a deep copy will be returned. The shape with another kernel type. Enum for the type of intersection geomerty. The intersection result struct. May contain up tp 6 points of data. The point data for the intersection. Represents up to 6 points in xy order. The number of points of data used. Was there a intersection. Is the intersection a polygon. The intersection geometry type. Array accessor for the point data. The array index from 0 to 6. The point at index i. Results information as string. esults information as string If result type was point get the point geometry. If result type was line get the line geometry. If result type was ray get the ray geometry. If result type was segment get the segment geometry. If result type was box get the box geometry. If result type was triangle get the triangle geometry. If result type was polygon get the points that make up the polygon geometry. Should only ever have at most 6 points. The intersection result as a polygon. The polygons kernel. The polygon. A CGALObject that represents a line on 2D space. A horizontal line on the x axis. A vertical line on the y axis. Create a new line where ax + by + c = 0 holds. The constant in ax. The constant in by. The constant. Create a new line that passes through the two points. The first point. The second point. Create a line that passes through the point in the direction of the vector. The point. The vector. Create a line from a existing pointer. The pointer. Create a new line that faces in the opposite direction. Create a new line that is perpendicular to current line. A point the line should turn ccw when turning. The perpendicular line. Translate the object. The amount to translate. Rotate the object. The amount to rotate. Scale the object. The amount to scale. Translate, rotate and scale the object. The amount to translate. The amount to rotate in degrees. The amount to scale. Create a deep copy of the line. The deep copy. The abstract class for the line object. The lines kernel. Convert to shape struct. The lines constant in ax. The lines constant in by. The lines constant. Is the line degenerate. Is the line horizontal on the x axis. Is the line vertical on the y axis. Convert the line to a vector. Does the point lie on the line. The point. True if the point lies on the line. Does the point lies on the negative/cw side of the line. The point. True if the point lies on the negative/cw side of the line. Does the point lies on the positive/ccw side of the line. The point. True if the point lies on the positive/ccw side of the line. The lines x value given a y value. The y value. The lines x value given a y value. The lines y value given a x value. The x value. The lines y value given a x value. Release the unmanaged pointer. Round the shape. The number of digits to round to. Convert to another kernel. Must provide a different kernel to convert to or just a deep copy will be returned. The shape with another kernel type. The unit x point. The unit y point. A point of zeros. A point of ones. A point of halfs. The type of kernel object uses. Round the point. The number of digits to round to. Clamp the point. The points min value. The points max value. Clamp the point. Convert to another kernel. Must provide a different kernel to convert to or just a deep copy will be returned. The shape with another kernel type. The unit x ray. The unit y ray. Translate the shape. The amount to translate. Rotate the shape. The amount to rotate. Scale the shape. The amount to scale. Convert to shape struct. Round the shape. The number of digits to round to. Convert to another kernel. Must provide a different kernel to convert to or just a deep copy will be returned. The shape with another kernel type. A horizontal line on the x axis. A vertical line on the y axis. Translate the shape. The amount to translate. Rotate the shape. The amount to rotate. Scale the shape. The amount to scale. Convert to shape struct. Round the shape. The number of digits to round to. Convert to another kernel. Must provide a different kernel to convert to or just a deep copy will be returned. The shape with another kernel type. Translate the shape. The amount to translate. Rotate the shape. The amount to rotate. Scale the shape. The amount to scale. Convert to shape struct. Round the shape. The number of digits to round to. Convert to another kernel. Must provide a different kernel to convert to or just a deep copy will be returned. The shape with another kernel type. A Vector2 object with kernel type K. The type of kernel. The unit x vector. The unit y vector. A vector of zeros. A vector of ones. Create a new Vector. Create a new vector filled with the value. The value to fill. Create a new vector with the values x and y. The vectors x value. The vectors y value. Create a new vector from a existing pointer. The pointer object. The type of kernel object uses. Vector information. The vectors string information. Create a deep copy of the vector. The deep copy. The vectors abstract bass class. Create a new vector with the kernel. The vectors kernel. Create a new vector from the x and y values. The vectors x value. The vectors y value. The vectors kernel. Create a new vector from a existing pointer. The vectors kernel. The existing pointer. The vectors kernel. The vectors sqr magnitude. The vectors sqr magnitude. Access the x component. Access the y component. Release the vectors pointer. Release a pointer to a vector. The pointer to release. Round the vector. The number of digits to round to. Clamp the vector. The vectors min value. The vectors max value. Clamp the vector. Normalize the vector. Convert to another kernel. Must provide a different kernel to convert to or just a deep copy will be returned. The shape with another kernel type. The convex hull method to use. The generic convex hull class. The kernel type The static instance. Default constructor. Find the convex of the points. The point array. The ararys length. The hull ethod to use. A polygon that represents the convex hull. Find the upper hull of points. The point array. The ararys length. A polygon that represents the upper hull. Find the lower hull of points. The point array. The ararys length. A polygon that represents the lower hull. The convex hull abstract base class. Default constructor. Construct hull with the kernel. The kernel The hulls kernel type. Is this set of points ccw orderer. The point array. The ararys length. Is this set of points ccw orderer. Is this set of points cw orderer. The point array. The ararys length. Is this set of points cw orderer. Checks if the minimum number of points have been provided. The point array length. Release any unmanaged resources. The generic convex hull class. The kernel type The static instance. Default constructor. Create the convex hull from a set of points. The point array. The point arrays length The hull as a polyhedron. Create the convex hull from a set of points. The point array. The point arrays length The hull as a surface mesh. The convex hull abstract base class. Default constructor. Construct hull with the kernel. The kernel The hulls kernel type. Check if the points in the polyhedron are convex. The polyhedron. True if the polyhedron is convex. Check if the points in the mesh are convex. The mesh. True if the mesh is convex. Checks if the minimum number of points have been provided. The point array length. Release any unmanaged resources. A static instance of the triangulation. The triangulation as a string. Insert the polygons points into the triangulation. May not retain the poylgons edges. Insert the polygons points into the triangulation. May not retain the poylgons edges. Insert the polygons points and the edges as constraints into the triangulation. Will retain the poylgons edges. The polygon to insert. Insert the polygons points and the edges as constraints into the triangulation. Will retain the poylgons edges. The polygon to insert. A deep copy of the triangulation. The deep copy. The max value the angle bounds can be. The number of verices in the triangulation. The number of triangles in the triangulation. The number of indices need to represent the triangulation (number of triangles * 3). The conforming triangulation kernel. Clear the triangulation. Translate the triangulation. The amount to translate. Rotate the triangulation. The amount to rotate in radians. Scale the triangulation. The amount to scale. Transform the triangulation with a TRS matrix. The amount to translate. The amount to rotate. The amount to scale. Make the mesh delaunay. Make the mesh Refine the mesh into smaller triangles. Default shape bound. 0.125 corresponds to abound 20.6 degree. Max 0.125 value. Upper bound on the length of the longest edge. Refine the mesh into smaller triangles. Default shape bound. 0.125 corresponds to abound 20.6 degree. Max 0.125 value. Upper bound on the length of the longest edge. Seeds point in polygons that are not to be refined. Release any unmanaged resources. Release any unmanaged resources. A static instance of the tetrahedral remeshing. The tetrahedral remeshing kernel. Release any unmanaged resources. Generic polygon definition. The kernel type. Default constructor. Create from a set of points. The polygons points. Create from a pointer. The polygons pointer. The polygon as a string. The polygon as a string. Copy the polygon. The copied polygon. Triangulate the polygon. The triangle indices. Do the polygons intersect. The other polygon. Do the polygons intersect. Do the polygons intersect. The other polygon. Do the polygons intersect. Do the polygons intersect. The other polygon. The intersection results. Do the polygons intersect. Do the polygons intersect. The other polygon. The intersection results. Do the polygons intersect. Refine the polygon to a triangulation. Does not modify this polygon. Upper bound on the length of the longest edge. The base triangulation. Refine the polygon to a triangulation. Does not modify this polygon. Default shape bound. 0.125 corresponds to abound 20.6 degree. Max 0.125 value. Upper bound on the length of the longest edge. The base triangulation. Partition the polygon into convex pieces. Does not modify this polygon. The convex partition. The type of partition method. Simplify the polygon. The simplification threshold. Simplify the polygon. The simplification parameters. offset the polygon. Does not modify this polygon. The type of offset. The amount to offset. The offset results. Create a polyhedron3 mesh with one polygon face. Should the y coord of the points be used for the z coord. The new polyhedron mesh Thrown if the polygon is not simple. Get the dual polygon where every point s now a edge. The dual polygon. The abstract polygon definition. Is the polygon simple. Must be updated to find if simple. The polygons orientation. Must be updated to find orientation. Default constructor. Construct with a new kernel. The polygon kernel. Construct with a new kernel. The polygon kernel. The points to construct from. Construct with a new kernel. The polygon kernel. The polygons pointer. The number of points in the polygon. The capacity of the point array. Is this a simple polygon. Certains actions can only be carried out on simple polygons. The polygons orientation. Certain actions depend on the polygons orientation. The orientation expressed as the clock direction. Is the polygon degenerate. Polygons with less than 3 points are degenerate. Is the polygon cw orientated. Is the polygon ccw orientated. Is the polygon updated. The polygons kernel. Contains the functions to the unmanaged CGAL polygon. The type of kernel object uses. Array accessor for the polygon. Getting a point wraps around the polygon. Mark th mesh as needing to be updated. Valid polygons should be simple and ccw for most algorithms to work on them. Valid hole polygons should be simple and cw to add to a polygon with holes. Clear the polygon of all points. Shrink the capacity to match the point count. Resize the point array. New elements will default to zero. Remove the point at the index from the array. The points index Remove a range of points from the array. The starting index The number of points to remove. Insert the point at the index into the array. The points index. The point to insert. Insert a range of points into the array. The starting index The points to insert. The number of points to insert. Add the point to the end of the poylgon. The point to add. Get the point a the index. The points index to get. The point at index. Get the point at the index and wrap around the polygon. The points index. The point at the index. Get the point at the index and clamp to the polygons last point. The points index. The point at the index. Get all the points in the polygon. The point array to copy the data into. The array length. Get all the polygon points. The list to copy the data into. Triangulate the polygon. The triangle indices. Get all the polygon segments. The segment array to copy the data into. The array length. Set the points at the index. The points index. The points value. Set the points from the array. If the array is larger than the polygon then the new points will be appended to end of polygon. The points array. The array length. Reverse the polygon. Swithches the orientation. Find the bounding box for the polygon. The bounding box. Find if the polygon is simple. True if simple. Find if the polygon is convex. Must be simple to determine. True if the polygon is convex. Find the polygons orientation. Must be simple to determine. The polygons orientations. Find the orientated side the point lies on. Must be simple to determine. The point. The orientated side of the polygon the point is on. Find the bounded side the point lies on. Must be simple to determine. The point. The bounded side of the polygon the point is on. Find the polygons signed area. Must be simple to determine. The signed area is positive if polygon is ccw and negation if cw. The area of the polygon. Must be simple to determine. The abs of the signed area. Find the perimeter. This is the length of the polygon boundary. Find the square perimeter. This is the square length of the polygon boundary. Does the polygon contain the points. Must be simple to determine. The point to find. Does the point on the boundary count True if the point is inside the polygon. Round each point it polygon to a number of digits. The number of digits to round to. Translate the polygon. The amount to translate. Rotate the polygon. The amount to rotate in radians. Scale the polygon. The amount to scale. Transform the polygon with a TRS matrix. The amount to translate. The amount to rotate. The amount to scale. Enumerate all points in the polygon. Each point in polygon. Enumerate all points in the polygon. Each point in polygon. Return all the points in the polygon in a array. The array. Get all the points in the polygon into a list. Convert the polygon to a new polygon with a different kernel. May result in different values due to precision issues. The new kernel type. The new polygon. Truncate a point in the polygon by splitting the point and shifting toward its neghbours. The points index in mesh. The amount to truncale. Print the polygon into a styring builder. Release the unmanaged pointer. Release the unmanaged pointer. Update the polygon if needed. Update the polygon directly without calling the update function. Is the polygon simepl. The polygons orientation. Should the input polygon be checked. Can disable for better performance if it is know all input if valid. Check if the polygon is valid to offset. Should be simple and ccw. The polygon to check. Check if the polygon is valid to offset. Should be simple and ccw. The polygon to check. The type of boolean ops. Generic polygon boolean class. The type of kernel A static instance to the boolean class. Create a new object. Perform the boolean op on the two polygons. The type of op. A simple ccw polygon. A simple ccw polygon. The result of the op. If the op was performed and the result list changed. Perform the boolean op on the two polygons. The type of op. A simple ccw polygon. A simple ccw polygon. The result of the op. If the op was performed and the result list changed. Perform the boolean op on the two polygons. The type of op. A simple ccw polygon. A simple ccw polygon. The result of the op. If the op was performed and the result list changed. Check if the polygons intesect. A simple ccw polygon. A simple ccw polygon. If the polygons intesect. Check if the polygons intesect. A simple ccw polygon. A simple ccw polygon. If the polygons intesect. Check if the polygons intesect. A simple ccw polygon. A simple ccw polygon. If the polygons intesect. The union of the two polygons. A simple ccw polygon. A simple ccw polygon. The union of the polygons. If the op was performed and the result list changed. The union of the two polygons. A simple ccw polygon. A simple ccw polygon. The union of the polygons. If the op was performed and the result list changed. The union of the two polygons. A simple ccw polygon. A simple ccw polygon. The union of the polygons. If the op was performed and the result list changed. The intersection of the two polygons. A simple ccw polygon. A simple ccw polygon. The intersection of the polygons. If the op was performed and the result list changed. The intersection of the two polygons. A simple ccw polygon. A simple ccw polygon. The intersection of the polygons. If the op was performed and the result list changed. The intersection of the two polygons. A simple ccw polygon. A simple ccw polygon. The intersection of the polygons. If the op was performed and the result list changed. The difference of the two polygons. A simple ccw polygon. A simple ccw polygon. The difference of the polygons. If the op was performed and the result list changed. The difference of the two polygons. A simple ccw polygon. A simple ccw polygon. The difference of the polygons. If the op was performed and the result list changed. The difference of the two polygons. A simple ccw polygon. A simple ccw polygon. The difference of the polygons. If the op was performed and the result list changed. The symmetric difference of the two polygons. A simple ccw polygon. A simple ccw polygon. The symmetric difference of the polygons. If the op was performed and the result list changed. The symmetric difference of the two polygons. A simple ccw polygon. A simple ccw polygon. The symmetric difference of the polygons. If the op was performed and the result list changed. The symmetric difference of the two polygons. A simple ccw polygon. A simple ccw polygon. The symmetric difference of the polygons. If the op was performed and the result list changed. The complement of the polygon. A simple ccw polygon. The complement of the polygon. Copy the unmanaged polygon objects created into the result list. The number of objects in the buffer. The result lis. Copy the unmanaged polygon object. The index of the polygon in the buffer. The polygon copy. Abstract base class for polygon boolean. The polygon boolean kernel. Clear the unmanaged buffer. Release the unmanaged resourses. Factory for creating polygons. The kernel type. Create a empty polygon. Create a polygon from a triangle. The triangle first point. The triangle second point. The triangle third point. True for a counter clock wise polygon, false for a clock wise polygon The created polygon. Create a polygon from a triangle. The triangle. True for a counter clock wise polygon, false for a clock wise polygon The created polygon. Create a polygon from a box. The boxs min point. The boxs max point. True for a counter clock wise polygon, false for a clock wise polygon The created polygon. Create a polygon from a box. The boxs min point. The boxs max point. True for a counter clock wise polygon, false for a clock wise polygon The created polygon. Create a polygon from a box. The box. True for a counter clock wise polygon, false for a clock wise polygon The created polygon. Create a polygon from a dounut. Outer radius must be greater than inner. The outer radius. The inner radius The number of segments. The created polygon with holes Create a polygon from a dounut. Outer radius must be greater than inner. The center position of the polygon. The outer radius. The inner radius The number of segments. The created polygon with holes Create a polygon from a circle. The radius of the circle. The number of segments. True for a counter clock wise polygon, false for a clock wise polygon The polygon. Create a polygon from a circle. The center of the circle. The radius of the circle. The number of segments. True for a counter clock wise polygon, false for a clock wise polygon Create a polygon from a circle. The cirlce. The number of segments. True for a counter clock wise polygon, false for a clock wise polygon https://rosettacode.org/wiki/Koch_curve#C.2B.2B The size of the polygon. The number of times to sub divide. True for a counter clock wise polygon, false for a clock wise polygon https://rosettacode.org/wiki/Koch_curve#C.2B.2B The stars center. The size of the polygon. The number of times to sub divide. True for a counter clock wise polygon, false for a clock wise polygon https://rosettacode.org/wiki/Koch_curve#C.2B.2B Decomposition stratergy for polygons. Decomposition stratergy for polygons with holes. Generic Minkowski class. The type of kernel A static instance to the Minkowski class. Create a new object. Compute the Minkowski sum of two polygons. Compute the Minkowski sum of two polygons. Compute the Minkowski sum of two polygons. The decomposition method. Compute the Minkowski sum of two polygons. The decomposition method. It is based on the angle-bisector decomposition method suggested by Chazelle and Dobkin [4], which runs in O(n2) time. In addition, it applies a heuristic by Flato that reduces the number of output polygons in many common cases. The convex decompositions that it produces usually yield efficient running times for Minkowski sum computations. It starts by examining each pair of reflex vertices in the input polygon, such that the entire interior of the diagonal connecting these vertices is contained in the polygon. Out of all available pairs, the vertices pi and pj are selected, such that the number of reflex vertices encountered when traversing the boundary of the polygon from pi to pj in clockwise order is minimal. The polygon is split by the diagonal pipj. This process is repeated recursively on both resulting sub-polygons. In case it is not possible to eliminate two reflex vertices at once any more, each reflex vertex is eliminated by a diagonal that is closest to the angle bisector emanating from this vertex and having rational-coordinate endpoints on both sides. Uses the dynamic-programming algorithm of Greene [6] for computing an optimal decomposition of a polygon into a minimal number of convex sub-polygons. While this algorithm results in a small number of convex polygons, it consumes rather many resources, as it runs in O(n4) time and O(n3) space in the worst case, where n is the number of vertices in the input polygon. Implements the approximation algorithm suggested by Hertel and Mehlhorn [8], which triangulates the input polygon and then discards unnecessary triangulation edges. After triangulation (carried out by the constrained-triangulation procedure of CGAL) the algorithm runs in O(n) time and space, and guarantees that the number of sub-polygons it generates is not more than four times the optimum. Implementation of Greene's approximation algorithm [6], which computes a convex decomposition of the polygon based on its partitioning into y-monotone polygons. This algorithm runs in O(nlogn) time and O(n) space, and has the same guarantee on the quality of approximation as Hertel and Mehlhorn's algorithm. Uses vertical decomposition to decompose the underlying arrangement. Uses vertical decomposition to decompose the underlying arrangement. Uses constrained triangulation to decompose the input polygons, which may have holes, into triangles. Uses constrained triangulation to decompose the input polygons, which may have holes, into triangles. Abstract base class for polygon minkowski. The polygon Minkowski kernel. Release the unmanaged resourses. The generic polgon offset class Static instance of polygon offset. Create new polygon offset. Create a interior or exterior offset. The offset type The polygon to offset. The offset amount The offset polygon Create a interior or exterior offset. The offset type The polygon to offset. The offset amount The offset polygon Create a interior offset. The polygon to offset. The offset amount The offset polygon Create a interior offset. The polygon to offset. The offset amount The offset polygon Create a exterior offset. The polygon to offset. The offset amount The offset polygon Create a exterior offset. The polygon to offset. The offset amount The offset polygon Create the interior skeleton of the polygon. The polygon to offset. Should the polygon be included as the border. The skeletons segments. Create the interior skeleton of the polygon. The polygon to offset. Should the polygon be included as the border. The skeletons segments. Create the exterior skeleton of the polygon. The polygon to offset. The bounding boxes offset from the polygons edges. Must be > 0. Should the polygon be included as the border. The skeletons segments. Create the exterior skeleton of the polygon. The polygon to offset. The bounding boxes offset from the polygons edges. Must be > 0. Should the polygon be included as the border. The skeletons segments. The abstract polygon offset class. The offset kernel. Get the number off polygons in the buffer. The size of the segment buffer. The number of segments in the buffer. Get the unmanaged point to the polygon at the buffer index The index in the buffer. The pointer Get the segment from buffer. The segments index. The segment. Clear the polygon buffer. Clear the segment buffer. Release the unmanaged resources. Type of polygon partitions. Generic polygon partition class. The kernel type. Static instance of polygon partition. Create new polygon partition. Is this polygon Y monotonic. The polygon. True if y monotonic. Is this polygon Y monotonic. The polygon. True if y monotonic. Partition a polygon. The polygon to partition. The resulting polygons. Partition a polygon. The polygon to partition. The resulting polygons. Partition a polygon. The type of partition to perfrom. The polygon to partition. The resulting polygons. Partition a polygon. The type of partition to perfrom. The polygon to partition. The resulting polygons. Partition in to Y monotonic polygons. The polygon to partition. The resulting polygons. Partition in to Y monotonic polygons. The polygon to partition. The resulting polygons. Partition the polygon into convex polygons where the number of convex polygons produced is no more than four times the minimal number. The polygon to partition. The resulting polygons. Partition the polygon into convex polygons where the number of convex polygons produced is no more than four times the minimal number. The polygon to partition. The resulting polygons. Partition the polygon into convex polygons where the number of convex polygons produced is no more than four times the minimal number. The polygon to partition. The resulting polygons. Partition the polygon into convex polygons where the number of convex polygons produced is no more than four times the minimal number. The polygon to partition. The resulting polygons. Partition the polygon into convex polygons where the number of convex polygons produced is minimal. The polygon to partition. The resulting polygons. Partition the polygon into convex polygons where the number of convex polygons produced is minimal. The polygon to partition. The resulting polygons. Copy the new polygons into the result array and the clear the buffer. The number of polygons in buffer. The resulting polygons. The abstract base class. The partition kernel. Clear the unmanaged buffer. Release the unmanaged resources. Cost options for simplification. Stop distance options for simplification. Paramaters for poylgon simplification. The default param settings. The param as a string. Generic polygon simplification class. The kernel type. Static instance of polygon simplification. Simplify the polygon. The polygon to simplify. Must be simple. The simplification parameters. The simplified polygon. Simplify the polygon. The polygon to simplify. Must be simple. The simplification parameters. The simplified polygon ptr. Simplify the polygons boundary and all the holes. The polygon to simplify. Must be simple. The simplification parameters. The simplified polygon. Simplify the polygons boundary and all the holes. The polygon to simplify. Must be simple. The simplification parameters. The simplified polygons ptr. Simplify the polygons boundary. The polygon to simplify. Must be simple. The simplification parameters. The simplified polygon. Simplify the polygons holes. The polygon to simplify. Must be simple. The simplification parameters. The simplified polygon. Simplify one of the polygons holes. The polygon to simplify. Must be simple. The simplification parameters. The hole index to simplify. The simplified polygon. Abstract polygon simplification class. The simplification kernel. Release unmanaged resources. The generic polgon visibility class Static instance of polygon visibility. Create new polygon visibility. Compute the visibility from a simple polygon with no holes. This class implements the algorithm of B.Joe and R.B.Simpson [4]. The algorithm is a modification and extension of the linear time algorithm of Lee [5]. It computes the visibility region from a viewpoint that is in the interior or on the boundary of the polygon. While scanning the boundary the algorithm uses a stack to manipulate the vertices, and ultimately yields the visibility region.For each scanned edge, at most 2 points are pushed onto the stack. Overall, at most 2 n points are pushed or popped. Thus, the time and space complexities of the algorithm are O(n) even in case of degeneracies such as needles, where n is the number of the vertices of the polygon. The visibility point. A simple polygon that contains the point. The visibility result. True if result was computed Compute the visibility from a polygon with holes. The visibility point. A polygon with holes that contains the point. The visibility result. True if result was computed Compute the visibility from a polygon with holes. What method to use. The visibility point. A polygon with holes that contains the point. The visibility result. True if result was computed Compute the visibility from a polygon with holes using the triangular expansion method. The algorithm does not require preprocessing. It relies on the algorithm of T. Asano [1] based on angular plane sweep, with a time complexity of O(nlogn) in the number of vertices. The visibility point. A polygon with holes that contains the point. The visibility result. True if result was computed Compute the visibility from a polygon with holes using the rotational sweep method. The algorithm obtains a constrained triangulation from the input arrangement, then computes visibility by expanding the triangle that contains the query point. Preprocessing takes O(n) time and O(n) space, where n is the number of vertices of input polygon. The query time is O(nh), where h is the number of holes+1 of input polygon. Thus, for simple polygons (or a polygon with a constant number of holes) the algorithm complexity is linear, but it is O(n2) in the worst case, as the number of holes can be linear in n. The visibility point. A polygon with holes that contains the point. The visibility result. True if result was computed The abstract polygon visibility class. The offset kernel. Release the unmanaged resources. Polygon with holes consists of a boundary and holes. Generic polygon definition. The kernel type. Default constuctor. Construct polygon with the boundary. A CCW polygon. Construct polygon with the boundary points A CCW set of points. Create from a pointer. The polygons pointer. The polygon as a string. The polygon as a string. Create a deep copy of the polygon. The copy. Create a deep copy of the polygon element. The element type to copy. If element os a hole thiss is the holes index. The copy. Get the boundary as a copy. If unbounded will return a empty polygon. A copy of the hole polygon. Get the hole as a copy. The holes index A copy of the hole polygon. Add a polygon as a holes. Holes must simple and CW. The hole polygon. Create a copy of boundary and hole polygons. The list of polygons. Triangulate the polygon. The triangle indices. Do the polygons intersect. The other polygon. Do the polygons intersect. Do the polygons intersect. The other polygon. Do the polygons intersect. Connect all the holes of the polygon and return as a polygon. Will result in a non simple polygon. The connected non-simple polygon. Partition the polygon into convex pieces. The convex partition. The type of partition method. Simplify the polygon. The simplification threshold. Simplify the polygon. The simplification parameters. offset the polygon. Does not modify this polygon. The type of offset. The amount to offset. The offset results. The abstract polygon definition. Default constructor. Construct polygon with the kernel. Construct the polygon with the kernel and boundary. A CCW polygon. Construct the polygon with the kernel and boundary. A CCW set of points. Construct the polygon with the kernel and pointer. Is the polygon unbounded. ie no boundary polygon has been set. Is the polygon bounded. ie a boundary polygon has been set. Number of points in the boindary polygon. The number of holes in polygon. Is this a simple polygon. Certains actions can only be carried out on simple polygons. The polygons orientation. Certain actions depend on the polygons orientation. The orientation expressed as the clock direction. Is the polygon degenerate. Polygons with less than 3 points are degenerate. Is the polygon cw orientated. Is the polygon ccw orientated. The polygon kernel. The type of kernel object uses. Valid polygon with holes must have a simple and ccw boundary and all holes must be simple and cw. Valid holes must be simple, cw and must be contained within the boundary polygon. True if the polygon is a valid hole. Clear the polygon. Clear the polygons boundary. Clear the polygons holes. Get the number of points of a polygon element. The element type. If element type is a hole this is the holes index. Remove a polygon. Can remove the boundary or a hole. The element type. If element type is a hole this is the holes index. Remove a hole from the polygon. The holes index. Reverse the polygon. The element type. If element type is a hole this is the holes index. Get a polygons point. The element type. The index of the point in the polygon. If element type is a hole this is the holes index. Get the points in the polygon element. The element type. The point array to copy points into. The ararys length. If element type is a hole this is the holes index. Set a polygons point. The element type. The index of the point in the polygon. The point to set. If element type is a hole this is the holes index. Set all the points in the polygon. If the point array is longer than the polygon is current the extra points are appended to the end. The element type. The points to set. The ararys length. If element type is a hole this is the holes index. Triangulate the polygon. The triangle indices. Add a hole from a set of points. A CW set of points. The ararys length. Find if the polygon has a boundary. True if the polygon has a boundary. Find the polygons bounding box. The element type. If element type is a hole this is the holes index. The polygons bounding box. Find if the polygon is simple. The element type. If element type is a hole this is the holes index. True if the polygon is simple. Find if the polygon is convex. The element type. If element type is a hole this is the holes index. True if polygon is convex. Find the orientation of polygon. The element type. If element type is a hole this is the holes index. The orientation of the polygon. Find the orientated side the point is on. The element type. If element type is a hole this is the holes index. The orientated side of point compared to the polygon. The signed area of the polygon. The element type. If element type is a hole this is the holes index. The signed area is positive if polygon is ccw and negation if cw. The area of the polygon. The element type. If element type is a hole this is the holes index. The polygons area. Enumerate all points in the polygon. Each point in polygon. Enumerate all points in the polygon. Each point in polygon. Return all the points in the polygon in a array. The array. Get all the points in the polygons boundary into a list. Get all the points in the polygon boundary and holes. The point array to copy into. Round each point it polygon to a number of digits. The number of digits to round to. Convert the polygon to a new polygon with a different kernel. May result in different values due to precision issues. The new kernel type. The new polygon. Release the unmanaged resoures. Release the unmanaged pointer. Does the polygon fully contain the other polygon. The other polygon. Should the boundary be included. True if the polygon is contained within this polygon. Does this polygon contain the point. The point. Should points on the boundary be counted as being inside the polygon. True if the polygon contain the point. Translate the polygon. The amount to translate. Translate the polygon. The element type. The amount to translate. If element type is a hole this is the holes index. Rotate the polygon. The amount to rotate in radians. Rotate the polygon. The element type. The amount to rotate in radians. If element type is a hole this is the holes index. Rotate the polygon. The amount to scale. Scale the polygon. The element type. The amount to scale. If element type is a hole this is the holes index. Transform the polygon. The amount to translate. The amount to rotate in radians. The amount to scale. Transform the polygon. The element type. The amount to translate. The amount to rotate in radians. The amount to scale. If element type is a hole this is the holes index. Print debug infomation. Number of vertices. Number of faces. Number of halfedges. Number of border edges. Since each border edge of a polyhedral surface has exactly one border halfedge, this number is equal to size of border halfedges. Returns true if the polyhedral surface is combinatorially consistent. Must be a valid mesh to check many other properties. Returns true if there are no border edges. Returns true if all faces are triangles. Returns true if all faces are quads. Is this a valid triangle mesh. Is this a valid closed mesh. Is this a valid closed triangle mesh. The current build stamp. Clear the mesh. Clear the normal maps. True to clear the vertex normal map. True to clear the face normal map. Create a mesh from the points and indices. The meshes points. The meshes triangles as a index array. Maybe null. The meshes quads as a index array. Maybe null. Create a triangle mesh from the points and indices. The meshes points. The point arrays length. The meshes trinagles as a index array. The indices array length. Create a quad mesh from the points and indices. The meshes points. The point arrays length. The meshes trinagles as a index array. The indices array length. Create a mesh with quads and triangles. The meshes points. The point array length. The meshes triangles. The triangle array length. The meshes quads. The quads array length. Create a mesh with riangles, quads, pentagons and hexagons. The meshs points. The length of the point array. The faces indices. Create a mesh consisting of one polygon face. The faces points The length of the point array. Should the y coord of the points be used for the z coord. Get the triangle and quad indices. The meshes triangles as a index array. Maybe null. The meshes quads as a index array. Maybe null. Get the meshes triangles. The meshes triangles. The triangle array length. Get the meshes quads. The meshes quads. The quads array length. Get the meshes triangles and quads. The meshes triangles. The triangle array length. The meshes quads. The quads array length. Get the meshes triangles, quads, pentagons and hexagons. The indices. Array accessor for the polygon. Getting a point wraps around the polygon. The points index. The vertices point. Get the vertices point. The vertex index in the mesh. The vertices point. If index is out of range. Get the points in the mesh. The array to copy points into. The point array length. Set the point at the index. The points index The pointsam> If index is out of range. Set the points from a array. The point array. The point arrays length. Get a halfedges segment. The halfedges index. The segment. True if halfedge found. Get a segment for each halfedge in the mesh. The segment array. The segment array length. Get the faces triangle. Presumes face is a triangle with no checks. The faces index. The faces triangle Get a triangle for each face in the mesh. Presumes all faces are triangles with no checks. The trainagle array. The traingle arrays length. Get the mesh vertex. The vertices index. The vertex. True if the vertex was found. Get the vertices in the mesh. The vertex array. The vertex array length. Get the mesh face. The faces index. The face. True if the face was found. Get the faces in the mesh. The face array. The face array length. Get the mesh halfedge. The halfedges index. The halfedge. True if the halfedge was found. Get the halfedges in the mesh. The halfedge array. The halfedge array length. Count the number of triangles, quads and polygons in the mesh. The number of triangles, quads and polygons in the mesh. Count the number of triangles, quads and polygons in the dual mesh. A dual mesh is were faces become vertices and vertices become faces. The number of triangles, quads and polygons in the mesh. Get a centroid (the avergae face position) for each face in the mesh. The point array. The points arrays lemgth. Computes the vertex normals if needed. Computes the face normals if needed. Get the vertex normals. The normals array. The normals array length. Get the face normals. The normals array. The normals array length. Translate each point in the mesh. The amount to translate. Rotate each point in the mesh. The amount to rotate. Scale each point in the mesh. The amount to scale. Transform each point in the mesh. The amount to translate. The amount to rotate. The amount to scale. Make all faces triangles. Read data from a off file into the pollyhedron. The files name. Write data from a off file into the pollyhedron. The files name. Print the mesh into a string builder. Reverses the orientation of the vertices in each face. Find what side of the mesh the lies in. The point to check. ON_BOUNDED_SIDE if point inside mesh, ON_UNBOUNDED_SIDE if point not inside, ON_BOUNDARY if point is on the surface. Does the mesh contain the point. The point. If point is on the boundary does it count a being contained. True if the poly contains the point Locate the face the rays hits. The ray. The hit result. Find the face closest to the point. The point. The hit result. Locate the face hit by the ray. The ray. The hit face. True if the ray hit a face. Locate the vertex hit by the ray. The ray. The distance the vertex has to be within hit point. The hit vertex. True if the ray hit a vertex. Locate the edge hit by the ray. The ray. The distance the edge has to be within hit point. The hit edge. True if the ray hit a edge. The faces index THe faces edge A face where all compents are null index. Are these faces equal. Are these faces not equal. Are these objects equal. Are these faces equal. The faces hash code. Enmerate all edges in this edge loop. The mesh the edges belong too. The next edge Enmerate all vertices in this edge loop. The mesh the edges belong too. The next vertex https://github.com/caosdoar/spheres/blob/master/src/spheres.cpp https://github.com/mrdoob/three.js/tree/dev/src/geometries Is the edge a border to a hole. The edges index. The edges source vertices index. The edges target vertices index. The edges opposite edge. The edges next edge. The edges previous edge. The edges face A edge where everthing is set to null index. Get the source point. The mesh the point belongs to. The source point If point is null index. Get the target point. The mesh the point belongs to. The target point If point is null index. Are these edges equal. Are these edges not equal. Are these objects equal. Are these edges equal. The edges hahe code Enmerate all edges in this edge loop. The mesh the edges belong too. The next edge Enmerate all vertices in this edge loop. The mesh the edges belong too. The next vertex The vertices point. The vertices degree is how mang edges connect to it. The vertices index. The vertices edge A vertex where all components are null. Are these vertices equal. Are these vertices not equal. Are these objects equal. Are these vertices equal. The vertices hash code Enmerate all edges surrounding the vertex. The mesh the edges belong too. The next edge Generic nef polyhedron definition. A 3D Nef polyhedron is a subset of the 3-dimensional space that is the result of forming complements and intersections starting from a finite set H of 3-dimensional halfspaces. Nef polyhedra are closed under all binary set operations, i.e., intersection, union, difference, complement, and under the topological operations boundary, closure, and interior. The kernel type. creates a Nef polyhedron and initializes it to the empty set if plane == EMPTY and to the whole space if space == COMPLETE. The nef's space creates a Nef polyhedron containing the halfspace on the negative side of plane including plane if boundary==INCLUDED, excluding plane if boundary==EXCLUDED. The plane. The boundary. creates a Nef polyhedron, which represents the same point set as the polyhedral surface. The polyhedron Create from a pointer. The polyhedrons pointer. The nef polyhdron as a string. The nef polyhedron as a string. Return the intersection of nef and nef1. Return the union of nef and nef1. Return the difference between nef and nef1. Return the symmetric difference of nef and nef1. Returns the complement of nef. Returns the interior of nef. Returns the boundary of nef. Returns the closure of nef. Returns the regularization, i.e. the closure of the interior, of nef. Returns the MinkowskiSum. Converts nef into a Polyhedron. nef must be simple to convert. The result of the conversion. True if nef is simple and the conversion was successful. Converts nef into a surface mesh. nef must be simple to convert. The result of the conversion. True if nef is simple and the conversion was successful. Get a list of the nef volumes. Get a list of the nef volumes. The abstract nef polyhedra definition. Default constructor. creates a Nef polyhedron and initializes it to the empty set if plane == EMPTY and to the whole space if space == COMPLETE. The polyhedron kernel. The nef's space creates a Nef polyhedron containing the halfspace on the negative side of plane including plane if boundary==INCLUDED, excluding plane if boundary==EXCLUDED. The polyhedron kernel. The plane. The boundary. creates a Nef polyhedron, which represents the same point set as the polyhedral surface. The polyhedron kernel. The polyhedron Construct with a new kernel. The polyhedron kernel. The polyhedrons pointer. The polyhedron kernel. Contains the functions to the unmanaged CGAL polhedron. Return the number of halfedge pairs. Return the number of halfedges. Return the number of faces. Return the number of vertices. Return the number of volumes. Returns true, if nef is the empty point set. Rreturns true, if nef is a 2-manifold. Returns true, if nef is the complete 3D space. Make nef the empty set if space == EMPTY and the complete 3D space if space == COMPLETE. Checks the integrity of nef. Decompose the nef into convex volumes. Print the nef polyhedron into a string builder. Release the unmanaged pointer. Should the input polygon be checked. Can disable for better performance if it is know all input if valid. Check if the mesh is valid. The mesh to check. Check if the mesh is valid. The mesh to check. Check if the mesh is a valid triangle mesh. The mesh to check. Check if the mesh is a valid triangle mesh. The mesh to check. Check if the mesh is a valid closed mesh. The mesh to check. Check if the mesh is a valid closed mesh. The polygon to check. Check if the mesh is a valid triangle mesh. The mesh to check. Check if the mesh is a valid triangle mesh. The mesh to check. A polyhedral surface consists of vertices, edges, facets and an incidence relation on them. Each edge is represented by two halfedges with opposite orientations. The kernel type. Default constructor. Construct from points and triangle indices. Construct from points and polygon indices. Create from a pointer. The meshs pointer. The polyhdron as a string. The mesh as a string. Create a deep copy of the mesh. A deep copy of the mesh. Subdive the mesh. The number of iterations to perfrom. The subdivision method. Simplify the polyhedra. A number between 0-1 that represents the percentage of vertices to remove. Refines a triangle mesh a factor to control density of the output mesh, where larger values lead to denser refinements. Defalus to sqrt of 2. The number of new vertices. Orient the faces in the mesh. The orientation method. Reverses the orientation of the vertices in each face. Split the mesh into its unconnected components. Each unconnect component as a new mesh. Remove all unconnected compontents except the largest. Largest is defined by the face count. The numbero of largest components to keep. The number of components removed in the mesh. Create a mesh consisting of one polygon face. The faces polygon. Should the y coord of the points be used for the z coord. Thrown if the polygon is not simple. Create the dual mesh where each face becomes a vertex and each vertex becomes a face. Must be a valid closed mesh to create the dual. The duel mesh. Is thrown if the mesh is not a valid closed mesh. Convert to a surface mesh. The surface mesh. Find the min, max and average edge lengths in the mesh The min, max and average edge lengths in the mesh. Find the min, max and average face areas in the mesh The min, max and average face areas in the mesh. Locate the face the rays hits. The ray. The hit result. Find the face closest to the point. The point. The hit result. The abstract polyhedra definition. Cached values found by running Update. Default constructor. Construct with a new kernel. The mesh kernel. Construct with a new kernel. The mesh kernel. The meshs pointer. The mesh kernel. Contains the functions to the unmanaged CGAL polhedron. Number of vertices. Number of faces. Number of half edges. Number of border edges. Since each border edge of a polyhedral surface has exactly one border halfedge, this number is equal to size of border halfedges. Number of border halfedges. The current build stamp. Returns true if the polyhedral surface is combinatorially consistent. Must be a valid mesh to check many other properties. Returns true if there are no border edges. Returns true if all faces are triangles. Returns true if all faces are quads. Is the mesh a valid triangle mesh. Is the mesh a valid closed mesh. Is the mesh a valid closed triangle mesh. Has the update function been called. Mark th mesh as needing to be updated. Clear the mesh. Clear the index maps. The index maps are used to access the meshes elemnts by index. They are automaticaly created when a elements is accessed be a function requiring it. True to clear the vertex index map. True to clear the face index map. True to clear the edges index map. Clear the normal maps. True to clear the vertex normal map. True to clear the face normal map Builds the vertex and/or face index maps if needed. True to build the vertex index map. True to build the face index map. True to build the face index map. True to force the build even if already built. A tetrahedron is added to the polyhedral surface with its vertices initialized to p1, p2, p3, and p4. A edge in the tetrahdron. A triangle with border edges is added to the polyhedral surface with its vertices initialized to p1, p2, and p3. A edge in the triangle. Create a mesh from the points and indices. The meshes points. The meshes triangles as a index array. Maybe null. The meshes quads as a index array. Maybe null. Create a triangle mesh from the points and indices. The meshes points. The point arrays length. The meshes trinagles as a index array. The indices array length. Create a quad mesh from the points and indices. The meshes points. The point arrays length. The meshes trinagles as a index array. The indices array length. Create a mesh with quads and triangles. The meshes points. The point array length. The meshes triangles. The triangle array length. The meshes quads. The quads array length. Create a mesh with riangles, quads, pentagons and hexagons. The meshs points. The length of the point array. The faces indices. Create a mesh consisting of one polygon face. The faces points The point array length. Should the y coord of the points be used for the z coord. Get the triangle and quad indices. The meshes triangles as a index array. Maybe null. The meshes quads as a index array. Maybe null. Get the meshes triangles. The meshes triangles. The triangle array length. Get the meshes quads. The meshes quads. The quads array length. Get the meshes triangles and quads. The meshes triangles. The triangle array length. The meshes quads. The quads array length. Get the meshes triangles, quads, pentagons and hexagons. The indices. Get the dual meshes triangles, quads, pentagons and hexagons. A dual mesh is were faces become vertices and vertices become faces. The indices Array accessor for the polygon. Getting a point wraps around the polygon. The points index. The vertices point. Get the vertices point. The vertex index in the mesh. The vertices point. If index is out of range. Get the point at the index and wrap around the polygon. The points index. The point at the index. Get the point at the index and clamp to the polygons last point. The points index. The point at the index. Get the vertices point but wraps the index. The vertex index in the mesh. The vertices point. Get the points in the mesh. The array to copy points into. The point array length. Set the point at the index. The points index The pointsam> If index is out of range. Set the points from a array. The point array. The point arrays length. Get a halfedges segment. The halfedges index. The segment. True if halfedge found. Get the segment. The segment index. The segment If segmentwith the index not found. Get a segment for each halfedge in the mesh. The segment array. The segment array length. Get the faces triangle. Presumes face is a triangle with no checks. The faces index. The faces triangle Get the triangle. The triangle index. The triangle If triangle with the index not found. Get a triangle for each face in the mesh. Presumes all faces are triangles with no checks. The trainagle array. The traingle arrays length. Get the mesh vertex. The vertices index. The vertex. True if the vertex was found. Get the mesh vertex. The vertexs index. The vertexs If vertex with the index not found. Get the vertices in the mesh. The vertex array. The vertex array length. Get the mesh face. The faces index. The face. True if the face was found. Get the mesh face. The faces index. The faces If face with the index not found. Get the faces in the mesh. The face array. The face array length. Get the mesh halfedge. The halfedges index. The halfedge. True if the halfedge was found. Get the mesh Halfedge. The Halfedges index. The Halfedges If Halfedge with the index not found. Get the halfedges in the mesh. The halfedge array. The halfedge array length. Count the number of triangles, quads and polygons in the mesh. The number of triangles, quads and polygons in the mesh. Count the number of triangles, quads and polygons in the dual mesh. A dual mesh is were faces become vertices and vertices become faces. The number of triangles, quads and polygons in the mesh. Get a centroid (the avergae face position) for each face in the mesh. The point array. The points arrays lemgth. Computes the vertex normals if needed. Computes the face normals if needed. Get the vertex normals. The normals array. The normals array length. Get the face normals. The normals array. The normals array length. Translate each point in the mesh. The amount to translate. Rotate each point in the mesh. The amount to rotate. Scale each point in the mesh. The amount to scale. Transform each point in the mesh. The amount to translate. The amount to rotate. The amount to scale. Make all faces triangles. sorts halfedges such that the non-border edges precede the border edges. For each border edge the halfedge iterator will reference the halfedge incident to the facet right before the halfedge incident to the hole. returns true if the border halfedges are in normalized representation, which is when enumerating all halfedges with the iterator: The non-border edges precede the border edges and for border edges, the second halfedge is the border halfedge. Find what side of the mesh the lies in. The point to check. ON_BOUNDED_SIDE if point inside mesh, ON_UNBOUNDED_SIDE if point not inside, ON_BOUNDARY if point is on the surface. Does the mesh contain the point. The point. If point is on the boundary does it count a being contained. True if the poly contains the point Locate the face the rays hits. The ray. The hit result. Find the face closest to the point. The point. The hit result. Locate the face hit by the ray. The ray. The hit face. True if the ray hit a face. Locate the vertex hit by the ray. The ray. The distance the vertex has to be within hit point. The hit vertex. True if the ray hit a vertex. Locate the edge hit by the ray. The ray. The distance the edge has to be within hit point. The hit edge. True if the ray hit a edge. Tests if a set of faces of a triangulated surface mesh self-intersects. Must be a triangle mesh. True/Fasle if a valid triangle polyhedra,or UNDETERMINED if not. returns true if the polyhedral surface is combinatorially consistent. For level == 1 the normalization of the border edges is checked too. This method checks that each face is at least a triangle and that the two incident facets of a non-border edge are distinct. Computes the bounding box. The bounding box. Computes the area of a range of faces of a given triangulated surface mesh. The area or 0 if poyhedron is not valid triangle mesh. computes the centroid of a volume bounded by a closed triangulated surface mesh. The centroid or 0 if poyhedron is not valid. Computes the volume of the domain bounded by a closed triangulated surface mesh. The volume or 0 if poyhedron is not valid closed triangle mesh. Returns true if there are no border edges. True/Fasle if valid, or UNDETERMINED if not a valid polyhedra. Returns true if all vertices have exactly two incident edges. True/Fasle if valid, or UNDETERMINED if not a valid polyhedra. Returns true if all vertices have exactly three incident edges. True/Fasle if valid, or UNDETERMINED if not a valid polyhedra. Returns true if all faces are triangles. True/Fasle if valid, or UNDETERMINED if not a valid polyhedra. Returns true if all faces are quads. True/Fasle if valid, or UNDETERMINED if not a valid polyhedra. Indicates if the mesh bounds a volume. Must be a closed and triangulated. True/Fasle if a valid triangle closed polyhedra,or UNDETERMINED if not. Builds the aabb tree used for location. Tree will be automatically built if need so not actually necessary to call this function. Will delete the aabb tree. Returns true if there exists a face of this poly and a face of other poly which intersect, and false otherwise. Must be a triangle mesh The other triangle poly. If test_bounded_sides is set to true, the overlap of bounded sides are tested as well. In that case, the meshes must be closed. True/Fasle if a valid triangle closed polyhedra,or UNDETERMINED if not. Subdive the mesh. The number of iterations to perfrom. The subdivision method. Simplify the polyhedra. A number between 0-1 that represents the percentage of vertices to remove. Refines a triangle mesh a factor to control density of the output mesh, where larger values lead to denser refinements. Defalus to sqrt of 2. The number of new vertices. Orient the faces in the mesh. The orientation method. Reverses the orientation of the vertices in each face. Remove all unconnected compontents except the largest. Largest is defined by the face count. The numbero of largest components to keep. The number of components removed in the mesh. Find the min, max and average edge lengths in the mesh The min, max and average edge lengths in the mesh. Find the min, max and average face areas in the mesh The min, max and average face areas in the mesh. Enumerate all points in the mesh. Each point in mesh. Enumerate all points in the mesh. Each point in mesh. Read data from a off file into the pollyhedron. The files name. Write data from a off file into the pollyhedron. The files name. Return all the points in the mesh in a array. The array. Return all the points in the mesh in a list. The list. https://doc.cgal.org/latest/Polyhedron/classCGAL_1_1Polyhedron__3.html#a73119c0c90bf8612da003305af25a52a creates a new facet within the hole incident to h and g by connecting the vertex denoted by g with the vertex denoted by h with a new halfedge and filling this separated part of the hole with a new facet, such that the new facet is incident to g. Precondition h->is_border(), g->is_border(), h != g, h->next() != g, and g can be reached along the same hole starting with h. a halfedge index a halfedge index Returns the halfedge of the new edge that is incident to the new facet. creates a new facet within the hole incident to h and g by connecting the tip of g with the tip of h with two new halfedges and a new vertex and filling this separated part of the hole with a new facet, such that the new facet is incident to g. Precondition h->is_border(), g->is_border(), h != g, and g can be reached along the same hole starting with h. a halfedge index a halfedge index Returns the halfedge of the new edge that is incident to the new facet and the new vertex. barycentric triangulation of h->facet(). Creates a new vertex, a copy of h->vertex(), and connects it to each vertex incident to h->facet() splitting h->facet() into triangles.h remains incident to the original facet, all other triangles are copies of this facet. Precondition h is not a border halfedge. a halfedge index Returns the halfedge h->next() after the operation, i.e., a halfedge pointing to the new vertex.The time is proportional to the size of the facet. reverses create_center_vertex(). Erases the vertex pointed to by g and all incident halfedges thereby merging all incident facets.Only g->facet() remains. The neighborhood of g->vertex() may not be triangulated, it can have larger facets. Precondition None of the incident facets of g->vertex() is a hole. There are at least two distinct facets incident to the facets that are incident to g->vertex(). (This prevents the operation from collapsing a volume into two facets glued together with opposite orientations, such as would happen with any vertex of a tetrahedron.) Supports_removal must be CGAL::Tag_true. a halfedge index Returns the halfedge g->prev(). Thus, the invariant h == erase_center_vertex(create_center_vertex(h)) holds if h is not a border halfedge.The time is proportional to the sum of the size of all incident facets. removes the incident facet of h and changes all halfedges incident to the facet into border edges or removes them from the polyhedral surface if they were already border edges. If this creates isolated vertices they get removed as well.See make_hole(h) for a more specialized variant. Precondition h->is_border() == false. Supports_removal must be CGAL::Tag_true a halfedge index Erase a facet. a halfedge index returns a range of handles over the facets. fills a hole with a newly created facet. Makes all border halfedges of the hole denoted by h incident to the new facet.Returns h. Precondition h.is_border(). a halfedge index performs an edge flip. Precondition h != Halfedge_handle() and both facets incident to h are triangles. a halfedge index It returns h after rotating the edge h one vertex in the direction of the face orientation. joins the two facets incident to h. The facet incident to h->opposite() gets removed.Both facets might be holes. Precondition The degree of both vertices incident to h is at least three(no antennas). Supports_removal must be CGAL::Tag_true. a halfedge index Returns the predecessor of h around the facet. The invariant join_facet(split_facet(h, g)) returns h and keeps the polyhedron unchanged.The time is proportional to the size of the facet removed and the time to compute h->prev(). glues the boundary of the two facets denoted by h and g together and returns h. Both facets and the vertices along the facet denoted by g gets removed.Both facets may be holes. The invariant join_loop(h, split_loop(h, i, j)) Precondition The facets denoted by h and g are different and have equal degree(i.e., number of edges). Supports_removal must be CGAL::Tag_true. a halfedge index a halfedge index returns h and keeps the polyhedron unchanged. joins the two vertices incident to h. The vertex denoted by h->opposite() gets removed. Precondition The size of both facets incident to h is at least four(no multi-edges). Supports_removal must be CGAL::Tag_true. a halfedge index Returns the predecessor of h around the vertex, i.e., h->opposite()->prev(). The invariant join_vertex(split_vertex(h, g)) returns h and keeps the polyhedron unchanged.The time is proportional to the degree of the vertex removed and the time to compute h->prev() and h->opposite()->prev(). removes the incident facet of h and changes all halfedges incident to the facet into border edges. Precondition None of the incident halfedges of the facet is a border edge. Supports_removal must be CGAL::Tag_true. a halfedge index Returns h.See erase_facet(h) for a more generalized variant. splits the halfedge h into two halfedges inserting a new vertex that is a copy of h->opposite()->vertex(). Is equivalent to split_vertex(h->prev(), h->opposite())->opposite(). The call of prev() can make this method slower than a direct call of split_vertex() if the previous halfedge is already known and computing it would be costly when the halfedge data structure does not support the prev() member function. a halfedge index Returns the new halfedge now pointing to the inserted vertex.The new halfedge is followed by the old halfedge, i.e., hnew->next() == h. splits the facet incident to h and g into two facets with a new diagonal between the two vertices denoted by h and g respectively. The second(new) facet is a copy of the first facet. Precondition h and g are incident to the same facet.h != g (no loops). h->next() != g and g->next() != h (no multi-edges). a halfedge index a halfedge index Returns h->next() after the operation, i.e., the new diagonal.The new face is to the right of the new diagonal, the old face is to the left.The time is proportional to the distance from h to g around the facet. cuts the polyhedron into two parts along the cycle (h,i,j) (edge j runs on the backside of the three dimensional figure above). Three new vertices(one copy for each vertex in the cycle) and three new halfedges(one copy for each halfedge in the cycle), and two new triangles are created.h,i,j will be incident to the first new triangle. Precondition h, i, j denote distinct, consecutive vertices of the polyhedron and form a cycle: i.e., h->vertex() == i->opposite()->vertex(), … , j->vertex() == h->opposite()->vertex(). The six facets incident to(h, i, j) are all distinct. a halfedge index a halfedge index a halfedge index The return value will be the halfedge incident to the second new triangle which is the copy of h-opposite(). splits the vertex incident to h and g into two vertices, the old vertex remains and a new copy is created, and connects them with a new edge. Let hnew be h->next()->opposite() after the split, i.e., a halfedge of the new edge. The split regroups the halfedges around the two vertices.The halfedge sequence hnew, g->next()->opposite(), … , h remains around the old vertex, while the halfedge sequence hnew->opposite(), h->next()->opposite() (before the split), … , g is regrouped around the new vertex. Precondition h and g are incident to the same vertex. h != g (antennas are not allowed). a halfedge index a halfedge index The split returns hnew, i.e., the new halfedge incident to the old vertex.The time is proportional to the distance from h to g around the vertex. Update the mesh if needed. Print the mesh into a string builder. Release the unmanaged pointer. This class is a data structure that can be used as halfedge data structure. It is an alternative to the classes Polyhedron3.The main difference is that it is indexed based and not pointer based, and that the mechanism for adding information to vertices, halfedges, edges, and faces is much simpler. When elements are removed, they are only marked as removed, and a garbage collection function must be called to really remove them. The kernel type Default constructor. Construct from points and triangle indices. Construct from points and polygon indices. Create from a pointer. The surface meshes pointer. The mesh as a string. The mesh as a string. Create a deep copy of the mesh. The deep copy. Subdive the mesh. The number of iterations to perfrom. The subdivision method. Simplify the polyhedra. A number between 0-1 that represents the percentage of vertices to remove. Refines a triangle mesh a factor to control density of the output mesh, where larger values lead to denser refinements. Defalus to sqrt of 2. The number of new vertices. Orient the faces in the mesh. The orientation method. Reverses the orientation of the vertices in each face. Split the mesh into its unconnected components. Each unconnect component as a new mesh. Remove all unconnected compontents except the largest. Largest is defined by the face count. The numbero of largest components to keep. The number of components removed in the mesh. Copy the other mesh to this one. Create a mesh consisting of one polygon face. The faces polygon. Should the y coord of the points be used for the z coord. Thrown if the polygon is not simple. Convert to a polyhedron mesh. The polyhedron mesh. Find the min, max and average edge lengths in the mesh The min, max and average edge lengths in the mesh. Find the min, max and average face areas in the mesh The min, max and average face areas in the mesh. Locate the face the rays hits. The ray. The hit result. Find the face closest to the point. The point. The hit result. The surface mesh abstract base class. Cached values found by running Update. Default constructor. Construct mesh with the kernel. The kernel Construct with a new kernel. The surface meshes kernel. The surface meshes pointer. The meshes kernel type. The number of vertices in the mesh. The number of half edges in the mesh. The number of edges in the mesh. The number of faces in the mesh. The number of border edges. The current build stamp. The number of vertices currenly maked to be removed but have not. Calling collect garbage will remove them. The number of vertices marked to be removed. The number of halfedges currenly maked to be removed but have not. Calling collect garbage will remove them. The number of half edges marked to be removed. The number of edges currenly maked to be removed but have not. Calling collect garbage will remove them. The number of edges marked to be removed. The number of faces currenly maked to be removed but have not. Calling collect garbage will remove them. The number of face marked to be removed. Returns true if the meshl surface is combinatorially consistent. Must be a valid mesh to check many other properties. Returns true if there are no border edges. Returns true if all faces are triangles. Returns true if all faces are quads. Is the mesh a valid triangle mesh. Is the mesh a valid closed mesh. Is the mesh a valid closed triangle mesh. Has the update function been called. Mark the mesh as needing to be updated. Clear the mesh. Clear the index maps. The index maps are used to access the meshes elemnts by index. They are automaticaly created when a elements is accessed be a function requiring it. True to clear the vertex index map. True to clear the face index map. True to clear the edges index map. True to clear the halfedges index map. Clear the normal maps. True to clear the vertex normal map. True to clear the face normal map Clear the property maps. Build the index maps. The index maps are used to access the meshes elemnts by index. They are automaticaly created when a elements is accessed be a function requiring it but can be create ahead of time. True to build the vertex index maps. True to build the face index maps. True to build the edge index maps. True to build the halfedge index maps. The index maps wont be build if the mesh knows they are already built and upto date. Setting force to true will build them always. Adds a vertex to the mesh. The vertices position The vertices index in the mesh. Adds a edge between the two vertices. The index of the vertex in the mesh. The index of the vertex in the mesh. The index of the edge in the mesh. Adds a triangle face to the mesh. The index of the vertex in the mesh. The index of the vertex in the mesh. The index of the vertex in the mesh. The index of the face in the mesh. Adds a quad face to the mesh. The index of the vertex in the mesh. The index of the vertex in the mesh. The index of the vertex in the mesh. The index of the vertex in the mesh. The index of the face in the mesh. Adds a pentagon face to the mesh. The index of the vertex in the mesh. The index of the vertex in the mesh. The index of the vertex in the mesh. The index of the vertex in the mesh. The index of the vertex in the mesh. The index of the face in the mesh. Adds a hexagon face to the mesh. The index of the vertex in the mesh. The index of the vertex in the mesh. The index of the vertex in the mesh. The index of the vertex in the mesh. The index of the vertex in the mesh. The index of the vertex in the mesh. The index of the face in the mesh. Add a polygon face to the mesh. The indices of the points in the mesm. The indices array length. The index of the face in the mesh. Checks if any vertices, halfedges, edges, or faces are marked as removed. Really removes vertices, halfedges, edges, and faces which are marked removed. By garbage collecting elements get new indices. In case you store indices in an auxiliary data structure or in a property these indices are potentially no longer refering to the right elements. Controls the recycling or not of simplices previously marked as removed upon addition of new elements. When set to true (default value), new elements are first picked in the garbage(if any) while if set to false only new elements are created. Array accessor for the polygon. Getting a point wraps around the polygon. Get the vertices point. The vertex index in the mesh. The vertices point. If index is out of range. Get the points in the mesh. The array to copy points into. The point array length. Set the point at the index. The points index The pointsam> If index is out of range. Set the points from a array. The point array. The point arrays length. Get a halfedges segment. The halfedges index. The segment. True if halfedge found. Get a segment for each halfedge in the mesh. The segment array. The segment array length. Get the faces triangle. Presumes face is a triangle with no checks. The faces index. The faces triangle Get a triangle for each face in the mesh. Presumes all faces are triangles with no checks. The trainagle array. The traingle arrays length. Get the mesh vertex. The vertices index. The vertex. True if the vertex was found. Get the mesh vertex. The vertices index. The vertex. Get the vertices in the mesh. The vertex array. The vertex array length. Get the mesh face. The faces index. The face. True if the face was found. Get the mesh face. The faces index. The face. Get the faces in the mesh. The face array. The face array length. Get the mesh halfedge. The halfedges index. The halfedge. True if the halfedge was found. Get the mesh halfedge. The halfedges index. THe healfedge. Get the halfedges in the mesh. The halfedge array. The halfedge array length. Returns the number of incident halfedges of vertex. The index of the vertex in the mesh. Returns the number of incident halfedges of vertex. Returns the number of incident halfedges of face. The index of the face in the mesh. Returns the number of incident halfedges of face. Returns whether vertex is isolated. The index of the vertex in the mesh. Returns whether vertex is isolated. Returns whether vertex is a border vertex. If the data contained in the Surface_mesh is not a 2-manifold, then this operation is not guaranteed to return the right result. he index of the vertex in the mesh. With the default value for check_all_incident_halfedges the function iteratates over the incident halfedges. With check_all_incident_halfedges == false the function returns true, if the incident halfedge associated to vertex is a border halfedge, or if the vertex is isolated. Returns whether vertex is a border vertex. Returns whether edge is a border edge, i.e., if any of its two halfedges is a border halfedge. The index of the edge in the mesh. Returns whether edge is a border edge. Returns the next halfedge within the incident face. The index of the halfedge in the mesh. Returns the next halfedge within the incident face. Returns the previous halfedge within the incident face. The index of the halfedge in the mesh. Returns the previous halfedge within the incident face. Returns the opposite halfedge of halfedge. The index of the halfedge in the mesh. Returns the opposite halfedge of halfedge. Returns the vertex the halfedge emanates from. The index of the halfedge in the mesh. Returns the vertex the halfedge emanates from. Returns the vertex the halfedge points to. The index of the halfedge in the mesh. Returns the vertex the halfedge points to. Removes vertex from the halfedge data structure without adjusting anything. The index of the vertex in the mesh. True if face removed. Removes the two halfedges corresponding to edge from the halfedge data structure without adjusting anything. The index of the edge in the mesh. True if face removed. Removes face from the halfedge data structure without adjusting anything. The index of the face in the mesh. True if face removed. Has this vertex been marked to be removed. The vertices index in the mesh. Has this vertex been marked to be removed. Has this face been marked to be removed. The faces index in the mesh. Has this face been marked to be removed. Has this halfedge been marked to be removed. The halfedge index in the mesh. Has this halfedge been marked to be removed. Has this edge been marked to be removed. The edges index in the mesh. Has this edge been marked to be removed. Performs a validity check on a single vertex. The index of the vertex in the mesh. True if valid. Performs a validity check on a single edge. The index of the edge in the mesh. True if valid. Performs a validity check on a single halfedge. The index of the halfedge in the mesh. True if valid. Performs a validity check on a single face. The index of the face in the mesh. True if valid. Translate each point in the mesh. The amount to translate. Rotate each point in the mesh. The amount to rotate. Scale each point in the mesh. The amount to scale. Transform each point in the mesh. The amount to translate. The amount to rotate. The amount to scale. Create a mesh from the points and indices. The meshes points. The meshes triangles as a index array. Maybe null. The meshes quads as a index array. Maybe null. Create a triangle mesh from the points and indices. The meshes points. The point arrays length. The meshes trinagles as a index array. The indices array length. Create a quad mesh from the points and indices. The meshes points. The point arrays length. The meshes trinagles as a index array. The indices array length. Create a mesh with quads and triangles. The meshes points. The point array length. The meshes triangles. The triangle array length. The meshes quads. The quads array length. Create a mesh with riangles, quads, pentagons and hexagons. The meshs points. The length of the point array. The faces indices. Create a mesh consisting of one polygon face. The faces points The paoint array length. Should the y coord of the points be used for the z coord. Get the triangle and quad indices. The meshes triangles as a index array. Maybe null. The meshes quads as a index array. Maybe null. Get the meshes triangles. The meshes triangles. The triangle array length. Get the meshes quads. The meshes quads. The quads array length. Get the meshes triangles and quads. The meshes triangles. The triangle array length. The meshes quads. The quads array length. Get the meshes triangles, quads, pentagons and hexagons. The indices. Whether v is a border vertex. The vertices index. With the default value for check_all_incident_halfedges the function iteratates over the incident halfedges. With check_all_incident_halfedges == false the function returns true, if the incident halfedge associated to vertex v is a border halfedge, or if the vertex is isolated. Whether v is a border vertex. Whether half edge is a border halfege, that is if its incident face is null. The halfedges index. Whether half edge is a border halfege. Whether e is a border edge, i.e., if any of its two halfedges is a border halfedge. The edges index. Whether e is a border edge. Count the number of triangles, quads and polygons in the mesh. The number of triangles, quads and polygons in the mesh. Count the number of triangles, quads and polygons in the dual mesh. A dual mesh is were faces become vertices and vertices become faces. The number of triangles, quads and polygons in the mesh. Build the aabb tree. Release the aabb tree. Find the bounding box of the meshes points. Read the mesh from a off file format. The files name. Write the mesh to off file format. The files name. Make all faces triangles. Tests if a set of faces of a triangulated surface mesh self-intersects. Must be a triangle mesh. True/Fasle if a valid triangle mesh,or UNDETERMINED if not. Perform an expensive validity check on the data structure. If the mesh is valid. Find if all the faces in the mesh are triangles. True if all the faces in the mesh are triangles, Will be undetermined if no a valid mesh. Find if all the faces in the mesh are quads. True if all the faces in the mesh are quads, Will be undetermined if no a valid mesh. Find if the mesh is closed, ie has no border edges. Computes the area of a range of faces of a given triangulated surface mesh. The area or 0 if mesh is not valid triangle mesh. computes the centroid of a volume bounded by a closed triangulated surface mesh. The centroid or 0 if mesh is not valid. Computes the volume of the domain bounded by a closed triangulated surface mesh. The volume or 0 if mesh is not valid closed triangle mesh. Indicates if the mesh bounds a volume. Must be a closed and triangulated. True/Fasle if a valid triangle closed mesh,or UNDETERMINED if not. Find what side of the mesh the lies in. The point to check. ON_BOUNDED_SIDE if point inside mesh, ON_UNBOUNDED_SIDE if point not inside, ON_BOUNDARY if point is on the surface. Does the mesh contain the point. The point. If point is on the boundary does it count a being contained. True if the poly contains the point Locate the face the rays hits. The ray. The hit result. Find the face closest to the point. The point. The hit result. Locate the face hit by the ray. The ray. The hit face. True if the ray hit a face. Locate the vertex hit by the ray. The ray. The distance the vertex has to be within hit point. The hit vertex. True if the ray hit a vertex. Locate the edge hit by the ray. The ray. The distance the edge has to be within hit point. The hit edge. True if the ray hit a edge. Returns true if there exists a face of this poly and a face of other mesh which intersect, and false otherwise. Must be a triangle mesh The other triangle poly. If test_bounded_sides is set to true, the overlap of bounded sides are tested as well. In that case, the meshes must be closed. True/Fasle if a valid triangle closed mesh,or UNDETERMINED if not. Find the min, max and average edge lengths in the mesh The min, max and average edge lengths in the mesh. Find the min, max and average face areas in the mesh The min, max and average face areas in the mesh. Subdive the mesh. The number of iterations to perfrom. The subdivision method. Simplify the polyhedra. A number between 0-1 that represents the percentage of vertices to remove. Refines a triangle mesh a factor to control density of the output mesh, where larger values lead to denser refinements. Defalus to sqrt of 2. The number of new vertices. Orient the faces in the mesh. The orientation method. Reverses the orientation of the vertices in each face. Remove all unconnected compontents except the largest. Largest is defined by the face count. The numbero of largest components to keep. The number of components removed in the mesh. Get a centroid (the avergae face position) for each face in the mesh. The point array. The points arrays lemgth. Compute the vertex normal map. Will only be computed if mesh has changed since last computation or no current nomral maps have been computed. Compute the face normal map. Will only be computed if mesh has changed since last computation or no current nomral maps have been computed. Get the vertex normals. Will be compute if they have not aready. The normal map array. The normal maps array length. Get the face normals. Will be compute if they have not aready. The normal map array. The normal maps array length. Enumerate all points in the mesh. Each point in mesh. Enumerate all points in the mesh. Each point in mesh. Return all the points in the mesh in a array. The array. Return all the points in the mesh in a list. The list. Update the mesh if needed. Print the mesh into a string builder. Release any unmanaged resources. Generic polyline definition. The kernel type. Default constructor. Create from a set of points. The polylines points. Create from a pointer. The polylines pointer. The polyline as a string. The polyline as a string. Copy the polyline. The copied polyline. Create a polygon from the line. Threshold for the firat and last points being equal. The polygon. The abstract polyline definition. Default constructor. Construct with a new kernel. The polyline kernel. Construct with a new kernel. The polyline kernel. The points to construct from. Construct with a new kernel. The polyline kernel. The polylines pointer. The number of points in the polyline. The capacity of the point array. Get the first point. Get the last point. The polylines kernel. Contains the functions to the unmanaged CGAL polyline. Array accessor for the polyline. Getting a point clamps to the last point in polyline. Clear the polyline of all points. Shrink the capacity to match the point count. Resize the point array. New elements will default to zero. Reverse the polints in the line. Remove the point at the index from the array. The points index Remove a range of points from the array. The starting index The number of points to remove. Remove the last point. Remove the point at the index from the array. The points index. The point to insert. Remove a range of points from the array. The points to insert. The starting index. The number of points to insert. Add the point to the end of the poylline. The point to add. Does the first and last point match. The distance threshold that counts as match. Get the point a the index. The points index to get. The point at index. Get the point at the index and wrap around the polyline. The points index. The point at the index. Get the point at the index and clamp to the polylines last point. The points index. The point at the index. Get all the points in the polyline. The point array to copy the data into. The array length. Get all the polyline points. The list to copy the data into. Get all the polyline segments. The segment array to copy the data into. The array length. Set the points at the index. The points index. The points value. Set the points from the array. If the array is larger than the polyline then the new points will be appended to end of polyline. The points array. The array length. Finds the length of the polyline. Finds the square length of the polyline. Translate the polyline. The amount to translate. Rotate the polyline. The amount to rotate in radians. Scale the polyline. The amount to scale. Transform the polyline with a TRS matrix. The amount to translate. The amount to rotate. The amount to scale. Enumerate all points in the polyline. Each point in polyline. Enumerate all points in the polyline. Each point in polyline. Return all the points in the polyline in a array. The array. Return all the points in the polyline in a list. The list. Convert the polyline to a new polyline with a different kernel. May result in different values due to precision issues. The new kernel type. The new polline. Print the polyline into a styring builder. Release the unmanaged pointer. Release the unmanaged pointer. Generic polyline definition. The kernel type. Default constructor. Create from a set of points. The polylines points. Create from a pointer. The polylines pointer. The polyline as a string. The polyline as a string. Copy the polyline. The copied polyline. The abstract polyline definition. Default constructor. Construct with a new kernel. The polyline kernel. Construct with a new kernel. The polyline kernel. The points to construct from. Construct with a new kernel. The polyline kernel. The polylines pointer. The number of points in the polyline. The capacity of the point array. Get the first point. Get the last point. The polylines kernel. Contains the functions to the unmanaged CGAL polyline. Array accessor for the polyline. Getting a point clamps to the last point in polyline. Clear the polyline of all points. Shrink the capacity to match the point count. Resize the point array. New elements will default to zero. Reverse the polints in the line. Remove the point at the index from the array. The points index Remove a range of points from the array. The starting index The number of points to remove. Remove the last point. Remove the point at the index from the array. The points index. The point to insert. Remove a range of points from the array. The points to insert. The starting index. The number of points to insert. Add the point to the end of the poylline. The point to add. Does the first and last point match. The distance threshold that counts as match. Get the point a the index. The points index to get. The point at index. Get the point at the index and wrap around the polyline. The points index. The point at the index. Get the point at the index and clamp to the polylines last point. The points index. The point at the index. Get all the points in the polyline. The point array to copy the data into. The array length. Get all the polyline points. The list to copy the data into. Get all the polyline segments. The segment array to copy the data into. The array length. Set the points at the index. The points index. The points value. Set the points from the array. If the array is larger than the polyline then the new points will be appended to end of polyline. The points array. The array length. Finds the length of the polyline. Finds the square length of the polyline. Translate each point in the polyline. The amount to translate. Rotate each point in the polyline. The amount to rotate. Scale each point in the polyline. The amount to scale. Transform each point in the polyline. The amount to translate. The amount to rotate. The amount to scale. Enumerate all points in the polyline. Each point in polyline. Enumerate all points in the polyline. Each point in polyline. Return all the points in the polyline in a array. The array. Return all the points in the polyline in a list. The list. Convert the polyline to a new polyline with a different kernel. May result in different values due to precision issues. The new kernel type. The new polline. Print the polyline into a styring builder. Release the unmanaged pointer. Release the unmanaged pointer. The heat method is an algorithm that solves the single- or multiple-source shortest path problem by returning an approximation of the geodesic distance for all vertices of a triangle mesh to the closest vertex in a given set of source vertices. The geodesic distance between two vertices of a mesh is the distance when walking on the surface, potentially through the interior of faces. Two vertices that are close in 3D space may be far away on the surface. Create a static instance. Create a new instance. Create a new instance from a existing pointer to a unmanaged object. The unmanaged objects pointer. Find the distances for each vertex in the mesh to the vertex at the provided index. The mesh containing the vertices. The vertices index to find the distances to. The distances for each vertex in the mesh. Should the intrinsitic delaunay triangulation be used. This will improve the results for meshes that have bad triangle quality. The maximum distance value. Find the distances for each vertex in the mesh to the vertex at the provided index. The mesh containing the vertices. The vertices index to find the distances to. The distances for each vertex in the mesh. This will improve the results for meshes that have bad triangle quality. The maximum distance value. Create a new instance. Create a new instance from a existing pointer to a unmanaged object. The unmanaged objects pointer. Release any unmanaged resources. Returns the number of unconnect components in the mesh. A valid mesh. Returns the number of unconnect components in the mesh. Returns a list of face indices that are part of the same component as the provided face index. A valid mesh. The faces index in the mesh. A list of face indices that are part of the same component as the provided face index. Returns a list of face indices that are part of the same component as the provided face index. A valid mesh. The faces index in the mesh. A list of face indices that are part of the same component as the provided face index. Split each component in the mesh into individual meshes. A valid mesh. The split meshes. Split each component in the mesh into individual meshes. A valid mesh. The split meshes. Removes connected components with less than a given number of faces. A valid mesh. The number of faces a component must have so that it is kept The number of components removed. Removes connected components with less than a given number of faces. A valid mesh. The number of faces a component must have so that it is kept The number of components removed. Removes the small connected components and all isolated vertices. A valid mesh. Keep this number of the largest connected components. The number of components removed. Removes the small connected components and all isolated vertices. A valid mesh. Keep this number of the largest connected components. The number of components removed. Release any unmanaged resources. Detects the edges that are considered to be sharp with respect to the given angle bound. A valid mesh. Angle in deg gives the maximum angle between the two normal vectors of adjacent triangles. For an edge of the input polygon mesh, if the angle between the two normal vectors of its incident facets is bigger than the given bound, then the edge is marked as being a feature edge. The halfedge indices of the edges that count as sharp. Detects the edges that are considered to be sharp with respect to the given angle bound. A valid mesh. Angle in deg gives the maximum angle between the two normal vectors of adjacent triangles. For an edge of the input polygon mesh, if the angle between the two normal vectors of its incident facets is bigger than the given bound, then the edge is marked as being a feature edge. The halfedge indices of the edges that count as sharp. Find the min, max and average edge lengths in the mesh. A valid mesh. The min, max and average edge lengths in the mesh. Find the min, max and average edge lengths in the mesh. A valid mesh. The min, max and average edge lengths in the mesh. Find the min, max and average face areas in the mesh. A valid mesh. The min, max and average face areas in the mesh. Find the min, max and average face areas in the mesh. A valid mesh. The min, max and average face areas in the mesh. Detects the sharp edges of mesh according to angle as the DetectSharpEdges function does. The sharp edges are then used to define a segmentation of a mesh, that is done by computing a surface patch id for each face. A valid mesh. Angle in deg gives the maximum angle between the two normal vectors of adjacent triangles. For an edge of the input polygon mesh, if the angle between the two normal vectors of its incident facets is bigger than the given bound, then the edge is marked as being a feature edge. The halfedge indices of the edges that count as sharp. The face indices for each patch found. Detects the sharp edges of pmesh according to angle as the DetectSharpEdges function does. The sharp edges are then used to define a segmentation of a mesh, that is done by computing a surface patch id for each face. A valid mesh. Angle in deg gives the maximum angle between the two normal vectors of adjacent triangles. For an edge of the input polygon mesh, if the angle between the two normal vectors of its incident facets is bigger than the given bound, then the edge is marked as being a feature edge. The face indices for each patch found. Release any unmanaged resources. Find a random point on mesh surface. The mesh. A random point on mesh surface. Find a random point on mesh surface. The mesh. A random point on mesh surface. Find the face the ray intersects with. The mesh. Th ray. The hit result with theface index, hit point and the barycentric coords. Find the face the ray intersects with. The mesh. Th ray. The hit result with theface index, hit point and the barycentric coords. Find the closest face to the point. The mesh. Th point. The hit result with the face index, closest point and the barycentric coords. Find the closest face to the point. The mesh. Th point. The hit result with the face index, closest point and the barycentric coords. Release any unmanaged resources. Fills output with a closed mesh bounding the volume swept by input when translating its vertices by dir. The mesh is oriented so that the faces corresponding to input in output have the same orientation. The a valid closed mesh. The direction vector. The extuded mesh. Fills output with a closed mesh bounding the volume swept by input when translating its vertices by dir. The mesh is oriented so that the faces corresponding to input in output have the same orientation. The a valid closed mesh. The direction vector. The extuded mesh. Fairs a region on a triangle mesh based on a ring of k vertices from the index vertex. The points of the selected vertices are relocated to yield an as-smooth-as-possible surface patch, based on solving a linear bi-Laplacian system with boundary constraints The region described by vertices might contain multiple disconnected components. Note that the mesh connectivity is not altered in any way, only vertex locations get updated. Fairing might fail if fixed vertices, which are used as boundary conditions, do not suffice to solve constructed linear system. Note that if the vertex range to which fairing is applied contains all the vertices of the triangle mesh, fairing does not fail, but the mesh gets shrinked to the origin. A valid triangle mesh. The vertex index in the mesh to start hthe k ring region from. The number of vertics to expand the region to. If the fairing was successfully run. Refines a triangle mesh A valid triangle mesh. a factor to control density of the output mesh, where larger values lead to denser refinements. Defalus to sqrt of 2. The number of new vertices added. Refines a triangle mesh A valid triangle mesh. a factor to control density of the output mesh, where larger values lead to denser refinements. Defalus to sqrt of 2. The number of new vertices added. Remeshes a triangulated region of a meshgon mesh. This operation sequentially performs edge splits, edge collapses, edge flips, tangential relaxation and projection to the initial surface to generate a smooth mesh with a prescribed edge length. A valid triangle mesh. The number of times to perform the remeshing. the edge length that is targeted in the remeshed patch. If 0 is passed then only the edge-flip, tangential relaxation, and projection steps will be done. The number of new vertices added. Remeshes a triangulated region of a meshgon mesh. This operation sequentially performs edge splits, edge collapses, edge flips, tangential relaxation and projection to the initial surface to generate a smooth mesh with a prescribed edge length. A valid triangle mesh. The number of times to perform the remeshing. the edge length that is targeted in the remeshed patch. If 0 is passed then only the edge-flip, tangential relaxation, and projection steps will be done. The number of new vertices added. randomly perturbs the locations of vertices of a triangulated surface mesh. By default, the vertices are re-projected onto the input surface after perturbation.Note that no geometric checks are done after the perturbation (face orientation might become incorrect and self-intersections might be introduced). A mesh. The maximun amount a vertex will be pertured. Must be greater tha 0. randomly perturbs the locations of vertices of a triangulated surface mesh. By default, the vertices are re-projected onto the input surface after perturbation.Note that no geometric checks are done after the perturbation (face orientation might become incorrect and self-intersections might be introduced). A mesh. The maximun amount a vertex will be pertured. Must be greater tha 0. Smooths a triangulated mesh. This function attempts to make the triangle angle and area distributions as uniform as possible by moving(non-constrained) vertices. Angle-based smoothing does not change the combinatorial information of the mesh. Area-based smoothing might change the combinatorial information, unless specified otherwise. It is also possible to make the smoothing algorithm "safer" by rejecting moves that, when applied, would worsen the quality of the mesh, e.g.that would decrease the value of the smallest angle around a vertex or create self-intersections. Optionally, the points are reprojected after each iteration. A valid triangle mesh. The edge angle that counts a feature and wont be smoothed. The number of iterations for the sequence of the smoothing iterations performed splits the edges listed in edges into sub-edges that are not longer than the given threshold max_length. Note this function is useful to split constrained edges before calling isotropic_remeshing() with protection of constraints activated (to match the constrained edge length required by the remeshing algorithm to be guaranteed to terminate) A valid mesh. The edge length above which an edge from edges is split into to sub-edges The number of new edges added to the mesh. splits the edges listed in edges into sub-edges that are not longer than the given threshold max_length. Note this function is useful to split constrained edges before calling isotropic_remeshing() with protection of constraints activated (to match the constrained edge length required by the remeshing algorithm to be guaranteed to terminate) A valid mesh. The edge length above which an edge from edges is split into to sub-edges The number of new edges added to the mesh. Triangulate a single face in the mesh. A valid mesh. The faces index in the mesh. True if successful. Triangulate a single face in the mesh. A valid mesh. The faces index in the mesh. True if successful. Triangulate a range of faces in the mesh. A valid mesh. The faces to triangulate. The length of the face array. True if successful. Triangulate a range of faces in the mesh. A valid mesh. The faces to triangulate. The length of the face array. True if successful. Release any unmanaged resources. Indicates if mesh bounds a volume. A closed triangle mesh. Indicates if mesh bounds a volume. A closed triangle mesh. Tests whether a closed triangle mesh has a positive orientation. A closed triangle mesh is considered to have a positive orientation if the normal vectors to all its faces point outside the domain bounded by the triangle mesh.The normal vector to each face is chosen pointing on the side of the face where its sequence of vertices is seen counterclockwise. A closed triangle mesh. Tests whether a closed triangle mesh has a positive orientation. A closed triangle mesh is considered to have a positive orientation if the normal vectors to all its faces point outside the domain bounded by the triangle mesh.The normal vector to each face is chosen pointing on the side of the face where its sequence of vertices is seen counterclockwise. A closed triangle mesh. Orient the faces in the mesh. The orientation method. A valid closed triangle mesh. Orient the faces in the mesh. The orientation method. A valid closed triangle mesh. Makes each connected component of a closed triangulated surface mesh inward or outward oriented. A closed triangle mesh. Makes each connected component of a closed triangulated surface mesh inward or outward oriented. A closed triangle mesh. Orients the connected components of tm to make it bound a volume. A closed triangle mesh. Orients the connected components of tm to make it bound a volume. A closed triangle mesh. Reverses for each face the order of the vertices along the face boundary. A valid mesh. Reverses for each face the order of the vertices along the face boundary. A valid mesh. Release any unmanaged resources. Find the number of degenerate edges in the mesh. The polygon mesh. The number of degenerate edges in the mesh. Find the number of degenerate faces in the mesh. A triangle polygon mesh. The number of degenerate faces in the mesh. Find the number of degenerate faces in the mesh. A triangle polygon mesh. The number of degenerate faces in the mesh. Checks whether a triangle face is needle. A triangle is said to be a needle if its longest edge is much longer than its shortest edge. A triangle polygon mesh. A bound on the ratio of the longest edge length and the shortest edge length. The number of needle triangles. Checks whether a triangle face is needle. A triangle is said to be a needle if its longest edge is much longer than its shortest edge. A triangle polygon mesh. A bound on the ratio of the longest edge length and the shortest edge length. The number of needle triangles. Collects the non-manifold vertices (if any) present in the mesh. A non-manifold vertex v is returned via one incident halfedge h such that target(h, pm) = v for all the umbrellas that v appears in (an umbrella being the set of faces incident to all the halfedges reachable by walking around v using hnext = prev(opposite(h, pm), pm), starting from h). A triangle polygon mesh. The non manifold vertex count. Collects the non-manifold vertices (if any) present in the mesh. A non-manifold vertex v is returned via one incident halfedge h such that target(h, pm) = v for all the umbrellas that v appears in (an umbrella being the set of faces incident to all the halfedges reachable by walking around v using hnext = prev(opposite(h, pm), pm), starting from h). A triangle polygon mesh. The non manifold vertex count. Cleans a given polygon soup through various repairing operations. More precisely, this function carries out the following tasks, in the same order as they are listed: merging of duplicate points. simplification of polygons to remove geometrically identical consecutive vertices; splitting of "pinched" polygons, that is polygons in which a geometric position appears more than once. The splitting process results in multiple non-pinched polygons; removal of invalid polygons, that is polygons with fewer than 2 vertices; removal of duplicate polygons. removal of isolated points. The polygon mesh. Cleans a given polygon soup through various repairing operations. More precisely, this function carries out the following tasks, in the same order as they are listed: merging of duplicate points. simplification of polygons to remove geometrically identical consecutive vertices; splitting of "pinched" polygons, that is polygons in which a geometric position appears more than once. The splitting process results in multiple non-pinched polygons; removal of invalid polygons, that is polygons with fewer than 2 vertices; removal of duplicate polygons. removal of isolated points. The polygon mesh. stitches together, whenever possible, two halfedges belonging to the same boundary cycle. Two border halfedges h1 and h2 can be stitched if the points associated to the source and target vertices of h1 are the same as those of the target and source vertices of h2, respectively. The polygon mesh. The number of stiched boundaries. stitches together, whenever possible, two halfedges belonging to the same boundary cycle. Two border halfedges h1 and h2 can be stitched if the points associated to the source and target vertices of h1 are the same as those of the target and source vertices of h2, respectively. The polygon mesh. The number of stiched boundaries. Stitches together border halfedges in a polygon mesh. The polygon mesh. The number of stiched borders. Stitches together border halfedges in a polygon mesh. The polygon mesh. The number of stiched borders. Removes the isolated vertices from any polygon mesh. A vertex is considered isolated if it is not incident to any simplex of higher dimension. The polygon mesh. The number of vertices that were removed. Removes the isolated vertices from any polygon mesh. A vertex is considered isolated if it is not incident to any simplex of higher dimension. The polygon mesh. The number of vertices that were removed. Release any unmanaged resources. Find the line formed from the intersection of the plane and the mesh. The mesh. Is not modified. The plane. The polylines from the intersection. Find the line formed from the intersection of the plane and the mesh. The mesh. Is not modified. The plane. The polylines from the intersection. Find the lines formed by slicing the mesh from the start point to the end point creating a plane at each increment. The mesh. Is not modified. The point to start from. The point to end at. Amount to increment each plane. he polylines from the intersection. Find the lines formed by slicing the mesh from the start point to the end point creating a plane at each increment. The mesh. Is not modified. The point to start from. The point to end at. Amount to increment each plane. he polylines from the intersection. Release any unmanaged resources. Simplify the mesh. A valid triangle mesh. A percentage 0-1 of edges to remove. Simplify the mesh. A valid triangle mesh. A percentage 0-1 of edges to remove. Release the unmanaged resourses. Subdive each face in the mesh. A valid mesh. Must be a triangle mesh for loop or sqrt3. The number of subdivision iterations. Subdive each face in the mesh. A valid mesh. Must be a triangle mesh for loop or sqrt3. The number of subdivision iterations. Subdive each face in the mesh. A valid mesh. The number of subdivision iterations. Subdive each face in the mesh. A valid mesh. The number of subdivision iterations. Subdive each face in the mesh. A valid triangle mesh. The number of subdivision iterations. Subdive each face in the mesh. A valid triangle mesh. The number of subdivision iterations. Subdive each face in the mesh. A valid triangle mesh. The number of subdivision iterations. Subdive each face in the mesh. A valid triangle mesh. The number of subdivision iterations. Subdive each face in the mesh. A valid triangle mesh. The number of subdivision iterations. Release the unmanaged resourses. Base triangulation class for Triangulation, DelaunayTriangulation, ConstrainedTriangulation and ConstrainedDelaunayTriangulation. The triangulations kernel. The number of verices in the triangulation. The number of triangles in the triangulation. The number of indices need to represent the triangulation (number of triangles * 3). A number that will change if the unmanaged triangulation model changes. Clear the triangulation. Is this a valid triangulation. True if valid. Force the face and vertex indices to be set. Inserts point p in the triangulation. If point coincides with an already existing vertex the triangulation remains unchanged. If point is on an edge, the two incident faces are split in two. If point is strictly inside a face of the triangulation, the face is split in three. If point is strictly outside the convex hull, p is linked to all visible points on the convex hull to form the new triangulation. The point to insert. Inserts points into the triangulation. If point coincides with an already existing vertex the triangulation remains unchanged. If point is on an edge, the two incident faces are split in two. If point is strictly inside a face of the triangulation, the face is split in three. If point is strictly outside the convex hull, p is linked to all visible points on the convex hull to form the new triangulation. The points to insert. The ararys length. Get a array of all the points in the triangulation. The point array. The ararys length. Get a array of the triangle indices. The ararys length. Get the vertices point. The vertex index. The vertices point. True if the vertex was found. Get the point. The points index. The point If point with the index not found. Get a vertex. The vertex index. The vertex. True if the vertex was found. Get the vertex. The vertexs index. The vertexs If vertex with the index not found. Get a array of all the vertices. The vertex array. The ararys length. Get a triangule face. The faces index The face True if the face was found. Get the face. The faces index. The Faces If face with the index not found. Get a array of all the triangle faces. A array of faces. The ararys length. Get the segment between the face and a neighbour. The faces index The neighbour (0-2) index in the face. The segment. True if the face was found. Get the segment between the face and a neighbour. The faces index The neighbour (0-2) index in the face. The segment If segment with the index not found. Get a faces triangle. The faces index The triangle True if the face was found Get the triangle. The triangles index. The triangle If triangle with the index not found. Get a array of all the triangles. A array of triangules. The ararys length. Get a faces circumcenter. The faces index The circumcenter. A circle that passes through all three of the triangules vertices. True if the face was found. Get the circumcenter. The circumcenters index. The circumcenter If circumcenter with the index not found. Get a array of all the circumcenters. A array of circumcenters. The ararys length. Get the index of the faces neighbour. The faces index. The neighbour (0-2) index in the face. The index of the neighbour face in the triangulation. -1 if there is no neighbour face at this index. Locate the face the point hits. The point. The face the point has hit. True if the point hit a face. Locate the closest vertex to point. The point The distance the point must be within to count as hitting the vertex. The closest vertex. True if point hit a face and found a vertex. Locate the closest edge and segment to point. The point The distance the point must be within to count as hitting the edge. The closest edge. True if the point hit a face and found a edge. Remove the vertex. The vertices index. True if removed. Flip a edge between the face and a neighbour. The faces index The neighbour (0-2) index in the face. True if the edge was flipped. Translate the triangulation. The amount to translate. Rotate the triangulation. The amount to rotate in radians. Scale the triangulation. The amount to scale. Transform the triangulation with a TRS matrix. The amount to translate. The amount to rotate. The amount to scale. Release any unmanaged resources. Base triangulation class for Triangulation, DelaunayTriangulation and ConstrainedTriangulation. The triangulations kernel. Returns the buildStamp. The build stamp will change if the triangulation model has changed Returns the dimension of the affine hull. Returns the number of vertices. Returns the number of finite vertices. Returns the number of cells or 0 if Dimension less than 3. The number of finite cells. Returns 0 if Dimension less than 3. The number of edges. Returns 0 if Dimension less than 1. The number of finite edges. Returns 0 if Dimension less than 1. The number of facets. Returns 0 if Dimension less than 2. The number of facets. Returns 0 if Dimension less than 2. The number of indices needed for the finite tetrahedrons. Clear the triangulation. Inserts the point p in the triangulation. If point p coincides with an already existing vertex the triangulation remains unchanged. If point p lies in the convex hull of the points, it is added naturally: if it lies inside a cell, the cell is split into four cells, if it lies on a facet, the two incident cells are split into three cells, if it lies on an edge, all the cells incident to this edge are split into two cells. If point p is strictly outside the convex hull but in the affine hull, p is linked to all visible points on the convex hull to form the new triangulation. If point p is outside the affine hull of the points, p is linked to all the points, and the dimension of the triangulation is incremented. All the points now belong to the boundary of the convex hull, so, the infinite vertex is linked to all the points to triangulate the new infinite face. The point to insert Insert all the points in the array. The points to insert. The arrays length Insert a vertex into a cell. The cells index. The point to insert. If the point query lies inside the convex hull of the points, the cell that contains the query in its interior is returned. If query lies on a facet, an edge or on a vertex, one of the cells having query on its boundary is returned. If the point query lies outside the convex hull of the points, an infinite cell with vertices { p,q,r,∞} is returned such that the tetrahedron(p, q, r, query) is positively oriented(the rest of the triangulation lies on the other side of facet (p, q, r)). Note that locate works even in degenerate dimensions: in dimension 2 (resp. 1, 0) the Cell_handle returned is the one that represents the facet(resp.edge, vertex) containing the query point. The optional argument start is used as a starting place for the search. The optional argument could_lock_zone is used by the concurrency-safe version of the triangulation.When the pointer is not null, the locate will try to lock all the cells along the walk. If it succeeds, could_lock_zone is true, otherwise it is false. In any case, the locked cells are not unlocked by locate, leaving this choice to the user. The point to query The cell thats closest to point. The closest cell to point. Get the centroids of each cell. The array of points The array of points length Get all the points in the triangulation. The array to copy into. The arrays length. Get all the points in the triangulation. The array to copy into. Get the triangulation vertices. The vertex array. The vertex array length. Get a triangulation vertex. The vertices index The vertex. Get the triangulation vertices. The vertex array. The vertex array length. Get a triangulation vertex. The vertices index The vertex. Get the indices of the cells edges in the triangulation. The indices array. The indices array length. Get the indices of the cells triangles in the triangulation. The indices array. The indices array length. Get the indices of the tetrahedron cells in the triangulation. The indices array. The indices array length. Translate each point in the mesh. The amount to translate. Rotate each point in the mesh. The amount to rotate. Scale each point in the mesh. The amount to scale. Transform each point in the mesh. The amount to translate. The amount to rotate. The amount to scale. Release any unmanaged resources. The generic constrained triangulation class. The kernel A static instance of the triangulation. The triangulation as a string. A deep copy of the triangulation. The deep copy. Compute the convex of the triagulation. The convex hull polygon. The abstract triangulation class. The kernel with the functions unique to the constrained triangulation. The number of constrainted edges in the triangulation. Move the vertex. The moved vertex True if the vertex was found. Insert the polygons points into the triangulation. May not retain the poylgons edges. Insert the polygons points into the triangulation. May not retain the poylgons edges. Insert the polygons points and the edges as constraints into the triangulation. Will retatin the poylgons edges. The polygon to insert. Insert the polygons points and the edges as constraints into the triangulation. Will retatin the poylgons edges. The polygon to insert. Get the number of constrainted edges incident to this vertex. The vertex index in the triagulation. The number of constrainted edges to the vertex. Does this vertex have a constrainted edge. The vertex index in the triagulation. Does this vertex have a constrainted edge. Add a segment as a constraint. The segment to add. Add the two points as a segment constraint. The segments point a. The segments point b. Add a list of segments as constraint to the triangulation. The segment array. The length of the segment array. Get a array of all the constraint edges in the triangulation. The edge array. The ararys length. Get a array of all the constraint segments in the triangulation. The segment array. The ararys length. Get the constraints incident to the vertex. The vertex index in the triangulation. The array of edges. The ararys length. Remove a constraint between a face and its neighbour. The faces index in the triangultion. The neighbours index in the faces neighbour array between 0-2. Remove all constraints incident to a vertex. The vertex index in the triangulation. Get the triangle indices for domain in the triangultion. Used to triangulate polygons. The indices. The generic constrained triangulation class. The kernel A static instance of the triangulation. The triangulation as a string. A deep copy of the triangulation. The deep copy. Compute the convex of the triagulation. The convex hull polygon. The abstract triangulation class. The kernel with the functions unique to the constrained triangulation. The number of constrainted edges in the triangulation. Move the vertex. The moved vertex True if the vertex was found. Insert the polygons points into the triangulation. May not retain the poylgons edges. Insert the polygons points into the triangulation. May not retain the poylgons edges. Insert the polygons points and the edges as constraints into the triangulation. Will retatin the poylgons edges. The polygon to insert. Insert the polygons points and the edges as constraints into the triangulation. Will retatin the poylgons edges. The polygon to insert. Get the number of constrainted edges incident to this vertex. The vertex index in the triagulation. The number of constrainted edges to the vertex. Does this vertex have a constrainted edge. The vertex index in the triagulation. Does this vertex have a constrainted edge. Add a segment as a constraint. The segment to add. Add the two points as a segment constraint. The segments point a. The segments point b. Add a list of segments as constraint to the triangulation. The segment array. The length of the segment array. Get a array of all the constraint edges in the triangulation. The edge array. The ararys length. Get a array of all the constraint segments in the triangulation. The segment array. The ararys length. Get the constraints incident to the vertex. The vertex index in the triangulation. The array of edges. The ararys length. Remove a constraint between a face and its neighbour. The faces index in the triangultion. The neighbours index in the faces neighbour array between 0-2. Remove all constraints incident to a vertex. The vertex index in the triangulation. Get the triangle indices for domain in the triangultion. Used to triangulate polygons. The indices. The generic delaunay triangulation class. The kerne A static instance of the delaunay triangulation. The triangulation as string. A deep copy of the triangulation. Insert the polygons points into the triangulation. May not retatin the poylgons edges. The polygon to insert. Insert the polygons points into the triangulation. May not retatin the poylgons edges. The polygon to insert. Compute the convex of the triagulation. The convex hull polygon. The anstract base class for the delaunay triangulation. The kernel with the functions unique to the delaunay triangulation. Move the vertex. If there is not already another vertex placed on the point, the triangulation is modified such that the new position of vertex same as point. The moved vertex True if the vertex was found. If the dual voronoi diagram of the triangulation is taken How many segments and rays would be produced. The number of segments. The number of rays. Get a array of the voronoi's segments. A array of the voronoi's segments. Get a array of the voronois rays. These are the segment at edge of triangulation that a end point can not be determined. A array of the voronoi's rays. Generic triangulation class. The kerel. Static instance of a triangulation. Default constructor. Construct a triangulation from the points. The triangulation points. Construct from a existing triangulation. A pointer to the unmanaged object. The triangulation as a string. Create a deep copy of the triangulation. The deep copy. Refine the triangulation. The target edge lengths. The number of iterations. Compute the convex of the triagulation. The convex hull polygon. Abstract base class for the triagulation. The kernel with the functions unique to the triangulation. Move a vertex. The vertices index. The point to move to. Should the vertex only be moved if there is no coliision. If the vertex was moved. Find the index of the nearest vertex to the point. The point. The index of the nearest vertex to the point. Find the index of the nearest vertex to the point. Presumes poimt is in a cell. The cells index. The point. The index of the nearest vertex to the point. Remobe a vertex. The vertex index. True if vertex was removed. Generic triangulation class. The kerel. Static instance of a triangulation. Default constructor. Construct a triangulation from the points. The triangulation points. Construct from a existing triangulation. A pointer to the unmanaged object. The triangulation as a string. Create a deep copy of the triangulation. The deep copy. Insert the points of the polygon into the triagulation. May no have the same edges as polygon. The polygon to insert/ Insert the points of the polygon into the triagulation. May no have the same edges as polygon. The polygon to insert/ Compute the convex of the triagulation. The convex hull polygon. Abstract base class for the triagulation. The kernel with the functions unique to the triangulation. Move the vertex. If there is not already another vertex placed on the point, the triangulation is modified such that the new position of vertex same as point. The moved vertex True if the vertex was found. Generic triangulation class. The kerel. Static instance of a triangulation. Default constructor. Construct a triangulation from the points. The triangulation points. Construct from a existing triangulation. A pointer to the unmanaged object. The triangulation as a string. Create a deep copy of the triangulation. The deep copy. Refine the triangulation. The target edge lengths. The number of iterations. Compute the convex of the triagulation. The convex hull polygon. Abstract base class for the triagulation. The kernel with the functions unique to the triangulation. From Index to HalfEdgeIndex must match layout of the unmanaged TriFace2 in the TriFace2 header file. Is this the infinite cell. The cells index in the triangulation. The cells 4 vertices. The cells 4 neighbor cells. Are the two cells equal. The first cell. The second cell. True if the cells are equal. Are the two cells not equal. The first cell. The second cell. True if the cells are not equal. Are these objects equal. The other object. True if the objects are equal. Are these cells equal. The other cell. True if the cells are equal. The cells hash code. The cells hash code. Get a vertex index. The vertices index 0-3. The vertices index in the triangulation. Get a neighbor cell index. The neighbor cell index 0-3. A neighbor cell index in the triangulation. Enumerate the vertices of the cell. The triangle the vertices below too. The cell vertices. Enumerate the vertices of the cell. The vertices array. The cell vertices. Enumerate the vertices of the cell. The triangle the vertices below too. The cell vertices. Enumerate the neighbors of the cell. The cell array. The cell neighbors. Are the two vertex arrays equal. Are the two neighbor arrays equal. From Index to TwinIndex must match layout of the unmanaged TriEdge2 in the TriEdge2 header file. The edges face index in the triangulation. The neighbours index in the face array betwen 0 and 2. The edges segment. The face index in the triangulation The neighbours index in the face array betwen 0 and 2. Are the two edges equal. The first edge. The second edge. True if the edges are equal. Are the two edges not equal. The first edge. The second edge. True if the edges are not equal. Are these objects equal. The other object. True if the objects are equal. Are these edges equal. The other edge. True if the edges are equal. The edges hash code. The edges hash code. From Index to HalfEdgeIndex must match layout of the unmanaged TriFace2 in the TriFace2 header file. Is this the infinite face. The faces index in the triangulation. The faces 3 vertices. Are the two faces equal. The first face. The second face. True if the faces are equal. Are the two faces not equal. The first face. The second face. True if the faces are not equal. Are these objects equal. The other object. True if the objects are equal. Are these faces equal. The other face. True if the faces are equal. The faces hash code. The faces hash code. Get a vertex index and wrap around array. The vertices index wrapped to 0-2. The vertices index in the triangulation. Enumerate the vertices of the face. The triangle the vertices below too. The face vertices. Enumerate the vertices of the face. The vertices array. The face vertices. From Point to HalfEdgeIndex must match layout of the unmanaged TriVertex2 in the TriVertex2 header file. The vertices point. Is this a infinite vertex. The number of egdes connected to the vertex. The vertices index in the triangulation. The one of the vertexs the vertex is connected to. Are the two vertexs equal. The first vertex. The second vertex. True if the vertexs are equal. Are the two vertexs not equal. The first vertex. The second vertex. True if the vertexs are not equal. Are these objects equal. The other object. True if the objects are equal. Are these vertexs equal. The other vertex. True if the vertexs are equal. The vertexs hash code. The vertexs hash code. The vertices point. Is this a infinte vertex. The vertices degree is the number of edges connecting to it. The vertices index in the triangulation. The one of the cells the vertex is connected to. Are the two vertices equal. The first vertex. The second vertex. True if the vertexs are equal. Are the two vertices not equal. The first vertex. The second vertex. True if the vertexs are not equal. Are these objects equal. The other object. True if the objects are equal. Are these vertexs equal. The other vertex. True if the vertexs are equal. The vertexs hash code. The vertexs hash code. Enumerate around all the other vertices in this vertexs cell. The triangulation the vertex belongs to. All the other vertices in this vertexs cell Enumerate around all the other vertices in this vertexs cell. A array of the other vertices in the triangulation. A array of the other cells in the triangulation. All the other vertices in this vertexs cell Cache to reuse arrays. Thread safe? Returns a array of Point2d objects that is at least the size of count. The minimum size of the array. Should the array be cleared first. Returns a array of Point2d objects that is at least the size of count. Returns a array of Segment2d objects that is at least the size of count. The minimum size of the array. Should the array be cleared first. Returns a array of Segment2d objects that is at least the size of count. Returns a array of Point3d objects that is at least the size of count. The minimum size of the array. Should the array be cleared first. Returns a array of Point3d objects that is at least the size of count. Returns a array of HPoint3d objects that is at least the size of count. The minimum size of the array. Should the array be cleared first. Returns a array of HPoint3d objects that is at least the size of count. Returns a array of ints that is at least the size of count. The minimum size of the array. Should the array be cleared first. Returns a array of ints that is at least the size of count. Returns a array of ints that is at least the size of count. The minimum size of the array. Should the array be cleared first. Returns a array of ints that is at least the size of count. Should a new array be created. The current array. The required new array size. Creates a new array if disabled, the current one is null or to small. Check a array that is passed to the c++ dll. If the array is invalid it will cause a hard crash. Array can be null if count is 0; ================================================ FILE: Binaries/CGALDotNetGeometry.xml ================================================ CGALDotNetGeometry Add two colors. Add vector and scalar. Add vector and scalar. Subtract two colors. Subtract vector and scalar. Subtract vector and scalar. Multiply two colors. Multiply a vector and a scalar. Multiply a vector and a scalar. Divide two colors. Divide a vector and a scalar. Are these colors equal. Are these colors not equal. Are these colors equal. Are these colors equal given the error. Are these colors equal. colors hash code. color as a string. color as a string. color from bytes. The distance between two colors. The square distance between two colors. Convert to RGB color space. Generates a list of colors with hues ranging from 0 360 and a saturation and value of 1. Add two colors. Add vector and scalar. Add vector and scalar. Subtract two colors. Subtract vector and scalar. Subtract vector and scalar. Multiply two colors. Multiply a vector and a scalar. Multiply a vector and a scalar. Divide two colors. Divide a vector and a scalar. Are these colors equal. Are these colors not equal. Are these colors equal. Are these colors equal given the error. Are these colors equal. colors hash code. color as a string. color as a string. color from bytes. The distance between two colors. The square distance between two colors. The minimum value between s and each component in vector. The maximum value between s and each component in vector. Clamp the each component to specified min and max. Lerp between two vectors. Convert to HSV color space. Create a palette of 6 colors from the rainbow. Create a palette of colors. Create a custom palette of hues with the same saturation and value. The number of hues in the palette. The saturation of the colors. The values of the colors. Add two colors. Add color and scalar. Add color and scalar. Subtract two colors. Subtract color and scalar. Subtract color and scalar. Multiply two colors. Multiply a color and a scalar. Multiply a color and a scalar. Divide two colors. Divide a color and a scalar. Are these colors equal. Are these colors not equal. Are these colors equal. Are these colors equal given the error. Are these colors equal. colors hash code. color as a string. color as a string. color from bytes. The distance between two colors. The square distance between two colors. color from ints. The minimum value between s and each component in vector. The maximum value between s and each component in vector. Clamp the each component to specified min and max. Lerp between two colors. Convert to HSV color space. Represents a angle in degrees. The angle in degrees. The degrees angle in radians. 0 degrees. 90 degrees. 180 degrees. 270 degrees. 360 degrees. Create a new degree from a value. The angle in degrees. Add two angles. Add angle and scalar. Negate the angle. Add angle and scalar. Subtract two angles. Subtract angle and scalar. Subtract angle and scalar. Multiply two angles. Multiply a angle and a scalar. Multiply a angle and a scalar. Divide two angles. Divide a angle and a scalar. Is the degree less than the scalar. Is the degree less than or equal to the scalar. Is the degree greater than the scalar. Is the degree greater than or equal to the scalar. Is the degree less than the other degree. Is the degree less than or equal to the other degree. Is the degree greater than the other degree. Is the degree greater than or equal to the other degree. Cast from a radian to degrees. The angle in radians. Are these angles equal. Are these angles not equal. Are these angles equal. Are these angles equal. Angles hash code. Angles as a string. Angles as a string. A rounded angle. The number of digits to round to. The rounded angle A Homogenous 2D point struct. The unit x point. The unit y point. A point of zeros. A point of ones. A point all with the value v. A point from the varibles. A point from the varibles. Array accessor for variables. The variables index. The variable value Are all the components of vector finite. Make a point with no non finite conponents. Are any of the points components nan. Make a point with no nan conponents. Convert from homogenous to cartesian space. Add two points. Add point and scalar. Add point and scalar. Multiply two points. Multiply a point and a scalar. Multiply a point and a scalar. Divide a point and a scalar. Divide a point and a scalar. Are these points equal. Are these points not equal. Are these points equal. Are these points equal. Are these points equal given the error. Vectors hash code. Vector as a string. Vector as a string. A rounded point. The number of digits to round to. The rounded point Round the point. The number of digits to round to. Floor each component if point. Ceilling each component if point. Create a array of random points. The seed The number of points to create. The number of points weight. The range of the points. The point array. A Homogenous 2D point struct. The unit x point. The unit y point. A point of zeros. A point of ones. A point all with the value v. A point from the varibles. A point from the varibles. A point from the varibles. Array accessor for variables. The variables index. The variable value Are all the components of vector finite. Make a point with no non finite conponents. Are any of the points components nan. Make a point with no nan conponents. Convert from homogenous to cartesian space. Add two points. Add point and scalar. Add point and scalar. Multiply two points. Multiply a point and a scalar. Multiply a point and a scalar. Divide a point and a scalar. Divide a point and a scalar. Are these points equal. Are these points not equal. Are these points equal. Are these points equal. Are these points equal given the error. Vectors hash code. Vector as a string. Vector as a string. A rounded point. The number of digits to round to. The rounded point Round the point. The number of digits to round to. Floor each component if point. Ceilling each component if point. Create a array of random points. The seed The number of points to create. The number of points weight. The range of the points. The point array. The unit x point. The unit y point. The unit z point. A point of zeros. A point of ones. A point of 0.5. A point of positive infinity. A point of negative infinity. A point all with the value v. A point all with the value v. A point from the varibles. A point from the varibles. Array accessor for variables. The variables index. The variable value Are all the components of vector finite. Make a point with no non finite conponents. Are any of the points components nan. Make a point with no nan conponents. Convert from homogenous to cartesian space. Point as vector. Point as vector. Add two points. Add point and scalar. Add point and scalar. Multiply two points. Multiply a point and a scalar. Multiply a point and a scalar. Divide a point and a scalar. Divide a point and a scalar. Are these points equal. Are these points not equal. Are these points equal. Are these points equal. Are these points equal given the error. Vectors hash code. Vector as a string. Vector as a string. A rounded point. The number of digits to round to. The rounded point Round the point. The number of digits to round to. Floor each component if point. Ceilling each component if point. Create a array of random points. The seed The number of points to create. The number of points weight. The range of the points. The point array. The unit x point. The unit y point. The unit z point. A point of zeros. A point of ones. A point of 0.5. A point of positive infinity. A point of negative infinity. A point all with the value v. A point all with the value v. A point from the varibles. A point from the varibles. A point from the varibles. Array accessor for variables. The variables index. The variable value Are all the components of vector finite. Make a point with no non finite conponents. Are any of the points components nan. Make a point with no nan conponents. Convert from homogenous to cartesian space. Point as vector. Point as vector. Add two points. Add point and scalar. Add point and scalar. Multiply two points. Multiply a point and a scalar. Multiply a point and a scalar. Divide a point and a scalar. Divide a point and a scalar. Are these points equal. Are these points not equal. Are these points equal. Are these points equal. Are these points equal given the error. Vectors hash code. Vector as a string. Vector as a string. A rounded point. The number of digits to round to. The rounded point Round the point. The number of digits to round to. Floor each component if point. Ceilling each component if point. Create a array of random points. The seed The number of points to create. The number of points weight. The range of the points. The point array. WARNING - Must match layout of unmanaged c++ CGAL struct in Index.h file. Wrap a value between 0 and count-1 (inclusive). Mirror a value between 0 and count-1 (inclusive). Is number a power of 2. Return the closest pow2 number to num. Return the closest pow2 number thats less than num. Simple int pow function. System Math.Pow may produce precision errors. Return the Binomial coefficients. N n Returns the factorial of number. Must be less than or equal MAX_FACTORIAL or overflow will occur. Returns the factorial of number using a BigInteger. Given N objects, how many unique sets exist. Given N objects, how many unique sets exist of size n where the order matters and objects may repeat. The size of the sets The total number of objects The number of sets possible Given N objects, how many unique sets exist of size n where the order does not matters and objects may repeat. The size of the sets The total number of objects The number of sets possible Given N objects, how many unique sets exist of size n where the order matters and objects may not repeat. The size of the sets The total number of objects The number of sets possible Given N objects, how many unique sets exist of size n where the order does not matters and objects may not repeat. The size of the sets The total number of objects The number of sets possible Creates a look up table for factorials. Matrix is column major. Data is accessed as: row + (column*2). Matrices can be indexed like 2D arrays but in an expression like mat[a, b], a refers to the row index, while b refers to the column index (note that this is the opposite way round to Cartesian coordinates). The matrix The matrix The Matrix Idenity. A matrix from the following varibles. A matrix from the following column vectors. A matrix from the following varibles. A matrix copied from a array of varibles. Access the varible at index i Is this the identity matrix. Access the varible at index ij The transpose of the matrix. The rows and columns are flipped. The determinate of a matrix. The inverse of the matrix. A matrix multipled by its inverse is the idenity. Add two matrices. Subtract two matrices. Multiply two matrices. Multiply a vector by a matrix. Multiply a point by a matrix. Multiply a matrix by a scalar. Multiply a matrix by a scalar. Cast to double matrix from a float matrix. The other matrix Are these matrices equal. Are these matrices not equal. Are these matrices equal. Are these matrices equal. Are these matrices equal. Matrices hash code. A matrix as a string. The Inverse of the matrix copied into mInv. Returns false if the matrix has no inverse. A matrix multipled by its inverse is the idenity. Get the ith column as a vector. Set the ith column from avector. Get the ith row as a vector. Set the ith row from avector. Create a rotation out of a angle. Convert to a float precision 3 dimension matrix. Matrix is column major. Data is accessed as: row + (column*2). Matrices can be indexed like 2D arrays but in an expression like mat[a, b], a refers to the row index, while b refers to the column index (note that this is the opposite way round to Cartesian coordinates). The matrix The matrix The Matrix Idenity. A matrix from the following varibles. A matrix from the following column vectors. A matrix from the following varibles. A matrix copied from a array of varibles. Access the varible at index i Access the varible at index ij Is this the identity matrix. The transpose of the matrix. The rows and columns are flipped. The determinate of a matrix. The inverse of the matrix. A matrix multipled by its inverse is the idenity. Add two matrices. Subtract two matrices. Multiply two matrices. Multiply a vector by a matrix. Multiply a point by a matrix. Multiply a matrix by a scalar. Multiply a matrix by a scalar. Cast to float matrix from a double matrix. The other matrix Are these matrices equal. Are these matrices not equal. Are these matrices equal. Are these matrices equal. Are these matrices equal. Matrices hash code. A matrix as a string. The Inverse of the matrix copied into mInv. Returns false if the matrix has no inverse. A matrix multipled by its inverse is the idenity. Get the ith column as a vector. Set the ith column from avector. Get the ith row as a vector. Set the ith row from avector. Create a rotation out of a angle. Convert to a single precision 3 dimension matrix. Matrix is column major. Data is accessed as: row + (column*3). Matrices can be indexed like 2D arrays but in an expression like mat[a, b], a refers to the row index, while b refers to the column index (note that this is the opposite way round to Cartesian coordinates). The matrix The matrix The matrix The Matrix Idenity. A matrix from the following varibles. A matrix from the following column vectors. A matrix from the following varibles. A matrix copied from a array of varibles. Is this the identity matrix. Does the matric have scale. Access the varible at index i Access the varible at index ij The transpose of the matrix. The rows and columns are flipped. The determinate of a matrix. The inverse of the matrix. A matrix multipled by its inverse is the idenity. Add two matrices. Subtract two matrices. Multiply two matrices. Multiply a vector by a matrix. Multiply a vector by a matrix. Multiply a point by a matrix. Multiply a point by a matrix. Multiply a matrix by a scalar. Multiply a matrix by a scalar. Cast to double matrix from a float matrix. The other matrix Are these matrices equal. Are these matrices not equal. Are these matrices equal. Are these matrices equal. Are these matrices equal. Matrices hash code. A matrix as a string. The Inverse of the matrix copied into mInv. Returns false if the matrix has no inverse. A matrix multipled by its inverse is the idenity. Invert a 3x3 using cofactors. This is about 8 times faster than the Numerical Recipes code which uses Gaussian elimination. Get the ith column as a vector. Set the ith column from avector. Get the ith row as a vector. Set the ith row from avector. Convert to a REAL precision 4 dimension matrix. Create a translation out of a vector. Create a translation out of a point. Create a scale out of a vector. Create a scale out of a point. Create a scale out of a vector. Create a rotation out of a angle. Create a rotation out of a angle. Create a rotation out of a angle. Create a rotation out of a vector. Matrix is column major. Data is accessed as: row + (column*3). Matrices can be indexed like 2D arrays but in an expression like mat[a, b], a refers to the row index, while b refers to the column index (note that this is the opposite way round to Cartesian coordinates). The matrix The matrix The matrix The Matrix Idenity. A matrix from the following varibles. A matrix from the following column vectors. A matrix from the following varibles. A matrix copied from a array of varibles. Access the varible at index i Access the varible at index ij Is this the identity matrix. Does the matric have scale. The transpose of the matrix. The rows and columns are flipped. The determinate of a matrix. The inverse of the matrix. A matrix multipled by its inverse is the idenity. Add two matrices. Subtract two matrices. Multiply two matrices. Multiply a vector by a matrix. Multiply a vector by a matrix. Multiply a point by a matrix. Multiply a point by a matrix. Multiply a matrix by a scalar. Multiply a matrix by a scalar. Cast to float matrix from a double matrix. The other matrix Are these matrices equal. Are these matrices not equal. Are these matrices equal. Are these matrices equal. Are these matrices equal. Matrices hash code. A matrix as a string. The Inverse of the matrix copied into mInv. Returns false if the matrix has no inverse. A matrix multipled by its inverse is the idenity. Invert a 3x3 using cofactors. This is about 8 times faster than the Numerical Recipes code which uses Gaussian elimination. Get the ith column as a vector. Set the ith column from avector. Get the ith row as a vector. Set the ith row from avector. Convert to a single precision 4 dimension matrix. Create a translation out of a vector. Create a translation out of a point. Create a scale out of a vector. Create a scale out of a point. Create a scale out of a vector. Create a rotation out of a angle. Create a rotation out of a angle. Create a rotation out of a angle. Create a rotation out of a vector. Matrix is column major. Data is accessed as: row + (column*4). Matrices can be indexed like 2D arrays but in an expression like mat[a, b], a refers to the row index, while b refers to the column index (note that this is the opposite way round to Cartesian coordinates). The matrix The matrix The matrix The matrix The Matrix Idenity. A matrix from the following varibles. A matrix from the following column vectors. A matrix from the following varibles. A matrix copied from a array of varibles. Access the varible at index i Access the varible at index ij Is this the identity matrix. Does the matric have scale. The transpose of the matrix. The rows and columns are flipped. The determinate of a matrix. The adjoint of a matrix. The inverse of the matrix. A matrix multipled by its inverse is the idenity. Add two matrices. Subtract two matrices. Multiply two matrices. Multiply a vector by a matrix. Acts like z is 0, and w is 0. Multiply a vector by a matrix. Acts like w is 0. Multiply a point by a matrix. Acts like z is 0, and w is 1. Multiply a point by a matrix. Acts like w is 1. Multiply a vector by a matrix. Multiply a point by a matrix. Multiply a matrix by a scalar. Multiply a matrix by a scalar. Cast to double matrix from a float matrix. The other matrix Are these matrices equal. Are these matrices not equal. Are these matrices equal. Are these matrices equal. Are these matrices equal. Matrices hash code. A matrix as a string. The minor of a matrix. The inverse of the matrix. A matrix multipled by its inverse is the idenity. Get the ith column as a vector. Set the ith column from a vector. Get the ith row as a vector. Set the ith row from a vector. Convert to a 3 dimension matrix. Create a translation, rotation and scale. Create a translation and rotation. Create a translation and scale. Create a rotation and scale. Create a translation out of a vector. Create a scale out of a vector. Create a scale out of a vector. Create a rotation out of a angle in degrees. Create a rotation out of a angle in degrees. Create a rotation out of a angle in degrees. Create a rotation out of a vector. Create a perspective matrix. Create a ortho matrix. Creates the matrix need to look at target from position. Matrix is column major. Data is accessed as: row + (column*4). Matrices can be indexed like 2D arrays but in an expression like mat[a, b], a refers to the row index, while b refers to the column index (note that this is the opposite way round to Cartesian coordinates). The matrix The matrix The matrix The matrix The Matrix Idenity. A matrix from the following varibles. A matrix from the following column vectors. A matrix from the following varibles. A matrix copied from a array of varibles. Access the varible at index i Access the varible at index ij Is this the identity matrix. Does the matric have scale. The transpose of the matrix. The rows and columns are flipped. The determinate of a matrix. The adjoint of a matrix. The inverse of the matrix. A matrix multipled by its inverse is the idenity. Add two matrices. Subtract two matrices. Multiply two matrices. Multiply a vector by a matrix. Acts like z is 0, and w is 0. Multiply a vector by a matrix. Acts like w is 0. Multiply a point by a matrix. Acts like z is 0, and w is 1. Multiply a point by a matrix. Acts like w is 1. Multiply a vector by a matrix. Multiply a point by a matrix. Multiply a matrix by a scalar. Multiply a matrix by a scalar. Cast to float matrix from a double matrix. The other matrix Are these matrices equal. Are these matrices not equal. Are these matrices equal. Are these matrices equal. Are these matrices equal. Matrices hash code. A matrix as a string. The minor of a matrix. The inverse of the matrix. A matrix multipled by its inverse is the idenity. Get the ith column as a vector. Set the ith column from a vector. Get the ith row as a vector. Set the ith row from a vector. Convert to a 3 dimension matrix. Create a translation, rotation and scale. Create a translation and rotation. Create a translation and scale. Create a rotation and scale. Create a translation out of a vector. Create a scale out of a vector. Create a scale out of a vector. Create a rotation out of a angle in degrees. Create a rotation out of a angle in degrees. Create a rotation out of a angle in degrees. Create a rotation out of a vector. Create a perspective matrix. Create a ortho matrix. Creates the matrix need to look at target from position. The unit x point. The unit y point. A point of zeros. A point of ones. A point of 0.5. A point of positive infinity. A point of negative infinity. 2D point to 3D point with z as 0. 2D point to 3D point with y as z. 2D point to 3D point with z as 1. 2D point to 4D point with z as 0 and w as 0. 2D point to 4D point with z as 0 and w as 1. A point all with the value v. A point from the varibles. Array accessor for variables. The variables index. The variable value Are all the components ofpoint finite. Make a point with no non finite conponents. Are any of the points components nan. Make a point with no nan conponents. Point as a vector. Point as a homogenous point. Point as a homogenous point. The sum of the points components. The product of the points components. The points absolute values. The length of the vector. The length of the vector squared. Add two point and vector. Add two points. Add point and scalar. Add point and scalar. Negate point. Subtract two points. Subtract a point and a vector. Subtract point and scalar. Subtract point and scalar. Multiply two points. Multiply a point and a scalar. Multiply a point and a scalar. Divide two points. Divide a point and a scalar. Divide a scalar and a point. Cast from Point2f to Point2d. Cast from Point2i to Point2d. Are these points equal. Are these points not equal. Are these points equal. Are these points equal given the error. Are these points equal. Vectors hash code. Vector as a string. Vector as a string. Distance between two points. Square distance between two points. Direction between two points. The first point. The second point. Should the vector be normalized. The vector from v0 to v1. The minimum value between s and each component in point. The minimum value between each component in points. The maximum value between s and each component in point. The maximum value between each component in points. Clamp each component to specified min and max. Clamp each component to specified min and max. Lerp between two points. A rounded point. The number of digits to round to. The rounded point Round the point. The number of digits to round to. Floor each component if point. Ceilling each component if point. Create a array of random points. The seed The number of points to create. The range of the points. The point array. The unit x point. The unit y point. A point of zeros. A point of ones. A point of 0.5. A point of positive infinity. A point of negative infinity. 2D point to 3D point with z as 0. 2D point to 3D point with y as z. 2D point to 3D point with z as 1. 2D point to 4D point with z as 0 and w as 0. 2D point to 4D point with z as 0 and w as 1. A point all with the value v. A point from the varibles. A point from the varibles. Array accessor for variables. The variables index. The variable value Are all the components of point finite. Make a point with no non finite conponents. Are any of the points components nan. Make a point with no nan conponents. Point as a vector. The sum of the points components. The product of the points components. The points absolute values. The length of the point. The length of the vector squared. Add two point and vector. Add two points. Add point and scalar. Add point and scalar. Negate point. Subtract two points. Subtract a point and a vector. Subtract point and scalar. Subtract point and scalar. Multiply two points. Multiply a point and a scalar. Multiply a point and a scalar. Divide two points. Divide a point and a scalar. Divide a scalar and a point. Cast from Point2d to Point2f. Cast from Point2i to Point2f. Are these points equal. Are these points not equal. Are these points equal. Are these points equal given the error. Are these points equal. Vectors hash code. Vector as a string. Vector as a string. Distance between two points. Square distance between two points. Direction between two points. The first point. The second point. Should the vector be normalized. The vector from v0 to v1. The minimum value between s and each component in point. The minimum value between each component in points. The maximum value between s and each component in point. The maximum value between each component in points. Clamp each component to specified min and max. Clamp each component to specified min and max. Lerp between two points. A rounded point. The number of digits to round to. The rounded point Round the point. The number of digits to round to. Floor each component if point. Ceilling each component if point. Create a array of random points. The seed The number of points to create. The range of the points. The point array. The unit x point. The unit y point. A point of zeros. A point of ones. A point of positive infinity. A point of negative infinity. 2D point to 3D point with z as 0. 2D point to 3D point with y as z. 2D point to 3D point with z as 1. 2D point to 4D point with z as 0 and w as 0. 2D point to 4D point with z as 0 and w as 1. A point all with the value v. A point from the varibles. Array accessor for variables. The variables index. The variable value Convert to float vector. Convert to double vector. Convert to float point. Convert to double point. The sum of the points components. The product of the points components. The points absolute values. The length of the point squared. Add two points. Add point and scalar. Add point and scalar. Negate point. Subtract two points. Subtract point and scalar. Subtract point and scalar. Multiply two points. Multiply a point and a scalar. Multiply a point and a scalar. Divide two points. Divide a point and a scalar. Divide a scalar and a point. Cast from Point2f to Point2i. Cast from Point2d to Point2i. Are these points equal. Are these points not equal. Are these points equal. Are these points equal. Vectors hash code. Vector as a string. Vector as a string. Distance between two points. Square distance between two points. Direction between two points. The minimum value between s and each component in point. The minimum value between each component in points. The maximum value between s and each component in point. The maximum value between each component in points. Clamp each component to specified min and max. Clamp each component to specified min and max. The unit x point. The unit y point. The unit z point. A point of zeros. A point of ones. A point of 0.5. A point of positive infinity. A point of negative infinity. 3D point to 3D swizzle point. 3D point to 2D point. 3D point to 2D point. 3D point to 2D point. 3D point to 4D point with w as 0. 3D point to 4D point with w as 1. A point all with the value v. A point from the varibles. Array accessor for variables. The variables index. The variable value Are all the components ofpoint finite. Make a point with no non finite conponents. Are any of the points components nan. Make a point with no nan conponents. Point as vector. Point as vector. Point as a homogenous point. Point as a homogenous point. The sum of the points components. The product of the points components. The points absolute values. The length of the vector. The length of the vector squared. Add two point and vector. Add two points. Add point and scalar. Add point and scalar. Negate point. Subtract two points. Subtract a point and a vector. Subtract point and scalar. Subtract point and scalar. Multiply two points. Multiply a point and a scalar. Multiply a point and a scalar. Divide two points. Divide a scalar and a point. Divide a point and a scalar. Cast from Point43f to Point3d. Cast from Point3i to Point3d. Are these points equal. Are these points not equal. Are these points equal. Are these points equal. Are these points equal given the error. Vectors hash code. Vector as a string. Vector as a string. Distance between two points. Square distance between two points. Direction between two points. The first point. The second point. Should the vector be normalized. The vector from v0 to v1. The minimum value between s and each component in point. The minimum value between each component in points. The maximum value between s and each component in point. The maximum value between each component in points. Clamp each component to specified min and max. Clamp each component to specified min and max. Lerp between two points. A rounded point. The number of digits to round to. The rounded point Round the point. The number of digits to round to. Floor each component if point. Ceilling each component if point. Create a array of random points. The seed The number of points to create. The range of the points. The point array. The unit x point. The unit y point. The unit z point. A point of zeros. A point of ones. A point of 0.5. A point of positive infinity. A point of negative infinity. 3D point to 3D swizzle point. 3D point to 2D point. 3D point to 2D point. 3D point to 2D point. 3D point to 4D point with w as 0. 3D point to 4D point with w as 1. A point all with the value v. A point from the varibles. A point from the varibles. Array accessor for variables. The variables index. The variable value Are all the components ofpoint finite. Make a point with no non finite conponents. Are any of the points components nan. Make a point with no nan conponents. Point as vector. Point as vector. The sum of the points components. The product of the points components. The points absolute values. The length of the vector. The length of the vector squared. Add two point and vector. Add two points. Add point and scalar. Add point and scalar. Negate point. Subtract two points. Subtract a point and a vector. Subtract point and scalar. Subtract point and scalar. Multiply two points. Multiply a point and a scalar. Multiply a point and a scalar. Divide two points. Divide a point and a scalar. Divide a scalar and a point. Cast from Point3d to Point3f. Cast from Point3i to Point3f. Are these points equal. Are these points not equal. Are these points equal. Are these points equal. Are these points equal given the error. Vectors hash code. Vector as a string. Vector as a string. Distance between two points. Square distance between two points. Direction between two points. The first point. The second point. Should the vector be normalized. The vector from v0 to v1. The minimum value between s and each component in point. The minimum value between each component in points. The maximum value between s and each component in point. The maximum value between each component in points. Clamp each component to specified min and max. Clamp each component to specified min and max. Lerp between two points. A rounded point. The number of digits to round to. The rounded point Round the point. The number of digits to round to. Floor each component if point. Ceilling each component if point. Create a array of random points. The seed The number of points to create. The range of the points. The point array. The unit x point. The unit y point. The unit z point. A point of zeros. A point of ones. A point of positive infinity. A point of negative infinity. 3D point to 3D swizzle point. 3D point to 2D point. 3D point to 2D point. 3D point to 4D point with w as 0. 3D point to 4D point with w as 1. A point all with the value v. A point from the varibles. Array accessor for variables. The variables index. The variable value Convert to float vector. Convert to double vector. Convert to float point. Convert to double point. The sum of the points components. The product of the points components. The points absolute values. The length of the vector squared. Add two points. Add point and scalar. Add point and scalar. Negate point. Subtract two points. Subtract point and scalar. Subtract point and scalar. Multiply two points. Multiply a point and a scalar. Multiply a point and a scalar. Divide two points. Divide a point and a scalar. Divide a scalar and a point. Cast from Point3f to Point3i. Cast from Point3d to Point3i. Are these points equal. Are these points not equal. Are these points equal. Are these points equal. Vectors hash code. Vector as a string. Vector as a string. Distance between two points. Square distance between two points. Direction between two points. The minimum value between s and each component in point. The minimum value between each component in points. The maximum value between s and each component in point. The maximum value between each component in points. Clamp each component to specified min and max. Clamp each component to specified min and max. The unit x point. The unit y point. The unit z point. The unit z point. A point of zeros. A point of ones. A point of 0.5. A point of positive infinity. A point of negative infinity. 4D point to 2D point. 4D point to 3D point. A point all with the value v. A point from the varibles. Array accessor for variables. The variables index. The variable value Are all the components ofpoint finite. Make a point with no non finite conponents. Are any of the points components nan. Make a point with no nan conponents. Point as vector. Point as vector. The sum of the points components. The product of the points components. The points absolute values. The length of the vector. The length of the vector squared. Add two points. Add a point and a vector. Add point and scalar. Add point and scalar. Negate point. Subtract two points. Add a point and a vector. Subtract point and scalar. Subtract point and scalar. Multiply two points. Multiply a point and a scalar. Multiply a point and a scalar. Divide two points. Divide a point and a scalar. Divide a scalar and a point. Cast from Point4f to Point4d. Cast from Point4i to Point4d. Are these points equal. Are these points not equal. Are these points equal. Are these points equal. Are these points equal given the error. Vectors hash code. Vector as a string. Vector as a string. Distance between two points. Square distance between two points. Direction between two points. The first point. The second point. Should the vector be normalized. The vector from v0 to v1. The minimum value between s and each component in point. The minimum value between each component in points. The maximum value between s and each component in point. The maximum value between each component in points. Clamp each component to specified min and max. Clamp each component to specified min and max. Lerp between two points. A rounded point. The number of digits to round to. The rounded point Round the point. The number of digits to round to. Floor each component if point. Ceilling each component if point. The unit x point. The unit y point. The unit z point. The unit z point. A point of zeros. A point of ones. A point of 0.5. A point of positive infinity. A point of negative infinity. 4D point to 2D point. 4D point to 3D point. A point all with the value v. A point from the varibles. A point from the varibles. Array accessor for variables. The variables index. The variable value Are all the components of point finite. Make a point with no non finite conponents. Are any of the points components nan. Make a point with no nan conponents. Point as vector. Point as vector. The sum of the points components. The product of the points components. The points absolute values. The length of the vector. The length of the vector squared. Add two points. Add a point and a vector. Add point and scalar. Add point and scalar. Negate point. Subtract two points. Subtract a point and a vector. Subtract point and scalar. Subtract point and scalar. Multiply two points. Multiply a point and a scalar. Multiply a point and a scalar. Divide two points. Divide a point and a scalar. Divide a scalar and a point. Cast from Point4d to Point4f. Cast from Point4i to Point4f. Are these points equal. Are these points not equal. Are these points equal. Are these points equal. Are these points equal given the error. Vectors hash code. Vector as a string. Vector as a string. Distance between two points. Square distance between two points. Direction between two points. The first point. The second point. Should the vector be normalized. The vector from v0 to v1. The minimum value between s and each component in point. The minimum value between each component in points. The maximum value between s and each component in point. The maximum value between each component in points. Clamp each component to specified min and max. Clamp each component to specified min and max. Lerp between two points. A rounded point. The number of digits to round to. The rounded point Round the point. The number of digits to round to. Floor each component if point. Ceilling each component if point. The unit x point. The unit y point. The unit z point. The unit z point. A point of zeros. A point of ones. A point of positive infinity. A point of negative infinity. 4D point to 2D point. 4D point to 3D point. A point all with the value v. A point from the varibles. Array accessor for variables. The variables index. The variable value Convert to float vector. Convert to double vector. Convert to float point. Convert to double point. The sum of the points components. The product of the points components. The points absolute values. The length of the vector squared. Add two points. Add point and scalar. Add point and scalar. Negate point. Subtract two points. Subtract point and scalar. Subtract point and scalar. Multiply two points. Multiply a point and a scalar. Multiply a point and a scalar. Divide two points. Divide a point and a scalar. Divide a scalar and a point. Cast from Point4f to Point4i. Cast from Point4d to Point4i. Are these points equal. Are these points not equal. Are these points equal. Are these points equal. Vectors hash code. Vector as a string. Vector as a string. The minimum value between s and each component in point. The minimum value between each component in points. The maximum value between s and each component in point. The maximum value between each component in points. Clamp each component to specified min and max. Clamp each component to specified min and max. A Quaternion from varibles. A Quaternion from a vector axis and angle. The axis is the up direction and the angle is the rotation. A quaternion with the rotation required to rotation from the from direction to the to direction. Returns the conjugate of a quaternion value. The inverse of the quaternion. The length of the quaternion. The sqr length of the quaternion. The a normalized quaternion. Subtract a quaternion and a scalar. Negate a quaternion. Subtract two quaternions. Add a quaternion and a scalar. Add two quaternions. Multiply a quaternion and a scalar. Divide a quaternion and a scalar. Multiply two quternions together. Multiply a quaternion and a vector together. Multiply a quaternion and a vector together. Are these Quaternions equal. Are these Quaternions not equal. Are these Quaternions equal. Are these Quaternions equal. Quaternions hash code. Quaternion as a string. Quaternion as a string. Convert to a single precision 3 dimension matrix. Convert to a single precision 4 dimension matrix. The normalize the quaternion. The dot product of two quaternion.. Slerp the quaternion from the from rotation to the to rotation by t. Create a rotation out of a vector. Uses Unity euler axis (+x right, +y up, +z forward) Returns a 4x4 matrix that rotates around the x-axis by a given number of degrees. The clockwise rotation angle when looking along the x-axis towards the origin in degrees. Returns a 4x4 matrix that rotates around the y-axis by a given number of degrees. The clockwise rotation angle when looking along the y-axis towards the origin in degrees. Returns a 4x4 matrix that rotates around the z-axis by a given number of degrees. The clockwise rotation angle when looking along the z-axis towards the origin in degrees. A Quaternion from varibles. A Quaternion from varibles. A Quaternion from a vector axis and angle. The axis is the up direction and the angle is the rotation. A quaternion with the rotation required to rotation from the from direction to the to direction. Returns the conjugate of a quaternion value. The inverse of the quaternion. The length of the quaternion. The sqr length of the quaternion. The a normalized quaternion. Subtract a quaternion and a scalar. Subtract two quaternions. Negate a quaternion. Add a quaternion and a scalar. Add two quaternions. Multiply a quaternion and a scalar. Divide a quaternion and a scalar. Multiply two quaternions together. Multiply a quaternion and a vector together. Multiply a quaternion and a vector together. Are these Quaternions equal. Are these Quaternions not equal. Are these Quaternions equal. Are these Quaternions equal. Quaternions hash code. Quaternion as a string. Quaternion as a string. Convert to a single precision 3 dimension matrix. Convert to a single precision 4 dimension matrix. The normalize the quaternion. The dot product of two quaternion.. Slerp the quaternion from the from rotation to the to rotation by t. Create a rotation out of a vector. Uses Unity euler axis (+x right, +y up, +z forward) Returns a 4x4 matrix that rotates around the x-axis by a given number of degrees. The clockwise rotation angle when looking along the x-axis towards the origin in degrees. Returns a 4x4 matrix that rotates around the y-axis by a given number of degrees. The clockwise rotation angle when looking along the y-axis towards the origin in degrees. Returns a 4x4 matrix that rotates around the z-axis by a given number of degrees. The clockwise rotation angle when looking along the z-axis towards the origin in degrees. Represents a angle in degrees. The angle in radians. The radian angle in degees. Pi. 0 degrees. 90 degrees. 90 degrees. 180 degrees. 270 degrees. 360 degrees. Create a new radian from a value. The angle in radians. Add two angles. Add angle and scalar. Negate the angle. Add angle and scalar. Subtract two angles. Subtract angle and scalar. Subtract angle and scalar. Multiply two angles. Multiply a angle and a scalar. Is the radian less than the scalar. Is the radian less than or equal to the scalar. Is the radian greater than the scalar. Is the radian greater than or equal to the scalar. Is the radian less than the other radian. Is the radian less than or equal to the other radian. Is the radian greater than the other radian. Is the radian greater than or equal to the other radian. Multiply a angle and a scalar. Cast from a degrees to radians. The angle in radians. Are these angles equal. Are these angles not equal. Are these angles equal. Are these angles equal. Angles hash code. Angles as a string. Angles as a string. A rounded angle. The number of digits to round to. The rounded angle The unit x vector. The unit y vector. A vector of zeros. A vector of ones. A vector of 0.5. A vector of positive infinity. A vector of negative infinity. Convert to a 3 dimension vector. Convert to a 3 dimension vector. Convert to a 4 dimension vector. Convert to a 4 dimension vector. A vector all with the value v. A vector from the varibles. Are all the components of vector finite. Make a vector with no non finite conponents. Are any of the vectors components nan. Make a vector with no nan conponents. Convert the vector to a point. The sum of the vectors components. The product of the vectors components. The length of the vector. The length of the vector squared. The vector normalized. Counter clock-wise perpendicular. Clock-wise perpendicular. The vectors absolute values. Add two vectors. Add vector and scalar. Add vector and scalar. Negate vector. Subtract two vectors. Subtract vector and scalar. Subtract vector and scalar. Multiply two vectors. Multiply a vector and a scalar. Multiply a vector and a scalar. Divide two vectors. Divide a vector and a scalar. Divide a scalar and a vector. Cast from Vector2f to Vector2f. Are these vectors equal. Are these vectors not equal. Are these vectors equal. Are these vectors equal given the error. Are these vectors equal. Vectors hash code. Compare two vectors by axis. Vector as a string. Vector as a string. The dot product of two vectors. The dot product of vector and point. The abs dot product of two vectors. Normalize the vector. Cross two vectors. Project vector v onto u. Given an incident vector i and a normal vector n. Returns the refraction vector given the incident vector i, the normal vector n and the refraction index eta. Angle between two vectors in degrees from 0 to 180. A and b origin treated as 0,0 and do not need to be normalized. Angle between two vectors in degrees from 0 to 360. Angle represents moving ccw from a to b. A and b origin treated as 0,0 and do not need to be normalized. The minimum value between s and each component in vector. The minimum value between each component in vectors. The maximum value between s and each component in vector. The maximum value between each component in vectors. Clamp each component to specified min and max. Clamp each component to specified min and max. Lerp between two vectors. Slerp between two vectors arc. Round vector. number of digits to round to. Round the vector. The number of digits to round to. Floor each component of vector. Ceilling each component of vector. The unit x vector. The unit y vector. A vector of zeros. A vector of ones. A vector of 0.5. A vector of positive infinity. A vector of negative infinity. Convert to a 3 dimension vector. Convert to a 3 dimension vector. Convert to a 4 dimension vector. Convert to a 4 dimension vector. A vector all with the value v. A vector from the variables. A vector from the varibles. Are all the components of vector finite. Make a vector with no non finite conponents. Are any of the vectors components nan. Make a vector with no nan conponents. Convert the vector to a point. The sum of the vectors components. The product of the vectors components. The length of the vector. The length of the vector squared. The vector normalized. Counter clock-wise perpendicular. Clock-wise perpendicular. The vectors absolute values. Add two vectors. Add vector and scalar. Add vector and scalar. Negate vector. Subtract two vectors. Subtract vector and scalar. Subtract vector and scalar. Multiply two vectors. Multiply a vector and a scalar. Multiply a vector and a scalar. Divide two vectors. Divide a vector and a scalar. Divide a scalar and a vector. Cast from Vector2d to Vector2f. Are these vectors equal. Are these vectors not equal. Are these vectors equal. Are these vectors equal given the error. Are these vectors equal. Vectors hash code. Compare two vectors by axis. Vector as a string. Vector as a string. The dot product of two vectors. The dot product of vector and point. The abs dot product of two vectors. Normalize the vector. Cross two vectors. Project vector v onto u. Given an incident vector i and a normal vector n. Returns the refraction vector given the incident vector i, the normal vector n and the refraction index eta. Angle between two vectors in degrees from 0 to 180. A and b origin treated as 0,0 and do not need to be normalized. Angle between two vectors in degrees from 0 to 360. Angle represents moving ccw from a to b. A and b origin treated as 0,0 and do not need to be normalized. The minimum value between s and each component in vector. The minimum value between each component in vectors. The maximum value between s and each component in vector. The maximum value between each component in vectors. Clamp each component to specified min and max. Clamp each component to specified min and max. Lerp between two vectors. Slerp between two vectors arc. Round vector. number of digits to round to. Round the vector. The number of digits to round to. Floor each component of vector. Ceilling each component of vector. The unit x vector. The unit y vector. The unit z vector. A vector of zeros. A vector of ones. A vector of 0.5. A vector of positive infinity. A vector of negative infinity. 3D vector to 3D swizzle vector. 3D vector to 2D vector. 3D vector to 2D vector. 3D vector to 2D vector. 3D vector to 4D vector with w as 0. 3D vector to 4D vector with w as 1. A vector all with the value v. A vector from the varibles. A vector from a 2d vector and the z varible. Are all the components of vector finite. Make a vector with no non finite conponents. Are any of the vectors components nan. Make a vector with no nan conponents. Convert the vector to a point. The sum of the vectors components. The product of the vectors components. The length of the vector. The length of the vector squared. The vector normalized. The vectors absolute values. Convert a normalized vector to tangent space. Add two vectors. Add vector and scalar. Add vector and scalar. Negate vector. Subtract two vectors. Subtract vector and scalar. Subtract vector and scalar. Multiply two vectors. Multiply a vector and a scalar. Multiply a vector and a scalar. Divide two vectors. Divide a vector and a scalar. Divide a scalar and a vector. Cast from Vector3f to Vector3d. Are these vectors equal. Are these vectors not equal. Are these vectors equal. Are these vectors equal given the error. Are these vectors equal. Vectors hash code. Compare two vectors by axis. Vector as a string. Vector as a string. The dot product of two vectors. The dot product of vector and point. The abs dot product of two vectors. Normalize the vector. Angle between two vectors in degrees from 0 to 180. A and b origin treated as 0,0 and do not need to be normalized. Cross two vectors. Cross two vectors. Cross a vector andpoint. Cross two points. Project vector v onto u. Given an incident vector i and a normal vector n. Returns the refraction vector given the incident vector i, the normal vector n and the refraction index eta. Create a set of orthonormal vectors. The minimum value between s and each component in vector. The minimum value between each component in vectors. The maximum value between s and each component in vector. The maximum value between each component in vectors. Clamp each component to specified min and max. Clamp each component to specified min and max. Lerp between two vectors. Slerp between two vectors arc. Round vector. number of digits to round to. Round the vector. The number of digits to round to. Floor each component of vector. Ceilling each component of vector. The unit x vector. The unit y vector. The unit z vector. A vector of zeros. A vector of ones. A vector of 0.5. A vector of positive infinity. A vector of negative infinity. 3D vector to 3D swizzle vector. 3D vector to 2D vector. 3D vector to 2D vector. 3D vector to 2D vector. 3D vector to 4D vector with w as 0. 3D vector to 4D vector with w as 1. A vector all with the value v. A vector from the varibles. A vector from the varibles. A vector from a 2d vector and the z varible. Are all the components of vector finite. Make a vector with no non finite conponents. Are any of the vectors components nan. Make a vector with no nan conponents. Convert the vector to a point. The sum of the vectors components. The product of the vectors components. The length of the vector. The length of the vector squared. The vector normalized. The vectors absolute values. Convert a normalized vector to tangent space. Add two vectors. Add vector and scalar. Add vector and scalar. Negate vector. Subtract two vectors. Subtract vector and scalar. Subtract vector and scalar. Multiply two vectors. Multiply a vector and a scalar. Multiply a vector and a scalar. Divide two vectors. Divide a vector and a scalar. Divide a scalar and a vector. Cast from Vector3d to Vector3f. Are these vectors equal. Are these vectors not equal. Are these vectors equal. Are these vectors equal given the error. Are these vectors equal. Vectors hash code. Compare two vectors by axis. Vector as a string. Vector as a string. The dot product of two vectors. The dot product of vector and point. The abs dot product of two vectors. Normalize the vector. Angle between two vectors in degrees from 0 to 180. A and b origin treated as 0,0 and do not need to be normalized. Cross two vectors. Cross two vectors. Cross a vector andpoint. Cross two points. Project vector v onto u. Given an incident vector i and a normal vector n. Returns the refraction vector given the incident vector i, the normal vector n and the refraction index eta. Create a set of orthonormal vectors. The minimum value between s and each component in vector. The minimum value between each component in vectors. The maximum value between s and each component in vector. The maximum value between each component in vectors. Clamp each component to specified min and max. Clamp each component to specified min and max. Lerp between two vectors. Slerp between two vectors arc. Round vector. number of digits to round to. Round the vector. The number of digits to round to. Floor each component of vector. Ceilling each component of vector. The unit x vector. The unit y vector. The unit z vector. The unit w vector. A vector of zeros. A vector of ones. A vector of 0.5. A vector of positive infinity. A vector of negative infinity. Convert to a 2 dimension vector. Convert to a 2 dimension vector. Convert to a 3 dimension vector. A copy of the vector with w as 0. A vector all with the value v. A vector from the varibles. A vector from a 2d vector and the z and w varibles. A vector from a 3d vector and the w varible. Are all the components of vector finite. Make a vector with no non finite conponents. Are any of the vectors components nan. Make a vector with no nan conponents. Convert the vector to a point. The sum of the vectors components. The product of the vectors components. The length of the vector. The length of the vector squared. The vector normalized. The vectors absolute values. Add two vectors. Add vector and scalar. Add vector and scalar. Negate vector. Subtract two vectors. Subtract vector and scalar. Subtract vector and scalar. Multiply two vectors. Multiply a vector and a scalar. Multiply a vector and a scalar. Divide two vectors. Divide a vector and a scalar. Divide a scalar and a vector. Cast from Vector4f to Vector4d. Are these vectors equal. Are these vectors not equal. Are these vectors equal. Are these vectors equal given the error. Are these vectors equal. Vectors hash code. Compare two vectors by axis. Vector as a string. Vector as a string. The dot product of two vectors. The dot product of vector and point. The abs dot product of two vectors. Normalize the vector. The minimum value between s and each component in vector. The minimum value between each component in vectors. The maximum value between s and each component in vector. The maximum value between each component in vectors. Clamp each component to specified min and max. Clamp each component to specified min and max. Lerp between two vectors. Round vector. number of digits to round to. Round the vector. The number of digits to round to. Floor each component of vector. Ceilling each component of vector. The unit x vector. The unit y vector. The unit z vector. The unit w vector. A vector of zeros. A vector of ones. A vector of 0.5. A vector of positive infinity. A vector of negative infinity. Convert to a 2 dimension vector. Convert to a 2 dimension vector. Convert to a 3 dimension vector. A copy of the vector with w as 0. A vector all with the value v. A vector from the varibles. A vector from the varibles. A vector from a 2d vector and the z and w varibles. A vector from a 3d vector and the w varible. Are all the components of vector finite. Make a vector with no non finite conponents. Are any of the vectors components nan. Make a vector with no nan conponents. Convert the vector to a point. The sum of the vectors components. The product of the vectors components. The length of the vector. The length of the vector squared. The vector normalized. The vectors absolute values. Add two vectors. Add vector and scalar. Add vector and scalar. Negate vector. Subtract two vectors. Subtract vector and scalar. Subtract vector and scalar. Multiply two vectors. Multiply a vector and a scalar. Multiply a vector and a scalar. Divide two vectors. Divide a vector and a scalar. Divide a scalar and a vector. Cast from Vector4d to Vector4f. Are these vectors equal. Are these vectors not equal. Are these vectors equal. Are these vectors equal given the error. Are these vectors equal. Vectors hash code. Compare two vectors by axis. Vector as a string. Vector as a string. The dot product of two vectors. The dot product of vector and point. The abs dot product of two vectors. Normalize the vector. The minimum value between s and each component in vector. The minimum value between each component in vectors. The maximum value between s and each component in vector. The maximum value between each component in vectors. Clamp each component to specified min and max. Clamp each component to specified min and max. Lerp between two vectors. Round vector. number of digits to round to. Round the vector. The number of digits to round to. Floor each component of vector. Ceilling each component of vector. A 2D box represented by its min and max values. The boxes min point. The boxes max point. Construct a new box. The boxes min point. The boxes max point. Construct a new box. The boxes min point. The boxes max point. The boxes lower left corner. The boxes lower right corner. The boxes upper right corner. The boxes upper left corner. The center of the box. The size of the boxes sides. The size of the box on the x axis. The size of the box on the y axis. The area of the box. Is the box equal to this obj. The object. Is the box equal to this obj. Is the box equal to the other box. The other box. Is the box equal to the other box. The boxes hash code. The boxes hash code. Get the boxes corner points as a array. The boxes corner points as a array Copy the boxes corner points in the array. A array that has a size of at least 4. Copy the boxes corner points in the array. Convert the 2d points into 3d points with the y component now as the z component. A array that has a size of at least 4. The 3d points y value. Returns the bounding box containing this box and the given point. Returns the bounding box containing this box and the given box. Return a new box expanded by the amount. The box to expand. The amount to expand. The expanded box. Returns true if this box intersects the other box. The other box. True if on border counts as inside. Returns true if this box intersects the other box. Does the box fully contain the other box. The other box. True if on border counts as inside. Does the box fully contain the other box. Does the box contain the point. The point. True if on border counts as inside. True if the box contains the point. Find the closest point to the box. If point inside box return point. Return the signed distance to the point. If point is outside box field is positive. If point is inside box field is negative. Round the boxes components. The number of digits to round to. Caculate the bounding box of the points. The points. The bounding box. Calculate the bounds of 2 points. The first point. The second point The bounding box. Caculate the bounding box of a set of segments. The segments. The bounding box A 2D box represented by its min and max values. The boxes min point. The boxes max point. Construct a new box. The boxes min point. The boxes max point. Construct a new box. The boxes min point. The boxes max point. The boxes lower left corner. The boxes lower right corner. The boxes upper right corner. The boxes upper left corner. The center of the box. The size of the boxes sides. The size of the box on the x axis. The size of the box on the y axis. The area of the box. Is the box equal to this obj. The object. Is the box equal to this obj. Is the box equal to the other box. The other box. Is the box equal to the other box. The boxes hash code. The boxes hash code. Get the boxes corner points as a array. The boxes corner points as a array Copy the boxes corner points in the array. A array that has a size of at least 4. Copy the boxes corner points in the array. Convert the 2f points into 3f points with the y component now as the z component. A array that has a size of at least 4. The 3f points y value. Returns the bounding box containing this box and the given point. Returns the bounding box containing this box and the given box. Return a new box expanded by the amount. The box to expand. The amount to expand. The expanded box. Returns true if this box intersects the other box. The other box. True if on border counts as inside. Returns true if this box intersects the other box. Does the box fully contain the other box. The other box. True if on border counts as inside. Does the box fully contain the other box. Does the box contain the point. The point. True if on border counts as inside. True if the box contains the point. Find the closest point to the box. If point inside box return point. Return the signed distance to the point. If point is outside box field is positive. If point is inside box field is negative. Round the boxes components. The number of digits to round to. Caculate the bounding box of the points. The points. The bounding box. Calculate the bounds of 2 points. The first point. The second point The bounding box. Caculate the bounding box of a set of segments. The segments. The bounding box A 2D box represented by its min and max values. The boxes min point. The boxes max point. Construct a new box. The boxes min point. The boxes max point. Construct a new box. The boxes min point. The boxes max point. The boxes lower left corner. The boxes lower right corner. The boxes upper right corner. The boxes upper left corner. The center of the box. The size of the boxes sides. The size of the box on the x axis. The size of the box on the y axis. The area of the box. Enumerate each point on the boxes perimeter. Enumerate each point in the box. Is the box equal to this obj. The object. Is the box equal to this obj. Is the box equal to the other box. The other box. Is the box equal to the other box. The boxes hash code. The boxes hash code. Get the boxes corner points as a array. The boxes corner points as a array Copy the boxes corner points in the array. A array that has a size of at least 4. Copy the boxes corner points in the array. Convert the 2i points into 3i points with the y component now as the z component. A array that has a size of at least 4. The 3i points y value. Returns the bounding box containing this box and the given point. Returns the bounding box containing this box and the given box. Return a new box expanded by the amount. The box to expand. The amount to expand. The expanded box. Returns true if this box intersects the other box. The other box. True if on border counts as inside. Returns true if this box intersects the other box. Does the box fully contain the other box. The other box. True if on border counts as inside. Does the box fully contain the other box. Does the box contain the point. The point. True if on border counts as inside. True if the box contains the point. Find the closest point to the box. If point inside box return point. Caculate the bounding box of the points. The points. The bounding box. Calculate the bounds of 2 points. The first point. The second point The bounding box. A 3D box represented by its min and max values. The boxes min point. The boxes max point. Construct a new box. The boxes min point. The boxes max point. Construct a new box. The boxes min point. The boxes max point. The center of the box. The size of the boxes sides. The size of the box on the x axis. The size of the box on the y axis. The size of the box on the z axis. The volume of the box. THe boxes surface area. Is the box equal to this obj. The object. Is the box equal to this obj. Is the box equal to the other box. The other box. Is the box equal to the other box. The boxes hash code. The boxes hash code. Get the boxes corner points as a array. The boxes corner points as a array Copy the boxes corner points in the array. A array that has a size of at least 8. Copy the boxes corner points in the array. A array that has a size of at least 8. Returns the bounding box containing this box and the given point. Returns the bounding box containing this box and the given box. Return a new box expanded by the amount. The box to expand. The amount to expand. The expanded box. Returns true if this box intersects the other box. The other box. True if on border counts as inside. Returns true if this box intersects the other box. Does the box fully contain the other box. The other box. True if on border counts as inside. Does the box fully contain the other box. Does the box contain the point. The point. True if on border counts as inside. True if the box contains the point. Find the closest point to the box. If point inside box return point. Return the signed distance to the point. If point is outside box field is positive. If point is inside box field is negative. Round the boxes components. The number of digits to round to. Caculate the bounding box of the points. The points. The bounding box. Calculate the bounds of 2 points. The first point. The second point The bounding box. Caculate the bounding box of a set of segments. The segments. The bounding box A 3D box represented by its min and max values. The boxes min point. The boxes max point. Construct a new box. The boxes min point. The boxes max point. Construct a new box. The boxes min point. The boxes max point. The center of the box. The size of the boxes sides. The size of the box on the x axis. The size of the box on the y axis. The size of the box on the z axis. The volume of the box. THe boxes surface area. Is the box equal to this obj. The object. Is the box equal to this obj. Is the box equal to the other box. The other box. Is the box equal to the other box. The boxes hash code. The boxes hash code. Get the boxes corner points as a array. The boxes corner points as a array Copy the boxes corner points in the array. A array that has a size of at least 8. Copy the boxes corner points in the array. A array that has a size of at least 8. Returns the bounding box containing this box and the given point. Returns the bounding box containing this box and the given box. Return a new box expanded by the amount. The box to expand. The amount to expand. The expanded box. Returns true if this box intersects the other box. The other box. True if on border counts as inside. Returns true if this box intersects the other box. Does the box fully contain the other box. The other box. True if on border counts as inside. Does the box fully contain the other box. Does the box contain the point. The point. True if on border counts as inside. True if the box contains the point. Find the closest point to the box. If point inside box return point. Return the signed distance to the point. If point is outside box field is positive. If point is inside box field is negative. Round the boxes components. The number of digits to round to. Caculate the bounding box of the points. The points. The bounding box. Calculate the bounds of 2 points. The first point. The second point The bounding box. Caculate the bounding box of a set of segments. The segments. The bounding box A 3D box represented by its min and max values. The boxes min point. The boxes max point. Construct a new box. The boxes min point. The boxes max point. Construct a new box. The boxes min point. The boxes max point. The center of the box. The size of the boxes sides. The size of the box on the x axis. The size of the box on the y axis. The size of the box on the z axis. The volume of the box. THe boxes surface area. Is the box equal to this obj. The object. Is the box equal to this obj. Is the box equal to the other box. The other box. Is the box equal to the other box. The boxes hash code. The boxes hash code. Get the boxes corner points as a array. The boxes corner points as a array Copy the boxes corner points in the array. A array that has a size of at least 8. Copy the boxes corner points in the array. A array that has a size of at least 8. Returns the bounding box containing this box and the given point. Returns the bounding box containing this box and the given box. Return a new box expanded by the amount. The box to expand. The amount to expand. The expanded box. Returns true if this box intersects the other box. The other box. True if on border counts as inside. Returns true if this box intersects the other box. Does the box fully contain the other box. The other box. True if on border counts as inside. Does the box fully contain the other box. Does the box contain the point. The point. True if on border counts as inside. True if the box contains the point. Find the closest point to the box. If point inside box return point. Caculate the bounding box of the points. The points. The bounding box. Calculate the bounds of 2 points. The first point. The second point The bounding box. The squared radius. The circles diameter. The circles area. the circles circumference. Calculate the bounding box. The circles hashcode. The circles hashcode. Find the closest point to the circle. If point inside circle return point. Return the signed distance to the point. If point is outside circle field is positive. If point is inside circle field is negative. Does the circle contain the point. The point. Does the border conunt as inside the circle. true if circle contains point Does the circle fully contain the box. The box. Does the border conunt as inside the circle. Does the circle fully contain the box. Does this circle intersect with the other circle. The other circle Does the border conunt as inside the circle. True if the circles intersect Does the circle intersect the box. The box. Does the border conunt as inside the circle. Does the circle intersect the box. Enlarge the circle so it contains the point p. Returns true if the point d is inside the circle defined by the points a, b, c. Creates a circle that has both points on its circumference. Creates a circle that has all 3 points on its circumference. From MathWorld: http://mathworld.wolfram.com/Circumcircle.html. Fails if the points are colinear. Creates a circle that contains all three point. Calculate the bounding circle that contains all the points in the list. Finds which axis contains the two most extreme points The squared radius. The circles diameter. The circles area. the circles circumference. Calculate the bounding box. The circles hashcode. The circles hashcode. Find the closest point to the circle. If point inside circle return point. Return the signed distance to the point. If point is outside circle field is positive. If point is inside circle field is negative. Does the circle contain the point. The point. Does the border conunt as inside the circle. true if circle contains point Does the circle fully contain the box. The box. Does the border conunt as inside the circle. Does the circle fully contain the box. Does this circle intersect with the other circle. The other circle Does the border conunt as inside the circle. True if the circles intersect Does the circle intersect the box. The box. Does the border conunt as inside the circle. Does the circle intersect the box. Enlarge the circle so it contains the point p. Returns true if the point d is inside the circle defined by the points a, b, c. Creates a circle that has both points on its circumference. Creates a circle that has all 3 points on its circumference. From MathWorld: http://mathworld.wolfram.com/Circumcircle.html. Fails if the points are colinear. Creates a circle that contains all three point. Calculate the bounding circle that contains all the points in the list. Finds which axis contains the two most extreme points Represents a line from three coefficients a, b and c, where ax + by + c = 0 holds. Create a new line from three coefficients a, b and c, where ax + by + c = 0 holds. The constant in ax. The constant in by The constant c Create a new line from the slope and the y intercept, where y = mx + b holds. The lines slope. The y intercept. Create a new line that passes through the two points. Point 1. Point 2. Find the slope of the line. Determines whether the line is ascending (that is, makes an angle with the positive direction of the X axis that lies in (0, pi/2). Determines whether the line is vertical (that is, makes an angle with the positive direction of the X axis that is equal to pi/2. Determines whether the line is descending (that is, makes an angle with the positive direction of the X axis that lies in (pi/2, pi). Determines whether the line is horizontal (that is, makes an angle with the positive direction of the X axis that is equal to pi. Determines whether the line is undefined (e.g.two equal points were passed to the constructor). Calculates the angle that the line makes with the positive direction of the X axis. Is the line equal to the other object. The other object. Is the line equal to the other object. Is the line equal to the other line. The other line. Is the line equal to the other line. The lines hash code. The lines hash code. Calculates the X coordinate of a point on the line by its Y coordinate. Calculates the Y coordinate of a point on the line by its X coordinate. Determines whether the point lies on the line. if the point lies on the line Calculates the perpendicular line that passes through the given point. Determines whether the point lies on the left side of the line. Determines whether the point lies on the right side of the line. Determine if the two lines are the equivalent even though they may have a different equation. Calculates the intersection of two lines. the other line intersection point if lines intersect Represents a line from three coefficients a, b and c, where ax + by + c = 0 holds. Create a new line from three coefficients a, b and c, where ax + by + c = 0 holds. The constant in ax. The constant in by The constant c Create a new line from the slope and the y intercept, where y = mx + b holds. The lines slope. The y intercept. Create a new line that passes through the two points. Point 1. Point 2. Find the slope of the line. Determines whether the line is ascending (that is, makes an angle with the positive direction of the X axis that lies in (0, pi/2). Determines whether the line is vertical (that is, makes an angle with the positive direction of the X axis that is equal to pi/2. Determines whether the line is descending (that is, makes an angle with the positive direction of the X axis that lies in (pi/2, pi). Determines whether the line is horizontal (that is, makes an angle with the positive direction of the X axis that is equal to pi. Determines whether the line is undefined (e.g.two equal points were passed to the constructor). Calculates the angle that the line makes with the positive direction of the X axis. Is the line equal to the other object. The other object. Is the line equal to the other object. Is the line equal to the other line. The other line. Is the line equal to the other line. The lines hash code. The lines hash code. Calculates the X coordinate of a point on the line by its Y coordinate. Calculates the Y coordinate of a point on the line by its X coordinate. Determines whether the point lies on the line. if the point lies on the line Calculates the perpendicular line that passes through the given point. Determines whether the point lies on the left side of the line. Determines whether the point lies on the right side of the line. Determine if the two lines are the equivalent even though they may have a different equation. Calculates the intersection of two lines. the other line intersection point if lines intersect A 3D Line struct represented by a position and a direction. The Lines position. The Lines direction. Might not be normalized. Construct a Line from a point and the direction. The Lines position. The Lines direction (will be normalized) Check if the two Lines are equal. The first Line. The second Line. True if the two Lines are equal. Check if the two Lines are not equal. The first Line. The second Line. True if the two Lines are not equal. Is the Line equal to this object. The object. Is the Line equal to this object. Is the Line equal to the other Line. The over Line. Is the Line equal to the other Line. The Lines hashcode. The Lines hashcode. The Lines as a string. Normalize the lines direction. Round the Lines position and direction. number of digits to round to. A 3f Line struct represented by a position and a direction. The Lines position. The Lines direction. Might not be normalized. Construct a Line from a point and the direction. The Lines position. The Lines direction (will be normalized) Check if the two Lines are equal. The first Line. The second Line. True if the two Lines are equal. Check if the two Lines are not equal. The first Line. The second Line. True if the two Lines are not equal. Is the Line equal to this object. The object. Is the Line equal to this object. Is the Line equal to the other Line. The over Line. Is the Line equal to the other Line. The Lines hashcode. The Lines hashcode. The Lines as a string. Normalize the lines direction. Round the Lines position and direction. number of digits to round to. Plane struct defined by a position and direction. A plane facing the x axis. A plane facing the y axis. A plane facing the z axis. The planes position. The planes direction. Create a new plane. The planes direction. Create a new plane. The planes position. The planes direction. Create a new plane. The planes direction. The planes distance from the origin. From three noncollinear points (ordered ccw). The planes distance from the origin. The planes square distance from the origin. Check if the two planes are equal. The first plane. The second plane. True if the planes are equal. Check if the two planes are not equal. The first plane. The second plane. True if the planes are not equal. Check if this plane is equal to the other object. The other object. Are these planes equal. Check if this plane is equal to the other plane. The other plane. Are these planes equal. The planes hash code. The plane as a string. The closest point on the plane to the point p. The point. The closest point on the plane. Plane struct defined by a position and direction. A plane facing the x axis. A plane facing the y axis. A plane facing the z axis. The planes position. The planes direction. Create a new plane. The planes direction. Create a new plane. The planes position. The planes direction. Create a new plane. The planes direction. The planes distance from the origin. From three noncollinear points (ordered ccw). The planes distance from the origin. The planes square distance from the origin. Check if the two planes are equal. The first plane. The second plane. True if the planes are equal. Check if the two planes are not equal. The first plane. The second plane. True if the planes are not equal. Check if this plane is equal to the other object. The other object. Are these planes equal. Check if this plane is equal to the other plane. The other plane. Are these planes equal. The planes hash code. The plane as a string. The closest point on the plane to the point p. The point. The closest point on the plane. A 2D ray. The rays position. The rays direction. Construct a new ray. The rays position. The rays directio Is the ray equal to the other object. The other object. Is the ray equal to the other object. Is the ray equal to the other ray. The other ray. Is the ray equal to the other ray. The rays hashcode. The rays hashcode. Round the rays components. The number of digits to round to. Get the position offset along the ray at t. The amount to offset. The position at t. Intersection point between two rays. Presumes there is a intersection. The other ray. Intersection between two rays. The other ray Intersection point = Position + s * Direction. Intersection point = ray.Position + t * ray.Direction. If rays intersect Intersection between ray and segment. the segment Intersection point = Position + s * Direction Intersection point = A + t * (B - A) If rays intersect Intersection between ray and circle. the circle Intersection point = Position + t * Direction If rays intersect Intersection between ray and box. the box Intersection point = Position + t * Direction If rays intersect A 2D ray. The rays position. The rays direction. Construct a new ray. The rays position. The rays directio Is the ray equal to the other object. The other object. Is the ray equal to the other object. Is the ray equal to the other ray. The other ray. Is the ray equal to the other ray. The rays hashcode. The rays hashcode. Get the position offset along the ray at t. The amount to offset. The position at t. Intersection point between two rays. Presumes there is a intersection. The other ray. Intersection between two rays. The other ray Intersection point = Position + s * Direction. Intersection point = ray.Position + t * ray.Direction. If rays intersect Intersection between ray and segment. the segment Intersection point = Position + s * Direction Intersection point = A + t * (B - A) If rays intersect Intersection between ray and circle. the circle Intersection point = Position + t * Direction If rays intersect Intersection between ray and box. the box Intersection point = Position + t * Direction If rays intersect A 3D ray struct represented by a position and a direction. The rays position. The rays direction. Might not be normalized. Construct a ray from a point and the direction. The rays position. The rays direction (will be normalized) Check if the two rays are equal. The first ray. The second ray. True if the two rays are equal. Check if the two rays are not equal. The first ray. The second ray. True if the two rays are not equal. Is the ray equal to this object. The object. Is the ray equal to this object. Is the ray equal to the other ray. The over ray. Is the ray equal to the other ray. The rays hashcode. The rays hashcode. The rays as a string. The rays directions magnidute. The rays directions square magnidute. Get the position offset along the ray at t. The amount to offset. The position at t. Normalize the lines direction. Round the rays position and direction. number of digits to round to. A 3D ray struct represented by a position and a direction. The rays position. The rays direction. Might not be normalized. Construct a ray from a point and the direction. The rays position. The rays direction (will be normalized) Check if the two rays are equal. The first ray. The second ray. True if the two rays are equal. Check if the two rays are not equal. The first ray. The second ray. True if the two rays are not equal. Is the ray equal to this object. The object. Is the ray equal to this object. Is the ray equal to the other ray. The over ray. Is the ray equal to the other ray. The rays hashcode. The rays hashcode. The rays as a string. The rays directions magnidute. The rays directions square magnidute. Get the position offset along the ray at t. The amount to offset. The position at t. Normalize the lines direction. Round the rays position and direction. number of digits to round to. A 2D segment. The segments first point. The segments second point. Construct a new segment. The segments first point. The segments second point. Construct a new segment. The segments first points x value. The segments first points y value. The segments second points x value. The segments second points y value. The segments center. The segments length. The segments square length. The segments tangent vector. The segments normal vector. The left most point of the segment. The right most point of the segment. The bottom most point of the segment. The top most point of the segment. THe segment flipped, a is now b, b is now a. The segments bounding box. Is the segment equal to the other object. The other object. Is the segment equal to the other object. Is the segment equal to the other segment. The other segment. Is the segment equal to the other segment. The segments hashcode. The segments hashcode. The points distance from the segment. The points sqr distance from the segment. Round the segments points. The number of digits to round to. Does the point line on the segemnts. Return the signed distance to the point. Always positive. Does the two segments intersect. other segment Do the two segments intersect. other segment Intersection point = A + t * (B - A) If they intersect Do the two segments intersect. other segment Intersection point = A + s * (B - A) Intersection point = seg.A + t * (seg.B - seg.A) If they intersect Does the segment intersect this box. The closest point on segment to point. point The closest point on segment to point. point closest point = A + t * (B - A) The closest segment spanning two other segments. the other segment The closest segment spanning two other segments. the other segment closest point = A + s * (B - A) other closest point = seg.A + t * (seg.B - seg.A) A 2D segment. The segments first point. The segments second point. Construct a new segment. The segments first point. The segments second point. Construct a new segment. The segments first points x value. The segments first points y value. The segments second points x value. The segments second points y value. The segments center. The segments length. The segments square length. The segments tangent vector. The segments normal vector. The left most point of the segment. The right most point of the segment. The bottom most point of the segment. The top most point of the segment. The segment flipped, a is now b, b is now a. The segments bounding box. Is the segment equal to the other object. The other object. Is the segment equal to the other object. Is the segment equal to the other segment. The other segment. Is the segment equal to the other segment. The segments hashcode. The segments hashcode. The points distance from the segment. The points sqr distance from the segment. Round the segments points. The number of digits to round to. Does the point line on the segemnts. Return the signed distance to the point. Always positive. Does the two segments intersect. other segment Do the two segments intersect. other segment Intersection point = A + t * (B - A) If they intersect Do the two segments intersect. other segment Intersection point = A + s * (B - A) Intersection point = seg.A + t * (seg.B - seg.A) If they intersect Does the segment intersect this box. The closest point on segment to point. point The closest point on segment to point. point closest point = A + t * (B - A) The closest segment spanning two other segments. the other segment The closest segment spanning two other segments. the other segment closest point = A + s * (B - A) other closest point = seg.A + t * (seg.B - seg.A) A 3D segment. The segments first (aka source) point. The segments second (aka target) point. Create a new segment. The first point. The second point. Create a new segment. The first points x value. The first points y value. The first points z value. The second points x value. The second points y value. The second points z value. The length of the segment. The square length of the segment. The segment flipped, a is now b, b is now a. The bounding box of the segment. Array acess to the segments points. The index of the point to access (0-2) The point at index i. Is the segment equal to this object. The object. Is the segment equal to this object. Is the segment equal to the other segment. The other segment. Is the segment equal to the other segment. The segments hash code. The segments hash code. The segment as a string. The segment as a string. Round the segments points. number of digits to round to. Does the point line on the segemnts. Return the signed distance to the point. Always positive. The closest point on segment to point. point The closest point on segment to point. point closest point = A + t * (B - A) The closest segment spanning two other segments. the other segment The closest segment spanning two other segments. the other segment closest point = A + s * (B - A) other closest point = seg.A + t * (seg.B - seg.A) A 3D segment. The segments first (aka source) point. The segments second (aka target) point. Create a new segment. The first point. The second point. Create a new segment. The first points x value. The first points y value. The first points z value. The second points x value. The second points y value. The second points z value. The length of the segment. The square length of the segment. The segment flipped, a is now b, b is now a. The bounding box of the segment. Array acess to the segments points. The index of the point to access (0-2) The point at index i. Is the segment equal to this object. The object. Is the segment equal to this object. Is the segment equal to the other segment. The other segment. Is the segment equal to the other segment. The segments hash code. The segments hash code. The segment as a string. The segment as a string. Round the segments points. number of digits to round to. Does the point line on the segemnts. Return the signed distance to the point. Always positive. The closest point on segment to point. point The closest point on segment to point. point closest point = A + t * (B - A) The closest segment spanning two other segments. the other segment The closest segment spanning two other segments. the other segment closest point = A + s * (B - A) other closest point = seg.A + t * (seg.B - seg.A) A segment represented by indices instead of points. The indices represent a index into a array of points. The segments first point index. The segments seconds point index. Consturct a new segment. The segments first point index. The segments second point index. Does the segment have a null index. The segment reverse where a is now b and b is now a. Is the segment equal to this object. The object. Is the segment equal to this object. Is the segment equal to the other segment. The other segment. Is the segment equal to the other segment. The segments hash code. The segments hash code. The segment as a string. The segment as a string. A 3D sphere. The shperes center point. The spheres radius. Construct a new sphere. The shperes center point. The spheres radius. The squared radius. The spheres diameter. The spheres area. The spheres surface area. Calculate the bounding box. Is this sphere equal to the other object. The other object. Is this sphere equal to the other object. Is this sphere equal to the other sphere. The other sphere. Is this sphere equal to the other sphere. The spheres hashcode. The spheres hashcode. Enlarge the sphere so it contains the point p. Round the spheres components. The number of digits to round to. Find the closest point to the sphere. If point inside sphere return point. Return the signed distance to the point. If point is outside sphere field is positive. If point is inside spher field is negative. Does the sphere contain the point. The point Does the border count as being in side the sphere. true if sphere contains point Does the sphere fully contain the box. The box. Does the border count as being in side the sphere. oes the sphere fully contain the box. Does this sphere intersect with the other sphere. The other sphere Does the border count as being in side the sphere. True if the spheres intersect Does the sphere intersect the box. Does the border count as being in side the sphere. Does the sphere intersect the box. Creates a sphere that has both points on its surface. Creates a sphere that has all 4 points on its surface. From MathWorld: http://mathworld.wolfram.com/Circumsphere.html. Fails if the points are colinear. Creates a sphere that contains all three points. Calculate the minimum bounding sphere that contains all the points in the list. Finds which axis contains the two most extreme points A 3D sphere. The shperes center point. The spheres radius. Construct a new sphere. The shperes center point. The spheres radius. The squared radius. The spheres diameter. The spheres area. The spheres surface area. Calculate the bounding box. Is this sphere equal to the other object. The other object. Is this sphere equal to the other object. Is this sphere equal to the other sphere. The other sphere. Is this sphere equal to the other sphere. The spheres hashcode. The spheres hashcode. Enlarge the sphere so it contains the point p. Round the spheres components. The number of digits to round to. Find the closest point to the sphere. If point inside sphere return point. Return the signed distance to the point. If point is outside sphere field is positive. If point is inside spher field is negative. Does the sphere contain the point. The point Does the border count as being in side the sphere. true if sphere contains point Does the sphere fully contain the box. The box. Does the border count as being in side the sphere. oes the sphere fully contain the box. Does this sphere intersect with the other sphere. The other sphere Does the border count as being in side the sphere. True if the spheres intersect Does the sphere intersect the box. Does the border count as being in side the sphere. Does the sphere intersect the box. Creates a sphere that has both points on its surface. Creates a sphere that has all 4 points on its surface. From MathWorld: http://mathworld.wolfram.com/Circumsphere.html. Fails if the points are colinear. Creates a sphere that contains all three points. Calculate the minimum bounding sphere that contains all the points in the list. Finds which axis contains the two most extreme points A 3D tetrahedron. The tetrahedrons first point. The tetrahedrons second point. The tetrahedrons third point. The tetrahedrons fourth point. Create a new tetrahedron. The first point. The second point. The third point. The fourth point. The bounding box of the tetrahedron. Array acess to the tetrahedrons points. The index of the point to access (0-3) The point at index i. Is the tetrahedron equal to this object. The object. Is the tetrahedron equal to this object. Is the tetrahedron equal to the other tetrahedron. The other tetrahedron. Is the tetrahedron equal to the other tetrahedron. The tetrahedrons hash code. The tetrahedrons hash code. The tetrahedron as a string. The tetrahedron as a string. Round the tetrahedrons points. number of digits to round to. A 3D tetrahedron. The tetrahedrons first point. The tetrahedrons second point. The tetrahedrons third point. The tetrahedrons fourth point. Create a new tetrahedron. The first point. The second point. The third point. The fourth point. The bounding box of the tetrahedron. Array acess to the tetrahedrons points. The index of the point to access (0-3) The point at index i. Is the tetrahedron equal to this object. The object. Is the tetrahedron equal to this object. Is the tetrahedron equal to the other tetrahedron. The other tetrahedron. Is the tetrahedron equal to the other tetrahedron. The tetrahedrons hash code. The tetrahedrons hash code. The tetrahedron as a string. The tetrahedron as a string. Round the tetrahedrons points. number of digits to round to. A 2D triangle. The triangles first point. The triangles second point. The triangles third point. Construct a new triangle. The triangles first point. The triangles second point. The triangles third point. Construct a new triangle. The triangles first points x value. The triangles first points y value. The triangles second points x value. The triangles second points y value. The triangles third points x value. The triangles third points y value. The average of the triangles positions. Is the triangle orientated ccw. The triangles area. The triangles signed area. The side lengths are given as a = sqrt((cx - bx)^2 + (cy - by)^2) -- side BC opposite of A b = sqrt((cx - ax)^2 + (cy - ay)^2) -- side CA opposite of B c = sqrt((ax - bx)^2 + (ay - by)^2) -- side AB opposite of C The side lengths are given as ang_a = acos((b^2 + c^2 - a^2) / (2 * b * c)) -- angle at A ang_b = acos((c^2 + a^2 - b^2) / (2 * c * a)) -- angle at B ang_c = acos((a^2 + b^2 - c^2) / (2 * a * b)) -- angle at C The semiperimeter is given as s = (a + b + c) / 2 The inradius is given as r = D / s This is the radius of the largest circle that can fit within the triangle. Not the same as the circum circles radius. The circumradius is given as R = a * b * c / (4 * D) The circum circle formed by the triangles points. The altitudes are given as alt_a = 2 * D / a -- altitude above side a alt_b = 2 * D / b -- altitude above side b alt_c = 2 * D / c -- altitude above side c The aspect ratio may be given as the ratio of the longest to the shortest edge or, more commonly as the ratio of the circumradius to twice the inradius ar = R / (2 * r) = a * b * c / (8 * (s - a) * (s - b) * (s - c)) = a * b * c / ((b + c - a) * (c + a - b) * (a + b - c)) Is the triangle equal to the other object. The other object. Is the triangle equal to the other object. Is the triangle equal to the other riangle. The other riangle. Is the triangle equal to the other riangle. The triangles hashcode. The triangles hashcode. Round the triangles components. The digits to round to. The cross product area which is the same as double the signed area. Return th barycentric coordinates with respect to p. Find the closest point to the triangle. If point inside triangle return point. Returns the signed distance to surface of triangle. positive if outside triangle, negative if inside and 0 on boundary Does triangle contain point. point true if triangle contains point Does triangle contain point. Asumes triangle is CCW; point true if triangle contains point Does the triangle intersect this box. A 2D triangle. The triangles first point. The triangles second point. The triangles third point. Construct a new triangle. The triangles first point. The triangles second point. The triangles third point. Construct a new triangle. The triangles first points x value. The triangles first points y value. The triangles second points x value. The triangles second points y value. The triangles third points x value. The triangles third points y value. The average of the triangles positions. Is the triangle orientated ccw. The triangles area. The triangles signed area. The side lengths are given as a = sqrt((cx - bx)^2 + (cy - by)^2) -- side BC opposite of A b = sqrt((cx - ax)^2 + (cy - ay)^2) -- side CA opposite of B c = sqrt((ax - bx)^2 + (ay - by)^2) -- side AB opposite of C The side lengths are given as ang_a = acos((b^2 + c^2 - a^2) / (2 * b * c)) -- angle at A ang_b = acos((c^2 + a^2 - b^2) / (2 * c * a)) -- angle at B ang_c = acos((a^2 + b^2 - c^2) / (2 * a * b)) -- angle at C The semiperimeter is given as s = (a + b + c) / 2 The inradius is given as r = D / s This is the radius of the largest circle that can fit within the triangle. Not the same as the circum circles radius. The circumradius is given as R = a * b * c / (4 * D) The circum circle formed by the triangles points. The altitudes are given as alt_a = 2 * D / a -- altitude above side a alt_b = 2 * D / b -- altitude above side b alt_c = 2 * D / c -- altitude above side c The aspect ratio may be given as the ratio of the longest to the shortest edge or, more commonly as the ratio of the circumradius to twice the inradius ar = R / (2 * r) = a * b * c / (8 * (s - a) * (s - b) * (s - c)) = a * b * c / ((b + c - a) * (c + a - b) * (a + b - c)) Is the triangle equal to the other object. The other object. Is the triangle equal to the other object. Is the triangle equal to the other riangle. The other riangle. Is the triangle equal to the other riangle. The triangles hashcode. The triangles hashcode. Round the triangles components. The digits to round to. The cross product area which is the same as double the signed area. Return th barycentric coordinates with respect to p. Find the closest point to the triangle. If point inside triangle return point. Returns the signed distance to surface of triangle. positive if outside triangle, negative if inside and 0 on boundary Does triangle contain point. point true if triangle contains point Does triangle contain point. Asumes triangle is CCW; point true if triangle contains point Does the triangle intersect this box. A 3D triangle. The triangles first point. The triangles second point. The triangles third point. Create a new triangle. The first point. The second point. The third point. Create a new triangle. The first points x value. The first points y value. The first points z value. The second points x value. The second points y value. The second points z value. The third points x value. The third points y value. The third points z value. The bounding box of the triangle. Array acess to the triangles points. The index of the point to access (0-2) The point at index i. Is the triangle equal to this object. The object. Is the triangle equal to this object. Is the triangle equal to the other triangle. The other triangle. Is the triangle equal to the other triangle. The triangles hash code. The triangles hash code. The triangle as a string. The triangle as a string. Round the triangles points. number of digits to round to. A 3D triangle. The triangles first point. The triangles second point. The triangles third point. Create a new triangle. The first point. The second point. The third point. Create a new triangle. The first points x value. The first points y value. The first points z value. The second points x value. The second points y value. The second points z value. The third points x value. The third points y value. The third points z value. The bounding box of the triangle. Array acess to the triangles points. The index of the point to access (0-2) The point at index i. Is the triangle equal to this object. The object. Is the triangle equal to this object. Is the triangle equal to the other triangle. The other triangle. Is the triangle equal to the other triangle. The triangles hash code. The triangles hash code. The triangle as a string. The triangle as a string. Round the triangles points. number of digits to round to. A triangle represented by indices instead of points. The indices represent a index into a array of points. The triangles first point index. The triangles second point index. The triangles third point index. Consturct a new triangle. The triangles first point index. The triangles second point index. The triangles third point index. Does the triangle have a null index. The triangle reversed. Is the triangle equal to this object. The object. Is the triangle equal to this object. Is the triangle equal to the other triangle. The other triangle. Is the triangle equal to the other triangle. The triangles hash code. The triangles hash code. The triangle as a string. The triangle as a string. ================================================ FILE: CGALDotNet/Arrangements/ArrFace2.cs ================================================ using System; using System.Collections.Generic; using System.Text; using CGALDotNetGeometry.Numerics; namespace CGALDotNet.Arrangements { public struct ArrFace2 { public bool IsFictitious; public bool IsUnbounded; public bool HasOuterEdges; public int HoleCount; public int Index; public int HalfEdgeIndex; public override string ToString() { return string.Format("[ArrFace2: Index={0}, HalfEdgeIndex={1}, IsFictitious={2}, IsUnbounded={3}, HasOuterEdges={4}, HoleCount={5}]", Index, HalfEdgeIndex, IsFictitious, IsUnbounded, HasOuterEdges, HoleCount); } public IEnumerable EnumerateEdges(Arrangement2 arr) { int count = arr.HalfEdgeCount; if (HalfEdgeIndex >= 0 && HalfEdgeIndex < count) { ArrHalfedge2 edge; arr.GetHalfEdge(HalfEdgeIndex, out edge); foreach (var e in edge.EnumerateEdges(arr)) yield return e; } else { yield break; } } public IEnumerable EnumerateVertices(Arrangement2 arr) { int count = arr.HalfEdgeCount; if (HalfEdgeIndex >= 0 && HalfEdgeIndex < count) { ArrHalfedge2 edge; arr.GetHalfEdge(HalfEdgeIndex, out edge); foreach (var e in edge.EnumerateVertices(arr)) yield return e; } else { yield break; } } } } ================================================ FILE: CGALDotNet/Arrangements/ArrHalfEdge2.cs ================================================ using System; using System.Collections.Generic; using System.Text; using CGALDotNetGeometry.Numerics; using CGALDotNetGeometry.Shapes; namespace CGALDotNet.Arrangements { public struct ArrHalfedge2 { public bool IsFictitious; public int Index; public int SourceIndex; public int TargetIndex; public int FaceIndex; public int NextIndex; public int PreviousIndex; public int TwinIndex; public override string ToString() { return string.Format("[ArrHalfEdge2: Index={0}, FaceIndex={1}, IsFictitious={2}]", Index, FaceIndex, IsFictitious); } public Segment2d GetSegment(ArrVertex2[] vertices) { if (SourceIndex == CGALGlobal.NULL_INDEX) throw new ArgumentException("Source index is null"); if (TargetIndex == CGALGlobal.NULL_INDEX) throw new ArgumentException("Target index is null"); var a = vertices[SourceIndex].Point; var b = vertices[TargetIndex].Point; return new Segment2d(a, b); } public IEnumerable EnumerateEdges(Arrangement2 arr) { var start = this; var e = start; int count = arr.HalfEdgeCount; do { yield return e; if (e.NextIndex >= 0 && e.NextIndex < count) arr.GetHalfEdge(e.NextIndex, out e); else yield break; } while (e.Index != start.Index); } public IEnumerable EnumerateVertices(Arrangement2 arr) { var start = this; var e = start; int vertCount = arr.VertexCount; int edgeCount = arr.HalfEdgeCount; do { if (e.SourceIndex >= 0 && e.SourceIndex < vertCount) { ArrVertex2 vert; arr.GetVertex(e.SourceIndex, out vert); yield return vert; } if (e.NextIndex >= 0 && e.NextIndex < edgeCount) arr.GetHalfEdge(e.NextIndex, out e); else yield break; } while (e.Index != start.Index); } } } ================================================ FILE: CGALDotNet/Arrangements/ArrQuery.cs ================================================ using System; using System.Collections.Generic; using System.Text; namespace CGALDotNet.Arrangements { public enum ARR_LOCATOR { NONE, NAIVE, WALK, LANDMARKS, TRAPEZOID }; public enum ARR_ELEMENT_HIT { NONE, VERTEX, HALF_EDGE, FACE }; public struct ArrQuery { public ARR_ELEMENT_HIT Element; public int Index; public override string ToString() { return string.Format("[ArrQuery: Element={0}, Index={1}]", Element, Index); } } } ================================================ FILE: CGALDotNet/Arrangements/ArrVertex2.cs ================================================ using System; using System.Collections.Generic; using System.Text; using CGALDotNetGeometry.Numerics; using CGALDotNetGeometry.Shapes; namespace CGALDotNet.Arrangements { public struct ArrVertex2 { public Point2d Point; public int Degree; public bool IsIsolated; public int Index; public int FaceIndex; public int HalfEdgeIndex; public override string ToString() { return string.Format("[ArrVertex2: Point={0}, Index={1}, FaceIndex={2}, Degree={3}, IsIsolated={4}]", Point, Index, FaceIndex, Degree, IsIsolated); } public IEnumerable EnumerateHalfedges(Arrangement2 arr) { ArrHalfedge2 start; arr.GetHalfEdge(HalfEdgeIndex, out start); ArrHalfedge2 e = start; int count = arr.HalfEdgeCount; do { yield return e; ArrHalfedge2 twin, next; if (e.TwinIndex >= 0 && e.TwinIndex < count) arr.GetHalfEdge(e.TwinIndex, out twin); else yield break; if (e.NextIndex >= 0 && e.NextIndex < count) arr.GetHalfEdge(twin.NextIndex, out next); else yield break; e = next; } while (e.Index != start.Index); } } } ================================================ FILE: CGALDotNet/Arrangements/Arrangement2.cs ================================================ using System; using System.Collections.Generic; using System.Text; using CGALDotNetGeometry.Numerics; using CGALDotNetGeometry.Shapes; using CGALDotNet.Polygons; using CGALDotNet.Triangulations; using CGALDotNet.Meshing; namespace CGALDotNet.Arrangements { /// /// The generic arrangment class. /// /// The kernel type. public sealed class Arrangement2 : Arrangement2 where K : CGALKernel, new() { /// /// The default constructor. /// public Arrangement2() : base(new K()) { } /// /// Create a arrangement from a unmanaged ptr. /// /// The unmanaged pointer. internal Arrangement2(IntPtr ptr) : base(new K(), ptr) { } /// /// The arrangement as a string. /// /// public override string ToString() { return string.Format("[Arrangement2<{0}>: Vertices={1}, HalfEdges={2}, Faces={3}, Locator={4}]", Kernel.Name, VertexCount, HalfEdgeCount, FaceCount, Locator); } /// /// Assigns the contents of another arrangement. /// /// The other arrangement. public void Assign(Arrangement2 other) { Kernel.Assign(Ptr, other.Ptr); } /// /// Computes the overlay of two arrangements and return as a new arrangement. /// /// The other arrangement. /// The overlay of both arrangements. public Arrangement2 Overlay(Arrangement2 other) { var ptr = Kernel.Overlay(Ptr, other.Ptr); return new Arrangement2(ptr); } /// /// Create a deep copy of this arrangment. /// /// The deep copy. public Arrangement2 Copy() { var copy = new Arrangement2(); Kernel.Assign(copy.Ptr, Ptr); return copy; } /// /// Insert the polygon into this arrangement. /// /// The polygon. /// If the polygon intersects anything else in the arramgement. public void InsertPolygon(Polygon2 polygon, bool nonIntersecting) { Kernel.InsertPolygon(Ptr, polygon.Ptr, nonIntersecting); } /// /// Insert the polygon into this arrangement. /// /// The polygon. /// If the polygon intersects anything else in the arramgement. public void InsertPolygon(PolygonWithHoles2 polygon, bool nonIntersecting) { Kernel.InsertPolygon(Ptr, polygon.Ptr, nonIntersecting); } } /// /// The abstract base class. /// public abstract class Arrangement2 : CGALObject { /// /// The default constructor. /// private Arrangement2() { CreateLocator(ARR_LOCATOR.WALK); } /// /// Create a arrangement from the kernel. /// /// The kernel. internal Arrangement2(CGALKernel kernel) { Kernel = kernel.ArrangementKernel2; Ptr = Kernel.Create(); CreateLocator(ARR_LOCATOR.WALK); } /// /// Create a arrangement from the kernel and unmanaged pointer. /// /// The kernel. /// The unmanaged pointer. internal Arrangement2(CGALKernel kernel, IntPtr ptr) : base(ptr) { Kernel = kernel.ArrangementKernel2; CreateLocator(ARR_LOCATOR.WALK); } /// /// The arrangements kernel. /// protected private ArrangementKernel2 Kernel { get; private set; } /// /// The number of vertices in the arrangement. /// public int VertexCount => Kernel.VertexCount(Ptr); /// /// The number of vertices in the arrangement that are i /// public int IsolatedVerticesCount => Kernel.IsolatedVerticesCount(Ptr); /// /// returns the number of arrangement vertices that lie at infinity a /// nd are not associated with valid points. /// Such vertices are not considered to be regular arrangement /// vertices and VertexCount does not count them. /// public int VerticesAtInfinityCount => Kernel.VerticesAtInfinityCount(Ptr); /// /// The number of half edges. /// public int HalfEdgeCount => Kernel.HalfEdgeCount(Ptr); /// /// The number of edges. two half edges count as one edge. /// public int EdgeCount => Kernel.EdgeCount(Ptr); /// /// The number of faces in the arrangement not counting /// the unbounded face. /// public int FaceCount => Kernel.FaceCount(Ptr) - UnboundedFaceCount; /// /// returns the number of unbounded faces in the arrangement. /// Such faces are not considered to be regular arrangement /// faces and FaceCount does not count them. /// public int UnboundedFaceCount => Kernel.UnboundedFaceCount(Ptr); /// /// The type of locator used to find element /// in the arrangement when queried. /// Default is walk which is the best in most cases /// public ARR_LOCATOR Locator { get; private set; } /// /// Is the arrangement empty. /// public bool IsEmpty => Kernel.IsEmpty(Ptr); /// /// A number that will change if the unmanaged /// arrangement model changes. /// public int BuildStamp => Kernel.BuildStamp(Ptr); /// /// Clear the arrangement. /// public void Clear() { Kernel.Clear(Ptr); } /// /// In particular, the functions checks the topological structure of the arrangement /// and assures that it is valid. In addition, the function performs several simple /// geometric tests to ensure the validity of some of the geometric properties of /// the arrangement. Namely, it checks that all arrangement vertices are associated /// with distinct points, and that the halfedges around every vertex are ordered clockwise. /// /// public bool IsValid() { return Kernel.IsValid(Ptr); } /// /// Get a copy of all the points in the arrangement. /// /// A point array that is the length of the vertex count. /// The ararys length. public void GetPoints(Point2d[] points, int count) { ErrorUtil.CheckArray(points, count); Kernel.GetPoints(Ptr, points, count); } /// /// Get a copy of all the segments in the arrangment. /// /// A segment array that is the length of the edge count. /// The ararys length. public void GetSegments(Segment2d[] segments, int count) { ErrorUtil.CheckArray(segments, count); Kernel.GetSegments(Ptr, segments, count); } /// /// Get a copy of all the vertices in the arrangement. /// /// A vertices array that is the length of the vertex count. /// The ararys length. public void GetVertices(ArrVertex2[] vertices, int count) { ErrorUtil.CheckArray(vertices, count); Kernel.GetVertices(Ptr, vertices, count); } /// /// Get the vertex from the arrangement. /// /// The index of the vertex. /// The vertex. /// True if the vertex was found. public bool GetVertex(int index, out ArrVertex2 vertex) { return Kernel.GetVertex(Ptr, index, out vertex); } /// /// Get a copy of all the half edges in the arrangement. /// /// A half edge array that is the length of the half edge count. /// The ararys length. public void GetHalfEdges(ArrHalfedge2[] edges, int count) { ErrorUtil.CheckArray(edges, count); Kernel.GetHalfEdges(Ptr, edges, count); } /// /// Get the half edge from the arrangement. /// /// The index of the half edge. /// The half edge. /// True if the half edge was found. public bool GetHalfEdge(int index, out ArrHalfedge2 edge) { return Kernel.GetHalfEdge(Ptr, index, out edge); } /// /// Get a copy of all the faces in the arrangement. /// /// A face array that is the length of the facee count. /// The ararys length. public void GetFaces(ArrFace2[] faces, int count) { ErrorUtil.CheckArray(faces, count); Kernel.GetFaces(Ptr, faces, count); } /// /// Get the face from the arrangement. /// /// The index of the half edge. /// The face. /// True if the face was found. public bool GetFace(int index, out ArrFace2 face) { return Kernel.GetFace(Ptr, index, out face); } /// /// Create the locator used to find query the arrangement. /// /// The locator type. public void CreateLocator(ARR_LOCATOR locator) { if (Locator == locator) return; Locator = locator; Kernel.CreateLocator(Ptr, locator); } /// /// Release the locator. Default will be used.. /// Default is walk which is the best in most cases. /// public void ReleaseLocator() { if (Locator == ARR_LOCATOR.NONE) return; Locator = ARR_LOCATOR.NONE; Kernel.ReleaseLocator(Ptr); } /// /// Query what the point hits in the arrangment. /// /// The point to query. /// What was hit. /// True if something was hit. public bool PointQuery(Point2d point, out ArrQuery result) { return Kernel.PointQuery(Ptr, point, out result); } /// /// Query multiple points in the arrangment. /// /// The points to query. /// The results for each point. /// True if any point hit something. public bool BatchedPointQuery(Point2d[] points, ArrQuery[] results) { ErrorUtil.CheckArray(points, points.Length); ErrorUtil.CheckArray(results, results.Length); return Kernel.BatchedPointQuery(Ptr, points, results, points.Length); } /// /// Query using a ray going up or down (y axis) from the query point. /// /// The point to start at. /// True to shoot ray up, false to shoot down. /// The result of what was hits. /// True if some thing was hit. public bool VerticalRayQuery(Point2d point, bool up, out ArrQuery result) { return Kernel.RayQuery(Ptr, point, up, out result); } /// /// Locate the vertex at this point. /// /// The point to locate vertex at. /// The vertex. /// True if a vertex was located. public bool LocateVertex(Point2d point, out ArrVertex2 vert) { vert = new ArrVertex2(); if (Kernel.PointQuery(Ptr, point, out ArrQuery result)) { if (result.Element == ARR_ELEMENT_HIT.VERTEX) { Kernel.GetVertex(Ptr, result.Index, out vert); return true; } else { return false; } } else { return false; } } /// /// Locate the closest vertex in the hit face /// /// The point /// The radius te closest vertex has to be within. /// The closest vertex. /// True if point hit a face and found a vertex. public bool LocateVertex(Point2d point, double radius, out ArrVertex2 vertex) { //Locate the face the point hit. vertex = new ArrVertex2(); if (LocateFace(point, out ArrFace2 face)) { //Find the closest vertex in the face to the point. double min = double.PositiveInfinity; var closest = new ArrVertex2(); foreach (var vert in face.EnumerateVertices(this)) { if (vert.Index == -1) continue; var sqdist = Point2d.SqrDistance(vert.Point, point); if (sqdist < min) { min = sqdist; closest = vert; } } if (min == double.PositiveInfinity || min > radius * radius) return false; else { vertex = closest; return true; } } return false; } /// /// Locate the edge at this point. /// /// The point to locate edge at. /// The edge. /// True if a edge was located. public bool LocateEdge(Point2d point, out ArrHalfedge2 edge) { edge = new ArrHalfedge2(); if (Kernel.PointQuery(Ptr, point, out ArrQuery result)) { if (result.Element == ARR_ELEMENT_HIT.HALF_EDGE) { Kernel.GetHalfEdge(Ptr, result.Index, out edge); return true; } else { return false; } } else { return false; } } /// /// Locate the closest edge in the hit face. /// /// The point /// The closest edge. /// The radius from the point a edge counts as being clicked on. /// True if the point hit a face and found a edge. public bool LocateEdge(Point2d point, double radius, out ArrHalfedge2 edge) { //Locate the face the point hit. edge = new ArrHalfedge2(); if (LocateFace(point, out ArrFace2 face)) { //Find the closest edge to the point in the face. double min = double.PositiveInfinity; var closest = new ArrHalfedge2(); foreach (var e in face.EnumerateEdges(this)) { ArrVertex2 v1, v2; if (!GetVertex(e.SourceIndex, out v1)) continue; if (!GetVertex(e.TargetIndex, out v2)) continue; var seg = new Segment2d(v1.Point, v2.Point); var sqdist = seg.SqrDistance(point); if (sqdist < min) { min = sqdist; closest = e; } } if (min == double.PositiveInfinity || min > radius * radius) return false; else { edge = closest; return true; } } return false; } /// /// Locate the faces at this point. /// /// The point to locate face at. /// The face. /// True if a face was located. public bool LocateFace(Point2d point, out ArrFace2 face) { face = new ArrFace2(); if(Kernel.PointQuery(Ptr, point, out ArrQuery result)) { if(result.Element == ARR_ELEMENT_HIT.FACE) { Kernel.GetFace(Ptr, result.Index, out face); return true; } else { return false; } } else { return false; } } /// /// Find if the arrangement has a element that intersects the segment. /// /// The segment. /// True if the segment intersects something in the arrangement. public bool IntersectsSegment(Segment2d segment) { return Kernel.IntersectsSegment(Ptr, segment); } /// /// Inserts a given point into a given arrangement. /// It uses a given point-location object to locate the given point in the given arrangement. /// If the point conincides with an existing vertex, there is nothing left to do. if it lies /// on an edge, the edge is split at the point. Otherwise, the point is contained inside a face, /// and is inserted as an isolated vertex inside this face. /// /// The point to insert. public void InsertPoint(Point2d point) { Kernel.InsertPoint(Ptr, point); } /// /// Insert the segment in to the arrangement. /// /// The segments start point. /// The segments end point. /// True if the segment is know not to /// hit anything currently in the arrangement. public void InsertSegment(Point2d a, Point2d b, bool nonIntersecting) { Kernel.InsertSegment(Ptr, new Segment2d(a, b), nonIntersecting); } /// /// Insert a segment into the arrangement. /// /// /// True if the segment is know not to /// hit anything currently in the arrangement. public void InsertSegment(Segment2d segment, bool nonIntersecting) { Kernel.InsertSegment(Ptr, segment, nonIntersecting); } /// /// Insert a array of segments into the arrangement. /// /// The segment array /// The segment arrays length. /// True if the segments are known not to /// hit anything currently in the arrangement. public void InsertSegments(Segment2d[] segments, int count, bool nonIntersecting) { ErrorUtil.CheckArray(segments, count); Kernel.InsertSegments(Ptr, segments, count, nonIntersecting); } /// /// Attempts to removed a given vertex from a given arrangement. /// The vertex can be removed if it is either an isolated vertex, /// (and has no incident edge,) or if it is a redundant vertex.That is, /// it has exactly two incident edges, whose associated curves can be /// merged to form a single x-monotone curve.The function returns a /// boolean value that indicates whether it succeeded removing the /// vertex from the arrangement. /// /// The index of the vertex in the arrangement. /// True if the vertex was removed. public bool RemoveVertex(int index) { return Kernel.RemoveVertexByIndex(Ptr, index); } /// /// Attempts to removed a given vertex from a given arrangement. /// The vertex can be removed if it is either an isolated vertex, /// (and has no incident edge,) or if it is a redundant vertex.That is, /// it has exactly two incident edges, whose associated curves can be /// merged to form a single x-monotone curve.The function returns a /// boolean value that indicates whether it succeeded removing the /// vertex from the arrangement. /// /// The poisition of the vertex in the arrangement. /// True if the vertex was removed. public bool RemoveVertex(Point2d point) { return Kernel.RemoveVertexByPoint(Ptr, point); } /// /// Removes an edge at the index from the arrangement. /// Once the edge is removed, if the vertices associated with its endpoints /// become isolated, they are removed as well. /// /// The index of the one of the half edges in the arrangement. /// True if the edge was removed. public bool RemoveEdge(int index) { return Kernel.RemoveEdgeByIndex(Ptr, index); } /// /// Removes an edge at the index from the arrangement. /// Once the edge is removed, if the vertices associated with its endpoints /// become isolated, they are removed as well. /// /// A segment with the same positions as the edge in the arrangement. /// True if the edge was removed. public bool RemoveEdge(Segment2d segment) { return Kernel.RemoveEdgeBySegment(Ptr, segment); } /// /// /// /// /// public void Print(StringBuilder builder, bool printElements) { builder.AppendLine(ToString()); builder.AppendLine("Isolated Vertex Count = " + IsolatedVerticesCount); builder.AppendLine("Vertex at Infinity Count = " + VerticesAtInfinityCount); builder.AppendLine("Edge Count = " + EdgeCount); builder.AppendLine("Unbounded Face Count = " + UnboundedFaceCount); if (printElements) { builder.AppendLine(); PrintVertices(builder); PrintHalfEdges(builder); PrintFaces(builder); } } /// /// /// /// public override void Print(StringBuilder builder) { builder.AppendLine(ToString()); builder.AppendLine("Isolated Vertex Count = " + IsolatedVerticesCount); builder.AppendLine("Vertex at Infinity Count = " + VerticesAtInfinityCount); builder.AppendLine("Edge Count = " + EdgeCount); builder.AppendLine("Unbounded Face Count = " + UnboundedFaceCount); } /// /// /// /// public void PrintVertices(StringBuilder builder) { builder.AppendLine("Arrangement Vertices.\n"); var vertices = new ArrVertex2[VertexCount]; GetVertices(vertices, vertices.Length); foreach (var v in vertices) { builder.AppendLine(v.ToString()); builder.AppendLine("Index = " + v.Index); builder.AppendLine("Face Index = " + v.FaceIndex); builder.AppendLine("HalfEdge Index = " + v.HalfEdgeIndex); builder.AppendLine(); } } /// /// /// /// public void PrintHalfEdges(StringBuilder builder) { builder.AppendLine("Arrangement Half Edges.\n"); var edges = new ArrHalfedge2[HalfEdgeCount]; GetHalfEdges(edges, edges.Length); foreach (var e in edges) { builder.AppendLine(e.ToString()); builder.AppendLine("Index = " + e.Index); builder.AppendLine("Source Index = " + e.SourceIndex); builder.AppendLine("Target Index = " + e.TargetIndex); builder.AppendLine("Face Index = " + e.FaceIndex); builder.AppendLine("Next Index = " + e.NextIndex); builder.AppendLine("Previous Index = " + e.PreviousIndex); builder.AppendLine("Twin Index = " + e.TwinIndex); builder.AppendLine(); } } /// /// /// /// public void PrintFaces(StringBuilder builder) { builder.AppendLine("Arrangement Faces.\n"); var faces = new ArrFace2[FaceCount]; GetFaces(faces, faces.Length); foreach (var e in faces) { builder.AppendLine(e.ToString()); builder.AppendLine("Index = " + e.Index); builder.AppendLine("HalfEdge Index = " + e.HalfEdgeIndex); builder.AppendLine(); } } /// /// Release any unmanaged resources. /// protected override void ReleasePtr() { Kernel.Release(Ptr); } } } ================================================ FILE: CGALDotNet/Arrangements/ArrangementKernel2.cs ================================================ using System; using System.Collections.Generic; using System.Text; using CGALDotNetGeometry.Numerics; using CGALDotNetGeometry.Shapes; namespace CGALDotNet.Arrangements { internal abstract class ArrangementKernel2 : CGALObjectKernel { internal abstract IntPtr Create(); internal abstract void Release(IntPtr ptr); internal abstract bool IsValid(IntPtr ptr); internal abstract void Clear(IntPtr ptr); internal abstract bool IsEmpty(IntPtr ptr); internal abstract int BuildStamp(IntPtr ptr); internal abstract void Assign(IntPtr ptr, IntPtr ptrOther); internal abstract IntPtr Overlay(IntPtr ptr, IntPtr ptrOther); internal abstract int VertexCount(IntPtr ptr); internal abstract int IsolatedVerticesCount(IntPtr ptr); internal abstract int VerticesAtInfinityCount(IntPtr ptr); internal abstract int HalfEdgeCount(IntPtr ptr); internal abstract int FaceCount(IntPtr ptr); internal abstract int EdgeCount(IntPtr ptr); internal abstract int UnboundedFaceCount(IntPtr ptr); internal abstract void GetPoints(IntPtr ptr, Point2d[] points, int count); internal abstract void GetSegments(IntPtr ptr, Segment2d[] segments, int count); internal abstract void GetVertices(IntPtr ptr, ArrVertex2[] vertices, int count); internal abstract bool GetVertex(IntPtr ptr, int index, out ArrVertex2 arrVertex); internal abstract void GetHalfEdges(IntPtr ptr, ArrHalfedge2[] edges, int count); internal abstract bool GetHalfEdge(IntPtr ptr, int index, out ArrHalfedge2 arrEdge); internal abstract void GetFaces(IntPtr ptr, ArrFace2[] faces, int count); internal abstract bool GetFace(IntPtr ptr, int index, out ArrFace2 arrFace); internal abstract int GetFaceHoleCount(IntPtr ptr, int index); internal abstract int GetHoleVertexCount(IntPtr ptr, int faceIndex, int holeIndex); internal abstract void CreateLocator(IntPtr ptr, ARR_LOCATOR type); internal abstract void ReleaseLocator(IntPtr ptr); internal abstract bool PointQuery(IntPtr ptr, Point2d point, out ArrQuery result); internal abstract bool BatchedPointQuery(IntPtr ptr, Point2d[] points, ArrQuery[] results, int count); internal abstract bool RayQuery(IntPtr ptr, Point2d point, bool up, out ArrQuery result); internal abstract bool IntersectsSegment(IntPtr ptr, Segment2d segment); internal abstract void InsertPoint(IntPtr ptr, Point2d point); internal abstract void InsertPolygon(IntPtr ptr, IntPtr polyPtr, bool nonItersecting); internal abstract void InsertPolygonWithHoles(IntPtr ptr, IntPtr pwhPtr, bool nonItersecting); internal abstract void InsertSegment(IntPtr ptr, Segment2d segment, bool nonItersecting); internal abstract void InsertSegments(IntPtr ptr, Segment2d[] segments, int count, bool nonItersecting); internal abstract bool RemoveVertexByIndex(IntPtr ptr, int index); internal abstract bool RemoveVertexByPoint(IntPtr ptr, Point2d point); internal abstract bool RemoveEdgeByIndex(IntPtr ptr, int index); internal abstract bool RemoveEdgeBySegment(IntPtr ptr, Segment2d segment); } } ================================================ FILE: CGALDotNet/Arrangements/ArrangementKernel2_EEK.cs ================================================ using System; using System.Collections.Generic; using System.Text; using System.Runtime.InteropServices; using CGALDotNetGeometry.Numerics; using CGALDotNetGeometry.Shapes; namespace CGALDotNet.Arrangements { internal class ArrangementKernel2_EEK : ArrangementKernel2 { internal override string Name => "EEK"; internal static readonly ArrangementKernel2 Instance = new ArrangementKernel2_EEK(); internal override IntPtr Create() { return Arrangement2_EEK_Create(); } internal override void Release(IntPtr ptr) { Arrangement2_EEK_Release(ptr); } internal override bool IsValid(IntPtr ptr) { return Arrangement2_EEK_IsValid(ptr); } internal override void Clear(IntPtr ptr) { Arrangement2_EEK_Clear(ptr); } internal override bool IsEmpty(IntPtr ptr) { return Arrangement2_EEK_IsEmpty(ptr); } internal override int BuildStamp(IntPtr ptr) { return Arrangement2_EEK_BuildStamp(ptr); } internal override void Assign(IntPtr ptr, IntPtr ptrOther) { Arrangement2_EEK_Assign(ptr, ptrOther); } internal override IntPtr Overlay(IntPtr ptr, IntPtr ptrOther) { return Arrangement2_EEK_Overlay(ptr, ptrOther); } internal override int VertexCount(IntPtr ptr) { return Arrangement2_EEK_VertexCount(ptr); } internal override int IsolatedVerticesCount(IntPtr ptr) { return Arrangement2_EEK_IsolatedVerticesCount(ptr); } internal override int VerticesAtInfinityCount(IntPtr ptr) { return Arrangement2_EEK_VerticesAtInfinityCount(ptr); } internal override int HalfEdgeCount(IntPtr ptr) { return Arrangement2_EEK_HalfEdgeCount(ptr); } internal override int FaceCount(IntPtr ptr) { return Arrangement2_EEK_FaceCount(ptr); } internal override int EdgeCount(IntPtr ptr) { return Arrangement2_EEK_EdgeCount(ptr); } internal override int UnboundedFaceCount(IntPtr ptr) { return Arrangement2_EEK_UnboundedFaceCount(ptr); } internal override void GetPoints(IntPtr ptr, Point2d[] points, int count) { Arrangement2_EEK_GetPoints(ptr, points, count); } internal override void GetSegments(IntPtr ptr, Segment2d[] segments, int count) { Arrangement2_EEK_GetSegments(ptr, segments, count); } internal override void GetVertices(IntPtr ptr, ArrVertex2[] vertices, int count) { Arrangement2_EEK_GetVertices(ptr, vertices, count); } internal override bool GetVertex(IntPtr ptr, int index, out ArrVertex2 arrVertex) { return Arrangement2_EEK_GetVertex(ptr, index, out arrVertex); } internal override void GetHalfEdges(IntPtr ptr, ArrHalfedge2[] edges, int count) { Arrangement2_EEK_GetHalfEdges(ptr, edges, count); } internal override bool GetHalfEdge(IntPtr ptr, int index, out ArrHalfedge2 arrEdge) { return Arrangement2_EEK_GetHalfEdge(ptr, index, out arrEdge); } internal override void GetFaces(IntPtr ptr, ArrFace2[] faces, int count) { Arrangement2_EEK_GetFaces(ptr, faces, count); } internal override bool GetFace(IntPtr ptr, int index, out ArrFace2 arrFace) { return Arrangement2_EEK_GetFace(ptr, index, out arrFace); } internal override int GetFaceHoleCount(IntPtr ptr, int index) { return Arrangement2_EEK_GetFaceHoleCount(ptr, index); } internal override int GetHoleVertexCount(IntPtr ptr, int faceIndex, int holeIndex) { return Arrangement2_EEK_GetHoleVertexCount(ptr, faceIndex, holeIndex); } internal override void CreateLocator(IntPtr ptr, ARR_LOCATOR type) { Arrangement2_EEK_CreateLocator(ptr, type); } internal override void ReleaseLocator(IntPtr ptr) { Arrangement2_EEK_ReleaseLocator(ptr); } internal override bool PointQuery(IntPtr ptr, Point2d point, out ArrQuery result) { return Arrangement2_EEK_PointQuery(ptr, point, out result); } internal override bool BatchedPointQuery(IntPtr ptr, Point2d[] points, ArrQuery[] results, int count) { return Arrangement2_EEK_BatchedPointQuery(ptr, points, results, count); } internal override bool RayQuery(IntPtr ptr, Point2d point, bool up, out ArrQuery result) { return Arrangement2_EEK_RayQuery(ptr, point, up, out result); } internal override bool IntersectsSegment(IntPtr ptr, Segment2d segment) { return Arrangement2_EEK_IntersectsSegment(ptr, segment); } internal override void InsertPoint(IntPtr ptr, Point2d point) { Arrangement2_EEK_InsertPoint(ptr, point); } internal override void InsertPolygon(IntPtr ptr, IntPtr polyPtr, bool nonItersecting) { Arrangement2_EEK_InsertPolygon(ptr, polyPtr, nonItersecting); } internal override void InsertPolygonWithHoles(IntPtr ptr, IntPtr pwhPtr, bool nonItersecting) { Arrangement2_EEK_InsertPolygonWithHoles(ptr, pwhPtr, nonItersecting); } internal override void InsertSegment(IntPtr ptr, Segment2d segment, bool nonItersecting) { Arrangement2_EEK_InsertSegment(ptr, segment, nonItersecting); } internal override void InsertSegments(IntPtr ptr, Segment2d[] segments, int count, bool nonItersecting) { Arrangement2_EEK_InsertSegments(ptr, segments, count, nonItersecting); } internal override bool RemoveVertexByIndex(IntPtr ptr, int index) { return Arrangement2_EEK_RemoveVertexByIndex(ptr, index); } internal override bool RemoveVertexByPoint(IntPtr ptr, Point2d point) { return Arrangement2_EEK_RemoveVertexByPoint(ptr, point); } internal override bool RemoveEdgeByIndex(IntPtr ptr, int index) { return Arrangement2_EEK_RemoveEdgeByIndex(ptr, index); } internal override bool RemoveEdgeBySegment(IntPtr ptr, Segment2d segment) { return Arrangement2_EEK_RemoveEdgeBySegment(ptr, segment); } [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr Arrangement2_EEK_Create(); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void Arrangement2_EEK_Release(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool Arrangement2_EEK_IsValid(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void Arrangement2_EEK_Clear(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool Arrangement2_EEK_IsEmpty(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int Arrangement2_EEK_BuildStamp(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void Arrangement2_EEK_Assign(IntPtr ptr, IntPtr ptrOther); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr Arrangement2_EEK_Overlay(IntPtr ptr, IntPtr ptrOther); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int Arrangement2_EEK_VertexCount(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int Arrangement2_EEK_IsolatedVerticesCount(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int Arrangement2_EEK_VerticesAtInfinityCount(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int Arrangement2_EEK_HalfEdgeCount(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int Arrangement2_EEK_FaceCount(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int Arrangement2_EEK_EdgeCount(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int Arrangement2_EEK_UnboundedFaceCount(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void Arrangement2_EEK_GetPoints(IntPtr ptr, [Out] Point2d[] points, int count); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void Arrangement2_EEK_GetSegments(IntPtr ptr, [Out] Segment2d[] segments, int count); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void Arrangement2_EEK_GetVertices(IntPtr ptr, [Out] ArrVertex2[] vertices, int count); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool Arrangement2_EEK_GetVertex(IntPtr ptr, int index, [Out] out ArrVertex2 arrVertex); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void Arrangement2_EEK_GetHalfEdges(IntPtr ptr, [Out] ArrHalfedge2[] edges, int count); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool Arrangement2_EEK_GetHalfEdge(IntPtr ptr, int index, [Out] out ArrHalfedge2 arrEdge); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void Arrangement2_EEK_GetFaces(IntPtr ptr, [Out] ArrFace2[] faces, int count); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool Arrangement2_EEK_GetFace(IntPtr ptr, int index, [Out] out ArrFace2 arrFace); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int Arrangement2_EEK_GetFaceHoleCount(IntPtr ptr, int index); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int Arrangement2_EEK_GetHoleVertexCount(IntPtr ptr, int faceIndex, int holeIndex); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void Arrangement2_EEK_CreateLocator(IntPtr ptr, ARR_LOCATOR type); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void Arrangement2_EEK_ReleaseLocator(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool Arrangement2_EEK_PointQuery(IntPtr ptr, Point2d point, [Out] out ArrQuery result); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool Arrangement2_EEK_BatchedPointQuery(IntPtr ptr, [Out] Point2d[] points, [Out] ArrQuery[] results, int count); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool Arrangement2_EEK_RayQuery(IntPtr ptr, Point2d point, bool up, [Out] out ArrQuery result); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool Arrangement2_EEK_IntersectsSegment(IntPtr ptr, Segment2d segment); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void Arrangement2_EEK_InsertPoint(IntPtr ptr, Point2d point); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void Arrangement2_EEK_InsertPolygon(IntPtr ptr, IntPtr polyPtr, bool nonItersecting); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void Arrangement2_EEK_InsertPolygonWithHoles(IntPtr ptr, IntPtr pwhPtr, bool nonItersecting); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void Arrangement2_EEK_InsertSegment(IntPtr ptr, Segment2d segment, bool nonItersecting); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void Arrangement2_EEK_InsertSegments(IntPtr ptr, [In] Segment2d[] points, int count, bool nonItersecting); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool Arrangement2_EEK_RemoveVertexByIndex(IntPtr ptr, int index); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool Arrangement2_EEK_RemoveVertexByPoint(IntPtr ptr, Point2d point); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool Arrangement2_EEK_RemoveEdgeByIndex(IntPtr ptr, int index); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool Arrangement2_EEK_RemoveEdgeBySegment(IntPtr ptr, Segment2d segment); } } ================================================ FILE: CGALDotNet/Arrangements/SweepLine.cs ================================================ using System; using System.Collections.Generic; using System.Text; using CGALDotNetGeometry.Numerics; using CGALDotNetGeometry.Shapes; namespace CGALDotNet.Arrangements { /// /// The generic sweep line class. /// /// The kernel. public sealed class SweepLine : SweepLine where K : CGALKernel, new() { /// /// A static instanceof a sweep line. /// public static readonly SweepLine Instance = new SweepLine(); /// /// Default constructor. /// public SweepLine() : base(new K()) { } /// /// Create from a unmanaged pointer. /// /// internal SweepLine(IntPtr ptr) : base(new K(), ptr) { } /// /// The sweep line as a string. /// /// public override string ToString() { return string.Format("[SweepLine<{0}>: ]", Kernel.Name); } } /// /// The abstract sweep line. /// public abstract class SweepLine : CGALObject { /// /// The default sweep line. /// private SweepLine() { } /// /// Create from the kernel. /// /// A kernel that implements a sweep line. internal SweepLine(CGALKernel kernel) { Kernel = kernel.SweepLineKernel; Ptr = Kernel.Create(); } /// /// Create from the kernel and unmanaged pointer. /// /// A kernel that implements a sweep line. /// A unmanaged pointer to a sweep line. internal SweepLine(CGALKernel kernel, IntPtr ptr) : base(ptr) { Kernel = kernel.SweepLineKernel; } /// /// The sweep line kernel. /// protected private SweepLineKernel Kernel { get; private set; } /// /// Do any of the segments in the array intersect. /// /// The segment array. /// The ararys length. /// Do any of the segments in the array intersect. public bool DoIntersect(Segment2d[] segments, int count) { ErrorUtil.CheckArray(segments, count); return Kernel.DoIntersect(Ptr, segments, count); } /// /// Compute all the sub segemnts from the intersection /// of the segments in the array. /// /// The segment array. /// The ararys length. /// The sub segments. public Segment2d[] ComputeSubcurves(Segment2d[] segments, int count) { ErrorUtil.CheckArray(segments, count); int len = Kernel.ComputeSubcurves(Ptr, segments, count); var subSegments = new Segment2d[len]; if (len > 0) { GetSegments(subSegments, len); ClearSegmentBuffer(); } return subSegments; } /// /// Compute all the intersection points from the /// segments in the array. /// /// The segment array. /// The ararys length. /// The intersection points. public Point2d[] ComputeIntersectionPoints(Segment2d[] segments, int count) { ErrorUtil.CheckArray(segments, count); int len = Kernel.ComputeIntersectionPoints(Ptr, segments, count); var points = new Point2d[len]; if (len > 0) { GetPoints(points, len); ClearPointBuffer(); } return points; } /// /// Get all the points in the point buffer. /// /// A point array the size of the point buffer. /// The ararys length. private void GetPoints(Point2d[] points, int count) { ErrorUtil.CheckArray(points, count); Kernel.GetPoints(Ptr, points, count); } /// /// Get all the segments in the point buffer. /// /// A segment array the size of the segment buffer. /// The ararys length. private void GetSegments(Segment2d[] segments, int count) { ErrorUtil.CheckArray(segments, count); Kernel.GetSegments(Ptr, segments, count); } /// /// Clear the point buffer. /// private void ClearPointBuffer() { Kernel.ClearPointBuffer(Ptr); } /// /// Clear the segment buffer. /// private void ClearSegmentBuffer() { Kernel.ClearSegmentBuffer(Ptr); } /// /// /// /// private int PointBufferSize() { return Kernel.PointBufferSize(Ptr); } /// /// /// /// private int SegmentBufferSize() { return Kernel.SegmentBufferSize(Ptr); } /// /// Release any unmanaged resources. /// protected override void ReleasePtr() { Kernel.Release(Ptr); } } } ================================================ FILE: CGALDotNet/Arrangements/SweepLineKernel.cs ================================================ using System; using System.Collections.Generic; using System.Text; using CGALDotNetGeometry.Numerics; using CGALDotNetGeometry.Shapes; namespace CGALDotNet.Arrangements { internal abstract class SweepLineKernel : CGALObjectKernel { internal abstract IntPtr Create(); internal abstract void Release(IntPtr ptr); internal abstract void ClearPointBuffer(IntPtr ptr); internal abstract void ClearSegmentBuffer(IntPtr ptr); internal abstract int PointBufferSize(IntPtr ptr); internal abstract int SegmentBufferSize(IntPtr ptr); internal abstract bool DoIntersect(IntPtr ptr, Segment2d[] segments, int count); internal abstract int ComputeSubcurves(IntPtr ptr, Segment2d[] segments, int count); internal abstract int ComputeIntersectionPoints(IntPtr ptr, Segment2d[] segments, int count); internal abstract void GetPoints(IntPtr ptr, Point2d[] points, int count); internal abstract void GetSegments(IntPtr ptr, Segment2d[] segments, int count); } } ================================================ FILE: CGALDotNet/Arrangements/SweepLineKernel_EEK.cs ================================================ using System; using System.Collections.Generic; using System.Text; using System.Runtime.InteropServices; using CGALDotNetGeometry.Numerics; using CGALDotNetGeometry.Shapes; namespace CGALDotNet.Arrangements { internal class SweepLineKernel_EEK : SweepLineKernel { internal override string Name => "EEK"; internal static readonly SweepLineKernel Instance = new SweepLineKernel_EEK(); internal override IntPtr Create() { return SweepLine2_EEK_Create(); } internal override void Release(IntPtr ptr) { SweepLine2_EEK_Release(ptr); } internal override void ClearPointBuffer(IntPtr ptr) { SweepLine2_EEK_ClearPointBuffer(ptr); } internal override void ClearSegmentBuffer(IntPtr ptr) { SweepLine2_EEK_ClearSegmentBuffer(ptr); } internal override int PointBufferSize(IntPtr ptr) { return SweepLine2_EEK_PointBufferSize(ptr); } internal override int SegmentBufferSize(IntPtr ptr) { return SweepLine2_EEK_SegmentBufferSize(ptr); } internal override bool DoIntersect(IntPtr ptr, Segment2d[] segments, int count) { return SweepLine2_EEK_DoIntersect(ptr, segments, count); } internal override int ComputeSubcurves(IntPtr ptr, Segment2d[] segments, int count) { return SweepLine2_EEK_ComputeSubcurves(ptr, segments, count); } internal override int ComputeIntersectionPoints(IntPtr ptr, Segment2d[] segments, int count) { return SweepLine2_EEK_ComputeIntersectionPoints(ptr, segments, count); } internal override void GetPoints(IntPtr ptr, Point2d[] points, int count) { SweepLine2_EEK_GetPoints(ptr, points, count); } internal override void GetSegments(IntPtr ptr, Segment2d[] segments, int count) { SweepLine2_EEK_GetSegments(ptr, segments, count); } [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr SweepLine2_EEK_Create(); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void SweepLine2_EEK_Release(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void SweepLine2_EEK_ClearPointBuffer(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void SweepLine2_EEK_ClearSegmentBuffer(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int SweepLine2_EEK_PointBufferSize(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int SweepLine2_EEK_SegmentBufferSize(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool SweepLine2_EEK_DoIntersect(IntPtr ptr, [In] Segment2d[] segments, int count); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int SweepLine2_EEK_ComputeSubcurves(IntPtr ptr, [In] Segment2d[] segments, int count); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int SweepLine2_EEK_ComputeIntersectionPoints(IntPtr ptr, [In] Segment2d[] segments, int count); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void SweepLine2_EEK_GetPoints(IntPtr ptr, [Out] Point2d[] points, int count); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void SweepLine2_EEK_GetSegments(IntPtr ptr, [Out] Segment2d[] segments, int count); } } ================================================ FILE: CGALDotNet/Arrangements/SweepLineKernel_EIK.cs ================================================ using System; using System.Collections.Generic; using System.Text; using System.Runtime.InteropServices; using CGALDotNetGeometry.Numerics; using CGALDotNetGeometry.Shapes; namespace CGALDotNet.Arrangements { internal class SweepLineKernel_EIK : SweepLineKernel { internal override string Name => "EIK"; internal static readonly SweepLineKernel Instance = new SweepLineKernel_EIK(); internal override IntPtr Create() { return SweepLine2_EIK_Create(); } internal override void Release(IntPtr ptr) { SweepLine2_EIK_Release(ptr); } internal override void ClearPointBuffer(IntPtr ptr) { SweepLine2_EIK_ClearPointBuffer(ptr); } internal override void ClearSegmentBuffer(IntPtr ptr) { SweepLine2_EIK_ClearSegmentBuffer(ptr); } internal override int PointBufferSize(IntPtr ptr) { return SweepLine2_EIK_PointBufferSize(ptr); } internal override int SegmentBufferSize(IntPtr ptr) { return SweepLine2_EIK_SegmentBufferSize(ptr); } internal override bool DoIntersect(IntPtr ptr, Segment2d[] segments, int count) { return SweepLine2_EIK_DoIntersect(ptr, segments, count); } internal override int ComputeSubcurves(IntPtr ptr, Segment2d[] segments, int count) { return SweepLine2_EIK_ComputeSubcurves(ptr, segments, count); } internal override int ComputeIntersectionPoints(IntPtr ptr, Segment2d[] segments, int count) { return SweepLine2_EIK_ComputeIntersectionPoints(ptr, segments, count); } internal override void GetPoints(IntPtr ptr, Point2d[] points, int count) { SweepLine2_EIK_GetPoints(ptr, points, count); } internal override void GetSegments(IntPtr ptr, Segment2d[] segments, int count) { SweepLine2_EIK_GetSegments(ptr, segments, count); } [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr SweepLine2_EIK_Create(); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void SweepLine2_EIK_Release(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void SweepLine2_EIK_ClearPointBuffer(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void SweepLine2_EIK_ClearSegmentBuffer(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int SweepLine2_EIK_PointBufferSize(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int SweepLine2_EIK_SegmentBufferSize(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool SweepLine2_EIK_DoIntersect(IntPtr ptr, [In] Segment2d[] segments, int count); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int SweepLine2_EIK_ComputeSubcurves(IntPtr ptr, [In] Segment2d[] segments, int count); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int SweepLine2_EIK_ComputeIntersectionPoints(IntPtr ptr, [In] Segment2d[] segments, int count); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void SweepLine2_EIK_GetPoints(IntPtr ptr, [Out] Point2d[] points, int count); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void SweepLine2_EIK_GetSegments(IntPtr ptr, [Out] Segment2d[] segments, int count); } } ================================================ FILE: CGALDotNet/CGALDotNet.csproj ================================================  netcoreapp3.1 OnBuildSuccess True F:\Projects\Visual Studio Projects\CGALDotNet\CGALDotNet\CGALDotNet.xml true true AnyCPU F:\Projects\Visual Studio Projects\CGALDotNet\CGALDotNet\CGALDotNet.xml ..\..\CGALDotNetGeometry\CGALDotNetGeometry\bin\Release\netcoreapp3.1\CGALDotNetGeometry.dll ================================================ FILE: CGALDotNet/CGALDotNet.xml ================================================ CGALDotNet The generic arrangment class. The kernel type. The default constructor. Create a arrangement from a unmanaged ptr. The unmanaged pointer. The arrangement as a string. Assigns the contents of another arrangement. The other arrangement. Computes the overlay of two arrangements and return as a new arrangement. The other arrangement. The overlay of both arrangements. Create a deep copy of this arrangment. The deep copy. Insert the polygon into this arrangement. The polygon. If the polygon intersects anything else in the arramgement. Insert the polygon into this arrangement. The polygon. If the polygon intersects anything else in the arramgement. The abstract base class. The default constructor. Create a arrangement from the kernel. The kernel. Create a arrangement from the kernel and unmanaged pointer. The kernel. The unmanaged pointer. The arrangements kernel. The number of vertices in the arrangement. The number of vertices in the arrangement that are i returns the number of arrangement vertices that lie at infinity a nd are not associated with valid points. Such vertices are not considered to be regular arrangement vertices and VertexCount does not count them. The number of half edges. The number of edges. two half edges count as one edge. The number of faces in the arrangement not counting the unbounded face. returns the number of unbounded faces in the arrangement. Such faces are not considered to be regular arrangement faces and FaceCount does not count them. The type of locator used to find element in the arrangement when queried. Default is walk which is the best in most cases Is the arrangement empty. A number that will change if the unmanaged arrangement model changes. Clear the arrangement. In particular, the functions checks the topological structure of the arrangement and assures that it is valid. In addition, the function performs several simple geometric tests to ensure the validity of some of the geometric properties of the arrangement. Namely, it checks that all arrangement vertices are associated with distinct points, and that the halfedges around every vertex are ordered clockwise. Get a copy of all the points in the arrangement. A point array that is the length of the vertex count. The ararys length. Get a copy of all the segments in the arrangment. A segment array that is the length of the edge count. The ararys length. Get a copy of all the vertices in the arrangement. A vertices array that is the length of the vertex count. The ararys length. Get the vertex from the arrangement. The index of the vertex. The vertex. True if the vertex was found. Get a copy of all the half edges in the arrangement. A half edge array that is the length of the half edge count. The ararys length. Get the half edge from the arrangement. The index of the half edge. The half edge. True if the half edge was found. Get a copy of all the faces in the arrangement. A face array that is the length of the facee count. The ararys length. Get the face from the arrangement. The index of the half edge. The face. True if the face was found. Create the locator used to find query the arrangement. The locator type. Release the locator. Default will be used.. Default is walk which is the best in most cases. Query what the point hits in the arrangment. The point to query. What was hit. True if something was hit. Query multiple points in the arrangment. The points to query. The results for each point. True if any point hit something. Query using a ray going up or down (y axis) from the query point. The point to start at. True to shoot ray up, false to shoot down. The result of what was hits. True if some thing was hit. Locate the vertex at this point. The point to locate vertex at. The vertex. True if a vertex was located. Locate the closest vertex in the hit face The point The radius te closest vertex has to be within. The closest vertex. True if point hit a face and found a vertex. Locate the edge at this point. The point to locate edge at. The edge. True if a edge was located. Locate the closest edge in the hit face. The point The closest edge. The radius from the point a edge counts as being clicked on. True if the point hit a face and found a edge. Locate the faces at this point. The point to locate face at. The face. True if a face was located. Find if the arrangement has a element that intersects the segment. The segment. True if the segment intersects something in the arrangement. Inserts a given point into a given arrangement. It uses a given point-location object to locate the given point in the given arrangement. If the point conincides with an existing vertex, there is nothing left to do. if it lies on an edge, the edge is split at the point. Otherwise, the point is contained inside a face, and is inserted as an isolated vertex inside this face. The point to insert. Insert the segment in to the arrangement. The segments start point. The segments end point. True if the segment is know not to hit anything currently in the arrangement. Insert a segment into the arrangement. True if the segment is know not to hit anything currently in the arrangement. Insert a array of segments into the arrangement. The segment array The segment arrays length. True if the segments are known not to hit anything currently in the arrangement. Attempts to removed a given vertex from a given arrangement. The vertex can be removed if it is either an isolated vertex, (and has no incident edge,) or if it is a redundant vertex.That is, it has exactly two incident edges, whose associated curves can be merged to form a single x-monotone curve.The function returns a boolean value that indicates whether it succeeded removing the vertex from the arrangement. The index of the vertex in the arrangement. True if the vertex was removed. Attempts to removed a given vertex from a given arrangement. The vertex can be removed if it is either an isolated vertex, (and has no incident edge,) or if it is a redundant vertex.That is, it has exactly two incident edges, whose associated curves can be merged to form a single x-monotone curve.The function returns a boolean value that indicates whether it succeeded removing the vertex from the arrangement. The poisition of the vertex in the arrangement. True if the vertex was removed. Removes an edge at the index from the arrangement. Once the edge is removed, if the vertices associated with its endpoints become isolated, they are removed as well. The index of the one of the half edges in the arrangement. True if the edge was removed. Removes an edge at the index from the arrangement. Once the edge is removed, if the vertices associated with its endpoints become isolated, they are removed as well. A segment with the same positions as the edge in the arrangement. True if the edge was removed. Release any unmanaged resources. The generic sweep line class. The kernel. A static instanceof a sweep line. Default constructor. Create from a unmanaged pointer. The sweep line as a string. The abstract sweep line. The default sweep line. Create from the kernel. A kernel that implements a sweep line. Create from the kernel and unmanaged pointer. A kernel that implements a sweep line. A unmanaged pointer to a sweep line. The sweep line kernel. Do any of the segments in the array intersect. The segment array. The ararys length. Do any of the segments in the array intersect. Compute all the sub segemnts from the intersection of the segments in the array. The segment array. The ararys length. The sub segments. Compute all the intersection points from the segments in the array. The segment array. The ararys length. The intersection points. Get all the points in the point buffer. A point array the size of the point buffer. The ararys length. Get all the segments in the point buffer. A segment array the size of the segment buffer. The ararys length. Clear the point buffer. Clear the segment buffer. Release any unmanaged resources. Global utility functions. Get the version of CGAL in use. Get the version of eigen being used. Returns OBTUSE, RIGHT or ACUTE depending on the angle formed by the two vectors u and v. The first vector. The second vector. OBTUSE, RIGHT or ACUTE depending on the angle formed by the two vectors u and v. Returns OBTUSE, RIGHT or ACUTE depending on the angle formed by the two vectors u and v. The first vector. The second vector. OBTUSE, RIGHT or ACUTE depending on the angle formed by the two vectors u and v. Returns OBTUSE, RIGHT or ACUTE depending on the angle formed by the two vectors u and v. The first vector. The second vector. OBTUSE, RIGHT or ACUTE depending on the angle formed by the two vectors u and v. returns OBTUSE, RIGHT or ACUTE depending on the angle formed by the two vectors u and v. The first vector. The second vector. OBTUSE, RIGHT or ACUTE depending on the angle formed by the two vectors u and v. Returns an approximation of the angle between u and v. The first vector. The second vector. The angle is given in degrees. Returns an approximation of the angle between p-q and r-q. The first tetrahedrons point. The second tetrahedrons point. The third tetrahedrons point. The angle is given in degrees. Returns an approximation of the angle between u and v. The first vector. The second vector. The angle is given in degrees. Returns an approximation of the angle between p-q and r-q. The first tetrahedrons point. The second tetrahedrons point. The third tetrahedrons point. The angle is given in degrees. Returns an approximation of the signed dihedral angle in the tetrahedron pqrs of edge pq. p,q,r and p,q,s are not collinear. The first tetrahedrons point. The second tetrahedrons point. The third tetrahedrons point. The fourth tetrahedrons point. The sign is negative if orientation(p,q,r,s) is CGAL::NEGATIVE and positive otherwise. The angle is given in degrees. Returns true, if the three points are collinear and q lies between p and r. Note that true is returned, if q==p or q==r. The first point. The second point. The third point. Returns true, if the three points are collinear and q lies between p and r. Returns true, if the three points are collinear and q lies between p and r. Note that true is returned, if q==p or q==r. The first point. The second point. The third point. Returns true, if the three points are collinear and q lies between p and r. Returns true, if the three points are collinear and q lies between p and r. Note that true is returned, if q==p or q==r. The first point. The second point. The third point. Returns true, if the three points are collinear and q lies between p and r. Returns true, if the three points are collinear and q lies between p and r. Note that true is returned, if q==p or q==r. The first point. The second point. The third point. Returns true, if the three points are collinear and q lies between p and r. returns true, if the three points are collinear and q lies strictly between p and r. Note that false is returned, if q==p or q==r. The first point. The second point. The third point. returns true, iff the three points are collinear and q lies strictly between p and r. returns true, if the three points are collinear and q lies strictly between p and r. Note that false is returned, if q==p or q==r. The first point. The second point. The third point. returns true, iff the three points are collinear and q lies strictly between p and r. returns true, if the three points are collinear and q lies strictly between p and r. Note that false is returned, if q==p or q==r. The first point. The second point. The third point. returns true, iff the three points are collinear and q lies strictly between p and r. returns true, if the three points are collinear and q lies strictly between p and r. Note that false is returned, if q==p or q==r. The first point. The second point. The third point. returns true, iff the three points are collinear and q lies strictly between p and r. Returns true, if p, q, and r are collinear The first point. The second point. The third point. returns true, if p, q, and r are collinear Returns true, if p, q, and r are collinear The first point. The second point. The third point. returns true, if p, q, and r are collinear Returns true, if p, q, and r are collinear The first point. The second point. The third point. returns true, if p, q, and r are collinear Returns true, if p, q, and r are collinear The first point. The second point. The third point. Returns true, iff p, q, and r are collinear Compute the barycenter of the points p1, p2 and p3 with corresponding weights w1, w2 and w3 as 1. The first point. The second point. The third point. Compute the barycenter of the points. Compute the barycenter of the points p1, p2 and p3 with corresponding weights w1, w2 and w3 as 1. The first point. The second point. The third point. Compute the barycenter of the points. Compute the barycenter of the points p1, p2 and p3 with corresponding weights w1, w2 and w3 as 1. The first point. The second point. The third point. Compute the barycenter of the points. Compute the barycenter of the points p1, p2 and p3 with corresponding weights w1, w2 and w3 as 1. The first point. The second point. The third point. Compute the barycenter of the points. Constructs the bisector line of the two points p and q. The bisector is oriented in such a way that p lies on its positive side. The first point. The second point. Constructs the bisector line of the two points p and q. Constructs the bisector of the two lines l1 and l2. In the general case, the bisector has the direction of the vector which is the sum of the normalized directions of the two lines, and which passes through the intersection of l1 and l2. If l1 and l2 are parallel, then the bisector is defined as the line which has the same direction as l1, and which is at the same distance from l1 and l2. If Kernel::FT is not a model of FieldWithSqrt an approximation of the square root will be used in this function, impacting the exactness of the result even with an (exact) multiprecision number type. The first line. The second line. Constructs the bisector of the two lines l1 and l2. Constructs the bisector of the two lines l1 and l2. In the general case, the bisector has the direction of the vector which is the sum of the normalized directions of the two lines, and which passes through the intersection of l1 and l2. If l1 and l2 are parallel, then the bisector is defined as the line which has the same direction as l1, and which is at the same distance from l1 and l2. If Kernel::FT is not a model of FieldWithSqrt an approximation of the square root will be used in this function, impacting the exactness of the result even with an (exact) multiprecision number type. The first line. The second line. Constructs the bisector of the two lines l1 and l2. Constructs the bisector of the two lines l1 and l2. In the general case, the bisector has the direction of the vector which is the sum of the normalized directions of the two lines, and which passes through the intersection of l1 and l2. If l1 and l2 are parallel, then the bisector is defined as the line which has the same direction as l1, and which is at the same distance from l1 and l2. If Kernel::FT is not a model of FieldWithSqrt an approximation of the square root will be used in this function, impacting the exactness of the result even with an (exact) multiprecision number type. The first line. The second line. Constructs the bisector of the two lines l1 and l2. Returns true, if p, q, r, and s are coplanar. The first point. The second point. The third point. The fourth point Returns true, if p, q, r, and s are coplanar. If p,q,r are collinear, then CGAL_COLLINEAR is returned. If not, then p,q,r define a plane p. The return value in this case is either CGAL_POSITIVE or CGAL_NEGATIVE, but we don't specify it explicitly. However, we guarantee that all calls to this predicate over 3 points in p will return a coherent orientation if considered a 2D orientation in p The first point. The second point. The third point. If p,q,r are collinear, then CGAL_COLLINEAR is returned. Let P be the plane defined by the points p, q, and r. Note that the order defines the orientation of P. The function computes the orientation of points p, q, and s in P: If p, q, s are collinear, CGAL_COLLINEAR is returned. If P and the plane defined by p, q, and s have the same orientation, CGAL_POSITIVE is returned; otherwise CGAL_NEGATIVE is returned. p, q, r, and s are coplanar and p, q, and r are not collinear. The first point. The second point. The third point. The fourth point Constructs the line which is at the same distance from the three points p, q and r. p, q and r are not collinear. Constructs the line which is at the same distance from the three points p, q and r. Returns true if p, q, and r form a left turn. The first point. The second point. The third point. Returns true if p, q, and r form a left turn. Returns true if p, q, and r form a left turn. The first point. The second point. The third point. Returns true if p, q, and r form a left turn. Returns true if p, q, and r form a left turn. The first point. The second point. The third point. Returns true if p, q, and r form a left turn. Returns true if p, q, and r form a right turn. The first point. The second point. The third point. Returns true if p, q, and r form a right turn. Returns true if p, q, and r form a right turn. The first point. The second point. The third point. Returns true if p, q, and r form a right turn. Returns true if p, q, and r form a right turn. The first point. The second point. The third point. Returns true if p, q, and r form a right turn. Returns LEFT_TURN, if r lies to the left of the oriented line l defined by p and q, returns RIGHT_TURN if r lies to the right of l, and returns COLLINEAR if r lies on l. The first point. The second point. The third point. Returns LEFT_TURN, if r lies to the left of the oriented line l defined by p and q, returns RIGHT_TURN if r lies to the right of l, and returns COLLINEAR if r lies on l. The first point. The second point. The third point. Returns LEFT_TURN, if r lies to the left of the oriented line l defined by p and q, returns RIGHT_TURN if r lies to the right of l, and returns COLLINEAR if r lies on l. The first point. The second point. The third point. returns LEFT_TURN if u and v form a left turn, returns RIGHT_TURN if u and v form a right turn, and returns COLLINEAR if u and v are collinear. Returns LEFT_TURN, if r lies to the left of the oriented line l defined by p and q, returns RIGHT_TURN if r lies to the right of l, and returns COLLINEAR if r lies on l. The first point. The second point. Returns LEFT_TURN, if r lies to the left of the oriented line l defined by p and q, returns RIGHT_TURN if r lies to the right of l, and returns COLLINEAR if r lies on l. The first point. The second point. returns POSITIVE, if s lies on the positive side of the oriented plane h defined by p, q, and r, returns NEGATIVE if s lies on the negative side of h, and returns COPLANAR if s lies on h. The first point. The second point. The third point. The fourth point returns NEGATIVE if u, v and w are negatively oriented, POSITIVE if u, v and w are positively oriented, and COPLANAR if u, v and w are coplanar. computes an orthogonal vector of the plane defined by p, q and r, which is directed to the positive side of this plane. The first point. The second point. The third point. computes an orthogonal vector of the plane returns true, if l1 and l2 are parallel or if one of those (or both) is degenerate. The first line. The seconed line. returns true, if l1 and l2 are parallel returns true, if l1 and l2 are parallel or if one of those (or both) is degenerate. The first line. The seconed line. returns true, if l1 and l2 are parallel returns true, if l1 and l2 are parallel or if one of those (or both) is degenerate. The first line. The seconed line. returns true, if l1 and l2 are parallel returns true, if r1 and r2 are parallel or if one of those (or both) is degenerate. The first ray. The second ray. returns true, if r1 and r2 are parallel returns true, if r1 and r2 are parallel or if one of those (or both) is degenerate. The first ray. The second ray. returns true, if r1 and r2 are parallel returns true, if r1 and r2 are parallel or if one of those (or both) is degenerate. The first ray. The second ray. returns true, if r1 and r2 are parallel returns true, if s1 and s2 are parallel or if one of those (or both) is degenerate. The first segment. The secong segment. returns true, if s1 and s2 are parallel returns true, if s1 and s2 are parallel or if one of those (or both) is degenerate. The first segment. The secong segment. returns true, if s1 and s2 are parallel returns true, if s1 and s2 are parallel or if one of those (or both) is degenerate. The first segment. The secong segment. returns true, if s1 and s2 are parallel Base class for objects that referrence a CGAL object. The pointer to the unmanged CGAL object. Default constructor. Constructor taking a referrence to a CGAL object. A pointer to a CGAL object. The destuctor. Has the object been disposed. Get the ptr to the CGAL object. Dispose the CGAL object. Print some information about the object. Print some information about the object. Print the object into the console. Print the object into a string builder. The builder to print into. Release the CGAL object. Swap the unmanaged pointer with another. The old ptr will be released first. The new ptr. The old ptr will be released first. Allow derived class to release the unmanaged memory. Allow derived class to release the unmanaged memory. Check if the object is still valid. enum for egien solvers. Create a new matrix filled with zeros. The number of rows. The number of columns. Create a new matrix fill with the array contents. The array. Create a new matrix filled with the contents of the column vectors. All column vectors must have the same dimension. Create a 2 x 2 matrix. Create a 3 x 3 matrix. Create a 4 x 4 matrix. Create a new matrix from a pointer. Create a identity matrix. The number of rows and columns of the matrix. Must be square. The identity matrix. Create a matrix filled with the numbers 1, 2. 3, etc to end. Used for debugging. The number of rows. The number columns. The Matrix. Create a new matrix fill with random numbers. The number of rows. The number columns. The minimum random number generated. The maximum random number generated. The random generators seed. The matrix. The number of rows in the matrix. The number of columns in the matrix. The total size of the matrix which is the rows times the number of columns. The single dimension array accessor. The array index. The value at the index i. The double dimension array accessor. The row index. The column index. The value at the index i,j. The matrix string info. The matrix string info. The matrix transposed. Flips a matrix over its diagonal that is, it switches the row and column indices of the matrix. The matrices conjugate. The matrix obtained by replacing each element a(ij) with its complex conjugate, A^=(a^(ij)). The matrices adjoint. The transpose of its cofactor matrix. Is the matrix invertible. The inverse of a square matrix A, sometimes called a reciprocal matrix, is a matrix A^(-1) such that AA^(-1)=I. DOes not check if the matrix is invertible. The determinant is a scalar value that is a function of the entries of a square matrix. The trace of a square matrix is defined to be the sum of elements on the main diagonal from the upper left to the lower right. A square matrix has the same number of rows and columns. A diagonal matrix is a matrix in which the entries outside the main diagonal are all zero. A square matrix is called upper triangular if all the entries below the main diagonal are zero. A square matrix is called lower triangular if all the entries above the main diagonal are zero. Multiple each component in matrix by the scalar. The matrix. The scalar. The matrix with each component multiplied by the scalar. Divide each component in matrix by the scalar. The matrix. The scalar. The matrix with each component divided by the scalar. Multiple the two matrices. The first matrices number of columns must the same as the second matrices number of rows. The first matrix. The second matrix. The product matrix. Add two matrices. The matrices must be the same size. The first matrix. The second matrix. A matrix where each compoent is the sum of the other two matrices. Subtract two matrices. The matrices must be the same size. The first matrix. The second matrix. A matrix where each compoent is the difference of the other two matrices. Multiple a matrix and a column vector. The matrix. The column vector. The product column vector. Is this matrix the identity matrix. The threshold the values in the matrix can be to the expected value. Is this matrix the identity matrix. Is this matrix filled with zeros. The threshold the values in the matrix can be to the expected value. Is this matrix filled with zeros. Are all the values in this matrix positive. Are all the values in this matrix positive. Does the matrix have a component that is nan. Does the matrix have a component that is nan. Replaces all nan values in the matrix with 0. Are all the values in the matrix finite (non-infinite and non-nan). Are all the values in the matrix finite (non-infinite and non-nan). Replaces all infinite and nan values in matrix with 0. Are all the values in the matrix the same. The threshold the values in the matrix can be to the expected value. Are all the values in the matrix the same. Create a sub matrix from this matrix. The row to start at. THe column to start at. The number of rows. The number of columns. A sub matrix from this matrix. Create a sub matrix from this matrix. The number of rows. The number of columns. A sub matrix from this matrix. Solve the linear system. The vector to solve. The solver type. The solution vector. Solve the linear system. The vector to solve. The solver type. The solution vector. Find the relative error from the linear system. The vector that was solved. The vector that was the solution. The relative error. Find the relative error from the linear system. The vector that was solved. The vector that was the solution. The relative error. Find the eigen values of the matrix. The eigen values if found, null otherwise. True if the values could be determined. Find the eigen vectors of the matrix. The eigen vectors if found, null otherwise. True if the vectors could be determined. Try and find the inverse of the matrix. The inverse if found, null otherwise. True if the inverse was found. Create a rotation from a angle and the rotation axis. The rotation amount. The axis to rotate on. The rotation matrix. / The first value in the vector. The second value in the vector. The third value in the vector. The fourth value in the vector. The generic Box wrapper for a CGAL object. The kernel type. Create box from min and max values. The min x and y value. The max x and y value. Create box from min and max points. The min point. The max point. Create from a pointer. The iso rectangle pointer. The type of kernel object uses. The iso rectangle as a string. The iso rectangle as a string. Translate the shape. The amount to translate. Rotate the shape. The amount to rotate. Scale the shape. The amount to scale. Transform the rectangle. The amount to translate. The amount to rotate The amount to scale. Create a deep copy of the rectangle. The deep copy. The abstract iso rectangle definition. Default constructor. Construct with a new kernel. The geometry kernel. The Box pointer. The iso rectangle kernel. Contains the functions to the unmanaged CGAL object. Convert to shape struct. The rectangles min point. The rectangles max point. The rectangles area. Is the rectangle degenerate. The side the rectangle the point is on. The point. If the point is iside, outside or on boundary. Does the rectangle contain the point. The point Should a point on the boundary count as being inside. Does the rectangle contain the point Release the unmanaged pointer. Round the shape. The number of digits to round to. Convert to another kernel. Must provide a different kernel to convert to or just a deep copy will be returned. The shape with another kernel type. The static intersection class. The static intersection class. The static intersection class. -------------------------------------------------------- The Point DoIntersect functions -------------------------------------------------------- -------------------------------------------------------- The Line DoIntersect functions -------------------------------------------------------- -------------------------------------------------------- The Ray DoIntersect functions -------------------------------------------------------- -------------------------------------------------------- The Segment DoIntersect functions -------------------------------------------------------- -------------------------------------------------------- The Triangle DoIntersect functions -------------------------------------------------------- -------------------------------------------------------- The Box DoIntersect functions -------------------------------------------------------- -------------------------------------------------------- The Point Intersection functions -------------------------------------------------------- -------------------------------------------------------- The Line Intersection functions ----------------------------------------------------- -------------------------------------------------------- The Ray Intersection functions ----------------------------------------------------- -------------------------------------------------------- The Segment Intersection functions ----------------------------------------------------- -------------------------------------------------------- The Triangle Intersection functions ----------------------------------------------------- -------------------------------------------------------- The Box Intersection functions ----------------------------------------------------- -------------------------------------------------------- The Point SqrDistance functions ----------------------------------------------------- -------------------------------------------------------- The Line SqrDistance functions -------------------------------------------------------- -------------------------------------------------------- The Ray SqrDistance functions -------------------------------------------------------- -------------------------------------------------------- The Segment SqrDistance functions ----------------------------------------------------- -------------------------------------------------------- The Triangle SqrDistance functions ----------------------------------------------------- -------------------------------------------------------- The Point DoIntersect extern functions ------------------------------------------------------ -------------------------------------------------------- The Linet DoIntersect extern functions ------------------------------------------------------ -------------------------------------------------------- The Ray DoIntersect extern functions ------------------------------------------------------ -------------------------------------------------------- The Segment DoIntersect extern functions ------------------------------------------------------ -------------------------------------------------------- The Triangle DoIntersect extern functions ------------------------------------------------------ -------------------------------------------------------- The Box DoIntersect extern functions ------------------------------------------------------ -------------------------------------------------------- The Point Intersection extern functions ------------------------------------------------------- -------------------------------------------------------- The Line Intersection extern functions ------------------------------------------------------- -------------------------------------------------------- The Ray Intersection extern functions ------------------------------------------------------- -------------------------------------------------------- The Segment Intersection extern functions ------------------------------------------------------- -------------------------------------------------------- The Triangle Intersection extern functions ------------------------------------------------------- -------------------------------------------------------- The Box Intersection extern functions ------------------------------------------------------- -------------------------------------------------------- The Point SqrDistance extern functions ------------------------------------------------------- -------------------------------------------------------- The Line SqrDistance extern functions ------------------------------------------------------ -------------------------------------------------------- The Ray SqrDistance extern functions ------------------------------------------------------ -------------------------------------------------------- The Segment SqrDistance extern functions ------------------------------------------------------ -------------------------------------------------------- The Triangle SqrDistance extern functions ------------------------------------------------------ -------------------------------------------------------- The Point DoIntersect functions -------------------------------------------------------- -------------------------------------------------------- The Line DoIntersect functions -------------------------------------------------------- -------------------------------------------------------- The Ray DoIntersect functions -------------------------------------------------------- -------------------------------------------------------- The Segment DoIntersect functions -------------------------------------------------------- -------------------------------------------------------- The Triangle DoIntersect functions -------------------------------------------------------- -------------------------------------------------------- The Box DoIntersect functions -------------------------------------------------------- -------------------------------------------------------- The Point Intersection functions -------------------------------------------------------- -------------------------------------------------------- The Line Intersection functions ----------------------------------------------------- -------------------------------------------------------- The Ray Intersection functions ----------------------------------------------------- -------------------------------------------------------- The Segment Intersection functions ----------------------------------------------------- -------------------------------------------------------- The Triangle Intersection functions ----------------------------------------------------- -------------------------------------------------------- The Box Intersection functions ----------------------------------------------------- -------------------------------------------------------- The Point SqrDistance functions ----------------------------------------------------- -------------------------------------------------------- The Line SqrDistance functions -------------------------------------------------------- -------------------------------------------------------- The Ray SqrDistance functions -------------------------------------------------------- -------------------------------------------------------- The Segment SqrDistance functions ----------------------------------------------------- -------------------------------------------------------- The Triangle SqrDistance functions ----------------------------------------------------- -------------------------------------------------------- The Point DoIntersect extern functions ------------------------------------------------------ -------------------------------------------------------- The Linet DoIntersect extern functions ------------------------------------------------------ -------------------------------------------------------- The Ray DoIntersect extern functions ------------------------------------------------------ -------------------------------------------------------- The Segment DoIntersect extern functions ------------------------------------------------------ -------------------------------------------------------- The Triangle DoIntersect extern functions ------------------------------------------------------ -------------------------------------------------------- The Box DoIntersect extern functions ------------------------------------------------------ -------------------------------------------------------- The Point Intersection extern functions ------------------------------------------------------- -------------------------------------------------------- The Line Intersection extern functions ------------------------------------------------------- -------------------------------------------------------- The Ray Intersection extern functions ------------------------------------------------------- -------------------------------------------------------- The Segment Intersection extern functions ------------------------------------------------------- -------------------------------------------------------- The Triangle Intersection extern functions ------------------------------------------------------- -------------------------------------------------------- The Box Intersection extern functions ------------------------------------------------------- -------------------------------------------------------- The Point SqrDistance extern functions ------------------------------------------------------- -------------------------------------------------------- The Line SqrDistance extern functions ------------------------------------------------------ -------------------------------------------------------- The Ray SqrDistance extern functions ------------------------------------------------------ -------------------------------------------------------- The Segment SqrDistance extern functions ------------------------------------------------------ -------------------------------------------------------- The Triangle SqrDistance extern functions ------------------------------------------------------ -------------------------------------------------------- The Point DoIntersect functions -------------------------------------------------------- -------------------------------------------------------- The Line DoIntersect functions -------------------------------------------------------- -------------------------------------------------------- The Ray DoIntersect functions -------------------------------------------------------- -------------------------------------------------------- The Segment DoIntersect functions -------------------------------------------------------- -------------------------------------------------------- The Triangle DoIntersect functions -------------------------------------------------------- -------------------------------------------------------- The Box DoIntersect functions -------------------------------------------------------- -------------------------------------------------------- The Point Intersection functions -------------------------------------------------------- -------------------------------------------------------- The Line Intersection functions ----------------------------------------------------- -------------------------------------------------------- The Ray Intersection functions ----------------------------------------------------- -------------------------------------------------------- The Segment Intersection functions ----------------------------------------------------- -------------------------------------------------------- The Triangle Intersection functions ----------------------------------------------------- -------------------------------------------------------- The Box Intersection functions ----------------------------------------------------- -------------------------------------------------------- The Point SqrDistance functions ----------------------------------------------------- -------------------------------------------------------- The Line SqrDistance functions -------------------------------------------------------- -------------------------------------------------------- The Ray SqrDistance functions -------------------------------------------------------- -------------------------------------------------------- The Segment SqrDistance functions ----------------------------------------------------- -------------------------------------------------------- The Triangle SqrDistance functions ----------------------------------------------------- -------------------------------------------------------- The Point DoIntersect extern functions ------------------------------------------------------ -------------------------------------------------------- The Linet DoIntersect extern functions ------------------------------------------------------ -------------------------------------------------------- The Ray DoIntersect extern functions ------------------------------------------------------ -------------------------------------------------------- The Segment DoIntersect extern functions ------------------------------------------------------ -------------------------------------------------------- The Triangle DoIntersect extern functions ------------------------------------------------------ -------------------------------------------------------- The Box DoIntersect extern functions ------------------------------------------------------ -------------------------------------------------------- The Point Intersection extern functions ------------------------------------------------------- -------------------------------------------------------- The Line Intersection extern functions ------------------------------------------------------- -------------------------------------------------------- The Ray Intersection extern functions ------------------------------------------------------- -------------------------------------------------------- The Segment Intersection extern functions ------------------------------------------------------- -------------------------------------------------------- The Triangle Intersection extern functions ------------------------------------------------------- -------------------------------------------------------- The Box Intersection extern functions ------------------------------------------------------- -------------------------------------------------------- The Point SqrDistance extern functions ------------------------------------------------------- -------------------------------------------------------- The Line SqrDistance extern functions ------------------------------------------------------ -------------------------------------------------------- The Ray SqrDistance extern functions ------------------------------------------------------ -------------------------------------------------------- The Segment SqrDistance extern functions ------------------------------------------------------ -------------------------------------------------------- The Triangle SqrDistance extern functions ------------------------------------------------------ -------------------------------------------------------- The Point2 Class Functions ------------------------------------------------------- -------------------------------------------------------- The Vector2 Class Functions ------------------------------------------------------- -------------------------------------------------------- The HPoint2 Class Functions ------------------------------------------------------- -------------------------------------------------------- The Line2 Class Functions ------------------------------------------------------- -------------------------------------------------------- The Ray2 Class Functions ------------------------------------------------------- -------------------------------------------------------- The Segment2 Class Functions ------------------------------------------------------- -------------------------------------------------------- The Triangle2 Class Functions ------------------------------------------------------- -------------------------------------------------------- The Box2 Class Functions ------------------------------------------------------- -------------------------------------------------------- The Point2 Class Functions ------------------------------------------------------- -------------------------------------------------------- The Vector2 Class Functions ------------------------------------------------------- -------------------------------------------------------- The HPoint2 Class Functions ------------------------------------------------------- -------------------------------------------------------- The Line2 Class Functions ------------------------------------------------------- -------------------------------------------------------- The Ray2 Class Functions ------------------------------------------------------- -------------------------------------------------------- The Segment Class Functions ------------------------------------------------------- -------------------------------------------------------- The Triangle2 Class Functions ------------------------------------------------------- -------------------------------------------------------- The IsoRectancle2 Class Functions ------------------------------------------------------- -------------------------------------------------------- The Point2 extern functions ------------------------------------------------------- -------------------------------------------------------- The Vector2 extern functions ------------------------------------------------------- -------------------------------------------------------- The HPoint2 extern functions ------------------------------------------------------- -------------------------------------------------------- The Line2 extern functions ------------------------------------------------------- -------------------------------------------------------- The Ray2 extern functions ------------------------------------------------------- -------------------------------------------------------- The Segment2 extern functions ------------------------------------------------------- -------------------------------------------------------- The Triangle2 extern functions ------------------------------------------------------- -------------------------------------------------------- The Box2 extern functions ------------------------------------------------------- -------------------------------------------------------- The Point2 Class Functions ------------------------------------------------------- -------------------------------------------------------- The Vector2 Class Functions ------------------------------------------------------- -------------------------------------------------------- The HPoint2 Class Functions ------------------------------------------------------- -------------------------------------------------------- The Line2 Class Functions ------------------------------------------------------- -------------------------------------------------------- The Ray2 Class Functions ------------------------------------------------------- -------------------------------------------------------- The Segment Class Functions ------------------------------------------------------- -------------------------------------------------------- The Triangle2 Class Functions ------------------------------------------------------- -------------------------------------------------------- The IsoRectancle2 Class Functions ------------------------------------------------------- -------------------------------------------------------- The Point2 extern functions ------------------------------------------------------- -------------------------------------------------------- The Vector2 extern functions ------------------------------------------------------- -------------------------------------------------------- The HPoint2 extern functions ------------------------------------------------------- -------------------------------------------------------- The Line2 extern functions ------------------------------------------------------- -------------------------------------------------------- The Ray2 extern functions ------------------------------------------------------- -------------------------------------------------------- The Segment2 extern functions ------------------------------------------------------- -------------------------------------------------------- The Triangle2 extern functions ------------------------------------------------------- -------------------------------------------------------- The Box2 extern functions ------------------------------------------------------- Weighted point class Create a new weighted point. Create a new weighted point from a value and weight as 1. The points value. Create a new weighted point from a x, y value and weight as 1. The points x value. The points y value. Create a new weighted point from a x, y value and weight as the w value. The points x value. The points y value. The points weight value. Create a new weighted point from a pointer. The pointer. The type of kernel object uses. Create a deep copy of the point. The deep copy. Create a new weighted point. The points kernel. Create a new weighted point from a x, y value and weight as the w value. The points x value. The points y value. The points weight value. The points kernel. Create a new weighted point from a existing ponter and kernel. The points kernel. The points pointer The points kernel. Release the pointer. Release the pointer. The pointer to release. Accessor or the points x value. ccessor or the points y value. Round the point. The number of digits to round to. Clamp the point. The points min value. The points max value. Clamp the point. Convert to another kernel. Must provide a different kernel to convert to or just a deep copy will be returned. The shape with another kernel type. Enum for the type of intersection geomerty. The intersection result struct. May contain up tp 6 points of data. The point data for the intersection. Represents up to 6 points in xy order. The number of points of data used. Was there a intersection. Is the intersection a polygon. The intersection geometry type. Array accessor for the point data. The array index from 0 to 6. The point at index i. Results information as string. esults information as string If result type was point get the point geometry. If result type was line get the line geometry. If result type was ray get the ray geometry. If result type was segment get the segment geometry. If result type was box get the box geometry. If result type was triangle get the triangle geometry. If result type was polygon get the points that make up the polygon geometry. Should only ever have at most 6 points. The intersection result as a polygon. The polygons kernel. The polygon. A CGALObject that represents a line on 2D space. A horizontal line on the x axis. A vertical line on the y axis. Create a new line where ax + by + c = 0 holds. The constant in ax. The constant in by. The constant. Create a new line that passes through the two points. The first point. The second point. Create a line that passes through the point in the direction of the vector. The point. The vector. Create a line from a existing pointer. The pointer. Create a new line that faces in the opposite direction. Create a new line that is perpendicular to current line. A point the line should turn ccw when turning. The perpendicular line. Translate the object. The amount to translate. Rotate the object. The amount to rotate. Scale the object. The amount to scale. Translate, rotate and scale the object. The amount to translate. The amount to rotate in degrees. The amount to scale. Create a deep copy of the line. The deep copy. The abstract class for the line object. The lines kernel. Convert to shape struct. The lines constant in ax. The lines constant in by. The lines constant. Is the line degenerate. Is the line horizontal on the x axis. Is the line vertical on the y axis. Convert the line to a vector. Does the point lie on the line. The point. True if the point lies on the line. Does the point lies on the negative/cw side of the line. The point. True if the point lies on the negative/cw side of the line. Does the point lies on the positive/ccw side of the line. The point. True if the point lies on the positive/ccw side of the line. The lines x value given a y value. The y value. The lines x value given a y value. The lines y value given a x value. The x value. The lines y value given a x value. Release the unmanaged pointer. Round the shape. The number of digits to round to. Convert to another kernel. Must provide a different kernel to convert to or just a deep copy will be returned. The shape with another kernel type. The unit x point. The unit y point. A point of zeros. A point of ones. A point of halfs. The type of kernel object uses. Round the point. The number of digits to round to. Clamp the point. The points min value. The points max value. Clamp the point. Convert to another kernel. Must provide a different kernel to convert to or just a deep copy will be returned. The shape with another kernel type. The unit x ray. The unit y ray. Translate the shape. The amount to translate. Rotate the shape. The amount to rotate. Scale the shape. The amount to scale. Convert to shape struct. Round the shape. The number of digits to round to. Convert to another kernel. Must provide a different kernel to convert to or just a deep copy will be returned. The shape with another kernel type. A horizontal line on the x axis. A vertical line on the y axis. Translate the shape. The amount to translate. Rotate the shape. The amount to rotate. Scale the shape. The amount to scale. Convert to shape struct. Round the shape. The number of digits to round to. Convert to another kernel. Must provide a different kernel to convert to or just a deep copy will be returned. The shape with another kernel type. Translate the shape. The amount to translate. Rotate the shape. The amount to rotate. Scale the shape. The amount to scale. Convert to shape struct. Round the shape. The number of digits to round to. Convert to another kernel. Must provide a different kernel to convert to or just a deep copy will be returned. The shape with another kernel type. A Vector2 object with kernel type K. The type of kernel. The unit x vector. The unit y vector. A vector of zeros. A vector of ones. Create a new Vector. Create a new vector filled with the value. The value to fill. Create a new vector with the values x and y. The vectors x value. The vectors y value. Create a new vector from a existing pointer. The pointer object. The type of kernel object uses. Vector information. The vectors string information. Create a deep copy of the vector. The deep copy. The vectors abstract bass class. Create a new vector with the kernel. The vectors kernel. Create a new vector from the x and y values. The vectors x value. The vectors y value. The vectors kernel. Create a new vector from a existing pointer. The vectors kernel. The existing pointer. The vectors kernel. The vectors sqr magnitude. The vectors sqr magnitude. Access the x component. Access the y component. Release the vectors pointer. Release a pointer to a vector. The pointer to release. Round the vector. The number of digits to round to. Clamp the vector. The vectors min value. The vectors max value. Clamp the vector. Normalize the vector. Convert to another kernel. Must provide a different kernel to convert to or just a deep copy will be returned. The shape with another kernel type. The convex hull method to use. The generic convex hull class. The kernel type The static instance. Default constructor. Find the convex of the points. The point array. The ararys length. The hull ethod to use. A polygon that represents the convex hull. Find the upper hull of points. The point array. The ararys length. A polygon that represents the upper hull. Find the lower hull of points. The point array. The ararys length. A polygon that represents the lower hull. The convex hull abstract base class. Default constructor. Construct hull with the kernel. The kernel The hulls kernel type. Is this set of points ccw orderer. The point array. The ararys length. Is this set of points ccw orderer. Is this set of points cw orderer. The point array. The ararys length. Is this set of points cw orderer. Checks if the minimum number of points have been provided. The point array length. Release any unmanaged resources. The generic convex hull class. The kernel type The static instance. Default constructor. Create the convex hull from a set of points. The point array. The point arrays length The hull as a polyhedron. Create the convex hull from a set of points. The point array. The point arrays length The hull as a surface mesh. The convex hull abstract base class. Default constructor. Construct hull with the kernel. The kernel The hulls kernel type. Check if the points in the polyhedron are convex. The polyhedron. True if the polyhedron is convex. Check if the points in the mesh are convex. The mesh. True if the mesh is convex. Checks if the minimum number of points have been provided. The point array length. Release any unmanaged resources. A static instance of the triangulation. The triangulation as a string. Insert the polygons points into the triangulation. May not retain the poylgons edges. Insert the polygons points into the triangulation. May not retain the poylgons edges. Insert the polygons points and the edges as constraints into the triangulation. Will retain the poylgons edges. The polygon to insert. Insert the polygons points and the edges as constraints into the triangulation. Will retain the poylgons edges. The polygon to insert. A deep copy of the triangulation. The deep copy. The max value the angle bounds can be. The number of verices in the triangulation. The number of triangles in the triangulation. The number of indices need to represent the triangulation (number of triangles * 3). The conforming triangulation kernel. Clear the triangulation. Translate the triangulation. The amount to translate. Rotate the triangulation. The amount to rotate in radians. Scale the triangulation. The amount to scale. Transform the triangulation with a TRS matrix. The amount to translate. The amount to rotate. The amount to scale. Make the mesh delaunay. Make the mesh Refine the mesh into smaller triangles. Default shape bound. 0.125 corresponds to abound 20.6 degree. Max 0.125 value. Upper bound on the length of the longest edge. Refine the mesh into smaller triangles. Default shape bound. 0.125 corresponds to abound 20.6 degree. Max 0.125 value. Upper bound on the length of the longest edge. Seeds point in polygons that are not to be refined. Release any unmanaged resources. Release any unmanaged resources. A static instance of the tetrahedral remeshing. The tetrahedral remeshing kernel. Release any unmanaged resources. Generic polygon definition. The kernel type. Default constructor. Create from a set of points. The polygons points. Create from a pointer. The polygons pointer. The polygon as a string. The polygon as a string. Copy the polygon. The copied polygon. Triangulate the polygon. The triangle indices. Do the polygons intersect. The other polygon. Do the polygons intersect. Do the polygons intersect. The other polygon. Do the polygons intersect. Do the polygons intersect. The other polygon. The intersection results. Do the polygons intersect. Do the polygons intersect. The other polygon. The intersection results. Do the polygons intersect. Refine the polygon to a triangulation. Does not modify this polygon. Upper bound on the length of the longest edge. The base triangulation. Refine the polygon to a triangulation. Does not modify this polygon. Default shape bound. 0.125 corresponds to abound 20.6 degree. Max 0.125 value. Upper bound on the length of the longest edge. The base triangulation. Partition the polygon into convex pieces. Does not modify this polygon. The convex partition. The type of partition method. Simplify the polygon. The simplification threshold. Simplify the polygon. The simplification parameters. offset the polygon. Does not modify this polygon. The type of offset. The amount to offset. The offset results. Create a polyhedron3 mesh with one polygon face. Should the y coord of the points be used for the z coord. The new polyhedron mesh Thrown if the polygon is not simple. Get the dual polygon where every point s now a edge. The dual polygon. The abstract polygon definition. Is the polygon simple. Must be updated to find if simple. The polygons orientation. Must be updated to find orientation. Default constructor. Construct with a new kernel. The polygon kernel. Construct with a new kernel. The polygon kernel. The points to construct from. Construct with a new kernel. The polygon kernel. The polygons pointer. The number of points in the polygon. The capacity of the point array. Is this a simple polygon. Certains actions can only be carried out on simple polygons. The polygons orientation. Certain actions depend on the polygons orientation. The orientation expressed as the clock direction. Is the polygon degenerate. Polygons with less than 3 points are degenerate. Is the polygon cw orientated. Is the polygon ccw orientated. Is the polygon updated. The polygons kernel. Contains the functions to the unmanaged CGAL polygon. The type of kernel object uses. Array accessor for the polygon. Getting a point wraps around the polygon. Mark th mesh as needing to be updated. Valid polygons should be simple and ccw for most algorithms to work on them. Valid hole polygons should be simple and cw to add to a polygon with holes. Clear the polygon of all points. Shrink the capacity to match the point count. Resize the point array. New elements will default to zero. Remove the point at the index from the array. The points index Remove a range of points from the array. The starting index The number of points to remove. Insert the point at the index into the array. The points index. The point to insert. Insert a range of points into the array. The starting index The points to insert. The number of points to insert. Add the point to the end of the poylgon. The point to add. Get the point a the index. The points index to get. The point at index. Get the point at the index and wrap around the polygon. The points index. The point at the index. Get the point at the index and clamp to the polygons last point. The points index. The point at the index. Get all the points in the polygon. The point array to copy the data into. The array length. Get all the polygon points. The list to copy the data into. Triangulate the polygon. The triangle indices. Get all the polygon segments. The segment array to copy the data into. The array length. Set the points at the index. The points index. The points value. Set the points from the array. If the array is larger than the polygon then the new points will be appended to end of polygon. The points array. The array length. Reverse the polygon. Swithches the orientation. Find the bounding box for the polygon. The bounding box. Find if the polygon is simple. True if simple. Find if the polygon is convex. Must be simple to determine. True if the polygon is convex. Find the polygons orientation. Must be simple to determine. The polygons orientations. Find the orientated side the point lies on. Must be simple to determine. The point. The orientated side of the polygon the point is on. Find the bounded side the point lies on. Must be simple to determine. The point. The bounded side of the polygon the point is on. Find the polygons signed area. Must be simple to determine. The signed area is positive if polygon is ccw and negation if cw. The area of the polygon. Must be simple to determine. The abs of the signed area. Find the perimeter. This is the length of the polygon boundary. Find the square perimeter. This is the square length of the polygon boundary. Does the polygon contain the points. Must be simple to determine. The point to find. Does the point on the boundary count True if the point is inside the polygon. Round each point it polygon to a number of digits. The number of digits to round to. Translate the polygon. The amount to translate. Rotate the polygon. The amount to rotate in radians. Scale the polygon. The amount to scale. Transform the polygon with a TRS matrix. The amount to translate. The amount to rotate. The amount to scale. Enumerate all points in the polygon. Each point in polygon. Enumerate all points in the polygon. Each point in polygon. Return all the points in the polygon in a array. The array. Get all the points in the polygon into a list. Convert the polygon to a new polygon with a different kernel. May result in different values due to precision issues. The new kernel type. The new polygon. Truncate a point in the polygon by splitting the point and shifting toward its neghbours. The points index in mesh. The amount to truncale. Print the polygon into a styring builder. Release the unmanaged pointer. Release the unmanaged pointer. Update the polygon if needed. Update the polygon directly without calling the update function. Is the polygon simepl. The polygons orientation. Should the input polygon be checked. Can disable for better performance if it is know all input if valid. Check if the polygon is valid to offset. Should be simple and ccw. The polygon to check. Check if the polygon is valid to offset. Should be simple and ccw. The polygon to check. The type of boolean ops. Generic polygon boolean class. The type of kernel A static instance to the boolean class. Create a new object. Perform the boolean op on the two polygons. The type of op. A simple ccw polygon. A simple ccw polygon. The result of the op. If the op was performed and the result list changed. Perform the boolean op on the two polygons. The type of op. A simple ccw polygon. A simple ccw polygon. The result of the op. If the op was performed and the result list changed. Perform the boolean op on the two polygons. The type of op. A simple ccw polygon. A simple ccw polygon. The result of the op. If the op was performed and the result list changed. Check if the polygons intesect. A simple ccw polygon. A simple ccw polygon. If the polygons intesect. Check if the polygons intesect. A simple ccw polygon. A simple ccw polygon. If the polygons intesect. Check if the polygons intesect. A simple ccw polygon. A simple ccw polygon. If the polygons intesect. The union of the two polygons. A simple ccw polygon. A simple ccw polygon. The union of the polygons. If the op was performed and the result list changed. The union of the two polygons. A simple ccw polygon. A simple ccw polygon. The union of the polygons. If the op was performed and the result list changed. The union of the two polygons. A simple ccw polygon. A simple ccw polygon. The union of the polygons. If the op was performed and the result list changed. The intersection of the two polygons. A simple ccw polygon. A simple ccw polygon. The intersection of the polygons. If the op was performed and the result list changed. The intersection of the two polygons. A simple ccw polygon. A simple ccw polygon. The intersection of the polygons. If the op was performed and the result list changed. The intersection of the two polygons. A simple ccw polygon. A simple ccw polygon. The intersection of the polygons. If the op was performed and the result list changed. The difference of the two polygons. A simple ccw polygon. A simple ccw polygon. The difference of the polygons. If the op was performed and the result list changed. The difference of the two polygons. A simple ccw polygon. A simple ccw polygon. The difference of the polygons. If the op was performed and the result list changed. The difference of the two polygons. A simple ccw polygon. A simple ccw polygon. The difference of the polygons. If the op was performed and the result list changed. The symmetric difference of the two polygons. A simple ccw polygon. A simple ccw polygon. The symmetric difference of the polygons. If the op was performed and the result list changed. The symmetric difference of the two polygons. A simple ccw polygon. A simple ccw polygon. The symmetric difference of the polygons. If the op was performed and the result list changed. The symmetric difference of the two polygons. A simple ccw polygon. A simple ccw polygon. The symmetric difference of the polygons. If the op was performed and the result list changed. The complement of the polygon. A simple ccw polygon. The complement of the polygon. Copy the unmanaged polygon objects created into the result list. The number of objects in the buffer. The result lis. Copy the unmanaged polygon object. The index of the polygon in the buffer. The polygon copy. Abstract base class for polygon boolean. The polygon boolean kernel. Clear the unmanaged buffer. Release the unmanaged resourses. Factory for creating polygons. The kernel type. Create a empty polygon. Create a polygon from a triangle. The triangle first point. The triangle second point. The triangle third point. True for a counter clock wise polygon, false for a clock wise polygon The created polygon. Create a polygon from a triangle. The triangle. True for a counter clock wise polygon, false for a clock wise polygon The created polygon. Create a polygon from a box. The boxs min point. The boxs max point. True for a counter clock wise polygon, false for a clock wise polygon The created polygon. Create a polygon from a box. The boxs min point. The boxs max point. True for a counter clock wise polygon, false for a clock wise polygon The created polygon. Create a polygon from a box. The box. True for a counter clock wise polygon, false for a clock wise polygon The created polygon. Create a polygon from a dounut. Outer radius must be greater than inner. The outer radius. The inner radius The number of segments. The created polygon with holes Create a polygon from a dounut. Outer radius must be greater than inner. The center position of the polygon. The outer radius. The inner radius The number of segments. The created polygon with holes Create a polygon from a circle. The radius of the circle. The number of segments. True for a counter clock wise polygon, false for a clock wise polygon The polygon. Create a polygon from a circle. The center of the circle. The radius of the circle. The number of segments. True for a counter clock wise polygon, false for a clock wise polygon Create a polygon from a circle. The cirlce. The number of segments. True for a counter clock wise polygon, false for a clock wise polygon https://rosettacode.org/wiki/Koch_curve#C.2B.2B The size of the polygon. The number of times to sub divide. True for a counter clock wise polygon, false for a clock wise polygon https://rosettacode.org/wiki/Koch_curve#C.2B.2B The stars center. The size of the polygon. The number of times to sub divide. True for a counter clock wise polygon, false for a clock wise polygon https://rosettacode.org/wiki/Koch_curve#C.2B.2B Decomposition stratergy for polygons. Decomposition stratergy for polygons with holes. Generic Minkowski class. The type of kernel A static instance to the Minkowski class. Create a new object. Compute the Minkowski sum of two polygons. Compute the Minkowski sum of two polygons. Compute the Minkowski sum of two polygons. The decomposition method. Compute the Minkowski sum of two polygons. The decomposition method. It is based on the angle-bisector decomposition method suggested by Chazelle and Dobkin [4], which runs in O(n2) time. In addition, it applies a heuristic by Flato that reduces the number of output polygons in many common cases. The convex decompositions that it produces usually yield efficient running times for Minkowski sum computations. It starts by examining each pair of reflex vertices in the input polygon, such that the entire interior of the diagonal connecting these vertices is contained in the polygon. Out of all available pairs, the vertices pi and pj are selected, such that the number of reflex vertices encountered when traversing the boundary of the polygon from pi to pj in clockwise order is minimal. The polygon is split by the diagonal pipj. This process is repeated recursively on both resulting sub-polygons. In case it is not possible to eliminate two reflex vertices at once any more, each reflex vertex is eliminated by a diagonal that is closest to the angle bisector emanating from this vertex and having rational-coordinate endpoints on both sides. Uses the dynamic-programming algorithm of Greene [6] for computing an optimal decomposition of a polygon into a minimal number of convex sub-polygons. While this algorithm results in a small number of convex polygons, it consumes rather many resources, as it runs in O(n4) time and O(n3) space in the worst case, where n is the number of vertices in the input polygon. Implements the approximation algorithm suggested by Hertel and Mehlhorn [8], which triangulates the input polygon and then discards unnecessary triangulation edges. After triangulation (carried out by the constrained-triangulation procedure of CGAL) the algorithm runs in O(n) time and space, and guarantees that the number of sub-polygons it generates is not more than four times the optimum. Implementation of Greene's approximation algorithm [6], which computes a convex decomposition of the polygon based on its partitioning into y-monotone polygons. This algorithm runs in O(nlogn) time and O(n) space, and has the same guarantee on the quality of approximation as Hertel and Mehlhorn's algorithm. Uses vertical decomposition to decompose the underlying arrangement. Uses vertical decomposition to decompose the underlying arrangement. Uses constrained triangulation to decompose the input polygons, which may have holes, into triangles. Uses constrained triangulation to decompose the input polygons, which may have holes, into triangles. Abstract base class for polygon minkowski. The polygon Minkowski kernel. Release the unmanaged resourses. The generic polgon offset class Static instance of polygon offset. Create new polygon offset. Create a interior or exterior offset. The offset type The polygon to offset. The offset amount The offset polygon Create a interior or exterior offset. The offset type The polygon to offset. The offset amount The offset polygon Create a interior offset. The polygon to offset. The offset amount The offset polygon Create a interior offset. The polygon to offset. The offset amount The offset polygon Create a exterior offset. The polygon to offset. The offset amount The offset polygon Create a exterior offset. The polygon to offset. The offset amount The offset polygon Create the interior skeleton of the polygon. The polygon to offset. Should the polygon be included as the border. The skeletons segments. Create the interior skeleton of the polygon. The polygon to offset. Should the polygon be included as the border. The skeletons segments. Create the exterior skeleton of the polygon. The polygon to offset. The bounding boxes offset from the polygons edges. Must be > 0. Should the polygon be included as the border. The skeletons segments. Create the exterior skeleton of the polygon. The polygon to offset. The bounding boxes offset from the polygons edges. Must be > 0. Should the polygon be included as the border. The skeletons segments. The abstract polygon offset class. The offset kernel. Get the number off polygons in the buffer. The size of the segment buffer. The number of segments in the buffer. Get the unmanaged point to the polygon at the buffer index The index in the buffer. The pointer Get the segment from buffer. The segments index. The segment. Clear the polygon buffer. Clear the segment buffer. Release the unmanaged resources. Type of polygon partitions. Generic polygon partition class. The kernel type. Static instance of polygon partition. Create new polygon partition. Is this polygon Y monotonic. The polygon. True if y monotonic. Is this polygon Y monotonic. The polygon. True if y monotonic. Partition a polygon. The polygon to partition. The resulting polygons. Partition a polygon. The polygon to partition. The resulting polygons. Partition a polygon. The type of partition to perfrom. The polygon to partition. The resulting polygons. Partition a polygon. The type of partition to perfrom. The polygon to partition. The resulting polygons. Partition in to Y monotonic polygons. The polygon to partition. The resulting polygons. Partition in to Y monotonic polygons. The polygon to partition. The resulting polygons. Partition the polygon into convex polygons where the number of convex polygons produced is no more than four times the minimal number. The polygon to partition. The resulting polygons. Partition the polygon into convex polygons where the number of convex polygons produced is no more than four times the minimal number. The polygon to partition. The resulting polygons. Partition the polygon into convex polygons where the number of convex polygons produced is no more than four times the minimal number. The polygon to partition. The resulting polygons. Partition the polygon into convex polygons where the number of convex polygons produced is no more than four times the minimal number. The polygon to partition. The resulting polygons. Partition the polygon into convex polygons where the number of convex polygons produced is minimal. The polygon to partition. The resulting polygons. Partition the polygon into convex polygons where the number of convex polygons produced is minimal. The polygon to partition. The resulting polygons. Copy the new polygons into the result array and the clear the buffer. The number of polygons in buffer. The resulting polygons. The abstract base class. The partition kernel. Clear the unmanaged buffer. Release the unmanaged resources. Cost options for simplification. Stop distance options for simplification. Paramaters for poylgon simplification. The default param settings. The param as a string. Generic polygon simplification class. The kernel type. Static instance of polygon simplification. Simplify the polygon. The polygon to simplify. Must be simple. The simplification parameters. The simplified polygon. Simplify the polygon. The polygon to simplify. Must be simple. The simplification parameters. The simplified polygon ptr. Simplify the polygons boundary and all the holes. The polygon to simplify. Must be simple. The simplification parameters. The simplified polygon. Simplify the polygons boundary and all the holes. The polygon to simplify. Must be simple. The simplification parameters. The simplified polygons ptr. Simplify the polygons boundary. The polygon to simplify. Must be simple. The simplification parameters. The simplified polygon. Simplify the polygons holes. The polygon to simplify. Must be simple. The simplification parameters. The simplified polygon. Simplify one of the polygons holes. The polygon to simplify. Must be simple. The simplification parameters. The hole index to simplify. The simplified polygon. Abstract polygon simplification class. The simplification kernel. Release unmanaged resources. The generic polgon visibility class Static instance of polygon visibility. Create new polygon visibility. Compute the visibility from a simple polygon with no holes. This class implements the algorithm of B.Joe and R.B.Simpson [4]. The algorithm is a modification and extension of the linear time algorithm of Lee [5]. It computes the visibility region from a viewpoint that is in the interior or on the boundary of the polygon. While scanning the boundary the algorithm uses a stack to manipulate the vertices, and ultimately yields the visibility region.For each scanned edge, at most 2 points are pushed onto the stack. Overall, at most 2 n points are pushed or popped. Thus, the time and space complexities of the algorithm are O(n) even in case of degeneracies such as needles, where n is the number of the vertices of the polygon. The visibility point. A simple polygon that contains the point. The visibility result. True if result was computed Compute the visibility from a polygon with holes. The visibility point. A polygon with holes that contains the point. The visibility result. True if result was computed Compute the visibility from a polygon with holes. What method to use. The visibility point. A polygon with holes that contains the point. The visibility result. True if result was computed Compute the visibility from a polygon with holes using the triangular expansion method. The algorithm does not require preprocessing. It relies on the algorithm of T. Asano [1] based on angular plane sweep, with a time complexity of O(nlogn) in the number of vertices. The visibility point. A polygon with holes that contains the point. The visibility result. True if result was computed Compute the visibility from a polygon with holes using the rotational sweep method. The algorithm obtains a constrained triangulation from the input arrangement, then computes visibility by expanding the triangle that contains the query point. Preprocessing takes O(n) time and O(n) space, where n is the number of vertices of input polygon. The query time is O(nh), where h is the number of holes+1 of input polygon. Thus, for simple polygons (or a polygon with a constant number of holes) the algorithm complexity is linear, but it is O(n2) in the worst case, as the number of holes can be linear in n. The visibility point. A polygon with holes that contains the point. The visibility result. True if result was computed The abstract polygon visibility class. The offset kernel. Release the unmanaged resources. Polygon with holes consists of a boundary and holes. Generic polygon definition. The kernel type. Default constuctor. Construct polygon with the boundary. A CCW polygon. Construct polygon with the boundary points A CCW set of points. Create from a pointer. The polygons pointer. The polygon as a string. The polygon as a string. Create a deep copy of the polygon. The copy. Create a deep copy of the polygon element. The element type to copy. If element os a hole thiss is the holes index. The copy. Get the boundary as a copy. If unbounded will return a empty polygon. A copy of the hole polygon. Get the hole as a copy. The holes index A copy of the hole polygon. Add a polygon as a holes. Holes must simple and CW. The hole polygon. Create a copy of boundary and hole polygons. The list of polygons. Triangulate the polygon. The triangle indices. Do the polygons intersect. The other polygon. Do the polygons intersect. Do the polygons intersect. The other polygon. Do the polygons intersect. Connect all the holes of the polygon and return as a polygon. Will result in a non simple polygon. The connected non-simple polygon. Partition the polygon into convex pieces. The convex partition. The type of partition method. Simplify the polygon. The simplification threshold. Simplify the polygon. The simplification parameters. offset the polygon. Does not modify this polygon. The type of offset. The amount to offset. The offset results. The abstract polygon definition. Default constructor. Construct polygon with the kernel. Construct the polygon with the kernel and boundary. A CCW polygon. Construct the polygon with the kernel and boundary. A CCW set of points. Construct the polygon with the kernel and pointer. Is the polygon unbounded. ie no boundary polygon has been set. Is the polygon bounded. ie a boundary polygon has been set. Number of points in the boindary polygon. The number of holes in polygon. Is this a simple polygon. Certains actions can only be carried out on simple polygons. The polygons orientation. Certain actions depend on the polygons orientation. The orientation expressed as the clock direction. Is the polygon degenerate. Polygons with less than 3 points are degenerate. Is the polygon cw orientated. Is the polygon ccw orientated. The polygon kernel. The type of kernel object uses. Valid polygon with holes must have a simple and ccw boundary and all holes must be simple and cw. Valid holes must be simple, cw and must be contained within the boundary polygon. True if the polygon is a valid hole. Clear the polygon. Clear the polygons boundary. Clear the polygons holes. Get the number of points of a polygon element. The element type. If element type is a hole this is the holes index. Remove a polygon. Can remove the boundary or a hole. The element type. If element type is a hole this is the holes index. Remove a hole from the polygon. The holes index. Reverse the polygon. The element type. If element type is a hole this is the holes index. Get a polygons point. The element type. The index of the point in the polygon. If element type is a hole this is the holes index. Get the points in the polygon element. The element type. The point array to copy points into. The ararys length. If element type is a hole this is the holes index. Set a polygons point. The element type. The index of the point in the polygon. The point to set. If element type is a hole this is the holes index. Set all the points in the polygon. If the point array is longer than the polygon is current the extra points are appended to the end. The element type. The points to set. The ararys length. If element type is a hole this is the holes index. Triangulate the polygon. The triangle indices. Add a hole from a set of points. A CW set of points. The ararys length. Find if the polygon has a boundary. True if the polygon has a boundary. Find the polygons bounding box. The element type. If element type is a hole this is the holes index. The polygons bounding box. Find if the polygon is simple. The element type. If element type is a hole this is the holes index. True if the polygon is simple. Find if the polygon is convex. The element type. If element type is a hole this is the holes index. True if polygon is convex. Find the orientation of polygon. The element type. If element type is a hole this is the holes index. The orientation of the polygon. Find the orientated side the point is on. The element type. If element type is a hole this is the holes index. The orientated side of point compared to the polygon. The signed area of the polygon. The element type. If element type is a hole this is the holes index. The signed area is positive if polygon is ccw and negation if cw. The area of the polygon. The element type. If element type is a hole this is the holes index. The polygons area. Enumerate all points in the polygon. Each point in polygon. Enumerate all points in the polygon. Each point in polygon. Return all the points in the polygon in a array. The array. Get all the points in the polygons boundary into a list. Get all the points in the polygon boundary and holes. The point array to copy into. Round each point it polygon to a number of digits. The number of digits to round to. Convert the polygon to a new polygon with a different kernel. May result in different values due to precision issues. The new kernel type. The new polygon. Release the unmanaged resoures. Release the unmanaged pointer. Does the polygon fully contain the other polygon. The other polygon. Should the boundary be included. True if the polygon is contained within this polygon. Does this polygon contain the point. The point. Should points on the boundary be counted as being inside the polygon. True if the polygon contain the point. Translate the polygon. The amount to translate. Translate the polygon. The element type. The amount to translate. If element type is a hole this is the holes index. Rotate the polygon. The amount to rotate in radians. Rotate the polygon. The element type. The amount to rotate in radians. If element type is a hole this is the holes index. Rotate the polygon. The amount to scale. Scale the polygon. The element type. The amount to scale. If element type is a hole this is the holes index. Transform the polygon. The amount to translate. The amount to rotate in radians. The amount to scale. Transform the polygon. The element type. The amount to translate. The amount to rotate in radians. The amount to scale. If element type is a hole this is the holes index. Print debug infomation. Number of vertices. Number of faces. Number of halfedges. Number of border edges. Since each border edge of a polyhedral surface has exactly one border halfedge, this number is equal to size of border halfedges. Returns true if the polyhedral surface is combinatorially consistent. Must be a valid mesh to check many other properties. Returns true if there are no border edges. Returns true if all faces are triangles. Returns true if all faces are quads. Is this a valid triangle mesh. Is this a valid closed mesh. Is this a valid closed triangle mesh. The current build stamp. Clear the mesh. Clear the normal maps. True to clear the vertex normal map. True to clear the face normal map. Create a mesh from the points and indices. The meshes points. The meshes triangles as a index array. Maybe null. The meshes quads as a index array. Maybe null. Create a triangle mesh from the points and indices. The meshes points. The point arrays length. The meshes trinagles as a index array. The indices array length. Create a quad mesh from the points and indices. The meshes points. The point arrays length. The meshes trinagles as a index array. The indices array length. Create a mesh with quads and triangles. The meshes points. The point array length. The meshes triangles. The triangle array length. The meshes quads. The quads array length. Create a mesh with riangles, quads, pentagons and hexagons. The meshs points. The length of the point array. The faces indices. Create a mesh consisting of one polygon face. The faces points The length of the point array. Should the y coord of the points be used for the z coord. Get the triangle and quad indices. The meshes triangles as a index array. Maybe null. The meshes quads as a index array. Maybe null. Get the meshes triangles. The meshes triangles. The triangle array length. Get the meshes quads. The meshes quads. The quads array length. Get the meshes triangles and quads. The meshes triangles. The triangle array length. The meshes quads. The quads array length. Get the meshes triangles, quads, pentagons and hexagons. The indices. Array accessor for the polygon. Getting a point wraps around the polygon. The points index. The vertices point. Get the vertices point. The vertex index in the mesh. The vertices point. If index is out of range. Get the points in the mesh. The array to copy points into. The point array length. Set the point at the index. The points index The pointsam> If index is out of range. Set the points from a array. The point array. The point arrays length. Get a halfedges segment. The halfedges index. The segment. True if halfedge found. Get a segment for each halfedge in the mesh. The segment array. The segment array length. Get the faces triangle. Presumes face is a triangle with no checks. The faces index. The faces triangle Get a triangle for each face in the mesh. Presumes all faces are triangles with no checks. The trainagle array. The traingle arrays length. Get the mesh vertex. The vertices index. The vertex. True if the vertex was found. Get the vertices in the mesh. The vertex array. The vertex array length. Get the mesh face. The faces index. The face. True if the face was found. Get the faces in the mesh. The face array. The face array length. Get the mesh halfedge. The halfedges index. The halfedge. True if the halfedge was found. Get the halfedges in the mesh. The halfedge array. The halfedge array length. Count the number of triangles, quads and polygons in the mesh. The number of triangles, quads and polygons in the mesh. Count the number of triangles, quads and polygons in the dual mesh. A dual mesh is were faces become vertices and vertices become faces. The number of triangles, quads and polygons in the mesh. Get a centroid (the avergae face position) for each face in the mesh. The point array. The points arrays lemgth. Computes the vertex normals if needed. Computes the face normals if needed. Get the vertex normals. The normals array. The normals array length. Get the face normals. The normals array. The normals array length. Translate each point in the mesh. The amount to translate. Rotate each point in the mesh. The amount to rotate. Scale each point in the mesh. The amount to scale. Transform each point in the mesh. The amount to translate. The amount to rotate. The amount to scale. Make all faces triangles. Read data from a off file into the pollyhedron. The files name. Write data from a off file into the pollyhedron. The files name. Print the mesh into a string builder. Reverses the orientation of the vertices in each face. Find what side of the mesh the lies in. The point to check. ON_BOUNDED_SIDE if point inside mesh, ON_UNBOUNDED_SIDE if point not inside, ON_BOUNDARY if point is on the surface. Does the mesh contain the point. The point. If point is on the boundary does it count a being contained. True if the poly contains the point Locate the face the rays hits. The ray. The hit result. Find the face closest to the point. The point. The hit result. Locate the face hit by the ray. The ray. The hit face. True if the ray hit a face. Locate the vertex hit by the ray. The ray. The distance the vertex has to be within hit point. The hit vertex. True if the ray hit a vertex. Locate the edge hit by the ray. The ray. The distance the edge has to be within hit point. The hit edge. True if the ray hit a edge. The faces index THe faces edge A face where all compents are null index. Are these faces equal. Are these faces not equal. Are these objects equal. Are these faces equal. The faces hash code. Enmerate all edges in this edge loop. The mesh the edges belong too. The next edge Enmerate all vertices in this edge loop. The mesh the edges belong too. The next vertex https://github.com/caosdoar/spheres/blob/master/src/spheres.cpp https://github.com/mrdoob/three.js/tree/dev/src/geometries Is the edge a border to a hole. The edges index. The edges source vertices index. The edges target vertices index. The edges opposite edge. The edges next edge. The edges previous edge. The edges face A edge where everthing is set to null index. Get the source point. The mesh the point belongs to. The source point If point is null index. Get the target point. The mesh the point belongs to. The target point If point is null index. Are these edges equal. Are these edges not equal. Are these objects equal. Are these edges equal. The edges hahe code Enmerate all edges in this edge loop. The mesh the edges belong too. The next edge Enmerate all vertices in this edge loop. The mesh the edges belong too. The next vertex The vertices point. The vertices degree is how mang edges connect to it. The vertices index. The vertices edge A vertex where all components are null. Are these vertices equal. Are these vertices not equal. Are these objects equal. Are these vertices equal. The vertices hash code Enmerate all edges surrounding the vertex. The mesh the edges belong too. The next edge Generic nef polyhedron definition. A 3D Nef polyhedron is a subset of the 3-dimensional space that is the result of forming complements and intersections starting from a finite set H of 3-dimensional halfspaces. Nef polyhedra are closed under all binary set operations, i.e., intersection, union, difference, complement, and under the topological operations boundary, closure, and interior. The kernel type. creates a Nef polyhedron and initializes it to the empty set if plane == EMPTY and to the whole space if space == COMPLETE. The nef's space creates a Nef polyhedron containing the halfspace on the negative side of plane including plane if boundary==INCLUDED, excluding plane if boundary==EXCLUDED. The plane. The boundary. creates a Nef polyhedron, which represents the same point set as the polyhedral surface. The polyhedron Create from a pointer. The polyhedrons pointer. The nef polyhdron as a string. The nef polyhedron as a string. Return the intersection of nef and nef1. Return the union of nef and nef1. Return the difference between nef and nef1. Return the symmetric difference of nef and nef1. Returns the complement of nef. Returns the interior of nef. Returns the boundary of nef. Returns the closure of nef. Returns the regularization, i.e. the closure of the interior, of nef. Returns the MinkowskiSum. Converts nef into a Polyhedron. nef must be simple to convert. The result of the conversion. True if nef is simple and the conversion was successful. Converts nef into a surface mesh. nef must be simple to convert. The result of the conversion. True if nef is simple and the conversion was successful. Get a list of the nef volumes. Get a list of the nef volumes. The abstract nef polyhedra definition. Default constructor. creates a Nef polyhedron and initializes it to the empty set if plane == EMPTY and to the whole space if space == COMPLETE. The polyhedron kernel. The nef's space creates a Nef polyhedron containing the halfspace on the negative side of plane including plane if boundary==INCLUDED, excluding plane if boundary==EXCLUDED. The polyhedron kernel. The plane. The boundary. creates a Nef polyhedron, which represents the same point set as the polyhedral surface. The polyhedron kernel. The polyhedron Construct with a new kernel. The polyhedron kernel. The polyhedrons pointer. The polyhedron kernel. Contains the functions to the unmanaged CGAL polhedron. Return the number of halfedge pairs. Return the number of halfedges. Return the number of faces. Return the number of vertices. Return the number of volumes. Returns true, if nef is the empty point set. Rreturns true, if nef is a 2-manifold. Returns true, if nef is the complete 3D space. Make nef the empty set if space == EMPTY and the complete 3D space if space == COMPLETE. Checks the integrity of nef. Decompose the nef into convex volumes. Print the nef polyhedron into a string builder. Release the unmanaged pointer. Should the input polygon be checked. Can disable for better performance if it is know all input if valid. Check if the mesh is valid. The mesh to check. Check if the mesh is valid. The mesh to check. Check if the mesh is a valid triangle mesh. The mesh to check. Check if the mesh is a valid triangle mesh. The mesh to check. Check if the mesh is a valid closed mesh. The mesh to check. Check if the mesh is a valid closed mesh. The polygon to check. Check if the mesh is a valid triangle mesh. The mesh to check. Check if the mesh is a valid triangle mesh. The mesh to check. A polyhedral surface consists of vertices, edges, facets and an incidence relation on them. Each edge is represented by two halfedges with opposite orientations. The kernel type. Default constructor. Construct from points and triangle indices. Construct from points and polygon indices. Create from a pointer. The meshs pointer. The polyhdron as a string. The mesh as a string. Create a deep copy of the mesh. A deep copy of the mesh. Subdive the mesh. The number of iterations to perfrom. The subdivision method. Simplify the polyhedra. A number between 0-1 that represents the percentage of vertices to remove. Refines a triangle mesh a factor to control density of the output mesh, where larger values lead to denser refinements. Defalus to sqrt of 2. The number of new vertices. Orient the faces in the mesh. The orientation method. Reverses the orientation of the vertices in each face. Split the mesh into its unconnected components. Each unconnect component as a new mesh. Remove all unconnected compontents except the largest. Largest is defined by the face count. The numbero of largest components to keep. The number of components removed in the mesh. Create a mesh consisting of one polygon face. The faces polygon. Should the y coord of the points be used for the z coord. Thrown if the polygon is not simple. Create the dual mesh where each face becomes a vertex and each vertex becomes a face. Must be a valid closed mesh to create the dual. The duel mesh. Is thrown if the mesh is not a valid closed mesh. Convert to a surface mesh. The surface mesh. Find the min, max and average edge lengths in the mesh The min, max and average edge lengths in the mesh. Find the min, max and average face areas in the mesh The min, max and average face areas in the mesh. Locate the face the rays hits. The ray. The hit result. Find the face closest to the point. The point. The hit result. The abstract polyhedra definition. Cached values found by running Update. Default constructor. Construct with a new kernel. The mesh kernel. Construct with a new kernel. The mesh kernel. The meshs pointer. The mesh kernel. Contains the functions to the unmanaged CGAL polhedron. Number of vertices. Number of faces. Number of half edges. Number of border edges. Since each border edge of a polyhedral surface has exactly one border halfedge, this number is equal to size of border halfedges. Number of border halfedges. The current build stamp. Returns true if the polyhedral surface is combinatorially consistent. Must be a valid mesh to check many other properties. Returns true if there are no border edges. Returns true if all faces are triangles. Returns true if all faces are quads. Is the mesh a valid triangle mesh. Is the mesh a valid closed mesh. Is the mesh a valid closed triangle mesh. Has the update function been called. Mark th mesh as needing to be updated. Clear the mesh. Clear the index maps. The index maps are used to access the meshes elemnts by index. They are automaticaly created when a elements is accessed be a function requiring it. True to clear the vertex index map. True to clear the face index map. True to clear the edges index map. Clear the normal maps. True to clear the vertex normal map. True to clear the face normal map Builds the vertex and/or face index maps if needed. True to build the vertex index map. True to build the face index map. True to build the face index map. True to force the build even if already built. A tetrahedron is added to the polyhedral surface with its vertices initialized to p1, p2, p3, and p4. A edge in the tetrahdron. A triangle with border edges is added to the polyhedral surface with its vertices initialized to p1, p2, and p3. A edge in the triangle. Create a mesh from the points and indices. The meshes points. The meshes triangles as a index array. Maybe null. The meshes quads as a index array. Maybe null. Create a triangle mesh from the points and indices. The meshes points. The point arrays length. The meshes trinagles as a index array. The indices array length. Create a quad mesh from the points and indices. The meshes points. The point arrays length. The meshes trinagles as a index array. The indices array length. Create a mesh with quads and triangles. The meshes points. The point array length. The meshes triangles. The triangle array length. The meshes quads. The quads array length. Create a mesh with riangles, quads, pentagons and hexagons. The meshs points. The length of the point array. The faces indices. Create a mesh consisting of one polygon face. The faces points The point array length. Should the y coord of the points be used for the z coord. Get the triangle and quad indices. The meshes triangles as a index array. Maybe null. The meshes quads as a index array. Maybe null. Get the meshes triangles. The meshes triangles. The triangle array length. Get the meshes quads. The meshes quads. The quads array length. Get the meshes triangles and quads. The meshes triangles. The triangle array length. The meshes quads. The quads array length. Get the meshes triangles, quads, pentagons and hexagons. The indices. Get the dual meshes triangles, quads, pentagons and hexagons. A dual mesh is were faces become vertices and vertices become faces. The indices Array accessor for the polygon. Getting a point wraps around the polygon. The points index. The vertices point. Get the vertices point. The vertex index in the mesh. The vertices point. If index is out of range. Get the point at the index and wrap around the polygon. The points index. The point at the index. Get the point at the index and clamp to the polygons last point. The points index. The point at the index. Get the vertices point but wraps the index. The vertex index in the mesh. The vertices point. Get the points in the mesh. The array to copy points into. The point array length. Set the point at the index. The points index The pointsam> If index is out of range. Set the points from a array. The point array. The point arrays length. Get a halfedges segment. The halfedges index. The segment. True if halfedge found. Get the segment. The segment index. The segment If segmentwith the index not found. Get a segment for each halfedge in the mesh. The segment array. The segment array length. Get the faces triangle. Presumes face is a triangle with no checks. The faces index. The faces triangle Get the triangle. The triangle index. The triangle If triangle with the index not found. Get a triangle for each face in the mesh. Presumes all faces are triangles with no checks. The trainagle array. The traingle arrays length. Get the mesh vertex. The vertices index. The vertex. True if the vertex was found. Get the mesh vertex. The vertexs index. The vertexs If vertex with the index not found. Get the vertices in the mesh. The vertex array. The vertex array length. Get the mesh face. The faces index. The face. True if the face was found. Get the mesh face. The faces index. The faces If face with the index not found. Get the faces in the mesh. The face array. The face array length. Get the mesh halfedge. The halfedges index. The halfedge. True if the halfedge was found. Get the mesh Halfedge. The Halfedges index. The Halfedges If Halfedge with the index not found. Get the halfedges in the mesh. The halfedge array. The halfedge array length. Count the number of triangles, quads and polygons in the mesh. The number of triangles, quads and polygons in the mesh. Count the number of triangles, quads and polygons in the dual mesh. A dual mesh is were faces become vertices and vertices become faces. The number of triangles, quads and polygons in the mesh. Get a centroid (the avergae face position) for each face in the mesh. The point array. The points arrays lemgth. Computes the vertex normals if needed. Computes the face normals if needed. Get the vertex normals. The normals array. The normals array length. Get the face normals. The normals array. The normals array length. Translate each point in the mesh. The amount to translate. Rotate each point in the mesh. The amount to rotate. Scale each point in the mesh. The amount to scale. Transform each point in the mesh. The amount to translate. The amount to rotate. The amount to scale. Make all faces triangles. sorts halfedges such that the non-border edges precede the border edges. For each border edge the halfedge iterator will reference the halfedge incident to the facet right before the halfedge incident to the hole. returns true if the border halfedges are in normalized representation, which is when enumerating all halfedges with the iterator: The non-border edges precede the border edges and for border edges, the second halfedge is the border halfedge. Find what side of the mesh the lies in. The point to check. ON_BOUNDED_SIDE if point inside mesh, ON_UNBOUNDED_SIDE if point not inside, ON_BOUNDARY if point is on the surface. Does the mesh contain the point. The point. If point is on the boundary does it count a being contained. True if the poly contains the point Locate the face the rays hits. The ray. The hit result. Find the face closest to the point. The point. The hit result. Locate the face hit by the ray. The ray. The hit face. True if the ray hit a face. Locate the vertex hit by the ray. The ray. The distance the vertex has to be within hit point. The hit vertex. True if the ray hit a vertex. Locate the edge hit by the ray. The ray. The distance the edge has to be within hit point. The hit edge. True if the ray hit a edge. Tests if a set of faces of a triangulated surface mesh self-intersects. Must be a triangle mesh. True/Fasle if a valid triangle polyhedra,or UNDETERMINED if not. returns true if the polyhedral surface is combinatorially consistent. For level == 1 the normalization of the border edges is checked too. This method checks that each face is at least a triangle and that the two incident facets of a non-border edge are distinct. Computes the bounding box. The bounding box. Computes the area of a range of faces of a given triangulated surface mesh. The area or 0 if poyhedron is not valid triangle mesh. computes the centroid of a volume bounded by a closed triangulated surface mesh. The centroid or 0 if poyhedron is not valid. Computes the volume of the domain bounded by a closed triangulated surface mesh. The volume or 0 if poyhedron is not valid closed triangle mesh. Returns true if there are no border edges. True/Fasle if valid, or UNDETERMINED if not a valid polyhedra. Returns true if all vertices have exactly two incident edges. True/Fasle if valid, or UNDETERMINED if not a valid polyhedra. Returns true if all vertices have exactly three incident edges. True/Fasle if valid, or UNDETERMINED if not a valid polyhedra. Returns true if all faces are triangles. True/Fasle if valid, or UNDETERMINED if not a valid polyhedra. Returns true if all faces are quads. True/Fasle if valid, or UNDETERMINED if not a valid polyhedra. Indicates if the mesh bounds a volume. Must be a closed and triangulated. True/Fasle if a valid triangle closed polyhedra,or UNDETERMINED if not. Builds the aabb tree used for location. Tree will be automatically built if need so not actually necessary to call this function. Will delete the aabb tree. Returns true if there exists a face of this poly and a face of other poly which intersect, and false otherwise. Must be a triangle mesh The other triangle poly. If test_bounded_sides is set to true, the overlap of bounded sides are tested as well. In that case, the meshes must be closed. True/Fasle if a valid triangle closed polyhedra,or UNDETERMINED if not. Subdive the mesh. The number of iterations to perfrom. The subdivision method. Simplify the polyhedra. A number between 0-1 that represents the percentage of vertices to remove. Refines a triangle mesh a factor to control density of the output mesh, where larger values lead to denser refinements. Defalus to sqrt of 2. The number of new vertices. Orient the faces in the mesh. The orientation method. Reverses the orientation of the vertices in each face. Remove all unconnected compontents except the largest. Largest is defined by the face count. The numbero of largest components to keep. The number of components removed in the mesh. Find the min, max and average edge lengths in the mesh The min, max and average edge lengths in the mesh. Find the min, max and average face areas in the mesh The min, max and average face areas in the mesh. Enumerate all points in the mesh. Each point in mesh. Enumerate all points in the mesh. Each point in mesh. Read data from a off file into the pollyhedron. The files name. Write data from a off file into the pollyhedron. The files name. Return all the points in the mesh in a array. The array. Return all the points in the mesh in a list. The list. https://doc.cgal.org/latest/Polyhedron/classCGAL_1_1Polyhedron__3.html#a73119c0c90bf8612da003305af25a52a creates a new facet within the hole incident to h and g by connecting the vertex denoted by g with the vertex denoted by h with a new halfedge and filling this separated part of the hole with a new facet, such that the new facet is incident to g. Precondition h->is_border(), g->is_border(), h != g, h->next() != g, and g can be reached along the same hole starting with h. a halfedge index a halfedge index Returns the halfedge of the new edge that is incident to the new facet. creates a new facet within the hole incident to h and g by connecting the tip of g with the tip of h with two new halfedges and a new vertex and filling this separated part of the hole with a new facet, such that the new facet is incident to g. Precondition h->is_border(), g->is_border(), h != g, and g can be reached along the same hole starting with h. a halfedge index a halfedge index Returns the halfedge of the new edge that is incident to the new facet and the new vertex. barycentric triangulation of h->facet(). Creates a new vertex, a copy of h->vertex(), and connects it to each vertex incident to h->facet() splitting h->facet() into triangles.h remains incident to the original facet, all other triangles are copies of this facet. Precondition h is not a border halfedge. a halfedge index Returns the halfedge h->next() after the operation, i.e., a halfedge pointing to the new vertex.The time is proportional to the size of the facet. reverses create_center_vertex(). Erases the vertex pointed to by g and all incident halfedges thereby merging all incident facets.Only g->facet() remains. The neighborhood of g->vertex() may not be triangulated, it can have larger facets. Precondition None of the incident facets of g->vertex() is a hole. There are at least two distinct facets incident to the facets that are incident to g->vertex(). (This prevents the operation from collapsing a volume into two facets glued together with opposite orientations, such as would happen with any vertex of a tetrahedron.) Supports_removal must be CGAL::Tag_true. a halfedge index Returns the halfedge g->prev(). Thus, the invariant h == erase_center_vertex(create_center_vertex(h)) holds if h is not a border halfedge.The time is proportional to the sum of the size of all incident facets. removes the incident facet of h and changes all halfedges incident to the facet into border edges or removes them from the polyhedral surface if they were already border edges. If this creates isolated vertices they get removed as well.See make_hole(h) for a more specialized variant. Precondition h->is_border() == false. Supports_removal must be CGAL::Tag_true a halfedge index Erase a facet. a halfedge index returns a range of handles over the facets. fills a hole with a newly created facet. Makes all border halfedges of the hole denoted by h incident to the new facet.Returns h. Precondition h.is_border(). a halfedge index performs an edge flip. Precondition h != Halfedge_handle() and both facets incident to h are triangles. a halfedge index It returns h after rotating the edge h one vertex in the direction of the face orientation. joins the two facets incident to h. The facet incident to h->opposite() gets removed.Both facets might be holes. Precondition The degree of both vertices incident to h is at least three(no antennas). Supports_removal must be CGAL::Tag_true. a halfedge index Returns the predecessor of h around the facet. The invariant join_facet(split_facet(h, g)) returns h and keeps the polyhedron unchanged.The time is proportional to the size of the facet removed and the time to compute h->prev(). glues the boundary of the two facets denoted by h and g together and returns h. Both facets and the vertices along the facet denoted by g gets removed.Both facets may be holes. The invariant join_loop(h, split_loop(h, i, j)) Precondition The facets denoted by h and g are different and have equal degree(i.e., number of edges). Supports_removal must be CGAL::Tag_true. a halfedge index a halfedge index returns h and keeps the polyhedron unchanged. joins the two vertices incident to h. The vertex denoted by h->opposite() gets removed. Precondition The size of both facets incident to h is at least four(no multi-edges). Supports_removal must be CGAL::Tag_true. a halfedge index Returns the predecessor of h around the vertex, i.e., h->opposite()->prev(). The invariant join_vertex(split_vertex(h, g)) returns h and keeps the polyhedron unchanged.The time is proportional to the degree of the vertex removed and the time to compute h->prev() and h->opposite()->prev(). removes the incident facet of h and changes all halfedges incident to the facet into border edges. Precondition None of the incident halfedges of the facet is a border edge. Supports_removal must be CGAL::Tag_true. a halfedge index Returns h.See erase_facet(h) for a more generalized variant. splits the halfedge h into two halfedges inserting a new vertex that is a copy of h->opposite()->vertex(). Is equivalent to split_vertex(h->prev(), h->opposite())->opposite(). The call of prev() can make this method slower than a direct call of split_vertex() if the previous halfedge is already known and computing it would be costly when the halfedge data structure does not support the prev() member function. a halfedge index Returns the new halfedge now pointing to the inserted vertex.The new halfedge is followed by the old halfedge, i.e., hnew->next() == h. splits the facet incident to h and g into two facets with a new diagonal between the two vertices denoted by h and g respectively. The second(new) facet is a copy of the first facet. Precondition h and g are incident to the same facet.h != g (no loops). h->next() != g and g->next() != h (no multi-edges). a halfedge index a halfedge index Returns h->next() after the operation, i.e., the new diagonal.The new face is to the right of the new diagonal, the old face is to the left.The time is proportional to the distance from h to g around the facet. cuts the polyhedron into two parts along the cycle (h,i,j) (edge j runs on the backside of the three dimensional figure above). Three new vertices(one copy for each vertex in the cycle) and three new halfedges(one copy for each halfedge in the cycle), and two new triangles are created.h,i,j will be incident to the first new triangle. Precondition h, i, j denote distinct, consecutive vertices of the polyhedron and form a cycle: i.e., h->vertex() == i->opposite()->vertex(), … , j->vertex() == h->opposite()->vertex(). The six facets incident to(h, i, j) are all distinct. a halfedge index a halfedge index a halfedge index The return value will be the halfedge incident to the second new triangle which is the copy of h-opposite(). splits the vertex incident to h and g into two vertices, the old vertex remains and a new copy is created, and connects them with a new edge. Let hnew be h->next()->opposite() after the split, i.e., a halfedge of the new edge. The split regroups the halfedges around the two vertices.The halfedge sequence hnew, g->next()->opposite(), … , h remains around the old vertex, while the halfedge sequence hnew->opposite(), h->next()->opposite() (before the split), … , g is regrouped around the new vertex. Precondition h and g are incident to the same vertex. h != g (antennas are not allowed). a halfedge index a halfedge index The split returns hnew, i.e., the new halfedge incident to the old vertex.The time is proportional to the distance from h to g around the vertex. Update the mesh if needed. Print the mesh into a string builder. Release the unmanaged pointer. This class is a data structure that can be used as halfedge data structure. It is an alternative to the classes Polyhedron3.The main difference is that it is indexed based and not pointer based, and that the mechanism for adding information to vertices, halfedges, edges, and faces is much simpler. When elements are removed, they are only marked as removed, and a garbage collection function must be called to really remove them. The kernel type Default constructor. Construct from points and triangle indices. Construct from points and polygon indices. Create from a pointer. The surface meshes pointer. The mesh as a string. The mesh as a string. Create a deep copy of the mesh. The deep copy. Subdive the mesh. The number of iterations to perfrom. The subdivision method. Simplify the polyhedra. A number between 0-1 that represents the percentage of vertices to remove. Refines a triangle mesh a factor to control density of the output mesh, where larger values lead to denser refinements. Defalus to sqrt of 2. The number of new vertices. Orient the faces in the mesh. The orientation method. Reverses the orientation of the vertices in each face. Split the mesh into its unconnected components. Each unconnect component as a new mesh. Remove all unconnected compontents except the largest. Largest is defined by the face count. The numbero of largest components to keep. The number of components removed in the mesh. Copy the other mesh to this one. Create a mesh consisting of one polygon face. The faces polygon. Should the y coord of the points be used for the z coord. Thrown if the polygon is not simple. Convert to a polyhedron mesh. The polyhedron mesh. Find the min, max and average edge lengths in the mesh The min, max and average edge lengths in the mesh. Find the min, max and average face areas in the mesh The min, max and average face areas in the mesh. Locate the face the rays hits. The ray. The hit result. Find the face closest to the point. The point. The hit result. The surface mesh abstract base class. Cached values found by running Update. Default constructor. Construct mesh with the kernel. The kernel Construct with a new kernel. The surface meshes kernel. The surface meshes pointer. The meshes kernel type. The number of vertices in the mesh. The number of half edges in the mesh. The number of edges in the mesh. The number of faces in the mesh. The number of border edges. The current build stamp. The number of vertices currenly maked to be removed but have not. Calling collect garbage will remove them. The number of vertices marked to be removed. The number of halfedges currenly maked to be removed but have not. Calling collect garbage will remove them. The number of half edges marked to be removed. The number of edges currenly maked to be removed but have not. Calling collect garbage will remove them. The number of edges marked to be removed. The number of faces currenly maked to be removed but have not. Calling collect garbage will remove them. The number of face marked to be removed. Returns true if the meshl surface is combinatorially consistent. Must be a valid mesh to check many other properties. Returns true if there are no border edges. Returns true if all faces are triangles. Returns true if all faces are quads. Is the mesh a valid triangle mesh. Is the mesh a valid closed mesh. Is the mesh a valid closed triangle mesh. Has the update function been called. Mark the mesh as needing to be updated. Clear the mesh. Clear the index maps. The index maps are used to access the meshes elemnts by index. They are automaticaly created when a elements is accessed be a function requiring it. True to clear the vertex index map. True to clear the face index map. True to clear the edges index map. True to clear the halfedges index map. Clear the normal maps. True to clear the vertex normal map. True to clear the face normal map Clear the property maps. Build the index maps. The index maps are used to access the meshes elemnts by index. They are automaticaly created when a elements is accessed be a function requiring it but can be create ahead of time. True to build the vertex index maps. True to build the face index maps. True to build the edge index maps. True to build the halfedge index maps. The index maps wont be build if the mesh knows they are already built and upto date. Setting force to true will build them always. Adds a vertex to the mesh. The vertices position The vertices index in the mesh. Adds a edge between the two vertices. The index of the vertex in the mesh. The index of the vertex in the mesh. The index of the edge in the mesh. Adds a triangle face to the mesh. The index of the vertex in the mesh. The index of the vertex in the mesh. The index of the vertex in the mesh. The index of the face in the mesh. Adds a quad face to the mesh. The index of the vertex in the mesh. The index of the vertex in the mesh. The index of the vertex in the mesh. The index of the vertex in the mesh. The index of the face in the mesh. Adds a pentagon face to the mesh. The index of the vertex in the mesh. The index of the vertex in the mesh. The index of the vertex in the mesh. The index of the vertex in the mesh. The index of the vertex in the mesh. The index of the face in the mesh. Adds a hexagon face to the mesh. The index of the vertex in the mesh. The index of the vertex in the mesh. The index of the vertex in the mesh. The index of the vertex in the mesh. The index of the vertex in the mesh. The index of the vertex in the mesh. The index of the face in the mesh. Add a polygon face to the mesh. The indices of the points in the mesm. The indices array length. The index of the face in the mesh. Checks if any vertices, halfedges, edges, or faces are marked as removed. Really removes vertices, halfedges, edges, and faces which are marked removed. By garbage collecting elements get new indices. In case you store indices in an auxiliary data structure or in a property these indices are potentially no longer refering to the right elements. Controls the recycling or not of simplices previously marked as removed upon addition of new elements. When set to true (default value), new elements are first picked in the garbage(if any) while if set to false only new elements are created. Array accessor for the polygon. Getting a point wraps around the polygon. Get the vertices point. The vertex index in the mesh. The vertices point. If index is out of range. Get the points in the mesh. The array to copy points into. The point array length. Set the point at the index. The points index The pointsam> If index is out of range. Set the points from a array. The point array. The point arrays length. Get a halfedges segment. The halfedges index. The segment. True if halfedge found. Get a segment for each halfedge in the mesh. The segment array. The segment array length. Get the faces triangle. Presumes face is a triangle with no checks. The faces index. The faces triangle Get a triangle for each face in the mesh. Presumes all faces are triangles with no checks. The trainagle array. The traingle arrays length. Get the mesh vertex. The vertices index. The vertex. True if the vertex was found. Get the mesh vertex. The vertices index. The vertex. Get the vertices in the mesh. The vertex array. The vertex array length. Get the mesh face. The faces index. The face. True if the face was found. Get the mesh face. The faces index. The face. Get the faces in the mesh. The face array. The face array length. Get the mesh halfedge. The halfedges index. The halfedge. True if the halfedge was found. Get the mesh halfedge. The halfedges index. THe healfedge. Get the halfedges in the mesh. The halfedge array. The halfedge array length. Returns the number of incident halfedges of vertex. The index of the vertex in the mesh. Returns the number of incident halfedges of vertex. Returns the number of incident halfedges of face. The index of the face in the mesh. Returns the number of incident halfedges of face. Returns whether vertex is isolated. The index of the vertex in the mesh. Returns whether vertex is isolated. Returns whether vertex is a border vertex. If the data contained in the Surface_mesh is not a 2-manifold, then this operation is not guaranteed to return the right result. he index of the vertex in the mesh. With the default value for check_all_incident_halfedges the function iteratates over the incident halfedges. With check_all_incident_halfedges == false the function returns true, if the incident halfedge associated to vertex is a border halfedge, or if the vertex is isolated. Returns whether vertex is a border vertex. Returns whether edge is a border edge, i.e., if any of its two halfedges is a border halfedge. The index of the edge in the mesh. Returns whether edge is a border edge. Returns the next halfedge within the incident face. The index of the halfedge in the mesh. Returns the next halfedge within the incident face. Returns the previous halfedge within the incident face. The index of the halfedge in the mesh. Returns the previous halfedge within the incident face. Returns the opposite halfedge of halfedge. The index of the halfedge in the mesh. Returns the opposite halfedge of halfedge. Returns the vertex the halfedge emanates from. The index of the halfedge in the mesh. Returns the vertex the halfedge emanates from. Returns the vertex the halfedge points to. The index of the halfedge in the mesh. Returns the vertex the halfedge points to. Removes vertex from the halfedge data structure without adjusting anything. The index of the vertex in the mesh. True if face removed. Removes the two halfedges corresponding to edge from the halfedge data structure without adjusting anything. The index of the edge in the mesh. True if face removed. Removes face from the halfedge data structure without adjusting anything. The index of the face in the mesh. True if face removed. Has this vertex been marked to be removed. The vertices index in the mesh. Has this vertex been marked to be removed. Has this face been marked to be removed. The faces index in the mesh. Has this face been marked to be removed. Has this halfedge been marked to be removed. The halfedge index in the mesh. Has this halfedge been marked to be removed. Has this edge been marked to be removed. The edges index in the mesh. Has this edge been marked to be removed. Performs a validity check on a single vertex. The index of the vertex in the mesh. True if valid. Performs a validity check on a single edge. The index of the edge in the mesh. True if valid. Performs a validity check on a single halfedge. The index of the halfedge in the mesh. True if valid. Performs a validity check on a single face. The index of the face in the mesh. True if valid. Translate each point in the mesh. The amount to translate. Rotate each point in the mesh. The amount to rotate. Scale each point in the mesh. The amount to scale. Transform each point in the mesh. The amount to translate. The amount to rotate. The amount to scale. Create a mesh from the points and indices. The meshes points. The meshes triangles as a index array. Maybe null. The meshes quads as a index array. Maybe null. Create a triangle mesh from the points and indices. The meshes points. The point arrays length. The meshes trinagles as a index array. The indices array length. Create a quad mesh from the points and indices. The meshes points. The point arrays length. The meshes trinagles as a index array. The indices array length. Create a mesh with quads and triangles. The meshes points. The point array length. The meshes triangles. The triangle array length. The meshes quads. The quads array length. Create a mesh with riangles, quads, pentagons and hexagons. The meshs points. The length of the point array. The faces indices. Create a mesh consisting of one polygon face. The faces points The paoint array length. Should the y coord of the points be used for the z coord. Get the triangle and quad indices. The meshes triangles as a index array. Maybe null. The meshes quads as a index array. Maybe null. Get the meshes triangles. The meshes triangles. The triangle array length. Get the meshes quads. The meshes quads. The quads array length. Get the meshes triangles and quads. The meshes triangles. The triangle array length. The meshes quads. The quads array length. Get the meshes triangles, quads, pentagons and hexagons. The indices. Whether v is a border vertex. The vertices index. With the default value for check_all_incident_halfedges the function iteratates over the incident halfedges. With check_all_incident_halfedges == false the function returns true, if the incident halfedge associated to vertex v is a border halfedge, or if the vertex is isolated. Whether v is a border vertex. Whether half edge is a border halfege, that is if its incident face is null. The halfedges index. Whether half edge is a border halfege. Whether e is a border edge, i.e., if any of its two halfedges is a border halfedge. The edges index. Whether e is a border edge. Count the number of triangles, quads and polygons in the mesh. The number of triangles, quads and polygons in the mesh. Count the number of triangles, quads and polygons in the dual mesh. A dual mesh is were faces become vertices and vertices become faces. The number of triangles, quads and polygons in the mesh. Build the aabb tree. Release the aabb tree. Find the bounding box of the meshes points. Read the mesh from a off file format. The files name. Write the mesh to off file format. The files name. Make all faces triangles. Tests if a set of faces of a triangulated surface mesh self-intersects. Must be a triangle mesh. True/Fasle if a valid triangle mesh,or UNDETERMINED if not. Perform an expensive validity check on the data structure. If the mesh is valid. Find if all the faces in the mesh are triangles. True if all the faces in the mesh are triangles, Will be undetermined if no a valid mesh. Find if all the faces in the mesh are quads. True if all the faces in the mesh are quads, Will be undetermined if no a valid mesh. Find if the mesh is closed, ie has no border edges. Computes the area of a range of faces of a given triangulated surface mesh. The area or 0 if mesh is not valid triangle mesh. computes the centroid of a volume bounded by a closed triangulated surface mesh. The centroid or 0 if mesh is not valid. Computes the volume of the domain bounded by a closed triangulated surface mesh. The volume or 0 if mesh is not valid closed triangle mesh. Indicates if the mesh bounds a volume. Must be a closed and triangulated. True/Fasle if a valid triangle closed mesh,or UNDETERMINED if not. Find what side of the mesh the lies in. The point to check. ON_BOUNDED_SIDE if point inside mesh, ON_UNBOUNDED_SIDE if point not inside, ON_BOUNDARY if point is on the surface. Does the mesh contain the point. The point. If point is on the boundary does it count a being contained. True if the poly contains the point Locate the face the rays hits. The ray. The hit result. Find the face closest to the point. The point. The hit result. Locate the face hit by the ray. The ray. The hit face. True if the ray hit a face. Locate the vertex hit by the ray. The ray. The distance the vertex has to be within hit point. The hit vertex. True if the ray hit a vertex. Locate the edge hit by the ray. The ray. The distance the edge has to be within hit point. The hit edge. True if the ray hit a edge. Returns true if there exists a face of this poly and a face of other mesh which intersect, and false otherwise. Must be a triangle mesh The other triangle poly. If test_bounded_sides is set to true, the overlap of bounded sides are tested as well. In that case, the meshes must be closed. True/Fasle if a valid triangle closed mesh,or UNDETERMINED if not. Find the min, max and average edge lengths in the mesh The min, max and average edge lengths in the mesh. Find the min, max and average face areas in the mesh The min, max and average face areas in the mesh. Subdive the mesh. The number of iterations to perfrom. The subdivision method. Simplify the polyhedra. A number between 0-1 that represents the percentage of vertices to remove. Refines a triangle mesh a factor to control density of the output mesh, where larger values lead to denser refinements. Defalus to sqrt of 2. The number of new vertices. Orient the faces in the mesh. The orientation method. Reverses the orientation of the vertices in each face. Remove all unconnected compontents except the largest. Largest is defined by the face count. The numbero of largest components to keep. The number of components removed in the mesh. Get a centroid (the avergae face position) for each face in the mesh. The point array. The points arrays lemgth. Compute the vertex normal map. Will only be computed if mesh has changed since last computation or no current nomral maps have been computed. Compute the face normal map. Will only be computed if mesh has changed since last computation or no current nomral maps have been computed. Get the vertex normals. Will be compute if they have not aready. The normal map array. The normal maps array length. Get the face normals. Will be compute if they have not aready. The normal map array. The normal maps array length. Enumerate all points in the mesh. Each point in mesh. Enumerate all points in the mesh. Each point in mesh. Return all the points in the mesh in a array. The array. Return all the points in the mesh in a list. The list. Update the mesh if needed. Print the mesh into a string builder. Release any unmanaged resources. Generic polyline definition. The kernel type. Default constructor. Create from a set of points. The polylines points. Create from a pointer. The polylines pointer. The polyline as a string. The polyline as a string. Copy the polyline. The copied polyline. Create a polygon from the line. Threshold for the firat and last points being equal. The polygon. The abstract polyline definition. Default constructor. Construct with a new kernel. The polyline kernel. Construct with a new kernel. The polyline kernel. The points to construct from. Construct with a new kernel. The polyline kernel. The polylines pointer. The number of points in the polyline. The capacity of the point array. Get the first point. Get the last point. The polylines kernel. Contains the functions to the unmanaged CGAL polyline. Array accessor for the polyline. Getting a point clamps to the last point in polyline. Clear the polyline of all points. Shrink the capacity to match the point count. Resize the point array. New elements will default to zero. Reverse the polints in the line. Remove the point at the index from the array. The points index Remove a range of points from the array. The starting index The number of points to remove. Remove the last point. Remove the point at the index from the array. The points index. The point to insert. Remove a range of points from the array. The points to insert. The starting index. The number of points to insert. Add the point to the end of the poylline. The point to add. Does the first and last point match. The distance threshold that counts as match. Get the point a the index. The points index to get. The point at index. Get the point at the index and wrap around the polyline. The points index. The point at the index. Get the point at the index and clamp to the polylines last point. The points index. The point at the index. Get all the points in the polyline. The point array to copy the data into. The array length. Get all the polyline points. The list to copy the data into. Get all the polyline segments. The segment array to copy the data into. The array length. Set the points at the index. The points index. The points value. Set the points from the array. If the array is larger than the polyline then the new points will be appended to end of polyline. The points array. The array length. Finds the length of the polyline. Finds the square length of the polyline. Translate the polyline. The amount to translate. Rotate the polyline. The amount to rotate in radians. Scale the polyline. The amount to scale. Transform the polyline with a TRS matrix. The amount to translate. The amount to rotate. The amount to scale. Enumerate all points in the polyline. Each point in polyline. Enumerate all points in the polyline. Each point in polyline. Return all the points in the polyline in a array. The array. Return all the points in the polyline in a list. The list. Convert the polyline to a new polyline with a different kernel. May result in different values due to precision issues. The new kernel type. The new polline. Print the polyline into a styring builder. Release the unmanaged pointer. Release the unmanaged pointer. Generic polyline definition. The kernel type. Default constructor. Create from a set of points. The polylines points. Create from a pointer. The polylines pointer. The polyline as a string. The polyline as a string. Copy the polyline. The copied polyline. The abstract polyline definition. Default constructor. Construct with a new kernel. The polyline kernel. Construct with a new kernel. The polyline kernel. The points to construct from. Construct with a new kernel. The polyline kernel. The polylines pointer. The number of points in the polyline. The capacity of the point array. Get the first point. Get the last point. The polylines kernel. Contains the functions to the unmanaged CGAL polyline. Array accessor for the polyline. Getting a point clamps to the last point in polyline. Clear the polyline of all points. Shrink the capacity to match the point count. Resize the point array. New elements will default to zero. Reverse the polints in the line. Remove the point at the index from the array. The points index Remove a range of points from the array. The starting index The number of points to remove. Remove the last point. Remove the point at the index from the array. The points index. The point to insert. Remove a range of points from the array. The points to insert. The starting index. The number of points to insert. Add the point to the end of the poylline. The point to add. Does the first and last point match. The distance threshold that counts as match. Get the point a the index. The points index to get. The point at index. Get the point at the index and wrap around the polyline. The points index. The point at the index. Get the point at the index and clamp to the polylines last point. The points index. The point at the index. Get all the points in the polyline. The point array to copy the data into. The array length. Get all the polyline points. The list to copy the data into. Get all the polyline segments. The segment array to copy the data into. The array length. Set the points at the index. The points index. The points value. Set the points from the array. If the array is larger than the polyline then the new points will be appended to end of polyline. The points array. The array length. Finds the length of the polyline. Finds the square length of the polyline. Translate each point in the polyline. The amount to translate. Rotate each point in the polyline. The amount to rotate. Scale each point in the polyline. The amount to scale. Transform each point in the polyline. The amount to translate. The amount to rotate. The amount to scale. Enumerate all points in the polyline. Each point in polyline. Enumerate all points in the polyline. Each point in polyline. Return all the points in the polyline in a array. The array. Return all the points in the polyline in a list. The list. Convert the polyline to a new polyline with a different kernel. May result in different values due to precision issues. The new kernel type. The new polline. Print the polyline into a styring builder. Release the unmanaged pointer. Release the unmanaged pointer. The heat method is an algorithm that solves the single- or multiple-source shortest path problem by returning an approximation of the geodesic distance for all vertices of a triangle mesh to the closest vertex in a given set of source vertices. The geodesic distance between two vertices of a mesh is the distance when walking on the surface, potentially through the interior of faces. Two vertices that are close in 3D space may be far away on the surface. Create a static instance. Create a new instance. Create a new instance from a existing pointer to a unmanaged object. The unmanaged objects pointer. Find the distances for each vertex in the mesh to the vertex at the provided index. The mesh containing the vertices. The vertices index to find the distances to. The distances for each vertex in the mesh. Should the intrinsitic delaunay triangulation be used. This will improve the results for meshes that have bad triangle quality. The maximum distance value. Find the distances for each vertex in the mesh to the vertex at the provided index. The mesh containing the vertices. The vertices index to find the distances to. The distances for each vertex in the mesh. This will improve the results for meshes that have bad triangle quality. The maximum distance value. Create a new instance. Create a new instance from a existing pointer to a unmanaged object. The unmanaged objects pointer. Release any unmanaged resources. Returns the number of unconnect components in the mesh. A valid mesh. Returns the number of unconnect components in the mesh. Returns a list of face indices that are part of the same component as the provided face index. A valid mesh. The faces index in the mesh. A list of face indices that are part of the same component as the provided face index. Returns a list of face indices that are part of the same component as the provided face index. A valid mesh. The faces index in the mesh. A list of face indices that are part of the same component as the provided face index. Split each component in the mesh into individual meshes. A valid mesh. The split meshes. Split each component in the mesh into individual meshes. A valid mesh. The split meshes. Removes connected components with less than a given number of faces. A valid mesh. The number of faces a component must have so that it is kept The number of components removed. Removes connected components with less than a given number of faces. A valid mesh. The number of faces a component must have so that it is kept The number of components removed. Removes the small connected components and all isolated vertices. A valid mesh. Keep this number of the largest connected components. The number of components removed. Removes the small connected components and all isolated vertices. A valid mesh. Keep this number of the largest connected components. The number of components removed. Release any unmanaged resources. Detects the edges that are considered to be sharp with respect to the given angle bound. A valid mesh. Angle in deg gives the maximum angle between the two normal vectors of adjacent triangles. For an edge of the input polygon mesh, if the angle between the two normal vectors of its incident facets is bigger than the given bound, then the edge is marked as being a feature edge. The halfedge indices of the edges that count as sharp. Detects the edges that are considered to be sharp with respect to the given angle bound. A valid mesh. Angle in deg gives the maximum angle between the two normal vectors of adjacent triangles. For an edge of the input polygon mesh, if the angle between the two normal vectors of its incident facets is bigger than the given bound, then the edge is marked as being a feature edge. The halfedge indices of the edges that count as sharp. Find the min, max and average edge lengths in the mesh. A valid mesh. The min, max and average edge lengths in the mesh. Find the min, max and average edge lengths in the mesh. A valid mesh. The min, max and average edge lengths in the mesh. Find the min, max and average face areas in the mesh. A valid mesh. The min, max and average face areas in the mesh. Find the min, max and average face areas in the mesh. A valid mesh. The min, max and average face areas in the mesh. Detects the sharp edges of mesh according to angle as the DetectSharpEdges function does. The sharp edges are then used to define a segmentation of a mesh, that is done by computing a surface patch id for each face. A valid mesh. Angle in deg gives the maximum angle between the two normal vectors of adjacent triangles. For an edge of the input polygon mesh, if the angle between the two normal vectors of its incident facets is bigger than the given bound, then the edge is marked as being a feature edge. The halfedge indices of the edges that count as sharp. The face indices for each patch found. Detects the sharp edges of pmesh according to angle as the DetectSharpEdges function does. The sharp edges are then used to define a segmentation of a mesh, that is done by computing a surface patch id for each face. A valid mesh. Angle in deg gives the maximum angle between the two normal vectors of adjacent triangles. For an edge of the input polygon mesh, if the angle between the two normal vectors of its incident facets is bigger than the given bound, then the edge is marked as being a feature edge. The face indices for each patch found. Release any unmanaged resources. Find a random point on mesh surface. The mesh. A random point on mesh surface. Find a random point on mesh surface. The mesh. A random point on mesh surface. Find the face the ray intersects with. The mesh. Th ray. The hit result with theface index, hit point and the barycentric coords. Find the face the ray intersects with. The mesh. Th ray. The hit result with theface index, hit point and the barycentric coords. Find the closest face to the point. The mesh. Th point. The hit result with the face index, closest point and the barycentric coords. Find the closest face to the point. The mesh. Th point. The hit result with the face index, closest point and the barycentric coords. Release any unmanaged resources. Fills output with a closed mesh bounding the volume swept by input when translating its vertices by dir. The mesh is oriented so that the faces corresponding to input in output have the same orientation. The a valid closed mesh. The direction vector. The extuded mesh. Fills output with a closed mesh bounding the volume swept by input when translating its vertices by dir. The mesh is oriented so that the faces corresponding to input in output have the same orientation. The a valid closed mesh. The direction vector. The extuded mesh. Fairs a region on a triangle mesh based on a ring of k vertices from the index vertex. The points of the selected vertices are relocated to yield an as-smooth-as-possible surface patch, based on solving a linear bi-Laplacian system with boundary constraints The region described by vertices might contain multiple disconnected components. Note that the mesh connectivity is not altered in any way, only vertex locations get updated. Fairing might fail if fixed vertices, which are used as boundary conditions, do not suffice to solve constructed linear system. Note that if the vertex range to which fairing is applied contains all the vertices of the triangle mesh, fairing does not fail, but the mesh gets shrinked to the origin. A valid triangle mesh. The vertex index in the mesh to start hthe k ring region from. The number of vertics to expand the region to. If the fairing was successfully run. Refines a triangle mesh A valid triangle mesh. a factor to control density of the output mesh, where larger values lead to denser refinements. Defalus to sqrt of 2. The number of new vertices added. Refines a triangle mesh A valid triangle mesh. a factor to control density of the output mesh, where larger values lead to denser refinements. Defalus to sqrt of 2. The number of new vertices added. Remeshes a triangulated region of a meshgon mesh. This operation sequentially performs edge splits, edge collapses, edge flips, tangential relaxation and projection to the initial surface to generate a smooth mesh with a prescribed edge length. A valid triangle mesh. The number of times to perform the remeshing. the edge length that is targeted in the remeshed patch. If 0 is passed then only the edge-flip, tangential relaxation, and projection steps will be done. The number of new vertices added. Remeshes a triangulated region of a meshgon mesh. This operation sequentially performs edge splits, edge collapses, edge flips, tangential relaxation and projection to the initial surface to generate a smooth mesh with a prescribed edge length. A valid triangle mesh. The number of times to perform the remeshing. the edge length that is targeted in the remeshed patch. If 0 is passed then only the edge-flip, tangential relaxation, and projection steps will be done. The number of new vertices added. randomly perturbs the locations of vertices of a triangulated surface mesh. By default, the vertices are re-projected onto the input surface after perturbation.Note that no geometric checks are done after the perturbation (face orientation might become incorrect and self-intersections might be introduced). A mesh. The maximun amount a vertex will be pertured. Must be greater tha 0. randomly perturbs the locations of vertices of a triangulated surface mesh. By default, the vertices are re-projected onto the input surface after perturbation.Note that no geometric checks are done after the perturbation (face orientation might become incorrect and self-intersections might be introduced). A mesh. The maximun amount a vertex will be pertured. Must be greater tha 0. Smooths a triangulated mesh. This function attempts to make the triangle angle and area distributions as uniform as possible by moving(non-constrained) vertices. Angle-based smoothing does not change the combinatorial information of the mesh. Area-based smoothing might change the combinatorial information, unless specified otherwise. It is also possible to make the smoothing algorithm "safer" by rejecting moves that, when applied, would worsen the quality of the mesh, e.g.that would decrease the value of the smallest angle around a vertex or create self-intersections. Optionally, the points are reprojected after each iteration. A valid triangle mesh. The edge angle that counts a feature and wont be smoothed. The number of iterations for the sequence of the smoothing iterations performed splits the edges listed in edges into sub-edges that are not longer than the given threshold max_length. Note this function is useful to split constrained edges before calling isotropic_remeshing() with protection of constraints activated (to match the constrained edge length required by the remeshing algorithm to be guaranteed to terminate) A valid mesh. The edge length above which an edge from edges is split into to sub-edges The number of new edges added to the mesh. splits the edges listed in edges into sub-edges that are not longer than the given threshold max_length. Note this function is useful to split constrained edges before calling isotropic_remeshing() with protection of constraints activated (to match the constrained edge length required by the remeshing algorithm to be guaranteed to terminate) A valid mesh. The edge length above which an edge from edges is split into to sub-edges The number of new edges added to the mesh. Triangulate a single face in the mesh. A valid mesh. The faces index in the mesh. True if successful. Triangulate a single face in the mesh. A valid mesh. The faces index in the mesh. True if successful. Triangulate a range of faces in the mesh. A valid mesh. The faces to triangulate. The length of the face array. True if successful. Triangulate a range of faces in the mesh. A valid mesh. The faces to triangulate. The length of the face array. True if successful. Release any unmanaged resources. Indicates if mesh bounds a volume. A closed triangle mesh. Indicates if mesh bounds a volume. A closed triangle mesh. Tests whether a closed triangle mesh has a positive orientation. A closed triangle mesh is considered to have a positive orientation if the normal vectors to all its faces point outside the domain bounded by the triangle mesh.The normal vector to each face is chosen pointing on the side of the face where its sequence of vertices is seen counterclockwise. A closed triangle mesh. Tests whether a closed triangle mesh has a positive orientation. A closed triangle mesh is considered to have a positive orientation if the normal vectors to all its faces point outside the domain bounded by the triangle mesh.The normal vector to each face is chosen pointing on the side of the face where its sequence of vertices is seen counterclockwise. A closed triangle mesh. Orient the faces in the mesh. The orientation method. A valid closed triangle mesh. Orient the faces in the mesh. The orientation method. A valid closed triangle mesh. Makes each connected component of a closed triangulated surface mesh inward or outward oriented. A closed triangle mesh. Makes each connected component of a closed triangulated surface mesh inward or outward oriented. A closed triangle mesh. Orients the connected components of tm to make it bound a volume. A closed triangle mesh. Orients the connected components of tm to make it bound a volume. A closed triangle mesh. Reverses for each face the order of the vertices along the face boundary. A valid mesh. Reverses for each face the order of the vertices along the face boundary. A valid mesh. Release any unmanaged resources. Find the number of degenerate edges in the mesh. The polygon mesh. The number of degenerate edges in the mesh. Find the number of degenerate faces in the mesh. A triangle polygon mesh. The number of degenerate faces in the mesh. Find the number of degenerate faces in the mesh. A triangle polygon mesh. The number of degenerate faces in the mesh. Checks whether a triangle face is needle. A triangle is said to be a needle if its longest edge is much longer than its shortest edge. A triangle polygon mesh. A bound on the ratio of the longest edge length and the shortest edge length. The number of needle triangles. Checks whether a triangle face is needle. A triangle is said to be a needle if its longest edge is much longer than its shortest edge. A triangle polygon mesh. A bound on the ratio of the longest edge length and the shortest edge length. The number of needle triangles. Collects the non-manifold vertices (if any) present in the mesh. A non-manifold vertex v is returned via one incident halfedge h such that target(h, pm) = v for all the umbrellas that v appears in (an umbrella being the set of faces incident to all the halfedges reachable by walking around v using hnext = prev(opposite(h, pm), pm), starting from h). A triangle polygon mesh. The non manifold vertex count. Collects the non-manifold vertices (if any) present in the mesh. A non-manifold vertex v is returned via one incident halfedge h such that target(h, pm) = v for all the umbrellas that v appears in (an umbrella being the set of faces incident to all the halfedges reachable by walking around v using hnext = prev(opposite(h, pm), pm), starting from h). A triangle polygon mesh. The non manifold vertex count. Cleans a given polygon soup through various repairing operations. More precisely, this function carries out the following tasks, in the same order as they are listed: merging of duplicate points. simplification of polygons to remove geometrically identical consecutive vertices; splitting of "pinched" polygons, that is polygons in which a geometric position appears more than once. The splitting process results in multiple non-pinched polygons; removal of invalid polygons, that is polygons with fewer than 2 vertices; removal of duplicate polygons. removal of isolated points. The polygon mesh. Cleans a given polygon soup through various repairing operations. More precisely, this function carries out the following tasks, in the same order as they are listed: merging of duplicate points. simplification of polygons to remove geometrically identical consecutive vertices; splitting of "pinched" polygons, that is polygons in which a geometric position appears more than once. The splitting process results in multiple non-pinched polygons; removal of invalid polygons, that is polygons with fewer than 2 vertices; removal of duplicate polygons. removal of isolated points. The polygon mesh. stitches together, whenever possible, two halfedges belonging to the same boundary cycle. Two border halfedges h1 and h2 can be stitched if the points associated to the source and target vertices of h1 are the same as those of the target and source vertices of h2, respectively. The polygon mesh. The number of stiched boundaries. stitches together, whenever possible, two halfedges belonging to the same boundary cycle. Two border halfedges h1 and h2 can be stitched if the points associated to the source and target vertices of h1 are the same as those of the target and source vertices of h2, respectively. The polygon mesh. The number of stiched boundaries. Stitches together border halfedges in a polygon mesh. The polygon mesh. The number of stiched borders. Stitches together border halfedges in a polygon mesh. The polygon mesh. The number of stiched borders. Removes the isolated vertices from any polygon mesh. A vertex is considered isolated if it is not incident to any simplex of higher dimension. The polygon mesh. The number of vertices that were removed. Removes the isolated vertices from any polygon mesh. A vertex is considered isolated if it is not incident to any simplex of higher dimension. The polygon mesh. The number of vertices that were removed. Release any unmanaged resources. Find the line formed from the intersection of the plane and the mesh. The mesh. Is not modified. The plane. The polylines from the intersection. Find the line formed from the intersection of the plane and the mesh. The mesh. Is not modified. The plane. The polylines from the intersection. Find the lines formed by slicing the mesh from the start point to the end point creating a plane at each increment. The mesh. Is not modified. The point to start from. The point to end at. Amount to increment each plane. he polylines from the intersection. Find the lines formed by slicing the mesh from the start point to the end point creating a plane at each increment. The mesh. Is not modified. The point to start from. The point to end at. Amount to increment each plane. he polylines from the intersection. Release any unmanaged resources. Simplify the mesh. A valid triangle mesh. A percentage 0-1 of edges to remove. Simplify the mesh. A valid triangle mesh. A percentage 0-1 of edges to remove. Release the unmanaged resourses. Subdive each face in the mesh. A valid mesh. Must be a triangle mesh for loop or sqrt3. The number of subdivision iterations. Subdive each face in the mesh. A valid mesh. Must be a triangle mesh for loop or sqrt3. The number of subdivision iterations. Subdive each face in the mesh. A valid mesh. The number of subdivision iterations. Subdive each face in the mesh. A valid mesh. The number of subdivision iterations. Subdive each face in the mesh. A valid triangle mesh. The number of subdivision iterations. Subdive each face in the mesh. A valid triangle mesh. The number of subdivision iterations. Subdive each face in the mesh. A valid triangle mesh. The number of subdivision iterations. Subdive each face in the mesh. A valid triangle mesh. The number of subdivision iterations. Subdive each face in the mesh. A valid triangle mesh. The number of subdivision iterations. Release the unmanaged resourses. Base triangulation class for Triangulation, DelaunayTriangulation, ConstrainedTriangulation and ConstrainedDelaunayTriangulation. The triangulations kernel. The number of verices in the triangulation. The number of triangles in the triangulation. The number of indices need to represent the triangulation (number of triangles * 3). A number that will change if the unmanaged triangulation model changes. Clear the triangulation. Is this a valid triangulation. True if valid. Force the face and vertex indices to be set. Inserts point p in the triangulation. If point coincides with an already existing vertex the triangulation remains unchanged. If point is on an edge, the two incident faces are split in two. If point is strictly inside a face of the triangulation, the face is split in three. If point is strictly outside the convex hull, p is linked to all visible points on the convex hull to form the new triangulation. The point to insert. Inserts points into the triangulation. If point coincides with an already existing vertex the triangulation remains unchanged. If point is on an edge, the two incident faces are split in two. If point is strictly inside a face of the triangulation, the face is split in three. If point is strictly outside the convex hull, p is linked to all visible points on the convex hull to form the new triangulation. The points to insert. The ararys length. Get a array of all the points in the triangulation. The point array. The ararys length. Get a array of the triangle indices. The ararys length. Get the vertices point. The vertex index. The vertices point. True if the vertex was found. Get the point. The points index. The point If point with the index not found. Get a vertex. The vertex index. The vertex. True if the vertex was found. Get the vertex. The vertexs index. The vertexs If vertex with the index not found. Get a array of all the vertices. The vertex array. The ararys length. Get a triangule face. The faces index The face True if the face was found. Get the face. The faces index. The Faces If face with the index not found. Get a array of all the triangle faces. A array of faces. The ararys length. Get the segment between the face and a neighbour. The faces index The neighbour (0-2) index in the face. The segment. True if the face was found. Get the segment between the face and a neighbour. The faces index The neighbour (0-2) index in the face. The segment If segment with the index not found. Get a faces triangle. The faces index The triangle True if the face was found Get the triangle. The triangles index. The triangle If triangle with the index not found. Get a array of all the triangles. A array of triangules. The ararys length. Get a faces circumcenter. The faces index The circumcenter. A circle that passes through all three of the triangules vertices. True if the face was found. Get the circumcenter. The circumcenters index. The circumcenter If circumcenter with the index not found. Get a array of all the circumcenters. A array of circumcenters. The ararys length. Get the index of the faces neighbour. The faces index. The neighbour (0-2) index in the face. The index of the neighbour face in the triangulation. -1 if there is no neighbour face at this index. Locate the face the point hits. The point. The face the point has hit. True if the point hit a face. Locate the closest vertex to point. The point The distance the point must be within to count as hitting the vertex. The closest vertex. True if point hit a face and found a vertex. Locate the closest edge and segment to point. The point The distance the point must be within to count as hitting the edge. The closest edge. True if the point hit a face and found a edge. Remove the vertex. The vertices index. True if removed. Flip a edge between the face and a neighbour. The faces index The neighbour (0-2) index in the face. True if the edge was flipped. Translate the triangulation. The amount to translate. Rotate the triangulation. The amount to rotate in radians. Scale the triangulation. The amount to scale. Transform the triangulation with a TRS matrix. The amount to translate. The amount to rotate. The amount to scale. Release any unmanaged resources. Base triangulation class for Triangulation, DelaunayTriangulation and ConstrainedTriangulation. The triangulations kernel. Returns the buildStamp. The build stamp will change if the triangulation model has changed Returns the dimension of the affine hull. Returns the number of vertices. Returns the number of finite vertices. Returns the number of cells or 0 if Dimension less than 3. The number of finite cells. Returns 0 if Dimension less than 3. The number of edges. Returns 0 if Dimension less than 1. The number of finite edges. Returns 0 if Dimension less than 1. The number of facets. Returns 0 if Dimension less than 2. The number of facets. Returns 0 if Dimension less than 2. The number of indices needed for the finite tetrahedrons. Clear the triangulation. Inserts the point p in the triangulation. If point p coincides with an already existing vertex the triangulation remains unchanged. If point p lies in the convex hull of the points, it is added naturally: if it lies inside a cell, the cell is split into four cells, if it lies on a facet, the two incident cells are split into three cells, if it lies on an edge, all the cells incident to this edge are split into two cells. If point p is strictly outside the convex hull but in the affine hull, p is linked to all visible points on the convex hull to form the new triangulation. If point p is outside the affine hull of the points, p is linked to all the points, and the dimension of the triangulation is incremented. All the points now belong to the boundary of the convex hull, so, the infinite vertex is linked to all the points to triangulate the new infinite face. The point to insert Insert all the points in the array. The points to insert. The arrays length Insert a vertex into a cell. The cells index. The point to insert. If the point query lies inside the convex hull of the points, the cell that contains the query in its interior is returned. If query lies on a facet, an edge or on a vertex, one of the cells having query on its boundary is returned. If the point query lies outside the convex hull of the points, an infinite cell with vertices { p,q,r,∞} is returned such that the tetrahedron(p, q, r, query) is positively oriented(the rest of the triangulation lies on the other side of facet (p, q, r)). Note that locate works even in degenerate dimensions: in dimension 2 (resp. 1, 0) the Cell_handle returned is the one that represents the facet(resp.edge, vertex) containing the query point. The optional argument start is used as a starting place for the search. The optional argument could_lock_zone is used by the concurrency-safe version of the triangulation.When the pointer is not null, the locate will try to lock all the cells along the walk. If it succeeds, could_lock_zone is true, otherwise it is false. In any case, the locked cells are not unlocked by locate, leaving this choice to the user. The point to query The cell thats closest to point. The closest cell to point. Get the centroids of each cell. The array of points The array of points length Get all the points in the triangulation. The array to copy into. The arrays length. Get all the points in the triangulation. The array to copy into. Get the triangulation vertices. The vertex array. The vertex array length. Get a triangulation vertex. The vertices index The vertex. Get the triangulation vertices. The vertex array. The vertex array length. Get a triangulation vertex. The vertices index The vertex. Get the indices of the cells edges in the triangulation. The indices array. The indices array length. Get the indices of the cells triangles in the triangulation. The indices array. The indices array length. Get the indices of the tetrahedron cells in the triangulation. The indices array. The indices array length. Translate each point in the mesh. The amount to translate. Rotate each point in the mesh. The amount to rotate. Scale each point in the mesh. The amount to scale. Transform each point in the mesh. The amount to translate. The amount to rotate. The amount to scale. Release any unmanaged resources. The generic constrained triangulation class. The kernel A static instance of the triangulation. The triangulation as a string. A deep copy of the triangulation. The deep copy. Compute the convex of the triagulation. The convex hull polygon. The abstract triangulation class. The kernel with the functions unique to the constrained triangulation. The number of constrainted edges in the triangulation. Move the vertex. The moved vertex True if the vertex was found. Insert the polygons points into the triangulation. May not retain the poylgons edges. Insert the polygons points into the triangulation. May not retain the poylgons edges. Insert the polygons points and the edges as constraints into the triangulation. Will retatin the poylgons edges. The polygon to insert. Insert the polygons points and the edges as constraints into the triangulation. Will retatin the poylgons edges. The polygon to insert. Get the number of constrainted edges incident to this vertex. The vertex index in the triagulation. The number of constrainted edges to the vertex. Does this vertex have a constrainted edge. The vertex index in the triagulation. Does this vertex have a constrainted edge. Add a segment as a constraint. The segment to add. Add the two points as a segment constraint. The segments point a. The segments point b. Add a list of segments as constraint to the triangulation. The segment array. The length of the segment array. Get a array of all the constraint edges in the triangulation. The edge array. The ararys length. Get a array of all the constraint segments in the triangulation. The segment array. The ararys length. Get the constraints incident to the vertex. The vertex index in the triangulation. The array of edges. The ararys length. Remove a constraint between a face and its neighbour. The faces index in the triangultion. The neighbours index in the faces neighbour array between 0-2. Remove all constraints incident to a vertex. The vertex index in the triangulation. Get the triangle indices for domain in the triangultion. Used to triangulate polygons. The indices. The generic constrained triangulation class. The kernel A static instance of the triangulation. The triangulation as a string. A deep copy of the triangulation. The deep copy. Compute the convex of the triagulation. The convex hull polygon. The abstract triangulation class. The kernel with the functions unique to the constrained triangulation. The number of constrainted edges in the triangulation. Move the vertex. The moved vertex True if the vertex was found. Insert the polygons points into the triangulation. May not retain the poylgons edges. Insert the polygons points into the triangulation. May not retain the poylgons edges. Insert the polygons points and the edges as constraints into the triangulation. Will retatin the poylgons edges. The polygon to insert. Insert the polygons points and the edges as constraints into the triangulation. Will retatin the poylgons edges. The polygon to insert. Get the number of constrainted edges incident to this vertex. The vertex index in the triagulation. The number of constrainted edges to the vertex. Does this vertex have a constrainted edge. The vertex index in the triagulation. Does this vertex have a constrainted edge. Add a segment as a constraint. The segment to add. Add the two points as a segment constraint. The segments point a. The segments point b. Add a list of segments as constraint to the triangulation. The segment array. The length of the segment array. Get a array of all the constraint edges in the triangulation. The edge array. The ararys length. Get a array of all the constraint segments in the triangulation. The segment array. The ararys length. Get the constraints incident to the vertex. The vertex index in the triangulation. The array of edges. The ararys length. Remove a constraint between a face and its neighbour. The faces index in the triangultion. The neighbours index in the faces neighbour array between 0-2. Remove all constraints incident to a vertex. The vertex index in the triangulation. Get the triangle indices for domain in the triangultion. Used to triangulate polygons. The indices. The generic delaunay triangulation class. The kerne A static instance of the delaunay triangulation. The triangulation as string. A deep copy of the triangulation. Insert the polygons points into the triangulation. May not retatin the poylgons edges. The polygon to insert. Insert the polygons points into the triangulation. May not retatin the poylgons edges. The polygon to insert. Compute the convex of the triagulation. The convex hull polygon. The anstract base class for the delaunay triangulation. The kernel with the functions unique to the delaunay triangulation. Move the vertex. If there is not already another vertex placed on the point, the triangulation is modified such that the new position of vertex same as point. The moved vertex True if the vertex was found. If the dual voronoi diagram of the triangulation is taken How many segments and rays would be produced. The number of segments. The number of rays. Get a array of the voronoi's segments. A array of the voronoi's segments. Get a array of the voronois rays. These are the segment at edge of triangulation that a end point can not be determined. A array of the voronoi's rays. Generic triangulation class. The kerel. Static instance of a triangulation. Default constructor. Construct a triangulation from the points. The triangulation points. Construct from a existing triangulation. A pointer to the unmanaged object. The triangulation as a string. Create a deep copy of the triangulation. The deep copy. Refine the triangulation. The target edge lengths. The number of iterations. Compute the convex of the triagulation. The convex hull polygon. Abstract base class for the triagulation. The kernel with the functions unique to the triangulation. Move a vertex. The vertices index. The point to move to. Should the vertex only be moved if there is no coliision. If the vertex was moved. Find the index of the nearest vertex to the point. The point. The index of the nearest vertex to the point. Find the index of the nearest vertex to the point. Presumes poimt is in a cell. The cells index. The point. The index of the nearest vertex to the point. Remobe a vertex. The vertex index. True if vertex was removed. Generic triangulation class. The kerel. Static instance of a triangulation. Default constructor. Construct a triangulation from the points. The triangulation points. Construct from a existing triangulation. A pointer to the unmanaged object. The triangulation as a string. Create a deep copy of the triangulation. The deep copy. Insert the points of the polygon into the triagulation. May no have the same edges as polygon. The polygon to insert/ Insert the points of the polygon into the triagulation. May no have the same edges as polygon. The polygon to insert/ Compute the convex of the triagulation. The convex hull polygon. Abstract base class for the triagulation. The kernel with the functions unique to the triangulation. Move the vertex. If there is not already another vertex placed on the point, the triangulation is modified such that the new position of vertex same as point. The moved vertex True if the vertex was found. Generic triangulation class. The kerel. Static instance of a triangulation. Default constructor. Construct a triangulation from the points. The triangulation points. Construct from a existing triangulation. A pointer to the unmanaged object. The triangulation as a string. Create a deep copy of the triangulation. The deep copy. Refine the triangulation. The target edge lengths. The number of iterations. Compute the convex of the triagulation. The convex hull polygon. Abstract base class for the triagulation. The kernel with the functions unique to the triangulation. From Index to HalfEdgeIndex must match layout of the unmanaged TriFace2 in the TriFace2 header file. Is this the infinite cell. The cells index in the triangulation. The cells 4 vertices. The cells 4 neighbor cells. Are the two cells equal. The first cell. The second cell. True if the cells are equal. Are the two cells not equal. The first cell. The second cell. True if the cells are not equal. Are these objects equal. The other object. True if the objects are equal. Are these cells equal. The other cell. True if the cells are equal. The cells hash code. The cells hash code. Get a vertex index. The vertices index 0-3. The vertices index in the triangulation. Get a neighbor cell index. The neighbor cell index 0-3. A neighbor cell index in the triangulation. Enumerate the vertices of the cell. The triangle the vertices below too. The cell vertices. Enumerate the vertices of the cell. The vertices array. The cell vertices. Enumerate the vertices of the cell. The triangle the vertices below too. The cell vertices. Enumerate the neighbors of the cell. The cell array. The cell neighbors. Are the two vertex arrays equal. Are the two neighbor arrays equal. From Index to TwinIndex must match layout of the unmanaged TriEdge2 in the TriEdge2 header file. The edges face index in the triangulation. The neighbours index in the face array betwen 0 and 2. The edges segment. The face index in the triangulation The neighbours index in the face array betwen 0 and 2. Are the two edges equal. The first edge. The second edge. True if the edges are equal. Are the two edges not equal. The first edge. The second edge. True if the edges are not equal. Are these objects equal. The other object. True if the objects are equal. Are these edges equal. The other edge. True if the edges are equal. The edges hash code. The edges hash code. From Index to HalfEdgeIndex must match layout of the unmanaged TriFace2 in the TriFace2 header file. Is this the infinite face. The faces index in the triangulation. The faces 3 vertices. Are the two faces equal. The first face. The second face. True if the faces are equal. Are the two faces not equal. The first face. The second face. True if the faces are not equal. Are these objects equal. The other object. True if the objects are equal. Are these faces equal. The other face. True if the faces are equal. The faces hash code. The faces hash code. Get a vertex index and wrap around array. The vertices index wrapped to 0-2. The vertices index in the triangulation. Enumerate the vertices of the face. The triangle the vertices below too. The face vertices. Enumerate the vertices of the face. The vertices array. The face vertices. From Point to HalfEdgeIndex must match layout of the unmanaged TriVertex2 in the TriVertex2 header file. The vertices point. Is this a infinite vertex. The number of egdes connected to the vertex. The vertices index in the triangulation. The one of the vertexs the vertex is connected to. Are the two vertexs equal. The first vertex. The second vertex. True if the vertexs are equal. Are the two vertexs not equal. The first vertex. The second vertex. True if the vertexs are not equal. Are these objects equal. The other object. True if the objects are equal. Are these vertexs equal. The other vertex. True if the vertexs are equal. The vertexs hash code. The vertexs hash code. The vertices point. Is this a infinte vertex. The vertices degree is the number of edges connecting to it. The vertices index in the triangulation. The one of the cells the vertex is connected to. Are the two vertices equal. The first vertex. The second vertex. True if the vertexs are equal. Are the two vertices not equal. The first vertex. The second vertex. True if the vertexs are not equal. Are these objects equal. The other object. True if the objects are equal. Are these vertexs equal. The other vertex. True if the vertexs are equal. The vertexs hash code. The vertexs hash code. Enumerate around all the other vertices in this vertexs cell. The triangulation the vertex belongs to. All the other vertices in this vertexs cell Enumerate around all the other vertices in this vertexs cell. A array of the other vertices in the triangulation. A array of the other cells in the triangulation. All the other vertices in this vertexs cell Cache to reuse arrays. Thread safe? Returns a array of Point2d objects that is at least the size of count. The minimum size of the array. Should the array be cleared first. Returns a array of Point2d objects that is at least the size of count. Returns a array of Segment2d objects that is at least the size of count. The minimum size of the array. Should the array be cleared first. Returns a array of Segment2d objects that is at least the size of count. Returns a array of Point3d objects that is at least the size of count. The minimum size of the array. Should the array be cleared first. Returns a array of Point3d objects that is at least the size of count. Returns a array of HPoint3d objects that is at least the size of count. The minimum size of the array. Should the array be cleared first. Returns a array of HPoint3d objects that is at least the size of count. Returns a array of ints that is at least the size of count. The minimum size of the array. Should the array be cleared first. Returns a array of ints that is at least the size of count. Returns a array of ints that is at least the size of count. The minimum size of the array. Should the array be cleared first. Returns a array of ints that is at least the size of count. Should a new array be created. The current array. The required new array size. Creates a new array if disabled, the current one is null or to small. Check a array that is passed to the c++ dll. If the array is invalid it will cause a hard crash. Array can be null if count is 0; ================================================ FILE: CGALDotNet/CGALGlobal.cs ================================================ using System; using System.Collections.Generic; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using CGALDotNetGeometry.Numerics; using CGALDotNetGeometry.Shapes; using CGALDotNet.Geometry; [assembly: InternalsVisibleTo("CGALDotNetConsole")] [assembly: InternalsVisibleTo("CGALDotNetTest")] namespace CGALDotNet { /// /// Global utility functions. /// public static class CGALGlobal { public const int NULL_INDEX = -1; private const string DLL_NAME = "CGALWrapper.dll"; private const CallingConvention CDECL = CallingConvention.Cdecl; /// /// Get the version of CGAL in use. /// public static string Version { get { int v = CGALGlobal_VersionNumber(); int MAJOR = v / 10000000 % 100; int MINOR = v / 100000 % 100; int PATCH = v / 10000 % 10; int BUILD = v % 10000; return string.Format("{0}.{1}.{2}.{3}", MAJOR, MINOR, PATCH, BUILD); } } /// /// Get the version of eigen being used. /// public static string EigenVersion { get { var v = CGALGlobal_EigenVersionNumber(); int WORLD = v.first; int MAJOR = v.second; int MINOR = v.third; return string.Format("{0}.{1}.{2}", WORLD, MAJOR, MINOR); } } /// /// Returns OBTUSE, RIGHT or ACUTE depending on the /// angle formed by the two vectors u and v. /// /// The first vector. /// The second vector. /// OBTUSE, RIGHT or ACUTE depending on the /// angle formed by the two vectors u and v. public static ANGLE Angle(Vector2d u, Vector2d v) { return CGALGlobal_EIK_Angle_Vector2(u, v); } /// /// Returns OBTUSE, RIGHT or ACUTE depending on the /// angle formed by the two vectors u and v. /// /// The first vector. /// The second vector. /// OBTUSE, RIGHT or ACUTE depending on the /// angle formed by the two vectors u and v. public static ANGLE Angle(Vector2 u, Vector2 v) { return CGALGlobal_EIK_Angle_Vector2(u.Ptr, v.Ptr); } /// /// Returns OBTUSE, RIGHT or ACUTE depending on the /// angle formed by the two vectors u and v. /// /// The first vector. /// The second vector. /// OBTUSE, RIGHT or ACUTE depending on the /// angle formed by the two vectors u and v. public static ANGLE Angle(Vector2 u, Vector2 v) { return CGALGlobal_EEK_Angle_Vector2(u.Ptr, v.Ptr); } /// /// returns OBTUSE, RIGHT or ACUTE depending on the /// angle formed by the two vectors u and v. /// /// The first vector. /// The second vector. /// OBTUSE, RIGHT or ACUTE depending on the /// angle formed by the two vectors u and v. public static ANGLE Angle(Vector3d u, Vector3d v) { return CGALGlobal_EIK_Angle_Vector3d(u, v); } /// /// Returns an approximation of the angle between u and v. /// /// The first vector. /// The second vector. /// The angle is given in degrees. public static Degree ApproxAngle(Vector2d u, Vector2d v) { return new Degree(CGALGlobal_EIK_ApproxAngle_Vector3d(u.xy0, v.xy0)); } /// /// Returns an approximation of the angle between p-q and r-q. /// /// The first tetrahedrons point. /// The second tetrahedrons point. /// The third tetrahedrons point. /// The angle is given in degrees. public static Degree ApproxAngle(Point2d p, Point2d q, Point2d r) { var u = Point2d.Direction(q, p).xy0; var v = Point2d.Direction(q, r).xy0; return new Degree(CGALGlobal_EIK_ApproxAngle_Vector3d(u, v)); } /// /// Returns an approximation of the angle between u and v. /// /// The first vector. /// The second vector. /// The angle is given in degrees. public static Degree ApproxAngle(Vector3d u, Vector3d v) { return new Degree(CGALGlobal_EIK_ApproxAngle_Vector3d(u, v)); } /// /// Returns an approximation of the angle between p-q and r-q. /// /// The first tetrahedrons point. /// The second tetrahedrons point. /// The third tetrahedrons point. /// The angle is given in degrees. public static Degree ApproxAngle(Point3d p, Point3d q, Point3d r) { var u = Point3d.Direction(q, p); var v = Point3d.Direction(q, r); return new Degree(CGALGlobal_EIK_ApproxAngle_Vector3d(u, v)); } /// /// Returns an approximation of the signed dihedral angle /// in the tetrahedron pqrs of edge pq. /// p,q,r and p,q,s are not collinear. /// /// The first tetrahedrons point. /// The second tetrahedrons point. /// The third tetrahedrons point. /// The fourth tetrahedrons point. /// The sign is negative if orientation(p,q,r,s) /// is CGAL::NEGATIVE and positive otherwise. /// The angle is given in degrees. public static Degree ApproxDihedralAngle(Point3d p, Point3d q, Point3d r, Point3d s) { return new Degree(CGALGlobal_EIK_ApproxDihedralAngle_Point3(p, q, r, s)); } /// /// Returns true, if the three points are collinear /// and q lies between p and r. /// Note that true is returned, if q==p or q==r. /// /// The first point. /// The second point. /// The third point. /// Returns true, if the three points are /// collinear and q lies between p and r. public static bool AreOrderedAlongLine(Point2d p, Point2d q, Point2d r) { return CGALGlobal_EIK_AreOrderedAlongLine_Point2d(p, q, r); } /// /// Returns true, if the three points are collinear /// and q lies between p and r. /// Note that true is returned, if q==p or q==r. /// /// The first point. /// The second point. /// The third point. /// Returns true, if the three points are /// collinear and q lies between p and r. public static bool AreOrderedAlongLine(Point2 p, Point2 q, Point2 r) { return CGALGlobal_EIK_AreOrderedAlongLine_Point2(p.Ptr, q.Ptr, r.Ptr); } /// /// Returns true, if the three points are collinear /// and q lies between p and r. /// Note that true is returned, if q==p or q==r. /// /// The first point. /// The second point. /// The third point. /// Returns true, if the three points are /// collinear and q lies between p and r. public static bool AreOrderedAlongLine(Point2 p, Point2 q, Point2 r) { return CGALGlobal_EEK_AreOrderedAlongLine_Point2(p.Ptr, q.Ptr, r.Ptr); } /// /// Returns true, if the three points are collinear /// and q lies between p and r. /// Note that true is returned, if q==p or q==r. /// /// The first point. /// The second point. /// The third point. /// Returns true, if the three points are /// collinear and q lies between p and r. public static bool AreOrderedAlongLine(Point3d p, Point3d q, Point3d r) { return CGALGlobal_EIK_AreOrderedAlongLine_Point3d(p, q, r); } /// /// returns true, if the three points are collinear /// and q lies strictly between p and r. /// Note that false is returned, if q==p or q==r. /// /// The first point. /// The second point. /// The third point. /// returns true, iff the three points are /// collinear and q lies strictly between p and r. public static bool AreStrictlyOrderedAlongLine(Point2d p, Point2d q, Point2d r) { return CGALGlobal_EIK_AreStrictlyOrderedAlongLine_Point2d(p, q, r); } /// /// returns true, if the three points are collinear /// and q lies strictly between p and r. /// Note that false is returned, if q==p or q==r. /// /// The first point. /// The second point. /// The third point. /// returns true, iff the three points are /// collinear and q lies strictly between p and r. public static bool AreStrictlyOrderedAlongLine(Point2 p, Point2 q, Point2 r) { return CGALGlobal_EIK_AreStrictlyOrderedAlongLine_Point2(p.Ptr, q.Ptr, r.Ptr); } /// /// returns true, if the three points are collinear /// and q lies strictly between p and r. /// Note that false is returned, if q==p or q==r. /// /// The first point. /// The second point. /// The third point. /// returns true, iff the three points are /// collinear and q lies strictly between p and r. public static bool AreStrictlyOrderedAlongLine(Point2 p, Point2 q, Point2 r) { return CGALGlobal_EEK_AreStrictlyOrderedAlongLine_Point2(p.Ptr, q.Ptr, r.Ptr); } /// /// returns true, if the three points are collinear /// and q lies strictly between p and r. /// Note that false is returned, if q==p or q==r. /// /// The first point. /// The second point. /// The third point. /// returns true, iff the three points are /// collinear and q lies strictly between p and r. public static bool AreStrictlyOrderedAlongLine(Point3d p, Point3d q, Point3d r) { return CGALGlobal_EIK_AreStrictlyOrderedAlongLine_Point3d(p, q, r); } /// /// Returns true, if p, q, and r are collinear /// /// The first point. /// The second point. /// The third point. /// returns true, if p, q, and r are collinear public static bool Collinear(Point2d p, Point2d q, Point2d r) { return CGALGlobal_EIK_Collinear_Point2d(p, q, r); } /// /// Returns true, if p, q, and r are collinear /// /// The first point. /// The second point. /// The third point. /// returns true, if p, q, and r are collinear public static bool Collinear(Point2 p, Point2 q, Point2 r) { return CGALGlobal_EIK_Collinear_Point2(p.Ptr, q.Ptr, r.Ptr); } /// /// Returns true, if p, q, and r are collinear /// /// The first point. /// The second point. /// The third point. /// returns true, if p, q, and r are collinear public static bool Collinear(Point2 p, Point2 q, Point2 r) { return CGALGlobal_EEK_Collinear_Point2(p.Ptr, q.Ptr, r.Ptr); } /// /// Returns true, if p, q, and r are collinear /// /// The first point. /// The second point. /// The third point. /// Returns true, iff p, q, and r are collinear public static bool Collinear(Point3d p, Point3d q, Point3d r) { return CGALGlobal_EIK_Collinear_Point3d(p, q, r); } /// /// Compute the barycenter of the points p1, p2 and p3 /// with corresponding weights w1, w2 and w3 as 1. /// /// The first point. /// The second point. /// The third point. /// Compute the barycenter of the points. public static Point2d Barycenter(Point2d p, Point2d q, Point2d r) { return CGALGlobal_EIK_Barycenter_Point2d(p, q, r); } /// /// Compute the barycenter of the points p1, p2 and p3 /// with corresponding weights w1, w2 and w3 as 1. /// /// The first point. /// The second point. /// The third point. /// Compute the barycenter of the points. public static Point2 Barycenter(Point2 p, Point2 q, Point2 r) { var ptr = CGALGlobal_EIK_Barycenter_Point2(p.Ptr, q.Ptr, r.Ptr); return new Point2(ptr); } /// /// Compute the barycenter of the points p1, p2 and p3 /// with corresponding weights w1, w2 and w3 as 1. /// /// The first point. /// The second point. /// The third point. /// Compute the barycenter of the points. public static Point2 Barycenter(Point2 p, Point2 q, Point2 r) { var ptr = CGALGlobal_EEK_Barycenter_Point2(p.Ptr, q.Ptr, r.Ptr); return new Point2(ptr); } /// /// Compute the barycenter of the points p1, p2 and p3 /// with corresponding weights w1, w2 and w3 as 1. /// /// The first point. /// The second point. /// The third point. /// Compute the barycenter of the points. public static Point3d Barycenter(Point3d p, Point3d q, Point3d r) { return CGALGlobal_EIK_Barycenter_Point3d(p, q, r); } /// /// Constructs the bisector line of the two points p and q. /// The bisector is oriented in such a way that p lies on its positive side. /// /// The first point. /// The second point. /// Constructs the bisector line of the two points p and q. public static Line2d Bisector(Point3d p, Point3d q) { return CGALGlobal_EIK_Bisector_Point3d(p, q); } /// /// Constructs the bisector of the two lines l1 and l2. /// /// In the general case, the bisector has the direction of /// the vector which is the sum of the normalized directions /// of the two lines, and which passes through the intersection /// of l1 and l2. If l1 and l2 are parallel, then the bisector /// is defined as the line which has the same direction as l1, /// and which is at the same distance from l1 and l2. /// If Kernel::FT is not a model of FieldWithSqrt an /// approximation of the square root will be used in this /// function, impacting the exactness of the result even /// with an (exact) multiprecision number type. /// /// The first line. /// The second line. /// Constructs the bisector of the two lines l1 and l2. public static Line2d Bisector(Line2d l1, Line2d l2) { return CGALGlobal_EIK_Bisector_Line2d(l1, l2); } /// /// Constructs the bisector of the two lines l1 and l2. /// /// In the general case, the bisector has the direction of /// the vector which is the sum of the normalized directions /// of the two lines, and which passes through the intersection /// of l1 and l2. If l1 and l2 are parallel, then the bisector /// is defined as the line which has the same direction as l1, /// and which is at the same distance from l1 and l2. /// If Kernel::FT is not a model of FieldWithSqrt an /// approximation of the square root will be used in this /// function, impacting the exactness of the result even /// with an (exact) multiprecision number type. /// /// The first line. /// The second line. /// Constructs the bisector of the two lines l1 and l2. public static Line2 Bisector(Line2 l1, Line2 l2) { var ptr = CGALGlobal_EIK_Bisector_Line2(l1.Ptr, l2.Ptr); return new Line2(ptr); } /// /// Constructs the bisector of the two lines l1 and l2. /// /// In the general case, the bisector has the direction of /// the vector which is the sum of the normalized directions /// of the two lines, and which passes through the intersection /// of l1 and l2. If l1 and l2 are parallel, then the bisector /// is defined as the line which has the same direction as l1, /// and which is at the same distance from l1 and l2. /// If Kernel::FT is not a model of FieldWithSqrt an /// approximation of the square root will be used in this /// function, impacting the exactness of the result even /// with an (exact) multiprecision number type. /// /// The first line. /// The second line. /// Constructs the bisector of the two lines l1 and l2. public static Line2 Bisector(Line2 l1, Line2 l2) { var ptr = CGALGlobal_EEK_Bisector_Line2(l1.Ptr, l2.Ptr); return new Line2(ptr); } /// /// Returns true, if p, q, r, and s are coplanar. /// /// The first point. /// The second point. /// The third point. /// The fourth point /// Returns true, if p, q, r, and s are coplanar. public static bool Coplanar(Point3d p, Point3d q, Point3d r, Point3d s) { return CGALGlobal_EIK_Coplanar_Point3d(p, q, r, s); } /// /// If p,q,r are collinear, then CGAL_COLLINEAR is returned. /// If not, then p,q,r define a plane p. The return value in this /// case is either CGAL_POSITIVE or CGAL_NEGATIVE, but we don't /// specify it explicitly. However, we guarantee that all calls to /// this predicate over 3 points in p will return a coherent /// orientation if considered a 2D orientation in p /// /// The first point. /// The second point. /// The third point. /// If p,q,r are collinear, then CGAL_COLLINEAR is returned. public static ORIENTATION CoplanarOrientation(Point3d p, Point3d q, Point3d r) { return CGALGlobal_EIK_CoplanarOrientation_3Point3d(p, q, r); } /// /// Let P be the plane defined by the points p, q, and r. /// Note that the order defines the orientation of P. The function computes /// the orientation of points p, q, and s in P: If p, q, s are collinear, /// CGAL_COLLINEAR is returned. If P and the plane defined by p, q, /// and s have the same orientation, CGAL_POSITIVE is returned; /// otherwise CGAL_NEGATIVE is returned. /// p, q, r, and s are coplanar and p, q, and r are not collinear. /// /// The first point. /// The second point. /// The third point. /// The fourth point /// public static ORIENTATION CoplanarOrientation(Point3d p, Point3d q, Point3d r, Point3d s) { return CGALGlobal_EIK_CoplanarOrientation_4Point3d(p, q, r, s); } /// /// Constructs the line which is at the same distance from the three points p, q and r. /// p, q and r are not collinear. /// /// /// /// /// Constructs the line which is at the same distance from the three points p, q and r. public static Line3d EquidistantLine(Point3d p, Point3d q, Point3d r) { return CGALGlobal_EIK_EquidistantLine_Line3d(p, q, r); } /// /// Returns true if p, q, and r form a left turn. /// /// The first point. /// The second point. /// The third point. /// Returns true if p, q, and r form a left turn. public static bool LeftTurn(Point2d p, Point2d q, Point2d r) { return CGALGlobal_EIK_LeftTurn_Point2d(p, q, r); } /// /// Returns true if p, q, and r form a left turn. /// /// The first point. /// The second point. /// The third point. /// Returns true if p, q, and r form a left turn. public static bool LeftTurn(Point2 p, Point2 q, Point2 r) { return CGALGlobal_EIK_LeftTurn_Point2(p.Ptr, q.Ptr, r.Ptr); } /// /// Returns true if p, q, and r form a left turn. /// /// The first point. /// The second point. /// The third point. /// Returns true if p, q, and r form a left turn. public static bool LeftTurn(Point2 p, Point2 q, Point2 r) { return CGALGlobal_EEK_LeftTurn_Point2(p.Ptr, q.Ptr, r.Ptr); } /// /// Returns true if p, q, and r form a right turn. /// /// The first point. /// The second point. /// The third point. /// Returns true if p, q, and r form a right turn. public static bool RightTurn(Point2d p, Point2d q, Point2d r) { return CGALGlobal_EIK_RightTurn_Point2d(p, q, r); } /// /// Returns true if p, q, and r form a right turn. /// /// The first point. /// The second point. /// The third point. /// Returns true if p, q, and r form a right turn. public static bool RightTurn(Point2 p, Point2 q, Point2 r) { return CGALGlobal_EIK_RightTurn_Point2(p.Ptr, q.Ptr, r.Ptr); } /// /// Returns true if p, q, and r form a right turn. /// /// The first point. /// The second point. /// The third point. /// Returns true if p, q, and r form a right turn. public static bool RightTurn(Point2 p, Point2 q, Point2 r) { return CGALGlobal_EIK_RightTurn_Point2(p.Ptr, q.Ptr, r.Ptr); } /// /// Returns LEFT_TURN, if r lies to the left of the oriented /// line l defined by p and q, returns RIGHT_TURN if r lies /// to the right of l, and returns COLLINEAR if r lies on l. /// /// The first point. /// The second point. /// The third point. /// public static ORIENTATION Orientation(Point2d p, Point2d q, Point2d r) { return CGALGlobal_EIK_Orientation_Point2d(p, q, r); } /// /// Returns LEFT_TURN, if r lies to the left of the oriented /// line l defined by p and q, returns RIGHT_TURN if r lies /// to the right of l, and returns COLLINEAR if r lies on l. /// /// The first point. /// The second point. /// The third point. /// public static ORIENTATION Orientation(Point2 p, Point2 q, Point2 r) { return CGALGlobal_EIK_Orientation_Point2(p.Ptr, q.Ptr, r.Ptr); } /// /// Returns LEFT_TURN, if r lies to the left of the oriented /// line l defined by p and q, returns RIGHT_TURN if r lies /// to the right of l, and returns COLLINEAR if r lies on l. /// /// The first point. /// The second point. /// The third point. /// public static ORIENTATION Orientation(Point2 p, Point2 q, Point2 r) { return CGALGlobal_EEK_Orientation_Point2(p.Ptr, q.Ptr, r.Ptr); } /// /// returns LEFT_TURN if u and v form a left turn, returns /// RIGHT_TURN if u and v form a right turn, and returns /// COLLINEAR if u and v are collinear. /// /// /// /// public static ORIENTATION Orientation(Vector2d u, Vector2d v) { return CGALGlobal_EIK_Orientation_Vector2d(u, v); } /// /// Returns LEFT_TURN, if r lies to the left of the oriented /// line l defined by p and q, returns RIGHT_TURN if r lies /// to the right of l, and returns COLLINEAR if r lies on l. /// /// The first point. /// The second point. /// public static ORIENTATION Orientation(Vector2 p, Vector2 q) { return CGALGlobal_EIK_Orientation_Vector2(p.Ptr, q.Ptr); } /// /// Returns LEFT_TURN, if r lies to the left of the oriented /// line l defined by p and q, returns RIGHT_TURN if r lies /// to the right of l, and returns COLLINEAR if r lies on l. /// /// The first point. /// The second point. /// public static ORIENTATION Orientation(Vector2 p, Vector2 q) { return CGALGlobal_EEK_Orientation_Vector2(p.Ptr, q.Ptr); } /// /// returns POSITIVE, if s lies on the positive side of the /// oriented plane h defined by p, q, and r, returns NEGATIVE /// if s lies on the negative side of h, and returns COPLANAR /// if s lies on h. /// /// The first point. /// The second point. /// The third point. /// The fourth point /// public static ORIENTATION Orientation(Point3d p, Point3d q, Point3d r, Point3d s) { return CGALGlobal_EIK_Orientation_Point3d(p, q, r, s); } /// /// returns NEGATIVE if u, v and w are negatively oriented, /// POSITIVE if u, v and w are positively oriented, /// and COPLANAR if u, v and w are coplanar. /// /// /// /// /// public static ORIENTATION Orientation(Vector3d u, Vector3d v, Vector3d w) { return CGALGlobal_EIK_Orientation_Vector3d(u, v, w); } /// /// computes an orthogonal vector of the plane defined by p, q /// and r, which is directed to the positive side of this plane. /// /// The first point. /// The second point. /// The third point. /// computes an orthogonal vector of the plane public static Vector3d OrthogonalVector(Point3d p, Point3d q, Point3d r) { return CGALGlobal_EIK_OrthogonalVector_Point3d(p, q, r); } /// /// returns true, if l1 and l2 are parallel or if one of those /// (or both) is degenerate. /// /// The first line. /// The seconed line. /// returns true, if l1 and l2 are parallel public static bool Parallel(Line2d l1, Line2d l2) { return CGALGlobal_EIK_Parallel_Line2d(l1, l2); } /// /// returns true, if l1 and l2 are parallel or if one of those /// (or both) is degenerate. /// /// The first line. /// The seconed line. /// returns true, if l1 and l2 are parallel public static bool Parallel(Line2 l1, Line2 l2) { return CGALGlobal_EIK_Parallel_Line2(l1.Ptr, l2.Ptr); } /// /// returns true, if l1 and l2 are parallel or if one of those /// (or both) is degenerate. /// /// The first line. /// The seconed line. /// returns true, if l1 and l2 are parallel public static bool Parallel(Line2 l1, Line2 l2) { return CGALGlobal_EEK_Parallel_Line2(l1.Ptr, l2.Ptr); } /// /// returns true, if r1 and r2 are parallel or if one of /// those (or both) is degenerate. /// /// The first ray. /// The second ray. /// returns true, if r1 and r2 are parallel public static bool Parallel(Ray2d r1, Ray2d r2) { return CGALGlobal_EIK_Parallel_Ray2d(r1, r2); } /// /// returns true, if r1 and r2 are parallel or if one of /// those (or both) is degenerate. /// /// The first ray. /// The second ray. /// returns true, if r1 and r2 are parallel public static bool Parallel(Ray2 r1, Ray2 r2) { return CGALGlobal_EIK_Parallel_Ray2(r1.Ptr, r2.Ptr); } /// /// returns true, if r1 and r2 are parallel or if one of /// those (or both) is degenerate. /// /// The first ray. /// The second ray. /// returns true, if r1 and r2 are parallel public static bool Parallel(Ray2 r1, Ray2 r2) { return CGALGlobal_EEK_Parallel_Ray2(r1.Ptr, r2.Ptr); } /// /// returns true, if s1 and s2 are parallel or if one of /// those (or both) is degenerate. /// /// The first segment. /// The secong segment. /// returns true, if s1 and s2 are parallel public static bool Parallel(Segment2d s1, Segment2d s2) { return CGALGlobal_EIK_Parallel_Segment2d(s1, s2); } /// /// returns true, if s1 and s2 are parallel or if one of /// those (or both) is degenerate. /// /// The first segment. /// The secong segment. /// returns true, if s1 and s2 are parallel public static bool Parallel(Segment2 s1, Segment2 s2) { return CGALGlobal_EIK_Parallel_Segment2(s1.Ptr, s2.Ptr); } /// /// returns true, if s1 and s2 are parallel or if one of /// those (or both) is degenerate. /// /// The first segment. /// The secong segment. /// returns true, if s1 and s2 are parallel public static bool Parallel(Segment2 s1, Segment2 s2) { return CGALGlobal_EEK_Parallel_Segment2(s1.Ptr, s2.Ptr); } //---------------------------------------------------------------------------// // Version // //---------------------------------------------------------------------------// [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int CGALGlobal_VersionNumber(); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern Index3 CGALGlobal_EigenVersionNumber(); //---------------------------------------------------------------------------// // Angle // //---------------------------------------------------------------------------// [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern ANGLE CGALGlobal_EIK_Angle_Vector2(Vector2d u, Vector2d v); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern ANGLE CGALGlobal_EIK_Angle_Vector2(IntPtr u, IntPtr v); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern ANGLE CGALGlobal_EEK_Angle_Vector2(IntPtr u, IntPtr v); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern ANGLE CGALGlobal_EIK_Angle_Vector3d(Vector3d u, Vector3d v); //---------------------------------------------------------------------------// // ApproxAngle // //---------------------------------------------------------------------------// [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern double CGALGlobal_EIK_ApproxAngle_Vector3d(Vector3d u, Vector3d v); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern double CGALGlobal_EIK_ApproxAngle_Vector2(IntPtr u, IntPtr v); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern double CGALGlobal_EEK_ApproxAngle_Vector2(IntPtr u, IntPtr v); //---------------------------------------------------------------------------// // ApproxDihedralAngle // //---------------------------------------------------------------------------// [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern double CGALGlobal_EIK_ApproxDihedralAngle_Point3(Point3d p, Point3d q, Point3d r, Point3d s); //---------------------------------------------------------------------------// // AreOrderedAlongLine // //---------------------------------------------------------------------------// [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool CGALGlobal_EIK_AreOrderedAlongLine_Point2d(Point2d p, Point2d q, Point2d r); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool CGALGlobal_EIK_AreOrderedAlongLine_Point2(IntPtr p, IntPtr q, IntPtr r); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool CGALGlobal_EEK_AreOrderedAlongLine_Point2(IntPtr p, IntPtr q, IntPtr r); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool CGALGlobal_EIK_AreOrderedAlongLine_Point3d(Point3d p, Point3d q, Point3d r); //---------------------------------------------------------------------------// // AreStrictlyOrderedAlongLine // //---------------------------------------------------------------------------// [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool CGALGlobal_EIK_AreStrictlyOrderedAlongLine_Point2d(Point2d p, Point2d q, Point2d r); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool CGALGlobal_EIK_AreStrictlyOrderedAlongLine_Point2(IntPtr p, IntPtr q, IntPtr r); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool CGALGlobal_EEK_AreStrictlyOrderedAlongLine_Point2(IntPtr p, IntPtr q, IntPtr r); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool CGALGlobal_EIK_AreStrictlyOrderedAlongLine_Point3d(Point3d p, Point3d q, Point3d r); //---------------------------------------------------------------------------// // Collinear // //---------------------------------------------------------------------------// [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool CGALGlobal_EIK_Collinear_Point2d(Point2d p, Point2d q, Point2d r); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool CGALGlobal_EIK_Collinear_Point2(IntPtr p, IntPtr q, IntPtr r); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool CGALGlobal_EEK_Collinear_Point2(IntPtr p, IntPtr q, IntPtr r); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool CGALGlobal_EIK_Collinear_Point3d(Point3d p, Point3d q, Point3d r); //---------------------------------------------------------------------------// // Barycenter // //---------------------------------------------------------------------------// [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern Point2d CGALGlobal_EIK_Barycenter_Point2d(Point2d p, Point2d q, Point2d r); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr CGALGlobal_EIK_Barycenter_Point2(IntPtr p, IntPtr q, IntPtr r); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr CGALGlobal_EEK_Barycenter_Point2(IntPtr p, IntPtr q, IntPtr r); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern Point3d CGALGlobal_EIK_Barycenter_Point3d(Point3d p, Point3d q, Point3d r); //---------------------------------------------------------------------------// // Bisector // //---------------------------------------------------------------------------// [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern Line2d CGALGlobal_EIK_Bisector_Point3d(Point3d p, Point3d q); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern Line2d CGALGlobal_EIK_Bisector_Line2d(Line2d p, Line2d q); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr CGALGlobal_EIK_Bisector_Line2(IntPtr p, IntPtr q); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr CGALGlobal_EEK_Bisector_Line2(IntPtr p, IntPtr q); //---------------------------------------------------------------------------// // Coplanar // //---------------------------------------------------------------------------// [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool CGALGlobal_EIK_Coplanar_Point3d(Point3d p, Point3d q, Point3d r, Point3d s); //---------------------------------------------------------------------------// // CoplanarOrientation // //---------------------------------------------------------------------------// [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern ORIENTATION CGALGlobal_EIK_CoplanarOrientation_3Point3d(Point3d p, Point3d q, Point3d r); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern ORIENTATION CGALGlobal_EIK_CoplanarOrientation_4Point3d(Point3d p, Point3d q, Point3d r, Point3d s); //---------------------------------------------------------------------------// // EquidistantLine // //---------------------------------------------------------------------------// [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern Line3d CGALGlobal_EIK_EquidistantLine_Line3d(Point3d p, Point3d q, Point3d r); //---------------------------------------------------------------------------// // LeftTurn // //---------------------------------------------------------------------------// [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool CGALGlobal_EIK_LeftTurn_Point2d(Point2d p, Point2d q, Point2d r); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool CGALGlobal_EIK_LeftTurn_Point2(IntPtr p, IntPtr q, IntPtr r); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool CGALGlobal_EEK_LeftTurn_Point2(IntPtr p, IntPtr q, IntPtr r); //---------------------------------------------------------------------------// // RightTurn // //---------------------------------------------------------------------------// [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool CGALGlobal_EIK_RightTurn_Point2d(Point2d p, Point2d q, Point2d r); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool CGALGlobal_EIK_RightTurn_Point2(IntPtr p, IntPtr q, IntPtr r); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool CGALGlobal_EEK_RightTurn_Point2(IntPtr p, IntPtr q, IntPtr r); //---------------------------------------------------------------------------// // Orientation // //---------------------------------------------------------------------------// [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern ORIENTATION CGALGlobal_EIK_Orientation_Point2d(Point2d p, Point2d q, Point2d r); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern ORIENTATION CGALGlobal_EIK_Orientation_Point2(IntPtr p, IntPtr q, IntPtr r); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern ORIENTATION CGALGlobal_EEK_Orientation_Point2(IntPtr p, IntPtr q, IntPtr r); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern ORIENTATION CGALGlobal_EIK_Orientation_Vector2d(Vector2d u, Vector2d v); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern ORIENTATION CGALGlobal_EIK_Orientation_Vector2(IntPtr p, IntPtr q); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern ORIENTATION CGALGlobal_EEK_Orientation_Vector2(IntPtr p, IntPtr q); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern ORIENTATION CGALGlobal_EIK_Orientation_Point3d(Point3d p, Point3d q, Point3d r, Point3d s); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern ORIENTATION CGALGlobal_EIK_Orientation_Vector3d(Vector3d u, Vector3d v, Vector3d w); //---------------------------------------------------------------------------// // OrthogonalVector // //---------------------------------------------------------------------------// [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern Vector3d CGALGlobal_EIK_OrthogonalVector_Point3d(Point3d p, Point3d q, Point3d r); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr CGALGlobal_EIK_OrthogonalVector_Point3(IntPtr p, IntPtr q, IntPtr r); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr CGALGlobal_EEK_OrthogonalVector_Point3(IntPtr p, IntPtr q, IntPtr r); //---------------------------------------------------------------------------// // Parallel // //---------------------------------------------------------------------------// [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool CGALGlobal_EIK_Parallel_Line2d(Line2d l1, Line2d l2); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool CGALGlobal_EIK_Parallel_Line2(IntPtr l1, IntPtr l2); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool CGALGlobal_EEK_Parallel_Line2(IntPtr l1, IntPtr l2); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool CGALGlobal_EIK_Parallel_Ray2d(Ray2d r1, Ray2d r2); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool CGALGlobal_EIK_Parallel_Ray2(IntPtr l1, IntPtr l2); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool CGALGlobal_EEK_Parallel_Ray2(IntPtr l1, IntPtr l2); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool CGALGlobal_EIK_Parallel_Segment2d(Segment2d s1, Segment2d s2); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool CGALGlobal_EIK_Parallel_Segment2(IntPtr l1, IntPtr l2); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool CGALGlobal_EEK_Parallel_Segment2(IntPtr l1, IntPtr l2); } } ================================================ FILE: CGALDotNet/CGALKernel.cs ================================================ using System; using System.Collections.Generic; using System.Text; using CGALDotNet.Geometry; using CGALDotNet.Polylines; using CGALDotNet.Polygons; using CGALDotNet.Arrangements; using CGALDotNet.Triangulations; using CGALDotNet.Hulls; using CGALDotNet.Polyhedra; using CGALDotNet.Meshing; using CGALDotNet.Processing; namespace CGALDotNet { public abstract class CGALKernel { internal abstract GeometryKernel2 GeometryKernel2 { get; } internal abstract PolylineKernel2 PolylineKernel2 { get; } internal abstract PolylineKernel3 PolylineKernel3 { get; } internal abstract PolygonKernel2 PolygonKernel2 { get; } internal abstract PolygonWithHolesKernel2 PolygonWithHolesKernel2 { get; } internal abstract PolygonBooleanKernel2 PolygonBooleanKernel2 { get; } internal abstract PolygonPartitionKernel2 PolygonPartitionKernel2 { get; } internal abstract PolygonSimplificationKernel2 PolygonSimplificationKernel2 { get; } internal abstract PolygonOffsetKernel2 PolygonOffsetKernel2 { get; } internal abstract PolygonMinkowskiKernel PolygonMinkowskiKernel { get; } internal abstract PolygonVisibilityKernel PolygonVisibilityKernel { get; } internal abstract ArrangementKernel2 ArrangementKernel2 { get; } internal abstract SweepLineKernel SweepLineKernel { get; } internal abstract TriangulationKernel2 TriangulationKernel2 { get; } internal abstract TriangulationKernel3 TriangulationKernel3 { get; } internal abstract DelaunayTriangulationKernel2 DelaunayTriangulationKernel2 { get; } internal abstract DelaunayTriangulationKernel3 DelaunayTriangulationKernel3 { get; } internal abstract ConstrainedTriangulationKernel2 ConstrainedTriangulationKernel2 { get; } internal abstract ConstrainedDelaunayTriangulationKernel2 ConstrainedDelaunayTriangulationKernel2 { get; } internal abstract ConformingTriangulationKernel2 ConformingTriangulationKernel2 { get; } internal abstract ConvexHullKernel2 ConvexHullKernel2 { get; } internal abstract ConvexHullKernel3 ConvexHullKernel3 { get; } internal abstract PolyhedronKernel3 PolyhedronKernel3 { get; } internal abstract NefPolyhedronKernel3 NefPolyhedronKernel3 { get; } internal abstract SurfaceMeshKernel3 SurfaceMeshKernel3 { get; } internal abstract TetrahedralRemeshingKernel TetrahedralRemeshingKernel { get; } internal abstract SurfaceSubdivisionKernel SurfaceSubdivisionKernel { get; } internal abstract SurfaceSimplificationKernel SurfaceSimplificationKernel { get; } internal abstract SkinSurfaceMeshingKernel SkinSurfaceMeshingKernel { get; } internal abstract MeshProcessingMeshingKernel MeshProcessingMeshingKernel { get; } internal abstract MeshProcessingRepairKernel MeshProcessingRepairKernel { get; } internal abstract MeshProcessingOrientationKernel MeshProcessingOrientationKernel { get; } internal abstract MeshProcessingBooleanKernel MeshProcessingBooleanKernel { get; } internal abstract MeshProcessingConnectionsKernel MeshProcessingConnectionsKernel { get; } internal abstract MeshProcessingSlicerKernel MeshProcessingSlicerKernel { get; } internal abstract MeshProcessingFeaturesKernel MeshProcessingFeaturesKernel { get; } internal abstract MeshProcessingLocateKernel MeshProcessingLocateKernel { get; } internal abstract HeatMethodKernel HeatMethodKernel { get; } } public class EIK : CGALKernel { public static readonly EIK Instance = new EIK(); internal override GeometryKernel2 GeometryKernel2 => GeometryKernel2_EIK.Instance; internal override PolylineKernel2 PolylineKernel2 => PolylineKernel2_EIK.Instance; internal override PolylineKernel3 PolylineKernel3 => PolylineKernel3_EIK.Instance; internal override PolygonKernel2 PolygonKernel2 => PolygonKernel2_EIK.Instance; internal override PolygonWithHolesKernel2 PolygonWithHolesKernel2 => PolygonWithHolesKernel2_EIK.Instance; internal override PolygonBooleanKernel2 PolygonBooleanKernel2 => PolygonBooleanKernel2_EIK.Instance; internal override PolygonPartitionKernel2 PolygonPartitionKernel2 => PolygonPartitionKernel2_EIK.Instance; internal override PolygonSimplificationKernel2 PolygonSimplificationKernel2 => PolygonSimplificationKernel2_EIK.Instance; internal override PolygonOffsetKernel2 PolygonOffsetKernel2 => PolygonOffsetKernel2_EIK.Instance; internal override PolygonMinkowskiKernel PolygonMinkowskiKernel => PolygonMinkowskiKernel_EIK.Instance; internal override PolygonVisibilityKernel PolygonVisibilityKernel => PolygonVisibilityKernel_EIK.Instance; internal override ArrangementKernel2 ArrangementKernel2 => throw new NotImplementedException(); internal override SweepLineKernel SweepLineKernel => SweepLineKernel_EIK.Instance; internal override TriangulationKernel2 TriangulationKernel2 => TriangulationKernel2_EIK.Instance; internal override TriangulationKernel3 TriangulationKernel3 => throw new NotImplementedException(); internal override DelaunayTriangulationKernel2 DelaunayTriangulationKernel2 => DelaunayTriangulationKernel2_EIK.Instance; internal override DelaunayTriangulationKernel3 DelaunayTriangulationKernel3 => throw new NotImplementedException(); internal override ConstrainedTriangulationKernel2 ConstrainedTriangulationKernel2 => ConstrainedTriangulationKernel2_EIK.Instance; internal override ConstrainedDelaunayTriangulationKernel2 ConstrainedDelaunayTriangulationKernel2 => throw new NotImplementedException(); internal override ConformingTriangulationKernel2 ConformingTriangulationKernel2 => ConformingTriangulationKernel2_EIK.Instance; internal override ConvexHullKernel2 ConvexHullKernel2 => ConvexHullKernel2_EIK.Instance; internal override ConvexHullKernel3 ConvexHullKernel3 => ConvexHullKernel3_EIK.Instance; internal override PolyhedronKernel3 PolyhedronKernel3 => PolyhedronKernel3_EIK.Instance; internal override NefPolyhedronKernel3 NefPolyhedronKernel3 => NefPolyhedronKernel3_EIK.Instance; internal override SurfaceMeshKernel3 SurfaceMeshKernel3 => SurfaceMeshKernel3_EIK.Instance; internal override TetrahedralRemeshingKernel TetrahedralRemeshingKernel => throw new NotImplementedException(); internal override SurfaceSubdivisionKernel SurfaceSubdivisionKernel => SurfaceSubdivisionKernel_EIK.Instance; internal override SurfaceSimplificationKernel SurfaceSimplificationKernel => SurfaceSimplificationKernel_EIK.Instance; internal override SkinSurfaceMeshingKernel SkinSurfaceMeshingKernel => throw new NotImplementedException(); internal override MeshProcessingMeshingKernel MeshProcessingMeshingKernel => MeshProcessingMeshingKernel_EIK.Instance; internal override MeshProcessingRepairKernel MeshProcessingRepairKernel => MeshProcessingRepairKernel_EIK.Instance; internal override MeshProcessingOrientationKernel MeshProcessingOrientationKernel => MeshProcessingOrientationKernel_EIK.Instance; internal override MeshProcessingBooleanKernel MeshProcessingBooleanKernel => MeshProcessingBooleanKernel_EIK.Instance; internal override MeshProcessingConnectionsKernel MeshProcessingConnectionsKernel => MeshProcessingConnectionsKernel_EIK.Instance; internal override MeshProcessingSlicerKernel MeshProcessingSlicerKernel => MeshProcessingSlicerKernel_EIK.Instance; internal override MeshProcessingFeaturesKernel MeshProcessingFeaturesKernel => MeshProcessingFeaturesKernel_EIK.Instance; internal override MeshProcessingLocateKernel MeshProcessingLocateKernel => MeshProcessingLocateKernel_EIK.Instance; internal override HeatMethodKernel HeatMethodKernel => HeatMethodKernel_EIK.Instance; } public class EEK : CGALKernel { public static readonly EEK Instance = new EEK(); internal override GeometryKernel2 GeometryKernel2 => GeometryKernel2_EEK.Instance; internal override PolylineKernel2 PolylineKernel2 => PolylineKernel2_EEK.Instance; internal override PolylineKernel3 PolylineKernel3 => PolylineKernel3_EEK.Instance; internal override PolygonKernel2 PolygonKernel2 => PolygonKernel2_EEK.Instance; internal override PolygonWithHolesKernel2 PolygonWithHolesKernel2 => PolygonWithHolesKernel2_EEK.Instance; internal override PolygonBooleanKernel2 PolygonBooleanKernel2 => PolygonBooleanKernel2_EEK.Instance; internal override PolygonPartitionKernel2 PolygonPartitionKernel2 => PolygonPartitionKernel2_EEK.Instance; internal override PolygonSimplificationKernel2 PolygonSimplificationKernel2 => PolygonSimplificationKernel2_EEK.Instance; internal override PolygonOffsetKernel2 PolygonOffsetKernel2 => PolygonOffsetKernel2_EEK.Instance; internal override PolygonMinkowskiKernel PolygonMinkowskiKernel => PolygonMinkowskiKernel_EEK.Instance; internal override PolygonVisibilityKernel PolygonVisibilityKernel => PolygonVisibilityKernel_EEK.Instance; internal override ArrangementKernel2 ArrangementKernel2 => ArrangementKernel2_EEK.Instance; internal override SweepLineKernel SweepLineKernel => SweepLineKernel_EEK.Instance; internal override TriangulationKernel2 TriangulationKernel2 => TriangulationKernel2_EEK.Instance; internal override TriangulationKernel3 TriangulationKernel3 => TriangulationKernel3_EEK.Instance; internal override DelaunayTriangulationKernel2 DelaunayTriangulationKernel2 => DelaunayTriangulationKernel2_EEK.Instance; internal override DelaunayTriangulationKernel3 DelaunayTriangulationKernel3 => DelaunayTriangulationKernel3_EEK.Instance; internal override ConstrainedTriangulationKernel2 ConstrainedTriangulationKernel2 => ConstrainedTriangulationKernel2_EEK.Instance; internal override ConstrainedDelaunayTriangulationKernel2 ConstrainedDelaunayTriangulationKernel2 => ConstrainedDelaunayTriangulationKernel2_EEK.Instance; internal override ConformingTriangulationKernel2 ConformingTriangulationKernel2 => ConformingTriangulationKernel2_EEK.Instance; internal override ConvexHullKernel2 ConvexHullKernel2 => ConvexHullKernel2_EEK.Instance; internal override ConvexHullKernel3 ConvexHullKernel3 => ConvexHullKernel3_EEK.Instance; internal override PolyhedronKernel3 PolyhedronKernel3 => PolyhedronKernel3_EEK.Instance; internal override NefPolyhedronKernel3 NefPolyhedronKernel3 => NefPolyhedronKernel3_EEK.Instance; internal override SurfaceMeshKernel3 SurfaceMeshKernel3 => SurfaceMeshKernel3_EEK.Instance; internal override TetrahedralRemeshingKernel TetrahedralRemeshingKernel => TetrahedralRemeshingKernel_EEK.Instance; internal override SurfaceSubdivisionKernel SurfaceSubdivisionKernel => SurfaceSubdivisionKernel_EEK.Instance; internal override SurfaceSimplificationKernel SurfaceSimplificationKernel => throw new NotSupportedException(); internal override SkinSurfaceMeshingKernel SkinSurfaceMeshingKernel => SkinSurfaceMeshingKernel_EEK.Instance; internal override MeshProcessingMeshingKernel MeshProcessingMeshingKernel => MeshProcessingMeshingKernel_EEK.Instance; internal override MeshProcessingRepairKernel MeshProcessingRepairKernel => MeshProcessingRepairKernel_EEK.Instance; internal override MeshProcessingOrientationKernel MeshProcessingOrientationKernel => MeshProcessingOrientationKernel_EEK.Instance; internal override MeshProcessingBooleanKernel MeshProcessingBooleanKernel => MeshProcessingBooleanKernel_EEK.Instance; internal override MeshProcessingConnectionsKernel MeshProcessingConnectionsKernel => MeshProcessingConnectionsKernel_EEK.Instance; internal override MeshProcessingSlicerKernel MeshProcessingSlicerKernel => MeshProcessingSlicerKernel_EEK.Instance; internal override MeshProcessingFeaturesKernel MeshProcessingFeaturesKernel => MeshProcessingFeaturesKernel_EEK.Instance; internal override MeshProcessingLocateKernel MeshProcessingLocateKernel => MeshProcessingLocateKernel_EEK.Instance; internal override HeatMethodKernel HeatMethodKernel => HeatMethodKernel_EEK.Instance; } } ================================================ FILE: CGALDotNet/CGALObject.cs ================================================ using System; using System.Collections.Generic; using System.Text; using System.Runtime.InteropServices; namespace CGALDotNet { /// /// Base class for objects that referrence a CGAL object. /// public abstract class CGALObject : IDisposable { protected const string DLL_NAME = "CGALWrapper.dll"; protected const CallingConvention CDECL = CallingConvention.Cdecl; /// /// The pointer to the unmanged CGAL object. /// private IntPtr m_ptr; /// /// Default constructor. /// internal CGALObject() { m_ptr = IntPtr.Zero; } /// /// Constructor taking a referrence to a CGAL object. /// /// A pointer to a CGAL object. internal CGALObject(IntPtr ptr) { m_ptr = ptr; } /// /// The destuctor. /// ~CGALObject() { Release(); } /// /// Has the object been disposed. /// public bool IsDisposed { get; private set; } /// /// Get the ptr to the CGAL object. /// internal IntPtr Ptr { get { CheckPtr(); return m_ptr; } private protected set { m_ptr = value; } } /// /// Dispose the CGAL object. /// public void Dispose() { Release(); GC.SuppressFinalize(this); } /// /// Print some information about the object. /// /// Print some information about the object. public override string ToString() { return String.Format("[CGALObject: Ptr={0}, IsDiposed={1}]", Ptr.ToInt64(), IsDisposed); } /// /// Print the object into the console. /// public void Print() { var buider = new StringBuilder(); Print(buider); Console.WriteLine(buider.ToString()); } /// /// Print the object into a string builder. /// /// The builder to print into. public virtual void Print(StringBuilder builder) { builder.AppendLine(ToString()); } /// /// Release the CGAL object. /// private void Release() { if (!IsDisposed) { if(m_ptr != IntPtr.Zero) ReleasePtr(); m_ptr = IntPtr.Zero; IsDisposed = true; } } /// /// Swap the unmanaged pointer with another. /// The old ptr will be released first. /// /// The new ptr. The old ptr will be released first. internal void Swap(IntPtr ptr) { if(IsDisposed) throw new CGALUnmanagedResourcesReleasedExeception("Can not swap when object has beed disposed."); if (m_ptr != IntPtr.Zero) ReleasePtr(Ptr); Ptr = ptr; } /// /// Allow derived class to release the unmanaged memory. /// protected abstract void ReleasePtr(); /// /// Allow derived class to release the unmanaged memory. /// protected virtual void ReleasePtr(IntPtr ptr) { throw new CGALUnmanagedResourcesNotReleasedExeception("ReleasePtr not implemented."); } /// /// Check if the object is still valid. /// protected void CheckPtr() { if(IsDisposed) throw new CGALUnmanagedResourcesReleasedExeception("Unmanaged resources have been released."); if (m_ptr == IntPtr.Zero) throw new CGALUnmanagedResourcesReleasedExeception("Unmanaged resources have not been created."); } } } ================================================ FILE: CGALDotNet/CGALObjectKernel.cs ================================================ using System; using System.Collections.Generic; using System.Text; using System.Runtime.InteropServices; namespace CGALDotNet { internal abstract class CGALObjectKernel { protected const string DLL_NAME = "CGALWrapper.dll"; protected const CallingConvention CDECL = CallingConvention.Cdecl; internal abstract string Name { get; } } } ================================================ FILE: CGALDotNet/Collections/NativeList.cs ================================================ using System; using System.Collections.Generic; using System.Text; using System.Runtime.InteropServices; using System.Collections; namespace CGALDotNet.Collections { /// /// /// /// public sealed class NativeList : NativeList, IList, IEnumerable where T : CGALObject, new() { /// /// /// private List m_list; /// /// /// public NativeList() : base() { m_list = new List(); } /// /// /// /// public NativeList(int count) : base(count) { m_list = new List(count); } /// /// /// /// internal NativeList(IntPtr ptr) : base(ptr) { for(int i = 0; i < Count; i++) { var p = NativeList_Get(Ptr, i); var item = new T(); item.Swap(p); m_list.Add(item); } } /// /// /// public bool IsSync => Count == m_list.Count; /// /// /// /// public override string ToString() { return String.Format("[NativeList: Count={0}, Capacity={1}, IsSync={2}]", Count, Capacity, IsSync); } /// /// /// /// public IEnumerator GetEnumerator() { for (int i = 0; i < Count; i++) yield return m_list[i]; } IEnumerator IEnumerable.GetEnumerator() { return GetEnumerator(); } /// /// /// /// /// public T this[int i] { get => Get(i); set => Set(i, value); } /// /// /// public void Clear() { m_list.Clear(); NativeList_Clear(Ptr); } /// /// /// /// public void Add(T item) { m_list.Add(item); NativeList_Add(Ptr, item.Ptr); } /// /// /// /// public void AddRange(IEnumerable items) { foreach(var item in items) Add(item); } /// /// /// /// public NativeList Copy() { var ptr = NativeList_Copy(Ptr); return new NativeList(ptr); } /// /// /// /// /// public void CopyTo(T[] array, int startIndex) { for (int i = startIndex; i < Count; i++) array[i] = Get(i); } /// /// /// /// /// public bool Contains(T item) { return m_list.Contains(item); } /// /// /// /// /// public int IndexOf(T item) { return m_list.IndexOf(item); } /// /// /// /// /// public void Insert(int index, T item) { m_list.Insert(index, item); NativeList_Insert(Ptr, item.Ptr, index); } /// /// /// /// /// public bool Remove(T item) { var b1 = m_list.Remove(item); var b2 = NativeList_Remove(Ptr, item.Ptr); return b1 && b2; } /// /// /// /// public void RemoveAt(int index) { m_list.RemoveAt(index); NativeList_RemoveAt(Ptr, index); } /// /// /// public void Reverse() { m_list.Reverse(); NativeList_Reverse(Ptr); } /// /// /// public void TrimExcess() { m_list.TrimExcess(); NativeList_TrimExcess(Ptr); } /// /// /// /// /// private T Get(int index) { return m_list[index]; } /// /// /// /// /// private void Set(int index, T item) { m_list[index] = item; NativeList_Set(Ptr, index, item.Ptr); } } /// /// /// public abstract class NativeList : CGALObject { /// /// /// public NativeList() { Ptr = NativeList_Create(); } /// /// /// /// public NativeList(int count) { Ptr = NativeList_CreateWithCount(count); } /// /// /// /// internal NativeList(IntPtr ptr) { Ptr = ptr; } /// /// /// public int Capacity => NativeList_Capacity(Ptr); /// /// /// public int Count => NativeList_Count(Ptr); /// /// /// public bool IsReadOnly => false; /// /// /// protected override void ReleasePtr() { NativeList_Release(Ptr); } [DllImport(DLL_NAME, CallingConvention = CDECL)] protected static extern IntPtr NativeList_Create(); [DllImport(DLL_NAME, CallingConvention = CDECL)] protected static extern IntPtr NativeList_CreateWithCount(int count); [DllImport(DLL_NAME, CallingConvention = CDECL)] protected static extern void NativeList_Release(IntPtr listPtr); [DllImport(DLL_NAME, CallingConvention = CDECL)] protected static extern void NativeList_Add(IntPtr listPtr, IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] protected static extern void NativeList_AddRange(IntPtr listPtr, IntPtr[] ptr_array, int count); [DllImport(DLL_NAME, CallingConvention = CDECL)] protected static extern int NativeList_Capacity(IntPtr listPtr); [DllImport(DLL_NAME, CallingConvention = CDECL)] protected static extern void NativeList_Clear(IntPtr listPtr); [DllImport(DLL_NAME, CallingConvention = CDECL)] protected static extern int NativeList_Count(IntPtr listPtr); [DllImport(DLL_NAME, CallingConvention = CDECL)] protected static extern bool NativeList_Contains(IntPtr listPtr, IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] protected static extern IntPtr NativeList_Copy(IntPtr listPtr); [DllImport(DLL_NAME, CallingConvention = CDECL)] protected static extern IntPtr NativeList_Get(IntPtr listPtr, int index); [DllImport(DLL_NAME, CallingConvention = CDECL)] protected static extern void NativeList_Set(IntPtr listPtr, int index, IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] protected static extern int NativeList_IndexOf(IntPtr listPtr, IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] protected static extern void NativeList_Insert(IntPtr listPtr, IntPtr ptr, int index); [DllImport(DLL_NAME, CallingConvention = CDECL)] protected static extern bool NativeList_Remove(IntPtr listPtr, IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] protected static extern void NativeList_RemoveAt(IntPtr listPtr, int index); [DllImport(DLL_NAME, CallingConvention = CDECL)] protected static extern void NativeList_Reverse(IntPtr listPtr); [DllImport(DLL_NAME, CallingConvention = CDECL)] protected static extern void NativeList_TrimExcess(IntPtr listPtr); } } ================================================ FILE: CGALDotNet/Eigen/EigenColumnVector.cs ================================================ using System; using System.Collections.Generic; using System.Text; using System.Runtime.InteropServices; using CGALDotNetGeometry.Numerics; using CGALDotNetGeometry.Shapes; namespace CGALDotNet.Eigen { /// /// /// public class EigenColumnVector : EigenVector { /// /// /// /// public EigenColumnVector(int dimension) { Ptr = EigenColumnVector_CreateVector(dimension); } /// /// /// /// /// public EigenColumnVector(double x, double y) { Ptr = EigenColumnVector_CreateVector(2); this[0] = x; this[1] = y; } /// /// /// /// /// /// public EigenColumnVector(double x, double y, double z) { Ptr = EigenColumnVector_CreateVector(3); this[0] = x; this[1] = y; this[2] = z; } /// /// /// /// /// /// /// public EigenColumnVector(double x, double y, double z, double w) { Ptr = EigenColumnVector_CreateVector(4); this[0] = x; this[1] = y; this[2] = z; this[3] = w; } /// /// /// /// public EigenColumnVector(IList list) { Ptr = EigenColumnVector_CreateVector(list.Count); for (int i = 0; i < list.Count; i++) this[i] = list[i]; } /// /// /// /// internal EigenColumnVector(IntPtr ptr) : base(ptr) { } /// /// /// /// /// public override double this[int i] { get { return EigenColumnVector_Get(Ptr, i); } set { EigenColumnVector_Set(Ptr, i, value); } } /// /// /// public override int Dimension => EigenColumnVector_Dimension(Ptr); /// /// /// public override double Magnitude => EigenColumnVector_Norm(Ptr); /// /// /// /// public override string ToString() { return String.Format("[EigenColumnVector: Dimension={0}]", Dimension); } /// /// /// public EigenColumnVector Normalized => new EigenColumnVector(EigenColumnVector_Normalized(Ptr)); /// /// /// public EigenRowVector Transpose => new EigenRowVector(EigenColumnVector_Transpose(Ptr)); /// /// /// public EigenColumnVector Adjoint => new EigenColumnVector(EigenColumnVector_Adjoint(Ptr)); /// /// /// public EigenColumnVector Conjugate => new EigenColumnVector(EigenColumnVector_Conjugate(Ptr)); /// /// /// /// /// /// public static double Dot(EigenColumnVector v1, EigenColumnVector v2) { AreSameSize(v1, v2); return EigenColumnVector_Dot(v1.Ptr, v2.Ptr); } /// /// /// public override void Normalize() { EigenColumnVector_Normalize(Ptr); } /// /// /// /// public override void Resize(int dimension) { EigenColumnVector_Resize(Ptr, dimension); } /// /// /// /// /// /// /// /// public static EigenColumnVector Random(int dimension, double min, double max, int seed) { var ptr = EigenColumnVector_CreateVector(dimension); var v = new EigenColumnVector(ptr); var rnd = new Random(seed); double range = max - min; for (int i = 0; i < v.Dimension; i++) v[i] = min + rnd.NextDouble() * range; return v; } /// /// /// protected override void ReleasePtr() { EigenColumnVector_Release(Ptr); } [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr EigenColumnVector_CreateVector(int dimension); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void EigenColumnVector_Release(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int EigenColumnVector_Rows(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int EigenColumnVector_Dimension(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern double EigenColumnVector_Get(IntPtr ptr, int x); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void EigenColumnVector_Set(IntPtr ptr, int x, double value); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern double EigenColumnVector_Dot(IntPtr ptr1, IntPtr ptr2); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr EigenColumnVector_Normalized(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void EigenColumnVector_Normalize(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern double EigenColumnVector_Norm(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr EigenColumnVector_Transpose(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr EigenColumnVector_Adjoint(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr EigenColumnVector_Conjugate(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void EigenColumnVector_Resize(IntPtr ptr, int dimension); } } ================================================ FILE: CGALDotNet/Eigen/EigenMatrix.cs ================================================ using System; using System.Collections.Generic; using System.Text; using System.Runtime.InteropServices; using CGALDotNetGeometry.Numerics; using CGALDotNetGeometry.Shapes; namespace CGALDotNet.Eigen { /// /// enum for egien solvers. /// public enum EIGEN_SOLVER { COL_PIV_HOUSEHOLDER_QR, PARTIAL_PIV_LU, FULL_PIV_LU, HOUSEHOLDER_QR, LLT, LDLT, BDCSVD, JACOBI_SVD, FULL_PIV_HOUSEHOLDER_QR, COMPLETE_ORTH_DECOM } public enum EIGEN_SOLVER_OPTIONS { COMPUTE_FULL_U = 4, //Used to indicate that the square matrix U is to be computed. COMPUTE_THIN_U = 8, //Used to indicate that the thin matrix U is to be computed. COMPUTE_FULL_V = 16, //Used to indicate that the square matrix V is to be computed. COMPUTE_THIN_V = 32, //Used to indicate that the thin matrix V is to be computed. } public class EigenMatrix : CGALObject { /// /// Create a new matrix filled with zeros. /// /// The number of rows. /// The number of columns. public EigenMatrix(int rows, int columns) { if (rows <= 0) throw new ArgumentException("Row vectors count can not be <= zero."); if (columns <= 0) throw new ArgumentException("Column vectors count can not be <= zero."); Ptr = EigenMatrix_Create(rows, columns); } /// /// Create a new matrix fill with the array contents. /// /// The array. public EigenMatrix(double[,] array) { int rowsCount = array.GetLength(0); int columnsCount = array.GetLength(1); if (rowsCount == 0) throw new ArgumentException("Row vectors count can not be zero."); if (columnsCount == 0) throw new ArgumentException("Column vectors count can not be zero."); Ptr = EigenMatrix_Create(rowsCount, columnsCount); for (int i = 0; i < rowsCount; i++) { for (int j = 0; j < columnsCount; j++) { this[i, j] = array[i, j]; } } } /// /// Create a new matrix filled with the contents of the column vectors. /// All column vectors must have the same dimension. /// /// public EigenMatrix(IList columns) { if (columns.Count == 0) throw new ArgumentException("Column vectors count can not be zero."); int rowsCount = columns.Count; int columnsCount = columns[0].Dimension; Ptr = EigenMatrix_Create(rowsCount, columnsCount); for (int i = 0; i < rowsCount; i++) { if (columns[i].Dimension != columnsCount) throw new ArgumentException("Column vector is not the same size as fisrt column vector."); for (int j = 0; j < columnsCount; j++) { this[i, j] = columns[i][j]; } } } /// /// Create a 2 x 2 matrix. /// public EigenMatrix(double m00, double m01, double m10, double m11) { Ptr = EigenMatrix_Create(2, 2); this[0, 0] = m00; this[0, 1] = m01; this[1, 0] = m10; this[1, 1] = m11; } /// /// Create a 3 x 3 matrix. /// public EigenMatrix(double m00, double m01, double m02, double m10, double m11, double m12, double m20, double m21, double m22) { Ptr = EigenMatrix_Create(3, 3); this[0, 0] = m00; this[0, 1] = m01; this[0, 2] = m02; this[1, 0] = m10; this[1, 1] = m11; this[1, 2] = m12; this[2, 0] = m20; this[2, 1] = m21; this[2, 2] = m22; ; } /// /// Create a 4 x 4 matrix. /// public EigenMatrix( double m00, double m01, double m02, double m03, double m10, double m11, double m12, double m13, double m20, double m21, double m22, double m23, double m30, double m31, double m32, double m33) { Ptr = EigenMatrix_Create(4, 4); this[0,0] = m00; this[0,1] = m01; this[0,2] = m02; this[0,3] = m03; this[1,0] = m10; this[1,1] = m11; this[1,2] = m12; this[1,3] = m13; this[2,0] = m20; this[2,1] = m21; this[2,2] = m22; this[2,3] = m23; this[3,0] = m30; this[3,1] = m31; this[3,2] = m32; this[3,3] = m33; } /// /// Create a new matrix from a pointer. /// /// internal EigenMatrix(IntPtr ptr) : base(ptr) { } /// /// Create a identity matrix. /// /// The number of rows and columns of the matrix. Must be square. /// The identity matrix. public static EigenMatrix Identity(int size) { if (size <= 0) throw new ArgumentException("Size can not be <= zero."); var ptr = EigenMatrix_CreateIdentity(size, size); return new EigenMatrix(ptr); } /// /// Create a matrix filled with the numbers 1, 2. 3, etc to end. /// Used for debugging. /// /// The number of rows. /// The number columns. /// The Matrix. /// internal static EigenMatrix Series(int rows, int columns) { if (rows <= 0) throw new ArgumentException("Rows can not be <= zero."); if (columns <= 0) throw new ArgumentException("Colums can not be <= zero."); var m = new EigenMatrix(rows, columns); int i = 0; for (int x = 0; x < m.Rows; x++) { for (int y = 0; y < m.Columns; y++) { m[x, y] = i++; } } return m; } /// /// Create a new matrix fill with random numbers. /// /// The number of rows. /// The number columns. /// The minimum random number generated. /// The maximum random number generated. /// The random generators seed. /// The matrix. public static EigenMatrix Random(int rows, int columns, double min, double max, int seed) { var m = new EigenMatrix(rows, columns); var rnd = new Random(seed); double range = max - min; for (int i = 0; i < m.Length; i++) m[i] = min + rnd.NextDouble() * range; return m; } /// /// The number of rows in the matrix. /// public int Rows => EigenMatrix_Rows(Ptr); /// /// The number of columns in the matrix. /// public int Columns => EigenMatrix_Columns(Ptr); /// /// The total size of the matrix which is /// the rows times the number of columns. /// public int Length => Rows * Columns; /// /// The single dimension array accessor. /// /// The array index. /// The value at the index i. public double this[int i] { get { return EigenMatrix_GetX(Ptr, i); } set { EigenMatrix_SetX(Ptr, i, value); } } /// /// The double dimension array accessor. /// /// The row index. /// The column index. /// The value at the index i,j. public double this[int i, int j] { get { return EigenMatrix_GetXY(Ptr, i, j); } set { EigenMatrix_SetXY(Ptr, i, j, value); } } /// /// The matrix string info. /// /// The matrix string info. public override string ToString() { return String.Format("[EigenMatrix: Rows={0}, Columns={1}]", Rows, Columns); } /// /// The matrix transposed. /// Flips a matrix over its diagonal that is, /// it switches the row and column indices of the matrix. /// public EigenMatrix Transpose { get { var ptr = EigenMatrix_Transpose(Ptr); return new EigenMatrix(ptr); } } /// /// The matrices conjugate. /// The matrix obtained by replacing each element a(ij) with its complex conjugate, A^=(a^(ij)). /// public EigenMatrix Conjugate { get { var ptr = EigenMatrix_Conjugate(Ptr); return new EigenMatrix(ptr); } } /// /// The matrices adjoint. /// The transpose of its cofactor matrix. /// public EigenMatrix Adjoint { get { var ptr = EigenMatrix_Adjoint(Ptr); return new EigenMatrix(ptr); } } /// /// Is the matrix invertible. /// public bool IsInvertible { get { if(IsSquare) return false; return EigenMatrix_IsInvertible(Ptr); } } /// /// The inverse of a square matrix A, /// sometimes called a reciprocal matrix, /// is a matrix A^(-1) such that AA^(-1)=I. /// DOes not check if the matrix is invertible. /// public EigenMatrix Inverse { get { CheckIfSqaure(this); var ptr = EigenMatrix_Inverse(Ptr); return new EigenMatrix(ptr); } } /// /// The determinant is a scalar value that is a /// function of the entries of a square matrix. /// public double Determinant { get { CheckIfSqaure(this); return EigenMatrix_Determinant(Ptr); } } /// /// The trace of a square matrix is defined to be the /// sum of elements on the main diagonal from the upper left to the lower right. /// public double Trace { get { CheckIfSqaure(this); return EigenMatrix_Trace(Ptr); } } /// /// A square matrix has the same number of rows and columns. /// public bool IsSquare => Rows == Columns; /// /// A diagonal matrix is a matrix in which the entries /// outside the main diagonal are all zero. /// public bool IsDiagonal => EigenMatrix_IsDiagonal(Ptr); /// /// A square matrix is called upper triangular /// if all the entries below the main diagonal are zero. /// public bool IsUpperTriangular => EigenMatrix_IsUpperTriangular(Ptr); /// /// A square matrix is called lower triangular /// if all the entries above the main diagonal are zero. /// public bool IsLowerTriangular => EigenMatrix_IsLowerTriangular(Ptr); /// /// Multiple each component in matrix by the scalar. /// /// The matrix. /// The scalar. /// The matrix with each component multiplied by the scalar. public static EigenMatrix operator *(EigenMatrix m, double s) { return new EigenMatrix(EigenMatrix_MulScalar(m.Ptr, s)); } /// /// Divide each component in matrix by the scalar. /// /// The matrix. /// The scalar. /// The matrix with each component divided by the scalar. public static EigenMatrix operator /(EigenMatrix m, double s) { return new EigenMatrix(EigenMatrix_DivideScalar(m.Ptr, s)); } /// /// Multiple the two matrices. /// The first matrices number of columns must /// the same as the second matrices number of rows. /// /// The first matrix. /// The second matrix. /// The product matrix. public static EigenMatrix operator *(EigenMatrix m1, EigenMatrix m2) { IsValidProduct(m1, m2); return new EigenMatrix(EigenMatrix_MulMatrix(m1.Ptr, m2.Ptr)); } /// /// Add two matrices. /// The matrices must be the same size. /// /// The first matrix. /// The second matrix. /// A matrix where each compoent is the sum of the other two matrices. public static EigenMatrix operator +(EigenMatrix m1, EigenMatrix m2) { AreSameSize(m1, m2); return new EigenMatrix(EigenMatrix_AddMatrix(m1.Ptr, m2.Ptr)); } /// /// Subtract two matrices. /// The matrices must be the same size. /// /// The first matrix. /// The second matrix. /// A matrix where each compoent is the difference of the other two matrices. public static EigenMatrix operator -(EigenMatrix m1, EigenMatrix m2) { AreSameSize(m1, m2); return new EigenMatrix(EigenMatrix_SubMatrix(m1.Ptr, m2.Ptr)); } /// /// Multiple a matrix and a column vector. /// /// The matrix. /// The column vector. /// The product column vector. public static EigenColumnVector operator *(EigenMatrix m, EigenColumnVector v) { IsValidProduct(m, v); return new EigenColumnVector(EigenMatrix_MulColumnVector(m.Ptr, v.Ptr)); } /// /// Is this matrix the identity matrix. /// /// The threshold the values in the /// matrix can be to the expected value. /// Is this matrix the identity matrix. public bool IsIdentity(double eps = MathUtil.DEG_TO_RAD_64) { if (!IsSquare) return false; for (int y = 0; y < Columns; y++) { for (int x = 0; x < Rows; x++) { if (x == y) { if (!MathUtil.IsOne(this[x, y], eps)) return false; } else { if (!MathUtil.IsZero(this[x, y], eps)) return false; } } } return true; } /// /// Is this matrix filled with zeros. /// /// The threshold the values in the /// matrix can be to the expected value. /// Is this matrix filled with zeros. public bool IsZero(double eps = MathUtil.DEG_TO_RAD_64) { for (int y = 0; y < Columns; y++) { for (int x = 0; x < Rows; x++) { if (!MathUtil.IsZero(this[x, y], eps)) return false; } } return true; } /// /// Are all the values in this matrix positive. /// /// Are all the values in this matrix positive. public bool IsPositive() { for (int y = 0; y < Columns; y++) { for (int x = 0; x < Rows; x++) { if (this[x, y] < 0) return false; } } return true; } /// /// Does the matrix have a component that is nan. /// /// Does the matrix have a component that is nan. public bool HasNAN() { for (int y = 0; y < Columns; y++) { for (int x = 0; x < Rows; x++) { if (double.IsNaN(this[x, y])) return true; } } return false; } /// /// Replaces all nan values in the matrix with 0. /// public void NoNAN() { for (int y = 0; y < Columns; y++) { for (int x = 0; x < Rows; x++) { if (double.IsNaN(this[x, y])) this[x, y] = 0; } } } /// /// Are all the values in the matrix finite (non-infinite and non-nan). /// /// Are all the values in the matrix finite (non-infinite and non-nan). public bool IsFinite() { for (int y = 0; y < Columns; y++) { for (int x = 0; x < Rows; x++) { if (!MathUtil.IsFinite(this[x, y])) return false; } } return true; } /// /// Replaces all infinite and nan values in matrix with 0. /// public void MakeFinite() { for (int y = 0; y < Columns; y++) { for (int x = 0; x < Rows; x++) { if (!MathUtil.IsFinite(this[x, y])) this[x, y] = 0; } } } /// /// Are all the values in the matrix the same. /// /// The threshold the values in the /// matrix can be to the expected value. /// Are all the values in the matrix the same. public bool IsConst(double eps = MathUtil.EPS_64) { var value = this[0]; for (int y = 0; y < Columns; y++) { for (int x = 0; x < Rows; x++) { if (!MathUtil.AlmostEqual(this[x, y], value, eps)) return false; } } return true; } /// /// Create a sub matrix from this matrix. /// /// The row to start at. /// THe column to start at. /// The number of rows. /// The number of columns. /// A sub matrix from this matrix. public EigenMatrix SubMatrix(int startRow, int startCol, int rows, int cols) { var ptr = EigenMatrix_Block(Ptr, startRow, startCol, rows, cols); return new EigenMatrix(ptr); } /// /// Create a sub matrix from this matrix. /// /// The number of rows. /// The number of columns. /// A sub matrix from this matrix. public EigenMatrix SubMatrix(int rows, int cols) { var ptr = EigenMatrix_Reshaped(Ptr, rows, cols); return new EigenMatrix(ptr); } /// /// Solve the linear system. /// /// The vector to solve. /// The solver type. /// The solution vector. public EigenColumnVector Solve(EigenColumnVector v, EIGEN_SOLVER solver = EIGEN_SOLVER.COL_PIV_HOUSEHOLDER_QR) { switch (solver) { case EIGEN_SOLVER.COL_PIV_HOUSEHOLDER_QR: return ColPivHouseholderQr(v); case EIGEN_SOLVER.PARTIAL_PIV_LU: return PartialPivLu(v); case EIGEN_SOLVER.FULL_PIV_LU: return FullPivLu(v); case EIGEN_SOLVER.HOUSEHOLDER_QR: return HouseholderQr(v); case EIGEN_SOLVER.LLT: return LLT(v); case EIGEN_SOLVER.LDLT: return LDLT(v); case EIGEN_SOLVER.BDCSVD: return BdcSvd(v); case EIGEN_SOLVER.JACOBI_SVD: return JacobiSvd(v); case EIGEN_SOLVER.FULL_PIV_HOUSEHOLDER_QR: return FullPivHouseholderQR(v); case EIGEN_SOLVER.COMPLETE_ORTH_DECOM: return CompleteOrthogonalDecomposition(v); default: return ColPivHouseholderQr(v); } } /// /// Solve the linear system. /// /// The vector to solve. /// The solver type. /// The solution vector. public EigenMatrix Solve(EigenMatrix v, EIGEN_SOLVER solver = EIGEN_SOLVER.COL_PIV_HOUSEHOLDER_QR) { switch (solver) { case EIGEN_SOLVER.COL_PIV_HOUSEHOLDER_QR: return ColPivHouseholderQr(v); case EIGEN_SOLVER.PARTIAL_PIV_LU: return PartialPivLu(v); case EIGEN_SOLVER.FULL_PIV_LU: return FullPivLu(v); case EIGEN_SOLVER.HOUSEHOLDER_QR: return HouseholderQr(v); case EIGEN_SOLVER.LLT: return LLT(v); case EIGEN_SOLVER.LDLT: return LDLT(v); case EIGEN_SOLVER.BDCSVD: return BdcSvd(v); case EIGEN_SOLVER.JACOBI_SVD: return JacobiSvd(v); case EIGEN_SOLVER.FULL_PIV_HOUSEHOLDER_QR: return FullPivHouseholderQR(v); case EIGEN_SOLVER.COMPLETE_ORTH_DECOM: return CompleteOrthogonalDecomposition(v); default: return ColPivHouseholderQr(v); } } public EigenColumnVector ColPivHouseholderQr(EigenColumnVector v) { IsValidProduct(this, v); var ptr = EigenMatrix_ColPivHouseholderQr_Vec(Ptr, v.Ptr); return new EigenColumnVector(ptr); } public EigenMatrix ColPivHouseholderQr(EigenMatrix m) { IsValidProduct(this, m); var ptr = EigenMatrix_ColPivHouseholderQr_Mat(Ptr, m.Ptr); return new EigenMatrix(ptr); } public EigenColumnVector PartialPivLu(EigenColumnVector v) { IsValidProduct(this, v); if (!IsInvertible) throw new InvalidOperationException("Matrix must be invertible for PartialPivLu solver."); var ptr = EigenMatrix_PartialPivLu_Vec(Ptr, v.Ptr); return new EigenColumnVector(ptr); } public EigenMatrix PartialPivLu(EigenMatrix v) { IsValidProduct(this, v); if (!IsInvertible) throw new InvalidOperationException("Matrix must be invertible for PartialPivLu solver."); var ptr = EigenMatrix_PartialPivLu_Mat(Ptr, v.Ptr); return new EigenMatrix(ptr); } public EigenColumnVector FullPivLu(EigenColumnVector v) { IsValidProduct(this, v); var ptr = EigenMatrix_FullPivLu_Vec(Ptr, v.Ptr); return new EigenColumnVector(ptr); } public EigenMatrix FullPivLu(EigenMatrix v) { IsValidProduct(this, v); var ptr = EigenMatrix_FullPivLu_Mat(Ptr, v.Ptr); return new EigenMatrix(ptr); } public EigenColumnVector HouseholderQr(EigenColumnVector v) { IsValidProduct(this, v); var ptr = EigenMatrix_HouseholderQr_Vec(Ptr, v.Ptr); return new EigenColumnVector(ptr); } public EigenMatrix HouseholderQr(EigenMatrix v) { IsValidProduct(this, v); var ptr = EigenMatrix_HouseholderQr_Mat(Ptr, v.Ptr); return new EigenMatrix(ptr); } public EigenColumnVector LLT(EigenColumnVector v) { IsValidProduct(this, v); if (!IsPositive()) throw new InvalidOperationException("Matrix must be positive for LLT solver."); var ptr = EigenMatrix_LLT_Vec(Ptr, v.Ptr); return new EigenColumnVector(ptr); } public EigenMatrix LLT(EigenMatrix v) { IsValidProduct(this, v); if (!IsPositive()) throw new InvalidOperationException("Matrix must be positive for LLT solver."); var ptr = EigenMatrix_LLT_Mat(Ptr, v.Ptr); return new EigenMatrix(ptr); } public EigenColumnVector LDLT(EigenColumnVector v) { IsValidProduct(this, v); var ptr = EigenMatrix_LDLT_Vec(Ptr, v.Ptr); return new EigenColumnVector(ptr); } public EigenMatrix LDLT(EigenMatrix m) { IsValidProduct(this, m); var ptr = EigenMatrix_LDLT_Mat(Ptr, m.Ptr); return new EigenMatrix(ptr); } public EigenColumnVector BdcSvd(EigenColumnVector v) { IsValidProduct(this, v); int options = (int)EIGEN_SOLVER_OPTIONS.COMPUTE_THIN_U | (int)EIGEN_SOLVER_OPTIONS.COMPUTE_THIN_V; var ptr = EigenMatrix_BdcSvd_Vec(Ptr, v.Ptr, options); return new EigenColumnVector(ptr); } public EigenMatrix BdcSvd(EigenMatrix v) { IsValidProduct(this, v); int options = (int)EIGEN_SOLVER_OPTIONS.COMPUTE_THIN_U | (int)EIGEN_SOLVER_OPTIONS.COMPUTE_THIN_V; var ptr = EigenMatrix_BdcSvd_Mat(Ptr, v.Ptr, options); return new EigenMatrix(ptr); } public EigenColumnVector JacobiSvd(EigenColumnVector v) { IsValidProduct(this, v); int options = (int)EIGEN_SOLVER_OPTIONS.COMPUTE_THIN_U | (int)EIGEN_SOLVER_OPTIONS.COMPUTE_THIN_V; var ptr = EigenMatrix_JacobiSvd_Vec(Ptr, v.Ptr, options); return new EigenColumnVector(ptr); } public EigenMatrix JacobiSvd(EigenMatrix v) { IsValidProduct(this, v); int options = (int)EIGEN_SOLVER_OPTIONS.COMPUTE_THIN_U | (int)EIGEN_SOLVER_OPTIONS.COMPUTE_THIN_V; var ptr = EigenMatrix_JacobiSvd_Mat(Ptr, v.Ptr, options); return new EigenMatrix(ptr); } public EigenColumnVector FullPivHouseholderQR(EigenColumnVector v) { IsValidProduct(this, v); var ptr = EigenMatrix_FullPivHouseholderQr_Vec(Ptr, v.Ptr); return new EigenColumnVector(ptr); } public EigenMatrix FullPivHouseholderQR(EigenMatrix v) { IsValidProduct(this, v); var ptr = EigenMatrix_FullPivHouseholderQr_Mat(Ptr, v.Ptr); return new EigenMatrix(ptr); } public EigenColumnVector CompleteOrthogonalDecomposition(EigenColumnVector v) { IsValidProduct(this, v); var ptr = EigenMatrix_CompleteOrthogonalDecomposition_Vec(Ptr, v.Ptr); return new EigenColumnVector(ptr); } public EigenMatrix CompleteOrthogonalDecomposition(EigenMatrix v) { IsValidProduct(this, v); var ptr = EigenMatrix_CompleteOrthogonalDecomposition_Mat(Ptr, v.Ptr); return new EigenMatrix(ptr); } /// /// Find the relative error from the linear system. /// /// The vector that was solved. /// The vector that was the solution. /// The relative error. public double RelativeError(EigenColumnVector v, EigenColumnVector x) { IsValidProduct(this, v); return EigenMatrix_RelativeError_Vec(Ptr, v.Ptr, x.Ptr); } /// /// Find the relative error from the linear system. /// /// The vector that was solved. /// The vector that was the solution. /// The relative error. public double RelativeError(EigenMatrix v, EigenMatrix x) { IsValidProduct(this, v); return EigenMatrix_RelativeError_Mat(Ptr, v.Ptr, x.Ptr); } /// /// Find the eigen values of the matrix. /// /// The eigen values if found, null otherwise. /// True if the values could be determined. public bool EigenValues(out EigenColumnVector values) { var ptr = EigenMatrix_Eigenvalues(Ptr); if (ptr != IntPtr.Zero) { values = new EigenColumnVector(ptr); return true; } else { values = null; return false; } } /// /// Find the eigen vectors of the matrix. /// /// The eigen vectors if found, null otherwise. /// True if the vectors could be determined. public bool EigenVectors(out EigenMatrix vectors) { var ptr = EigenMatrix_Eigenvectors(Ptr); if (ptr != IntPtr.Zero) { vectors = new EigenMatrix(ptr); return true; } else { vectors = null; return false; } } /// /// /// /// /// /// public bool EigenValuesAndVectors(out EigenColumnVector values, out EigenMatrix vectors) { IntPtr valuesPtr; IntPtr vectorsPtr; if (EigenMatrix_EigenValuesVectors(Ptr, out valuesPtr, out vectorsPtr)) { values = new EigenColumnVector(valuesPtr); vectors = new EigenMatrix(vectorsPtr); return true; } else { values = null; vectors = null; return false; } } /// /// Try and find the inverse of the matrix. /// /// The inverse if found, null otherwise. /// True if the inverse was found. public bool TryInverse(out EigenMatrix inverse) { inverse = null; if(!IsSquare) return false; var ptr = EigenMatrix_TryInverse(Ptr); if(ptr != IntPtr.Zero) { inverse = new EigenMatrix(ptr); return true; } else { return false; } } /// /// /// /// /// public EigenRowVector GetRow(int Row) { CheckRows(this, Row + 1); var v = new EigenRowVector(Rows); for (int i = 0; i < Rows; i++) v[i] = this[i, Row]; return v; } /// /// /// /// /// public void SetRow(int Row, EigenRowVector v) { AreSameSize(this, v); for (int i = 0; i < Rows; i++) this[i, Row] = v[i]; } /// /// /// /// /// /// public void SetRow(int row, double x, double y) { CheckSize(this, row + 1, 2); this[row, 0] = x; this[row, 1] = y; } /// /// /// /// /// /// /// public void SetRow(int row, double x, double y, double z) { CheckSize(this, row + 1, 3); this[row, 0] = x; this[row, 1] = y; this[row, 2] = z; } /// /// /// /// /// /// /// /// public void SetRow(int row, double x, double y, double z, double w) { CheckSize(this, row + 1, 4); this[row, 0] = x; this[row, 1] = y; this[row, 2] = z; this[row, 3] = w; } /// /// /// /// /// public EigenColumnVector GetColumn(int Column) { CheckColumns(this, Column + 1); var v = new EigenColumnVector(Columns); for (int i = 0; i < Columns; i++) v[i] = this[Column, i]; return v; } /// /// /// /// /// public void SetColumn(int Column, EigenColumnVector v) { AreSameSize(this, v); for (int i = 0; i < Columns; i++) this[Column, i] = v[i]; } /// /// /// /// /// /// public void SetColumn(int column, double x, double y) { CheckSize(this, 2, column + 1); this[0, column] = x; this[1, column] = y; } /// /// /// /// /// /// /// public void SetColumn(int column, double x, double y, double z) { CheckSize(this, 3, column + 1); this[0, column] = x; this[1, column] = y; this[2, column] = z; } /// /// /// /// /// /// /// /// public void SetColumn(int column, double x, double y, double z, double w) { CheckSize(this, 4, column + 1); this[0, column] = x; this[1, column] = y; this[2, column] = z; this[3, column] = w; } /// /// /// /// public void Round(int digits) { for (int i = 0; i < Length; i++) this[i] = Math.Round(this[i], digits); } /// /// /// /// /// public static EigenMatrix Translate(Point3d point) { var m = EigenMatrix.Identity(4); m.SetColumn(3, point.x, point.y, point.z, 1); return m; } /// /// /// /// /// public static EigenMatrix Scale(Point3d point) { var m = EigenMatrix.Identity(4); m[0, 0] = point.x; m[1, 1] = point.y; m[2, 2] = point.z; return m; } /// /// /// /// /// static public EigenMatrix Scale(double s) { var m = EigenMatrix.Identity(4); m[0, 0] = s; m[1, 1] = s; m[2, 2] = s; return m; } /// /// /// /// /// static public EigenMatrix RotateX(Radian radian) { var m = new EigenMatrix(4, 4); double ca = MathUtil.Cos(radian); double sa = MathUtil.Sin(radian); return new EigenMatrix( 1, 0, 0, 0, 0, ca, -sa, 0, 0, sa, ca, 0, 0, 0, 0, 1); } /// /// /// /// /// static public EigenMatrix RotateY(Radian radian) { var m = new EigenMatrix(4, 4); double ca = MathUtil.Cos(radian); double sa = MathUtil.Sin(radian); return new EigenMatrix(ca, 0, sa, 0, 0, 1, 0, 0, -sa, 0, ca, 0, 0, 0, 0, 1); } /// /// /// /// /// static public EigenMatrix RotateZ(Radian radian) { var m = new EigenMatrix(4, 4); double ca = MathUtil.Cos(radian); double sa = MathUtil.Sin(radian); return new EigenMatrix(ca, -sa, 0, 0, sa, ca, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1); } /// /// Create a rotation from a angle and the rotation axis. /// /// The rotation amount. /// The axis to rotate on. /// The rotation matrix. static public EigenMatrix Rotate(Radian radian, Vector3d axis) { var m = EigenMatrix.Identity(4); double sinTheta = MathUtil.Sin(radian); double cosTheta = MathUtil.Cos(radian); // Compute rotation of first basis vector m[0, 0] = axis.x * axis.x + (1 - axis.x * axis.x) * cosTheta; m[0, 1] = axis.x * axis.y * (1 - cosTheta) - axis.z * sinTheta; m[0, 2] = axis.x * axis.z * (1 - cosTheta) + axis.y * sinTheta; m[0, 3] = 0; // Compute rotations of second and third basis vectors m[1, 0] = axis.x * axis.y * (1 - cosTheta) + axis.z * sinTheta; m[1, 1] = axis.y * axis.y + (1 - axis.y * axis.y) * cosTheta; m[1, 2] = axis.y * axis.z * (1 - cosTheta) - axis.x * sinTheta; m[1, 3] = 0; m[2, 0] = axis.x * axis.z * (1 - cosTheta) - axis.y * sinTheta; m[2, 1] = axis.y * axis.z * (1 - cosTheta) + axis.x * sinTheta; m[2, 2] = axis.z * axis.z + (1 - axis.z * axis.z) * cosTheta; m[2, 3] = 0; return m; } /// /// /// /// public override void Print(StringBuilder builder) { builder.AppendLine(this.ToString()); for (int x = 0; x < Rows; x++) { for (int y = 0; y < Columns; y++) { builder.Append(this[x, y].ToString()); if (y != Columns - 1) builder.Append(","); } builder.AppendLine(); } } internal static void CheckIfSqaure(EigenMatrix m) { if (!m.IsSquare) throw new InvalidOperationException("Matrix must be Square."); } internal static void IsValidProduct(EigenMatrix m, EigenColumnVector v) { if (v.Dimension != m.Columns) throw new InvalidOperationException("Matrix must have same number of columns as vectors dimension."); } internal static void IsValidProduct(EigenMatrix m1, EigenMatrix m2) { if (m1.Columns != m2.Rows) throw new InvalidOperationException("Matrix1 must have same number of columns as matrix2 has rows."); } internal static void AreSameSize(EigenMatrix m1, EigenMatrix m2) { if (m1.Rows != m2.Rows) throw new InvalidOperationException("Matrix1 must be the same size as matrix2."); if (m1.Columns != m2.Columns) throw new InvalidOperationException("Matrix1 must be the same size as matrix2."); } internal static void AreSameSize(EigenMatrix m, EigenRowVector v) { if (m.Rows != v.Dimension) throw new InvalidOperationException("Matrix must have the same number of rows as vector dimension."); } internal static void AreSameSize(EigenMatrix m, EigenColumnVector v) { if (m.Columns != v.Dimension) throw new InvalidOperationException("Matrix must have the same number of columns as vector dimension."); } internal static void CheckSize(EigenMatrix m, int rows, int columns) { if (rows > m.Rows) throw new InvalidOperationException(String.Format("Matrix must have at least {0} rows.", rows)); if (columns > m.Columns) throw new InvalidOperationException(String.Format("Matrix must have at least {0} columns.", columns)); } internal static void CheckRows(EigenMatrix m, int rows) { if (rows > m.Rows) throw new InvalidOperationException(String.Format("Matrix must have at least {0} rows.", rows)); } internal static void CheckColumns(EigenMatrix m, int columns) { if (columns > m.Columns) throw new InvalidOperationException(String.Format("Matrix must have at least {0} rows.", columns)); } protected override void ReleasePtr() { EigenMatrix_Release(Ptr); } [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr EigenMatrix_Create(int rows, int columns); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr EigenMatrix_CreateIdentity(int rows, int columns); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void EigenMatrix_Release(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int EigenMatrix_Rows(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int EigenMatrix_Columns(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern double EigenMatrix_GetXY(IntPtr ptr, int x, int y); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void EigenMatrix_SetXY(IntPtr ptr, int x, int y, double value); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern double EigenMatrix_GetX(IntPtr ptr, int x); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void EigenMatrix_SetX(IntPtr ptr, int x, double value); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr EigenMatrix_Transpose(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr EigenMatrix_Conjugate(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr EigenMatrix_Adjoint(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr EigenMatrix_Inverse(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern double EigenMatrix_Determinant(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern double EigenMatrix_Trace(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool EigenMatrix_IsIdentity(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool EigenMatrix_IsDiagonal(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool EigenMatrix_IsUpperTriangular(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool EigenMatrix_IsLowerTriangular(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr EigenMatrix_MulScalar(IntPtr ptr1, double s); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr EigenMatrix_DivideScalar(IntPtr ptr1, double s); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr EigenMatrix_MulMatrix(IntPtr ptr1, IntPtr ptr2); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr EigenMatrix_AddMatrix(IntPtr ptr1, IntPtr ptr2); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr EigenMatrix_SubMatrix(IntPtr ptr1, IntPtr ptr2); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr EigenMatrix_MulColumnVector(IntPtr ptr1, IntPtr ptr2); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr EigenMatrix_Block(IntPtr ptr, int startRox, int startCol, int blockRows, int blockCols); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr EigenMatrix_Reshaped(IntPtr ptr, int rows, int cols); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr EigenMatrix_ColPivHouseholderQr_Vec(IntPtr ptr1, IntPtr ptr2); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr EigenMatrix_ColPivHouseholderQr_Mat(IntPtr ptr1, IntPtr ptr2); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr EigenMatrix_PartialPivLu_Vec(IntPtr ptr1, IntPtr ptr2); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr EigenMatrix_PartialPivLu_Mat(IntPtr ptr1, IntPtr ptr2); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr EigenMatrix_FullPivLu_Vec(IntPtr ptr1, IntPtr ptr2); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr EigenMatrix_FullPivLu_Mat(IntPtr ptr1, IntPtr ptr2); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr EigenMatrix_HouseholderQr_Vec(IntPtr ptr1, IntPtr ptr2); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr EigenMatrix_HouseholderQr_Mat(IntPtr ptr1, IntPtr ptr2); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr EigenMatrix_LLT_Vec(IntPtr ptr1, IntPtr ptr2); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr EigenMatrix_LLT_Mat(IntPtr ptr1, IntPtr ptr2); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr EigenMatrix_LDLT_Vec(IntPtr ptr1, IntPtr ptr2); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr EigenMatrix_LDLT_Mat(IntPtr ptr1, IntPtr ptr2); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr EigenMatrix_BdcSvd_Vec(IntPtr ptr1, IntPtr ptr2, int options); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr EigenMatrix_BdcSvd_Mat(IntPtr ptr1, IntPtr ptr2, int options); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr EigenMatrix_JacobiSvd_Vec(IntPtr ptr1, IntPtr ptr2, int options); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr EigenMatrix_JacobiSvd_Mat(IntPtr ptr1, IntPtr ptr2, int options); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr EigenMatrix_FullPivHouseholderQr_Vec(IntPtr ptr1, IntPtr ptr2); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr EigenMatrix_FullPivHouseholderQr_Mat(IntPtr ptr1, IntPtr ptr2); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr EigenMatrix_CompleteOrthogonalDecomposition_Vec(IntPtr ptr1, IntPtr ptr2); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr EigenMatrix_CompleteOrthogonalDecomposition_Mat(IntPtr ptr1, IntPtr ptr2); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern double EigenMatrix_RelativeError_Vec(IntPtr ptr1, IntPtr ptr2, IntPtr ptr3); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern double EigenMatrix_RelativeError_Mat(IntPtr ptr1, IntPtr ptr2, IntPtr ptr3); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr EigenMatrix_Eigenvalues(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr EigenMatrix_Eigenvectors(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool EigenMatrix_EigenValuesVectors(IntPtr ptr, [Out] out IntPtr values, [Out] out IntPtr vectors); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool EigenMatrix_IsInvertible(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr EigenMatrix_TryInverse(IntPtr ptr); } } ================================================ FILE: CGALDotNet/Eigen/EigenRowVector.cs ================================================ using System; using System.Collections.Generic; using System.Text; using System.Runtime.InteropServices; using CGALDotNetGeometry.Numerics; using CGALDotNetGeometry.Shapes; namespace CGALDotNet.Eigen { /// /// /// public class EigenRowVector : EigenVector { /// /// /// /// public EigenRowVector(int dimension) { Ptr = EigenRowVector_CreateVector(dimension); } /// /// /// /// /// public EigenRowVector(double x, double y) { Ptr = EigenRowVector_CreateVector(2); this[0] = x; this[1] = y; } public EigenRowVector(double x, double y, double z) { Ptr = EigenRowVector_CreateVector(3); this[0] = x; this[1] = y; this[2] = z; } /// /// /// /// /// /// /// public EigenRowVector(double x, double y, double z, double w) { Ptr = EigenRowVector_CreateVector(4); this[0] = x; this[1] = y; this[2] = z; this[3] = w; } /// /// /// /// public EigenRowVector(IList list) { Ptr = EigenRowVector_CreateVector(list.Count); for(int i = 0; i < list.Count; i++) this[i] = list[i]; } /// /// /// /// internal EigenRowVector(IntPtr ptr) : base(ptr) { } /// /// /// /// /// public override double this[int i] { get { return EigenRowVector_Get(Ptr, i); } set { EigenRowVector_Set(Ptr, i, value); } } /// /// /// public override int Dimension => EigenRowVector_Dimension(Ptr); /// /// /// public override double Magnitude => EigenRowVector_Norm(Ptr); /// /// / /// /// public override string ToString() { return String.Format("[EigenRowVector: Dimension={0}]", Dimension); } /// /// /// public EigenRowVector Normalized => new EigenRowVector(EigenRowVector_Normalized(Ptr)); /// /// /// public EigenColumnVector Transpose => new EigenColumnVector(EigenRowVector_Transpose(Ptr)); /// /// /// public EigenRowVector Adjoint => new EigenRowVector(EigenRowVector_Adjoint(Ptr)); /// /// /// public EigenRowVector Conjugate => new EigenRowVector(EigenRowVector_Conjugate(Ptr)); /// /// /// /// /// /// public static double Dot(EigenRowVector v1, EigenRowVector v2) { AreSameSize(v1, v2); return EigenRowVector_Dot(v1.Ptr, v2.Ptr); } /// /// /// public override void Normalize() { EigenRowVector_Normalize(Ptr); } public override void Resize(int dimension) { EigenRowVector_Resize(Ptr, dimension); } /// /// /// /// /// /// /// /// public static EigenRowVector Random(int dimension, double min, double max, int seed) { var ptr = EigenRowVector_CreateVector(dimension); var v = new EigenRowVector(ptr); var rnd = new Random(seed); double range = max - min; for (int i = 0; i < v.Dimension; i++) v[i] = min + rnd.NextDouble() * range; return v; } /// /// /// protected override void ReleasePtr() { EigenRowVector_Release(Ptr); } [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr EigenRowVector_CreateVector(int dimension); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void EigenRowVector_Release(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int EigenRowVector_Rows(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int EigenRowVector_Dimension(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern double EigenRowVector_Get(IntPtr ptr, int x); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void EigenRowVector_Set(IntPtr ptr, int x, double value); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern double EigenRowVector_Dot(IntPtr ptr1, IntPtr ptr2); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr EigenRowVector_Normalized(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void EigenRowVector_Normalize(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern double EigenRowVector_Norm(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr EigenRowVector_Transpose(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr EigenRowVector_Adjoint(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr EigenRowVector_Conjugate(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void EigenRowVector_Resize(IntPtr ptr, int dimension); } } ================================================ FILE: CGALDotNet/Eigen/EigenVector.cs ================================================ using System; using System.Text; using CGALDotNetGeometry.Numerics; using CGALDotNetGeometry.Shapes; namespace CGALDotNet.Eigen { /// /// /// public abstract class EigenVector : CGALObject { /// /// /// internal EigenVector() { } /// /// /// /// internal EigenVector(IntPtr ptr) : base(ptr) { } /// /// The first value in the vector. /// public double x { get { return this[0]; } set { this[0] = value; } } /// /// The second value in the vector. /// public double y { get { return this[1]; } set { this[1] = value; } } /// /// The third value in the vector. /// public double z { get { return this[2]; } set { this[2] = value; } } /// /// The fourth value in the vector. /// public double w { get { return this[3]; } set { this[3] = value; } } /// /// /// /// /// public abstract double this[int i] { get; set; } /// /// /// public abstract int Dimension { get; } /// /// /// public abstract double Magnitude { get; } /// /// /// public abstract void Normalize(); /// /// /// /// public abstract void Resize(int dimension); /// /// /// /// /// public bool IsZero(double eps = MathUtil.DEG_TO_RAD_64) { for (int x = 0; x < Dimension; x++) { if (!MathUtil.IsZero(this[x], eps)) return false; } return true; } /// /// /// /// public bool IsPositive() { for (int x = 0; x < Dimension; x++) { if (this[x] < 0) return false; } return true; } /// /// /// /// public bool HasNAN() { for (int x = 0; x < Dimension; x++) { if (double.IsNaN(this[x])) return true; } return false; } /// /// /// public void NoNAN() { for (int x = 0; x < Dimension; x++) { if (double.IsNaN(this[x])) this[x] = 0; } } /// /// /// /// public bool IsFinite() { for (int x = 0; x < Dimension; x++) { if (!MathUtil.IsFinite(this[x])) return false; } return true; } /// /// /// public void MakeFinite() { for (int x = 0; x < Dimension; x++) { if (!MathUtil.IsFinite(this[x])) this[x] = 0; } } /// /// /// /// /// public bool IsConst(double eps = MathUtil.EPS_64) { var value = this[0]; for (int x = 0; x < Dimension; x++) { if (!MathUtil.AlmostEqual(this[x], value, eps)) return false; } return true; } /// /// /// /// public void Round(int digits) { for (int i = 0; i < Dimension; i++) this[i] = Math.Round(this[i], digits); } /// /// /// /// public override void Print(StringBuilder builder) { builder.AppendLine(this.ToString()); if (this is EigenColumnVector) { for (int i = 0; i < Dimension; i++) { builder.Append(this[i].ToString()); if (i != Dimension - 1) builder.AppendLine(","); else builder.AppendLine(); } } else { for (int i = 0; i < Dimension; i++) { builder.Append(this[i].ToString()); if (i != Dimension - 1) builder.Append(","); else builder.AppendLine(); } } } /// /// /// /// /// /// internal static void AreSameSize(EigenVector v1, EigenVector v2) { if (v1.Dimension != v2.Dimension) throw new InvalidOperationException("Vector1 must be the same size as Vector2."); } } } ================================================ FILE: CGALDotNet/Extensions/ArrayExtensions.cs ================================================ using System; using System.Collections.Generic; using CGALDotNet.Triangulations; namespace CGALDotNet.Extensions { public static class ArrayExtensions { public static void Round(this TriVertex2[] array, int digits) { if (digits < 0) return; for (int i = 0; i < array.Length; i++) { var p = array[i].Point; array[i].Point = p.Rounded(digits); } } public static void Round(this TriVertex3[] array, int digits) { if (digits < 0) return; for (int i = 0; i < array.Length; i++) { var p = array[i].Point; array[i].Point = p.Rounded(digits); } } } } ================================================ FILE: CGALDotNet/Extensions/EnumExtensions.cs ================================================ using System; using System.Collections.Generic; using System.Text; namespace CGALDotNet.Extensions { public static class EnumExtensions { internal static bool ToBool(this BOOL_OR_UNDETERMINED e) { return e == BOOL_OR_UNDETERMINED.TRUE; } } } ================================================ FILE: CGALDotNet/Extensions/PrimativeExtensions.cs ================================================ using System; using System.Collections.Generic; using System.Text; namespace CGALDotNet.Extensions { public static class PrimativeExtensions { internal static BOOL_OR_UNDETERMINED ToBoolOrUndetermined(this bool b) { return b ? BOOL_OR_UNDETERMINED.TRUE : BOOL_OR_UNDETERMINED.FALSE; } } } ================================================ FILE: CGALDotNet/Geometry/Box2.cs ================================================ using System; using System.Collections.Generic; using System.Text; using CGALDotNet; using CGALDotNetGeometry.Numerics; using CGALDotNetGeometry.Shapes; namespace CGALDotNet.Geometry { /// /// The generic Box wrapper for a CGAL object. /// /// The kernel type. public sealed class Box2 : Box2 where K : CGALKernel, new() { /// /// Create box from min and max values. /// /// The min x and y value. /// The max x and y value. public Box2(double min, double max) : base(new Point2d(min), new Point2d(max), new K()) { } /// /// Create box from min and max points. /// /// The min point. /// The max point. public Box2(Point2d min, Point2d max) : base(min, max, new K()) { } /// /// Create from a pointer. /// /// The iso rectangle pointer. internal Box2(IntPtr ptr) : base(new K(), ptr) { } /// /// The type of kernel object uses. /// public string KernelName => Kernel.Name; /// /// The iso rectangle as a string. /// /// The iso rectangle as a string. public override string ToString() { return string.Format("[Box2<{0}>: Min={1}, Max={2}]", KernelName, Min, Max); } /// /// Translate the shape. /// /// The amount to translate. public void Translate(Point2d translation) { Kernel.Box2_Transform(Ptr, translation, 0, 1); } /// /// Rotate the shape. /// /// The amount to rotate. public void Rotate(Degree rotation) { Kernel.Box2_Transform(Ptr, Point2d.Zero, rotation.radian, 1); } /// /// Scale the shape. /// /// The amount to scale. public void Scale(double scale) { Kernel.Box2_Transform(Ptr, Point2d.Zero, 0, scale); } /// /// Transform the rectangle. /// /// The amount to translate. /// The amount to rotate /// The amount to scale. public void Transform(Point2d translation, Degree rotation, double scale) { Kernel.Box2_Transform(Ptr, translation, rotation.radian, scale); } /// /// Create a deep copy of the rectangle. /// /// The deep copy. public Box2 Copy() { var ptr = Kernel.Box2_Copy(Ptr); return new Box2(ptr); } } /// /// The abstract iso rectangle definition. /// public abstract class Box2 : CGALObject { /// /// Default constructor. /// private Box2() { } /// /// /// /// /// /// internal Box2(Point2d min, Point2d max, CGALKernel kernel) { Kernel = kernel.GeometryKernel2; Ptr = Kernel.Box2_Create(min, max); } /// /// Construct with a new kernel. /// /// The geometry kernel. /// The Box pointer. internal Box2(CGALKernel kernel, IntPtr ptr) : base(ptr) { Kernel = kernel.GeometryKernel2; } /// /// The iso rectangle kernel. /// Contains the functions to the unmanaged CGAL object. /// protected private GeometryKernel2 Kernel { get; private set; } /// /// Convert to shape struct. /// public Box2d Shape => new Box2d(Min, Max); /// /// The rectangles min point. /// public Point2d Min { get { return Kernel.Box2_GetMin(Ptr); } set { Kernel.Box2_SetMin(Ptr, value); } } /// /// The rectangles max point. /// public Point2d Max { get { return Kernel.Box2_GetMax(Ptr); } set { Kernel.Box2_SetMax(Ptr, value); } } /// /// The rectangles area. /// public double Area { get { if (IsDegenerate) return 0; else return Kernel.Box2_Area(Ptr); } } /// /// Is the rectangle degenerate. /// public bool IsDegenerate => Kernel.Box2_IsDegenerate(Ptr); /// /// The side the rectangle the point is on. /// /// The point. /// If the point is iside, outside or on boundary. public BOUNDED_SIDE BoundedSide(Point2d point) { if (IsDegenerate) return BOUNDED_SIDE.UNDETERMINED; else return Kernel.Box2_BoundedSide(Ptr, point); } /// /// Does the rectangle contain the point. /// /// The point /// Should a point on /// the boundary count as being inside. /// Does the rectangle contain the point public bool ContainsPoint(Point2d point, bool includeBoundary = true) { if (IsDegenerate) return false; else return Kernel.Box2_ContainsPoint(Ptr, point, includeBoundary); } /// /// Release the unmanaged pointer. /// protected override void ReleasePtr() { Kernel.Box2_Release(Ptr); } /// /// Round the shape. /// /// The number of digits to round to. public void Round(int digits) { this.Min = Min.Rounded(digits); this.Max = Max.Rounded(digits); } /// /// Convert to another kernel. /// Must provide a different kernel to convert to or /// just a deep copy will be returned. /// /// The shape with another kernel type. public Box2 Convert() where T : CGALKernel, new() { var k = typeof(T).Name; var e = CGALEnum.ToKernelEnum(k); var ptr = Kernel.Box2_Convert(Ptr, e); return new Box2(ptr); } } } ================================================ FILE: CGALDotNet/Geometry/CGALIntersections_Geometry_EEK.cs ================================================ using System; using System.Collections.Generic; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using CGALDotNetGeometry.Numerics; using CGALDotNetGeometry.Shapes; namespace CGALDotNet.Geometry { /// /// The static intersection class. /// public static partial class CGALIntersections { /// -------------------------------------------------------- /// /// The Point DoIntersect functions /// /// -------------------------------------------------------- public static bool DoIntersect(Point2 point, Line2 line) { return Intersections_Geometry_EEK_DoIntersect_PointLine(point.Ptr, line.Ptr); } public static bool DoIntersect(Point2 point, Ray2 ray) { return Intersections_Geometry_EEK_DoIntersect_PointRay(point.Ptr, ray.Ptr); } public static bool DoIntersect(Point2 point, Segment2 segment) { return Intersections_Geometry_EEK_DoIntersect_PointSegment(point.Ptr, segment.Ptr); } public static bool DoIntersect(Point2 point, Triangle2 triangle) { return Intersections_Geometry_EEK_DoIntersect_PointTriangle(point.Ptr, triangle.Ptr); } public static bool DoIntersect(Point2 point, Box2 box) { return Intersections_Geometry_EEK_DoIntersect_PointBox(point.Ptr, box.Ptr); } /// -------------------------------------------------------- /// /// The Line DoIntersect functions /// /// -------------------------------------------------------- public static bool DoIntersect(Line2 line, Point2 point) { return Intersections_Geometry_EEK_DoIntersect_LinePoint(line.Ptr, point.Ptr); } public static bool DoIntersect(Line2 line, Line2 line2) { return Intersections_Geometry_EEK_DoIntersect_LineLine(line.Ptr, line2.Ptr); } public static bool DoIntersect(Line2 line, Ray2 ray) { return Intersections_Geometry_EEK_DoIntersect_LineRay(line.Ptr, ray.Ptr); } public static bool DoIntersect(Line2 line, Segment2 segment) { return Intersections_Geometry_EEK_DoIntersect_LineSegment(line.Ptr, segment.Ptr); } public static bool DoIntersect(Line2 line, Triangle2 triangle) { return Intersections_Geometry_EEK_DoIntersect_LineTriangle(line.Ptr, triangle.Ptr); } public static bool DoIntersect(Line2 line, Box2 box) { return Intersections_Geometry_EEK_DoIntersect_LineBox(line.Ptr, box.Ptr); } /// -------------------------------------------------------- /// /// The Ray DoIntersect functions /// /// -------------------------------------------------------- public static bool DoIntersect(Ray2 ray, Point2 point) { return Intersections_Geometry_EEK_DoIntersect_RayPoint(ray.Ptr, point.Ptr); } public static bool DoIntersect(Ray2 ray, Line2 line) { return Intersections_Geometry_EEK_DoIntersect_RayLine(ray.Ptr, line.Ptr); } public static bool DoIntersect(Ray2 ray, Ray2 ray2) { return Intersections_Geometry_EEK_DoIntersect_RayRay(ray.Ptr, ray2.Ptr); } public static bool DoIntersect(Ray2 ray, Segment2 segment) { return Intersections_Geometry_EEK_DoIntersect_RaySegment(ray.Ptr, segment.Ptr); } public static bool DoIntersect(Ray2 ray, Triangle2 triangle) { return Intersections_Geometry_EEK_DoIntersect_RayTriangle(ray.Ptr, triangle.Ptr); } public static bool DoIntersect(Ray2 ray, Box2 box) { return Intersections_Geometry_EEK_DoIntersect_RayBox(ray.Ptr, box.Ptr); } /// -------------------------------------------------------- /// /// The Segment DoIntersect functions /// /// -------------------------------------------------------- public static bool DoIntersect(Segment2 segment, Point2 point) { return Intersections_Geometry_EEK_DoIntersect_SegmentPoint(segment.Ptr, point.Ptr); } public static bool DoIntersect(Segment2 segment, Line2 line) { return Intersections_Geometry_EEK_DoIntersect_SegmentLine(segment.Ptr, line.Ptr); } public static bool DoIntersect(Segment2 segment, Ray2 ray) { return Intersections_Geometry_EEK_DoIntersect_SegmentRay(segment.Ptr, ray.Ptr); } public static bool DoIntersect(Segment2 segment, Segment2 segment2) { return Intersections_Geometry_EEK_DoIntersect_SegmentSegment(segment.Ptr, segment2.Ptr); } public static bool DoIntersect(Segment2 segment, Triangle2 triangle) { return Intersections_Geometry_EEK_DoIntersect_SegmentTriangle(segment.Ptr, triangle.Ptr); } public static bool DoIntersect(Segment2 segment, Box2 box) { return Intersections_Geometry_EEK_DoIntersect_SegmentBox(segment.Ptr, box.Ptr); } /// -------------------------------------------------------- /// /// The Triangle DoIntersect functions /// /// -------------------------------------------------------- public static bool DoIntersect(Triangle2 triangle, Point2 point) { return Intersections_Geometry_EEK_DoIntersect_TrianglePoint(triangle.Ptr, point.Ptr); } public static bool DoIntersect(Triangle2 triangle, Line2 line) { return Intersections_Geometry_EEK_DoIntersect_TriangleLine(triangle.Ptr, line.Ptr); } public static bool DoIntersect(Triangle2 triangle, Ray2 ray) { return Intersections_Geometry_EEK_DoIntersect_TriangleRay(triangle.Ptr, ray.Ptr); } public static bool DoIntersect(Triangle2 triangle, Segment2 segment) { return Intersections_Geometry_EEK_DoIntersect_TriangleSegment(triangle.Ptr, segment.Ptr); } public static bool DoIntersect(Triangle2 triangle, Triangle2 triangle2) { return Intersections_Geometry_EEK_DoIntersect_TriangleTriangle(triangle.Ptr, triangle2.Ptr); } public static bool DoIntersect(Triangle2 triangle, Box2 box) { return Intersections_Geometry_EEK_DoIntersect_TriangleBox(triangle.Ptr, box.Ptr); } /// -------------------------------------------------------- /// /// The Box DoIntersect functions /// /// -------------------------------------------------------- public static bool DoIntersect(Box2 box, Point2 point) { return Intersections_Geometry_EEK_DoIntersect_BoxPoint(box.Ptr, point.Ptr); } public static bool DoIntersect(Box2 box, Line2 line) { return Intersections_Geometry_EEK_DoIntersect_BoxLine(box.Ptr, line.Ptr); } public static bool DoIntersect(Box2 box, Ray2 ray) { return Intersections_Geometry_EEK_DoIntersect_BoxRay(box.Ptr, ray.Ptr); } public static bool DoIntersect(Box2 box, Segment2 segment) { return Intersections_Geometry_EEK_DoIntersect_BoxSegment(box.Ptr, segment.Ptr); } public static bool DoIntersect(Box2 box, Triangle2 triangle) { return Intersections_Geometry_EEK_DoIntersect_BoxTriangle(box.Ptr, triangle.Ptr); } public static bool DoIntersect(Box2 box, Box2 box2) { return Intersections_Geometry_EEK_DoIntersect_BoxBox(box.Ptr, box2.Ptr); } /// -------------------------------------------------------- /// /// The Point Intersection functions /// /// -------------------------------------------------------- public static IntersectionResult2d Intersection(Point2 point, Line2 line) { return Intersections_Geometry_EEK_Intersection_PointLine(point.Ptr, line.Ptr); } public static IntersectionResult2d Intersection(Point2 point, Ray2 ray) { return Intersections_Geometry_EEK_Intersection_PointRay(point.Ptr, ray.Ptr); } public static IntersectionResult2d Intersection(Point2 point, Segment2 segment) { return Intersections_Geometry_EEK_Intersection_PointSegment(point.Ptr, segment.Ptr); } public static IntersectionResult2d Intersection(Point2 point, Triangle2 triangle) { return Intersections_Geometry_EEK_Intersection_PointTriangle(point.Ptr, triangle.Ptr); } public static IntersectionResult2d Intersection(Point2 point, Box2 box) { return Intersections_Geometry_EEK_Intersection_PointBox(point.Ptr, box.Ptr); } /// -------------------------------------------------------- /// /// The Line Intersection functions /// /// ----------------------------------------------------- public static IntersectionResult2d Intersection(Line2 line, Point2 point) { return Intersections_Geometry_EEK_Intersection_LinePoint(line.Ptr, point.Ptr); } public static IntersectionResult2d Intersection(Line2 line, Line2 line2) { return Intersections_Geometry_EEK_Intersection_LineLine(line.Ptr, line2.Ptr); } public static IntersectionResult2d Intersection(Line2 line, Ray2 ray) { return Intersections_Geometry_EEK_Intersection_LineRay(line.Ptr, ray.Ptr); } public static IntersectionResult2d Intersection(Line2 line, Segment2 segment) { return Intersections_Geometry_EEK_Intersection_LineSegment(line.Ptr, segment.Ptr); } public static IntersectionResult2d Intersection(Line2 line, Triangle2 triangle) { return Intersections_Geometry_EEK_Intersection_LineTriangle(line.Ptr, triangle.Ptr); } public static IntersectionResult2d Intersection(Line2 line, Box2 box) { return Intersections_Geometry_EEK_Intersection_LineBox(line.Ptr, box.Ptr); } /// -------------------------------------------------------- /// /// The Ray Intersection functions /// /// ----------------------------------------------------- public static IntersectionResult2d Intersection(Ray2 ray, Point2 point) { return Intersections_Geometry_EEK_Intersection_RayPoint(ray.Ptr, point.Ptr); } public static IntersectionResult2d Intersection(Ray2 ray, Line2 line) { return Intersections_Geometry_EEK_Intersection_RayLine(ray.Ptr, line.Ptr); } public static IntersectionResult2d Intersection(Ray2 ray, Ray2 ray2) { return Intersections_Geometry_EEK_Intersection_RayRay(ray.Ptr, ray2.Ptr); } public static IntersectionResult2d Intersection(Ray2 ray, Segment2 segment) { return Intersections_Geometry_EEK_Intersection_RaySegment(ray.Ptr, segment.Ptr); } public static IntersectionResult2d Intersection(Ray2 ray, Triangle2 triangle) { return Intersections_Geometry_EEK_Intersection_RayTriangle(ray.Ptr, triangle.Ptr); } public static IntersectionResult2d Intersection(Ray2 ray, Box2 box) { return Intersections_Geometry_EEK_Intersection_RayBox(ray.Ptr, box.Ptr); } /// -------------------------------------------------------- /// /// The Segment Intersection functions /// /// ----------------------------------------------------- public static IntersectionResult2d Intersection(Segment2 segment, Point2 point) { return Intersections_Geometry_EEK_Intersection_SegmentPoint(segment.Ptr, point.Ptr); } public static IntersectionResult2d Intersection(Segment2 segment, Line2 line) { return Intersections_Geometry_EEK_Intersection_SegmentLine(segment.Ptr, line.Ptr); } public static IntersectionResult2d Intersection(Segment2 segment, Ray2 ray) { return Intersections_Geometry_EEK_Intersection_SegmentRay(segment.Ptr, ray.Ptr); } public static IntersectionResult2d Intersection(Segment2 segment, Segment2 segment2) { return Intersections_Geometry_EEK_Intersection_SegmentSegment(segment.Ptr, segment2.Ptr); } public static IntersectionResult2d Intersection(Segment2 segment, Triangle2 triangle) { return Intersections_Geometry_EEK_Intersection_SegmentTriangle(segment.Ptr, triangle.Ptr); } public static IntersectionResult2d Intersection(Segment2 segment, Box2 box) { return Intersections_Geometry_EEK_Intersection_SegmentBox(segment.Ptr, box.Ptr); } /// -------------------------------------------------------- /// /// The Triangle Intersection functions /// /// ----------------------------------------------------- public static IntersectionResult2d Intersection(Triangle2 triangle, Point2 point) { return Intersections_Geometry_EEK_Intersection_TrianglePoint(triangle.Ptr, point.Ptr); } public static IntersectionResult2d Intersection(Triangle2 triangle, Line2 line) { return Intersections_Geometry_EEK_Intersection_TriangleLine(triangle.Ptr, line.Ptr); } public static IntersectionResult2d Intersection(Triangle2 triangle, Ray2 ray) { return Intersections_Geometry_EEK_Intersection_TriangleRay(triangle.Ptr, ray.Ptr); } public static IntersectionResult2d Intersection(Triangle2 triangle, Segment2 segment) { return Intersections_Geometry_EEK_Intersection_TriangleSegment(triangle.Ptr, segment.Ptr); } public static IntersectionResult2d Intersection(Triangle2 triangle, Triangle2 triangle2) { return Intersections_Geometry_EEK_Intersection_TriangleTriangle(triangle.Ptr, triangle2.Ptr); } public static IntersectionResult2d Intersection(Triangle2 triangle, Box2 box) { return Intersections_Geometry_EEK_Intersection_TriangleBox(triangle.Ptr, box.Ptr); } /// -------------------------------------------------------- /// /// The Box Intersection functions /// /// ----------------------------------------------------- public static IntersectionResult2d Intersection(Box2 box, Point2 point) { return Intersections_Geometry_EEK_Intersection_BoxPoint(box.Ptr, point.Ptr); } public static IntersectionResult2d Intersection(Box2 box, Line2 line) { return Intersections_Geometry_EEK_Intersection_BoxLine(box.Ptr, line.Ptr); } public static IntersectionResult2d Intersection(Box2 box, Ray2 ray) { return Intersections_Geometry_EEK_Intersection_BoxRay(box.Ptr, ray.Ptr); } public static IntersectionResult2d Intersection(Box2 box, Segment2 segment) { return Intersections_Geometry_EEK_Intersection_BoxSegment(box.Ptr, segment.Ptr); } public static IntersectionResult2d Intersection(Box2 box, Triangle2 triangle) { return Intersections_Geometry_EEK_Intersection_BoxTriangle(box.Ptr, triangle.Ptr); } public static IntersectionResult2d Intersection(Box2 box, Box2 box2) { return Intersections_Geometry_EEK_Intersection_BoxBox(box.Ptr, box2.Ptr); } /// -------------------------------------------------------- /// /// The Point SqrDistance functions /// /// ----------------------------------------------------- public static double SqrDistance(Point2 point, Point2 point2) { return Intersections_Geometry_EEK_SqrDistance_PointPoint(point.Ptr, point2.Ptr); } public static double SqrDistance(Point2 point, Line2 line) { return Intersections_Geometry_EEK_SqrDistance_PointLine(point.Ptr, line.Ptr); } public static double SqrDistance(Point2 point, Ray2 ray) { return Intersections_Geometry_EEK_SqrDistance_PointRay(point.Ptr, ray.Ptr); } public static double SqrDistance(Point2 point, Segment2 seg) { return Intersections_Geometry_EEK_SqrDistance_PointSegment(point.Ptr, seg.Ptr); } public static double SqrDistance(Point2 point, Triangle2 tri) { return Intersections_Geometry_EEK_SqrDistance_PointTriangle(point.Ptr, tri.Ptr); } /// -------------------------------------------------------- /// /// The Line SqrDistance functions /// /// -------------------------------------------------------- public static double SqrDistance(Line2 line, Point2 point) { return Intersections_Geometry_EEK_SqrDistance_LinePoint(line.Ptr, point.Ptr); } public static double SqrDistance(Line2 line, Line2 line2) { return Intersections_Geometry_EEK_SqrDistance_LineLine(line.Ptr, line2.Ptr); } public static double SqrDistance(Line2 line, Ray2 ray) { return Intersections_Geometry_EEK_SqrDistance_LineRay(line.Ptr, ray.Ptr); } public static double SqrDistance(Line2 line, Segment2 segment) { return Intersections_Geometry_EEK_SqrDistance_LineSegment(line.Ptr, segment.Ptr); } public static double SqrDistance(Line2 line, Triangle2 triangle) { return Intersections_Geometry_EEK_SqrDistance_LineTriangle(line.Ptr, triangle.Ptr); } /// -------------------------------------------------------- /// /// The Ray SqrDistance functions /// /// -------------------------------------------------------- public static double SqrDistance(Ray2 ray, Point2 point) { return Intersections_Geometry_EEK_SqrDistance_RayPoint(ray.Ptr, point.Ptr); } public static double SqrDistance(Ray2 ray, Line2 line) { return Intersections_Geometry_EEK_SqrDistance_RayLine(ray.Ptr, line.Ptr); } public static double SqrDistance(Ray2 ray, Ray2 ray2) { return Intersections_Geometry_EEK_SqrDistance_RayRay(ray.Ptr, ray2.Ptr); } public static double SqrDistance(Ray2 ray, Segment2 segment) { return Intersections_Geometry_EEK_SqrDistance_RaySegment(ray.Ptr, segment.Ptr); } public static double SqrDistance(Ray2 ray, Triangle2 triangle) { return Intersections_Geometry_EEK_SqrDistance_RayTriangle(ray.Ptr, triangle.Ptr); } /// -------------------------------------------------------- /// /// The Segment SqrDistance functions /// /// ----------------------------------------------------- public static double SqrDistance(Segment2 segment, Point2 point) { return Intersections_Geometry_EEK_SqrDistance_SegmentPoint(segment.Ptr, point.Ptr); } public static double SqrDistance(Segment2 segment, Line2 line) { return Intersections_Geometry_EEK_SqrDistance_SegmentLine(segment.Ptr, line.Ptr); } public static double SqrDistance(Segment2 segment, Ray2 ray) { return Intersections_Geometry_EEK_SqrDistance_SegmentRay(segment.Ptr, ray.Ptr); } public static double SqrDistance(Segment2 segment, Segment2 segment2) { return Intersections_Geometry_EEK_SqrDistance_SegmentSegment(segment.Ptr, segment2.Ptr); } public static double SqrDistance(Segment2 segment, Triangle2 triangle) { return Intersections_Geometry_EEK_SqrDistance_SegmentTriangle(segment.Ptr, triangle.Ptr); } /// -------------------------------------------------------- /// /// The Triangle SqrDistance functions /// /// ----------------------------------------------------- public static double SqrDistance(Triangle2 triangle, Point2 point) { return Intersections_Geometry_EEK_SqrDistance_TrianglePoint(triangle.Ptr, point.Ptr); } public static double SqrDistance(Triangle2 triangle, Line2 line) { return Intersections_Geometry_EEK_SqrDistance_TriangleLine(triangle.Ptr, line.Ptr); } public static double SqrDistance(Triangle2 triangle, Ray2 ray) { return Intersections_Geometry_EEK_SqrDistance_TriangleRay(triangle.Ptr, ray.Ptr); } public static double SqrDistance(Triangle2 triangle, Segment2 segment) { return Intersections_Geometry_EEK_SqrDistance_TriangleSegment(triangle.Ptr, segment.Ptr); } public static double SqrDistance(Triangle2 triangle, Triangle2 triangle2) { return Intersections_Geometry_EEK_SqrDistance_TriangleTriangle(triangle.Ptr, triangle2.Ptr); } /// -------------------------------------------------------- /// /// The Point DoIntersect extern functions /// /// ------------------------------------------------------ [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool Intersections_Geometry_EEK_DoIntersect_PointLine(IntPtr point, IntPtr line); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool Intersections_Geometry_EEK_DoIntersect_PointRay(IntPtr point, IntPtr ray); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool Intersections_Geometry_EEK_DoIntersect_PointSegment(IntPtr point, IntPtr segment); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool Intersections_Geometry_EEK_DoIntersect_PointTriangle(IntPtr point, IntPtr triangle); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool Intersections_Geometry_EEK_DoIntersect_PointBox(IntPtr point, IntPtr box); /// -------------------------------------------------------- /// /// The Linet DoIntersect extern functions /// /// ------------------------------------------------------ [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool Intersections_Geometry_EEK_DoIntersect_LinePoint(IntPtr line, IntPtr point); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool Intersections_Geometry_EEK_DoIntersect_LineLine(IntPtr line, IntPtr line2); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool Intersections_Geometry_EEK_DoIntersect_LineRay(IntPtr line, IntPtr ray); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool Intersections_Geometry_EEK_DoIntersect_LineSegment(IntPtr line, IntPtr segment); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool Intersections_Geometry_EEK_DoIntersect_LineTriangle(IntPtr line, IntPtr triangle); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool Intersections_Geometry_EEK_DoIntersect_LineBox(IntPtr line, IntPtr box); /// -------------------------------------------------------- /// /// The Ray DoIntersect extern functions /// /// ------------------------------------------------------ [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool Intersections_Geometry_EEK_DoIntersect_RayPoint(IntPtr ray, IntPtr point); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool Intersections_Geometry_EEK_DoIntersect_RayLine(IntPtr ray, IntPtr line); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool Intersections_Geometry_EEK_DoIntersect_RayRay(IntPtr ray, IntPtr ray2); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool Intersections_Geometry_EEK_DoIntersect_RaySegment(IntPtr ray, IntPtr segment); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool Intersections_Geometry_EEK_DoIntersect_RayTriangle(IntPtr ray, IntPtr triangle); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool Intersections_Geometry_EEK_DoIntersect_RayBox(IntPtr ray, IntPtr box); /// -------------------------------------------------------- /// /// The Segment DoIntersect extern functions /// /// ------------------------------------------------------ [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool Intersections_Geometry_EEK_DoIntersect_SegmentPoint(IntPtr segment, IntPtr point); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool Intersections_Geometry_EEK_DoIntersect_SegmentLine(IntPtr segment, IntPtr line); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool Intersections_Geometry_EEK_DoIntersect_SegmentRay(IntPtr segment, IntPtr ray); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool Intersections_Geometry_EEK_DoIntersect_SegmentSegment(IntPtr segment, IntPtr segment2); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool Intersections_Geometry_EEK_DoIntersect_SegmentTriangle(IntPtr segment, IntPtr triangle); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool Intersections_Geometry_EEK_DoIntersect_SegmentBox(IntPtr segment, IntPtr box); /// -------------------------------------------------------- /// /// The Triangle DoIntersect extern functions /// /// ------------------------------------------------------ [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool Intersections_Geometry_EEK_DoIntersect_TrianglePoint(IntPtr triangle, IntPtr point); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool Intersections_Geometry_EEK_DoIntersect_TriangleLine(IntPtr triangle, IntPtr line); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool Intersections_Geometry_EEK_DoIntersect_TriangleRay(IntPtr triangle, IntPtr ray); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool Intersections_Geometry_EEK_DoIntersect_TriangleSegment(IntPtr triangle, IntPtr segment); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool Intersections_Geometry_EEK_DoIntersect_TriangleTriangle(IntPtr triangle, IntPtr triangle2); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool Intersections_Geometry_EEK_DoIntersect_TriangleBox(IntPtr triangle, IntPtr box); /// -------------------------------------------------------- /// /// The Box DoIntersect extern functions /// /// ------------------------------------------------------ [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool Intersections_Geometry_EEK_DoIntersect_BoxPoint(IntPtr box, IntPtr point); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool Intersections_Geometry_EEK_DoIntersect_BoxLine(IntPtr box, IntPtr line); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool Intersections_Geometry_EEK_DoIntersect_BoxRay(IntPtr box, IntPtr ray); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool Intersections_Geometry_EEK_DoIntersect_BoxSegment(IntPtr box, IntPtr segment); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool Intersections_Geometry_EEK_DoIntersect_BoxTriangle(IntPtr box, IntPtr triangle); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool Intersections_Geometry_EEK_DoIntersect_BoxBox(IntPtr box, IntPtr box2); /// -------------------------------------------------------- /// /// The Point Intersection extern functions /// /// ------------------------------------------------------- [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntersectionResult2d Intersections_Geometry_EEK_Intersection_PointLine(IntPtr point, IntPtr line); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntersectionResult2d Intersections_Geometry_EEK_Intersection_PointRay(IntPtr point, IntPtr ray); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntersectionResult2d Intersections_Geometry_EEK_Intersection_PointSegment(IntPtr point, IntPtr segment); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntersectionResult2d Intersections_Geometry_EEK_Intersection_PointTriangle(IntPtr point, IntPtr triangle); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntersectionResult2d Intersections_Geometry_EEK_Intersection_PointBox(IntPtr point, IntPtr box); /// -------------------------------------------------------- /// /// The Line Intersection extern functions /// /// ------------------------------------------------------- [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntersectionResult2d Intersections_Geometry_EEK_Intersection_LinePoint(IntPtr line, IntPtr point); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntersectionResult2d Intersections_Geometry_EEK_Intersection_LineLine(IntPtr line, IntPtr line2); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntersectionResult2d Intersections_Geometry_EEK_Intersection_LineRay(IntPtr line, IntPtr ray); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntersectionResult2d Intersections_Geometry_EEK_Intersection_LineSegment(IntPtr line, IntPtr segment); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntersectionResult2d Intersections_Geometry_EEK_Intersection_LineTriangle(IntPtr line, IntPtr triangle); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntersectionResult2d Intersections_Geometry_EEK_Intersection_LineBox(IntPtr line, IntPtr box); /// -------------------------------------------------------- /// /// The Ray Intersection extern functions /// /// ------------------------------------------------------- [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntersectionResult2d Intersections_Geometry_EEK_Intersection_RayPoint(IntPtr ray, IntPtr point); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntersectionResult2d Intersections_Geometry_EEK_Intersection_RayLine(IntPtr ray, IntPtr line); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntersectionResult2d Intersections_Geometry_EEK_Intersection_RayRay(IntPtr ray, IntPtr ray2); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntersectionResult2d Intersections_Geometry_EEK_Intersection_RaySegment(IntPtr ray, IntPtr segment); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntersectionResult2d Intersections_Geometry_EEK_Intersection_RayTriangle(IntPtr ray, IntPtr triangle); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntersectionResult2d Intersections_Geometry_EEK_Intersection_RayBox(IntPtr ray, IntPtr box); /// -------------------------------------------------------- /// /// The Segment Intersection extern functions /// /// ------------------------------------------------------- [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntersectionResult2d Intersections_Geometry_EEK_Intersection_SegmentPoint(IntPtr segment, IntPtr point); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntersectionResult2d Intersections_Geometry_EEK_Intersection_SegmentLine(IntPtr segment, IntPtr line); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntersectionResult2d Intersections_Geometry_EEK_Intersection_SegmentRay(IntPtr segment, IntPtr ray); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntersectionResult2d Intersections_Geometry_EEK_Intersection_SegmentSegment(IntPtr segment, IntPtr segment2); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntersectionResult2d Intersections_Geometry_EEK_Intersection_SegmentTriangle(IntPtr segment, IntPtr triangle); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntersectionResult2d Intersections_Geometry_EEK_Intersection_SegmentBox(IntPtr segment, IntPtr box); /// -------------------------------------------------------- /// /// The Triangle Intersection extern functions /// /// ------------------------------------------------------- [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntersectionResult2d Intersections_Geometry_EEK_Intersection_TrianglePoint(IntPtr triangle, IntPtr point); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntersectionResult2d Intersections_Geometry_EEK_Intersection_TriangleLine(IntPtr triangle, IntPtr line); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntersectionResult2d Intersections_Geometry_EEK_Intersection_TriangleRay(IntPtr triangle, IntPtr ray); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntersectionResult2d Intersections_Geometry_EEK_Intersection_TriangleSegment(IntPtr triangle, IntPtr segment); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntersectionResult2d Intersections_Geometry_EEK_Intersection_TriangleTriangle(IntPtr triangle, IntPtr triangle2); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntersectionResult2d Intersections_Geometry_EEK_Intersection_TriangleBox(IntPtr triangle, IntPtr box); /// -------------------------------------------------------- /// /// The Box Intersection extern functions /// /// ------------------------------------------------------- [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntersectionResult2d Intersections_Geometry_EEK_Intersection_BoxPoint(IntPtr box, IntPtr point); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntersectionResult2d Intersections_Geometry_EEK_Intersection_BoxLine(IntPtr box, IntPtr line); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntersectionResult2d Intersections_Geometry_EEK_Intersection_BoxRay(IntPtr box, IntPtr ray); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntersectionResult2d Intersections_Geometry_EEK_Intersection_BoxSegment(IntPtr box, IntPtr segment); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntersectionResult2d Intersections_Geometry_EEK_Intersection_BoxTriangle(IntPtr box, IntPtr triangle); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntersectionResult2d Intersections_Geometry_EEK_Intersection_BoxBox(IntPtr box, IntPtr box2); /// -------------------------------------------------------- /// /// The Point SqrDistance extern functions /// /// ------------------------------------------------------- [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern double Intersections_Geometry_EEK_SqrDistance_PointPoint(IntPtr point, IntPtr point2); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern double Intersections_Geometry_EEK_SqrDistance_PointLine(IntPtr point, IntPtr line); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern double Intersections_Geometry_EEK_SqrDistance_PointRay(IntPtr point, IntPtr ray); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern double Intersections_Geometry_EEK_SqrDistance_PointSegment(IntPtr point, IntPtr seg); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern double Intersections_Geometry_EEK_SqrDistance_PointTriangle(IntPtr point, IntPtr tri); /// -------------------------------------------------------- /// /// The Line SqrDistance extern functions /// /// ------------------------------------------------------ [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern double Intersections_Geometry_EEK_SqrDistance_LinePoint(IntPtr line, IntPtr point); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern double Intersections_Geometry_EEK_SqrDistance_LineLine(IntPtr line, IntPtr line2); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern double Intersections_Geometry_EEK_SqrDistance_LineRay(IntPtr line, IntPtr ray); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern double Intersections_Geometry_EEK_SqrDistance_LineSegment(IntPtr line, IntPtr segment); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern double Intersections_Geometry_EEK_SqrDistance_LineTriangle(IntPtr line, IntPtr triangle); /// -------------------------------------------------------- /// /// The Ray SqrDistance extern functions /// /// ------------------------------------------------------ [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern double Intersections_Geometry_EEK_SqrDistance_RayPoint(IntPtr ray, IntPtr point); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern double Intersections_Geometry_EEK_SqrDistance_RayLine(IntPtr ray, IntPtr line2); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern double Intersections_Geometry_EEK_SqrDistance_RayRay(IntPtr ray, IntPtr ray2); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern double Intersections_Geometry_EEK_SqrDistance_RaySegment(IntPtr ray, IntPtr segment); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern double Intersections_Geometry_EEK_SqrDistance_RayTriangle(IntPtr ray, IntPtr triangle); /// -------------------------------------------------------- /// /// The Segment SqrDistance extern functions /// /// ------------------------------------------------------ [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern double Intersections_Geometry_EEK_SqrDistance_SegmentPoint(IntPtr segment, IntPtr point); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern double Intersections_Geometry_EEK_SqrDistance_SegmentLine(IntPtr segment, IntPtr line2); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern double Intersections_Geometry_EEK_SqrDistance_SegmentRay(IntPtr segment, IntPtr ray); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern double Intersections_Geometry_EEK_SqrDistance_SegmentSegment(IntPtr segment, IntPtr segment2); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern double Intersections_Geometry_EEK_SqrDistance_SegmentTriangle(IntPtr segment, IntPtr triangle); /// -------------------------------------------------------- /// /// The Triangle SqrDistance extern functions /// /// ------------------------------------------------------ [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern double Intersections_Geometry_EEK_SqrDistance_TrianglePoint(IntPtr triangle, IntPtr point); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern double Intersections_Geometry_EEK_SqrDistance_TriangleLine(IntPtr triangle, IntPtr line2); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern double Intersections_Geometry_EEK_SqrDistance_TriangleRay(IntPtr triangle, IntPtr ray); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern double Intersections_Geometry_EEK_SqrDistance_TriangleSegment(IntPtr triangle, IntPtr segment); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern double Intersections_Geometry_EEK_SqrDistance_TriangleTriangle(IntPtr triangle, IntPtr triangle2); } } ================================================ FILE: CGALDotNet/Geometry/CGALIntersections_Geometry_EIK.cs ================================================ using System; using System.Collections.Generic; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using CGALDotNetGeometry.Numerics; using CGALDotNetGeometry.Shapes; namespace CGALDotNet.Geometry { /// /// The static intersection class. /// public static partial class CGALIntersections { /// -------------------------------------------------------- /// /// The Point DoIntersect functions /// /// -------------------------------------------------------- public static bool DoIntersect(Point2 point, Line2 line) { return Intersections_Geometry_EIK_DoIntersect_PointLine(point.Ptr, line.Ptr); } public static bool DoIntersect(Point2 point, Ray2 ray) { return Intersections_Geometry_EIK_DoIntersect_PointRay(point.Ptr, ray.Ptr); } public static bool DoIntersect(Point2 point, Segment2 segment) { return Intersections_Geometry_EIK_DoIntersect_PointSegment(point.Ptr, segment.Ptr); } public static bool DoIntersect(Point2 point, Triangle2 triangle) { return Intersections_Geometry_EIK_DoIntersect_PointTriangle(point.Ptr, triangle.Ptr); } public static bool DoIntersect(Point2 point, Box2 box) { return Intersections_Geometry_EIK_DoIntersect_PointBox(point.Ptr, box.Ptr); } /// -------------------------------------------------------- /// /// The Line DoIntersect functions /// /// -------------------------------------------------------- public static bool DoIntersect(Line2 line, Point2 point) { return Intersections_Geometry_EIK_DoIntersect_LinePoint(line.Ptr, point.Ptr); } public static bool DoIntersect(Line2 line, Line2 line2) { return Intersections_Geometry_EIK_DoIntersect_LineLine(line.Ptr, line2.Ptr); } public static bool DoIntersect(Line2 line, Ray2 ray) { return Intersections_Geometry_EIK_DoIntersect_LineRay(line.Ptr, ray.Ptr); } public static bool DoIntersect(Line2 line, Segment2 segment) { return Intersections_Geometry_EIK_DoIntersect_LineSegment(line.Ptr, segment.Ptr); } public static bool DoIntersect(Line2 line, Triangle2 triangle) { return Intersections_Geometry_EIK_DoIntersect_LineTriangle(line.Ptr, triangle.Ptr); } public static bool DoIntersect(Line2 line, Box2 box) { return Intersections_Geometry_EIK_DoIntersect_LineBox(line.Ptr, box.Ptr); } /// -------------------------------------------------------- /// /// The Ray DoIntersect functions /// /// -------------------------------------------------------- public static bool DoIntersect(Ray2 ray, Point2 point) { return Intersections_Geometry_EIK_DoIntersect_RayPoint(ray.Ptr, point.Ptr); } public static bool DoIntersect(Ray2 ray, Line2 line) { return Intersections_Geometry_EIK_DoIntersect_RayLine(ray.Ptr, line.Ptr); } public static bool DoIntersect(Ray2 ray, Ray2 ray2) { return Intersections_Geometry_EIK_DoIntersect_RayRay(ray.Ptr, ray2.Ptr); } public static bool DoIntersect(Ray2 ray, Segment2 segment) { return Intersections_Geometry_EIK_DoIntersect_RaySegment(ray.Ptr, segment.Ptr); } public static bool DoIntersect(Ray2 ray, Triangle2 triangle) { return Intersections_Geometry_EIK_DoIntersect_RayTriangle(ray.Ptr, triangle.Ptr); } public static bool DoIntersect(Ray2 ray, Box2 box) { return Intersections_Geometry_EIK_DoIntersect_RayBox(ray.Ptr, box.Ptr); } /// -------------------------------------------------------- /// /// The Segment DoIntersect functions /// /// -------------------------------------------------------- public static bool DoIntersect(Segment2 segment, Point2 point) { return Intersections_Geometry_EIK_DoIntersect_SegmentPoint(segment.Ptr, point.Ptr); } public static bool DoIntersect(Segment2 segment, Line2 line) { return Intersections_Geometry_EIK_DoIntersect_SegmentLine(segment.Ptr, line.Ptr); } public static bool DoIntersect(Segment2 segment, Ray2 ray) { return Intersections_Geometry_EIK_DoIntersect_SegmentRay(segment.Ptr, ray.Ptr); } public static bool DoIntersect(Segment2 segment, Segment2 segment2) { return Intersections_Geometry_EIK_DoIntersect_SegmentSegment(segment.Ptr, segment2.Ptr); } public static bool DoIntersect(Segment2 segment, Triangle2 triangle) { return Intersections_Geometry_EIK_DoIntersect_SegmentTriangle(segment.Ptr, triangle.Ptr); } public static bool DoIntersect(Segment2 segment, Box2 box) { return Intersections_Geometry_EIK_DoIntersect_SegmentBox(segment.Ptr, box.Ptr); } /// -------------------------------------------------------- /// /// The Triangle DoIntersect functions /// /// -------------------------------------------------------- public static bool DoIntersect(Triangle2 triangle, Point2 point) { return Intersections_Geometry_EIK_DoIntersect_TrianglePoint(triangle.Ptr, point.Ptr); } public static bool DoIntersect(Triangle2 triangle, Line2 line) { return Intersections_Geometry_EIK_DoIntersect_TriangleLine(triangle.Ptr, line.Ptr); } public static bool DoIntersect(Triangle2 triangle, Ray2 ray) { return Intersections_Geometry_EIK_DoIntersect_TriangleRay(triangle.Ptr, ray.Ptr); } public static bool DoIntersect(Triangle2 triangle, Segment2 segment) { return Intersections_Geometry_EIK_DoIntersect_TriangleSegment(triangle.Ptr, segment.Ptr); } public static bool DoIntersect(Triangle2 triangle, Triangle2 triangle2) { return Intersections_Geometry_EIK_DoIntersect_TriangleTriangle(triangle.Ptr, triangle2.Ptr); } public static bool DoIntersect(Triangle2 triangle, Box2 box) { return Intersections_Geometry_EIK_DoIntersect_TriangleBox(triangle.Ptr, box.Ptr); } /// -------------------------------------------------------- /// /// The Box DoIntersect functions /// /// -------------------------------------------------------- public static bool DoIntersect(Box2 box, Point2 point) { return Intersections_Geometry_EIK_DoIntersect_BoxPoint(box.Ptr, point.Ptr); } public static bool DoIntersect(Box2 box, Line2 line) { return Intersections_Geometry_EIK_DoIntersect_BoxLine(box.Ptr, line.Ptr); } public static bool DoIntersect(Box2 box, Ray2 ray) { return Intersections_Geometry_EIK_DoIntersect_BoxRay(box.Ptr, ray.Ptr); } public static bool DoIntersect(Box2 box, Segment2 segment) { return Intersections_Geometry_EIK_DoIntersect_BoxSegment(box.Ptr, segment.Ptr); } public static bool DoIntersect(Box2 box, Triangle2 triangle) { return Intersections_Geometry_EIK_DoIntersect_BoxTriangle(box.Ptr, triangle.Ptr); } public static bool DoIntersect(Box2 box, Box2 box2) { return Intersections_Geometry_EIK_DoIntersect_BoxBox(box.Ptr, box2.Ptr); } /// -------------------------------------------------------- /// /// The Point Intersection functions /// /// -------------------------------------------------------- public static IntersectionResult2d Intersection(Point2 point, Line2 line) { return Intersections_Geometry_EIK_Intersection_PointLine(point.Ptr, line.Ptr); } public static IntersectionResult2d Intersection(Point2 point, Ray2 ray) { return Intersections_Geometry_EIK_Intersection_PointRay(point.Ptr, ray.Ptr); } public static IntersectionResult2d Intersection(Point2 point, Segment2 segment) { return Intersections_Geometry_EIK_Intersection_PointSegment(point.Ptr, segment.Ptr); } public static IntersectionResult2d Intersection(Point2 point, Triangle2 triangle) { return Intersections_Geometry_EIK_Intersection_PointTriangle(point.Ptr, triangle.Ptr); } public static IntersectionResult2d Intersection(Point2 point, Box2 box) { return Intersections_Geometry_EIK_Intersection_PointBox(point.Ptr, box.Ptr); } /// -------------------------------------------------------- /// /// The Line Intersection functions /// /// ----------------------------------------------------- public static IntersectionResult2d Intersection(Line2 line, Point2 point) { return Intersections_Geometry_EIK_Intersection_LinePoint(line.Ptr, point.Ptr); } public static IntersectionResult2d Intersection(Line2 line, Line2 line2) { return Intersections_Geometry_EIK_Intersection_LineLine(line.Ptr, line2.Ptr); } public static IntersectionResult2d Intersection(Line2 line, Ray2 ray) { return Intersections_Geometry_EIK_Intersection_LineRay(line.Ptr, ray.Ptr); } public static IntersectionResult2d Intersection(Line2 line, Segment2 segment) { return Intersections_Geometry_EIK_Intersection_LineSegment(line.Ptr, segment.Ptr); } public static IntersectionResult2d Intersection(Line2 line, Triangle2 triangle) { return Intersections_Geometry_EIK_Intersection_LineTriangle(line.Ptr, triangle.Ptr); } public static IntersectionResult2d Intersection(Line2 line, Box2 box) { return Intersections_Geometry_EIK_Intersection_LineBox(line.Ptr, box.Ptr); } /// -------------------------------------------------------- /// /// The Ray Intersection functions /// /// ----------------------------------------------------- public static IntersectionResult2d Intersection(Ray2 ray, Point2 point) { return Intersections_Geometry_EIK_Intersection_RayPoint(ray.Ptr, point.Ptr); } public static IntersectionResult2d Intersection(Ray2 ray, Line2 line) { return Intersections_Geometry_EIK_Intersection_RayLine(ray.Ptr, line.Ptr); } public static IntersectionResult2d Intersection(Ray2 ray, Ray2 ray2) { return Intersections_Geometry_EIK_Intersection_RayRay(ray.Ptr, ray2.Ptr); } public static IntersectionResult2d Intersection(Ray2 ray, Segment2 segment) { return Intersections_Geometry_EIK_Intersection_RaySegment(ray.Ptr, segment.Ptr); } public static IntersectionResult2d Intersection(Ray2 ray, Triangle2 triangle) { return Intersections_Geometry_EIK_Intersection_RayTriangle(ray.Ptr, triangle.Ptr); } public static IntersectionResult2d Intersection(Ray2 ray, Box2 box) { return Intersections_Geometry_EIK_Intersection_RayBox(ray.Ptr, box.Ptr); } /// -------------------------------------------------------- /// /// The Segment Intersection functions /// /// ----------------------------------------------------- public static IntersectionResult2d Intersection(Segment2 segment, Point2 point) { return Intersections_Geometry_EIK_Intersection_SegmentPoint(segment.Ptr, point.Ptr); } public static IntersectionResult2d Intersection(Segment2 segment, Line2 line) { return Intersections_Geometry_EIK_Intersection_SegmentLine(segment.Ptr, line.Ptr); } public static IntersectionResult2d Intersection(Segment2 segment, Ray2 ray) { return Intersections_Geometry_EIK_Intersection_SegmentRay(segment.Ptr, ray.Ptr); } public static IntersectionResult2d Intersection(Segment2 segment, Segment2 segment2) { return Intersections_Geometry_EIK_Intersection_SegmentSegment(segment.Ptr, segment2.Ptr); } public static IntersectionResult2d Intersection(Segment2 segment, Triangle2 triangle) { return Intersections_Geometry_EIK_Intersection_SegmentTriangle(segment.Ptr, triangle.Ptr); } public static IntersectionResult2d Intersection(Segment2 segment, Box2 box) { return Intersections_Geometry_EIK_Intersection_SegmentBox(segment.Ptr, box.Ptr); } /// -------------------------------------------------------- /// /// The Triangle Intersection functions /// /// ----------------------------------------------------- public static IntersectionResult2d Intersection(Triangle2 triangle, Point2 point) { return Intersections_Geometry_EIK_Intersection_TrianglePoint(triangle.Ptr, point.Ptr); } public static IntersectionResult2d Intersection(Triangle2 triangle, Line2 line) { return Intersections_Geometry_EIK_Intersection_TriangleLine(triangle.Ptr, line.Ptr); } public static IntersectionResult2d Intersection(Triangle2 triangle, Ray2 ray) { return Intersections_Geometry_EIK_Intersection_TriangleRay(triangle.Ptr, ray.Ptr); } public static IntersectionResult2d Intersection(Triangle2 triangle, Segment2 segment) { return Intersections_Geometry_EIK_Intersection_TriangleSegment(triangle.Ptr, segment.Ptr); } public static IntersectionResult2d Intersection(Triangle2 triangle, Triangle2 triangle2) { return Intersections_Geometry_EIK_Intersection_TriangleTriangle(triangle.Ptr, triangle2.Ptr); } public static IntersectionResult2d Intersection(Triangle2 triangle, Box2 box) { return Intersections_Geometry_EIK_Intersection_TriangleBox(triangle.Ptr, box.Ptr); } /// -------------------------------------------------------- /// /// The Box Intersection functions /// /// ----------------------------------------------------- public static IntersectionResult2d Intersection(Box2 box, Point2 point) { return Intersections_Geometry_EIK_Intersection_BoxPoint(box.Ptr, point.Ptr); } public static IntersectionResult2d Intersection(Box2 box, Line2 line) { return Intersections_Geometry_EIK_Intersection_BoxLine(box.Ptr, line.Ptr); } public static IntersectionResult2d Intersection(Box2 box, Ray2 ray) { return Intersections_Geometry_EIK_Intersection_BoxRay(box.Ptr, ray.Ptr); } public static IntersectionResult2d Intersection(Box2 box, Segment2 segment) { return Intersections_Geometry_EIK_Intersection_BoxSegment(box.Ptr, segment.Ptr); } public static IntersectionResult2d Intersection(Box2 box, Triangle2 triangle) { return Intersections_Geometry_EIK_Intersection_BoxTriangle(box.Ptr, triangle.Ptr); } public static IntersectionResult2d Intersection(Box2 box, Box2 box2) { return Intersections_Geometry_EIK_Intersection_BoxBox(box.Ptr, box2.Ptr); } /// -------------------------------------------------------- /// /// The Point SqrDistance functions /// /// ----------------------------------------------------- public static double SqrDistance(Point2 point, Point2 point2) { return Intersections_Geometry_EIK_SqrDistance_PointPoint(point.Ptr, point2.Ptr); } public static double SqrDistance(Point2 point, Line2 line) { return Intersections_Geometry_EIK_SqrDistance_PointLine(point.Ptr, line.Ptr); } public static double SqrDistance(Point2 point, Ray2 ray) { return Intersections_Geometry_EIK_SqrDistance_PointRay(point.Ptr, ray.Ptr); } public static double SqrDistance(Point2 point, Segment2 seg) { return Intersections_Geometry_EIK_SqrDistance_PointSegment(point.Ptr, seg.Ptr); } public static double SqrDistance(Point2 point, Triangle2 tri) { return Intersections_Geometry_EIK_SqrDistance_PointTriangle(point.Ptr, tri.Ptr); } /// -------------------------------------------------------- /// /// The Line SqrDistance functions /// /// -------------------------------------------------------- public static double SqrDistance(Line2 line, Point2 point) { return Intersections_Geometry_EIK_SqrDistance_LinePoint(line.Ptr, point.Ptr); } public static double SqrDistance(Line2 line, Line2 line2) { return Intersections_Geometry_EIK_SqrDistance_LineLine(line.Ptr, line2.Ptr); } public static double SqrDistance(Line2 line, Ray2 ray) { return Intersections_Geometry_EIK_SqrDistance_LineRay(line.Ptr, ray.Ptr); } public static double SqrDistance(Line2 line, Segment2 segment) { return Intersections_Geometry_EIK_SqrDistance_LineSegment(line.Ptr, segment.Ptr); } public static double SqrDistance(Line2 line, Triangle2 triangle) { return Intersections_Geometry_EIK_SqrDistance_LineTriangle(line.Ptr, triangle.Ptr); } /// -------------------------------------------------------- /// /// The Ray SqrDistance functions /// /// -------------------------------------------------------- public static double SqrDistance(Ray2 ray, Point2 point) { return Intersections_Geometry_EIK_SqrDistance_RayPoint(ray.Ptr, point.Ptr); } public static double SqrDistance(Ray2 ray, Line2 line) { return Intersections_Geometry_EIK_SqrDistance_RayLine(ray.Ptr, line.Ptr); } public static double SqrDistance(Ray2 ray, Ray2 ray2) { return Intersections_Geometry_EIK_SqrDistance_RayRay(ray.Ptr, ray2.Ptr); } public static double SqrDistance(Ray2 ray, Segment2 segment) { return Intersections_Geometry_EIK_SqrDistance_RaySegment(ray.Ptr, segment.Ptr); } public static double SqrDistance(Ray2 ray, Triangle2 triangle) { return Intersections_Geometry_EIK_SqrDistance_RayTriangle(ray.Ptr, triangle.Ptr); } /// -------------------------------------------------------- /// /// The Segment SqrDistance functions /// /// ----------------------------------------------------- public static double SqrDistance(Segment2 segment, Point2 point) { return Intersections_Geometry_EIK_SqrDistance_SegmentPoint(segment.Ptr, point.Ptr); } public static double SqrDistance(Segment2 segment, Line2 line) { return Intersections_Geometry_EIK_SqrDistance_SegmentLine(segment.Ptr, line.Ptr); } public static double SqrDistance(Segment2 segment, Ray2 ray) { return Intersections_Geometry_EIK_SqrDistance_SegmentRay(segment.Ptr, ray.Ptr); } public static double SqrDistance(Segment2 segment, Segment2 segment2) { return Intersections_Geometry_EIK_SqrDistance_SegmentSegment(segment.Ptr, segment2.Ptr); } public static double SqrDistance(Segment2 segment, Triangle2 triangle) { return Intersections_Geometry_EIK_SqrDistance_SegmentTriangle(segment.Ptr, triangle.Ptr); } /// -------------------------------------------------------- /// /// The Triangle SqrDistance functions /// /// ----------------------------------------------------- public static double SqrDistance(Triangle2 triangle, Point2 point) { return Intersections_Geometry_EIK_SqrDistance_TrianglePoint(triangle.Ptr, point.Ptr); } public static double SqrDistance(Triangle2 triangle, Line2 line) { return Intersections_Geometry_EIK_SqrDistance_TriangleLine(triangle.Ptr, line.Ptr); } public static double SqrDistance(Triangle2 triangle, Ray2 ray) { return Intersections_Geometry_EIK_SqrDistance_TriangleRay(triangle.Ptr, ray.Ptr); } public static double SqrDistance(Triangle2 triangle, Segment2 segment) { return Intersections_Geometry_EIK_SqrDistance_TriangleSegment(triangle.Ptr, segment.Ptr); } public static double SqrDistance(Triangle2 triangle, Triangle2 triangle2) { return Intersections_Geometry_EIK_SqrDistance_TriangleTriangle(triangle.Ptr, triangle2.Ptr); } /// -------------------------------------------------------- /// /// The Point DoIntersect extern functions /// /// ------------------------------------------------------ [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool Intersections_Geometry_EIK_DoIntersect_PointLine(IntPtr point, IntPtr line); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool Intersections_Geometry_EIK_DoIntersect_PointRay(IntPtr point, IntPtr ray); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool Intersections_Geometry_EIK_DoIntersect_PointSegment(IntPtr point, IntPtr segment); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool Intersections_Geometry_EIK_DoIntersect_PointTriangle(IntPtr point, IntPtr triangle); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool Intersections_Geometry_EIK_DoIntersect_PointBox(IntPtr point, IntPtr box); /// -------------------------------------------------------- /// /// The Linet DoIntersect extern functions /// /// ------------------------------------------------------ [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool Intersections_Geometry_EIK_DoIntersect_LinePoint(IntPtr line, IntPtr point); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool Intersections_Geometry_EIK_DoIntersect_LineLine(IntPtr line, IntPtr line2); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool Intersections_Geometry_EIK_DoIntersect_LineRay(IntPtr line, IntPtr ray); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool Intersections_Geometry_EIK_DoIntersect_LineSegment(IntPtr line, IntPtr segment); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool Intersections_Geometry_EIK_DoIntersect_LineTriangle(IntPtr line, IntPtr triangle); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool Intersections_Geometry_EIK_DoIntersect_LineBox(IntPtr line, IntPtr box); /// -------------------------------------------------------- /// /// The Ray DoIntersect extern functions /// /// ------------------------------------------------------ [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool Intersections_Geometry_EIK_DoIntersect_RayPoint(IntPtr ray, IntPtr point); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool Intersections_Geometry_EIK_DoIntersect_RayLine(IntPtr ray, IntPtr line); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool Intersections_Geometry_EIK_DoIntersect_RayRay(IntPtr ray, IntPtr ray2); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool Intersections_Geometry_EIK_DoIntersect_RaySegment(IntPtr ray, IntPtr segment); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool Intersections_Geometry_EIK_DoIntersect_RayTriangle(IntPtr ray, IntPtr triangle); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool Intersections_Geometry_EIK_DoIntersect_RayBox(IntPtr ray, IntPtr box); /// -------------------------------------------------------- /// /// The Segment DoIntersect extern functions /// /// ------------------------------------------------------ [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool Intersections_Geometry_EIK_DoIntersect_SegmentPoint(IntPtr segment, IntPtr point); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool Intersections_Geometry_EIK_DoIntersect_SegmentLine(IntPtr segment, IntPtr line); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool Intersections_Geometry_EIK_DoIntersect_SegmentRay(IntPtr segment, IntPtr ray); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool Intersections_Geometry_EIK_DoIntersect_SegmentSegment(IntPtr segment, IntPtr segment2); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool Intersections_Geometry_EIK_DoIntersect_SegmentTriangle(IntPtr segment, IntPtr triangle); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool Intersections_Geometry_EIK_DoIntersect_SegmentBox(IntPtr segment, IntPtr box); /// -------------------------------------------------------- /// /// The Triangle DoIntersect extern functions /// /// ------------------------------------------------------ [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool Intersections_Geometry_EIK_DoIntersect_TrianglePoint(IntPtr triangle, IntPtr point); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool Intersections_Geometry_EIK_DoIntersect_TriangleLine(IntPtr triangle, IntPtr line); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool Intersections_Geometry_EIK_DoIntersect_TriangleRay(IntPtr triangle, IntPtr ray); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool Intersections_Geometry_EIK_DoIntersect_TriangleSegment(IntPtr triangle, IntPtr segment); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool Intersections_Geometry_EIK_DoIntersect_TriangleTriangle(IntPtr triangle, IntPtr triangle2); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool Intersections_Geometry_EIK_DoIntersect_TriangleBox(IntPtr triangle, IntPtr box); /// -------------------------------------------------------- /// /// The Box DoIntersect extern functions /// /// ------------------------------------------------------ [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool Intersections_Geometry_EIK_DoIntersect_BoxPoint(IntPtr box, IntPtr point); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool Intersections_Geometry_EIK_DoIntersect_BoxLine(IntPtr box, IntPtr line); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool Intersections_Geometry_EIK_DoIntersect_BoxRay(IntPtr box, IntPtr ray); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool Intersections_Geometry_EIK_DoIntersect_BoxSegment(IntPtr box, IntPtr segment); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool Intersections_Geometry_EIK_DoIntersect_BoxTriangle(IntPtr box, IntPtr triangle); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool Intersections_Geometry_EIK_DoIntersect_BoxBox(IntPtr box, IntPtr box2); /// -------------------------------------------------------- /// /// The Point Intersection extern functions /// /// ------------------------------------------------------- [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntersectionResult2d Intersections_Geometry_EIK_Intersection_PointLine(IntPtr point, IntPtr line); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntersectionResult2d Intersections_Geometry_EIK_Intersection_PointRay(IntPtr point, IntPtr ray); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntersectionResult2d Intersections_Geometry_EIK_Intersection_PointSegment(IntPtr point, IntPtr segment); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntersectionResult2d Intersections_Geometry_EIK_Intersection_PointTriangle(IntPtr point, IntPtr triangle); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntersectionResult2d Intersections_Geometry_EIK_Intersection_PointBox(IntPtr point, IntPtr box); /// -------------------------------------------------------- /// /// The Line Intersection extern functions /// /// ------------------------------------------------------- [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntersectionResult2d Intersections_Geometry_EIK_Intersection_LinePoint(IntPtr line, IntPtr point); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntersectionResult2d Intersections_Geometry_EIK_Intersection_LineLine(IntPtr line, IntPtr line2); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntersectionResult2d Intersections_Geometry_EIK_Intersection_LineRay(IntPtr line, IntPtr ray); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntersectionResult2d Intersections_Geometry_EIK_Intersection_LineSegment(IntPtr line, IntPtr segment); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntersectionResult2d Intersections_Geometry_EIK_Intersection_LineTriangle(IntPtr line, IntPtr triangle); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntersectionResult2d Intersections_Geometry_EIK_Intersection_LineBox(IntPtr line, IntPtr box); /// -------------------------------------------------------- /// /// The Ray Intersection extern functions /// /// ------------------------------------------------------- [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntersectionResult2d Intersections_Geometry_EIK_Intersection_RayPoint(IntPtr ray, IntPtr point); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntersectionResult2d Intersections_Geometry_EIK_Intersection_RayLine(IntPtr ray, IntPtr line); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntersectionResult2d Intersections_Geometry_EIK_Intersection_RayRay(IntPtr ray, IntPtr ray2); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntersectionResult2d Intersections_Geometry_EIK_Intersection_RaySegment(IntPtr ray, IntPtr segment); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntersectionResult2d Intersections_Geometry_EIK_Intersection_RayTriangle(IntPtr ray, IntPtr triangle); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntersectionResult2d Intersections_Geometry_EIK_Intersection_RayBox(IntPtr ray, IntPtr box); /// -------------------------------------------------------- /// /// The Segment Intersection extern functions /// /// ------------------------------------------------------- [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntersectionResult2d Intersections_Geometry_EIK_Intersection_SegmentPoint(IntPtr segment, IntPtr point); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntersectionResult2d Intersections_Geometry_EIK_Intersection_SegmentLine(IntPtr segment, IntPtr line); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntersectionResult2d Intersections_Geometry_EIK_Intersection_SegmentRay(IntPtr segment, IntPtr ray); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntersectionResult2d Intersections_Geometry_EIK_Intersection_SegmentSegment(IntPtr segment, IntPtr segment2); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntersectionResult2d Intersections_Geometry_EIK_Intersection_SegmentTriangle(IntPtr segment, IntPtr triangle); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntersectionResult2d Intersections_Geometry_EIK_Intersection_SegmentBox(IntPtr segment, IntPtr box); /// -------------------------------------------------------- /// /// The Triangle Intersection extern functions /// /// ------------------------------------------------------- [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntersectionResult2d Intersections_Geometry_EIK_Intersection_TrianglePoint(IntPtr triangle, IntPtr point); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntersectionResult2d Intersections_Geometry_EIK_Intersection_TriangleLine(IntPtr triangle, IntPtr line); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntersectionResult2d Intersections_Geometry_EIK_Intersection_TriangleRay(IntPtr triangle, IntPtr ray); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntersectionResult2d Intersections_Geometry_EIK_Intersection_TriangleSegment(IntPtr triangle, IntPtr segment); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntersectionResult2d Intersections_Geometry_EIK_Intersection_TriangleTriangle(IntPtr triangle, IntPtr triangle2); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntersectionResult2d Intersections_Geometry_EIK_Intersection_TriangleBox(IntPtr triangle, IntPtr box); /// -------------------------------------------------------- /// /// The Box Intersection extern functions /// /// ------------------------------------------------------- [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntersectionResult2d Intersections_Geometry_EIK_Intersection_BoxPoint(IntPtr box, IntPtr point); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntersectionResult2d Intersections_Geometry_EIK_Intersection_BoxLine(IntPtr box, IntPtr line); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntersectionResult2d Intersections_Geometry_EIK_Intersection_BoxRay(IntPtr box, IntPtr ray); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntersectionResult2d Intersections_Geometry_EIK_Intersection_BoxSegment(IntPtr box, IntPtr segment); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntersectionResult2d Intersections_Geometry_EIK_Intersection_BoxTriangle(IntPtr box, IntPtr triangle); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntersectionResult2d Intersections_Geometry_EIK_Intersection_BoxBox(IntPtr box, IntPtr box2); /// -------------------------------------------------------- /// /// The Point SqrDistance extern functions /// /// ------------------------------------------------------- [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern double Intersections_Geometry_EIK_SqrDistance_PointPoint(IntPtr point, IntPtr point2); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern double Intersections_Geometry_EIK_SqrDistance_PointLine(IntPtr point, IntPtr line); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern double Intersections_Geometry_EIK_SqrDistance_PointRay(IntPtr point, IntPtr ray); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern double Intersections_Geometry_EIK_SqrDistance_PointSegment(IntPtr point, IntPtr seg); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern double Intersections_Geometry_EIK_SqrDistance_PointTriangle(IntPtr point, IntPtr tri); /// -------------------------------------------------------- /// /// The Line SqrDistance extern functions /// /// ------------------------------------------------------ [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern double Intersections_Geometry_EIK_SqrDistance_LinePoint(IntPtr line, IntPtr point); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern double Intersections_Geometry_EIK_SqrDistance_LineLine(IntPtr line, IntPtr line2); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern double Intersections_Geometry_EIK_SqrDistance_LineRay(IntPtr line, IntPtr ray); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern double Intersections_Geometry_EIK_SqrDistance_LineSegment(IntPtr line, IntPtr segment); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern double Intersections_Geometry_EIK_SqrDistance_LineTriangle(IntPtr line, IntPtr triangle); /// -------------------------------------------------------- /// /// The Ray SqrDistance extern functions /// /// ------------------------------------------------------ [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern double Intersections_Geometry_EIK_SqrDistance_RayPoint(IntPtr ray, IntPtr point); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern double Intersections_Geometry_EIK_SqrDistance_RayLine(IntPtr ray, IntPtr line2); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern double Intersections_Geometry_EIK_SqrDistance_RayRay(IntPtr ray, IntPtr ray2); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern double Intersections_Geometry_EIK_SqrDistance_RaySegment(IntPtr ray, IntPtr segment); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern double Intersections_Geometry_EIK_SqrDistance_RayTriangle(IntPtr ray, IntPtr triangle); /// -------------------------------------------------------- /// /// The Segment SqrDistance extern functions /// /// ------------------------------------------------------ [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern double Intersections_Geometry_EIK_SqrDistance_SegmentPoint(IntPtr segment, IntPtr point); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern double Intersections_Geometry_EIK_SqrDistance_SegmentLine(IntPtr segment, IntPtr line2); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern double Intersections_Geometry_EIK_SqrDistance_SegmentRay(IntPtr segment, IntPtr ray); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern double Intersections_Geometry_EIK_SqrDistance_SegmentSegment(IntPtr segment, IntPtr segment2); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern double Intersections_Geometry_EIK_SqrDistance_SegmentTriangle(IntPtr segment, IntPtr triangle); /// -------------------------------------------------------- /// /// The Triangle SqrDistance extern functions /// /// ------------------------------------------------------ [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern double Intersections_Geometry_EIK_SqrDistance_TrianglePoint(IntPtr triangle, IntPtr point); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern double Intersections_Geometry_EIK_SqrDistance_TriangleLine(IntPtr triangle, IntPtr line2); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern double Intersections_Geometry_EIK_SqrDistance_TriangleRay(IntPtr triangle, IntPtr ray); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern double Intersections_Geometry_EIK_SqrDistance_TriangleSegment(IntPtr triangle, IntPtr segment); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern double Intersections_Geometry_EIK_SqrDistance_TriangleTriangle(IntPtr triangle, IntPtr triangle2); } } ================================================ FILE: CGALDotNet/Geometry/CGALIntersections_Shapes.cs ================================================ using System; using System.Collections.Generic; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using CGALDotNet.Polygons; using CGALDotNetGeometry.Numerics; using CGALDotNetGeometry.Shapes; namespace CGALDotNet.Geometry { /// /// The static intersection class. /// public static partial class CGALIntersections { public const string DLL_NAME = "CGALWrapper.dll"; public const CallingConvention CDECL = CallingConvention.Cdecl; /// -------------------------------------------------------- /// /// The Point DoIntersect functions /// /// -------------------------------------------------------- public static bool DoIntersect(Point2d point, Line2d line) { return Intersections_Shapes_EIK_DoIntersect_PointLine(point, line); } public static bool DoIntersect(Point2d point, Ray2d ray) { return Intersections_Shapes_EIK_DoIntersect_PointRay(point, ray); } public static bool DoIntersect(Point2d point, Segment2d segment) { return Intersections_Shapes_EIK_DoIntersect_PointSegment(point, segment); } public static bool DoIntersect(Point2d point, Triangle2d triangle) { return Intersections_Shapes_EIK_DoIntersect_PointTriangle(point, triangle); } public static bool DoIntersect(Point2d point, Box2d box) { return Intersections_Shapes_EIK_DoIntersect_PointBox(point, box); } /// -------------------------------------------------------- /// /// The Line DoIntersect functions /// /// -------------------------------------------------------- public static bool DoIntersect(Line2d line, Point2d point) { return Intersections_Shapes_EIK_DoIntersect_LinePoint(line, point); } public static bool DoIntersect(Line2d line, Line2d line2) { return Intersections_Shapes_EIK_DoIntersect_LineLine(line, line2); } public static bool DoIntersect(Line2d line, Ray2d ray) { return Intersections_Shapes_EIK_DoIntersect_LineRay(line, ray); } public static bool DoIntersect(Line2d line, Segment2d segment) { return Intersections_Shapes_EIK_DoIntersect_LineSegment(line, segment); } public static bool DoIntersect(Line2d line, Triangle2d triangle) { return Intersections_Shapes_EIK_DoIntersect_LineTriangle(line, triangle); } public static bool DoIntersect(Line2d line, Box2d box) { return Intersections_Shapes_EIK_DoIntersect_LineBox(line, box); } /// -------------------------------------------------------- /// /// The Ray DoIntersect functions /// /// -------------------------------------------------------- public static bool DoIntersect(Ray2d ray, Point2d point) { return Intersections_Shapes_EIK_DoIntersect_RayPoint(ray, point); } public static bool DoIntersect(Ray2d ray, Line2d line) { return Intersections_Shapes_EIK_DoIntersect_RayLine(ray, line); } public static bool DoIntersect(Ray2d ray, Ray2d ray2) { return Intersections_Shapes_EIK_DoIntersect_RayRay(ray, ray2); } public static bool DoIntersect(Ray2d ray, Segment2d segment) { return Intersections_Shapes_EIK_DoIntersect_RaySegment(ray, segment); } public static bool DoIntersect(Ray2d ray, Triangle2d triangle) { return Intersections_Shapes_EIK_DoIntersect_RayTriangle(ray, triangle); } public static bool DoIntersect(Ray2d ray, Box2d box) { return Intersections_Shapes_EIK_DoIntersect_RayBox(ray, box); } /// -------------------------------------------------------- /// /// The Segment DoIntersect functions /// /// -------------------------------------------------------- public static bool DoIntersect(Segment2d segment, Point2d point) { return Intersections_Shapes_EIK_DoIntersect_SegmentPoint(segment, point); } public static bool DoIntersect(Segment2d segment, Line2d line) { return Intersections_Shapes_EIK_DoIntersect_SegmentLine(segment, line); } public static bool DoIntersect(Segment2d segment, Ray2d ray) { return Intersections_Shapes_EIK_DoIntersect_SegmentRay(segment, ray); } public static bool DoIntersect(Segment2d segment, Segment2d segment2) { return Intersections_Shapes_EIK_DoIntersect_SegmentSegment(segment, segment2); } public static bool DoIntersect(Segment2d segment, Triangle2d triangle) { return Intersections_Shapes_EIK_DoIntersect_SegmentTriangle(segment, triangle); } public static bool DoIntersect(Segment2d segment, Box2d box) { return Intersections_Shapes_EIK_DoIntersect_SegmentBox(segment, box); } /// -------------------------------------------------------- /// /// The Triangle DoIntersect functions /// /// -------------------------------------------------------- public static bool DoIntersect(Triangle2d triangle, Point2d point) { return Intersections_Shapes_EIK_DoIntersect_TrianglePoint(triangle, point); } public static bool DoIntersect(Triangle2d triangle, Line2d line) { return Intersections_Shapes_EIK_DoIntersect_TriangleLine(triangle, line); } public static bool DoIntersect(Triangle2d triangle, Ray2d ray) { return Intersections_Shapes_EIK_DoIntersect_TriangleRay(triangle, ray); } public static bool DoIntersect(Triangle2d triangle, Segment2d segment) { return Intersections_Shapes_EIK_DoIntersect_TriangleSegment(triangle, segment); } public static bool DoIntersect(Triangle2d triangle, Triangle2d triangle2) { return Intersections_Shapes_EIK_DoIntersect_TriangleTriangle(triangle, triangle2); } public static bool DoIntersect(Triangle2d triangle, Box2d box) { return Intersections_Shapes_EIK_DoIntersect_TriangleBox(triangle, box); } /// -------------------------------------------------------- /// /// The Box DoIntersect functions /// /// -------------------------------------------------------- public static bool DoIntersect(Box2d box, Point2d point) { return Intersections_Shapes_EIK_DoIntersect_BoxPoint(box, point); } public static bool DoIntersect(Box2d box, Line2d line) { return Intersections_Shapes_EIK_DoIntersect_BoxLine(box, line); } public static bool DoIntersect(Box2d box, Ray2d ray) { return Intersections_Shapes_EIK_DoIntersect_BoxRay(box, ray); } public static bool DoIntersect(Box2d box, Segment2d segment) { return Intersections_Shapes_EIK_DoIntersect_BoxSegment(box, segment); } public static bool DoIntersect(Box2d box, Triangle2d triangle) { return Intersections_Shapes_EIK_DoIntersect_BoxTriangle(box, triangle); } public static bool DoIntersect(Box2d box, Box2d boxd) { return Intersections_Shapes_EIK_DoIntersect_BoxBox(box, boxd); } /// -------------------------------------------------------- /// /// The Point Intersection functions /// /// -------------------------------------------------------- public static IntersectionResult2d Intersection(Point2d point, Line2d line) { return Intersections_Shapes_EIK_Intersection_PointLine(point, line); } public static IntersectionResult2d Intersection(Point2d point, Ray2d ray) { return Intersections_Shapes_EIK_Intersection_PointRay(point, ray); } public static IntersectionResult2d Intersection(Point2d point, Segment2d segment) { return Intersections_Shapes_EIK_Intersection_PointSegment(point, segment); } public static IntersectionResult2d Intersection(Point2d point, Triangle2d triangle) { return Intersections_Shapes_EIK_Intersection_PointTriangle(point, triangle); } public static IntersectionResult2d Intersection(Point2d point, Box2d box) { return Intersections_Shapes_EIK_Intersection_PointBox(point, box); } /// -------------------------------------------------------- /// /// The Line Intersection functions /// /// ----------------------------------------------------- public static IntersectionResult2d Intersection(Line2d line, Point2d point) { return Intersections_Shapes_EIK_Intersection_LinePoint(line, point); } public static IntersectionResult2d Intersection(Line2d line, Line2d line2) { return Intersections_Shapes_EIK_Intersection_LineLine(line, line2); } public static IntersectionResult2d Intersection(Line2d line, Ray2d ray) { return Intersections_Shapes_EIK_Intersection_LineRay(line, ray); } public static IntersectionResult2d Intersection(Line2d line, Segment2d segment) { return Intersections_Shapes_EIK_Intersection_LineSegment(line, segment); } public static IntersectionResult2d Intersection(Line2d line, Triangle2d triangle) { return Intersections_Shapes_EIK_Intersection_LineTriangle(line, triangle); } public static IntersectionResult2d Intersection(Line2d line, Box2d box) { return Intersections_Shapes_EIK_Intersection_LineBox(line, box); } /// -------------------------------------------------------- /// /// The Ray Intersection functions /// /// ----------------------------------------------------- public static IntersectionResult2d Intersection(Ray2d ray, Point2d point) { return Intersections_Shapes_EIK_Intersection_RayPoint(ray, point); } public static IntersectionResult2d Intersection(Ray2d ray, Line2d line) { return Intersections_Shapes_EIK_Intersection_RayLine(ray, line); } public static IntersectionResult2d Intersection(Ray2d ray, Ray2d ray2) { return Intersections_Shapes_EIK_Intersection_RayRay(ray, ray2); } public static IntersectionResult2d Intersection(Ray2d ray, Segment2d segment) { return Intersections_Shapes_EIK_Intersection_RaySegment(ray, segment); } public static IntersectionResult2d Intersection(Ray2d ray, Triangle2d triangle) { return Intersections_Shapes_EIK_Intersection_RayTriangle(ray, triangle); } public static IntersectionResult2d Intersection(Ray2d ray, Box2d box) { return Intersections_Shapes_EIK_Intersection_RayBox(ray, box); } /// -------------------------------------------------------- /// /// The Segment Intersection functions /// /// ----------------------------------------------------- public static IntersectionResult2d Intersection(Segment2d segment, Point2d point) { return Intersections_Shapes_EIK_Intersection_SegmentPoint(segment, point); } public static IntersectionResult2d Intersection(Segment2d segment, Line2d line) { return Intersections_Shapes_EIK_Intersection_SegmentLine(segment, line); } public static IntersectionResult2d Intersection(Segment2d segment, Ray2d ray) { return Intersections_Shapes_EIK_Intersection_SegmentRay(segment, ray); } public static IntersectionResult2d Intersection(Segment2d segment, Segment2d segment2) { return Intersections_Shapes_EIK_Intersection_SegmentSegment(segment, segment2); } public static IntersectionResult2d Intersection(Segment2d segment, Triangle2d triangle) { return Intersections_Shapes_EIK_Intersection_SegmentTriangle(segment, triangle); } public static IntersectionResult2d Intersection(Segment2d segment, Box2d box) { return Intersections_Shapes_EIK_Intersection_SegmentBox(segment, box); } /// -------------------------------------------------------- /// /// The Triangle Intersection functions /// /// ----------------------------------------------------- public static IntersectionResult2d Intersection(Triangle2d triangle, Point2d point) { return Intersections_Shapes_EIK_Intersection_TrianglePoint(triangle, point); } public static IntersectionResult2d Intersection(Triangle2d triangle, Line2d line) { return Intersections_Shapes_EIK_Intersection_TriangleLine(triangle, line); } public static IntersectionResult2d Intersection(Triangle2d triangle, Ray2d ray) { return Intersections_Shapes_EIK_Intersection_TriangleRay(triangle, ray); } public static IntersectionResult2d Intersection(Triangle2d triangle, Segment2d segment) { return Intersections_Shapes_EIK_Intersection_TriangleSegment(triangle, segment); } public static IntersectionResult2d Intersection(Triangle2d triangle, Triangle2d triangle2) { return Intersections_Shapes_EIK_Intersection_TriangleTriangle(triangle, triangle2); } public static IntersectionResult2d Intersection(Triangle2d triangle, Box2d box) { return Intersections_Shapes_EIK_Intersection_TriangleBox(triangle, box); } /// -------------------------------------------------------- /// /// The Box Intersection functions /// /// ----------------------------------------------------- public static IntersectionResult2d Intersection(Box2d box, Point2d point) { return Intersections_Shapes_EIK_Intersection_BoxPoint(box, point); } public static IntersectionResult2d Intersection(Box2d box, Line2d line) { return Intersections_Shapes_EIK_Intersection_BoxLine(box, line); } public static IntersectionResult2d Intersection(Box2d box, Ray2d ray) { return Intersections_Shapes_EIK_Intersection_BoxRay(box, ray); } public static IntersectionResult2d Intersection(Box2d box, Segment2d segment) { return Intersections_Shapes_EIK_Intersection_BoxSegment(box, segment); } public static IntersectionResult2d Intersection(Box2d box, Triangle2d triangle) { return Intersections_Shapes_EIK_Intersection_BoxTriangle(box, triangle); } public static IntersectionResult2d Intersection(Box2d box, Box2d boxd) { return Intersections_Shapes_EIK_Intersection_BoxBox(box, boxd); } /// -------------------------------------------------------- /// /// The Point SqrDistance functions /// /// ----------------------------------------------------- public static double SqrDistance(Point2d point, Point2d point2) { return Intersections_Shapes_EIK_SqrDistance_PointPoint(point, point2); } public static double SqrDistance(Point2d point, Line2d line) { return Intersections_Shapes_EIK_SqrDistance_PointLine(point, line); } public static double SqrDistance(Point2d point, Ray2d ray) { return Intersections_Shapes_EIK_SqrDistance_PointRay(point, ray); } public static double SqrDistance(Point2d point, Segment2d seg) { return Intersections_Shapes_EIK_SqrDistance_PointSegment(point, seg); } public static double SqrDistance(Point2d point, Triangle2d tri) { return Intersections_Shapes_EIK_SqrDistance_PointTriangle(point, tri); } /// -------------------------------------------------------- /// /// The Line SqrDistance functions /// /// -------------------------------------------------------- public static double SqrDistance(Line2d line, Point2d point) { return Intersections_Shapes_EIK_SqrDistance_LinePoint(line, point); } public static double SqrDistance(Line2d line, Line2d line2) { return Intersections_Shapes_EIK_SqrDistance_LineLine(line, line2); } public static double SqrDistance(Line2d line, Ray2d ray) { return Intersections_Shapes_EIK_SqrDistance_LineRay(line, ray); } public static double SqrDistance(Line2d line, Segment2d segment) { return Intersections_Shapes_EIK_SqrDistance_LineSegment(line, segment); } public static double SqrDistance(Line2d line, Triangle2d triangle) { return Intersections_Shapes_EIK_SqrDistance_LineTriangle(line, triangle); } /// -------------------------------------------------------- /// /// The Ray SqrDistance functions /// /// -------------------------------------------------------- public static double SqrDistance(Ray2d ray, Line2d line) { return Intersections_Shapes_EIK_SqrDistance_RayLine(ray, line); } public static double SqrDistance(Ray2d ray, Ray2d ray2) { return Intersections_Shapes_EIK_SqrDistance_RayRay(ray, ray2); } public static double SqrDistance(Ray2d ray, Segment2d segment) { return Intersections_Shapes_EIK_SqrDistance_RaySegment(ray, segment); } public static double SqrDistance(Ray2d ray, Triangle2d triangle) { return Intersections_Shapes_EIK_SqrDistance_RayTriangle(ray, triangle); } /// -------------------------------------------------------- /// /// The Segment SqrDistance functions /// /// ----------------------------------------------------- public static double SqrDistance(Segment2d segment, Point2d point) { return Intersections_Shapes_EIK_SqrDistance_SegmentPoint(segment, point); } public static double SqrDistance(Segment2d segment, Line2d line) { return Intersections_Shapes_EIK_SqrDistance_SegmentLine(segment, line); } public static double SqrDistance(Segment2d segment, Ray2d ray) { return Intersections_Shapes_EIK_SqrDistance_SegmentRay(segment, ray); } public static double SqrDistance(Segment2d segment, Segment2d segment2) { return Intersections_Shapes_EIK_SqrDistance_SegmentSegment(segment, segment2); } public static double SqrDistance(Segment2d segment, Triangle2d triangle) { return Intersections_Shapes_EIK_SqrDistance_SegmentTriangle(segment, triangle); } /// -------------------------------------------------------- /// /// The Triangle SqrDistance functions /// /// ----------------------------------------------------- public static double SqrDistance(Triangle2d triangle, Point2d point) { return Intersections_Shapes_EIK_SqrDistance_TrianglePoint(triangle, point); } public static double SqrDistance(Triangle2d triangle, Line2d line) { return Intersections_Shapes_EIK_SqrDistance_TriangleLine(triangle, line); } public static double SqrDistance(Triangle2d triangle, Ray2d ray) { return Intersections_Shapes_EIK_SqrDistance_TriangleRay(triangle, ray); } public static double SqrDistance(Triangle2d triangle, Segment2d segment) { return Intersections_Shapes_EIK_SqrDistance_TriangleSegment(triangle, segment); } public static double SqrDistance(Triangle2d triangle, Triangle2d triangle2) { return Intersections_Shapes_EIK_SqrDistance_TriangleTriangle(triangle, triangle2); } /// -------------------------------------------------------- /// /// The Point DoIntersect extern functions /// /// ------------------------------------------------------ [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool Intersections_Shapes_EIK_DoIntersect_PointLine(Point2d point, Line2d line); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool Intersections_Shapes_EIK_DoIntersect_PointRay(Point2d point, Ray2d ray); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool Intersections_Shapes_EIK_DoIntersect_PointSegment(Point2d point, Segment2d segment); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool Intersections_Shapes_EIK_DoIntersect_PointTriangle(Point2d point, Triangle2d triangle); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool Intersections_Shapes_EIK_DoIntersect_PointBox(Point2d point, Box2d box); /// -------------------------------------------------------- /// /// The Linet DoIntersect extern functions /// /// ------------------------------------------------------ [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool Intersections_Shapes_EIK_DoIntersect_LinePoint(Line2d line, Point2d point); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool Intersections_Shapes_EIK_DoIntersect_LineLine(Line2d line, Line2d line2); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool Intersections_Shapes_EIK_DoIntersect_LineRay(Line2d line, Ray2d ray); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool Intersections_Shapes_EIK_DoIntersect_LineSegment(Line2d line, Segment2d segment); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool Intersections_Shapes_EIK_DoIntersect_LineTriangle(Line2d line, Triangle2d triangle); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool Intersections_Shapes_EIK_DoIntersect_LineBox(Line2d line, Box2d box); /// -------------------------------------------------------- /// /// The Ray DoIntersect extern functions /// /// ------------------------------------------------------ [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool Intersections_Shapes_EIK_DoIntersect_RayPoint(Ray2d ray, Point2d point); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool Intersections_Shapes_EIK_DoIntersect_RayLine(Ray2d ray, Line2d line); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool Intersections_Shapes_EIK_DoIntersect_RayRay(Ray2d ray, Ray2d ray2); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool Intersections_Shapes_EIK_DoIntersect_RaySegment(Ray2d ray, Segment2d segment); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool Intersections_Shapes_EIK_DoIntersect_RayTriangle(Ray2d ray, Triangle2d triangle); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool Intersections_Shapes_EIK_DoIntersect_RayBox(Ray2d ray, Box2d box); /// -------------------------------------------------------- /// /// The Segment DoIntersect extern functions /// /// ------------------------------------------------------ [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool Intersections_Shapes_EIK_DoIntersect_SegmentPoint(Segment2d segment, Point2d point); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool Intersections_Shapes_EIK_DoIntersect_SegmentLine(Segment2d segment, Line2d line); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool Intersections_Shapes_EIK_DoIntersect_SegmentRay(Segment2d segment, Ray2d ray); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool Intersections_Shapes_EIK_DoIntersect_SegmentSegment(Segment2d segment, Segment2d segment2); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool Intersections_Shapes_EIK_DoIntersect_SegmentTriangle(Segment2d segment, Triangle2d triangle); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool Intersections_Shapes_EIK_DoIntersect_SegmentBox(Segment2d segment, Box2d box); /// -------------------------------------------------------- /// /// The Triangle DoIntersect extern functions /// /// ------------------------------------------------------ [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool Intersections_Shapes_EIK_DoIntersect_TrianglePoint(Triangle2d triangle, Point2d point); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool Intersections_Shapes_EIK_DoIntersect_TriangleLine(Triangle2d triangle, Line2d line); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool Intersections_Shapes_EIK_DoIntersect_TriangleRay(Triangle2d triangle, Ray2d ray); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool Intersections_Shapes_EIK_DoIntersect_TriangleSegment(Triangle2d triangle, Segment2d segment); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool Intersections_Shapes_EIK_DoIntersect_TriangleTriangle(Triangle2d triangle, Triangle2d triangle2); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool Intersections_Shapes_EIK_DoIntersect_TriangleBox(Triangle2d triangle, Box2d box); /// -------------------------------------------------------- /// /// The Box DoIntersect extern functions /// /// ------------------------------------------------------ [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool Intersections_Shapes_EIK_DoIntersect_BoxPoint(Box2d box, Point2d point); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool Intersections_Shapes_EIK_DoIntersect_BoxLine(Box2d box, Line2d line); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool Intersections_Shapes_EIK_DoIntersect_BoxRay(Box2d box, Ray2d ray); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool Intersections_Shapes_EIK_DoIntersect_BoxSegment(Box2d box, Segment2d segment); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool Intersections_Shapes_EIK_DoIntersect_BoxTriangle(Box2d box, Triangle2d triangle); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool Intersections_Shapes_EIK_DoIntersect_BoxBox(Box2d box, Box2d box2); /// -------------------------------------------------------- /// /// The Point Intersection extern functions /// /// ------------------------------------------------------- [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntersectionResult2d Intersections_Shapes_EIK_Intersection_PointLine(Point2d point, Line2d line); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntersectionResult2d Intersections_Shapes_EIK_Intersection_PointRay(Point2d point, Ray2d ray); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntersectionResult2d Intersections_Shapes_EIK_Intersection_PointSegment(Point2d point, Segment2d segment); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntersectionResult2d Intersections_Shapes_EIK_Intersection_PointTriangle(Point2d point, Triangle2d triangle); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntersectionResult2d Intersections_Shapes_EIK_Intersection_PointBox(Point2d point, Box2d box); /// -------------------------------------------------------- /// /// The Line Intersection extern functions /// /// ------------------------------------------------------- [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntersectionResult2d Intersections_Shapes_EIK_Intersection_LinePoint(Line2d line, Point2d point); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntersectionResult2d Intersections_Shapes_EIK_Intersection_LineLine(Line2d line, Line2d line2); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntersectionResult2d Intersections_Shapes_EIK_Intersection_LineRay(Line2d line, Ray2d ray); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntersectionResult2d Intersections_Shapes_EIK_Intersection_LineSegment(Line2d line, Segment2d segment); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntersectionResult2d Intersections_Shapes_EIK_Intersection_LineTriangle(Line2d line, Triangle2d triangle); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntersectionResult2d Intersections_Shapes_EIK_Intersection_LineBox(Line2d line, Box2d box); /// -------------------------------------------------------- /// /// The Ray Intersection extern functions /// /// ------------------------------------------------------- [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntersectionResult2d Intersections_Shapes_EIK_Intersection_RayPoint(Ray2d ray, Point2d point); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntersectionResult2d Intersections_Shapes_EIK_Intersection_RayLine(Ray2d ray, Line2d line); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntersectionResult2d Intersections_Shapes_EIK_Intersection_RayRay(Ray2d ray, Ray2d ray2); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntersectionResult2d Intersections_Shapes_EIK_Intersection_RaySegment(Ray2d ray, Segment2d segment); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntersectionResult2d Intersections_Shapes_EIK_Intersection_RayTriangle(Ray2d ray, Triangle2d triangle); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntersectionResult2d Intersections_Shapes_EIK_Intersection_RayBox(Ray2d ray, Box2d box); /// -------------------------------------------------------- /// /// The Segment Intersection extern functions /// /// ------------------------------------------------------- [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntersectionResult2d Intersections_Shapes_EIK_Intersection_SegmentPoint(Segment2d segment, Point2d point); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntersectionResult2d Intersections_Shapes_EIK_Intersection_SegmentLine(Segment2d segment, Line2d line); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntersectionResult2d Intersections_Shapes_EIK_Intersection_SegmentRay(Segment2d segment, Ray2d ray); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntersectionResult2d Intersections_Shapes_EIK_Intersection_SegmentSegment(Segment2d segment, Segment2d segment2); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntersectionResult2d Intersections_Shapes_EIK_Intersection_SegmentTriangle(Segment2d segment, Triangle2d triangle); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntersectionResult2d Intersections_Shapes_EIK_Intersection_SegmentBox(Segment2d segment, Box2d box); /// -------------------------------------------------------- /// /// The Triangle Intersection extern functions /// /// ------------------------------------------------------- [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntersectionResult2d Intersections_Shapes_EIK_Intersection_TrianglePoint(Triangle2d triangle, Point2d point); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntersectionResult2d Intersections_Shapes_EIK_Intersection_TriangleLine(Triangle2d triangle, Line2d line); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntersectionResult2d Intersections_Shapes_EIK_Intersection_TriangleRay(Triangle2d triangle, Ray2d ray); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntersectionResult2d Intersections_Shapes_EIK_Intersection_TriangleSegment(Triangle2d triangle, Segment2d segment); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntersectionResult2d Intersections_Shapes_EIK_Intersection_TriangleTriangle(Triangle2d triangle, Triangle2d triangle2); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntersectionResult2d Intersections_Shapes_EIK_Intersection_TriangleBox(Triangle2d triangle, Box2d box); /// -------------------------------------------------------- /// /// The Box Intersection extern functions /// /// ------------------------------------------------------- [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntersectionResult2d Intersections_Shapes_EIK_Intersection_BoxPoint(Box2d box, Point2d point); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntersectionResult2d Intersections_Shapes_EIK_Intersection_BoxLine(Box2d box, Line2d line); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntersectionResult2d Intersections_Shapes_EIK_Intersection_BoxRay(Box2d box, Ray2d ray); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntersectionResult2d Intersections_Shapes_EIK_Intersection_BoxSegment(Box2d box, Segment2d segment); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntersectionResult2d Intersections_Shapes_EIK_Intersection_BoxTriangle(Box2d box, Triangle2d triangle); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntersectionResult2d Intersections_Shapes_EIK_Intersection_BoxBox(Box2d box, Box2d box2); /// -------------------------------------------------------- /// /// The Point SqrDistance extern functions /// /// ------------------------------------------------------- [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern double Intersections_Shapes_EIK_SqrDistance_PointPoint(Point2d point, Point2d point2); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern double Intersections_Shapes_EIK_SqrDistance_PointLine(Point2d point, Line2d line); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern double Intersections_Shapes_EIK_SqrDistance_PointRay(Point2d point, Ray2d ray); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern double Intersections_Shapes_EIK_SqrDistance_PointSegment(Point2d point, Segment2d seg); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern double Intersections_Shapes_EIK_SqrDistance_PointTriangle(Point2d point, Triangle2d tri); /// -------------------------------------------------------- /// /// The Line SqrDistance extern functions /// /// ------------------------------------------------------ [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern double Intersections_Shapes_EIK_SqrDistance_LinePoint(Line2d line, Point2d point); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern double Intersections_Shapes_EIK_SqrDistance_LineLine(Line2d line, Line2d line2); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern double Intersections_Shapes_EIK_SqrDistance_LineRay(Line2d line, Ray2d ray); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern double Intersections_Shapes_EIK_SqrDistance_LineSegment(Line2d line, Segment2d segment); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern double Intersections_Shapes_EIK_SqrDistance_LineTriangle(Line2d line, Triangle2d triangle); /// -------------------------------------------------------- /// /// The Ray SqrDistance extern functions /// /// ------------------------------------------------------ [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern double Intersections_Shapes_EIK_SqrDistance_RayPoint(Ray2d ray, Point2d point); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern double Intersections_Shapes_EIK_SqrDistance_RayLine(Ray2d ray, Line2d line2); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern double Intersections_Shapes_EIK_SqrDistance_RayRay(Ray2d ray, Ray2d ray2); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern double Intersections_Shapes_EIK_SqrDistance_RaySegment(Ray2d ray, Segment2d segment); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern double Intersections_Shapes_EIK_SqrDistance_RayTriangle(Ray2d ray, Triangle2d triangle); /// -------------------------------------------------------- /// /// The Segment SqrDistance extern functions /// /// ------------------------------------------------------ [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern double Intersections_Shapes_EIK_SqrDistance_SegmentPoint(Segment2d segment, Point2d point); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern double Intersections_Shapes_EIK_SqrDistance_SegmentLine(Segment2d segment, Line2d line2); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern double Intersections_Shapes_EIK_SqrDistance_SegmentRay(Segment2d segment, Ray2d ray); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern double Intersections_Shapes_EIK_SqrDistance_SegmentSegment(Segment2d segment, Segment2d segment2); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern double Intersections_Shapes_EIK_SqrDistance_SegmentTriangle(Segment2d segment, Triangle2d triangle); /// -------------------------------------------------------- /// /// The Triangle SqrDistance extern functions /// /// ------------------------------------------------------ [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern double Intersections_Shapes_EIK_SqrDistance_TrianglePoint(Triangle2d triangle, Point2d point); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern double Intersections_Shapes_EIK_SqrDistance_TriangleLine(Triangle2d triangle, Line2d line2); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern double Intersections_Shapes_EIK_SqrDistance_TriangleRay(Triangle2d triangle, Ray2d ray); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern double Intersections_Shapes_EIK_SqrDistance_TriangleSegment(Triangle2d triangle, Segment2d segment); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern double Intersections_Shapes_EIK_SqrDistance_TriangleTriangle(Triangle2d triangle, Triangle2d triangle2); } } ================================================ FILE: CGALDotNet/Geometry/GeometryKernel2.cs ================================================ using System; using System.Collections.Generic; using System.Text; using CGALDotNetGeometry.Numerics; namespace CGALDotNet.Geometry { internal abstract class GeometryKernel2 : CGALObjectKernel { /// -------------------------------------------------------- /// /// The Point2 Class Functions /// /// ------------------------------------------------------- internal abstract IntPtr Point2_Create(); internal abstract IntPtr Point2_CreateFromPoint(Point2d point); internal abstract void Point2_Release(IntPtr ptr); internal abstract double Point2_GetX(IntPtr ptr); internal abstract double Point2_GetY(IntPtr ptr); internal abstract void Point2_SetX(IntPtr ptr, double x); internal abstract void Point2_SetY(IntPtr ptr, double y); internal abstract IntPtr Point2_Copy(IntPtr ptr); internal abstract IntPtr Point2_Convert(IntPtr ptr, CGAL_KERNEL k); /// -------------------------------------------------------- /// /// The Vector2 Class Functions /// /// ------------------------------------------------------- internal abstract IntPtr Vector2_Create(); internal abstract IntPtr Vector2_CreateFromVector(Vector2d vector); internal abstract void Vector2_Release(IntPtr ptr); internal abstract double Vector2_GetX(IntPtr ptr); internal abstract double Vector2_GetY(IntPtr ptr); internal abstract void Vector2_SetX(IntPtr ptr, double x); internal abstract void Vector2_SetY(IntPtr ptr, double y); internal abstract double Vector2_SqrLength(IntPtr ptr); internal abstract IntPtr Vector2_Perpendicular(IntPtr ptr, ORIENTATION orientation); internal abstract void Vector2_Normalize(IntPtr ptr); internal abstract double Vector2_Magnitude(IntPtr ptr); internal abstract IntPtr Vector2_Copy(IntPtr ptr); internal abstract IntPtr Vector2_Convert(IntPtr ptr, CGAL_KERNEL k); /// -------------------------------------------------------- /// /// The HPoint2 Class Functions /// /// ------------------------------------------------------- internal abstract IntPtr HPoint2_Create(); internal abstract IntPtr HPoint2_CreateFromPoint( HPoint2d point); internal abstract void HPoint2_Release(IntPtr ptr); internal abstract double HPoint2_GetX(IntPtr ptr); internal abstract double HPoint2_GetY(IntPtr ptr); internal abstract double HPoint2_GetW(IntPtr ptr); internal abstract void HPoint2_SetX(IntPtr ptr, double x); internal abstract void HPoint2_SetY(IntPtr ptr, double y); internal abstract void HPoint2_SetW(IntPtr ptr, double y); internal abstract IntPtr HPoint2_Copy(IntPtr ptr); internal abstract IntPtr HPoint2_Convert(IntPtr ptr, CGAL_KERNEL k); /// -------------------------------------------------------- /// /// The Line2 Class Functions /// /// ------------------------------------------------------- internal abstract IntPtr Line2_Create(double a, double b, double c); internal abstract IntPtr CreateFromPoints(Point2d p1, Point2d p2); internal abstract IntPtr CreateFromPointVector(Point2d p, Vector2d v); internal abstract void Line2_Release(IntPtr ptr); internal abstract double Line2_GetA(IntPtr ptr); internal abstract double Line2_GetB(IntPtr ptr); internal abstract double Line2_GetC(IntPtr ptr); internal abstract void Line2_SetA(IntPtr ptr, double a); internal abstract void Line2_SetB(IntPtr ptr, double b); internal abstract void Line2_SetC(IntPtr ptr, double c); internal abstract bool Line2_IsDegenerate(IntPtr ptr); internal abstract bool Line2_IsHorizontal(IntPtr ptr); internal abstract bool Line2_IsVertical(IntPtr ptr); internal abstract bool Line2_HasOn(IntPtr linePtr, Point2d point); internal abstract bool Line2_HasOnNegativeSide(IntPtr linePtr, Point2d point); internal abstract bool Line2_HasOnPositiveSide(IntPtr linePtr, Point2d point); internal abstract IntPtr Line2_Opposite(IntPtr ptr); internal abstract IntPtr Line2_Perpendicular(IntPtr ptr, Point2d point); internal abstract double Line2_X_On_Y(IntPtr ptr, double y); internal abstract double Line2_Y_On_X(IntPtr ptr, double x); internal abstract Vector2d Line2_Vector(IntPtr ptr); internal abstract void Line2_Transform(IntPtr ptr, Point2d translation, double rotation, double scale); internal abstract IntPtr Line2_Copy(IntPtr ptr); internal abstract IntPtr Line2_Convert(IntPtr ptr, CGAL_KERNEL k); /// -------------------------------------------------------- /// /// The Ray2 Class Functions /// /// ------------------------------------------------------- internal abstract IntPtr Ray2_Create(Point2d position, Vector2d direction); internal abstract void Ray2_Release(IntPtr ptr); internal abstract bool Ray2_IsDegenerate(IntPtr ptr); internal abstract bool Ray2_IsHorizontal(IntPtr ptr); internal abstract bool Ray2_IsVertical(IntPtr ptr); internal abstract bool Ray2_HasOn(IntPtr rayPtr, Point2d point); internal abstract Point2d Ray2_Source(IntPtr ptr); internal abstract Vector2d Ray2_Vector(IntPtr ptr); internal abstract IntPtr Ray2_Opposite(IntPtr ptr); internal abstract IntPtr Ray2_Line(IntPtr ptr); internal abstract void Ray2_Transform(IntPtr ptr, Point2d translation, double rotation, double scale); internal abstract IntPtr Ray2_Copy(IntPtr ptr); internal abstract IntPtr Ray2_Convert(IntPtr ptr, CGAL_KERNEL k); /// -------------------------------------------------------- /// /// The Segment2 Class Functions /// /// ------------------------------------------------------- internal abstract IntPtr Segment2_Create(Point2d a, Point2d b); internal abstract void Segment2_Release(IntPtr ptr); internal abstract Point2d Segment2_GetVertex(IntPtr ptr, int i); internal abstract void Segment2_SetVertex(IntPtr ptr, int i, Point2d point); internal abstract Point2d Segment2_Min(IntPtr ptr); internal abstract Point2d Segment2_Max(IntPtr ptr); internal abstract bool Segment2_IsDegenerate(IntPtr ptr); internal abstract bool Segment2_IsHorizontal(IntPtr ptr); internal abstract bool Segment2_IsVertical(IntPtr ptr); internal abstract bool Segment2_HasOn(IntPtr segPtr, Point2d point); internal abstract Vector2d Segment2_Vector(IntPtr ptr); internal abstract IntPtr Segment2_Line(IntPtr ptr); internal abstract double Segment2_SqrLength(IntPtr ptr); internal abstract void Segment2_Transform(IntPtr ptr, Point2d translation, double rotation, double scale); internal abstract IntPtr Segment2_Copy(IntPtr ptr); internal abstract IntPtr Segment2_Convert(IntPtr ptr, CGAL_KERNEL k); /// -------------------------------------------------------- /// /// The Triangle2 Class Functions /// /// ------------------------------------------------------- internal abstract IntPtr Triangle2_Create(Point2d a, Point2d b, Point2d c); internal abstract void Triangle2_Release(IntPtr ptr); internal abstract Point2d Triangle2_GetVertex(IntPtr ptr, int i); internal abstract void Triangle2_SetVertex(IntPtr ptr, int i, Point2d point); internal abstract double Triangle2_Area(IntPtr ptr); internal abstract BOUNDED_SIDE Triangle2_BoundedSide(IntPtr ptr, Point2d point); internal abstract ORIENTED_SIDE Triangle2_OrientedSide(IntPtr ptr, Point2d point); internal abstract ORIENTATION Triangle2_Orientation(IntPtr ptr); internal abstract bool Triangle2_IsDegenerate(IntPtr ptr); internal abstract void Triangle2_Transform(IntPtr ptr, Point2d translation, double rotation, double scale); internal abstract IntPtr Triangle2_Copy(IntPtr ptr); internal abstract IntPtr Triangle2_Convert(IntPtr ptr, CGAL_KERNEL k); /// -------------------------------------------------------- /// /// The Box2 Class Functions /// /// ------------------------------------------------------- internal abstract IntPtr Box2_Create(Point2d min, Point2d max); internal abstract void Box2_Release(IntPtr ptr); internal abstract Point2d Box2_GetMin(IntPtr ptr); internal abstract void Box2_SetMin(IntPtr ptr, Point2d point); internal abstract Point2d Box2_GetMax(IntPtr ptr); internal abstract void Box2_SetMax(IntPtr ptr, Point2d point); internal abstract double Box2_Area(IntPtr ptr); internal abstract BOUNDED_SIDE Box2_BoundedSide(IntPtr ptr, Point2d point); internal abstract bool Box2_ContainsPoint(IntPtr ptr, Point2d point, bool inculdeBoundary); internal abstract bool Box2_IsDegenerate(IntPtr ptr); internal abstract void Box2_Transform(IntPtr ptr, Point2d translation, double rotation, double scale); internal abstract IntPtr Box2_Copy(IntPtr ptr); internal abstract IntPtr Box2_Convert(IntPtr ptr, CGAL_KERNEL k); } } ================================================ FILE: CGALDotNet/Geometry/GeometryKernel2_EEK.cs ================================================ using System; using System.Collections.Generic; using System.Runtime.InteropServices; using CGALDotNetGeometry.Numerics; using CGALDotNetGeometry.Shapes; namespace CGALDotNet.Geometry { internal class GeometryKernel2_EEK : GeometryKernel2 { internal override string Name => "EEK"; internal static readonly GeometryKernel2 Instance = new GeometryKernel2_EEK(); /// -------------------------------------------------------- /// /// The Point2 Class Functions /// /// ------------------------------------------------------- internal override IntPtr Point2_Create() { return Point2_Create(); } internal override IntPtr Point2_CreateFromPoint(Point2d point) { return Point2_EEK_CreateFromPoint(point); } internal override void Point2_Release(IntPtr ptr) { Point2_EEK_Release(ptr); } internal override double Point2_GetX(IntPtr ptr) { return Point2_EEK_GetX(ptr); } internal override double Point2_GetY(IntPtr ptr) { return Point2_EEK_GetY(ptr); } internal override void Point2_SetX(IntPtr ptr, double x) { Point2_EEK_SetX(ptr, x); } internal override void Point2_SetY(IntPtr ptr, double y) { Point2_EEK_SetY(ptr, y); } internal override IntPtr Point2_Copy(IntPtr ptr) { return Point2_EEK_Copy(ptr); } internal override IntPtr Point2_Convert(IntPtr ptr, CGAL_KERNEL k) { return Point2_EEK_Convert(ptr, k); } /// -------------------------------------------------------- /// /// The Vector2 Class Functions /// /// ------------------------------------------------------- internal override IntPtr Vector2_Create() { return Vector2_EEK_Create(); } internal override IntPtr Vector2_CreateFromVector(Vector2d vector) { return Vector2_EEK_CreateFromVector(vector); } internal override void Vector2_Release(IntPtr ptr) { Vector2_EEK_Release(ptr); } internal override double Vector2_GetX(IntPtr ptr) { return Vector2_EEK_GetX(ptr); } internal override double Vector2_GetY(IntPtr ptr) { return Vector2_EEK_GetY(ptr); } internal override void Vector2_SetX(IntPtr ptr, double x) { Vector2_EEK_SetX(ptr, x); } internal override void Vector2_SetY(IntPtr ptr, double y) { Vector2_EEK_SetY(ptr, y); } internal override double Vector2_SqrLength(IntPtr ptr) { return Vector2_EEK_SqrLength(ptr); } internal override IntPtr Vector2_Perpendicular(IntPtr ptr, ORIENTATION orientation) { return Vector2_EEK_Perpendicular(ptr, orientation); } internal override void Vector2_Normalize(IntPtr ptr) { Vector2_EEK_Normalize(ptr); } internal override double Vector2_Magnitude(IntPtr ptr) { return Vector2_EEK_Magnitude(ptr); } internal override IntPtr Vector2_Copy(IntPtr ptr) { return Vector2_EEK_Copy(ptr); } internal override IntPtr Vector2_Convert(IntPtr ptr, CGAL_KERNEL k) { return Vector2_EEK_Convert(ptr, k); } /// -------------------------------------------------------- /// /// The HPoint2 Class Functions /// /// ------------------------------------------------------- internal override IntPtr HPoint2_Create() { return HPoint2_Create(); } internal override IntPtr HPoint2_CreateFromPoint(HPoint2d point) { return HPoint2_EEK_CreateFromPoint(point); } internal override void HPoint2_Release(IntPtr ptr) { HPoint2_EEK_Release(ptr); } internal override double HPoint2_GetX(IntPtr ptr) { return HPoint2_EEK_GetX(ptr); } internal override double HPoint2_GetY(IntPtr ptr) { return HPoint2_EEK_GetY(ptr); } internal override double HPoint2_GetW(IntPtr ptr) { return HPoint2_EEK_GetW(ptr); } internal override void HPoint2_SetX(IntPtr ptr, double x) { HPoint2_EEK_SetX(ptr, x); } internal override void HPoint2_SetY(IntPtr ptr, double y) { HPoint2_EEK_SetY(ptr, y); } internal override void HPoint2_SetW(IntPtr ptr, double w) { HPoint2_EEK_SetW(ptr, w); } internal override IntPtr HPoint2_Copy(IntPtr ptr) { return HPoint2_EEK_Copy(ptr); } internal override IntPtr HPoint2_Convert(IntPtr ptr, CGAL_KERNEL k) { return HPoint2_EEK_Convert(ptr, k); } /// -------------------------------------------------------- /// /// The Line2 Class Functions /// /// ------------------------------------------------------- internal override IntPtr Line2_Create(double a, double b, double c) { return Line2_EEK_Create(a, b, c); } internal override IntPtr CreateFromPoints(Point2d p1, Point2d p2) { return Line2_EEK_CreateFromPoints(p1, p2); } internal override IntPtr CreateFromPointVector(Point2d p, Vector2d v) { return Line2_EEK_CreateFromPointVector(p, v); } internal override void Line2_Release(IntPtr ptr) { Line2_EEK_Release(ptr); } internal override double Line2_GetA(IntPtr ptr) { return Line2_EEK_GetA(ptr); } internal override double Line2_GetB(IntPtr ptr) { return Line2_EEK_GetB(ptr); } internal override double Line2_GetC(IntPtr ptr) { return Line2_EEK_GetC(ptr); } internal override void Line2_SetA(IntPtr ptr, double a) { Line2_EEK_SetA(ptr, a); } internal override void Line2_SetB(IntPtr ptr, double b) { Line2_EEK_SetB(ptr, b); } internal override void Line2_SetC(IntPtr ptr, double c) { Line2_EEK_SetC(ptr, c); } internal override bool Line2_IsDegenerate(IntPtr ptr) { return Line2_EEK_IsDegenerate(ptr); } internal override bool Line2_IsHorizontal(IntPtr ptr) { return Line2_EEK_IsHorizontal(ptr); } internal override bool Line2_IsVertical(IntPtr ptr) { return Line2_EEK_IsVertical(ptr); } internal override bool Line2_HasOn(IntPtr linePtr, Point2d point) { return Line2_EEK_HasOn(linePtr, point); } internal override bool Line2_HasOnNegativeSide(IntPtr linePtr, Point2d point) { return Line2_EEK_HasOnNegativeSide(linePtr, point); } internal override bool Line2_HasOnPositiveSide(IntPtr linePtr, Point2d point) { return Line2_EEK_HasOnPositiveSide(linePtr, point); } internal override IntPtr Line2_Opposite(IntPtr ptr) { return Line2_EEK_Opposite(ptr); } internal override IntPtr Line2_Perpendicular(IntPtr ptr, Point2d point) { return Line2_EEK_Perpendicular(ptr, point); } internal override double Line2_X_On_Y(IntPtr ptr, double y) { return Line2_EEK_X_On_Y(ptr, y); } internal override double Line2_Y_On_X(IntPtr ptr, double x) { return Line2_EEK_Y_On_X(ptr, x); } internal override Vector2d Line2_Vector(IntPtr ptr) { return Line2_EEK_Vector(ptr); } internal override void Line2_Transform(IntPtr ptr, Point2d translation, double rotation, double scale) { Line2_EEK_Transform(ptr, translation, rotation, scale); } internal override IntPtr Line2_Copy(IntPtr ptr) { return Line2_EEK_Copy(ptr); } internal override IntPtr Line2_Convert(IntPtr ptr, CGAL_KERNEL k) { return Line2_EEK_Convert(ptr, k); } /// -------------------------------------------------------- /// /// The Ray2 Class Functions /// /// ------------------------------------------------------- internal override IntPtr Ray2_Create(Point2d position, Vector2d direction) { return Ray2_EEK_Create(position, direction); } internal override void Ray2_Release(IntPtr ptr) { Ray2_EEK_Release(ptr); } internal override bool Ray2_IsDegenerate(IntPtr ptr) { return Box2_EEK_IsDegenerate(ptr); } internal override bool Ray2_IsHorizontal(IntPtr ptr) { return Ray2_EEK_IsHorizontal(ptr); } internal override bool Ray2_IsVertical(IntPtr ptr) { return Ray2_EEK_IsVertical(ptr); } internal override bool Ray2_HasOn(IntPtr rayPtr, Point2d point) { return Ray2_EEK_HasOn(rayPtr, point); } internal override Point2d Ray2_Source(IntPtr ptr) { return Ray2_EEK_Source(ptr); } internal override Vector2d Ray2_Vector(IntPtr ptr) { return Ray2_EEK_Vector(ptr); } internal override IntPtr Ray2_Opposite(IntPtr ptr) { return Ray2_EEK_Opposite(ptr); } internal override IntPtr Ray2_Line(IntPtr ptr) { return Ray2_EEK_Line(ptr); } internal override void Ray2_Transform(IntPtr ptr, Point2d translation, double rotation, double scale) { Ray2_EEK_Transform(ptr, translation, rotation, scale); } internal override IntPtr Ray2_Copy(IntPtr ptr) { return Ray2_EEK_Copy(ptr); } internal override IntPtr Ray2_Convert(IntPtr ptr, CGAL_KERNEL k) { return Ray2_EEK_Convert(ptr, k); } /// -------------------------------------------------------- /// /// The Segment Class Functions /// /// ------------------------------------------------------- internal override IntPtr Segment2_Create(Point2d a, Point2d b) { return Segment2_EEK_Create(a, b); } internal override void Segment2_Release(IntPtr ptr) { Segment2_EEK_Release(ptr); } internal override Point2d Segment2_GetVertex(IntPtr ptr, int i) { return Segment2_EEK_GetVertex(ptr, i); } internal override void Segment2_SetVertex(IntPtr ptr, int i, Point2d point) { Segment2_EEK_SetVertex(ptr, i, point); } internal override Point2d Segment2_Min(IntPtr ptr) { return Segment2_EEK_Min(ptr); } internal override Point2d Segment2_Max(IntPtr ptr) { return Segment2_EEK_Max(ptr); } internal override bool Segment2_IsDegenerate(IntPtr ptr) { return Segment2_EEK_IsDegenerate(ptr); } internal override bool Segment2_IsHorizontal(IntPtr ptr) { return Segment2_EEK_IsHorizontal(ptr); } internal override bool Segment2_IsVertical(IntPtr ptr) { return Segment2_EEK_IsVertical(ptr); } internal override bool Segment2_HasOn(IntPtr segPtr, Point2d point) { return Segment2_EEK_HasOn(segPtr, point); } internal override Vector2d Segment2_Vector(IntPtr ptr) { return Segment2_EEK_Vector(ptr); } internal override IntPtr Segment2_Line(IntPtr ptr) { return Segment2_EEK_Line(ptr); } internal override double Segment2_SqrLength(IntPtr ptr) { return Segment2_EEK_SqrLength(ptr); } internal override void Segment2_Transform(IntPtr ptr, Point2d translation, double rotation, double scale) { Segment2_EEK_Transform(ptr, translation, rotation, scale); } internal override IntPtr Segment2_Copy(IntPtr ptr) { return Segment2_EEK_Copy(ptr); } internal override IntPtr Segment2_Convert(IntPtr ptr, CGAL_KERNEL k) { return Segment2_EEK_Convert(ptr, k); } /// -------------------------------------------------------- /// /// The Triangle2 Class Functions /// /// ------------------------------------------------------- internal override IntPtr Triangle2_Create(Point2d a, Point2d b, Point2d c) { return Triangle2_EEK_Create(a, b, c); } internal override void Triangle2_Release(IntPtr ptr) { Triangle2_EEK_Release(ptr); } internal override Point2d Triangle2_GetVertex(IntPtr ptr, int i) { return Triangle2_EEK_GetVertex(ptr, i); } internal override void Triangle2_SetVertex(IntPtr ptr, int i, Point2d point) { Segment2_EEK_SetVertex(ptr, i, point); } internal override double Triangle2_Area(IntPtr ptr) { return Triangle2_EEK_Area(ptr); } internal override BOUNDED_SIDE Triangle2_BoundedSide(IntPtr ptr, Point2d point) { return Triangle2_EEK_BoundedSide(ptr, point); } internal override ORIENTED_SIDE Triangle2_OrientedSide(IntPtr ptr, Point2d point) { return Triangle2_EEK_OrientedSide(ptr, point); } internal override ORIENTATION Triangle2_Orientation(IntPtr ptr) { return Triangle2_EEK_Orientation(ptr); } internal override bool Triangle2_IsDegenerate(IntPtr ptr) { return Triangle2_EEK_IsDegenerate(ptr); } internal override void Triangle2_Transform(IntPtr ptr, Point2d translation, double rotation, double scale) { Triangle2_EEK_Transform(ptr, translation, rotation, scale); } internal override IntPtr Triangle2_Copy(IntPtr ptr) { return Triangle2_EEK_Copy(ptr); } internal override IntPtr Triangle2_Convert(IntPtr ptr, CGAL_KERNEL k) { return Triangle2_EEK_Convert(ptr, k); } /// -------------------------------------------------------- /// /// The IsoRectancle2 Class Functions /// /// ------------------------------------------------------- internal override IntPtr Box2_Create(Point2d min, Point2d max) { return Box2_EEK_Create(min, max); } internal override void Box2_Release(IntPtr ptr) { Box2_EEK_Release(ptr); } internal override Point2d Box2_GetMin(IntPtr ptr) { return Box2_EEK_GetMin(ptr); } internal override void Box2_SetMin(IntPtr ptr, Point2d point) { Box2_EEK_SetMin(ptr, point); } internal override Point2d Box2_GetMax(IntPtr ptr) { return Box2_EEK_GetMax(ptr); } internal override void Box2_SetMax(IntPtr ptr, Point2d point) { Box2_EEK_SetMax(ptr, point); } internal override double Box2_Area(IntPtr ptr) { return Box2_EEK_Area(ptr); } internal override BOUNDED_SIDE Box2_BoundedSide(IntPtr ptr, Point2d point) { return Box2_EEK_BoundedSide(ptr, point); } internal override bool Box2_ContainsPoint(IntPtr ptr, Point2d point, bool inculdeBoundary) { return Box2_EEK_ContainsPoint(ptr, point, inculdeBoundary); } internal override bool Box2_IsDegenerate(IntPtr ptr) { return Box2_EEK_IsDegenerate(ptr); } internal override void Box2_Transform(IntPtr ptr, Point2d translation, double rotation, double scale) { Box2_EEK_Transform(ptr, translation, rotation, scale); } internal override IntPtr Box2_Copy(IntPtr ptr) { return Box2_EEK_Copy(ptr); } internal override IntPtr Box2_Convert(IntPtr ptr, CGAL_KERNEL k) { return Box2_EEK_Convert(ptr, k); } /// -------------------------------------------------------- /// /// The Point2 extern functions /// /// ------------------------------------------------------- [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr Point2_EEK_Create(); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr Point2_EEK_CreateFromPoint(Point2d point); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void Point2_EEK_Release(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern double Point2_EEK_GetX(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern double Point2_EEK_GetY(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void Point2_EEK_SetX(IntPtr ptr, double x); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void Point2_EEK_SetY(IntPtr ptr, double y); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr Point2_EEK_Copy(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr Point2_EEK_Convert(IntPtr ptr, CGAL_KERNEL k); /// -------------------------------------------------------- /// /// The Vector2 extern functions /// /// ------------------------------------------------------- [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr Vector2_EEK_Create(); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr Vector2_EEK_CreateFromVector(Vector2d vector); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void Vector2_EEK_Release(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern double Vector2_EEK_GetX(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern double Vector2_EEK_GetY(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void Vector2_EEK_SetX(IntPtr ptr, double x); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void Vector2_EEK_SetY(IntPtr ptr, double y); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern double Vector2_EEK_SqrLength(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr Vector2_EEK_Perpendicular(IntPtr ptr, ORIENTATION orientation); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void Vector2_EEK_Normalize(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern double Vector2_EEK_Magnitude(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr Vector2_EEK_Copy(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr Vector2_EEK_Convert(IntPtr ptr, CGAL_KERNEL k); /// -------------------------------------------------------- /// /// The HPoint2 extern functions /// /// ------------------------------------------------------- [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr HPoint2_EEK_Create(); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr HPoint2_EEK_CreateFromPoint(HPoint2d point); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void HPoint2_EEK_Release(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern double HPoint2_EEK_GetX(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern double HPoint2_EEK_GetY(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern double HPoint2_EEK_GetW(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void HPoint2_EEK_SetX(IntPtr ptr, double x); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void HPoint2_EEK_SetY(IntPtr ptr, double y); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void HPoint2_EEK_SetW(IntPtr ptr, double y); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr HPoint2_EEK_Copy(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr HPoint2_EEK_Convert(IntPtr ptr, CGAL_KERNEL k); /// -------------------------------------------------------- /// /// The Line2 extern functions /// /// ------------------------------------------------------- [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr Line2_EEK_Create(double a, double b, double c); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr Line2_EEK_CreateFromPoints(Point2d p1, Point2d p2); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr Line2_EEK_CreateFromPointVector(Point2d p, Vector2d v); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void Line2_EEK_Release(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern double Line2_EEK_GetA(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern double Line2_EEK_GetB(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern double Line2_EEK_GetC(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void Line2_EEK_SetA(IntPtr ptr, double a); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void Line2_EEK_SetB(IntPtr ptr, double b); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void Line2_EEK_SetC(IntPtr ptr, double c); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool Line2_EEK_IsDegenerate(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool Line2_EEK_IsHorizontal(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool Line2_EEK_IsVertical(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool Line2_EEK_HasOn(IntPtr linePtr, Point2d point); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool Line2_EEK_HasOnNegativeSide(IntPtr linePtr, Point2d point); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool Line2_EEK_HasOnPositiveSide(IntPtr linePtr, Point2d point); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr Line2_EEK_Opposite(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr Line2_EEK_Perpendicular(IntPtr ptr, Point2d point); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern double Line2_EEK_X_On_Y(IntPtr ptr, double y); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern double Line2_EEK_Y_On_X(IntPtr ptr, double x); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern Vector2d Line2_EEK_Vector(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void Line2_EEK_Transform(IntPtr ptr, Point2d translation, double rotation, double scale); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr Line2_EEK_Copy(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr Line2_EEK_Convert(IntPtr ptr, CGAL_KERNEL k); /// -------------------------------------------------------- /// /// The Ray2 extern functions /// /// ------------------------------------------------------- [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr Ray2_EEK_Create(Point2d position, Vector2d direction); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void Ray2_EEK_Release(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool Ray2_EEK_IsDegenerate(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool Ray2_EEK_IsHorizontal(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool Ray2_EEK_IsVertical(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool Ray2_EEK_HasOn(IntPtr rayPtr, Point2d point); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern Point2d Ray2_EEK_Source(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern Vector2d Ray2_EEK_Vector(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr Ray2_EEK_Opposite(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr Ray2_EEK_Line(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void Ray2_EEK_Transform(IntPtr ptr, Point2d translation, double rotation, double scale); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr Ray2_EEK_Copy(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr Ray2_EEK_Convert(IntPtr ptr, CGAL_KERNEL k); /// -------------------------------------------------------- /// /// The Segment2 extern functions /// /// ------------------------------------------------------- [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr Segment2_EEK_Create(Point2d a, Point2d b); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void Segment2_EEK_Release(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern Point2d Segment2_EEK_GetVertex(IntPtr ptr, int i); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void Segment2_EEK_SetVertex(IntPtr ptr, int i, Point2d point); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern Point2d Segment2_EEK_Min(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern Point2d Segment2_EEK_Max(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool Segment2_EEK_IsDegenerate(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool Segment2_EEK_IsHorizontal(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool Segment2_EEK_IsVertical(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool Segment2_EEK_HasOn(IntPtr segPtr, Point2d point); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern Vector2d Segment2_EEK_Vector(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr Segment2_EEK_Line(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern double Segment2_EEK_SqrLength(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void Segment2_EEK_Transform(IntPtr ptr, Point2d translation, double rotation, double scale); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr Segment2_EEK_Copy(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr Segment2_EEK_Convert(IntPtr ptr, CGAL_KERNEL k); /// -------------------------------------------------------- /// /// The Triangle2 extern functions /// /// ------------------------------------------------------- [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr Triangle2_EEK_Create(Point2d a, Point2d b, Point2d c); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void Triangle2_EEK_Release(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern Point2d Triangle2_EEK_GetVertex(IntPtr ptr, int i); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void Triangle2_EEK_SetVertex(IntPtr ptr, int i, Point2d point); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern double Triangle2_EEK_Area(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern BOUNDED_SIDE Triangle2_EEK_BoundedSide(IntPtr ptr, Point2d point); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern ORIENTED_SIDE Triangle2_EEK_OrientedSide(IntPtr ptr, Point2d point); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern ORIENTATION Triangle2_EEK_Orientation(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool Triangle2_EEK_IsDegenerate(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void Triangle2_EEK_Transform(IntPtr ptr, Point2d translation, double rotation, double scale); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr Triangle2_EEK_Copy(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr Triangle2_EEK_Convert(IntPtr ptr, CGAL_KERNEL k); /// -------------------------------------------------------- /// /// The Box2 extern functions /// /// ------------------------------------------------------- [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr Box2_EEK_Create(Point2d min, Point2d max); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void Box2_EEK_Release(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern Point2d Box2_EEK_GetMin(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void Box2_EEK_SetMin(IntPtr ptr, Point2d point); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern Point2d Box2_EEK_GetMax(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void Box2_EEK_SetMax(IntPtr ptr, Point2d point); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern double Box2_EEK_Area(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern BOUNDED_SIDE Box2_EEK_BoundedSide(IntPtr ptr, Point2d point); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool Box2_EEK_ContainsPoint(IntPtr ptr, Point2d point, bool inculdeBoundary); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool Box2_EEK_IsDegenerate(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void Box2_EEK_Transform(IntPtr ptr, Point2d translation, double rotation, double scale); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr Box2_EEK_Copy(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr Box2_EEK_Convert(IntPtr ptr, CGAL_KERNEL k); } } ================================================ FILE: CGALDotNet/Geometry/GeometryKernel2_EIK.cs ================================================ using System; using System.Collections.Generic; using System.Runtime.InteropServices; using CGALDotNetGeometry.Numerics; using CGALDotNetGeometry.Shapes; namespace CGALDotNet.Geometry { internal class GeometryKernel2_EIK : GeometryKernel2 { internal override string Name => "EIK"; internal static readonly GeometryKernel2 Instance = new GeometryKernel2_EIK(); /// -------------------------------------------------------- /// /// The Point2 Class Functions /// /// ------------------------------------------------------- internal override IntPtr Point2_Create() { return Point2_Create(); } internal override IntPtr Point2_CreateFromPoint(Point2d point) { return Point2_EIK_CreateFromPoint(point); } internal override void Point2_Release(IntPtr ptr) { Point2_EIK_Release(ptr); } internal override double Point2_GetX(IntPtr ptr) { return Point2_EIK_GetX(ptr); } internal override double Point2_GetY(IntPtr ptr) { return Point2_EIK_GetY(ptr); } internal override void Point2_SetX(IntPtr ptr, double x) { Point2_EIK_SetX(ptr, x); } internal override void Point2_SetY(IntPtr ptr, double y) { Point2_EIK_SetY(ptr, y); } internal override IntPtr Point2_Copy(IntPtr ptr) { return Point2_EIK_Copy(ptr); } internal override IntPtr Point2_Convert(IntPtr ptr, CGAL_KERNEL k) { return Point2_EIK_Convert(ptr, k); } /// -------------------------------------------------------- /// /// The Vector2 Class Functions /// /// ------------------------------------------------------- internal override IntPtr Vector2_Create() { return Vector2_EIK_Create(); } internal override IntPtr Vector2_CreateFromVector(Vector2d vector) { return Vector2_EIK_CreateFromVector(vector); } internal override void Vector2_Release(IntPtr ptr) { Vector2_EIK_Release(ptr); } internal override double Vector2_GetX(IntPtr ptr) { return Vector2_EIK_GetX(ptr); } internal override double Vector2_GetY(IntPtr ptr) { return Vector2_EIK_GetY(ptr); } internal override void Vector2_SetX(IntPtr ptr, double x) { Vector2_EIK_SetX(ptr, x); } internal override void Vector2_SetY(IntPtr ptr, double y) { Vector2_EIK_SetY(ptr, y); } internal override double Vector2_SqrLength(IntPtr ptr) { return Vector2_EIK_SqrLength(ptr); } internal override IntPtr Vector2_Perpendicular(IntPtr ptr, ORIENTATION orientation) { return Vector2_EIK_Perpendicular(ptr, orientation); } internal override void Vector2_Normalize(IntPtr ptr) { Vector2_EIK_Normalize(ptr); } internal override double Vector2_Magnitude(IntPtr ptr) { return Vector2_EIK_Magnitude(ptr); } internal override IntPtr Vector2_Copy(IntPtr ptr) { return Vector2_EIK_Copy(ptr); } internal override IntPtr Vector2_Convert(IntPtr ptr, CGAL_KERNEL k) { return Vector2_EIK_Convert(ptr, k); } /// -------------------------------------------------------- /// /// The HPoint2 Class Functions /// /// ------------------------------------------------------- internal override IntPtr HPoint2_Create() { return HPoint2_Create(); } internal override IntPtr HPoint2_CreateFromPoint(HPoint2d point) { return HPoint2_EIK_CreateFromPoint(point); } internal override void HPoint2_Release(IntPtr ptr) { HPoint2_EIK_Release(ptr); } internal override double HPoint2_GetX(IntPtr ptr) { return HPoint2_EIK_GetX(ptr); } internal override double HPoint2_GetY(IntPtr ptr) { return HPoint2_EIK_GetY(ptr); } internal override double HPoint2_GetW(IntPtr ptr) { return HPoint2_EIK_GetW(ptr); } internal override void HPoint2_SetX(IntPtr ptr, double x) { HPoint2_EIK_SetX(ptr, x); } internal override void HPoint2_SetY(IntPtr ptr, double y) { HPoint2_EIK_SetY(ptr, y); } internal override void HPoint2_SetW(IntPtr ptr, double w) { HPoint2_EIK_SetW(ptr, w); } internal override IntPtr HPoint2_Copy(IntPtr ptr) { return HPoint2_EIK_Copy(ptr); } internal override IntPtr HPoint2_Convert(IntPtr ptr, CGAL_KERNEL k) { return HPoint2_EIK_Convert(ptr, k); } /// -------------------------------------------------------- /// /// The Line2 Class Functions /// /// ------------------------------------------------------- internal override IntPtr Line2_Create(double a, double b, double c) { return Line2_EIK_Create(a, b, c); } internal override IntPtr CreateFromPoints(Point2d p1, Point2d p2) { return Line2_EIK_CreateFromPoints(p1, p2); } internal override IntPtr CreateFromPointVector(Point2d p, Vector2d v) { return Line2_EIK_CreateFromPointVector(p, v); } internal override void Line2_Release(IntPtr ptr) { Line2_EIK_Release(ptr); } internal override double Line2_GetA(IntPtr ptr) { return Line2_EIK_GetA(ptr); } internal override double Line2_GetB(IntPtr ptr) { return Line2_EIK_GetB(ptr); } internal override double Line2_GetC(IntPtr ptr) { return Line2_EIK_GetC(ptr); } internal override void Line2_SetA(IntPtr ptr, double a) { Line2_EIK_SetA(ptr, a); } internal override void Line2_SetB(IntPtr ptr, double b) { Line2_EIK_SetB(ptr, b); } internal override void Line2_SetC(IntPtr ptr, double c) { Line2_EIK_SetC(ptr, c); } internal override bool Line2_IsDegenerate(IntPtr ptr) { return Line2_EIK_IsDegenerate(ptr); } internal override bool Line2_IsHorizontal(IntPtr ptr) { return Line2_EIK_IsHorizontal(ptr); } internal override bool Line2_IsVertical(IntPtr ptr) { return Line2_EIK_IsVertical(ptr); } internal override bool Line2_HasOn(IntPtr linePtr, Point2d point) { return Line2_EIK_HasOn(linePtr, point); } internal override bool Line2_HasOnNegativeSide(IntPtr linePtr, Point2d point) { return Line2_EIK_HasOnNegativeSide(linePtr, point); } internal override bool Line2_HasOnPositiveSide(IntPtr linePtr, Point2d point) { return Line2_EIK_HasOnPositiveSide(linePtr, point); } internal override IntPtr Line2_Opposite(IntPtr ptr) { return Line2_EIK_Opposite(ptr); } internal override IntPtr Line2_Perpendicular(IntPtr ptr, Point2d point) { return Line2_EIK_Perpendicular(ptr, point); } internal override double Line2_X_On_Y(IntPtr ptr, double y) { return Line2_EIK_X_On_Y(ptr, y); } internal override double Line2_Y_On_X(IntPtr ptr, double x) { return Line2_EIK_Y_On_X(ptr, x); } internal override Vector2d Line2_Vector(IntPtr ptr) { return Line2_EIK_Vector(ptr); } internal override void Line2_Transform(IntPtr ptr, Point2d translation, double rotation, double scale) { Line2_EIK_Transform(ptr, translation, rotation, scale); } internal override IntPtr Line2_Copy(IntPtr ptr) { return Line2_EIK_Copy(ptr); } internal override IntPtr Line2_Convert(IntPtr ptr, CGAL_KERNEL k) { return Line2_EIK_Convert(ptr, k); } /// -------------------------------------------------------- /// /// The Ray2 Class Functions /// /// ------------------------------------------------------- internal override IntPtr Ray2_Create(Point2d position, Vector2d direction) { return Ray2_EIK_Create(position, direction); } internal override void Ray2_Release(IntPtr ptr) { Ray2_EIK_Release(ptr); } internal override bool Ray2_IsDegenerate(IntPtr ptr) { return Box2_EIK_IsDegenerate(ptr); } internal override bool Ray2_IsHorizontal(IntPtr ptr) { return Ray2_EIK_IsHorizontal(ptr); } internal override bool Ray2_IsVertical(IntPtr ptr) { return Ray2_EIK_IsVertical(ptr); } internal override bool Ray2_HasOn(IntPtr rayPtr, Point2d point) { return Ray2_EIK_HasOn(rayPtr, point); } internal override Point2d Ray2_Source(IntPtr ptr) { return Ray2_EIK_Source(ptr); } internal override Vector2d Ray2_Vector(IntPtr ptr) { return Ray2_EIK_Vector(ptr); } internal override IntPtr Ray2_Opposite(IntPtr ptr) { return Ray2_EIK_Opposite(ptr); } internal override IntPtr Ray2_Line(IntPtr ptr) { return Ray2_EIK_Line(ptr); } internal override void Ray2_Transform(IntPtr ptr, Point2d translation, double rotation, double scale) { Ray2_EIK_Transform(ptr, translation, rotation, scale); } internal override IntPtr Ray2_Copy(IntPtr ptr) { return Ray2_EIK_Copy(ptr); } internal override IntPtr Ray2_Convert(IntPtr ptr, CGAL_KERNEL k) { return Ray2_EIK_Convert(ptr, k); } /// -------------------------------------------------------- /// /// The Segment Class Functions /// /// ------------------------------------------------------- internal override IntPtr Segment2_Create(Point2d a, Point2d b) { return Segment2_EIK_Create(a, b); } internal override void Segment2_Release(IntPtr ptr) { Segment2_EIK_Release(ptr); } internal override Point2d Segment2_GetVertex(IntPtr ptr, int i) { return Segment2_EIK_GetVertex(ptr, i); } internal override void Segment2_SetVertex(IntPtr ptr, int i, Point2d point) { Segment2_EIK_SetVertex(ptr, i, point); } internal override Point2d Segment2_Min(IntPtr ptr) { return Segment2_EIK_Min(ptr); } internal override Point2d Segment2_Max(IntPtr ptr) { return Segment2_EIK_Max(ptr); } internal override bool Segment2_IsDegenerate(IntPtr ptr) { return Segment2_EIK_IsDegenerate(ptr); } internal override bool Segment2_IsHorizontal(IntPtr ptr) { return Segment2_EIK_IsHorizontal(ptr); } internal override bool Segment2_IsVertical(IntPtr ptr) { return Segment2_EIK_IsVertical(ptr); } internal override bool Segment2_HasOn(IntPtr segPtr, Point2d point) { return Segment2_EIK_HasOn(segPtr, point); } internal override Vector2d Segment2_Vector(IntPtr ptr) { return Segment2_EIK_Vector(ptr); } internal override IntPtr Segment2_Line(IntPtr ptr) { return Segment2_EIK_Line(ptr); } internal override double Segment2_SqrLength(IntPtr ptr) { return Segment2_EIK_SqrLength(ptr); } internal override void Segment2_Transform(IntPtr ptr, Point2d translation, double rotation, double scale) { Segment2_EIK_Transform(ptr, translation, rotation, scale); } internal override IntPtr Segment2_Copy(IntPtr ptr) { return Segment2_EIK_Copy(ptr); } internal override IntPtr Segment2_Convert(IntPtr ptr, CGAL_KERNEL k) { return Segment2_EIK_Convert(ptr, k); } /// -------------------------------------------------------- /// /// The Triangle2 Class Functions /// /// ------------------------------------------------------- internal override IntPtr Triangle2_Create(Point2d a, Point2d b, Point2d c) { return Triangle2_EIK_Create(a, b, c); } internal override void Triangle2_Release(IntPtr ptr) { Triangle2_EIK_Release(ptr); } internal override Point2d Triangle2_GetVertex(IntPtr ptr, int i) { return Triangle2_EIK_GetVertex(ptr, i); } internal override void Triangle2_SetVertex(IntPtr ptr, int i, Point2d point) { Segment2_EIK_SetVertex(ptr, i, point); } internal override double Triangle2_Area(IntPtr ptr) { return Triangle2_EIK_Area(ptr); } internal override BOUNDED_SIDE Triangle2_BoundedSide(IntPtr ptr, Point2d point) { return Triangle2_EIK_BoundedSide(ptr, point); } internal override ORIENTED_SIDE Triangle2_OrientedSide(IntPtr ptr, Point2d point) { return Triangle2_EIK_OrientedSide(ptr, point); } internal override ORIENTATION Triangle2_Orientation(IntPtr ptr) { return Triangle2_EIK_Orientation(ptr); } internal override bool Triangle2_IsDegenerate(IntPtr ptr) { return Triangle2_EIK_IsDegenerate(ptr); } internal override void Triangle2_Transform(IntPtr ptr, Point2d translation, double rotation, double scale) { Triangle2_EIK_Transform(ptr, translation, rotation, scale); } internal override IntPtr Triangle2_Copy(IntPtr ptr) { return Triangle2_EIK_Copy(ptr); } internal override IntPtr Triangle2_Convert(IntPtr ptr, CGAL_KERNEL k) { return Triangle2_EIK_Convert(ptr, k); } /// -------------------------------------------------------- /// /// The IsoRectancle2 Class Functions /// /// ------------------------------------------------------- internal override IntPtr Box2_Create(Point2d min, Point2d max) { return Box2_EIK_Create(min, max); } internal override void Box2_Release(IntPtr ptr) { Box2_EIK_Release(ptr); } internal override Point2d Box2_GetMin(IntPtr ptr) { return Box2_EIK_GetMin(ptr); } internal override void Box2_SetMin(IntPtr ptr, Point2d point) { Box2_EIK_SetMin(ptr, point); } internal override Point2d Box2_GetMax(IntPtr ptr) { return Box2_EIK_GetMax(ptr); } internal override void Box2_SetMax(IntPtr ptr, Point2d point) { Box2_EIK_SetMax(ptr, point); } internal override double Box2_Area(IntPtr ptr) { return Box2_EIK_Area(ptr); } internal override BOUNDED_SIDE Box2_BoundedSide(IntPtr ptr, Point2d point) { return Box2_EIK_BoundedSide(ptr, point); } internal override bool Box2_ContainsPoint(IntPtr ptr, Point2d point, bool inculdeBoundary) { return Box2_EIK_ContainsPoint(ptr, point, inculdeBoundary); } internal override bool Box2_IsDegenerate(IntPtr ptr) { return Box2_EIK_IsDegenerate(ptr); } internal override void Box2_Transform(IntPtr ptr, Point2d translation, double rotation, double scale) { Box2_EIK_Transform(ptr, translation, rotation, scale); } internal override IntPtr Box2_Copy(IntPtr ptr) { return Box2_EIK_Copy(ptr); } internal override IntPtr Box2_Convert(IntPtr ptr, CGAL_KERNEL k) { return Box2_EIK_Convert(ptr, k); } /// -------------------------------------------------------- /// /// The Point2 extern functions /// /// ------------------------------------------------------- [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr Point2_EIK_Create(); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr Point2_EIK_CreateFromPoint(Point2d point); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void Point2_EIK_Release(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern double Point2_EIK_GetX(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern double Point2_EIK_GetY(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void Point2_EIK_SetX(IntPtr ptr, double x); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void Point2_EIK_SetY(IntPtr ptr, double y); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr Point2_EIK_Copy(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr Point2_EIK_Convert(IntPtr ptr, CGAL_KERNEL k); /// -------------------------------------------------------- /// /// The Vector2 extern functions /// /// ------------------------------------------------------- [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr Vector2_EIK_Create(); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr Vector2_EIK_CreateFromVector(Vector2d vector); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void Vector2_EIK_Release(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern double Vector2_EIK_GetX(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern double Vector2_EIK_GetY(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void Vector2_EIK_SetX(IntPtr ptr, double x); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void Vector2_EIK_SetY(IntPtr ptr, double y); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern double Vector2_EIK_SqrLength(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr Vector2_EIK_Perpendicular(IntPtr ptr, ORIENTATION orientation); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void Vector2_EIK_Normalize(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern double Vector2_EIK_Magnitude(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr Vector2_EIK_Copy(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr Vector2_EIK_Convert(IntPtr ptr, CGAL_KERNEL k); /// -------------------------------------------------------- /// /// The HPoint2 extern functions /// /// ------------------------------------------------------- [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr HPoint2_EIK_Create(); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr HPoint2_EIK_CreateFromPoint(HPoint2d point); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void HPoint2_EIK_Release(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern double HPoint2_EIK_GetX(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern double HPoint2_EIK_GetY(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern double HPoint2_EIK_GetW(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void HPoint2_EIK_SetX(IntPtr ptr, double x); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void HPoint2_EIK_SetY(IntPtr ptr, double y); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void HPoint2_EIK_SetW(IntPtr ptr, double y); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr HPoint2_EIK_Copy(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr HPoint2_EIK_Convert(IntPtr ptr, CGAL_KERNEL k); /// -------------------------------------------------------- /// /// The Line2 extern functions /// /// ------------------------------------------------------- [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr Line2_EIK_Create(double a, double b, double c); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr Line2_EIK_CreateFromPoints(Point2d p1, Point2d p2); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr Line2_EIK_CreateFromPointVector(Point2d p, Vector2d v); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void Line2_EIK_Release(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern double Line2_EIK_GetA(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern double Line2_EIK_GetB(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern double Line2_EIK_GetC(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void Line2_EIK_SetA(IntPtr ptr, double a); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void Line2_EIK_SetB(IntPtr ptr, double b); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void Line2_EIK_SetC(IntPtr ptr, double c); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool Line2_EIK_IsDegenerate(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool Line2_EIK_IsHorizontal(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool Line2_EIK_IsVertical(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool Line2_EIK_HasOn(IntPtr linePtr, Point2d point); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool Line2_EIK_HasOnNegativeSide(IntPtr linePtr, Point2d point); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool Line2_EIK_HasOnPositiveSide(IntPtr linePtr, Point2d point); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr Line2_EIK_Opposite(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr Line2_EIK_Perpendicular(IntPtr ptr, Point2d point); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern double Line2_EIK_X_On_Y(IntPtr ptr, double y); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern double Line2_EIK_Y_On_X(IntPtr ptr, double x); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern Vector2d Line2_EIK_Vector(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void Line2_EIK_Transform(IntPtr ptr, Point2d translation, double rotation, double scale); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr Line2_EIK_Copy(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr Line2_EIK_Convert(IntPtr ptr, CGAL_KERNEL k); /// -------------------------------------------------------- /// /// The Ray2 extern functions /// /// ------------------------------------------------------- [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr Ray2_EIK_Create(Point2d position, Vector2d direction); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void Ray2_EIK_Release(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool Ray2_EIK_IsDegenerate(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool Ray2_EIK_IsHorizontal(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool Ray2_EIK_IsVertical(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool Ray2_EIK_HasOn(IntPtr rayPtr, Point2d point); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern Point2d Ray2_EIK_Source(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern Vector2d Ray2_EIK_Vector(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr Ray2_EIK_Opposite(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr Ray2_EIK_Line(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void Ray2_EIK_Transform(IntPtr ptr, Point2d translation, double rotation, double scale); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr Ray2_EIK_Copy(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr Ray2_EIK_Convert(IntPtr ptr, CGAL_KERNEL k); /// -------------------------------------------------------- /// /// The Segment2 extern functions /// /// ------------------------------------------------------- [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr Segment2_EIK_Create(Point2d a, Point2d b); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void Segment2_EIK_Release(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern Point2d Segment2_EIK_GetVertex(IntPtr ptr, int i); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void Segment2_EIK_SetVertex(IntPtr ptr, int i, Point2d point); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern Point2d Segment2_EIK_Min(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern Point2d Segment2_EIK_Max(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool Segment2_EIK_IsDegenerate(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool Segment2_EIK_IsHorizontal(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool Segment2_EIK_IsVertical(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool Segment2_EIK_HasOn(IntPtr segPtr, Point2d point); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern Vector2d Segment2_EIK_Vector(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr Segment2_EIK_Line(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern double Segment2_EIK_SqrLength(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void Segment2_EIK_Transform(IntPtr ptr, Point2d translation, double rotation, double scale); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr Segment2_EIK_Copy(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr Segment2_EIK_Convert(IntPtr ptr, CGAL_KERNEL k); /// -------------------------------------------------------- /// /// The Triangle2 extern functions /// /// ------------------------------------------------------- [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr Triangle2_EIK_Create(Point2d a, Point2d b, Point2d c); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void Triangle2_EIK_Release(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern Point2d Triangle2_EIK_GetVertex(IntPtr ptr, int i); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void Triangle2_EIK_SetVertex(IntPtr ptr, int i, Point2d point); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern double Triangle2_EIK_Area(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern BOUNDED_SIDE Triangle2_EIK_BoundedSide(IntPtr ptr, Point2d point); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern ORIENTED_SIDE Triangle2_EIK_OrientedSide(IntPtr ptr, Point2d point); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern ORIENTATION Triangle2_EIK_Orientation(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool Triangle2_EIK_IsDegenerate(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void Triangle2_EIK_Transform(IntPtr ptr, Point2d translation, double rotation, double scale); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr Triangle2_EIK_Copy(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr Triangle2_EIK_Convert(IntPtr ptr, CGAL_KERNEL k); /// -------------------------------------------------------- /// /// The Box2 extern functions /// /// ------------------------------------------------------- [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr Box2_EIK_Create(Point2d min, Point2d max); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void Box2_EIK_Release(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern Point2d Box2_EIK_GetMin(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void Box2_EIK_SetMin(IntPtr ptr, Point2d point); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern Point2d Box2_EIK_GetMax(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void Box2_EIK_SetMax(IntPtr ptr, Point2d point); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern double Box2_EIK_Area(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern BOUNDED_SIDE Box2_EIK_BoundedSide(IntPtr ptr, Point2d point); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool Box2_EIK_ContainsPoint(IntPtr ptr, Point2d point, bool inculdeBoundary); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool Box2_EIK_IsDegenerate(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void Box2_EIK_Transform(IntPtr ptr, Point2d translation, double rotation, double scale); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr Box2_EIK_Copy(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr Box2_EIK_Convert(IntPtr ptr, CGAL_KERNEL k); } } ================================================ FILE: CGALDotNet/Geometry/HPoint2.cs ================================================ using System; using System.Collections.Generic; using System.Text; using CGALDotNetGeometry.Numerics; using CGALDotNetGeometry.Shapes; namespace CGALDotNet.Geometry { /// /// Weighted point class /// /// public sealed class HPoint2 : HPoint2 where K : CGALKernel, new() { /// /// Create a new weighted point. /// public HPoint2() : base(new K()) { } /// /// Create a new weighted point from a value and weight as 1. /// /// The points value. public HPoint2(double v) : base(v, v, 1, new K()) { } /// /// Create a new weighted point from a x, y value and weight as 1. /// /// The points x value. /// The points y value. public HPoint2(double x, double y) : base(x, y, 1, new K()) { } /// /// Create a new weighted point from a x, y value and weight as the w value. /// /// The points x value. /// The points y value. /// The points weight value. public HPoint2(double x, double y, double w) : base(x, y, w, new K()) { } /// /// Create a new weighted point from a pointer. /// /// The pointer. internal HPoint2(IntPtr ptr) : base(new K(), ptr) { } /// /// The type of kernel object uses. /// public string KernelName => Kernel.Name; /// /// /// /// public override string ToString() { return string.Format("[HPoint2<{0}>: x={1}, y={2}]", KernelName, x, y); } /// /// Create a deep copy of the point. /// /// The deep copy. public HPoint2 Copy() { return new HPoint2(Kernel.HPoint2_Copy(Ptr)); } } /// /// /// public abstract class HPoint2 : CGALObject { /// /// Create a new weighted point. /// /// The points kernel. internal HPoint2(CGALKernel kernel) { Kernel = kernel.GeometryKernel2; Ptr = Kernel.HPoint2_Create(); } /// /// Create a new weighted point from a x, y value and weight as the w value. /// /// The points x value. /// The points y value. /// The points weight value. /// The points kernel. internal HPoint2(double x, double y, double w, CGALKernel kernel) { Kernel = kernel.GeometryKernel2; Ptr = Kernel.HPoint2_CreateFromPoint(new HPoint2d(x, y, w)); } /// /// Create a new weighted point from a existing ponter and kernel. /// /// The points kernel. /// The points pointer internal HPoint2(CGALKernel kernel, IntPtr ptr) : base(ptr) { Kernel = kernel.GeometryKernel2; } /// /// The points kernel. /// protected private GeometryKernel2 Kernel { get; private set; } /// /// Release the pointer. /// protected override void ReleasePtr() { Kernel.HPoint2_Release(Ptr); } /// /// Release the pointer. /// /// The pointer to release. protected override void ReleasePtr(IntPtr ptr) { Kernel.HPoint2_Release(ptr); } /// /// Accessor or the points x value. /// public double x { get { return Kernel.HPoint2_GetX(Ptr); } set { Kernel.HPoint2_SetX(Ptr, value); } } /// /// ccessor or the points y value. /// public double y { get { return Kernel.HPoint2_GetY(Ptr); } set { Kernel.HPoint2_SetY(Ptr, value); } } //public double w //{ // get { return Kernel.HPoint2_GetW(Ptr); } // set { Kernel.HPoint2_SetW(Ptr, value); } //} /// /// Round the point. /// /// The number of digits to round to. public void Round(int digits) { this.x = Math.Round(x, digits); this.y = Math.Round(y, digits); //this.w = Math.Round(w, digits); } /// /// Clamp the point. /// /// The points min value. /// The points max value. public void Clamp(double min, double max) { this.x = MathUtil.Clamp(x, min, max); this.y = MathUtil.Clamp(y, min, max); //this.w = MathUtil.Clamp(w, min, max); } /// /// Clamp the point. /// public void Clamp01() { this.x = MathUtil.Clamp01(x); this.y = MathUtil.Clamp01(y); //this.w = MathUtil.Clamp01(w); } /// /// Convert to another kernel. /// Must provide a different kernel to convert to or /// just a deep copy will be returned. /// /// The shape with another kernel type. public HPoint2 Convert() where T : CGALKernel, new() { var k = typeof(T).Name; var e = CGALEnum.ToKernelEnum(k); var ptr = Kernel.HPoint2_Convert(Ptr, e); return new HPoint2(ptr); } } } ================================================ FILE: CGALDotNet/Geometry/IntersectionResult2d.cs ================================================ using System; using System.Collections.Generic; using CGALDotNet.Polygons; using CGALDotNetGeometry.Numerics; using CGALDotNetGeometry.Shapes; namespace CGALDotNet.Geometry { /// /// Enum for the type of intersection geomerty. /// public enum INTERSECTION_RESULT_2D { NONE, POINT2, LINE2, RAY2, SEGMENT2, BOX2, TRIANGLE2, POLYGON2 } /// /// The intersection result struct. /// May contain up tp 6 points of data. /// public unsafe struct IntersectionResult2d { /// /// The point data for the intersection. /// Represents up to 6 points in xy order. /// private fixed double Data[12]; /// /// The number of points of data used. /// private int Count; /// /// Was there a intersection. /// public bool Hit => Type != INTERSECTION_RESULT_2D.NONE; /// /// Is the intersection a polygon. /// public bool IsPolygon => Type == INTERSECTION_RESULT_2D.POLYGON2; /// /// The intersection geometry type. /// public INTERSECTION_RESULT_2D Type; /// /// Array accessor for the point data. /// /// The array index from 0 to 6. /// The point at index i. public Point2d this[int i] { get { if ((uint)i >= 6) throw new IndexOutOfRangeException("IntersectionResult2d index out of range."); fixed (IntersectionResult2d* array = &this) { return ((Point2d*)array)[i]; } } } /// /// Results information as string. /// /// esults information as string public override string ToString() { return string.Format("[IntersectionResult2d: Type={0}, Count={1}]", Type, Count); } /// /// If result type was point get the point geometry. /// public Point2d Point => this[0]; /// /// If result type was line get the line geometry. /// public Line2d Line => new Line2d(Data[0], Data[1], Data[2]); /// /// If result type was ray get the ray geometry. /// public Ray2d Ray => new Ray2d(this[0], this[1]); /// /// If result type was segment get the segment geometry. /// public Segment2d Segment => new Segment2d(this[0], this[1]); /// /// If result type was box get the box geometry. /// public Box2d Box => new Box2d(this[0], this[1]); /// /// If result type was triangle get the triangle geometry. /// public Triangle2d Triangle => new Triangle2d(this[0], this[1], this[2]); /// /// If result type was polygon get the points that /// make up the polygon geometry. /// Should only ever have at most 6 points. /// public Point2d[] PolygonPoints { get { if (Count > 6) throw new Exception("Unexpected number of polygon points."); if (!IsPolygon) throw new Exception("Intersection not a polygon."); var points = new Point2d[Count]; for (int i = 0; i < Count; i++) points[i] = this[i]; return points; } } /// /// The intersection result as a polygon. /// /// The polygons kernel. /// The polygon. public Polygon2 Polygon() where K : CGALKernel, new() { return new Polygon2(PolygonPoints); } } } ================================================ FILE: CGALDotNet/Geometry/Line2.cs ================================================ using System; using System.Collections.Generic; using System.Text; using CGALDotNetGeometry.Numerics; using CGALDotNetGeometry.Shapes; namespace CGALDotNet.Geometry { /// /// A CGALObject that represents a line on 2D space. /// /// public sealed class Line2 : Line2 where K : CGALKernel, new() { /// /// A horizontal line on the x axis. /// public readonly static Line2 Horizontal = new Line2(Point2d.Zero, Point2d.UnitX); /// /// A vertical line on the y axis. /// public readonly static Line2 Vertical = new Line2(Point2d.Zero, Point2d.UnitY); /// /// Create a new line where ax + by + c = 0 holds. /// /// The constant in ax. /// The constant in by. /// The constant. public Line2(double a, double b, double c) : base(a, b, c, new K()) { } /// /// Create a new line that passes through the two points. /// /// The first point. /// The second point. public Line2(Point2d p1, Point2d p2) : base(p1, p2, new K()) { } /// /// Create a line that passes through the point in the direction of the vector. /// /// The point. /// The vector. public Line2(Point2d p, Vector2d v) : base(p, v, new K()) { } /// /// Create a line from a existing pointer. /// /// The pointer. internal Line2(IntPtr ptr) : base(new K(), ptr) { } /// /// Create a new line that faces in the opposite direction. /// public Line2 Opposite => new Line2(Kernel.Line2_Opposite(Ptr)); /// /// /// /// public override string ToString() { return string.Format("[Line2<{0}>: A={1}, B={2}, C={3}]", Kernel.Name, A, B, C); } /// /// Create a new line that is perpendicular to current line. /// /// A point the line should turn ccw when turning. /// The perpendicular line. public Line2 Perpendicular(Point2d point) { var ptr = Kernel.Line2_Perpendicular(Ptr, point); return new Line2(ptr); } /// /// Translate the object. /// /// The amount to translate. public void Translate(Point2d translation) { Kernel.Line2_Transform(Ptr, translation, 0, 1); } /// /// Rotate the object. /// /// The amount to rotate. public void Rotate(Degree rotation) { Kernel.Line2_Transform(Ptr, Point2d.Zero, rotation.radian, 1); } /// /// Scale the object. /// /// The amount to scale. public void Scale(double scale) { Kernel.Line2_Transform(Ptr, Point2d.Zero, 0, scale); } /// /// Translate, rotate and scale the object. /// /// The amount to translate. /// The amount to rotate in degrees. /// The amount to scale. public void Transform(Point2d translation, Degree rotation, double scale) { Kernel.Line2_Transform(Ptr, translation, rotation.radian, scale); } /// /// Create a deep copy of the line. /// /// The deep copy. public Line2 Copy() { return new Line2(Kernel.Line2_Copy(Ptr)); } } /// /// The abstract class for the line object. /// public abstract class Line2 : CGALObject { /// /// /// private Line2() { } /// /// /// /// /// /// /// internal Line2(double a, double b, double c, CGALKernel kernel) { Kernel = kernel.GeometryKernel2; Ptr = Kernel.Line2_Create(a, b, c); } /// /// /// /// /// /// internal Line2(Point2d p1, Point2d p2, CGALKernel kernel) { Kernel = kernel.GeometryKernel2; Ptr = Kernel.CreateFromPoints(p1, p2); } /// /// /// /// /// /// internal Line2(Point2d p, Vector2d v, CGALKernel kernel) { Kernel = kernel.GeometryKernel2; Ptr = Kernel.CreateFromPointVector(p, v); } internal Line2(CGALKernel kernel, IntPtr ptr) : base(ptr) { Kernel = kernel.GeometryKernel2; } /// /// The lines kernel. /// protected private GeometryKernel2 Kernel { get; private set; } /// /// Convert to shape struct. /// public Line2d Shape => new Line2d(A, B, C); /// /// The lines constant in ax. /// public double A { get { return Kernel.Line2_GetA(Ptr); } set { Kernel.Line2_SetA(Ptr, value); } } /// /// The lines constant in by. /// public double B { get { return Kernel.Line2_GetB(Ptr); } set { Kernel.Line2_SetB(Ptr, value); } } /// /// The lines constant. /// public double C { get { return Kernel.Line2_GetC(Ptr); } set { Kernel.Line2_SetC(Ptr, value); } } /// /// Is the line degenerate. /// public bool IsDegenerate => Kernel.Line2_IsDegenerate(Ptr); /// /// Is the line horizontal on the x axis. /// public bool IsHorizontal => Kernel.Line2_IsHorizontal(Ptr); /// /// Is the line vertical on the y axis. /// public bool IsVertical => Kernel.Line2_IsVertical(Ptr); /// /// Convert the line to a vector. /// public Vector2d Vector => Kernel.Line2_Vector(Ptr); /// /// Does the point lie on the line. /// /// The point. /// True if the point lies on the line. public bool HasOn(Point2d point) { return Kernel.Line2_HasOn(Ptr, point); } /// /// Does the point lies on the negative/cw side of the line. /// /// The point. /// True if the point lies on the negative/cw side of the line. public bool HasOnNegativeSide(Point2d point) { return Kernel.Line2_HasOnNegativeSide(Ptr, point); } /// /// Does the point lies on the positive/ccw side of the line. /// /// The point. /// True if the point lies on the positive/ccw side of the line. public bool HasOnPositiveSide(Point2d point) { return Kernel.Line2_HasOnPositiveSide(Ptr, point); } /// /// The lines x value given a y value. /// /// The y value. /// The lines x value given a y value. public double X_On_Y(double y) { return Kernel.Line2_X_On_Y(Ptr, y); } /// /// The lines y value given a x value. /// /// The x value. /// The lines y value given a x value. public double Y_On_X(double x) { return Kernel.Line2_Y_On_X(Ptr, x); } /// /// Release the unmanaged pointer. /// protected override void ReleasePtr() { Kernel.Line2_Release(Ptr); } /// /// Round the shape. /// /// The number of digits to round to. public void Round(int digits) { this.A = Math.Round(A, digits); this.B = Math.Round(B, digits); this.C = Math.Round(C, digits); } /// /// Convert to another kernel. /// Must provide a different kernel to convert to or /// just a deep copy will be returned. /// /// The shape with another kernel type. public Line2 Convert() where T : CGALKernel, new() { var k = typeof(T).Name; var e = CGALEnum.ToKernelEnum(k); var ptr = Kernel.Line2_Convert(Ptr, e); return new Line2(ptr); } } } ================================================ FILE: CGALDotNet/Geometry/Point2.cs ================================================ using System; using System.Collections.Generic; using System.Text; using CGALDotNetGeometry.Numerics; using CGALDotNetGeometry.Shapes; namespace CGALDotNet.Geometry { /// /// /// /// public sealed class Point2 : Point2 where K : CGALKernel, new() { /// /// The unit x point. /// public readonly static Point2 UnitX = new Point2(1, 0); /// /// The unit y point. /// public readonly static Point2 UnitY = new Point2(0, 1); /// /// A point of zeros. /// public readonly static Point2 Zero = new Point2(0); /// /// A point of ones. /// public readonly static Point2 One = new Point2(1); /// /// A point of halfs. /// public readonly static Point2 Half = new Point2(0.5); /// /// /// public Point2() : base(new K()) { } /// /// /// /// public Point2(double v) : base(v, v, new K()) { } /// /// /// /// /// public Point2(double x, double y) : base(x, y, new K()) { } /// /// /// /// internal Point2(IntPtr ptr) : base(new K(), ptr) { } /// /// The type of kernel object uses. /// public string KernelName => Kernel.Name; /// /// /// /// public override string ToString() { return string.Format("[Point2<{0}>: x={1}, y={2}]", KernelName, x, y); } /// /// /// /// public Point2 Copy() { return new Point2(Kernel.Point2_Copy(Ptr)); } } /// /// /// public abstract class Point2 : CGALObject { /// /// /// /// internal Point2(CGALKernel kernel) { Kernel = kernel.GeometryKernel2; Ptr = Kernel.Point2_Create(); } /// /// /// /// /// /// internal Point2(double x, double y, CGALKernel kernel) { Kernel = kernel.GeometryKernel2; Ptr = Kernel.Point2_CreateFromPoint(new Point2d(x,y)); } /// /// /// /// /// internal Point2(CGALKernel kernel, IntPtr ptr) : base(ptr) { Kernel = kernel.GeometryKernel2; } /// /// /// protected private GeometryKernel2 Kernel { get; private set; } /// /// /// protected override void ReleasePtr() { Kernel.Point2_Release(Ptr); } /// /// /// /// protected override void ReleasePtr(IntPtr ptr) { Kernel.Point2_Release(ptr); } /// /// /// public double x { get { return Kernel.Point2_GetX(Ptr); } set { Kernel.Point2_SetX(Ptr, value); } } /// /// /// public double y { get { return Kernel.Point2_GetY(Ptr); } set { Kernel.Point2_SetY(Ptr, value); } } /// /// Round the point. /// /// The number of digits to round to. public void Round(int digits) { this.x = Math.Round(x, digits); this.y = Math.Round(y, digits); } /// /// Clamp the point. /// /// The points min value. /// The points max value. public void Clamp(double min, double max) { this.x = MathUtil.Clamp(x, min, max); this.y = MathUtil.Clamp(y, min, max); } /// /// Clamp the point. /// public void Clamp01() { this.x = MathUtil.Clamp01(x); this.y = MathUtil.Clamp01(y); } /// /// Convert to another kernel. /// Must provide a different kernel to convert to or /// just a deep copy will be returned. /// /// The shape with another kernel type. public Point2 Convert() where T : CGALKernel, new() { var k = typeof(T).Name; var e = CGALEnum.ToKernelEnum(k); var ptr = Kernel.Point2_Convert(Ptr, e); return new Point2(ptr); } } } ================================================ FILE: CGALDotNet/Geometry/Ray2.cs ================================================ using System; using System.Collections.Generic; using System.Text; using CGALDotNetGeometry.Numerics; using CGALDotNetGeometry.Shapes; namespace CGALDotNet.Geometry { /// /// /// /// public sealed class Ray2 : Ray2 where K : CGALKernel, new() { /// /// The unit x ray. /// public readonly static Ray2 UnitX = new Ray2(Point2d.Zero, Vector2d.UnitX); /// /// The unit y ray. /// public readonly static Ray2 UnitY = new Ray2(Point2d.Zero, Vector2d.UnitY); /// /// /// /// /// public Ray2(Point2d position, Vector2d direction) : base(position, direction, new K()) { } /// /// /// /// internal Ray2(IntPtr ptr) : base(new K(), ptr) { } /// /// /// /// public override string ToString() { return string.Format("[Ray2<{0}>: Position={1}, Direction={2}]", Kernel.Name, Position, Direction); } /// /// /// public Ray2 Opposite => new Ray2(Kernel.Ray2_Opposite(Ptr)); /// /// /// public Line2 Line => new Line2(Kernel.Ray2_Line(Ptr)); /// /// Translate the shape. /// /// The amount to translate. public void Translate(Point2d translation) { Kernel.Ray2_Transform(Ptr, translation, 0, 1); } /// /// Rotate the shape. /// /// The amount to rotate. public void Rotate(Degree rotation) { Kernel.Ray2_Transform(Ptr, Point2d.Zero, rotation.radian, 1); } /// /// Scale the shape. /// /// The amount to scale. public void Scale(double scale) { Kernel.Ray2_Transform(Ptr, Point2d.Zero, 0, scale); } /// /// /// /// /// /// public void Transform(Point2d translation, Degree rotation, double scale) { Kernel.Ray2_Transform(Ptr, translation, rotation.radian, scale); } /// /// /// /// public Ray2 Copy() { return new Ray2(Kernel.Ray2_Copy(Ptr)); } } /// /// /// public abstract class Ray2 : CGALObject { /// /// /// private Ray2() { } /// /// /// /// /// /// internal Ray2(Point2d position, Vector2d direction, CGALKernel kernel) { Kernel = kernel.GeometryKernel2; Ptr = Kernel.Ray2_Create(position, direction); } /// /// /// /// /// internal Ray2(CGALKernel kernel, IntPtr ptr) : base(ptr) { Kernel = kernel.GeometryKernel2; } /// /// /// protected private GeometryKernel2 Kernel { get; private set; } /// /// Convert to shape struct. /// public Ray2d Shape => new Ray2d(Position, Direction); /// /// /// public bool IsDegenerate => Kernel.Ray2_IsDegenerate(Ptr); /// /// /// public bool IsHorizontal => Kernel.Ray2_IsHorizontal(Ptr); /// /// /// public bool IsVertical => Kernel.Ray2_IsVertical(Ptr); /// /// /// public Point2d Position => Kernel.Ray2_Source(Ptr); /// /// /// public Vector2d Direction => Kernel.Ray2_Vector(Ptr); /// /// /// /// /// public bool HasOn(Point2d point) { return Kernel.Ray2_HasOn(Ptr, point); } /// /// /// protected override void ReleasePtr() { Kernel.Ray2_Release(Ptr); } /// /// Round the shape. /// /// The number of digits to round to. public void Round(int digits) { Position.Round(digits); Direction.Round(digits); } /// /// Convert to another kernel. /// Must provide a different kernel to convert to or /// just a deep copy will be returned. /// /// The shape with another kernel type. public Ray2 Convert() where T : CGALKernel, new() { var k = typeof(T).Name; var e = CGALEnum.ToKernelEnum(k); var ptr = Kernel.Ray2_Convert(Ptr, e); return new Ray2(ptr); } } } ================================================ FILE: CGALDotNet/Geometry/Segment2.cs ================================================ using System; using System.Collections.Generic; using System.Text; using CGALDotNetGeometry.Numerics; using CGALDotNetGeometry.Shapes; namespace CGALDotNet.Geometry { /// /// /// /// public sealed class Segment2 : Segment2 where K : CGALKernel, new() { /// /// A horizontal line on the x axis. /// public readonly static Segment2 Horizontal = new Segment2(new Point2d(-1, 0), new Point2d(1, 0)); /// /// A vertical line on the y axis. /// public readonly static Segment2 Vertical = new Segment2(new Point2d(0, -1), new Point2d(0, 1)); /// /// /// /// /// public Segment2(Point2d a, Point2d b) : base(a, b, new K()) { } /// /// /// /// internal Segment2(IntPtr ptr) : base(new K(), ptr) { } /// /// /// /// public override string ToString() { return string.Format("[Segment2<{0}>: A={1}, B={2}]", Kernel.Name, A, B); } /// /// /// public Line2 Line => new Line2(Kernel.Segment2_Line(Ptr)); /// /// Translate the shape. /// /// The amount to translate. public void Translate(Point2d translation) { Kernel.Segment2_Transform(Ptr, translation, 0, 1); } /// /// Rotate the shape. /// /// The amount to rotate. public void Rotate(Degree rotation) { Kernel.Segment2_Transform(Ptr, Point2d.Zero, rotation.radian, 1); } /// /// Scale the shape. /// /// The amount to scale. public void Scale(double scale) { Kernel.Segment2_Transform(Ptr, Point2d.Zero, 0, scale); } /// /// /// /// /// /// public void Transform(Point2d translation, Degree rotation, double scale) { Kernel.Segment2_Transform(Ptr, translation, rotation.radian, scale); } /// /// /// /// public Segment2 Copy() { return new Segment2(Kernel.Segment2_Copy(Ptr)); } } /// /// /// public abstract class Segment2 : CGALObject { /// /// /// private Segment2() { } /// /// /// /// /// /// internal Segment2(Point2d a, Point2d b, CGALKernel kernel) { Kernel = kernel.GeometryKernel2; Ptr = Kernel.Segment2_Create(a, b); } /// /// /// /// /// internal Segment2(CGALKernel kernel, IntPtr ptr) : base(ptr) { Kernel = kernel.GeometryKernel2; } /// /// /// protected private GeometryKernel2 Kernel { get; private set; } /// /// Convert to shape struct. /// public Segment2d Shape => new Segment2d(A, B); /// /// /// public Point2d A { get { return Kernel.Segment2_GetVertex(Ptr, 0); } set { Kernel.Segment2_SetVertex(Ptr, 0, value); } } /// /// /// public Point2d B { get { return Kernel.Segment2_GetVertex(Ptr, 1); } set { Kernel.Segment2_SetVertex(Ptr, 1, value); } } /// /// /// public Point2d Min => Kernel.Segment2_Min(Ptr); /// /// /// public Point2d Max => Kernel.Segment2_Max(Ptr); /// /// /// public bool IsDegenerate => Kernel.Segment2_IsDegenerate(Ptr); /// /// /// public bool IsHorizontal => Kernel.Segment2_IsHorizontal(Ptr); /// /// /// public bool IsVertical => Kernel.Segment2_IsVertical(Ptr); /// /// /// public Vector2d Vector => Kernel.Segment2_Vector(Ptr); /// /// /// public double SqrLength => Kernel.Segment2_SqrLength(Ptr); /// /// /// /// /// public bool HasOn(Point2d point) { return Kernel.Line2_HasOn(Ptr, point); } /// /// /// protected override void ReleasePtr() { Kernel.Segment2_Release(Ptr); } /// /// Round the shape. /// /// The number of digits to round to. public void Round(int digits) { A.Round(digits); B.Round(digits); } /// /// Convert to another kernel. /// Must provide a different kernel to convert to or /// just a deep copy will be returned. /// /// The shape with another kernel type. public Segment2 Convert() where T : CGALKernel, new() { var k = typeof(T).Name; var e = CGALEnum.ToKernelEnum(k); var ptr = Kernel.Segment2_Convert(Ptr, e); return new Segment2(ptr); } } } ================================================ FILE: CGALDotNet/Geometry/Triangle2.cs ================================================ using System; using System.Collections.Generic; using System.Text; using CGALDotNetGeometry.Numerics; using CGALDotNetGeometry.Shapes; namespace CGALDotNet.Geometry { /// /// /// /// public sealed class Triangle2 : Triangle2 where K : CGALKernel, new() { /// /// /// /// /// /// public Triangle2(Point2d a, Point2d b, Point2d c) : base(a, b, c, new K()) { } /// /// /// /// internal Triangle2(IntPtr ptr) : base(new K(), ptr) { } /// /// /// /// public override string ToString() { return string.Format("[Triangle2<{0}>: A={1}, B={2}, C={2}]", Kernel.Name, A, B, C); } /// /// Translate the shape. /// /// The amount to translate. public void Translate(Point2d translation) { Kernel.Triangle2_Transform(Ptr, translation, 0, 1); } /// /// Rotate the shape. /// /// The amount to rotate. public void Rotate(Degree rotation) { Kernel.Triangle2_Transform(Ptr, Point2d.Zero, rotation.radian, 1); } /// /// Scale the shape. /// /// The amount to scale. public void Scale(double scale) { Kernel.Triangle2_Transform(Ptr, Point2d.Zero, 0, scale); } /// /// /// /// /// /// public void Transform(Point2d translation, Degree rotation, double scale) { Kernel.Triangle2_Transform(Ptr, translation, rotation.radian, scale); } /// /// /// /// public Triangle2 Copy() { return new Triangle2(Kernel.Triangle2_Copy(Ptr)); } } /// /// /// public abstract class Triangle2 : CGALObject { /// /// /// private Triangle2() { } /// /// /// /// /// /// /// internal Triangle2(Point2d a, Point2d b, Point2d c, CGALKernel kernel) { Kernel = kernel.GeometryKernel2; Ptr = Kernel.Triangle2_Create(a, b, c); } /// /// /// /// /// internal Triangle2(CGALKernel kernel, IntPtr ptr) : base(ptr) { Kernel = kernel.GeometryKernel2; } /// /// /// protected private GeometryKernel2 Kernel { get; private set; } /// /// Convert to shape struct. /// public Triangle2d Shape => new Triangle2d(A, B, C); /// /// /// public Point2d A { get { return Kernel.Triangle2_GetVertex(Ptr, 0); } set { Kernel.Triangle2_SetVertex(Ptr, 0, value); } } /// /// /// public Point2d B { get { return Kernel.Triangle2_GetVertex(Ptr, 1); } set { Kernel.Triangle2_SetVertex(Ptr, 1, value); } } /// /// /// public Point2d C { get { return Kernel.Triangle2_GetVertex(Ptr, 2); } set { Kernel.Triangle2_SetVertex(Ptr, 2, value); } } /// /// /// public bool IsDegenerate => Kernel.Triangle2_IsDegenerate(Ptr); /// /// /// public double Area { get { if (IsDegenerate) return 0; else return Kernel.Triangle2_Area(Ptr); } } /// /// /// public ORIENTATION Orientation { get { if (IsDegenerate) return ORIENTATION.ZERO; else return Kernel.Triangle2_Orientation(Ptr); } } /// /// /// /// /// public BOUNDED_SIDE BoundedSide(Point2d point) { if (IsDegenerate) return BOUNDED_SIDE.UNDETERMINED; else return Kernel.Triangle2_BoundedSide(Ptr, point); } /// /// /// /// /// public ORIENTED_SIDE OrientedSide(Point2d point) { if (IsDegenerate) return ORIENTED_SIDE.UNDETERMINED; else return Kernel.Triangle2_OrientedSide(Ptr, point); } /// /// /// protected override void ReleasePtr() { Kernel.Triangle2_Release(Ptr); } /// /// Round the shape. /// /// The number of digits to round to. public void Round(int digits) { A.Round(digits); B.Round(digits); C.Round(digits); } /// /// Convert to another kernel. /// Must provide a different kernel to convert to or /// just a deep copy will be returned. /// /// The shape with another kernel type. public Triangle2 Convert() where T : CGALKernel, new() { var k = typeof(T).Name; var e = CGALEnum.ToKernelEnum(k); var ptr = Kernel.Triangle2_Convert(Ptr, e); return new Triangle2(ptr); } } } ================================================ FILE: CGALDotNet/Geometry/Vector2.cs ================================================ using System; using System.Collections.Generic; using System.Text; using CGALDotNetGeometry.Numerics; using CGALDotNetGeometry.Shapes; namespace CGALDotNet.Geometry { /// /// A Vector2 object with kernel type K. /// /// The type of kernel. public sealed class Vector2 : Vector2 where K : CGALKernel, new() { /// /// The unit x vector. /// public readonly static Vector2 UnitX = new Vector2(1, 0); /// /// The unit y vector. /// public readonly static Vector2 UnitY = new Vector2(0, 1); /// /// A vector of zeros. /// public readonly static Vector2 Zero = new Vector2(0); /// /// A vector of ones. /// public readonly static Vector2 One = new Vector2(1); /// /// Create a new Vector. /// public Vector2() : base(new K()) { } /// /// Create a new vector filled with the value. /// /// The value to fill. public Vector2(double v) : base(v, v, new K()) { } /// /// Create a new vector with the values x and y. /// /// The vectors x value. /// The vectors y value. public Vector2(double x, double y) : base(x, y, new K()) { } /// /// Create a new vector from a existing pointer. /// /// The pointer object. internal Vector2(IntPtr ptr) : base(new K(), ptr) { } /// /// The type of kernel object uses. /// public string KernelName => Kernel.Name; /// /// Vector information. /// /// The vectors string information. public override string ToString() { return string.Format("[Vector2<{0}>: x={1}, y={2}]", KernelName, x, y); } /// /// Create a deep copy of the vector. /// /// The deep copy. public Vector2 Copy() { return new Vector2(Kernel.Vector2_Copy(Ptr)); } } /// /// The vectors abstract bass class. /// public abstract class Vector2 : CGALObject { /// /// Create a new vector with the kernel. /// /// The vectors kernel. internal Vector2(CGALKernel kernel) { Kernel = kernel.GeometryKernel2; Ptr = Kernel.Vector2_Create(); } /// /// Create a new vector from the x and y values. /// /// The vectors x value. /// The vectors y value. /// The vectors kernel. internal Vector2(double x, double y, CGALKernel kernel) { Kernel = kernel.GeometryKernel2; Ptr = Kernel.Vector2_CreateFromVector(new Vector2d(x, y)); } /// /// Create a new vector from a existing pointer. /// /// The vectors kernel. /// The existing pointer. internal Vector2(CGALKernel kernel, IntPtr ptr) : base(ptr) { Kernel = kernel.GeometryKernel2; } /// /// The vectors kernel. /// protected private GeometryKernel2 Kernel { get; private set; } /// /// The vectors sqr magnitude. /// public double Magnitude => Kernel.Vector2_Magnitude(Ptr); /// /// The vectors sqr magnitude. /// public double SqrMagnitude => Kernel.Vector2_SqrLength(Ptr); /// /// Access the x component. /// public double x { get { return Kernel.Vector2_GetX(Ptr); } set { Kernel.Vector2_SetX(Ptr, value); } } /// /// Access the y component. /// public double y { get { return Kernel.Vector2_GetY(Ptr); } set { Kernel.Vector2_SetY(Ptr, value); } } /// /// Release the vectors pointer. /// protected override void ReleasePtr() { Kernel.Vector2_Release(Ptr); } /// /// Release a pointer to a vector. /// /// The pointer to release. protected override void ReleasePtr(IntPtr ptr) { Kernel.Vector2_Release(ptr); } /// /// Round the vector. /// /// The number of digits to round to. public void Round(int digits) { this.x = Math.Round(x, digits); this.y = Math.Round(y, digits); } /// /// Clamp the vector. /// /// The vectors min value. /// The vectors max value. public void Clamp(double min, double max) { this.x = MathUtil.Clamp(x, min, max); this.y = MathUtil.Clamp(y, min, max); } /// /// Clamp the vector. /// public void Clamp01() { this.x = MathUtil.Clamp01(x); this.y = MathUtil.Clamp01(y); } /// /// Normalize the vector. /// public void Normalize() { Kernel.Vector2_Normalize(Ptr); } /// /// Convert to another kernel. /// Must provide a different kernel to convert to or /// just a deep copy will be returned. /// /// The shape with another kernel type. public Vector2 Convert() where T : CGALKernel, new() { var k = typeof(T).Name; var e = CGALEnum.ToKernelEnum(k); var ptr = Kernel.Vector2_Convert(Ptr, e); return new Vector2(ptr); } } } ================================================ FILE: CGALDotNet/Hulls/ConvexHull2.cs ================================================ using System; using System.Collections.Generic; using System.Text; using CGALDotNetGeometry.Numerics; using CGALDotNetGeometry.Shapes; using CGALDotNet.Polygons; namespace CGALDotNet.Hulls { /// /// The convex hull method to use. /// public enum HULL_METHOD { DEFAULT, AKL_TOUSSAINT, BYKAT, EDDY, GRAHAM_ANDREW, JARVIS }; /// /// The generic convex hull class. /// /// The kernel type public sealed class ConvexHull2 : ConvexHull2 where K : CGALKernel, new() { /// /// The static instance. /// public static readonly ConvexHull2 Instance = new ConvexHull2(); /// /// Default constructor. /// public ConvexHull2() : base(new K()) { } /// /// /// /// public override string ToString() { return string.Format("[ConvexHull2<{0}>: ]", Kernel.Name); } /// /// Find the convex of the points. /// /// The point array. /// The ararys length. /// The hull ethod to use. /// A polygon that represents the convex hull. public Polygon2 CreateHull(Point2d[] points, int count, HULL_METHOD method = HULL_METHOD.DEFAULT) { CheckCount(count); ErrorUtil.CheckArray(points, count); var ptr = Kernel.CreateHull(points, count, method); return new Polygon2(ptr); } /// /// Find the upper hull of points. /// /// The point array. /// The ararys length. /// A polygon that represents the upper hull. public Polygon2 UpperHull(Point2d[] points, int count) { CheckCount(count); ErrorUtil.CheckArray(points, count); var ptr = Kernel.UpperHull(points, count); return new Polygon2(ptr); } /// /// Find the lower hull of points. /// /// The point array. /// The ararys length. /// A polygon that represents the lower hull. public Polygon2 LowerHull(Point2d[] points, int count) { CheckCount(count); ErrorUtil.CheckArray(points, count); var ptr = Kernel.LowerHull(points, count); return new Polygon2(ptr); } } /// /// The convex hull abstract base class. /// public abstract class ConvexHull2 : CGALObject { /// /// Default constructor. /// private ConvexHull2() { } /// /// Construct hull with the kernel. /// /// The kernel internal ConvexHull2(CGALKernel kernel) { Kernel = kernel.ConvexHullKernel2; Ptr = Kernel.Create(); } /// /// The hulls kernel type. /// protected private ConvexHullKernel2 Kernel { get; private set; } /// /// Is this set of points ccw orderer. /// /// The point array. /// The ararys length. /// Is this set of points ccw orderer. public bool IsStronglyConvexCCW(Point2d[] points, int count) { CheckCount(count); ErrorUtil.CheckArray(points, count); return Kernel.IsStronglyConvexCCW(points, count); } /// /// Is this set of points cw orderer. /// /// The point array. /// The ararys length. /// Is this set of points cw orderer. public bool IsStronglyConvexCW(Point2d[] points, int count) { CheckCount(count); ErrorUtil.CheckArray(points, count); return Kernel.IsStronglyConvexCW(points, count); } /// /// Checks if the minimum number of points have been provided. /// /// The point array length. /// protected void CheckCount(int count) { if (count < 3) throw new ArgumentException("3 or more points must be provided to find the convex hull."); } /// /// Release any unmanaged resources. /// protected override void ReleasePtr() { Kernel.Release(Ptr); } } } ================================================ FILE: CGALDotNet/Hulls/ConvexHull3.cs ================================================ using System; using System.Collections.Generic; using System.Text; using CGALDotNetGeometry.Numerics; using CGALDotNetGeometry.Shapes; using CGALDotNet.Polyhedra; namespace CGALDotNet.Hulls { /// /// The generic convex hull class. /// /// The kernel type public sealed class ConvexHull3 : ConvexHull3 where K : CGALKernel, new() { /// /// The static instance. /// public static readonly ConvexHull3 Instance = new ConvexHull3(); /// /// Default constructor. /// public ConvexHull3() : base(new K()) { } /// /// /// /// public override string ToString() { return string.Format("[ConvexHull3<{0}>: ]", Kernel.Name); } /// /// Create the convex hull from a set of points. /// /// The point array. /// The point arrays length /// The hull as a polyhedron. public Polyhedron3 CreateHullAsPolyhedron(Point3d[] points, int count) { CheckCount(count); ErrorUtil.CheckArray(points, count); var ptr = Kernel.CreateHullAsPolyhedronFromPoints(points, count); return new Polyhedron3(ptr); } /// /// Create the convex hull from a set of points. /// /// The point array. /// The point arrays length /// The hull as a surface mesh. public SurfaceMesh3 CreateHullAsSurfaceMesh(Point3d[] points, int count) { CheckCount(count); ErrorUtil.CheckArray(points, count); var ptr = Kernel.CreateHullAsSurfaceMeshFromPoints(points, count); return new SurfaceMesh3(ptr); } /* /// /// /// /// /// /// public Polyhedron3 CreateHullAsPolyhedron(Plane3d[] planes, int count) { CheckCount(count); ErrorUtil.CheckArray(planes, count); var ptr = Kernel.CreateHullAsPolyhedronFromPlanes(planes, count); return new Polyhedron3(ptr); } */ /* /// /// /// /// /// /// public SurfaceMesh3 CreateHullAsSurfaceMesh(Plane3d[] planes, int count) { CheckCount(count); ErrorUtil.CheckArray(planes, count); var ptr = Kernel.CreateHullAsSurfaceMeshFromPlanes(planes, count); return new SurfaceMesh3(ptr); } */ } /// /// The convex hull abstract base class. /// public abstract class ConvexHull3 : CGALObject { /// /// Default constructor. /// private ConvexHull3() { } /// /// Construct hull with the kernel. /// /// The kernel internal ConvexHull3(CGALKernel kernel) { Kernel = kernel.ConvexHullKernel3; Ptr = Kernel.Create(); } /// /// The hulls kernel type. /// protected private ConvexHullKernel3 Kernel { get; private set; } /// /// Check if the points in the polyhedron are convex. /// /// The polyhedron. /// True if the polyhedron is convex. public bool IsStronglyConvex(Polyhedron3 poly) { return Kernel.IsPolyhedronStronglyConvex(poly.Ptr); } /// /// Check if the points in the mesh are convex. /// /// The mesh. /// True if the mesh is convex. public bool IsStronglyConvex(SurfaceMesh3 mesh) { return Kernel.IsSurfaceMeshStronglyConvex(mesh.Ptr); ; } /// /// Checks if the minimum number of points have been provided. /// /// The point array length. /// protected void CheckCount(int count) { if (count < 4) throw new ArgumentException("4 or more points must be provided to find the convex hull."); } /// /// Release any unmanaged resources. /// protected override void ReleasePtr() { Kernel.Release(Ptr); } } } ================================================ FILE: CGALDotNet/Hulls/ConvexHullKernel2.cs ================================================ using System; using System.Collections.Generic; using System.Runtime.InteropServices; using System.Text; using CGALDotNetGeometry.Numerics; using CGALDotNet.Polygons; namespace CGALDotNet.Hulls { internal abstract class ConvexHullKernel2 : CGALObjectKernel { internal abstract IntPtr Create(); internal abstract void Release(IntPtr ptr); internal abstract IntPtr CreateHull(Point2d[] points, int count, HULL_METHOD method); internal abstract IntPtr UpperHull(Point2d[] points, int count); internal abstract IntPtr LowerHull(Point2d[] points, int count); internal abstract bool IsStronglyConvexCCW(Point2d[] points, int count); internal abstract bool IsStronglyConvexCW(Point2d[] points, int count); } } ================================================ FILE: CGALDotNet/Hulls/ConvexHullKernel2_EEK.cs ================================================ using System; using System.Collections.Generic; using System.Text; using System.Runtime.InteropServices; using CGALDotNetGeometry.Numerics; using CGALDotNet.Polygons; namespace CGALDotNet.Hulls { internal class ConvexHullKernel2_EEK : ConvexHullKernel2 { internal override string Name => "EEK"; internal static readonly ConvexHullKernel2 Instance = new ConvexHullKernel2_EEK(); internal override IntPtr Create() { return ConvexHull2_EEK_Create(); } internal override void Release(IntPtr ptr) { ConvexHull2_EEK_Release(ptr); } internal override IntPtr CreateHull(Point2d[] points, int count, HULL_METHOD method) { return ConvexHull2_EEK_CreateHull(points, count, method); } internal override IntPtr UpperHull(Point2d[] points, int count) { return ConvexHull2_EEK_UpperHull(points, count); } internal override IntPtr LowerHull(Point2d[] points, int count) { return ConvexHull2_EEK_LowerHull(points, count); } internal override bool IsStronglyConvexCCW(Point2d[] points, int count) { return ConvexHull2_EEK_IsStronglyConvexCCW(points, count); } internal override bool IsStronglyConvexCW(Point2d[] points, int count) { return IsStronglyConvexCW(points, count); } [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr ConvexHull2_EEK_Create(); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void ConvexHull2_EEK_Release(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr ConvexHull2_EEK_CreateHull([In] Point2d[] points, int count, HULL_METHOD method); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr ConvexHull2_EEK_UpperHull([In] Point2d[] points, int count); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr ConvexHull2_EEK_LowerHull([In] Point2d[] points, int count); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool ConvexHull2_EEK_IsStronglyConvexCCW([In] Point2d[] points, int count); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool ConvexHull2_EEK_IsStronglyConvexCW([In] Point2d[] points, int count); } } ================================================ FILE: CGALDotNet/Hulls/ConvexHullKernel2_EIK.cs ================================================ using System; using System.Collections.Generic; using System.Text; using System.Runtime.InteropServices; using CGALDotNetGeometry.Numerics; using CGALDotNet.Polygons; namespace CGALDotNet.Hulls { internal class ConvexHullKernel2_EIK : ConvexHullKernel2 { internal override string Name => "EIK"; internal static readonly ConvexHullKernel2 Instance = new ConvexHullKernel2_EIK(); internal override IntPtr Create() { return ConvexHull2_EIK_Create(); } internal override void Release(IntPtr ptr) { ConvexHull2_EIK_Release(ptr); } internal override IntPtr CreateHull(Point2d[] points, int count, HULL_METHOD method) { return ConvexHull2_EIK_CreateHull(points, count, method); } internal override IntPtr UpperHull(Point2d[] points, int count) { return ConvexHull2_EIK_UpperHull(points, count); } internal override IntPtr LowerHull(Point2d[] points, int count) { return ConvexHull2_EIK_LowerHull(points, count); } internal override bool IsStronglyConvexCCW(Point2d[] points, int count) { return ConvexHull2_EIK_IsStronglyConvexCCW(points, count); } internal override bool IsStronglyConvexCW(Point2d[] points, int count) { return IsStronglyConvexCW(points, count); } [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr ConvexHull2_EIK_Create(); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void ConvexHull2_EIK_Release(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr ConvexHull2_EIK_CreateHull([In] Point2d[] points, int count, HULL_METHOD method); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr ConvexHull2_EIK_UpperHull([In] Point2d[] points, int count); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr ConvexHull2_EIK_LowerHull([In] Point2d[] points, int count); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool ConvexHull2_EIK_IsStronglyConvexCCW([In] Point2d[] points, int count); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool ConvexHull2_EIK_IsStronglyConvexCW([In] Point2d[] points, int count); } } ================================================ FILE: CGALDotNet/Hulls/ConvexHullKernel3.cs ================================================ using System; using System.Collections.Generic; using System.Runtime.InteropServices; using System.Text; using CGALDotNetGeometry.Numerics; using CGALDotNetGeometry.Shapes; namespace CGALDotNet.Hulls { internal abstract class ConvexHullKernel3 : CGALObjectKernel { internal abstract IntPtr Create(); internal abstract void Release(IntPtr ptr); internal abstract IntPtr CreateHullAsPolyhedronFromPoints(Point3d[] points, int count); internal abstract IntPtr CreateHullAsSurfaceMeshFromPoints(Point3d[] points, int count); internal abstract IntPtr CreateHullAsPolyhedronFromPlanes(Plane3d[] planes, int count); internal abstract IntPtr CreateHullAsSurfaceMeshFromPlanes(Plane3d[] planes, int count); internal abstract bool IsPolyhedronStronglyConvex(IntPtr ptr); internal abstract bool IsSurfaceMeshStronglyConvex(IntPtr ptr); } } ================================================ FILE: CGALDotNet/Hulls/ConvexHullKernel3_EEK.cs ================================================ using System; using System.Collections.Generic; using System.Text; using System.Runtime.InteropServices; using CGALDotNetGeometry.Numerics; using CGALDotNetGeometry.Shapes; namespace CGALDotNet.Hulls { internal class ConvexHullKernel3_EEK : ConvexHullKernel3 { internal override string Name => "EEK"; internal static readonly ConvexHullKernel3 Instance = new ConvexHullKernel3_EEK(); internal override IntPtr Create() { return ConvexHull3_EEK_Create(); } internal override void Release(IntPtr ptr) { ConvexHull3_EEK_Release(ptr); } internal override IntPtr CreateHullAsPolyhedronFromPoints(Point3d[] points, int count) { return ConvexHull3_EEK_CreateHullAsPolyhedronFromPoints(points, count); } internal override IntPtr CreateHullAsSurfaceMeshFromPoints(Point3d[] points, int count) { return ConvexHull3_EEK_CreateHullAsSurfaceMeshFromPoints((Point3d[])points, count); } internal override IntPtr CreateHullAsPolyhedronFromPlanes(Plane3d[] planes, int count) { return ConvexHull3_EEK_CreateHullAsPolyhedronFromPlanes(planes, count); } internal override IntPtr CreateHullAsSurfaceMeshFromPlanes(Plane3d[] planes, int count) { return ConvexHull3_EEK_CreateHullAsSurfaceMeshFromPlanes(planes, count); } internal override bool IsPolyhedronStronglyConvex(IntPtr ptr) { return ConvexHull3_EEK_IsPolyhedronStronglyConvex(ptr); } internal override bool IsSurfaceMeshStronglyConvex(IntPtr ptr) { return ConvexHull3_EEK_IsSurfaceMeshStronglyConvex(ptr); } [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr ConvexHull3_EEK_Create(); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void ConvexHull3_EEK_Release(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr ConvexHull3_EEK_CreateHullAsPolyhedronFromPoints(Point3d[] points, int count); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr ConvexHull3_EEK_CreateHullAsSurfaceMeshFromPoints(Point3d[] points, int count); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr ConvexHull3_EEK_CreateHullAsPolyhedronFromPlanes(Plane3d[] planes, int count); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr ConvexHull3_EEK_CreateHullAsSurfaceMeshFromPlanes(Plane3d[] planes, int count); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool ConvexHull3_EEK_IsPolyhedronStronglyConvex(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool ConvexHull3_EEK_IsSurfaceMeshStronglyConvex(IntPtr ptr); } } ================================================ FILE: CGALDotNet/Hulls/ConvexHullKernel3_EIK.cs ================================================ using System; using System.Collections.Generic; using System.Text; using System.Runtime.InteropServices; using CGALDotNetGeometry.Numerics; using CGALDotNetGeometry.Shapes; namespace CGALDotNet.Hulls { internal class ConvexHullKernel3_EIK : ConvexHullKernel3 { internal override string Name => "EIK"; internal static readonly ConvexHullKernel3 Instance = new ConvexHullKernel3_EIK(); internal override IntPtr Create() { return ConvexHull3_EIK_Create(); } internal override void Release(IntPtr ptr) { ConvexHull3_EIK_Release(ptr); } internal override IntPtr CreateHullAsPolyhedronFromPoints(Point3d[] points, int count) { return ConvexHull3_EIK_CreateHullAsPolyhedronFromPoints(points, count); } internal override IntPtr CreateHullAsSurfaceMeshFromPoints(Point3d[] points, int count) { return ConvexHull3_EIK_CreateHullAsSurfaceMeshFromPoints((Point3d[])points, count); } internal override IntPtr CreateHullAsPolyhedronFromPlanes(Plane3d[] planes, int count) { return ConvexHull3_EIK_CreateHullAsPolyhedronFromPlanes(planes, count); } internal override IntPtr CreateHullAsSurfaceMeshFromPlanes(Plane3d[] planes, int count) { return ConvexHull3_EIK_CreateHullAsSurfaceMeshFromPlanes(planes, count); } internal override bool IsPolyhedronStronglyConvex(IntPtr ptr) { return ConvexHull3_EIK_IsPolyhedronStronglyConvex(ptr); } internal override bool IsSurfaceMeshStronglyConvex(IntPtr ptr) { return ConvexHull3_EIK_IsSurfaceMeshStronglyConvex(ptr); } [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr ConvexHull3_EIK_Create(); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void ConvexHull3_EIK_Release(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr ConvexHull3_EIK_CreateHullAsPolyhedronFromPoints(Point3d[] points, int count); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr ConvexHull3_EIK_CreateHullAsSurfaceMeshFromPoints(Point3d[] points, int count); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr ConvexHull3_EIK_CreateHullAsPolyhedronFromPlanes(Plane3d[] planes, int count); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr ConvexHull3_EIK_CreateHullAsSurfaceMeshFromPlanes(Plane3d[] planes, int count); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool ConvexHull3_EIK_IsPolyhedronStronglyConvex(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool ConvexHull3_EIK_IsSurfaceMeshStronglyConvex(IntPtr ptr); } } ================================================ FILE: CGALDotNet/Meshing/ConformingTriangulation2.cs ================================================ using System; using System.Collections.Generic; using System.Text; using CGALDotNet.Polygons; using CGALDotNetGeometry.Numerics; using CGALDotNetGeometry.Shapes; namespace CGALDotNet.Meshing { /// /// /// /// public sealed class ConformingTriangulation2 : ConformingTriangulation2 where K : CGALKernel, new() { /// /// A static instance of the triangulation. /// public static readonly ConformingTriangulation2 Instance = new ConformingTriangulation2(); /// /// /// public ConformingTriangulation2() : base(new K()) { } /// /// /// /// public ConformingTriangulation2(Point2d[] points) : base(new K(), points) { } /// /// /// /// internal ConformingTriangulation2(IntPtr ptr) : base(new K(), ptr) { } /// /// The triangulation as a string. /// /// public override string ToString() { return string.Format("[ConformingTriangulation2<{0}>: VertexCount={1}, TriangleCount={2}]", Kernel.Name, VertexCount, TriangleCount); } /// /// Insert the polygons points into the triangulation. /// May not retain the poylgons edges. /// /// public void Insert(Polygon2 polygon) { Kernel.InsertPolygon(Ptr, polygon.Ptr); } /// /// Insert the polygons points into the triangulation. /// May not retain the poylgons edges. /// /// public void Insert(PolygonWithHoles2 pwh) { Kernel.InsertPolygonWithHoles(Ptr, pwh.Ptr); } /// /// Insert the polygons points and the edges as constraints into the triangulation. /// Will retain the poylgons edges. /// /// The polygon to insert. public void InsertConstraint(Polygon2 polygon) { Kernel.InsertPolygonConstraint(Ptr, polygon.Ptr); } /// /// Insert the polygons points and the edges as constraints into the triangulation. /// Will retain the poylgons edges. /// /// The polygon to insert. public void InsertConstraint(PolygonWithHoles2 pwh) { Kernel.InsertPolygonWithHolesConstraint(Ptr, pwh.Ptr); } /// /// A deep copy of the triangulation. /// /// The deep copy. public ConformingTriangulation2 Copy() { return new ConformingTriangulation2(Kernel.Copy(Ptr)); } } /// /// /// public abstract class ConformingTriangulation2 : CGALObject { /// /// The max value the angle bounds can be. /// public const double MAX_ANGLE_BOUNDS = 0.125; /// /// /// private ConformingTriangulation2() { } /// /// /// /// internal ConformingTriangulation2(CGALKernel kernel) { Kernel = kernel.ConformingTriangulationKernel2; Ptr = Kernel.Create(); } /// /// /// /// /// internal ConformingTriangulation2(CGALKernel kernel, Point2d[] points) { Kernel = kernel.ConformingTriangulationKernel2; Ptr = Kernel.Create(); Insert(points, points.Length); } /// /// /// /// /// internal ConformingTriangulation2(CGALKernel kernel, IntPtr ptr) : base(ptr) { Kernel = kernel.ConformingTriangulationKernel2; Ptr = ptr; } /// /// The number of verices in the triangulation. /// public int VertexCount => Kernel.VertexCount(Ptr); /// /// The number of triangles in the triangulation. /// public int TriangleCount => Kernel.FaceCount(Ptr); /// /// The number of indices need to represent the /// triangulation (number of triangles * 3). /// public int IndiceCount => TriangleCount * 3; /// /// The conforming triangulation kernel. /// internal ConformingTriangulationKernel2 Kernel { get; private set; } /// /// Clear the triangulation. /// public void Clear() { Kernel.Clear(Ptr); } /// /// /// /// public void Insert(Point2d point) { Kernel.InsertPoint(Ptr, point); } /// /// /// /// /// public void Insert(Point2d[] points, int count) { ErrorUtil.CheckArray(points, count); Kernel.InsertPoints(Ptr, points, count); } /// /// /// /// /// public void GetPoints( Point2d[] points, int count) { ErrorUtil.CheckArray(points, count); Kernel.GetPoints(Ptr, points, count); } /// /// /// /// /// public void GetIndices(int[] indices, int count) { ErrorUtil.CheckArray(indices, count); Kernel.GetIndices(Ptr, indices, count); } /// /// Translate the triangulation. /// /// The amount to translate. public void Translate(Point2d translation) { Kernel.Transform(Ptr, translation, 0, 1); } /// /// Rotate the triangulation. /// /// The amount to rotate in radians. public void Rotate(Radian rotation) { Kernel.Transform(Ptr, Point2d.Zero, rotation.angle, 1); } /// /// Scale the triangulation. /// /// The amount to scale. public void Scale(double scale) { Kernel.Transform(Ptr, Point2d.Zero, 0, scale); } /// /// Transform the triangulation with a TRS matrix. /// /// The amount to translate. /// The amount to rotate. /// The amount to scale. public void Transform(Point2d translation, Radian rotation, double scale) { Kernel.Transform(Ptr, translation, rotation.angle, scale); } /// /// /// /// /// public void InsertConstraint(Point2d a, Point2d b) { Kernel.InsertSegmentConstraint(Ptr, a, b); } /// /// /// /// public void InsertConstraint(Segment2d segment) { Kernel.InsertSegmentConstraint(Ptr, segment.A, segment.B); } /// /// /// /// /// public void InsertConstraints(Segment2d[] segments, int count) { ErrorUtil.CheckArray(segments, count); Kernel.InsertSegmentConstraints(Ptr, segments, count); } /// /// Make the mesh delaunay. /// public void MakeDelaunay() { Kernel.MakeDelaunay(Ptr); } /// /// Make the mesh /// public void MakeGabriel() { Kernel.MakeGabriel(Ptr); } /// /// Refine the mesh into smaller triangles. /// /// Default shape bound. 0.125 corresponds to abound 20.6 degree. Max 0.125 value. /// Upper bound on the length of the longest edge. public void Refine(double angleBounds, double lengthBounds) { if (angleBounds > MAX_ANGLE_BOUNDS) angleBounds = MAX_ANGLE_BOUNDS; if (lengthBounds <= 0) return; Kernel.RefineAndOptimize(Ptr, 1, angleBounds, lengthBounds); } /// /// Refine the mesh into smaller triangles. /// /// Default shape bound. 0.125 corresponds to abound 20.6 degree. Max 0.125 value. /// Upper bound on the length of the longest edge. /// Seeds point in polygons that are not to be refined. public void Refine(double angleBounds, double lengthBounds, Point2d[] seeds) { if (angleBounds > MAX_ANGLE_BOUNDS) angleBounds = MAX_ANGLE_BOUNDS; if (lengthBounds <= 0) return; Kernel.RefineAndOptimizeWithSeeds(Ptr, 1, angleBounds, lengthBounds, seeds, seeds.Length); } /// /// /// /// public override void Print(StringBuilder builder) { builder.AppendLine(ToString()); builder.AppendLine("VertexCount = " + VertexCount); builder.AppendLine("TriangleCount = " + TriangleCount); builder.AppendLine("IndiceCount = " + IndiceCount); } /// /// Release any unmanaged resources. /// protected override void ReleasePtr() { Kernel.Release(Ptr); } } } ================================================ FILE: CGALDotNet/Meshing/ConformingTriangulationKernel2.cs ================================================ using System; using System.Collections.Generic; using System.Text; using System.Runtime.InteropServices; using CGALDotNetGeometry.Numerics; using CGALDotNetGeometry.Shapes; namespace CGALDotNet.Meshing { internal abstract class ConformingTriangulationKernel2 : CGALObjectKernel { internal abstract IntPtr Create(); internal abstract void Release(IntPtr ptr); internal abstract void Clear(IntPtr ptr); internal abstract IntPtr Copy(IntPtr ptr); internal abstract int VertexCount(IntPtr ptr); internal abstract int FaceCount(IntPtr ptr); internal abstract void InsertPoint(IntPtr ptr, Point2d point); internal abstract void InsertPoints(IntPtr ptr, Point2d[] points, int count); internal abstract void InsertPolygon(IntPtr triPtr, IntPtr polyPtr); internal abstract void InsertPolygonWithHoles(IntPtr triPtr, IntPtr pwhPtr); internal abstract void GetPoints(IntPtr ptr, Point2d[] points, int count); internal abstract void GetIndices(IntPtr ptr, int[] indices, int count); internal abstract void Transform(IntPtr ptr, Point2d translation, double rotation, double scale); internal abstract void InsertSegmentConstraint(IntPtr ptr, Point2d a, Point2d b); internal abstract void InsertSegmentConstraints(IntPtr ptr, Segment2d[] segments, int count); internal abstract void InsertPolygonConstraint(IntPtr triPtr, IntPtr polyPtr); internal abstract void InsertPolygonWithHolesConstraint(IntPtr triPtr, IntPtr pwhPtr); internal abstract void MakeDelaunay(IntPtr ptr); internal abstract void MakeGabriel(IntPtr ptr); internal abstract void RefineAndOptimize(IntPtr ptr, int iterations, double angleBounds, double lengthBounds); internal abstract void RefineAndOptimizeWithSeeds(IntPtr ptr, int iterations, double angleBounds, double lengthBounds, Point2d[] points, int count); } } ================================================ FILE: CGALDotNet/Meshing/ConformingTriangulationKernel2_EEK.cs ================================================ using System; using System.Collections.Generic; using System.Text; using System.Runtime.InteropServices; using CGALDotNetGeometry.Numerics; using CGALDotNetGeometry.Shapes; namespace CGALDotNet.Meshing { internal class ConformingTriangulationKernel2_EEK : ConformingTriangulationKernel2 { internal override string Name => "EEK"; internal static readonly ConformingTriangulationKernel2 Instance = new ConformingTriangulationKernel2_EEK(); internal override IntPtr Create() { return ConformingTriangulation2_EEK_Create(); } internal override void Release(IntPtr ptr) { ConformingTriangulation2_EEK_Release(ptr); } internal override void Clear(IntPtr ptr) { ConformingTriangulation2_EEK_Clear(ptr); } internal override IntPtr Copy(IntPtr ptr) { return ConformingTriangulation2_EEK_Copy(ptr); } internal override int VertexCount(IntPtr ptr) { return ConformingTriangulation2_EEK_VertexCount(ptr); } internal override int FaceCount(IntPtr ptr) { return ConformingTriangulation2_EEK_FaceCount(ptr); } internal override void InsertPoint(IntPtr ptr, Point2d point) { ConformingTriangulation2_EEK_InsertPoint(ptr, point); } internal override void InsertPoints(IntPtr ptr, Point2d[] points, int count) { ConformingTriangulation2_EEK_InsertPoints(ptr, points, count); } internal override void InsertPolygon(IntPtr triPtr, IntPtr polyPtr) { ConformingTriangulation2_EEK_InsertPolygon(triPtr, polyPtr); } internal override void InsertPolygonWithHoles(IntPtr triPtr, IntPtr pwhPtr) { ConformingTriangulation2_EEK_InsertPolygonWithHoles(triPtr, pwhPtr); } internal override void GetPoints(IntPtr ptr, Point2d[] points, int count) { ConformingTriangulation2_EEK_GetPoints(ptr, points, count); } internal override void GetIndices(IntPtr ptr, int[] indices, int count) { ConformingTriangulation2_EEK_GetIndices(ptr, indices, count); } internal override void Transform(IntPtr ptr, Point2d translation, double rotation, double scale) { ConformingTriangulation2_EEK_Transform(ptr, translation, rotation, scale); } internal override void InsertSegmentConstraint(IntPtr ptr, Point2d a, Point2d b) { ConformingTriangulation2_EEK_InsertSegmentConstraint(ptr, a, b); } internal override void InsertSegmentConstraints(IntPtr ptr, Segment2d[] segments, int count) { ConformingTriangulation2_EEK_InsertSegmentConstraints(ptr, segments, count); } internal override void InsertPolygonConstraint(IntPtr triPtr, IntPtr polyPtr) { ConformingTriangulation2_EEK_InsertPolygonConstraint(triPtr, polyPtr); } internal override void InsertPolygonWithHolesConstraint(IntPtr triPtr, IntPtr pwhPtr) { ConformingTriangulation2_EEK_InsertPolygonWithHolesConstraint(triPtr, pwhPtr); } internal override void MakeDelaunay(IntPtr ptr) { ConformingTriangulation2_EEK_MakeDelaunay(ptr); } internal override void MakeGabriel(IntPtr ptr) { ConformingTriangulation2_EEK_MakeGabriel(ptr); } internal override void RefineAndOptimize(IntPtr ptr, int iterations, double angleBounds, double lengthBounds) { Conformingriangulation2_EEK_RefineAndOptimize(ptr, iterations, angleBounds, lengthBounds); } internal override void RefineAndOptimizeWithSeeds(IntPtr ptr, int iterations, double angleBounds, double lengthBounds, Point2d[] points, int count) { ConformingTriangulation2_EEK_RefineAndOptimizeWithSeeds(ptr, iterations, angleBounds, lengthBounds, points, count); } [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr ConformingTriangulation2_EEK_Create(); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void ConformingTriangulation2_EEK_Release(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void ConformingTriangulation2_EEK_Clear(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr ConformingTriangulation2_EEK_Copy(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int ConformingTriangulation2_EEK_VertexCount(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int ConformingTriangulation2_EEK_FaceCount(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void ConformingTriangulation2_EEK_InsertPoint(IntPtr ptr, Point2d point); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void ConformingTriangulation2_EEK_InsertPoints(IntPtr ptr, Point2d[] points, int count); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void ConformingTriangulation2_EEK_InsertPolygon(IntPtr triPtr, IntPtr polyPtr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void ConformingTriangulation2_EEK_InsertPolygonWithHoles(IntPtr triPtr, IntPtr pwhPtr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void ConformingTriangulation2_EEK_GetPoints(IntPtr ptr, [Out] Point2d[] points, int count); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void ConformingTriangulation2_EEK_GetIndices(IntPtr ptr, [Out] int[] indices, int count); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void ConformingTriangulation2_EEK_Transform(IntPtr ptr, Point2d translation, double rotation, double scale); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void ConformingTriangulation2_EEK_InsertSegmentConstraint(IntPtr ptr, Point2d a, Point2d b); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void ConformingTriangulation2_EEK_InsertSegmentConstraints(IntPtr ptr, Segment2d[] segments, int count); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void ConformingTriangulation2_EEK_InsertPolygonConstraint(IntPtr triPtr, IntPtr polyPtr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void ConformingTriangulation2_EEK_InsertPolygonWithHolesConstraint(IntPtr triPtr, IntPtr pwhPtr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void ConformingTriangulation2_EEK_MakeDelaunay(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void ConformingTriangulation2_EEK_MakeGabriel(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void Conformingriangulation2_EEK_RefineAndOptimize(IntPtr ptr, int iterations, double angleBounds, double lengthBounds); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void ConformingTriangulation2_EEK_RefineAndOptimizeWithSeeds(IntPtr ptr, int iterations, double angleBounds, double lengthBounds, Point2d[] points, int count); } } ================================================ FILE: CGALDotNet/Meshing/ConformingTriangulationKernel2_EIK.cs ================================================ using System; using System.Collections.Generic; using System.Text; using System.Runtime.InteropServices; using CGALDotNetGeometry.Numerics; using CGALDotNetGeometry.Shapes; namespace CGALDotNet.Meshing { internal class ConformingTriangulationKernel2_EIK : ConformingTriangulationKernel2 { internal override string Name => "EIK"; internal static readonly ConformingTriangulationKernel2 Instance = new ConformingTriangulationKernel2_EIK(); internal override IntPtr Create() { return ConformingTriangulation2_EIK_Create(); } internal override void Release(IntPtr ptr) { ConformingTriangulation2_EIK_Release(ptr); } internal override void Clear(IntPtr ptr) { ConformingTriangulation2_EIK_Clear(ptr); } internal override IntPtr Copy(IntPtr ptr) { return ConformingTriangulation2_EIK_Copy(ptr); } internal override int VertexCount(IntPtr ptr) { return ConformingTriangulation2_EIK_VertexCount(ptr); } internal override int FaceCount(IntPtr ptr) { return ConformingTriangulation2_EIK_FaceCount(ptr); } internal override void InsertPoint(IntPtr ptr, Point2d point) { ConformingTriangulation2_EIK_InsertPoint(ptr, point); } internal override void InsertPoints(IntPtr ptr, Point2d[] points, int count) { ConformingTriangulation2_EIK_InsertPoints(ptr, points, count); } internal override void InsertPolygon(IntPtr triPtr, IntPtr polyPtr) { ConformingTriangulation2_EIK_InsertPolygon(triPtr, polyPtr); } internal override void InsertPolygonWithHoles(IntPtr triPtr, IntPtr pwhPtr) { ConformingTriangulation2_EIK_InsertPolygonWithHoles(triPtr, pwhPtr); } internal override void GetPoints(IntPtr ptr, Point2d[] points, int count) { ConformingTriangulation2_EIK_GetPoints(ptr, points, count); } internal override void GetIndices(IntPtr ptr, int[] indices, int count) { ConformingTriangulation2_EIK_GetIndices(ptr, indices, count); } internal override void Transform(IntPtr ptr, Point2d translation, double rotation, double scale) { ConformingTriangulation2_EIK_Transform(ptr, translation, rotation, scale); } internal override void InsertSegmentConstraint(IntPtr ptr, Point2d a, Point2d b) { ConformingTriangulation2_EIK_InsertSegmentConstraint(ptr, a, b); } internal override void InsertSegmentConstraints(IntPtr ptr, Segment2d[] segments, int count) { ConformingTriangulation2_EIK_InsertSegmentConstraints(ptr, segments, count); } internal override void InsertPolygonConstraint(IntPtr triPtr, IntPtr polyPtr) { ConformingTriangulation2_EIK_InsertPolygonConstraint(triPtr, polyPtr); } internal override void InsertPolygonWithHolesConstraint(IntPtr triPtr, IntPtr pwhPtr) { ConformingTriangulation2_EIK_InsertPolygonWithHolesConstraint(triPtr, pwhPtr); } internal override void MakeDelaunay(IntPtr ptr) { ConformingTriangulation2_EIK_MakeDelaunay(ptr); } internal override void MakeGabriel(IntPtr ptr) { ConformingTriangulation2_EIK_MakeGabriel(ptr); } internal override void RefineAndOptimize(IntPtr ptr, int iterations, double angleBounds, double lengthBounds) { Conformingriangulation2_EIK_RefineAndOptimize(ptr, iterations, angleBounds, lengthBounds); } internal override void RefineAndOptimizeWithSeeds(IntPtr ptr, int iterations, double angleBounds, double lengthBounds, Point2d[] points, int count) { ConformingTriangulation2_EIK_RefineAndOptimizeWithSeeds(ptr, iterations, angleBounds, lengthBounds, points, count); } [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr ConformingTriangulation2_EIK_Create(); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void ConformingTriangulation2_EIK_Release(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void ConformingTriangulation2_EIK_Clear(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr ConformingTriangulation2_EIK_Copy(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int ConformingTriangulation2_EIK_VertexCount(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int ConformingTriangulation2_EIK_FaceCount(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void ConformingTriangulation2_EIK_InsertPoint(IntPtr ptr, Point2d point); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void ConformingTriangulation2_EIK_InsertPoints(IntPtr ptr, Point2d[] points, int count); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void ConformingTriangulation2_EIK_InsertPolygon(IntPtr triPtr, IntPtr polyPtr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void ConformingTriangulation2_EIK_InsertPolygonWithHoles(IntPtr triPtr, IntPtr pwhPtr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void ConformingTriangulation2_EIK_GetPoints(IntPtr ptr, [Out] Point2d[] points, int count); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void ConformingTriangulation2_EIK_GetIndices(IntPtr ptr, [Out] int[] indices, int count); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void ConformingTriangulation2_EIK_Transform(IntPtr ptr, Point2d translation, double rotation, double scale); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void ConformingTriangulation2_EIK_InsertSegmentConstraint(IntPtr ptr, Point2d a, Point2d b); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void ConformingTriangulation2_EIK_InsertSegmentConstraints(IntPtr ptr, Segment2d[] segments, int count); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void ConformingTriangulation2_EIK_InsertPolygonConstraint(IntPtr triPtr, IntPtr polyPtr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void ConformingTriangulation2_EIK_InsertPolygonWithHolesConstraint(IntPtr triPtr, IntPtr pwhPtr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void ConformingTriangulation2_EIK_MakeDelaunay(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void ConformingTriangulation2_EIK_MakeGabriel(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void Conformingriangulation2_EIK_RefineAndOptimize(IntPtr ptr, int iterations, double angleBounds, double lengthBounds); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void ConformingTriangulation2_EIK_RefineAndOptimizeWithSeeds(IntPtr ptr, int iterations, double angleBounds, double lengthBounds, Point2d[] points, int count); } } ================================================ FILE: CGALDotNet/Meshing/SkinSurfaceMeshing.cs ================================================ using System; using System.Collections.Generic; using System.Text; using CGALDotNet.Polyhedra; using CGALDotNetGeometry.Numerics; using CGALDotNetGeometry.Shapes; namespace CGALDotNet.Meshing { /// /// /// /// public sealed class SkinSurfaceMeshing : SkinSurfaceMeshing where K : CGALKernel, new() { /// /// /// public static readonly SkinSurfaceMeshing Instance = new SkinSurfaceMeshing(); /// /// /// public SkinSurfaceMeshing() : base(new K()) { } /// /// /// /// internal SkinSurfaceMeshing(IntPtr ptr) : base(new K(), ptr) { } /// /// /// /// public override string ToString() { return string.Format("[SkinMeshing<{0}>: ]", Kernel.Name); } /// /// /// /// /// /// /// /// public Polyhedron3 CreateSkinPolyhedra(double shrinkFactor, bool subdivde, Point3d[] points, int count) { if (shrinkFactor < 0) shrinkFactor = 0; if (shrinkFactor == 0) return new Polyhedron3(); ErrorUtil.CheckArray(points, count); var ptr = Kernel.MakeSkinSurface(shrinkFactor, subdivde, points, count); return new Polyhedron3(ptr); } /// /// /// /// /// /// /// /// public Polyhedron3 CreateSkinPolyhedra(double shrinkFactor, bool subdivde, HPoint3d[] points, int count) { if(shrinkFactor < 0) shrinkFactor = 0; if (shrinkFactor == 0) return new Polyhedron3(); ErrorUtil.CheckArray(points, count); var ptr = Kernel.MakeSkinSurface(shrinkFactor, subdivde, points, count); return new Polyhedron3(ptr); } } /// /// /// public abstract class SkinSurfaceMeshing : CGALObject { /// /// /// private SkinSurfaceMeshing() { } /// /// /// /// internal SkinSurfaceMeshing(CGALKernel kernel) { Kernel = kernel.SkinSurfaceMeshingKernel; Ptr = Kernel.Create(); } /// /// /// /// /// internal SkinSurfaceMeshing(CGALKernel kernel, IntPtr ptr) : base(ptr) { Kernel = kernel.SkinSurfaceMeshingKernel; Ptr = ptr; } /// /// /// internal SkinSurfaceMeshingKernel Kernel { get; private set; } /// /// Release any unmanaged resources. /// protected override void ReleasePtr() { Kernel.Release(Ptr); } } } ================================================ FILE: CGALDotNet/Meshing/SkinSurfaceMeshingKernel.cs ================================================ using System; using System.Collections.Generic; using System.Text; using CGALDotNetGeometry.Numerics; namespace CGALDotNet.Meshing { internal abstract class SkinSurfaceMeshingKernel : CGALObjectKernel { internal abstract IntPtr Create(); internal abstract void Release(IntPtr ptr); internal abstract IntPtr MakeSkinSurface(double shrinkfactor, bool subdivide, Point3d[] points, int count); internal abstract IntPtr MakeSkinSurface(double shrinkfactor, bool subdivide, HPoint3d[] points, int count); } } ================================================ FILE: CGALDotNet/Meshing/SkinSurfaceMeshingKernel_EEK.cs ================================================ using System; using System.Collections.Generic; using System.Runtime.InteropServices; using CGALDotNetGeometry.Numerics; namespace CGALDotNet.Meshing { internal class SkinSurfaceMeshingKernel_EEK : SkinSurfaceMeshingKernel { internal override string Name => "EEK"; internal static readonly SkinSurfaceMeshingKernel Instance = new SkinSurfaceMeshingKernel_EEK(); internal override IntPtr Create() { return SkinSurfaceMeshing_EEK_Create(); } internal override void Release(IntPtr ptr) { SkinSurfaceMeshing_EEK_Release(ptr); } internal override IntPtr MakeSkinSurface(double shrinkfactor, bool subdivide, Point3d[] points, int count) { return SkinSurfaceMeshing_EEK_MakeSkinSurface_Point3d(shrinkfactor, subdivide, points, count); } internal override IntPtr MakeSkinSurface(double shrinkfactor, bool subdivide, HPoint3d[] points, int count) { return SkinSurfaceMeshing_EEK_MakeSkinSurface_HPoint3d(shrinkfactor, subdivide, points, count); } [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr SkinSurfaceMeshing_EEK_Create(); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void SkinSurfaceMeshing_EEK_Release(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr SkinSurfaceMeshing_EEK_MakeSkinSurface_Point3d(double shrinkfactor, bool subdivide, Point3d[] points, int count); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr SkinSurfaceMeshing_EEK_MakeSkinSurface_HPoint3d(double shrinkfactor, bool subdivide, HPoint3d[] points, int count); } } ================================================ FILE: CGALDotNet/Meshing/TetrahedralRemeshing.cs ================================================ using System; using System.Collections.Generic; using System.Text; using CGALDotNet.Polygons; using CGALDotNetGeometry.Numerics; using CGALDotNetGeometry.Shapes; namespace CGALDotNet.Meshing { /// /// /// /// public sealed class TetrahedralRemeshing : TetrahedralRemeshing where K : CGALKernel, new() { /// /// A static instance of the tetrahedral remeshing. /// public static readonly TetrahedralRemeshing Instance = new TetrahedralRemeshing(); /// /// /// public TetrahedralRemeshing() : base(new K()) { } /// /// /// /// internal TetrahedralRemeshing(IntPtr ptr) : base(new K(), ptr) { } /// /// /// /// public override string ToString() { return string.Format("[TetrahedralRemeshing<{0}>: ]", Kernel.Name); } } /// /// /// public abstract class TetrahedralRemeshing : CGALObject { /// /// /// private TetrahedralRemeshing() { } /// /// /// /// internal TetrahedralRemeshing(CGALKernel kernel) { Kernel = kernel.TetrahedralRemeshingKernel; Ptr = Kernel.Create(); } /// /// /// /// /// internal TetrahedralRemeshing(CGALKernel kernel, IntPtr ptr) : base(ptr) { Kernel = kernel.TetrahedralRemeshingKernel; Ptr = ptr; } /// /// The tetrahedral remeshing kernel. /// internal TetrahedralRemeshingKernel Kernel { get; private set; } /// /// /// /// /// /// /// /// public int Remesh(double targetLength, int iterations, Point3d[] points, int count) { return Kernel.Remesh(Ptr, targetLength, iterations, points, count); } /// /// /// /// /// public void GetPoints(Point3d[] points, int count) { Kernel.GetPoints(Ptr, points, count); } /// /// Release any unmanaged resources. /// protected override void ReleasePtr() { Kernel.Release(Ptr); } } } ================================================ FILE: CGALDotNet/Meshing/TetrahedralRemeshingKernel.cs ================================================ using System; using System.Collections.Generic; using System.Text; using CGALDotNetGeometry.Numerics; namespace CGALDotNet.Meshing { internal abstract class TetrahedralRemeshingKernel : CGALObjectKernel { internal abstract IntPtr Create(); internal abstract void Release(IntPtr ptr); internal abstract void GetPoints(IntPtr ptr, Point3d[] points, int count); internal abstract int Remesh(IntPtr ptr, double targetLength, int iterations, Point3d[] points, int count); } } ================================================ FILE: CGALDotNet/Meshing/TetrahedralRemeshingKernel_EEK.cs ================================================ using System; using System.Collections.Generic; using System.Runtime.InteropServices; using CGALDotNetGeometry.Numerics; namespace CGALDotNet.Meshing { internal class TetrahedralRemeshingKernel_EEK : TetrahedralRemeshingKernel { internal override string Name => "EEK"; internal static readonly TetrahedralRemeshingKernel Instance = new TetrahedralRemeshingKernel_EEK(); internal override IntPtr Create() { return TetrahedralRemeshing_EEK_Create(); } internal override void Release(IntPtr ptr) { TetrahedralRemeshing_EEK_Release(ptr); } internal override void GetPoints(IntPtr ptr, Point3d[] points, int count) { TetrahedralRemeshing_EEK_GetPoints(ptr, points, count); } internal override int Remesh(IntPtr ptr, double targetLength, int iterations, Point3d[] points, int count) { return TetrahedralRemeshing_EEK_Remesh(ptr, targetLength, iterations, points, count); } [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr TetrahedralRemeshing_EEK_Create(); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void TetrahedralRemeshing_EEK_Release(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void TetrahedralRemeshing_EEK_GetPoints(IntPtr ptr, [Out] Point3d[] points, int count); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int TetrahedralRemeshing_EEK_Remesh(IntPtr ptr, double targetLength, int iterations, Point3d[] points, int count); } } ================================================ FILE: CGALDotNet/Polygons/Polygon2.cs ================================================ using System; using System.Collections; using System.Collections.Generic; using System.Text; using CGALDotNetGeometry.Numerics; using CGALDotNetGeometry.Shapes; using CGALDotNet.Triangulations; using CGALDotNet.Meshing; using CGALDotNet.Polyhedra; namespace CGALDotNet.Polygons { /// /// Generic polygon definition. /// /// The kernel type. public sealed class Polygon2 : Polygon2 where K : CGALKernel, new() { /// /// Default constructor. /// public Polygon2() : base(new K()) { } /// /// Create from a set of points. /// /// The polygons points. public Polygon2(Point2d[] points) : base(new K(), points) { } /// /// Create from a pointer. /// /// The polygons pointer. internal Polygon2(IntPtr ptr) : base(new K(), ptr) { } /// /// The polygon as a string. /// /// The polygon as a string. public override string ToString() { return string.Format("[Polygon2<{0}>: Count={1}, IsSimple={2}, Orientation={3}]", Kernel.Name, Count, IsSimple, Orientation); } /// /// Copy the polygon. /// /// The copied polygon. public Polygon2 Copy() { var copy = new Polygon2(Kernel.Copy(Ptr)); copy.Update(IsSimple, Orientation); return copy; } /// /// Triangulate the polygon. /// /// The triangle indices. public override void Triangulate(List indices) { try { var ct = ConstrainedTriangulation2.Instance; ct.InsertConstraint(this); ct.GetConstrainedDomainIndices(indices); ct.Clear(); } catch (NotImplementedException) { } catch (NotSupportedException) { } } /// /// Do the polygons intersect. /// /// The other polygon. /// Do the polygons intersect. public bool Intersects(Polygon2 polygon) { try { return PolygonBoolean2.Instance.DoIntersect(this, polygon); } catch (NotImplementedException) { } catch (NotSupportedException) { } return false; } /// /// Do the polygons intersect. /// /// The other polygon. /// Do the polygons intersect. public bool Intersects(PolygonWithHoles2 polygon) { try { return PolygonBoolean2.Instance.DoIntersect(this, polygon); } catch (NotImplementedException) { } catch (NotSupportedException) { } return false; } /// /// Do the polygons intersect. /// /// The other polygon. /// The intersection results. /// Do the polygons intersect. public bool Intersection(Polygon2 polygon, List> results) { try { return PolygonBoolean2.Instance.Intersect(this, polygon, results); } catch (NotImplementedException) { } catch (NotSupportedException) { } return false; } /// /// Do the polygons intersect. /// /// The other polygon. /// The intersection results. /// Do the polygons intersect. public bool Intersection(PolygonWithHoles2 polygon, List> results) { try { return PolygonBoolean2.Instance.Intersect(this, polygon, results); } catch (NotImplementedException) { } catch (NotSupportedException) { } return false; } /// /// Refine the polygon to a triangulation. /// Does not modify this polygon. /// /// Upper bound on the length of the longest edge. /// The base triangulation. public DelaunayTriangulation2 Refine(double lengthBounds) { return Refine(ConformingTriangulation2.MAX_ANGLE_BOUNDS, lengthBounds); } /// /// Refine the polygon to a triangulation. /// Does not modify this polygon. /// /// Default shape bound. 0.125 corresponds to abound 20.6 degree. Max 0.125 value. /// Upper bound on the length of the longest edge. /// The base triangulation. public DelaunayTriangulation2 Refine(double angleBounds, double lengthBounds) { try { var ct = ConformingTriangulation2.Instance; ct.InsertConstraint(this); ct.Refine(angleBounds, lengthBounds); int count = ct.VertexCount; var points = ArrayCache.Point2dArray(count); ct.GetPoints(points, count); ct.Clear(); return new DelaunayTriangulation2(points); } catch (NotImplementedException) { } catch (NotSupportedException) { } return new DelaunayTriangulation2(); } /// /// Partition the polygon into convex pieces. /// Does not modify this polygon. /// /// The convex partition. /// The type of partition method. public void Partition(List> results, POLYGON_PARTITION type = POLYGON_PARTITION.GREENE_APROX_CONVEX) { try { var part = PolygonPartition2.Instance; part.Partition(type, this, results); } catch (NotImplementedException) { } catch (NotSupportedException) { } } /// /// Simplify the polygon. /// /// The simplification threshold. public void Simplify(double threshold) { var param = PolygonSimplificationParams.Default; param.threshold = threshold; Simplify(param); } /// /// Simplify the polygon. /// /// The simplification parameters. public void Simplify(PolygonSimplificationParams param) { try { var sim = PolygonSimplification2.Instance; var ptr = sim.SimplifyPtr(this, param); Swap(ptr); IsUpdated = false; } catch (NotImplementedException) { } catch (NotSupportedException) { } } /// /// offset the polygon. Does not modify this polygon. /// /// The type of offset. /// The amount to offset. /// The offset results. public void Offset(OFFSET offset, double amount, List> results) { try { var off = PolygonOffset2.Instance; off.CreateOffset(offset, this, amount, results); } catch (NotImplementedException) { } catch (NotSupportedException) { } } /// /// Create a polyhedron3 mesh with one polygon face. /// /// Should the y coord of the points be used for the z coord. /// The new polyhedron mesh /// Thrown if the polygon is not simple. public Polyhedron3 ToPolyhedron3(bool xz) { if (!IsSimple) throw new InvalidOperationException("Polygon must be simple to convert to polyhedron mesh."); var poly = new Polyhedron3(); poly.CreatePolygonMesh(this, xz); return poly; } /// /// Get the dual polygon where every point s now a edge. /// /// The dual polygon. public Polygon2 Dual() { int count = Count; if (count < 3) throw new InvalidOperationException("Count < 3"); var points = new Point2d[count]; for (int i = 0; i < count; i++) { var a = GetPoint(i); var b = GetPointWrapped(i + 1); points[i] = (a + b) * 0.5; } return new Polygon2(points); } } /// /// The abstract polygon definition. /// public abstract class Polygon2 : CGALObject, IEnumerable { /// /// Is the polygon simple. /// Must be updated to find if simple. /// private bool m_isSimple; /// /// The polygons orientation. /// Must be updated to find orientation. /// private ORIENTATION m_orientation; /// /// Default constructor. /// private Polygon2() { } /// /// Construct with a new kernel. /// /// The polygon kernel. internal Polygon2(CGALKernel kernel) { Kernel = kernel.PolygonKernel2; Ptr = Kernel.Create(); } /// /// Construct with a new kernel. /// /// The polygon kernel. /// The points to construct from. internal Polygon2(CGALKernel kernel, Point2d[] points) { Kernel = kernel.PolygonKernel2; Ptr = Kernel.Create(); SetPoints(points, points.Length); Update(); } /// /// Construct with a new kernel. /// /// The polygon kernel. /// The polygons pointer. internal Polygon2(CGALKernel kernel, IntPtr ptr) : base(ptr) { Kernel = kernel.PolygonKernel2; Count = Kernel.Count(Ptr); Update(); } /// /// The number of points in the polygon. /// public int Count { get; private set; } /// /// The capacity of the point array. /// public int Capacity => Kernel.Capacity(Ptr); /// /// Is this a simple polygon. /// Certains actions can only be carried out on simple polygons. /// public bool IsSimple { get { Update(); return m_isSimple; } protected set { m_isSimple = value; } } /// /// The polygons orientation. /// Certain actions depend on the polygons orientation. /// public ORIENTATION Orientation { get { Update(); return m_orientation; } protected set { m_orientation = value; } } /// /// The orientation expressed as the clock direction. /// public CLOCK_DIR ClockDir => (CLOCK_DIR)Orientation; /// /// Is the polygon degenerate. /// Polygons with less than 3 points are degenerate. /// public bool IsDegenerate => Count < 3 || Orientation == ORIENTATION.ZERO; /// /// Is the polygon cw orientated. /// public bool IsClockWise => ClockDir == CLOCK_DIR.CLOCKWISE; /// /// Is the polygon ccw orientated. /// public bool IsCounterClockWise => ClockDir == CLOCK_DIR.COUNTER_CLOCKWISE; /// /// Is the polygon updated. /// protected bool IsUpdated { get; set; } /// /// The polygons kernel. /// Contains the functions to the unmanaged CGAL polygon. /// protected private PolygonKernel2 Kernel { get; private set; } /// /// The type of kernel object uses. /// public string KernelName => Kernel.Name; /// /// Array accessor for the polygon. /// Getting a point wraps around the polygon. /// /// /// public Point2d this[int i] { get => GetPointWrapped(i); set => SetPoint(i, value); } /// /// Mark th mesh as needing to be updated. /// public void SetIsUpdatedToFalse() { IsUpdated = false; } /// /// Valid polygons should be simple and ccw /// for most algorithms to work on them. /// public bool IsValid() { return IsSimple && IsCounterClockWise; } /// /// Valid hole polygons should be simple /// and cw to add to a polygon with holes. /// public bool IsValidHole() { return IsSimple && IsClockWise; } /// /// Clear the polygon of all points. /// public void Clear() { Count = 0; Kernel.Clear(Ptr); Update(false, ORIENTATION.ZERO); } /// /// Shrink the capacity to match the point count. /// public void ShrinkCapacityToFitCount() { Kernel.ShrinkToFit(Ptr); } /// /// Resize the point array. /// New elements will default to zero. /// /// public void Resize(int count) { Count = count; IsUpdated = false; Kernel.Resize(Ptr, count); } /// /// Remove the point at the index from the array. /// /// The points index public void Remove(int index) { if (index < 0 || index >= Count) throw new IndexOutOfRangeException("Index out of range."); Count--; IsUpdated = false; Kernel.Erase(Ptr, index); } /// /// Remove a range of points from the array. /// /// The starting index /// The number of points to remove. public void Remove(int start, int count) { if (start < 0 || start >= Count || start + count >= Count || count > Count) throw new IndexOutOfRangeException("Index out of range."); Count -= count; IsUpdated = false; Kernel.EraseRange(Ptr, start, count); } /// /// Insert the point at the index into the array. /// /// The points index. /// The point to insert. public void Insert(int index, Point2d point) { if (index < 0 || index >= Count) throw new IndexOutOfRangeException("Index out of range."); Count++; IsUpdated = false; Kernel.Insert(Ptr, index, point); } /// /// Insert a range of points into the array. /// /// The starting index /// The points to insert. /// The number of points to insert. public void Insert(int start, Point2d[] points, int count) { if (start < 0 || start >= Count) throw new IndexOutOfRangeException("Index out of range."); ErrorUtil.CheckArray(points, count); Count += count; IsUpdated = false; Kernel.InsertRange(Ptr, start, count, points); } /// /// Add the point to the end of the poylgon. /// /// The point to add. public void Add(Point2d point) { Insert(Count-1, point); } /// /// Get the point a the index. /// /// The points index to get. /// The point at index. public Point2d GetPoint(int index) { return Kernel.GetPoint(Ptr, index); } /// /// Get the point at the index /// and wrap around the polygon. /// /// The points index. /// The point at the index. public Point2d GetPointWrapped(int index) { index = MathUtil.Wrap(index, Count); return Kernel.GetPoint(Ptr, index); } /// /// Get the point at the index /// and clamp to the polygons last point. /// /// The points index. /// The point at the index. public Point2d GetPointClamped(int index) { index = MathUtil.Clamp(index, 0, Count - 1); return Kernel.GetPoint(Ptr, index); } /// /// Get all the points in the polygon. /// /// The point array to copy the data into. /// The array length. public void GetPoints(Point2d[] points, int count) { ErrorUtil.CheckArray(points, count); Kernel.GetPoints(Ptr, points, count); } /// /// Get all the polygon points. /// /// The list to copy the data into. public void GetPoints(List points) { for (int i = 0; i < Count; i++) points.Add(GetPoint(i)); } /// /// Triangulate the polygon. /// /// The triangle indices. public abstract void Triangulate(List indices); /* /// /// Triangulate the polygon. /// /// The triangless. public void Triangulate(List triangules) { int numPoints = Count; var points = ArrayCache.Point2dArray(numPoints); GetPoints(points, points.Length); // A polygon can be composed of multiple contours which are all tessellated at the same time. var contour = new ContourVertex[numPoints]; for (int i = 0; i < numPoints; i++) contour[i].Position = new Vec3(points[i].x, points[i].y, 0); // Create an instance of the tessellator. Can be reused. var tess = new Tess(); // Add the contour with a specific orientation, use "Original" if you want to keep the input orientation. tess.AddContour(contour, ContourOrientation.Clockwise); // Tessellate! // The winding rule determines how the different contours are combined together. // See http://www.glprogramming.com/red/chapter11.html (section "Winding Numbers and Winding Rules") for more information. // If you want triangles as output, you need to use "Polygons" type as output and 3 vertices per polygon. tess.Tessellate(WindingRule.EvenOdd, ElementType.Polygons, 3); int numTriangles = tess.ElementCount; for (int i = 0; i < numTriangles; i++) { var a = points[tess.Elements[i * 3 + 0]]; var b = points[tess.Elements[i * 3 + 1]]; var c = points[tess.Elements[i * 3 + 2]]; var t = new Triangle2d(a, b, c); triangules.Add(t); } } /// /// Triangulate the polygon. /// /// The triangle indices. public void Triangulate(List triangules) { int numPoints = Count; var points = new Point2d[numPoints]; GetPoints(points, points.Length); // A polygon can be composed of multiple contours which are all tessellated at the same time. var contour = new ContourVertex[numPoints]; for (int i = 0; i < numPoints; i++) contour[i].Position = new Vec3(points[i].x, points[i].y, 0); // Create an instance of the tessellator. Can be reused. var tess = new Tess(); // Add the contour with a specific orientation, use "Original" if you want to keep the input orientation. tess.AddContour(contour, ContourOrientation.Clockwise); // The winding rule determines how the different contours are combined together. // See http://www.glprogramming.com/red/chapter11.html (section "Winding Numbers and Winding Rules") for more information. // If you want triangles as output, you need to use "Polygons" type as output and 3 vertices per polygon. tess.Tessellate(WindingRule.EvenOdd, ElementType.Polygons, 3); int numTriangles = tess.ElementCount; for (int i = 0; i < numTriangles; i++) { var a = tess.Elements[i * 3 + 0]; var b = tess.Elements[i * 3 + 1]; var c = tess.Elements[i * 3 + 2]; Console.WriteLine(a); Console.WriteLine(b); Console.WriteLine(c); triangules.Add(a); triangules.Add(b); triangules.Add(c); } } */ /// /// Get all the polygon segments. /// /// The segment array to copy the data into. /// The array length. public void GetSegments(Segment2d[] segments, int count) { ErrorUtil.CheckArray(segments, count); Kernel.GetSegments(Ptr, segments, count); } /// /// Set the points at the index. /// /// The points index. /// The points value. public void SetPoint(int index, Point2d point) { Kernel.SetPoint(Ptr, index, point); IsUpdated = false; } /// /// Set the points from the array. /// If the array is larger than the polygon then /// the new points will be appended to end of polygon. /// /// The points array. /// The array length. public void SetPoints(Point2d[] points, int count) { ErrorUtil.CheckArray(points, count); Kernel.SetPoints(Ptr, points, count); Count = count; IsUpdated = false; } /// /// Reverse the polygon. /// Swithches the orientation. /// public void Reverse() { Kernel.Reverse(Ptr); m_orientation = CGALEnum.Opposite(m_orientation); } /// /// Find the bounding box for the polygon. /// /// The bounding box. public Box2d FindBoundingBox() { return Kernel.GetBoundingBox(Ptr); } /// /// Find if the polygon is simple. /// /// True if simple. public bool FindIfSimple() { if (Count < 3) return false; else return Kernel.IsSimple(Ptr); } /// /// Find if the polygon is convex. /// Must be simple to determine. /// /// True if the polygon is convex. public bool FindIfConvex() { if (IsSimple) return Kernel.IsConvex(Ptr); else return false; } /// /// Find the polygons orientation. /// Must be simple to determine. /// /// The polygons orientations. public ORIENTATION FindOrientation() { if (IsSimple) return Kernel.Orientation(Ptr); else return ORIENTATION.ZERO; } /// /// Find the orientated side the point lies on. /// Must be simple to determine. /// /// The point. /// The orientated side of the polygon the point is on. public ORIENTED_SIDE OrientedSide(Point2d point) { if (IsSimple) return Kernel.OrientedSide(Ptr, point); else return ORIENTED_SIDE.UNDETERMINED; } /// /// Find the bounded side the point lies on. /// Must be simple to determine. /// /// The point. /// The bounded side of the polygon the point is on. public BOUNDED_SIDE BoundedSide(Point2d point) { if (IsSimple) return Kernel.BoundedSide(Ptr, point); else return BOUNDED_SIDE.UNDETERMINED; } /// /// Find the polygons signed area. /// Must be simple to determine. /// /// The signed area is positive if polygon is ccw /// and negation if cw. public double FindSignedArea() { if (IsSimple) return Kernel.SignedArea(Ptr); else return 0; } /// /// The area of the polygon. /// Must be simple to determine. /// /// The abs of the signed area. public double FindArea() { return Math.Abs(FindSignedArea()); } /// /// Find the perimeter. /// This is the length of the polygon boundary. /// /// public double FindPerimeter() { return Kernel.SqPerimeter(Ptr); } /// /// Find the square perimeter. /// This is the square length of the polygon boundary. /// /// public double FindSquarePerimeter() { return Kernel.SqPerimeter(Ptr); } /// /// Does the polygon contain the points. /// Must be simple to determine. /// /// The point to find. /// Does the point on the boundary count /// True if the point is inside the polygon. public bool ContainsPoint(Point2d point, bool inculdeBoundary = true) { if (IsSimple) return Kernel.ContainsPoint(Ptr, point, Orientation, inculdeBoundary); else return false; } /// /// Round each point it polygon to a number of digits. /// /// The number of digits to round to. public void Round(int digits) { for(int i = 0; i < Count; i++) this[i] = GetPoint(i).Rounded(digits); IsUpdated = false; } /// /// Translate the polygon. /// /// The amount to translate. public void Translate(Point2d translation) { Kernel.Translate(Ptr, translation); IsUpdated = false; } /// /// Rotate the polygon. /// /// The amount to rotate in radians. public void Rotate(Degree rotation) { Kernel.Rotate(Ptr, rotation.radian); IsUpdated = false; } /// /// Scale the polygon. /// /// The amount to scale. public void Scale(double scale) { Kernel.Scale(Ptr, scale); IsUpdated = false; } /// /// Transform the polygon with a TRS matrix. /// /// The amount to translate. /// The amount to rotate. /// The amount to scale. public void Transform(Point2d translation, Degree rotation, double scale) { Kernel.Transform(Ptr, translation, rotation.radian, scale); IsUpdated = false; } /// /// Enumerate all points in the polygon. /// /// Each point in polygon. public IEnumerator GetEnumerator() { for (int i = 0; i < Count; i++) yield return GetPoint(i); } /// /// Enumerate all points in the polygon. /// /// Each point in polygon. IEnumerator IEnumerable.GetEnumerator() { return GetEnumerator(); } /// /// Return all the points in the polygon in a array. /// /// The array. public Point2d[] ToArray() { var points = new Point2d[Count]; GetPoints(points, points.Length); return points; } /// /// Get all the points in the polygon into a list. /// public void ToList(List list) { for (int i = 0; i < Count; i++) list.Add(GetPoint(i)); } /// /// Convert the polygon to a new polygon with a different kernel. /// May result in different values due to precision issues. /// /// The new kernel type. /// The new polygon. public Polygon2 Convert() where T : CGALKernel, new() { var k = typeof(T).Name; var e = CGALEnum.ToKernelEnum(k); var ptr = Kernel.Convert(Ptr, e); return new Polygon2(ptr); } /// /// Truncate a point in the polygon by splitting /// the point and shifting toward its neghbours. /// /// The points index in mesh. /// The amount to truncale. public void Truncate(int index, double amount) { if (amount <= 0) return; var a = GetPointWrapped(index - 1); var b = GetPoint(index); var c = GetPointWrapped(index + 1); var dir_ba = Point2d.Direction(b, a); var dir_bc = Point2d.Direction(b, c); var dist_ba = Point2d.Distance(b, a); var dist_bc = Point2d.Distance(b, c); if (amount >= dist_ba && amount >= dist_bc) { Remove(index); } else if (amount < dist_ba && amount < dist_bc) { var d = b + dir_ba * amount; var e = b + dir_bc * amount; Remove(index); Insert(index, d); Insert(index + 1, e); } } /// /// Print the polygon into a styring builder. /// /// public override void Print(StringBuilder builder) { Update(); builder.AppendLine(ToString()); builder.AppendLine("Capacity = " + Capacity); builder.AppendLine("CCW = " + IsCounterClockWise); builder.AppendLine("Is convex = " + FindIfConvex()); builder.AppendLine("Signed Area = " + FindSignedArea()); builder.AppendLine("Area = " + FindArea()); builder.AppendLine("Perimeter = " + FindPerimeter()); } /// /// Release the unmanaged pointer. /// protected override void ReleasePtr() { Kernel.Release(Ptr); } /// /// Release the unmanaged pointer. /// protected override void ReleasePtr(IntPtr ptr) { Kernel.Release(ptr); } /// /// Update the polygon if needed. /// protected void Update() { if (IsUpdated) return; IsUpdated = true; if (FindIfSimple()) { IsSimple = true; Orientation = FindOrientation(); } else { IsSimple = false; Orientation = ORIENTATION.ZERO; } } /// /// Update the polygon directly without calling the update /// function. /// /// Is the polygon simepl. /// The polygons orientation. protected void Update(bool isSimple, ORIENTATION orientation) { IsSimple = isSimple; Orientation = orientation; IsUpdated = true; } } } ================================================ FILE: CGALDotNet/Polygons/PolygonAlgorithm.cs ================================================ using System; using System.Collections.Generic; using System.Text; using CGALDotNetGeometry.Numerics; namespace CGALDotNet.Polygons { public abstract class PolygonAlgorithm : CGALObject { /// /// Should the input polygon be checked. /// Can disable for better performance if /// it is know all input if valid. /// public bool CheckInput = true; /// /// Check if the polygon is valid to offset. /// Should be simple and ccw. /// /// The polygon to check. protected void CheckPolygon(Polygon2 polygon) { if (polygon == null) throw new NullReferenceException("The polygon is null."); if (!CheckInput) return; if (!polygon.IsValid()) throw new InvalidOperationException("Polygon2 must be simple and ccw."); } /// /// Check if the polygon is valid to offset. /// Should be simple and ccw. /// /// The polygon to check. protected void CheckPolygon(PolygonWithHoles2 polygon) { if (polygon == null) throw new NullReferenceException("The polygon is null."); if (!CheckInput) return; if (!polygon.IsValid()) throw new InvalidOperationException("PolygonWithHoles2 must be simple and ccw and all holes must be simple and cw."); } } } ================================================ FILE: CGALDotNet/Polygons/PolygonBoolean2.cs ================================================ using System; using System.Collections.Generic; namespace CGALDotNet.Polygons { /// /// The type of boolean ops. /// public enum POLYGON_BOOLEAN { JOIN, INTERSECT, DIFFERENCE, SYMMETRIC_DIFFERENCE }; /// /// Generic polygon boolean class. /// /// The type of kernel public sealed class PolygonBoolean2 : PolygonBoolean2 where K : CGALKernel, new() { /// /// A static instance to the boolean class. /// public static readonly PolygonBoolean2 Instance = new PolygonBoolean2(); /// /// Create a new object. /// public PolygonBoolean2() : base(new K()) { } /// /// /// /// public override string ToString() { return string.Format("[PolygonBoolean2<{0}>: ]", Kernel.Name); } /// /// Perform the boolean op on the two polygons. /// /// The type of op. /// A simple ccw polygon. /// A simple ccw polygon. /// The result of the op. /// If the op was performed and the result list changed. public bool Op(POLYGON_BOOLEAN op, Polygon2 polygon1, Polygon2 polygon2, List> result) { switch (op) { case POLYGON_BOOLEAN.JOIN: return Join(polygon1, polygon2, result); case POLYGON_BOOLEAN.INTERSECT: return Intersect(polygon1, polygon2, result); case POLYGON_BOOLEAN.DIFFERENCE: return Difference(polygon1, polygon2, result); case POLYGON_BOOLEAN.SYMMETRIC_DIFFERENCE: return SymmetricDifference(polygon1, polygon2, result); } return false; } /// /// Perform the boolean op on the two polygons. /// /// The type of op. /// A simple ccw polygon. /// A simple ccw polygon. /// The result of the op. /// If the op was performed and the result list changed. public bool Op(POLYGON_BOOLEAN op, Polygon2 polygon1, PolygonWithHoles2 polygon2, List> result) { switch (op) { case POLYGON_BOOLEAN.JOIN: return Join(polygon1, polygon2, result); case POLYGON_BOOLEAN.INTERSECT: return Intersect(polygon1, polygon2, result); case POLYGON_BOOLEAN.DIFFERENCE: return Difference(polygon1, polygon2, result); case POLYGON_BOOLEAN.SYMMETRIC_DIFFERENCE: return SymmetricDifference(polygon1, polygon2, result); } return false; } /// /// Perform the boolean op on the two polygons. /// /// The type of op. /// A simple ccw polygon. /// A simple ccw polygon. /// The result of the op. /// If the op was performed and the result list changed. public bool Op(POLYGON_BOOLEAN op, PolygonWithHoles2 polygon1, PolygonWithHoles2 polygon2, List> result) { switch (op) { case POLYGON_BOOLEAN.JOIN: return Join(polygon1, polygon2, result); case POLYGON_BOOLEAN.INTERSECT: return Intersect(polygon1, polygon2, result); case POLYGON_BOOLEAN.DIFFERENCE: return Difference(polygon1, polygon2, result); case POLYGON_BOOLEAN.SYMMETRIC_DIFFERENCE: return SymmetricDifference(polygon1, polygon2, result); } return false; } /// /// Check if the polygons intesect. /// /// A simple ccw polygon. /// A simple ccw polygon. /// If the polygons intesect. public bool DoIntersect(Polygon2 polygon1, Polygon2 polygon2) { CheckPolygon(polygon1); CheckPolygon(polygon2); return Kernel.DoIntersect(Ptr, polygon1, polygon2); } /// /// Check if the polygons intesect. /// /// A simple ccw polygon. /// A simple ccw polygon. /// If the polygons intesect. public bool DoIntersect(Polygon2 polygon1, PolygonWithHoles2 polygon2) { CheckPolygon(polygon1); CheckPolygon(polygon2); return Kernel.DoIntersect(Ptr, polygon1, polygon2); } /// /// Check if the polygons intesect. /// /// A simple ccw polygon. /// A simple ccw polygon. /// If the polygons intesect. public bool DoIntersect(PolygonWithHoles2 polygon1, PolygonWithHoles2 polygon2) { CheckPolygon(polygon1); CheckPolygon(polygon2); return Kernel.DoIntersect(Ptr, polygon1, polygon2); } /// /// The union of the two polygons. /// /// A simple ccw polygon. /// A simple ccw polygon. /// The union of the polygons. /// If the op was performed and the result list changed. public bool Join(Polygon2 polygon1, Polygon2 polygon2, List> result) { CheckPolygon(polygon1); CheckPolygon(polygon2); if (Kernel.Join(Ptr, polygon1, polygon2, out IntPtr resultPtr)) { result.Add(new PolygonWithHoles2(resultPtr)); return true; } else { return false; } } /// /// The union of the two polygons. /// /// A simple ccw polygon. /// A simple ccw polygon. /// The union of the polygons. /// If the op was performed and the result list changed. public bool Join(Polygon2 polygon1, PolygonWithHoles2 polygon2, List> result) { CheckPolygon(polygon1); CheckPolygon(polygon2); if (Kernel.Join(Ptr, polygon1, polygon2, out IntPtr resultPtr)) { result.Add(new PolygonWithHoles2(resultPtr)); return true; } else { return false; } } /// /// The union of the two polygons. /// /// A simple ccw polygon. /// A simple ccw polygon. /// The union of the polygons. /// If the op was performed and the result list changed. public bool Join(PolygonWithHoles2 polygon1, PolygonWithHoles2 polygon2, List> result) { CheckPolygon(polygon1); CheckPolygon(polygon2); if (Kernel.Join(Ptr, polygon1, polygon2, out IntPtr resultPtr)) { result.Add(new PolygonWithHoles2(resultPtr)); return true; } else { return false; } } /// /// The intersection of the two polygons. /// /// A simple ccw polygon. /// A simple ccw polygon. /// The intersection of the polygons. /// If the op was performed and the result list changed. public bool Intersect(Polygon2 polygon1, Polygon2 polygon2, List> result) { CheckPolygon(polygon1); CheckPolygon(polygon2); int count = Kernel.Intersect(Ptr, polygon1, polygon2); CopyBuffer(count, result); return count != 0; } /// /// The intersection of the two polygons. /// /// A simple ccw polygon. /// A simple ccw polygon. /// The intersection of the polygons. /// If the op was performed and the result list changed. public bool Intersect(Polygon2 polygon1, PolygonWithHoles2 polygon2, List> result) { CheckPolygon(polygon1); CheckPolygon(polygon2); int count = Kernel.Intersect(Ptr, polygon1, polygon2); CopyBuffer(count, result); return count != 0; } /// /// The intersection of the two polygons. /// /// A simple ccw polygon. /// A simple ccw polygon. /// The intersection of the polygons. /// If the op was performed and the result list changed. public bool Intersect(PolygonWithHoles2 polygon1, PolygonWithHoles2 polygon2, List> result) { CheckPolygon(polygon1); CheckPolygon(polygon2); int count = Kernel.Intersect(Ptr, polygon1, polygon2); CopyBuffer(count, result); return count != 0; } /// /// The difference of the two polygons. /// /// A simple ccw polygon. /// A simple ccw polygon. /// The difference of the polygons. /// If the op was performed and the result list changed. public bool Difference(Polygon2 polygon1, Polygon2 polygon2, List> result) { CheckPolygon(polygon1); CheckPolygon(polygon2); int count = Kernel.Difference(Ptr, polygon1, polygon2); CopyBuffer(count, result); return count != 0; } /// /// The difference of the two polygons. /// /// A simple ccw polygon. /// A simple ccw polygon. /// The difference of the polygons. /// If the op was performed and the result list changed. public bool Difference(Polygon2 polygon1, PolygonWithHoles2 polygon2, List> result) { CheckPolygon(polygon1); CheckPolygon(polygon2); int count = Kernel.Difference(Ptr, polygon1, polygon2); CopyBuffer(count, result); return count != 0; } /// /// The difference of the two polygons. /// /// A simple ccw polygon. /// A simple ccw polygon. /// The difference of the polygons. /// If the op was performed and the result list changed. public bool Difference(PolygonWithHoles2 polygon1, PolygonWithHoles2 polygon2, List> result) { CheckPolygon(polygon1); CheckPolygon(polygon2); int count = Kernel.Difference(Ptr, polygon1, polygon2); CopyBuffer(count, result); return count != 0; } /// /// The symmetric difference of the two polygons. /// /// A simple ccw polygon. /// A simple ccw polygon. /// The symmetric difference of the polygons. /// If the op was performed and the result list changed. public bool SymmetricDifference(Polygon2 polygon1, Polygon2 polygon2, List> result) { CheckPolygon(polygon1); CheckPolygon(polygon2); int count = Kernel.SymmetricDifference(Ptr, polygon1, polygon2); CopyBuffer(count, result); return count != 0; } /// /// The symmetric difference of the two polygons. /// /// A simple ccw polygon. /// A simple ccw polygon. /// The symmetric difference of the polygons. /// If the op was performed and the result list changed. public bool SymmetricDifference(Polygon2 polygon1, PolygonWithHoles2 polygon2, List> result) { CheckPolygon(polygon1); CheckPolygon(polygon2); int count = Kernel.SymmetricDifference(Ptr, polygon1, polygon2); CopyBuffer(count, result); return count != 0; } /// /// The symmetric difference of the two polygons. /// /// A simple ccw polygon. /// A simple ccw polygon. /// The symmetric difference of the polygons. /// If the op was performed and the result list changed. public bool SymmetricDifference(PolygonWithHoles2 polygon1, PolygonWithHoles2 polygon2, List> result) { CheckPolygon(polygon1); CheckPolygon(polygon2); int count = Kernel.SymmetricDifference(Ptr, polygon1, polygon2); CopyBuffer(count, result); return count != 0; } /// /// The complement of the polygon. /// /// A simple ccw polygon. /// The complement of the polygon. public void Complement(PolygonWithHoles2 polygon, List> result) { CheckPolygon(polygon); int count = Kernel.Complement(Ptr, polygon); CopyBuffer(count, result); } /// /// Copy the unmanaged polygon objects created /// into the result list. /// /// The number of objects in the buffer. /// The result lis. private void CopyBuffer(int count, List> result) { for (int i = 0; i < count; i++) result.Add(CopyBufferItem(i)); ClearBuffer(); } /// /// Copy the unmanaged polygon object. /// /// The index of the polygon in the buffer. /// The polygon copy. private PolygonWithHoles2 CopyBufferItem(int index) { var ptr = Kernel.CopyBufferItem(Ptr, index); return new PolygonWithHoles2(ptr); } } /// /// Abstract base class for polygon boolean. /// public abstract class PolygonBoolean2 : PolygonAlgorithm { private PolygonBoolean2() { } internal PolygonBoolean2(CGALKernel kernel) { Kernel = kernel.PolygonBooleanKernel2; Ptr = Kernel.Create(); } /// /// The polygon boolean kernel. /// protected private PolygonBooleanKernel2 Kernel { get; private set; } /// /// Clear the unmanaged buffer. /// protected void ClearBuffer() { Kernel.ClearBuffer(Ptr); } /// /// Release the unmanaged resourses. /// protected override void ReleasePtr() { Kernel.Release(Ptr); } } } ================================================ FILE: CGALDotNet/Polygons/PolygonBooleanKernel2.cs ================================================ using System; using System.Collections.Generic; using System.Runtime.InteropServices; namespace CGALDotNet.Polygons { internal abstract class PolygonBooleanKernel2 : CGALObjectKernel { internal abstract IntPtr Create(); internal abstract void Release(IntPtr ptr); internal abstract void ClearBuffer(IntPtr ptr); internal abstract IntPtr CopyBufferItem(IntPtr ptr, int index); internal abstract bool DoIntersect(IntPtr ptr, Polygon2 poly1, Polygon2 poly2); internal abstract bool DoIntersect(IntPtr ptr, Polygon2 poly1, PolygonWithHoles2 poly2); internal abstract bool DoIntersect(IntPtr ptr, PolygonWithHoles2 poly1, PolygonWithHoles2 poly2); internal abstract bool Join(IntPtr ptr, Polygon2 poly1, Polygon2 poly2, out IntPtr result); internal abstract bool Join(IntPtr ptr, Polygon2 poly1, PolygonWithHoles2 poly2, out IntPtr result); internal abstract bool Join(IntPtr ptr, PolygonWithHoles2 poly1, PolygonWithHoles2 poly2, out IntPtr result); internal abstract int Intersect(IntPtr ptr, Polygon2 poly, Polygon2 poly2); internal abstract int Intersect(IntPtr ptr, Polygon2 poly1, PolygonWithHoles2 poly2); internal abstract int Intersect(IntPtr ptr, PolygonWithHoles2 poly1, PolygonWithHoles2 poly2); internal abstract int Difference(IntPtr ptr, Polygon2 poly1, Polygon2 poly2); internal abstract int Difference(IntPtr ptr, Polygon2 poly1, PolygonWithHoles2 poly2); internal abstract int Difference(IntPtr ptr, PolygonWithHoles2 poly1, PolygonWithHoles2 poly2); internal abstract int SymmetricDifference(IntPtr ptr, Polygon2 poly1, Polygon2 poly2); internal abstract int SymmetricDifference(IntPtr ptr, Polygon2 poly1, PolygonWithHoles2 poly2); internal abstract int SymmetricDifference(IntPtr ptr, PolygonWithHoles2 poly1, PolygonWithHoles2 poly2); internal abstract int Complement(IntPtr ptr, PolygonWithHoles2 poly); } } ================================================ FILE: CGALDotNet/Polygons/PolygonBooleanKernel2_EEK.cs ================================================ using System; using System.Collections.Generic; using System.Runtime.InteropServices; namespace CGALDotNet.Polygons { internal class PolygonBooleanKernel2_EEK : PolygonBooleanKernel2 { internal override string Name => "EEK"; internal static readonly PolygonBooleanKernel2 Instance = new PolygonBooleanKernel2_EEK(); internal override IntPtr Create() { return PolygonBoolean2_EEK_Create(); } internal override void Release(IntPtr ptr) { PolygonBoolean2_EEK_Release(ptr); } internal override void ClearBuffer(IntPtr ptr) { PolygonBoolean2_EEK_ClearBuffer(ptr); } internal override IntPtr CopyBufferItem(IntPtr ptr, int index) { return PolygonBoolean2_EEK_CopyBufferItem(ptr, index); } internal override bool DoIntersect(IntPtr ptr, Polygon2 poly1, Polygon2 poly2) { return PolygonBoolean2_EEK_DoIntersect_P_P(ptr, poly1.Ptr, poly2.Ptr); } internal override bool DoIntersect(IntPtr ptr, Polygon2 poly1, PolygonWithHoles2 poly2) { return PolygonBoolean2_EEK_DoIntersect_P_PWH(ptr, poly1.Ptr, poly2.Ptr); } internal override bool DoIntersect(IntPtr ptr, PolygonWithHoles2 poly1, PolygonWithHoles2 poly2) { return PolygonBoolean2_EEK_DoIntersect_PWH_PWH(ptr, poly1.Ptr, poly2.Ptr); } internal override int Intersect(IntPtr ptr, Polygon2 poly1, Polygon2 poly2) { return PolygonBoolean2_EEK_Intersect_P_P(ptr, poly1.Ptr, poly2.Ptr); } internal override int Intersect(IntPtr ptr, Polygon2 poly1, PolygonWithHoles2 poly2) { return PolygonBoolean2_EEK_Intersect_P_PWH(ptr, poly1.Ptr, poly2.Ptr); } internal override int Intersect(IntPtr ptr, PolygonWithHoles2 poly1, PolygonWithHoles2 poly2) { return PolygonBoolean2_EEK_Intersect_PWH_PWH(ptr, poly1.Ptr, poly2.Ptr); } internal override bool Join(IntPtr ptr, Polygon2 poly1, Polygon2 poly2, out IntPtr result) { return PolygonBoolean2_EEK_Join_P_P(ptr, poly1.Ptr, poly2.Ptr, out result); } internal override bool Join(IntPtr ptr, Polygon2 poly1, PolygonWithHoles2 poly2, out IntPtr result) { return PolygonBoolean2_EEK_Join_P_PWH(ptr, poly1.Ptr, poly2.Ptr, out result); } internal override bool Join(IntPtr ptr, PolygonWithHoles2 poly1, PolygonWithHoles2 poly2, out IntPtr result) { return PolygonBoolean2_EEK_Join_PWH_PWH(ptr, poly1.Ptr, poly2.Ptr, out result); } internal override int Difference(IntPtr ptr, Polygon2 poly1, Polygon2 poly2) { return PolygonBoolean2_EEK_Difference_P_P(ptr, poly1.Ptr, poly2.Ptr); } internal override int Difference(IntPtr ptr, Polygon2 poly1, PolygonWithHoles2 poly2) { return PolygonBoolean2_EEK_Difference_P_PWH(ptr, poly1.Ptr, poly2.Ptr); } internal override int Difference(IntPtr ptr, PolygonWithHoles2 poly1, PolygonWithHoles2 poly2) { return PolygonBoolean2_EEK_Difference_PWH_PWH(ptr, poly1.Ptr, poly2.Ptr); } internal override int SymmetricDifference(IntPtr ptr, PolygonWithHoles2 poly1, PolygonWithHoles2 poly2) { return PolygonBoolean2_EEK_SymmetricDifference_PWH_PWH(ptr, poly1.Ptr, poly2.Ptr); } internal override int SymmetricDifference(IntPtr ptr, Polygon2 poly1, Polygon2 poly2) { return PolygonBoolean2_EEK_SymmetricDifference_P_P(ptr, poly1.Ptr, poly2.Ptr); } internal override int SymmetricDifference(IntPtr ptr, Polygon2 poly1, PolygonWithHoles2 poly2) { return PolygonBoolean2_EEK_SymmetricDifference_P_PWH(ptr, poly1.Ptr, poly2.Ptr); } internal override int Complement(IntPtr ptr, PolygonWithHoles2 poly) { return PolygonBoolean2_EEK_Complement_PWH(ptr, poly.Ptr); } [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr PolygonBoolean2_EEK_Create(); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void PolygonBoolean2_EEK_Release(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void PolygonBoolean2_EEK_ClearBuffer(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr PolygonBoolean2_EEK_CopyBufferItem(IntPtr ptr, int index); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool PolygonBoolean2_EEK_DoIntersect_P_P(IntPtr ptr0, IntPtr ptr1, IntPtr ptr2); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool PolygonBoolean2_EEK_DoIntersect_P_PWH(IntPtr ptr0, IntPtr ptr1, IntPtr ptr2); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool PolygonBoolean2_EEK_DoIntersect_PWH_PWH(IntPtr ptr0, IntPtr ptr1, IntPtr ptr2); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool PolygonBoolean2_EEK_Join_P_P(IntPtr ptr0, IntPtr ptr1, IntPtr ptr2, out IntPtr result); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool PolygonBoolean2_EEK_Join_P_PWH(IntPtr ptr0, IntPtr ptr1, IntPtr ptr2, out IntPtr result); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool PolygonBoolean2_EEK_Join_PWH_PWH(IntPtr ptr0, IntPtr ptr1, IntPtr ptr2, out IntPtr result); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int PolygonBoolean2_EEK_Intersect_P_P(IntPtr ptr0, IntPtr ptr1, IntPtr ptr2); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int PolygonBoolean2_EEK_Intersect_P_PWH(IntPtr ptr0, IntPtr ptr1, IntPtr ptr2); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int PolygonBoolean2_EEK_Intersect_PWH_PWH(IntPtr ptr0, IntPtr ptr1, IntPtr ptr2); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int PolygonBoolean2_EEK_Difference_P_P(IntPtr ptr0, IntPtr ptr1, IntPtr ptr2); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int PolygonBoolean2_EEK_Difference_P_PWH(IntPtr ptr0, IntPtr ptr1, IntPtr ptr2); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int PolygonBoolean2_EEK_Difference_PWH_PWH(IntPtr ptr0, IntPtr ptr1, IntPtr ptr2); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int PolygonBoolean2_EEK_SymmetricDifference_P_P(IntPtr ptr0, IntPtr ptr1, IntPtr ptr2); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int PolygonBoolean2_EEK_SymmetricDifference_P_PWH(IntPtr ptr0, IntPtr ptr1, IntPtr ptr2); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int PolygonBoolean2_EEK_SymmetricDifference_PWH_PWH(IntPtr ptr0, IntPtr ptr1, IntPtr ptr2); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int PolygonBoolean2_EEK_Complement_PWH(IntPtr ptr0, IntPtr ptr1); } } ================================================ FILE: CGALDotNet/Polygons/PolygonBooleanKernel2_EIK.cs ================================================ using System; using System.Collections.Generic; using System.Runtime.InteropServices; namespace CGALDotNet.Polygons { internal class PolygonBooleanKernel2_EIK : PolygonBooleanKernel2 { internal override string Name => "EIK"; internal static readonly PolygonBooleanKernel2 Instance = new PolygonBooleanKernel2_EIK(); internal override IntPtr Create() { return PolygonBoolean2_EIK_Create(); } internal override void Release(IntPtr ptr) { PolygonBoolean2_EIK_Release(ptr); } internal override void ClearBuffer(IntPtr ptr) { PolygonBoolean2_EIK_ClearBuffer(ptr); } internal override IntPtr CopyBufferItem(IntPtr ptr, int index) { return PolygonBoolean2_EIK_CopyBufferItem(ptr, index); } internal override bool DoIntersect(IntPtr ptr, Polygon2 poly1, Polygon2 poly2) { return PolygonBoolean2_EIK_DoIntersect_P_P(ptr, poly1.Ptr, poly2.Ptr); } internal override bool DoIntersect(IntPtr ptr, Polygon2 poly1, PolygonWithHoles2 poly2) { return PolygonBoolean2_EIK_DoIntersect_P_PWH(ptr, poly1.Ptr, poly2.Ptr); } internal override bool DoIntersect(IntPtr ptr, PolygonWithHoles2 poly1, PolygonWithHoles2 poly2) { return PolygonBoolean2_EIK_DoIntersect_PWH_PWH(ptr, poly1.Ptr, poly2.Ptr); } internal override int Intersect(IntPtr ptr, Polygon2 poly1, Polygon2 poly2) { return PolygonBoolean2_EIK_Intersect_P_P(ptr, poly1.Ptr, poly2.Ptr); } internal override int Intersect(IntPtr ptr, Polygon2 poly1, PolygonWithHoles2 poly2) { return PolygonBoolean2_EIK_Intersect_P_PWH(ptr, poly1.Ptr, poly2.Ptr); } internal override int Intersect(IntPtr ptr, PolygonWithHoles2 poly1, PolygonWithHoles2 poly2) { return PolygonBoolean2_EIK_Intersect_PWH_PWH(ptr, poly1.Ptr, poly2.Ptr); } internal override bool Join(IntPtr ptr, Polygon2 poly1, Polygon2 poly2, out IntPtr result) { return PolygonBoolean2_EIK_Join_P_P(ptr, poly1.Ptr, poly2.Ptr, out result); } internal override bool Join(IntPtr ptr, Polygon2 poly1, PolygonWithHoles2 poly2, out IntPtr result) { return PolygonBoolean2_EIK_Join_P_PWH(ptr, poly1.Ptr, poly2.Ptr, out result); } internal override bool Join(IntPtr ptr, PolygonWithHoles2 poly1, PolygonWithHoles2 poly2, out IntPtr result) { return PolygonBoolean2_EIK_Join_PWH_PWH(ptr, poly1.Ptr, poly2.Ptr, out result); } internal override int Difference(IntPtr ptr, Polygon2 poly1, Polygon2 poly2) { return PolygonBoolean2_EIK_Difference_P_P(ptr, poly1.Ptr, poly2.Ptr); } internal override int Difference(IntPtr ptr, Polygon2 poly1, PolygonWithHoles2 poly2) { return PolygonBoolean2_EIK_Difference_P_PWH(ptr, poly1.Ptr, poly2.Ptr); } internal override int Difference(IntPtr ptr, PolygonWithHoles2 poly1, PolygonWithHoles2 poly2) { return PolygonBoolean2_EIK_Difference_PWH_PWH(ptr, poly1.Ptr, poly2.Ptr); } internal override int SymmetricDifference(IntPtr ptr, PolygonWithHoles2 poly1, PolygonWithHoles2 poly2) { return PolygonBoolean2_EIK_SymmetricDifference_PWH_PWH(ptr, poly1.Ptr, poly2.Ptr); } internal override int SymmetricDifference(IntPtr ptr, Polygon2 poly1, Polygon2 poly2) { return PolygonBoolean2_EIK_SymmetricDifference_P_P(ptr, poly1.Ptr, poly2.Ptr); } internal override int SymmetricDifference(IntPtr ptr, Polygon2 poly1, PolygonWithHoles2 poly2) { return PolygonBoolean2_EIK_SymmetricDifference_P_PWH(ptr, poly1.Ptr, poly2.Ptr); } internal override int Complement(IntPtr ptr, PolygonWithHoles2 poly) { return PolygonBoolean2_EIK_Complement_PWH(ptr, poly.Ptr); } [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr PolygonBoolean2_EIK_Create(); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void PolygonBoolean2_EIK_Release(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void PolygonBoolean2_EIK_ClearBuffer(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr PolygonBoolean2_EIK_CopyBufferItem(IntPtr ptr, int index); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool PolygonBoolean2_EIK_DoIntersect_P_P(IntPtr ptr0, IntPtr ptr1, IntPtr ptr2); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool PolygonBoolean2_EIK_DoIntersect_P_PWH(IntPtr ptr0, IntPtr ptr1, IntPtr ptr2); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool PolygonBoolean2_EIK_DoIntersect_PWH_PWH(IntPtr ptr0, IntPtr ptr1, IntPtr ptr2); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool PolygonBoolean2_EIK_Join_P_P(IntPtr ptr0, IntPtr ptr1, IntPtr ptr2, out IntPtr result); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool PolygonBoolean2_EIK_Join_P_PWH(IntPtr ptr0, IntPtr ptr1, IntPtr ptr2, out IntPtr result); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool PolygonBoolean2_EIK_Join_PWH_PWH(IntPtr ptr0, IntPtr ptr1, IntPtr ptr2, out IntPtr result); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int PolygonBoolean2_EIK_Intersect_P_P(IntPtr ptr0, IntPtr ptr1, IntPtr ptr2); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int PolygonBoolean2_EIK_Intersect_P_PWH(IntPtr ptr0, IntPtr ptr1, IntPtr ptr2); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int PolygonBoolean2_EIK_Intersect_PWH_PWH(IntPtr ptr0, IntPtr ptr1, IntPtr ptr2); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int PolygonBoolean2_EIK_Difference_P_P(IntPtr ptr0, IntPtr ptr1, IntPtr ptr2); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int PolygonBoolean2_EIK_Difference_P_PWH(IntPtr ptr0, IntPtr ptr1, IntPtr ptr2); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int PolygonBoolean2_EIK_Difference_PWH_PWH(IntPtr ptr0, IntPtr ptr1, IntPtr ptr2); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int PolygonBoolean2_EIK_SymmetricDifference_P_P(IntPtr ptr0, IntPtr ptr1, IntPtr ptr2); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int PolygonBoolean2_EIK_SymmetricDifference_P_PWH(IntPtr ptr0, IntPtr ptr1, IntPtr ptr2); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int PolygonBoolean2_EIK_SymmetricDifference_PWH_PWH(IntPtr ptr0, IntPtr ptr1, IntPtr ptr2); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int PolygonBoolean2_EIK_Complement_PWH(IntPtr ptr0, IntPtr ptr1); } } ================================================ FILE: CGALDotNet/Polygons/PolygonFactory.cs ================================================ using System; using System.Collections.Generic; using System.Text; using CGALDotNetGeometry.Numerics; using CGALDotNetGeometry.Shapes; namespace CGALDotNet.Polygons { /// /// Factory for creating polygons. /// /// The kernel type. public static class PolygonFactory where K : CGALKernel, new() { /// /// Create a empty polygon. /// /// public static Polygon2 Create() { var poly = new Polygon2(); return poly; } /// /// Create a polygon from a triangle. /// /// The triangle first point. /// The triangle second point. /// The triangle third point. /// True for a counter clock wise polygon, false for a clock wise polygon /// The created polygon. public static Polygon2 CreateTriangle(Point2d a, Point2d b, Point2d c, bool ccw = true) { var tri = new Triangle2d(a, b, c); return CreateTriangle(tri, ccw); } /// /// Create a polygon from a triangle. /// /// The triangle. /// True for a counter clock wise polygon, false for a clock wise polygon /// The created polygon. public static Polygon2 CreateTriangle(Triangle2d tri, bool ccw = true) { var points = new Point2d[] { tri.A, tri.B, tri.C }; var poly = new Polygon2(points); if (!ccw) poly.Reverse(); return poly; } /// /// Create a polygon from a box. /// /// The boxs min point. /// The boxs max point. /// True for a counter clock wise polygon, false for a clock wise polygon /// The created polygon. public static Polygon2 CreateBox(Point2d min, Point2d max, bool ccw = true) { var box = new Box2d(min, max); return CreateBox(box, ccw); } /// /// Create a polygon from a box. /// /// The boxs min point. /// The boxs max point. /// True for a counter clock wise polygon, false for a clock wise polygon /// The created polygon. public static Polygon2 CreateBox(double min, double max, bool ccw = true) { var box = new Box2d(min, max); return CreateBox(box, ccw); } /// /// Create a polygon from a box. /// /// The box. /// True for a counter clock wise polygon, false for a clock wise polygon /// The created polygon. public static Polygon2 CreateBox(Box2d box, bool ccw = true) { var points = new Point2d[4]; box.GetCorners(points); var poly = new Polygon2(points); if (!ccw) poly.Reverse(); return poly; } /// /// Create a polygon from a dounut. /// Outer radius must be greater than inner. /// /// The outer radius. /// The inner radius /// The number of segments. /// The created polygon with holes public static PolygonWithHoles2 CreateDounut(double outer, double inner, int segments) { return CreateDounut(Point2d.Zero, outer, inner, segments); } /// /// Create a polygon from a dounut. /// Outer radius must be greater than inner. /// /// The center position of the polygon. /// The outer radius. /// The inner radius /// The number of segments. /// The created polygon with holes public static PolygonWithHoles2 CreateDounut(Point2d center, double outer, double inner, int segments) { var boundary = CreateCircle(new Circle2d(center, outer), segments); var pwh = new PolygonWithHoles2(boundary); if (inner < outer) { var hole = CreateCircle(new Circle2d(center, inner), segments); hole.Reverse(); pwh.AddHole(hole); } return pwh; } /// /// Create a polygon from a circle. /// /// The radius of the circle. /// The number of segments. /// True for a counter clock wise polygon, false for a clock wise polygon /// The polygon. public static Polygon2 CreateCircle(double radius, int segments, bool ccw = true) { return CreateCircle(new Circle2d(Point2d.Zero, radius), segments, ccw); } /// /// Create a polygon from a circle. /// /// The center of the circle. /// The radius of the circle. /// The number of segments. /// True for a counter clock wise polygon, false for a clock wise polygon /// public static Polygon2 CreateCircle(Point2d center, double radius, int segments, bool ccw = true) { return CreateCircle(new Circle2d(center, radius), segments, ccw); } /// /// Create a polygon from a circle. /// /// The cirlce. /// The number of segments. /// True for a counter clock wise polygon, false for a clock wise polygon /// public static Polygon2 CreateCircle(Circle2d circle, int segments, bool ccw = true) { segments = Math.Max(3, segments); double pi = Math.PI; var points = new Point2d[segments]; double rotate = Rotation(segments); for (int i = 0; i < segments; i++) { double theta = 2.0 * pi * i / segments + rotate; double x = -circle.Radius * Math.Cos(theta); double y = -circle.Radius * Math.Sin(theta); points[i] = circle.Center + new Point2d(x, y); } var poly = new Polygon2(points); if (!ccw) poly.Reverse(); return poly; } private static double Rotation(int segments) { return (((segments - 2) * 180) / segments) * MathUtil.DEG_TO_RAD_64 * 0.5; } /// /// https://rosettacode.org/wiki/Koch_curve#C.2B.2B /// /// The size of the polygon. /// The number of times to sub divide. /// True for a counter clock wise polygon, false for a clock wise polygon /// public static Polygon2 KochStar(double size, int iterations, bool ccw = true) { return KochStar(Point2d.Zero, size, iterations, ccw); } /// /// https://rosettacode.org/wiki/Koch_curve#C.2B.2B /// /// The stars center. /// The size of the polygon. /// The number of times to sub divide. /// True for a counter clock wise polygon, false for a clock wise polygon /// public static Polygon2 KochStar(Point2d center, double size, int iterations, bool ccw = true) { double sqrt3_2 = Math.Sqrt(3) / 2.0; double length = size * sqrt3_2 * 0.95; double x = (size - length) / 2.0; double y = size / 2.0 - length * sqrt3_2 / 3.0; var points = new List(4); points.Add(new Point2d(x, y)); points.Add(new Point2d(x + length / 2, y + length * sqrt3_2)); points.Add(new Point2d(x + length, y)); points.Add(new Point2d(x, y)); for (int i = 0; i < iterations; ++i) points = KochNext(points); int last = points.Count - 1; points.RemoveAt(last); points.Reverse(); var offset = center + new Point2d(size / 2); for (int i = 0; i < points.Count; ++i) points[i] -= offset; var poly = new Polygon2(points.ToArray()); if (!ccw) poly.Reverse(); return poly; } /// /// https://rosettacode.org/wiki/Koch_curve#C.2B.2B /// /// /// private static List KochNext(List points) { double sqrt3_2 = Math.Sqrt(3) / 2.0; int size = points.Count; var output = new List(4 * (size - 1) + 1); double x0 = 0, y0 = 0, x1 = 0, y1 = 0; for (int i = 0; i + 1 < size; ++i) { x0 = points[i].x; y0 = points[i].y; x1 = points[i + 1].x; y1 = points[i + 1].y; double dy = y1 - y0; double dx = x1 - x0; output.Add(new Point2d(x0, y0)); output.Add(new Point2d(x0 + dx / 3.0, y0 + dy / 3.0)); output.Add(new Point2d(x0 + dx / 2.0 - dy * sqrt3_2 / 3, y0 + dy / 2.0 + dx * sqrt3_2 / 3.0)); output.Add(new Point2d(x0 + 2.0 * dx / 3.0, y0 + 2.0 * dy / 3.0)); } output.Add(new Point2d(x1, y1)); return output; } } } ================================================ FILE: CGALDotNet/Polygons/PolygonKernel2.cs ================================================ using System; using System.Collections.Generic; using System.Runtime.InteropServices; using System.Text; using CGALDotNetGeometry.Numerics; using CGALDotNetGeometry.Shapes; namespace CGALDotNet.Polygons { internal abstract class PolygonKernel2 : CGALObjectKernel { internal abstract IntPtr Create(); internal abstract void Release(IntPtr ptr); internal abstract int Count(IntPtr ptr); internal abstract IntPtr Copy(IntPtr ptr); internal abstract IntPtr Convert(IntPtr ptr, CGAL_KERNEL k); internal abstract Box2d GetBoundingBox(IntPtr ptr); internal abstract void Clear(IntPtr ptr); internal abstract int Capacity(IntPtr ptr); internal abstract void Resize(IntPtr ptr, int count); internal abstract void ShrinkToFit(IntPtr ptr); internal abstract void Erase(IntPtr ptr, int index); internal abstract void EraseRange(IntPtr ptr, int start, int count); internal abstract void Insert(IntPtr ptr, int index, Point2d point); internal abstract void InsertRange(IntPtr ptr, int start, int count, Point2d[] points); internal abstract double SqPerimeter(IntPtr ptr); internal abstract Point2d GetPoint(IntPtr ptr, int index); internal abstract void GetPoints(IntPtr ptr, Point2d[] points, int count); internal abstract void GetSegments(IntPtr ptr, Segment2d[] segments, int count); internal abstract void SetPoint(IntPtr ptr, int index, Point2d point); internal abstract void SetPoints(IntPtr ptr, Point2d[] points, int count); internal abstract void Reverse(IntPtr ptr); internal abstract bool IsSimple(IntPtr ptr); internal abstract bool IsConvex(IntPtr ptr); internal abstract ORIENTATION Orientation(IntPtr ptr); internal abstract ORIENTED_SIDE OrientedSide(IntPtr ptr, Point2d point); internal abstract BOUNDED_SIDE BoundedSide(IntPtr ptr, Point2d point); internal abstract double SignedArea(IntPtr ptr); internal abstract void Translate(IntPtr ptr, Point2d translation); internal abstract void Rotate(IntPtr ptr, double rotation); internal abstract void Scale(IntPtr ptr, double scale); internal abstract void Transform(IntPtr ptr, Point2d translation, double rotation, double scale); internal abstract bool ContainsPoint(IntPtr ptr, Point2d point, ORIENTATION orientation, bool inculdeBoundary); } } ================================================ FILE: CGALDotNet/Polygons/PolygonKernel2_EEK.cs ================================================ using System; using System.Collections.Generic; using System.Text; using System.Runtime.InteropServices; using CGALDotNetGeometry.Numerics; using CGALDotNetGeometry.Shapes; namespace CGALDotNet.Polygons { internal class PolygonKernel2_EEK : PolygonKernel2 { internal override string Name => "EEK"; internal static readonly PolygonKernel2 Instance = new PolygonKernel2_EEK(); internal override IntPtr Create() { return Polygon2_EEK_Create(); } internal override void Release(IntPtr ptr) { Polygon2_EEK_Release(ptr); } internal override int Count(IntPtr ptr) { return Polygon2_EEK_Count(ptr); } internal override IntPtr Copy(IntPtr ptr) { return Polygon2_EEK_Copy(ptr); } internal override IntPtr Convert(IntPtr ptr, CGAL_KERNEL k) { return Polygon2_EEK_Convert(ptr, k); } internal override Box2d GetBoundingBox(IntPtr ptr) { return Polygon2_EEK_GetBoundingBox(ptr); } internal override void Clear(IntPtr ptr) { Polygon2_EEK_Copy(ptr); } internal override int Capacity(IntPtr ptr) { return Polygon2_EEK_Capacity(ptr); } internal override void Resize(IntPtr ptr, int count) { Polygon2_EEK_Resize(ptr, count); } internal override void ShrinkToFit(IntPtr ptr) { Polygon2_EEK_ShrinkToFit(ptr); } internal override void Erase(IntPtr ptr, int index) { Polygon2_EEK_Erase(ptr, index); } internal override void EraseRange(IntPtr ptr, int start, int count) { Polygon2_EEK_EraseRange(ptr, start, count); } internal override void Insert(IntPtr ptr, int index, Point2d point) { Polygon2_EEK_Insert(ptr, index, point); } internal override void InsertRange(IntPtr ptr, int start, int count, Point2d[] points) { Polygon2_EEK_InsertRange(ptr, start, count, points); } internal override double SqPerimeter(IntPtr ptr) { return Polygon2_EEK_SqPerimeter(ptr); } internal override Point2d GetPoint(IntPtr ptr, int index) { return Polygon2_EEK_GetPoint(ptr, index); } internal override void GetPoints(IntPtr ptr, Point2d[] points, int count) { Polygon2_EEK_GetPoints(ptr, points, count); } internal override void GetSegments(IntPtr ptr, Segment2d[] segments, int count) { Polygon2_EEK_GetSegments(ptr, segments, count); } internal override void SetPoint(IntPtr ptr, int index, Point2d point) { Polygon2_EEK_SetPoint(ptr, index, point); } internal override void SetPoints(IntPtr ptr, Point2d[] points, int count) { Polygon2_EEK_SetPoints(ptr, points, count); } internal override void Reverse(IntPtr ptr) { Polygon2_EEK_Reverse(ptr); } internal override bool IsSimple(IntPtr ptr) { return Polygon2_EEK_IsSimple(ptr); } internal override bool IsConvex(IntPtr ptr) { return Polygon2_EEK_IsConvex(ptr); } internal override ORIENTATION Orientation(IntPtr ptr) { return Polygon2_EEK_Orientation(ptr); } internal override ORIENTED_SIDE OrientedSide(IntPtr ptr, Point2d point) { return Polygon2_EEK_OrientedSide(ptr, point); } internal override BOUNDED_SIDE BoundedSide(IntPtr ptr, Point2d point) { return Polygon2_EEK_BoundedSide(ptr, point); } internal override double SignedArea(IntPtr ptr) { return Polygon2_EEK_SignedArea(ptr); } internal override void Translate(IntPtr ptr, Point2d translation) { Polygon2_EEK_Translate(ptr, translation); } internal override void Rotate(IntPtr ptr, double rotation) { Polygon2_EEK_Rotate(ptr, rotation); } internal override void Scale(IntPtr ptr, double scale) { Polygon2_EEK_Scale(ptr, scale); } internal override void Transform(IntPtr ptr, Point2d translation, double rotation, double scale) { Polygon2_EEK_Transform(ptr, translation, rotation, scale); } internal override bool ContainsPoint(IntPtr ptr, Point2d point, ORIENTATION orientation, bool inculdeBoundary) { return Polygon2_EEK_ContainsPoint(ptr, point, orientation, inculdeBoundary); } [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr Polygon2_EEK_Create(); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void Polygon2_EEK_Release(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int Polygon2_EEK_Count(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr Polygon2_EEK_Copy(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr Polygon2_EEK_Convert(IntPtr ptr, CGAL_KERNEL k); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern Box2d Polygon2_EEK_GetBoundingBox(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void Polygon2_EEK_Clear(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int Polygon2_EEK_Capacity(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void Polygon2_EEK_Resize(IntPtr ptr, int count); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void Polygon2_EEK_ShrinkToFit(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void Polygon2_EEK_Erase(IntPtr ptr, int index); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void Polygon2_EEK_EraseRange(IntPtr ptr, int start, int count); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void Polygon2_EEK_Insert(IntPtr ptr, int index, Point2d point); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void Polygon2_EEK_InsertRange(IntPtr ptr, int start, int count, Point2d[] points); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern double Polygon2_EEK_SqPerimeter(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern Point2d Polygon2_EEK_GetPoint(IntPtr ptr, int index); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void Polygon2_EEK_GetPoints(IntPtr ptr, [Out] Point2d[] points, int count); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void Polygon2_EEK_GetSegments(IntPtr ptr, [Out] Segment2d[] segments, int count); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void Polygon2_EEK_SetPoint(IntPtr ptr, int index, Point2d point); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void Polygon2_EEK_SetPoints(IntPtr ptr, [In] Point2d[] points, int count); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern Point2d Polygon2_EEK_TopVertex(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern Point2d Polygon2_EEK_BottomVertex(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern Point2d Polygon2_EEK_RightVertex(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern Point2d Polygon2_EEK_LeftVertex(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void Polygon2_EEK_Reverse(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool Polygon2_EEK_IsSimple(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool Polygon2_EEK_IsConvex(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern ORIENTATION Polygon2_EEK_Orientation(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern ORIENTED_SIDE Polygon2_EEK_OrientedSide(IntPtr ptr, Point2d point); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern BOUNDED_SIDE Polygon2_EEK_BoundedSide(IntPtr ptr, Point2d point); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern double Polygon2_EEK_SignedArea(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void Polygon2_EEK_Translate(IntPtr ptr, Point2d translation); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void Polygon2_EEK_Rotate(IntPtr ptr, double rotation); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void Polygon2_EEK_Scale(IntPtr ptr, double scale); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void Polygon2_EEK_Transform(IntPtr ptr, Point2d translation, double rotation, double scale); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool Polygon2_EEK_ContainsPoint(IntPtr ptr, Point2d point, ORIENTATION orientation, bool inculdeBoundary); } } ================================================ FILE: CGALDotNet/Polygons/PolygonKernel2_EIK.cs ================================================ using System; using System.Collections.Generic; using System.Text; using System.Runtime.InteropServices; using CGALDotNetGeometry.Numerics; using CGALDotNetGeometry.Shapes; namespace CGALDotNet.Polygons { internal class PolygonKernel2_EIK : PolygonKernel2 { internal override string Name => "EIK"; internal static readonly PolygonKernel2 Instance = new PolygonKernel2_EIK(); internal override IntPtr Create() { return Polygon2_EIK_Create(); } internal override void Release(IntPtr ptr) { Polygon2_EIK_Release(ptr); } internal override int Count(IntPtr ptr) { return Polygon2_EIK_Count(ptr); } internal override IntPtr Copy(IntPtr ptr) { return Polygon2_EIK_Copy(ptr); } internal override IntPtr Convert(IntPtr ptr, CGAL_KERNEL k) { return Polygon2_EIK_Convert(ptr, k); } internal override Box2d GetBoundingBox(IntPtr ptr) { return Polygon2_EIK_GetBoundingBox(ptr); } internal override void Clear(IntPtr ptr) { Polygon2_EIK_Copy(ptr); } internal override int Capacity(IntPtr ptr) { return Polygon2_EIK_Capacity(ptr); } internal override void Resize(IntPtr ptr, int count) { Polygon2_EIK_Resize(ptr, count); } internal override void ShrinkToFit(IntPtr ptr) { Polygon2_EIK_ShrinkToFit(ptr); } internal override void Erase(IntPtr ptr, int index) { Polygon2_EIK_Erase(ptr, index); } internal override void EraseRange(IntPtr ptr, int start, int count) { Polygon2_EIK_EraseRange(ptr, start, count); } internal override void Insert(IntPtr ptr, int index, Point2d point) { Polygon2_EIK_Insert(ptr, index, point); } internal override void InsertRange(IntPtr ptr, int start, int count, Point2d[] points) { Polygon2_EIK_InsertRange(ptr, start, count, points); } internal override double SqPerimeter(IntPtr ptr) { return Polygon2_EIK_SqPerimeter(ptr); } internal override Point2d GetPoint(IntPtr ptr, int index) { return Polygon2_EIK_GetPoint(ptr, index); } internal override void GetPoints(IntPtr ptr, Point2d[] points, int count) { Polygon2_EIK_GetPoints(ptr, points, count); } internal override void GetSegments(IntPtr ptr, Segment2d[] segments, int count) { Polygon2_EIK_GetSegments(ptr, segments, count); } internal override void SetPoint(IntPtr ptr, int index, Point2d point) { Polygon2_EIK_SetPoint(ptr, index, point); } internal override void SetPoints(IntPtr ptr, Point2d[] points, int count) { Polygon2_EIK_SetPoints(ptr, points, count); } internal override void Reverse(IntPtr ptr) { Polygon2_EIK_Reverse(ptr); } internal override bool IsSimple(IntPtr ptr) { return Polygon2_EIK_IsSimple(ptr); } internal override bool IsConvex(IntPtr ptr) { return Polygon2_EIK_IsConvex(ptr); } internal override ORIENTATION Orientation(IntPtr ptr) { return Polygon2_EIK_Orientation(ptr); } internal override ORIENTED_SIDE OrientedSide(IntPtr ptr, Point2d point) { return Polygon2_EIK_OrientedSide(ptr, point); } internal override BOUNDED_SIDE BoundedSide(IntPtr ptr, Point2d point) { return Polygon2_EIK_BoundedSide(ptr, point); } internal override double SignedArea(IntPtr ptr) { return Polygon2_EIK_SignedArea(ptr); } internal override void Translate(IntPtr ptr, Point2d translation) { Polygon2_EIK_Translate(ptr, translation); } internal override void Rotate(IntPtr ptr, double rotation) { Polygon2_EIK_Rotate(ptr, rotation); } internal override void Scale(IntPtr ptr, double scale) { Polygon2_EIK_Scale(ptr, scale); } internal override void Transform(IntPtr ptr, Point2d translation, double rotation, double scale) { Polygon2_EIK_Transform(ptr, translation, rotation, scale); } internal override bool ContainsPoint(IntPtr ptr, Point2d point, ORIENTATION orientation, bool inculdeBoundary) { return Polygon2_EIK_ContainsPoint(ptr, point, orientation, inculdeBoundary); } [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr Polygon2_EIK_Create(); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void Polygon2_EIK_Release(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int Polygon2_EIK_Count(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr Polygon2_EIK_Copy(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr Polygon2_EIK_Convert(IntPtr ptr, CGAL_KERNEL k); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern Box2d Polygon2_EIK_GetBoundingBox(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void Polygon2_EIK_Clear(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int Polygon2_EIK_Capacity(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void Polygon2_EIK_Resize(IntPtr ptr, int count); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void Polygon2_EIK_ShrinkToFit(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void Polygon2_EIK_Erase(IntPtr ptr, int index); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void Polygon2_EIK_EraseRange(IntPtr ptr, int start, int count); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void Polygon2_EIK_Insert(IntPtr ptr, int index, Point2d point); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void Polygon2_EIK_InsertRange(IntPtr ptr, int start, int count, Point2d[] points); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern double Polygon2_EIK_SqPerimeter(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern Point2d Polygon2_EIK_GetPoint(IntPtr ptr, int index); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void Polygon2_EIK_GetPoints(IntPtr ptr, [Out] Point2d[] points, int count); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void Polygon2_EIK_GetSegments(IntPtr ptr, [Out] Segment2d[] segments, int count); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void Polygon2_EIK_SetPoint(IntPtr ptr, int index, Point2d point); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void Polygon2_EIK_SetPoints(IntPtr ptr, [In] Point2d[] points, int count); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern Point2d Polygon2_EIK_TopVertex(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern Point2d Polygon2_EIK_BottomVertex(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern Point2d Polygon2_EIK_RightVertex(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern Point2d Polygon2_EIK_LeftVertex(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void Polygon2_EIK_Reverse(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool Polygon2_EIK_IsSimple(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool Polygon2_EIK_IsConvex(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern ORIENTATION Polygon2_EIK_Orientation(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern ORIENTED_SIDE Polygon2_EIK_OrientedSide(IntPtr ptr, Point2d point); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern BOUNDED_SIDE Polygon2_EIK_BoundedSide(IntPtr ptr, Point2d point); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern double Polygon2_EIK_SignedArea(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void Polygon2_EIK_Translate(IntPtr ptr, Point2d translation); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void Polygon2_EIK_Rotate(IntPtr ptr, double rotation); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void Polygon2_EIK_Scale(IntPtr ptr, double scale); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void Polygon2_EIK_Transform(IntPtr ptr, Point2d translation, double rotation, double scale); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool Polygon2_EIK_ContainsPoint(IntPtr ptr, Point2d point, ORIENTATION orientation, bool inculdeBoundary); } } ================================================ FILE: CGALDotNet/Polygons/PolygonMinkowski.cs ================================================ using System; using System.Collections.Generic; namespace CGALDotNet.Polygons { /// /// Decomposition stratergy for polygons. /// public enum MINKOWSKI_DECOMPOSITION { SMALL_SIDE_ANGLE_BISECTOR, OPTIMAL_CONVEX, HERTEL_MEHLHORN_CONVEX, GREENE_CONVEX, VERTICAL, TRIANGULATION } /// /// Decomposition stratergy for polygons with holes. /// public enum MINKOWSKI_DECOMPOSITION_PWH { VERTICAL, TRIANGULATION } /// /// Generic Minkowski class. /// /// The type of kernel public class PolygonMinkowski : PolygonMinkowski where K : CGALKernel, new() { /// /// A static instance to the Minkowski class. /// public static readonly PolygonMinkowski Instance = new PolygonMinkowski(); /// /// Create a new object. /// public PolygonMinkowski() : base(new K()) { } /// /// /// /// public override string ToString() { return string.Format("[PolygonMinkowski<{0}>: ]", Kernel.Name); } /// /// Compute the Minkowski sum of two polygons. /// /// /// /// public PolygonWithHoles2 Sum(Polygon2 polygon, Polygon2 shape) { CheckPolygon(polygon); CheckPolygon(shape); var ptr = Kernel.MinkowskiSum(polygon.Ptr, shape.Ptr); return new PolygonWithHoles2(ptr); } /// /// Compute the Minkowski sum of two polygons. /// /// /// /// public PolygonWithHoles2 Sum(PolygonWithHoles2 polygon, Polygon2 shape) { CheckPolygon(polygon); CheckPolygon(shape); var ptr = Kernel.MinkowskiSumPWH(polygon.Ptr, shape.Ptr); return new PolygonWithHoles2(ptr); } /// /// Compute the Minkowski sum of two polygons. /// /// The decomposition method. /// /// /// public PolygonWithHoles2 Sum(MINKOWSKI_DECOMPOSITION decomp, Polygon2 polygon, Polygon2 shape) { switch (decomp) { case MINKOWSKI_DECOMPOSITION.SMALL_SIDE_ANGLE_BISECTOR: return SumSSAB(polygon, shape); case MINKOWSKI_DECOMPOSITION.OPTIMAL_CONVEX: return SumOptimalConvex(polygon, shape); case MINKOWSKI_DECOMPOSITION.HERTEL_MEHLHORN_CONVEX: return SumHertelMehlhorn(polygon, shape); case MINKOWSKI_DECOMPOSITION.GREENE_CONVEX: return SumGreeneConvex(polygon, shape); case MINKOWSKI_DECOMPOSITION.VERTICAL: return SumVertical(polygon, shape); case MINKOWSKI_DECOMPOSITION.TRIANGULATION: return SumTriangle(polygon, shape); default: return Sum(polygon, shape); } } /// /// Compute the Minkowski sum of two polygons. /// /// The decomposition method. /// /// /// public PolygonWithHoles2 Sum(MINKOWSKI_DECOMPOSITION_PWH decomp, PolygonWithHoles2 polygon, Polygon2 shape) { switch (decomp) { case MINKOWSKI_DECOMPOSITION_PWH.VERTICAL: return SumVertical(polygon, shape); case MINKOWSKI_DECOMPOSITION_PWH.TRIANGULATION: return SumTriangle(polygon, shape); default: return Sum(polygon, shape); } } /// /// It is based on the angle-bisector decomposition method suggested by Chazelle and Dobkin [4], /// which runs in O(n2) time. In addition, it applies a heuristic by Flato that reduces the number /// of output polygons in many common cases. The convex decompositions that it produces usually /// yield efficient running times for Minkowski sum computations. It starts by examining each pair /// of reflex vertices in the input polygon, such that the entire interior of the diagonal /// connecting these vertices is contained in the polygon. Out of all available pairs, the vertices /// pi and pj are selected, such that the number of reflex vertices encountered when traversing /// the boundary of the polygon from pi to pj in clockwise order is minimal. The polygon is split /// by the diagonal pipj. This process is repeated recursively on both resulting sub-polygons. /// In case it is not possible to eliminate two reflex vertices at once any more, each reflex /// vertex is eliminated by a diagonal that is closest to the angle bisector emanating from this /// vertex and having rational-coordinate endpoints on both sides. /// /// /// /// public PolygonWithHoles2 SumSSAB(Polygon2 polygon, Polygon2 shape) { CheckPolygon(polygon); CheckPolygon(shape); var ptr = Kernel.MinkowskiSum_SSAB(polygon.Ptr, shape.Ptr); return new PolygonWithHoles2(ptr); } /// /// Uses the dynamic-programming algorithm of Greene [6] for computing an optimal decomposition of /// a polygon into a minimal number of convex sub-polygons. While this algorithm results in a small /// number of convex polygons, it consumes rather many resources, as it runs in O(n4) time and O(n3) /// space in the worst case, where n is the number of vertices in the input polygon. /// /// /// /// public PolygonWithHoles2 SumOptimalConvex(Polygon2 polygon, Polygon2 shape) { CheckPolygon(polygon); CheckPolygon(shape); var ptr = Kernel.MinkowskiSum_OptimalConvex(polygon.Ptr, shape.Ptr); return new PolygonWithHoles2(ptr); } /// /// Implements the approximation algorithm suggested by Hertel and Mehlhorn [8], which triangulates /// the input polygon and then discards unnecessary triangulation edges. After triangulation (carried /// out by the constrained-triangulation procedure of CGAL) the algorithm runs in O(n) time and space, /// and guarantees that the number of sub-polygons it generates is not more than four times the optimum. /// /// /// /// public PolygonWithHoles2 SumHertelMehlhorn(Polygon2 polygon, Polygon2 shape) { CheckPolygon(polygon); CheckPolygon(shape); var ptr = Kernel.MinkowskiSum_HertelMehlhorn(polygon.Ptr, shape.Ptr); return new PolygonWithHoles2(ptr); } /// /// Implementation of Greene's approximation algorithm [6], which computes a convex decomposition of the /// polygon based on its partitioning into y-monotone polygons. This algorithm runs in O(nlogn) time and /// O(n) space, and has the same guarantee on the quality of approximation as Hertel and Mehlhorn's algorithm. /// /// /// /// public PolygonWithHoles2 SumGreeneConvex(Polygon2 polygon, Polygon2 shape) { CheckPolygon(polygon); CheckPolygon(shape); var ptr = Kernel.MinkowskiSum_GreeneConvex(polygon.Ptr, shape.Ptr); return new PolygonWithHoles2(ptr); } /// /// Uses vertical decomposition to decompose the underlying arrangement. /// /// /// /// public PolygonWithHoles2 SumVertical(Polygon2 polygon, Polygon2 shape) { CheckPolygon(polygon); CheckPolygon(shape); var ptr = Kernel.MinkowskiSum_Vertical(polygon.Ptr, shape.Ptr); return new PolygonWithHoles2(ptr); } /// /// Uses vertical decomposition to decompose the underlying arrangement. /// /// /// /// public PolygonWithHoles2 SumVertical(PolygonWithHoles2 polygon, Polygon2 shape) { CheckPolygon(polygon); CheckPolygon(shape); var ptr = Kernel.MinkowskiSumPWH_Vertical(polygon.Ptr, shape.Ptr); return new PolygonWithHoles2(ptr); } /// /// Uses constrained triangulation to decompose the input polygons, which may have holes, into triangles. /// /// /// /// public PolygonWithHoles2 SumTriangle(Polygon2 polygon, Polygon2 shape) { CheckPolygon(polygon); CheckPolygon(shape); var ptr = Kernel.MinkowskiSum_Triangle(polygon.Ptr, shape.Ptr); return new PolygonWithHoles2(ptr); } /// /// Uses constrained triangulation to decompose the input polygons, which may have holes, into triangles. /// /// /// /// public PolygonWithHoles2 SumTriangle(PolygonWithHoles2 polygon, Polygon2 shape) { CheckPolygon(polygon); CheckPolygon(shape); var ptr = Kernel.MinkowskiSumPWH_Triangle(polygon.Ptr, shape.Ptr); return new PolygonWithHoles2(ptr); } } /// /// Abstract base class for polygon minkowski. /// public abstract class PolygonMinkowski : PolygonAlgorithm { private PolygonMinkowski() { } internal PolygonMinkowski(CGALKernel kernel) { Kernel = kernel.PolygonMinkowskiKernel; Ptr = Kernel.Create(); } /// /// The polygon Minkowski kernel. /// protected private PolygonMinkowskiKernel Kernel { get; private set; } /// /// Release the unmanaged resourses. /// protected override void ReleasePtr() { Kernel.Release(Ptr); } } } ================================================ FILE: CGALDotNet/Polygons/PolygonMinkowskiKernel.cs ================================================ using System; using System.Collections.Generic; using System.Runtime.InteropServices; namespace CGALDotNet.Polygons { internal abstract class PolygonMinkowskiKernel : CGALObjectKernel { internal abstract IntPtr Create(); internal abstract void Release(IntPtr ptr); internal abstract IntPtr MinkowskiSum(IntPtr polyPtr1, IntPtr polyPtr2); internal abstract IntPtr MinkowskiSumPWH(IntPtr pwhPtr1, IntPtr polyPtr2); internal abstract IntPtr MinkowskiSum_SSAB(IntPtr polyPtr1, IntPtr polyPtr2); internal abstract IntPtr MinkowskiSum_OptimalConvex(IntPtr polyPtr1, IntPtr polyPtr2); internal abstract IntPtr MinkowskiSum_HertelMehlhorn(IntPtr polyPtr1, IntPtr polyPtr2); internal abstract IntPtr MinkowskiSum_GreeneConvex(IntPtr polyPtr1, IntPtr polyPtr2); internal abstract IntPtr MinkowskiSum_Vertical(IntPtr polyPtr1, IntPtr polyPtr2); internal abstract IntPtr MinkowskiSumPWH_Vertical(IntPtr pwhPtr1, IntPtr polyPtr2); internal abstract IntPtr MinkowskiSum_Triangle(IntPtr polyPtr1, IntPtr polyPtr2); internal abstract IntPtr MinkowskiSumPWH_Triangle(IntPtr pwhPtr1, IntPtr polyPtr2); } } ================================================ FILE: CGALDotNet/Polygons/PolygonMinkowskiKernel_EEK.cs ================================================ using System; using System.Collections.Generic; using System.Runtime.InteropServices; namespace CGALDotNet.Polygons { internal class PolygonMinkowskiKernel_EEK : PolygonMinkowskiKernel { internal override string Name => "EEK"; internal static readonly PolygonMinkowskiKernel Instance = new PolygonMinkowskiKernel_EEK(); internal override IntPtr Create() { return PolygonMinkowski_EEK_Create(); } internal override void Release(IntPtr ptr) { PolygonMinkowski_EEK_Release(ptr); } internal override IntPtr MinkowskiSum(IntPtr polyPtr1, IntPtr polyPtr2) { return PolygonMinkowski_EEK_MinkowskiSum(polyPtr1, polyPtr2); } internal override IntPtr MinkowskiSumPWH(IntPtr pwhPtr1, IntPtr polyPtr2) { return PolygonMinkowski_EEK_MinkowskiSumPWH(pwhPtr1, polyPtr2); } internal override IntPtr MinkowskiSum_SSAB(IntPtr polyPtr1, IntPtr polyPtr2) { return PolygonMinkowski_EEK_MinkowskiSum_SSAB(polyPtr1, polyPtr2); } internal override IntPtr MinkowskiSum_OptimalConvex(IntPtr polyPtr1, IntPtr polyPtr2) { return PolygonMinkowski_EEK_MinkowskiSum_OptimalConvex(polyPtr1, polyPtr2); } internal override IntPtr MinkowskiSum_HertelMehlhorn(IntPtr polyPtr1, IntPtr polyPtr2) { return PolygonMinkowski_EEK_MinkowskiSum_HertelMehlhorn(polyPtr1, polyPtr2); } internal override IntPtr MinkowskiSum_GreeneConvex(IntPtr polyPtr1, IntPtr polyPtr2) { return PolygonMinkowski_EEK_MinkowskiSum_GreeneConvex(polyPtr1, polyPtr2); } internal override IntPtr MinkowskiSum_Vertical(IntPtr polyPtr1, IntPtr polyPtr2) { return PolygonMinkowski_EEK_MinkowskiSum_Vertical(polyPtr1, polyPtr2); } internal override IntPtr MinkowskiSumPWH_Vertical(IntPtr pwhPtr1, IntPtr polyPtr2) { return PolygonMinkowski_EEK_MinkowskiSumPWH_Vertical(pwhPtr1, polyPtr2); } internal override IntPtr MinkowskiSum_Triangle(IntPtr polyPtr1, IntPtr polyPtr2) { return PolygonMinkowski_EEK_MinkowskiSum_Triangle(polyPtr1, polyPtr2); } internal override IntPtr MinkowskiSumPWH_Triangle(IntPtr pwhPtr1, IntPtr polyPtr2) { return PolygonMinkowski_EEK_MinkowskiSumPWH_Triangle(pwhPtr1, polyPtr2); } [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr PolygonMinkowski_EEK_Create(); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void PolygonMinkowski_EEK_Release(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr PolygonMinkowski_EEK_MinkowskiSum(IntPtr polyPtr1, IntPtr polyPtr2); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr PolygonMinkowski_EEK_MinkowskiSumPWH(IntPtr pwhPtr1, IntPtr polyPtr2); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr PolygonMinkowski_EEK_MinkowskiSum_SSAB(IntPtr polyPtr1, IntPtr polyPtr2); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr PolygonMinkowski_EEK_MinkowskiSum_OptimalConvex(IntPtr polyPtr1, IntPtr polyPtr2); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr PolygonMinkowski_EEK_MinkowskiSum_HertelMehlhorn(IntPtr polyPtr1, IntPtr polyPtr2); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr PolygonMinkowski_EEK_MinkowskiSum_GreeneConvex(IntPtr polyPtr1, IntPtr polyPtr2); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr PolygonMinkowski_EEK_MinkowskiSum_Vertical(IntPtr polyPtr1, IntPtr polyPtr2); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr PolygonMinkowski_EEK_MinkowskiSumPWH_Vertical(IntPtr pwhPtr1, IntPtr polyPtr2); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr PolygonMinkowski_EEK_MinkowskiSum_Triangle(IntPtr polyPtr1, IntPtr polyPtr2); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr PolygonMinkowski_EEK_MinkowskiSumPWH_Triangle(IntPtr pwhPtr1, IntPtr polyPtr2); } } ================================================ FILE: CGALDotNet/Polygons/PolygonMinkowskiKernel_EIK.cs ================================================ using System; using System.Collections.Generic; using System.Runtime.InteropServices; namespace CGALDotNet.Polygons { internal class PolygonMinkowskiKernel_EIK : PolygonMinkowskiKernel { internal override string Name => "EIK"; internal static readonly PolygonMinkowskiKernel Instance = new PolygonMinkowskiKernel_EIK(); internal override IntPtr Create() { return PolygonMinkowski_EIK_Create(); } internal override void Release(IntPtr ptr) { PolygonMinkowski_EIK_Release(ptr); } internal override IntPtr MinkowskiSum(IntPtr polyPtr1, IntPtr polyPtr2) { return PolygonMinkowski_EIK_MinkowskiSum(polyPtr1, polyPtr2); } internal override IntPtr MinkowskiSumPWH(IntPtr pwhPtr1, IntPtr polyPtr2) { return PolygonMinkowski_EIK_MinkowskiSumPWH(pwhPtr1, polyPtr2); } internal override IntPtr MinkowskiSum_SSAB(IntPtr polyPtr1, IntPtr polyPtr2) { return PolygonMinkowski_EIK_MinkowskiSum_SSAB(polyPtr1, polyPtr2); } internal override IntPtr MinkowskiSum_OptimalConvex(IntPtr polyPtr1, IntPtr polyPtr2) { return PolygonMinkowski_EIK_MinkowskiSum_OptimalConvex(polyPtr1, polyPtr2); } internal override IntPtr MinkowskiSum_HertelMehlhorn(IntPtr polyPtr1, IntPtr polyPtr2) { return PolygonMinkowski_EIK_MinkowskiSum_HertelMehlhorn(polyPtr1, polyPtr2); } internal override IntPtr MinkowskiSum_GreeneConvex(IntPtr polyPtr1, IntPtr polyPtr2) { return PolygonMinkowski_EIK_MinkowskiSum_GreeneConvex(polyPtr1, polyPtr2); } internal override IntPtr MinkowskiSum_Vertical(IntPtr polyPtr1, IntPtr polyPtr2) { return PolygonMinkowski_EIK_MinkowskiSum_Vertical(polyPtr1, polyPtr2); } internal override IntPtr MinkowskiSumPWH_Vertical(IntPtr pwhPtr1, IntPtr polyPtr2) { return PolygonMinkowski_EIK_MinkowskiSumPWH_Vertical(pwhPtr1, polyPtr2); } internal override IntPtr MinkowskiSum_Triangle(IntPtr polyPtr1, IntPtr polyPtr2) { return PolygonMinkowski_EIK_MinkowskiSum_Triangle(polyPtr1, polyPtr2); } internal override IntPtr MinkowskiSumPWH_Triangle(IntPtr pwhPtr1, IntPtr polyPtr2) { return PolygonMinkowski_EIK_MinkowskiSumPWH_Triangle(pwhPtr1, polyPtr2); } [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr PolygonMinkowski_EIK_Create(); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void PolygonMinkowski_EIK_Release(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr PolygonMinkowski_EIK_MinkowskiSum(IntPtr polyPtr1, IntPtr polyPtr2); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr PolygonMinkowski_EIK_MinkowskiSumPWH(IntPtr pwhPtr1, IntPtr polyPtr2); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr PolygonMinkowski_EIK_MinkowskiSum_SSAB(IntPtr polyPtr1, IntPtr polyPtr2); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr PolygonMinkowski_EIK_MinkowskiSum_OptimalConvex(IntPtr polyPtr1, IntPtr polyPtr2); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr PolygonMinkowski_EIK_MinkowskiSum_HertelMehlhorn(IntPtr polyPtr1, IntPtr polyPtr2); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr PolygonMinkowski_EIK_MinkowskiSum_GreeneConvex(IntPtr polyPtr1, IntPtr polyPtr2); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr PolygonMinkowski_EIK_MinkowskiSum_Vertical(IntPtr polyPtr1, IntPtr polyPtr2); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr PolygonMinkowski_EIK_MinkowskiSumPWH_Vertical(IntPtr pwhPtr1, IntPtr polyPtr2); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr PolygonMinkowski_EIK_MinkowskiSum_Triangle(IntPtr polyPtr1, IntPtr polyPtr2); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr PolygonMinkowski_EIK_MinkowskiSumPWH_Triangle(IntPtr pwhPtr1, IntPtr polyPtr2); } } ================================================ FILE: CGALDotNet/Polygons/PolygonOffset2.cs ================================================ using System; using System.Collections.Generic; using System.Text; using CGALDotNetGeometry.Numerics; using CGALDotNetGeometry.Shapes; namespace CGALDotNet.Polygons { public enum OFFSET { INTERIOR, EXTERIOR } /// /// The generic polgon offset class /// /// public sealed class PolygonOffset2 : PolygonOffset2 where K : CGALKernel, new() { /// /// Static instance of polygon offset. /// public static readonly PolygonOffset2 Instance = new PolygonOffset2(); /// /// Create new polygon offset. /// public PolygonOffset2() : base(new K()) { } /// /// /// /// public override string ToString() { return string.Format("[PolygonOffset2<{0}>: ]", Kernel.Name); } /// /// Create a interior or exterior offset. /// /// The offset type /// The polygon to offset. /// The offset amount /// The offset polygon public void CreateOffset(OFFSET offset, Polygon2 polygon, double amount, List> results) { if (offset == OFFSET.INTERIOR) CreateInteriorOffset(polygon, amount, results); else CreateExteriorOffset(polygon, amount, results); } /// /// Create a interior or exterior offset. /// /// The offset type /// The polygon to offset. /// The offset amount /// The offset polygon public void CreateOffset(OFFSET offset, PolygonWithHoles2 polygon, double amount, List> results) { if (offset == OFFSET.INTERIOR) CreateInteriorOffset(polygon, amount, results); else CreateExteriorOffset(polygon, amount, results); } /// /// Create a interior offset. /// /// The polygon to offset. /// The offset amount /// The offset polygon public void CreateInteriorOffset(Polygon2 polygon, double offset, List> results) { CheckPolygon(polygon); Kernel.CreateInteriorOffset(Ptr, polygon.Ptr, offset); int count = PolygonBufferSize(); for (int i = 0; i < count; i++) { var ptr = GetBufferedPolygon(i); results.Add(new Polygon2(ptr)); } ClearPolygonBuffer(); } /// /// Create a interior offset. /// /// The polygon to offset. /// The offset amount /// The offset polygon public void CreateInteriorOffset(PolygonWithHoles2 polygon, double offset, List> results) { CheckPolygon(polygon); Kernel.CreateInteriorOffsetPWH(Ptr, polygon.Ptr, offset, false); int count = PolygonBufferSize(); for (int i = 0; i < count; i++) { var ptr = GetBufferedPolygon(i); results.Add(new Polygon2(ptr)); } ClearPolygonBuffer(); } /// /// Create a exterior offset. /// /// The polygon to offset. /// The offset amount /// The offset polygon public void CreateExteriorOffset(Polygon2 polygon, double offset, List> results) { CheckPolygon(polygon); Kernel.CreateExteriorOffset(Ptr, polygon.Ptr, offset); int count = PolygonBufferSize(); for (int i = 0; i < count; i++) { var ptr = GetBufferedPolygon(i); results.Add(new Polygon2(ptr)); } ClearPolygonBuffer(); } /// /// Create a exterior offset. /// /// The polygon to offset. /// The offset amount /// The offset polygon public void CreateExteriorOffset(PolygonWithHoles2 polygon, double offset, List> results) { CheckPolygon(polygon); Kernel.CreateExteriorOffsetPWH(Ptr, polygon.Ptr, offset, false); int count = PolygonBufferSize(); for (int i = 0; i < count; i++) { var ptr = GetBufferedPolygon(i); results.Add(new Polygon2(ptr)); } ClearPolygonBuffer(); } /// /// Create the interior skeleton of the polygon. /// /// The polygon to offset. /// Should the polygon be included as the border. /// The skeletons segments. public void CreateInteriorSkeleton(Polygon2 polygon, bool includeBorder, List results) { CheckPolygon(polygon); Kernel.CreateInteriorSkeleton(Ptr, polygon.Ptr, includeBorder); int count = SegmentBufferSize(); for (int i = 0; i < count; i++) results.Add(GetBufferedSegment(i)); ClearSegmentBuffer(); } /// /// Create the interior skeleton of the polygon. /// /// The polygon to offset. /// Should the polygon be included as the border. /// The skeletons segments. public void CreateInteriorSkeleton(PolygonWithHoles2 polygon, bool includeBorder, List results) { CheckPolygon(polygon); Kernel.CreateInteriorSkeletonPWH(Ptr, polygon.Ptr, includeBorder); int count = SegmentBufferSize(); for (int i = 0; i < count; i++) results.Add(GetBufferedSegment(i)); ClearSegmentBuffer(); } /// /// Create the exterior skeleton of the polygon. /// /// The polygon to offset. /// The bounding boxes offset from the polygons edges. Must be > 0. /// Should the polygon be included as the border. /// The skeletons segments. public void CreateExteriorSkeleton(Polygon2 polygon, double maxOffset, bool includeBorder, List results) { CheckPolygon(polygon); if (maxOffset <= 0) return; Kernel.CreateExteriorSkeleton(Ptr, polygon.Ptr, maxOffset, includeBorder); int count = SegmentBufferSize(); for (int i = 0; i < count; i++) results.Add(GetBufferedSegment(i)); ClearSegmentBuffer(); } /// /// Create the exterior skeleton of the polygon. /// /// The polygon to offset. /// The bounding boxes offset from the polygons edges. Must be > 0. /// Should the polygon be included as the border. /// The skeletons segments. public void CreateExteriorSkeleton(PolygonWithHoles2 polygon, double maxOffset, bool includeBorder, List results) { CheckPolygon(polygon); if (maxOffset <= 0) return; Kernel.CreateExteriorSkeletonPWH(Ptr, polygon.Ptr, maxOffset, includeBorder); int count = SegmentBufferSize(); for (int i = 0; i < count; i++) results.Add(GetBufferedSegment(i)); ClearSegmentBuffer(); } } /// /// The abstract polygon offset class. /// public abstract class PolygonOffset2 : PolygonAlgorithm { /// /// /// private PolygonOffset2() { } /// /// /// /// internal PolygonOffset2(CGALKernel kernel) { Kernel = kernel.PolygonOffsetKernel2; Ptr = Kernel.Create(); } /// /// The offset kernel. /// protected private PolygonOffsetKernel2 Kernel { get; private set; } /// /// Get the number off polygons in the buffer. /// /// protected int PolygonBufferSize() { return Kernel.PolygonBufferSize(Ptr); } /// /// The size of the segment buffer. /// /// The number of segments in the buffer. protected int SegmentBufferSize() { return Kernel.SegmentBufferSize(Ptr); } /// /// Get the unmanaged point to the polygon at the buffer index /// /// The index in the buffer. /// The pointer protected IntPtr GetBufferedPolygon(int index) { return Kernel.GetBufferedPolygon(Ptr, index); } /// /// Get the segment from buffer. /// /// The segments index. /// The segment. protected Segment2d GetBufferedSegment(int index) { return Kernel.GetSegment(Ptr, index); } /// /// Clear the polygon buffer. /// protected void ClearPolygonBuffer() { Kernel.ClearPolygonBuffer(Ptr); } /// /// Clear the segment buffer. /// protected void ClearSegmentBuffer() { Kernel.ClearSegmentBuffer(Ptr); } /// /// Release the unmanaged resources. /// protected override void ReleasePtr() { Kernel.Release(Ptr); } } } ================================================ FILE: CGALDotNet/Polygons/PolygonOffsetKernel2.cs ================================================ using System; using System.Collections.Generic; using System.Runtime.InteropServices; using System.Text; using CGALDotNetGeometry.Numerics; using CGALDotNetGeometry.Shapes; namespace CGALDotNet.Polygons { internal abstract class PolygonOffsetKernel2 : CGALObjectKernel { internal abstract IntPtr Create(); internal abstract void Release(IntPtr ptr); internal abstract int PolygonBufferSize(IntPtr ptr); internal abstract int SegmentBufferSize(IntPtr ptr); internal abstract void ClearPolygonBuffer(IntPtr ptr); internal abstract void ClearSegmentBuffer(IntPtr ptr); internal abstract IntPtr GetBufferedPolygon(IntPtr ptr, int index); internal abstract Segment2d GetSegment(IntPtr ptr, int index); internal abstract void GetSegments(IntPtr ptr, Segment2d[] segments, int count); internal abstract void CreateInteriorOffset(IntPtr ptr, IntPtr polyPtr, double offset); internal abstract void CreateInteriorOffsetPWH(IntPtr ptr, IntPtr pwhPtr, double offset, bool boundaryOnly); internal abstract void CreateExteriorOffset(IntPtr ptr, IntPtr polyPtr, double offset); internal abstract void CreateExteriorOffsetPWH(IntPtr ptr, IntPtr pwhPtr, double offset, bool boundaryOnly); internal abstract void CreateInteriorSkeleton(IntPtr ptr, IntPtr polyPtr, bool includeBorder); internal abstract void CreateInteriorSkeletonPWH(IntPtr ptr, IntPtr pwhPtr, bool includeBorder); internal abstract void CreateExteriorSkeleton(IntPtr ptr, IntPtr polyPtr, double maxOffset, bool includeBorder); internal abstract void CreateExteriorSkeletonPWH(IntPtr ptr, IntPtr pwhPtr, double maxOffset, bool includeBorder); } } ================================================ FILE: CGALDotNet/Polygons/PolygonOffsetKernel2_EEK.cs ================================================ using System; using System.Collections.Generic; using System.Text; using System.Runtime.InteropServices; using CGALDotNetGeometry.Numerics; using CGALDotNetGeometry.Shapes; namespace CGALDotNet.Polygons { internal class PolygonOffsetKernel2_EEK : PolygonOffsetKernel2 { internal override string Name => "EEK"; internal static readonly PolygonOffsetKernel2 Instance = new PolygonOffsetKernel2_EEK(); internal override IntPtr Create() { return PolygonOffset2_EEK_Create(); } internal override void Release(IntPtr ptr) { PolygonOffset2_EEK_Release(ptr); } internal override int PolygonBufferSize(IntPtr ptr) { return PolygonOffset2_EEK_PolygonBufferSize(ptr); } internal override int SegmentBufferSize(IntPtr ptr) { return PolygonOffset2_EEK_SegmentBufferSize(ptr); } internal override void ClearPolygonBuffer(IntPtr ptr) { PolygonOffset2_EEK_ClearPolygonBuffer(ptr); } internal override void ClearSegmentBuffer(IntPtr ptr) { PolygonOffset2_EEK_ClearSegmentBuffer(ptr); } internal override IntPtr GetBufferedPolygon(IntPtr ptr, int index) { return PolygonOffset2_EEK_GetBufferedPolygon(ptr, index); } internal override Segment2d GetSegment(IntPtr ptr, int index) { return PolygonOffset2_EEK_GetSegment(ptr, index); } internal override void GetSegments(IntPtr ptr, Segment2d[] segments, int count) { PolygonOffset2_EEK_GetSegments(ptr, segments, count); } internal override void CreateInteriorOffset(IntPtr ptr, IntPtr polyPtr, double offset) { PolygonOffset2_EEK_CreateInteriorOffset(ptr, polyPtr, offset); } internal override void CreateInteriorOffsetPWH(IntPtr ptr, IntPtr pwhPtr, double offset, bool boundaryOnly) { PolygonOffset2_EEK_CreateInteriorOffsetPWH(ptr, pwhPtr, offset, boundaryOnly); } internal override void CreateExteriorOffset(IntPtr ptr, IntPtr polyPtr, double offset) { PolygonOffset2_EEK_CreateExteriorOffset(ptr, polyPtr, offset); } internal override void CreateExteriorOffsetPWH(IntPtr ptr, IntPtr pwhPtr, double offset, bool boundaryOnly) { PolygonOffset2_EEK_CreateExteriorOffsetPWH(ptr, pwhPtr, offset, boundaryOnly); } internal override void CreateInteriorSkeleton(IntPtr ptr, IntPtr polyPtr, bool includeBorder) { PolygonOffset2_EEK_CreateInteriorSkeleton(ptr, polyPtr, includeBorder); } internal override void CreateInteriorSkeletonPWH(IntPtr ptr, IntPtr pwhPtr, bool includeBorder) { PolygonOffset2_EEK_CreateInteriorSkeletonPWH(ptr, pwhPtr, includeBorder); } internal override void CreateExteriorSkeleton(IntPtr ptr, IntPtr polyPtr, double maxOffset, bool includeBorder) { PolygonOffset2_EEK_CreateExteriorSkeleton(ptr, polyPtr, maxOffset, includeBorder); } internal override void CreateExteriorSkeletonPWH(IntPtr ptr, IntPtr pwhPtr, double maxOffset, bool includeBorder) { PolygonOffset2_EEK_CreateExteriorSkeletonPWH(ptr, pwhPtr, maxOffset, includeBorder); } [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr PolygonOffset2_EEK_Create(); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void PolygonOffset2_EEK_Release(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int PolygonOffset2_EEK_PolygonBufferSize(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int PolygonOffset2_EEK_SegmentBufferSize(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void PolygonOffset2_EEK_ClearPolygonBuffer(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void PolygonOffset2_EEK_ClearSegmentBuffer(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr PolygonOffset2_EEK_GetBufferedPolygon(IntPtr ptr, int index); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern Segment2d PolygonOffset2_EEK_GetSegment(IntPtr ptr, int index); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void PolygonOffset2_EEK_GetSegments(IntPtr ptr, [Out] Segment2d[] segments, int count); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void PolygonOffset2_EEK_CreateInteriorOffset(IntPtr ptr, IntPtr polyPtr, double offset); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void PolygonOffset2_EEK_CreateInteriorOffsetPWH(IntPtr ptr, IntPtr pwhPtr, double offset, bool boundaryOnly); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void PolygonOffset2_EEK_CreateExteriorOffset(IntPtr ptr, IntPtr polyPtr, double offset); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void PolygonOffset2_EEK_CreateExteriorOffsetPWH(IntPtr ptr, IntPtr pwhPtr, double offset, bool boundaryOnly); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void PolygonOffset2_EEK_CreateInteriorSkeleton(IntPtr ptr, IntPtr polyPtr, bool includeBorder); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void PolygonOffset2_EEK_CreateInteriorSkeletonPWH(IntPtr ptr, IntPtr pwhPtr, bool includeBorder); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void PolygonOffset2_EEK_CreateExteriorSkeleton(IntPtr ptr, IntPtr polyPtr, double maxOffset, bool includeBorder); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void PolygonOffset2_EEK_CreateExteriorSkeletonPWH(IntPtr ptr, IntPtr pwhPtr, double maxOffset, bool includeBorder); } } ================================================ FILE: CGALDotNet/Polygons/PolygonOffsetKernel2_EIK.cs ================================================ using System; using System.Collections.Generic; using System.Text; using System.Runtime.InteropServices; using CGALDotNetGeometry.Numerics; using CGALDotNetGeometry.Shapes; namespace CGALDotNet.Polygons { internal class PolygonOffsetKernel2_EIK : PolygonOffsetKernel2 { internal override string Name => "EIK"; internal static readonly PolygonOffsetKernel2 Instance = new PolygonOffsetKernel2_EIK(); internal override IntPtr Create() { return PolygonOffset2_EIK_Create(); } internal override void Release(IntPtr ptr) { PolygonOffset2_EIK_Release(ptr); } internal override int PolygonBufferSize(IntPtr ptr) { return PolygonOffset2_EIK_PolygonBufferSize(ptr); } internal override int SegmentBufferSize(IntPtr ptr) { return PolygonOffset2_EIK_SegmentBufferSize(ptr); } internal override void ClearPolygonBuffer(IntPtr ptr) { PolygonOffset2_EIK_ClearPolygonBuffer(ptr); } internal override void ClearSegmentBuffer(IntPtr ptr) { PolygonOffset2_EIK_ClearSegmentBuffer(ptr); } internal override IntPtr GetBufferedPolygon(IntPtr ptr, int index) { return PolygonOffset2_EIK_GetBufferedPolygon(ptr, index); } internal override Segment2d GetSegment(IntPtr ptr, int index) { return PolygonOffset2_EIK_GetSegment(ptr, index); } internal override void GetSegments(IntPtr ptr, Segment2d[] segments, int count) { PolygonOffset2_EIK_GetSegments(ptr, segments, count); } internal override void CreateInteriorOffset(IntPtr ptr, IntPtr polyPtr, double offset) { PolygonOffset2_EIK_CreateInteriorOffset(ptr, polyPtr, offset); } internal override void CreateInteriorOffsetPWH(IntPtr ptr, IntPtr pwhPtr, double offset, bool boundaryOnly) { PolygonOffset2_EIK_CreateInteriorOffsetPWH(ptr, pwhPtr, offset, boundaryOnly); } internal override void CreateExteriorOffset(IntPtr ptr, IntPtr polyPtr, double offset) { PolygonOffset2_EIK_CreateExteriorOffset(ptr, polyPtr, offset); } internal override void CreateExteriorOffsetPWH(IntPtr ptr, IntPtr pwhPtr, double offset, bool boundaryOnly) { PolygonOffset2_EIK_CreateExteriorOffsetPWH(ptr, pwhPtr, offset, boundaryOnly); } internal override void CreateInteriorSkeleton(IntPtr ptr, IntPtr polyPtr, bool includeBorder) { PolygonOffset2_EIK_CreateInteriorSkeleton(ptr, polyPtr, includeBorder); } internal override void CreateInteriorSkeletonPWH(IntPtr ptr, IntPtr pwhPtr, bool includeBorder) { PolygonOffset2_EIK_CreateInteriorSkeletonPWH(ptr, pwhPtr, includeBorder); } internal override void CreateExteriorSkeleton(IntPtr ptr, IntPtr polyPtr, double maxOffset, bool includeBorder) { PolygonOffset2_EIK_CreateExteriorSkeleton(ptr, polyPtr, maxOffset, includeBorder); } internal override void CreateExteriorSkeletonPWH(IntPtr ptr, IntPtr pwhPtr, double maxOffset, bool includeBorder) { PolygonOffset2_EIK_CreateExteriorSkeletonPWH(ptr, pwhPtr, maxOffset, includeBorder); } [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr PolygonOffset2_EIK_Create(); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void PolygonOffset2_EIK_Release(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int PolygonOffset2_EIK_PolygonBufferSize(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int PolygonOffset2_EIK_SegmentBufferSize(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void PolygonOffset2_EIK_ClearPolygonBuffer(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void PolygonOffset2_EIK_ClearSegmentBuffer(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr PolygonOffset2_EIK_GetBufferedPolygon(IntPtr ptr, int index); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern Segment2d PolygonOffset2_EIK_GetSegment(IntPtr ptr, int index); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void PolygonOffset2_EIK_GetSegments(IntPtr ptr, [Out] Segment2d[] segments, int count); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void PolygonOffset2_EIK_CreateInteriorOffset(IntPtr ptr, IntPtr polyPtr, double offset); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void PolygonOffset2_EIK_CreateInteriorOffsetPWH(IntPtr ptr, IntPtr pwhPtr, double offset, bool boundaryOnly); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void PolygonOffset2_EIK_CreateExteriorOffset(IntPtr ptr, IntPtr polyPtr, double offset); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void PolygonOffset2_EIK_CreateExteriorOffsetPWH(IntPtr ptr, IntPtr pwhPtr, double offset, bool boundaryOnly); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void PolygonOffset2_EIK_CreateInteriorSkeleton(IntPtr ptr, IntPtr polyPtr, bool includeBorder); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void PolygonOffset2_EIK_CreateInteriorSkeletonPWH(IntPtr ptr, IntPtr pwhPtr, bool includeBorder); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void PolygonOffset2_EIK_CreateExteriorSkeleton(IntPtr ptr, IntPtr polyPtr, double maxOffset, bool includeBorder); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void PolygonOffset2_EIK_CreateExteriorSkeletonPWH(IntPtr ptr, IntPtr pwhPtr, double maxOffset, bool includeBorder); } } ================================================ FILE: CGALDotNet/Polygons/PolygonPartition2.cs ================================================ using System; using System.Collections.Generic; namespace CGALDotNet.Polygons { /// /// Type of polygon partitions. /// public enum POLYGON_PARTITION { OPTIMAL_CONVEX, APPROX_CONVEX, GREENE_APROX_CONVEX, Y_MONOTONE } /// /// Generic polygon partition class. /// /// The kernel type. public sealed class PolygonPartition2 : PolygonPartition2 where K : CGALKernel, new() { /// /// Static instance of polygon partition. /// public static readonly PolygonPartition2 Instance = new PolygonPartition2(); /// /// Create new polygon partition. /// public PolygonPartition2() : base(new K()) { } /// /// /// /// public override string ToString() { return string.Format("[PolygonPartition2<{0}>: ]", Kernel.Name); } /// /// Is this polygon Y monotonic. /// /// The polygon. /// True if y monotonic. public bool Is_Y_Monotone(Polygon2 polygon) { CheckPolygon(polygon); return Kernel.Is_Y_Monotone(Ptr, polygon.Ptr); } /// /// Is this polygon Y monotonic. /// /// The polygon. /// True if y monotonic. public bool Is_Y_Monotone(PolygonWithHoles2 polygon) { CheckPolygon(polygon); return Kernel.Is_Y_MonotonePWH(Ptr, polygon.Ptr); } /// /// Partition a polygon. /// /// The polygon to partition. /// The resulting polygons. public void Partition(Polygon2 polygon, List> results) { GreeneApproxConvex(polygon, results); } /// /// Partition a polygon. /// /// The polygon to partition. /// The resulting polygons. public void Partition(PolygonWithHoles2 polygon, List> results) { GreeneApproxConvex(polygon, results); } /// /// Partition a polygon. /// /// The type of partition to perfrom. /// The polygon to partition. /// The resulting polygons. public void Partition(POLYGON_PARTITION type, Polygon2 polygon, List> results) { switch (type) { case POLYGON_PARTITION.OPTIMAL_CONVEX: OptimalConvex(polygon, results); break; case POLYGON_PARTITION.APPROX_CONVEX: ApproxConvex(polygon, results); break; case POLYGON_PARTITION.GREENE_APROX_CONVEX: GreeneApproxConvex(polygon, results); break; case POLYGON_PARTITION.Y_MONOTONE: Y_Monotone(polygon, results); break; } } /// /// Partition a polygon. /// /// The type of partition to perfrom. /// The polygon to partition. /// The resulting polygons. public void Partition(POLYGON_PARTITION type, PolygonWithHoles2 polygon, List> results) { switch (type) { case POLYGON_PARTITION.OPTIMAL_CONVEX: OptimalConvex(polygon, results); break; case POLYGON_PARTITION.APPROX_CONVEX: ApproxConvex(polygon, results); break; case POLYGON_PARTITION.GREENE_APROX_CONVEX: GreeneApproxConvex(polygon, results); break; case POLYGON_PARTITION.Y_MONOTONE: Y_Monotone(polygon, results); break; } } /// /// Partition in to Y monotonic polygons. /// /// The polygon to partition. /// The resulting polygons. public void Y_Monotone(Polygon2 polygon, List> results) { CheckPolygon(polygon); int count = Kernel.Y_MonotonePartition(Ptr, polygon.Ptr); CopyBufferAndClear(count, results); } /// /// Partition in to Y monotonic polygons. /// /// The polygon to partition. /// The resulting polygons. public void Y_Monotone(PolygonWithHoles2 polygon, List> results) { CheckPolygon(polygon); int count = Kernel.Y_MonotonePartitionPWH(Ptr, polygon.Ptr); CopyBufferAndClear(count, results); } /// /// Partition the polygon into convex polygons where the number of /// convex polygons produced is no more than four times the minimal number. /// /// The polygon to partition. /// The resulting polygons. public void ApproxConvex(Polygon2 polygon, List> results) { CheckPolygon(polygon); int count = Kernel.ApproxConvexPartition(Ptr, polygon.Ptr); CopyBufferAndClear(count, results); } /// /// Partition the polygon into convex polygons where the number of /// convex polygons produced is no more than four times the minimal number. /// /// The polygon to partition. /// The resulting polygons. public void ApproxConvex(PolygonWithHoles2 polygon, List> results) { CheckPolygon(polygon); int count = Kernel.ApproxConvexPartitionPWH(Ptr, polygon.Ptr); CopyBufferAndClear(count, results); } /// /// Partition the polygon into convex polygons where the number of /// convex polygons produced is no more than four times the minimal number. /// /// The polygon to partition. /// The resulting polygons. public void GreeneApproxConvex(Polygon2 polygon, List> results) { CheckPolygon(polygon); int count = Kernel.GreeneApproxConvexPartition(Ptr, polygon.Ptr); CopyBufferAndClear(count, results); } /// /// Partition the polygon into convex polygons where the number of /// convex polygons produced is no more than four times the minimal number. /// /// The polygon to partition. /// The resulting polygons. public void GreeneApproxConvex(PolygonWithHoles2 polygon, List> results) { CheckPolygon(polygon); int count = Kernel.GreeneApproxConvexPartitionPWH(Ptr, polygon.Ptr); CopyBufferAndClear(count, results); } /// /// Partition the polygon into convex polygons where the number of /// convex polygons produced is minimal. /// /// The polygon to partition. /// The resulting polygons. public void OptimalConvex(Polygon2 polygon, List> results) { CheckPolygon(polygon); int count = Kernel.OptimalConvexPartition(Ptr, polygon.Ptr); CopyBufferAndClear(count, results); } /// /// Partition the polygon into convex polygons where the number of /// convex polygons produced is minimal. /// /// The polygon to partition. /// The resulting polygons. public void OptimalConvex(PolygonWithHoles2 polygon, List> results) { CheckPolygon(polygon); int count = Kernel.OptimalConvexPartitionPWH(Ptr, polygon.Ptr); CopyBufferAndClear(count, results); } /// /// Copy the new polygons into the result array /// and the clear the buffer. /// /// The number of polygons in buffer. /// The resulting polygons. private void CopyBufferAndClear(int count, List> results) { for (int i = 0; i < count; i++) { var ptr = Kernel.CopyBufferItem(Ptr, i); results.Add(new Polygon2(ptr)); } Kernel.ClearBuffer(Ptr); } private bool PartitionIsValid(Polygon2 polygon) { return Kernel.PartitionIsValid(Ptr, polygon.Ptr); } private bool ConvexPartitionIsValid(Polygon2 polygon) { return Kernel.ConvexPartitionIsValid(Ptr, polygon.Ptr); } } /// /// The abstract base class. /// public abstract class PolygonPartition2 : PolygonAlgorithm { private PolygonPartition2() { } internal PolygonPartition2(CGALKernel kernel) { Kernel = kernel.PolygonPartitionKernel2; Ptr = Kernel.Create(); } /// /// The partition kernel. /// protected private PolygonPartitionKernel2 Kernel { get; private set; } /// /// Clear the unmanaged buffer. /// protected void ClearBuffer() { Kernel.ClearBuffer(Ptr); } /// /// Release the unmanaged resources. /// protected override void ReleasePtr() { Kernel.Release(Ptr); } } } ================================================ FILE: CGALDotNet/Polygons/PolygonPartitionKernel2.cs ================================================ using System; using System.Collections.Generic; using System.Text; using CGALDotNetGeometry.Numerics; namespace CGALDotNet.Polygons { internal abstract class PolygonPartitionKernel2 : CGALObjectKernel { internal abstract IntPtr Create(); internal abstract void Release(IntPtr ptr); internal abstract void ClearBuffer(IntPtr ptr); internal abstract int BufferCount(IntPtr ptr); internal abstract IntPtr CopyBufferItem(IntPtr ptr, int index); internal abstract bool Is_Y_Monotone(IntPtr ptr, IntPtr polyPtr); internal abstract bool Is_Y_MonotonePWH(IntPtr ptr, IntPtr polyPtr); internal abstract bool PartitionIsValid(IntPtr ptr, IntPtr polyPtr); internal abstract bool ConvexPartitionIsValid(IntPtr ptr, IntPtr polyPtr); internal abstract int Y_MonotonePartition(IntPtr ptr, IntPtr polyPtr); internal abstract int Y_MonotonePartitionPWH(IntPtr ptr, IntPtr polyPtr); internal abstract int ApproxConvexPartition(IntPtr ptr, IntPtr polyPtr); internal abstract int ApproxConvexPartitionPWH(IntPtr ptr, IntPtr polyPtr); internal abstract int GreeneApproxConvexPartition(IntPtr ptr, IntPtr polyPtr); internal abstract int GreeneApproxConvexPartitionPWH(IntPtr ptr, IntPtr polyPtr); internal abstract int OptimalConvexPartition(IntPtr ptr, IntPtr polyPtr); internal abstract int OptimalConvexPartitionPWH(IntPtr ptr, IntPtr polyPtr); } } ================================================ FILE: CGALDotNet/Polygons/PolygonPartitionKernel2_EEK.cs ================================================ using System; using System.Collections.Generic; using System.Text; using System.Runtime.InteropServices; using CGALDotNetGeometry.Numerics; namespace CGALDotNet.Polygons { internal class PolygonPartitionKernel2_EEK : PolygonPartitionKernel2 { internal override string Name => "EEK"; internal static readonly PolygonPartitionKernel2 Instance = new PolygonPartitionKernel2_EEK(); internal override IntPtr Create() { return PolygonPartition2_EEK_Create(); } internal override void Release(IntPtr ptr) { PolygonPartition2_EEK_Release(ptr); } internal override void ClearBuffer(IntPtr ptr) { PolygonPartition2_EEK_ClearBuffer(ptr); } internal override int BufferCount(IntPtr ptr) { return PolygonPartition2_EEK_BufferCount(ptr); } internal override IntPtr CopyBufferItem(IntPtr ptr, int index) { return PolygonPartition2_EEK_CopyBufferItem(ptr, index); } internal override bool Is_Y_Monotone(IntPtr ptr, IntPtr polyPtr) { return PolygonPartition2_EEK_Is_Y_Monotone(ptr, polyPtr); } internal override bool Is_Y_MonotonePWH(IntPtr ptr, IntPtr polyPtr) { return PolygonPartition2_EEK_Is_Y_MonotonePWH(ptr, polyPtr); } internal override bool PartitionIsValid(IntPtr ptr, IntPtr polyPtr) { return PolygonPartition2_EEK_PartitionIsValid(ptr, polyPtr); } internal override bool ConvexPartitionIsValid(IntPtr ptr, IntPtr polyPtr) { return PolygonPartition2_EEK_ConvexPartitionIsValid(ptr, polyPtr); } internal override int Y_MonotonePartition(IntPtr ptr, IntPtr polyPtr) { return PolygonPartition2_EEK_Y_MonotonePartition(ptr, polyPtr); } internal override int Y_MonotonePartitionPWH(IntPtr ptr, IntPtr polyPtr) { return PolygonPartition2_EEK_Y_MonotonePartitionPWH(ptr, polyPtr); } internal override int ApproxConvexPartition(IntPtr ptr, IntPtr polyPtr) { return PolygonPartition2_EEK_ApproxConvexPartition(ptr, polyPtr); } internal override int ApproxConvexPartitionPWH(IntPtr ptr, IntPtr polyPtr) { return PolygonPartition2_EEK_ApproxConvexPartitionPWH(ptr, polyPtr); } internal override int GreeneApproxConvexPartition(IntPtr ptr, IntPtr polyPtr) { return PolygonPartition2_EEK_GreeneApproxConvexPartition(ptr, polyPtr); } internal override int GreeneApproxConvexPartitionPWH(IntPtr ptr, IntPtr polyPtr) { return PolygonPartition2_EEK_GreeneApproxConvexPartitionPWH(ptr, polyPtr); } internal override int OptimalConvexPartition(IntPtr ptr, IntPtr polyPtr) { return PolygonPartition2_EEK_OptimalConvexPartition(ptr, polyPtr); } internal override int OptimalConvexPartitionPWH(IntPtr ptr, IntPtr polyPtr) { return PolygonPartition2_EEK_OptimalConvexPartitionPWH(ptr, polyPtr); } [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr PolygonPartition2_EEK_Create(); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void PolygonPartition2_EEK_Release(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void PolygonPartition2_EEK_ClearBuffer(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int PolygonPartition2_EEK_BufferCount(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr PolygonPartition2_EEK_CopyBufferItem(IntPtr ptr, int index); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool PolygonPartition2_EEK_Is_Y_Monotone(IntPtr ptr, IntPtr polyPtr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool PolygonPartition2_EEK_Is_Y_MonotonePWH(IntPtr ptr, IntPtr polyPtr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool PolygonPartition2_EEK_PartitionIsValid(IntPtr ptr, IntPtr polyPtr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool PolygonPartition2_EEK_ConvexPartitionIsValid(IntPtr ptr, IntPtr polyPtr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int PolygonPartition2_EEK_Y_MonotonePartition(IntPtr ptr, IntPtr polyPtr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int PolygonPartition2_EEK_Y_MonotonePartitionPWH(IntPtr ptr, IntPtr polyPtr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int PolygonPartition2_EEK_ApproxConvexPartition(IntPtr ptr, IntPtr polyPtr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int PolygonPartition2_EEK_ApproxConvexPartitionPWH(IntPtr ptr, IntPtr polyPtr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int PolygonPartition2_EEK_GreeneApproxConvexPartition(IntPtr ptr, IntPtr polyPtr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int PolygonPartition2_EEK_GreeneApproxConvexPartitionPWH(IntPtr ptr, IntPtr polyPtr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int PolygonPartition2_EEK_OptimalConvexPartition(IntPtr ptr, IntPtr polyPtr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int PolygonPartition2_EEK_OptimalConvexPartitionPWH(IntPtr ptr, IntPtr polyPtr); } } ================================================ FILE: CGALDotNet/Polygons/PolygonPartitionKernel2_EIK.cs ================================================ using System; using System.Collections.Generic; using System.Text; using System.Runtime.InteropServices; using CGALDotNetGeometry.Numerics; namespace CGALDotNet.Polygons { internal class PolygonPartitionKernel2_EIK : PolygonPartitionKernel2 { internal override string Name => "EIK"; internal static readonly PolygonPartitionKernel2 Instance = new PolygonPartitionKernel2_EIK(); internal override IntPtr Create() { return PolygonPartition2_EIK_Create(); } internal override void Release(IntPtr ptr) { PolygonPartition2_EIK_Release(ptr); } internal override void ClearBuffer(IntPtr ptr) { PolygonPartition2_EIK_ClearBuffer(ptr); } internal override int BufferCount(IntPtr ptr) { return PolygonPartition2_EIK_BufferCount(ptr); } internal override IntPtr CopyBufferItem(IntPtr ptr, int index) { return PolygonPartition2_EIK_CopyBufferItem(ptr, index); } internal override bool Is_Y_Monotone(IntPtr ptr, IntPtr polyPtr) { return PolygonPartition2_EIK_Is_Y_Monotone(ptr, polyPtr); } internal override bool Is_Y_MonotonePWH(IntPtr ptr, IntPtr polyPtr) { return PolygonPartition2_EIK_Is_Y_MonotonePWH(ptr, polyPtr); } internal override bool PartitionIsValid(IntPtr ptr, IntPtr polyPtr) { return PolygonPartition2_EIK_PartitionIsValid(ptr, polyPtr); } internal override bool ConvexPartitionIsValid(IntPtr ptr, IntPtr polyPtr) { return PolygonPartition2_EIK_ConvexPartitionIsValid(ptr, polyPtr); } internal override int Y_MonotonePartition(IntPtr ptr, IntPtr polyPtr) { return PolygonPartition2_EIK_Y_MonotonePartition(ptr, polyPtr); } internal override int Y_MonotonePartitionPWH(IntPtr ptr, IntPtr polyPtr) { return PolygonPartition2_EIK_Y_MonotonePartitionPWH(ptr, polyPtr); } internal override int ApproxConvexPartition(IntPtr ptr, IntPtr polyPtr) { return PolygonPartition2_EIK_ApproxConvexPartition(ptr, polyPtr); } internal override int ApproxConvexPartitionPWH(IntPtr ptr, IntPtr polyPtr) { return PolygonPartition2_EIK_ApproxConvexPartitionPWH(ptr, polyPtr); } internal override int GreeneApproxConvexPartition(IntPtr ptr, IntPtr polyPtr) { return PolygonPartition2_EIK_GreeneApproxConvexPartition(ptr, polyPtr); } internal override int GreeneApproxConvexPartitionPWH(IntPtr ptr, IntPtr polyPtr) { return PolygonPartition2_EIK_GreeneApproxConvexPartitionPWH(ptr, polyPtr); } internal override int OptimalConvexPartition(IntPtr ptr, IntPtr polyPtr) { return PolygonPartition2_EIK_OptimalConvexPartition(ptr, polyPtr); } internal override int OptimalConvexPartitionPWH(IntPtr ptr, IntPtr polyPtr) { return PolygonPartition2_EIK_OptimalConvexPartitionPWH(ptr, polyPtr); } [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr PolygonPartition2_EIK_Create(); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void PolygonPartition2_EIK_Release(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void PolygonPartition2_EIK_ClearBuffer(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int PolygonPartition2_EIK_BufferCount(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr PolygonPartition2_EIK_CopyBufferItem(IntPtr ptr, int index); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool PolygonPartition2_EIK_Is_Y_Monotone(IntPtr ptr, IntPtr polyPtr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool PolygonPartition2_EIK_Is_Y_MonotonePWH(IntPtr ptr, IntPtr polyPtr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool PolygonPartition2_EIK_PartitionIsValid(IntPtr ptr, IntPtr polyPtr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool PolygonPartition2_EIK_ConvexPartitionIsValid(IntPtr ptr, IntPtr polyPtr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int PolygonPartition2_EIK_Y_MonotonePartition(IntPtr ptr, IntPtr polyPtr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int PolygonPartition2_EIK_Y_MonotonePartitionPWH(IntPtr ptr, IntPtr polyPtr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int PolygonPartition2_EIK_ApproxConvexPartition(IntPtr ptr, IntPtr polyPtr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int PolygonPartition2_EIK_ApproxConvexPartitionPWH(IntPtr ptr, IntPtr polyPtr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int PolygonPartition2_EIK_GreeneApproxConvexPartition(IntPtr ptr, IntPtr polyPtr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int PolygonPartition2_EIK_GreeneApproxConvexPartitionPWH(IntPtr ptr, IntPtr polyPtr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int PolygonPartition2_EIK_OptimalConvexPartition(IntPtr ptr, IntPtr polyPtr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int PolygonPartition2_EIK_OptimalConvexPartitionPWH(IntPtr ptr, IntPtr polyPtr); } } ================================================ FILE: CGALDotNet/Polygons/PolygonSimplification2.cs ================================================ using System; using System.Collections.Generic; namespace CGALDotNet.Polygons { /// /// Cost options for simplification. /// public enum POLYGON_SIMP_COST_FUNC { SQUARE_DIST, SCALED_SQ_DIST }; /// /// Stop distance options for simplification. /// public enum POLYGON_SIMP_STOP_FUNC { BELOW_RATIO, BELOW_THRESHOLD, ABOVE_THRESHOLD }; /// /// Paramaters for poylgon simplification. /// public struct PolygonSimplificationParams { public POLYGON_SIMP_COST_FUNC cost; public POLYGON_SIMP_STOP_FUNC stop; public double threshold; /// /// The default param settings. /// public static PolygonSimplificationParams Default { get { var param = new PolygonSimplificationParams(); param.stop = POLYGON_SIMP_STOP_FUNC.BELOW_THRESHOLD; param.cost = POLYGON_SIMP_COST_FUNC.SQUARE_DIST; param.threshold = 0.5; return param; } } /// /// The param as a string. /// /// public override string ToString() { return String.Format("[PolygonSimplificationParams: Cost={0}, Stop={1}, Threshold={2}]", cost, stop, threshold); } } /// /// Generic polygon simplification class. /// /// The kernel type. public sealed class PolygonSimplification2 : PolygonSimplification2 where K : CGALKernel, new() { /// /// Static instance of polygon simplification. /// public static readonly PolygonSimplification2 Instance = new PolygonSimplification2(); /// /// /// public PolygonSimplification2() : base(new K()) { } /// /// /// /// public override string ToString() { return string.Format("[PolygonSimplification2<{0}>: ]", Kernel.Name); } /// /// Simplify the polygon. /// /// The polygon to simplify. Must be simple. /// The simplification parameters. /// The simplified polygon. public Polygon2 Simplify(Polygon2 polygon, PolygonSimplificationParams param) { CheckPolygon(polygon); var ptr = Kernel.SimplifyPolygon(polygon.Ptr, param); return new Polygon2(ptr); } /// /// Simplify the polygon. /// /// The polygon to simplify. Must be simple. /// The simplification parameters. /// The simplified polygon ptr. internal IntPtr SimplifyPtr(Polygon2 polygon, PolygonSimplificationParams param) { CheckPolygon(polygon); return Kernel.SimplifyPolygon(polygon.Ptr, param); } /// /// Simplify the polygons boundary and all the holes. /// /// The polygon to simplify. Must be simple. /// The simplification parameters. /// The simplified polygon. public PolygonWithHoles2 Simplify(PolygonWithHoles2 polygon, PolygonSimplificationParams param) { CheckPolygon(polygon); var ptr = Kernel.SimplifyPolygonWithHoles_All(polygon.Ptr, param); return new PolygonWithHoles2(ptr); } /// /// Simplify the polygons boundary and all the holes. /// /// The polygon to simplify. Must be simple. /// The simplification parameters. /// The simplified polygons ptr. internal IntPtr SimplifyPtr(PolygonWithHoles2 polygon, PolygonSimplificationParams param) { CheckPolygon(polygon); return Kernel.SimplifyPolygonWithHoles_All(polygon.Ptr, param); } /// /// Simplify the polygons boundary. /// /// The polygon to simplify. Must be simple. /// The simplification parameters. /// The simplified polygon. public PolygonWithHoles2 SimplifyBoundary(PolygonWithHoles2 polygon, PolygonSimplificationParams param) { CheckPolygon(polygon); var ptr = Kernel.SimplifyPolygonWithHoles_Boundary(polygon.Ptr, param); return new PolygonWithHoles2(ptr); } /// /// Simplify the polygons holes. /// /// The polygon to simplify. Must be simple. /// The simplification parameters. /// The simplified polygon. public PolygonWithHoles2 SimplifyHoles(PolygonWithHoles2 polygon, PolygonSimplificationParams param) { CheckPolygon(polygon); var ptr = Kernel.SimplifyPolygonWithHoles_Holes(polygon.Ptr, param); return new PolygonWithHoles2(ptr); } /// /// Simplify one of the polygons holes. /// /// The polygon to simplify. Must be simple. /// The simplification parameters. /// The hole index to simplify. /// The simplified polygon. public PolygonWithHoles2 SimplifyHole(PolygonWithHoles2 polygon, PolygonSimplificationParams param, int index) { CheckPolygon(polygon); var ptr = Kernel.SimplifyPolygonWithHoles_Hole(polygon.Ptr, param, index); return new PolygonWithHoles2(ptr); } } /// /// Abstract polygon simplification class. /// public abstract class PolygonSimplification2 : PolygonAlgorithm { private PolygonSimplification2() { } internal PolygonSimplification2(CGALKernel kernel) { Kernel = kernel.PolygonSimplificationKernel2; Ptr = Kernel.Create(); } /// /// The simplification kernel. /// protected private PolygonSimplificationKernel2 Kernel { get; private set; } /// /// Release unmanaged resources. /// protected override void ReleasePtr() { Kernel.Release(Ptr); } } } ================================================ FILE: CGALDotNet/Polygons/PolygonSimplificationKernel2.cs ================================================ using System; using System.Collections.Generic; using System.Text; using CGALDotNetGeometry.Numerics; namespace CGALDotNet.Polygons { internal abstract class PolygonSimplificationKernel2 : CGALObjectKernel { internal abstract IntPtr Create(); internal abstract void Release(IntPtr ptr); internal abstract IntPtr SimplifyPolygon(IntPtr polyPtr, PolygonSimplificationParams param); internal abstract IntPtr SimplifyPolygonWithHoles_All(IntPtr polyPtr, PolygonSimplificationParams param); internal abstract IntPtr SimplifyPolygonWithHoles_Boundary(IntPtr polyPtr, PolygonSimplificationParams param); internal abstract IntPtr SimplifyPolygonWithHoles_Holes(IntPtr polyPtr, PolygonSimplificationParams param); internal abstract IntPtr SimplifyPolygonWithHoles_Hole(IntPtr polyPtr, PolygonSimplificationParams param, int index); } } ================================================ FILE: CGALDotNet/Polygons/PolygonSimplificationKernel2_EEK.cs ================================================ using System; using System.Collections.Generic; using System.Text; using System.Runtime.InteropServices; using CGALDotNetGeometry.Numerics; namespace CGALDotNet.Polygons { internal class PolygonSimplificationKernel2_EEK : PolygonSimplificationKernel2 { internal override string Name => "EEK"; internal static readonly PolygonSimplificationKernel2 Instance = new PolygonSimplificationKernel2_EEK(); internal override IntPtr Create() { return PolygonSimplification2_EEK_Create(); } internal override void Release(IntPtr ptr) { PolygonSimplification2_EEK_Release(ptr); } internal override IntPtr SimplifyPolygon(IntPtr polyPtr, PolygonSimplificationParams param) { return PolygonSimplification2_EEK_Simplify(polyPtr, param.cost, param.stop, param.threshold); } internal override IntPtr SimplifyPolygonWithHoles_All(IntPtr pwhPtr, PolygonSimplificationParams param) { return PolygonSimplification2_EEK_SimplifyPolygonWithHoles_All(pwhPtr, param.cost, param.stop, param.threshold); } internal override IntPtr SimplifyPolygonWithHoles_Boundary(IntPtr pwhPtr, PolygonSimplificationParams param) { return PolygonSimplification2_EEK_SimplifyPolygonWithHoles_Boundary(pwhPtr, param.cost, param.stop, param.threshold); } internal override IntPtr SimplifyPolygonWithHoles_Holes(IntPtr pwhPtr, PolygonSimplificationParams param) { return PolygonSimplification2_EEK_SimplifyPolygonWithHoles_Holes(pwhPtr, param.cost, param.stop, param.threshold); } internal override IntPtr SimplifyPolygonWithHoles_Hole(IntPtr pwhPtr, PolygonSimplificationParams param, int index) { return PolygonSimplification2_EEK_SimplifyPolygonWithHoles_Hole(pwhPtr, param.cost, param.stop, param.threshold, index); } [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr PolygonSimplification2_EEK_Create(); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void PolygonSimplification2_EEK_Release(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr PolygonSimplification2_EEK_Simplify(IntPtr polyPtr, POLYGON_SIMP_COST_FUNC cost, POLYGON_SIMP_STOP_FUNC stop, double theshold); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr PolygonSimplification2_EEK_SimplifyPolygonWithHoles_All(IntPtr pwhPtr, POLYGON_SIMP_COST_FUNC cost, POLYGON_SIMP_STOP_FUNC stop, double theshold); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr PolygonSimplification2_EEK_SimplifyPolygonWithHoles_Boundary(IntPtr pwhPtr, POLYGON_SIMP_COST_FUNC cost, POLYGON_SIMP_STOP_FUNC stop, double theshold); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr PolygonSimplification2_EEK_SimplifyPolygonWithHoles_Holes(IntPtr pwhPtr, POLYGON_SIMP_COST_FUNC cost, POLYGON_SIMP_STOP_FUNC stop, double theshold); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr PolygonSimplification2_EEK_SimplifyPolygonWithHoles_Hole(IntPtr pwhPtr, POLYGON_SIMP_COST_FUNC cost, POLYGON_SIMP_STOP_FUNC stop, double theshold, int index); } } ================================================ FILE: CGALDotNet/Polygons/PolygonSimplificationKernel2_EIK.cs ================================================ using System; using System.Collections.Generic; using System.Text; using System.Runtime.InteropServices; using CGALDotNetGeometry.Numerics; namespace CGALDotNet.Polygons { internal class PolygonSimplificationKernel2_EIK : PolygonSimplificationKernel2 { internal override string Name => "EIK"; internal static readonly PolygonSimplificationKernel2 Instance = new PolygonSimplificationKernel2_EIK(); internal override IntPtr Create() { return PolygonSimplification2_EIK_Create(); } internal override void Release(IntPtr ptr) { PolygonSimplification2_EIK_Release(ptr); } internal override IntPtr SimplifyPolygon(IntPtr polyPtr, PolygonSimplificationParams param) { return PolygonSimplification2_EIK_Simplify(polyPtr, param.cost, param.stop, param.threshold); } internal override IntPtr SimplifyPolygonWithHoles_All(IntPtr pwhPtr, PolygonSimplificationParams param) { return PolygonSimplification2_EIK_SimplifyPolygonWithHoles_All(pwhPtr, param.cost, param.stop, param.threshold); } internal override IntPtr SimplifyPolygonWithHoles_Boundary(IntPtr pwhPtr, PolygonSimplificationParams param) { return PolygonSimplification2_EIK_SimplifyPolygonWithHoles_Boundary(pwhPtr, param.cost, param.stop, param.threshold); } internal override IntPtr SimplifyPolygonWithHoles_Holes(IntPtr pwhPtr, PolygonSimplificationParams param) { return PolygonSimplification2_EIK_SimplifyPolygonWithHoles_Holes(pwhPtr, param.cost, param.stop, param.threshold); } internal override IntPtr SimplifyPolygonWithHoles_Hole(IntPtr pwhPtr, PolygonSimplificationParams param, int index) { return PolygonSimplification2_EIK_SimplifyPolygonWithHoles_Hole(pwhPtr, param.cost, param.stop, param.threshold, index); } [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr PolygonSimplification2_EIK_Create(); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void PolygonSimplification2_EIK_Release(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr PolygonSimplification2_EIK_Simplify(IntPtr polyPtr, POLYGON_SIMP_COST_FUNC cost, POLYGON_SIMP_STOP_FUNC stop, double theshold); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr PolygonSimplification2_EIK_SimplifyPolygonWithHoles_All(IntPtr pwhPtr, POLYGON_SIMP_COST_FUNC cost, POLYGON_SIMP_STOP_FUNC stop, double theshold); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr PolygonSimplification2_EIK_SimplifyPolygonWithHoles_Boundary(IntPtr pwhPtr, POLYGON_SIMP_COST_FUNC cost, POLYGON_SIMP_STOP_FUNC stop, double theshold); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr PolygonSimplification2_EIK_SimplifyPolygonWithHoles_Holes(IntPtr pwhPtr, POLYGON_SIMP_COST_FUNC cost, POLYGON_SIMP_STOP_FUNC stop, double theshold); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr PolygonSimplification2_EIK_SimplifyPolygonWithHoles_Hole(IntPtr pwhPtr, POLYGON_SIMP_COST_FUNC cost, POLYGON_SIMP_STOP_FUNC stop, double theshold, int index); } } ================================================ FILE: CGALDotNet/Polygons/PolygonVisibility.cs ================================================ using System; using System.Collections.Generic; using System.Text; using CGALDotNetGeometry.Numerics; using CGALDotNetGeometry.Shapes; namespace CGALDotNet.Polygons { public enum POLYGON_VISIBILITY { ROTATION_SWEEP, TRIANGULAR_EXPANSION } /// /// The generic polgon visibility class /// /// public sealed class PolygonVisibility : PolygonVisibility where K : CGALKernel, new() { /// /// Static instance of polygon visibility. /// public static readonly PolygonVisibility Instance = new PolygonVisibility(); /// /// Create new polygon visibility. /// public PolygonVisibility() : base(new K()) { } /// /// /// /// public override string ToString() { return string.Format("[PolygonVisibility<{0}>: ]", Kernel.Name); } /// /// Compute the visibility from a simple polygon with no holes. /// This class implements the algorithm of B.Joe and R.B.Simpson [4]. The algorithm is a modification /// and extension of the linear time algorithm of Lee [5]. It computes the visibility region from a /// viewpoint that is in the interior or on the boundary of the polygon. /// While scanning the boundary the algorithm uses a stack to manipulate the vertices, and ultimately /// yields the visibility region.For each scanned edge, at most 2 points are pushed onto the stack. /// Overall, at most 2 n points are pushed or popped. Thus, the time and space complexities of the /// algorithm are O(n) even in case of degeneracies such as needles, where n is the number of the vertices of the polygon. /// /// The visibility point. /// A simple polygon that contains the point. /// The visibility result. /// True if result was computed public bool ComputeVisibility(Point2d point, Polygon2 polygon, out Polygon2 result) { if(polygon.ContainsPoint(point)) { CheckPolygon(polygon); var ptr = Kernel.ComputeVisibilitySimple(point, polygon.Ptr); result = new Polygon2(ptr); if (result.IsClockWise) polygon.Reverse(); return true; } else { result = null; return false; } } /// /// Compute the visibility from a polygon with holes. /// /// The visibility point. /// A polygon with holes that contains the point. /// The visibility result. /// True if result was computed public bool ComputeVisibility(Point2d point, PolygonWithHoles2 polygon, out PolygonWithHoles2 result) { return ComputeVisibilityRSV(point, polygon, out result); } /// /// Compute the visibility from a polygon with holes. /// /// What method to use. /// The visibility point. /// A polygon with holes that contains the point. /// The visibility result. /// True if result was computed public bool ComputeVisibility(POLYGON_VISIBILITY method, Point2d point, PolygonWithHoles2 polygon, out PolygonWithHoles2 result) { switch (method) { case POLYGON_VISIBILITY.ROTATION_SWEEP: return ComputeVisibilityRSV(point, polygon, out result); case POLYGON_VISIBILITY.TRIANGULAR_EXPANSION: return ComputeVisibilityTEV(point, polygon, out result); default: return ComputeVisibilityTEV(point, polygon, out result); } } /// /// Compute the visibility from a polygon with holes using the triangular expansion method. /// The algorithm does not require preprocessing. It relies on the algorithm of T. /// Asano [1] based on angular plane sweep, with a time complexity of O(nlogn) in the number of vertices. /// /// The visibility point. /// A polygon with holes that contains the point. /// The visibility result. /// True if result was computed public bool ComputeVisibilityTEV(Point2d point, PolygonWithHoles2 polygon, out PolygonWithHoles2 result) { if (polygon.ContainsPoint(point)) { //CheckPolygon(polygon); var ptr = Kernel.ComputeVisibilityTEV(point, polygon.Ptr); result = new PolygonWithHoles2(ptr); return true; } else { result = null; return false; } } /// /// Compute the visibility from a polygon with holes using the rotational sweep method. /// The algorithm obtains a constrained triangulation from the input arrangement, then computes visibility by /// expanding the triangle that contains the query point. Preprocessing takes O(n) time and O(n) space, where /// n is the number of vertices of input polygon. The query time is O(nh), where h is the number of holes+1 of /// input polygon. Thus, for simple polygons (or a polygon with a constant number of holes) the algorithm /// complexity is linear, but it is O(n2) in the worst case, as the number of holes can be linear in n. /// /// The visibility point. /// A polygon with holes that contains the point. /// The visibility result. /// True if result was computed public bool ComputeVisibilityRSV(Point2d point, PolygonWithHoles2 polygon, out PolygonWithHoles2 result) { if (polygon.ContainsPoint(point)) { //CheckPolygon(polygon); var ptr = Kernel.ComputeVisibilityRSV(point, polygon.Ptr); result = new PolygonWithHoles2(ptr); return true; } else { result = null; return false; } } } /// /// The abstract polygon visibility class. /// public abstract class PolygonVisibility : PolygonAlgorithm { /// /// /// private PolygonVisibility() { } /// /// /// /// internal PolygonVisibility(CGALKernel kernel) { Kernel = kernel.PolygonVisibilityKernel; Ptr = Kernel.Create(); } /// /// The offset kernel. /// protected private PolygonVisibilityKernel Kernel { get; private set; } /// /// Release the unmanaged resources. /// protected override void ReleasePtr() { Kernel.Release(Ptr); } } } ================================================ FILE: CGALDotNet/Polygons/PolygonVisibilityKernel.cs ================================================ using System; using System.Collections.Generic; using System.Runtime.InteropServices; using System.Text; using CGALDotNetGeometry.Numerics; namespace CGALDotNet.Polygons { internal abstract class PolygonVisibilityKernel : CGALObjectKernel { internal abstract IntPtr Create(); internal abstract void Release(IntPtr ptr); internal abstract IntPtr ComputeVisibilitySimple(Point2d point, IntPtr polyPtr); internal abstract IntPtr ComputeVisibilityTEV(Point2d point, IntPtr pwhPtr); internal abstract IntPtr ComputeVisibilityRSV(Point2d point, IntPtr pwhPtr); } } ================================================ FILE: CGALDotNet/Polygons/PolygonVisibilityKernel_EEK.cs ================================================ using System; using System.Collections.Generic; using System.Runtime.InteropServices; using System.Text; using CGALDotNetGeometry.Numerics; namespace CGALDotNet.Polygons { internal class PolygonVisibilityKernel_EEK : PolygonVisibilityKernel { internal override string Name => "EEK"; internal static readonly PolygonVisibilityKernel Instance = new PolygonVisibilityKernel_EEK(); internal override IntPtr Create() { return PolygonVisibility_EEK_Create(); } internal override void Release(IntPtr ptr) { PolygonVisibility_EEK_Release(ptr); } internal override IntPtr ComputeVisibilitySimple(Point2d point, IntPtr polyPtr) { return PolygonVisibility_EEK_ComputeVisibilitySimple(point, polyPtr); } internal override IntPtr ComputeVisibilityTEV(Point2d point, IntPtr pwhPtr) { return PolygonVisibility_EEK_ComputeVisibilityTEV(point, pwhPtr); } internal override IntPtr ComputeVisibilityRSV(Point2d point, IntPtr pwhPtr) { return PolygonVisibility_EEK_ComputeVisibilityRSV(point, pwhPtr); } [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr PolygonVisibility_EEK_Create(); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void PolygonVisibility_EEK_Release(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr PolygonVisibility_EEK_ComputeVisibilitySimple(Point2d point, IntPtr polyPtr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr PolygonVisibility_EEK_ComputeVisibilityTEV(Point2d point, IntPtr pwhPtr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr PolygonVisibility_EEK_ComputeVisibilityRSV(Point2d point, IntPtr pwhPtr); } } ================================================ FILE: CGALDotNet/Polygons/PolygonVisibilityKernel_EIK.cs ================================================ using System; using System.Collections.Generic; using System.Runtime.InteropServices; using System.Text; using CGALDotNetGeometry.Numerics; namespace CGALDotNet.Polygons { internal class PolygonVisibilityKernel_EIK : PolygonVisibilityKernel { internal override string Name => "EIK"; internal static readonly PolygonVisibilityKernel Instance = new PolygonVisibilityKernel_EIK(); internal override IntPtr Create() { return PolygonVisibility_EIK_Create(); } internal override void Release(IntPtr ptr) { PolygonVisibility_EIK_Release(ptr); } internal override IntPtr ComputeVisibilitySimple(Point2d point, IntPtr polyPtr) { return PolygonVisibility_EIK_ComputeVisibilitySimple(point, polyPtr); } internal override IntPtr ComputeVisibilityTEV(Point2d point, IntPtr pwhPtr) { return PolygonVisibility_EIK_ComputeVisibilityTEV(point, pwhPtr); } internal override IntPtr ComputeVisibilityRSV(Point2d point, IntPtr pwhPtr) { return PolygonVisibility_EIK_ComputeVisibilityRSV(point, pwhPtr); } [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr PolygonVisibility_EIK_Create(); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void PolygonVisibility_EIK_Release(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr PolygonVisibility_EIK_ComputeVisibilitySimple(Point2d point, IntPtr polyPtr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr PolygonVisibility_EIK_ComputeVisibilityTEV(Point2d point, IntPtr pwhPtr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr PolygonVisibility_EIK_ComputeVisibilityRSV(Point2d point, IntPtr pwhPtr); } } ================================================ FILE: CGALDotNet/Polygons/PolygonWithHoles2.cs ================================================ using System; using System.Collections; using System.Collections.Generic; using System.Text; using CGALDotNetGeometry.Numerics; using CGALDotNetGeometry.Shapes; using CGALDotNet.Triangulations; namespace CGALDotNet.Polygons { /// /// Polygon with holes consists of a boundary and holes. /// public enum POLYGON_ELEMENT { BOUNDARY, HOLE } /// /// Generic polygon definition. /// /// The kernel type. public sealed class PolygonWithHoles2 : PolygonWithHoles2 where K : CGALKernel, new() { /// /// Default constuctor. /// public PolygonWithHoles2() : base(new K()) { } /// /// Construct polygon with the boundary. /// /// A CCW polygon. public PolygonWithHoles2(Polygon2 boundary) : base(new K(), boundary) { } /// /// Construct polygon with the boundary points /// /// A CCW set of points. public PolygonWithHoles2(Point2d[] boundary) : base(new K(), boundary) { } /// /// Create from a pointer. /// /// The polygons pointer. internal PolygonWithHoles2(IntPtr ptr) : base(new K(), ptr) { } /// /// The polygon as a string. /// /// The polygon as a string. public override string ToString() { return string.Format("[PolygonWithHoles2<{0}>: IsBounded={1}, PointCount={2}, HoleCount={3}]", Kernel.Name, IsBounded, Count, HoleCount); } /// /// Create a deep copy of the polygon. /// /// The copy. public PolygonWithHoles2 Copy() { return new PolygonWithHoles2(Kernel.Copy(Ptr)); } /// /// Create a deep copy of the polygon element. /// /// The element type to copy. /// If element os a hole thiss is the holes index. /// The copy. public Polygon2 Copy(POLYGON_ELEMENT element, int index = 0) { if (element == POLYGON_ELEMENT.BOUNDARY) { if (IsUnbounded) return new Polygon2(); var ptr = Kernel.CopyPolygon(Ptr, BOUNDARY_INDEX); if (ptr != IntPtr.Zero) return new Polygon2(ptr); else throw new InvalidOperationException("Failed to find boundary."); } else { if(index < 0 || index >= HoleCount) throw new ArgumentOutOfRangeException("Hole index must be > 0 and < HoleCount."); return new Polygon2(Kernel.CopyPolygon(Ptr, index)); } } /// /// Get the boundary as a copy. /// If unbounded will return a empty polygon. /// /// A copy of the hole polygon. public Polygon2 GetBoundary() { return Copy(POLYGON_ELEMENT.BOUNDARY); } /// /// Get the hole as a copy. /// /// The holes index /// A copy of the hole polygon. public Polygon2 GetHole(int index) { return Copy(POLYGON_ELEMENT.HOLE, index); } /// /// Add a polygon as a holes. /// Holes must simple and CW. /// /// The hole polygon. public void AddHole(Polygon2 polygon) { Kernel.AddHoleFromPolygon(Ptr, polygon.Ptr); HoleCount++; } /// /// Create a copy of boundary and hole polygons. /// /// The list of polygons. public List> ToList() { int count = HoleCount; if (IsBounded) count++; var polygons = new List>(count); if (IsBounded) polygons.Add(GetBoundary()); for (int i = 0; i < HoleCount; i++) polygons.Add(GetHole(i)); return polygons; } /// /// Triangulate the polygon. /// /// The triangle indices. public override void Triangulate(List indices) { try { var ct = ConstrainedTriangulation2.Instance; ct.InsertConstraint(this); ct.GetConstrainedDomainIndices(indices); ct.Clear(); } catch (NotImplementedException) { } catch (NotSupportedException) { } } /// /// Do the polygons intersect. /// /// The other polygon. /// Do the polygons intersect. public bool Intersects(Polygon2 polygon) { try { return PolygonBoolean2.Instance.DoIntersect(polygon, this); } catch (NotImplementedException) { } catch (NotSupportedException) { } return false; } /// /// Do the polygons intersect. /// /// The other polygon. /// Do the polygons intersect. public bool Intersects(PolygonWithHoles2 polygon) { try { return PolygonBoolean2.Instance.DoIntersect(polygon, this); } catch (NotImplementedException) { } catch (NotSupportedException) { } return false; } /// /// Connect all the holes of the polygon /// and return as a polygon. /// Will result in a non simple polygon. /// /// The connected non-simple polygon. public Polygon2 ConnectHoles() { var ptr = Kernel.ConnectHoles(Ptr); return new Polygon2(ptr); } /// /// Partition the polygon into convex pieces. /// /// The convex partition. /// The type of partition method. public void Partition(List> results, POLYGON_PARTITION type = POLYGON_PARTITION.GREENE_APROX_CONVEX) { try { var part = PolygonPartition2.Instance; part.Partition(type, this, results); } catch (NotImplementedException) { } catch (NotSupportedException) { } } /// /// Simplify the polygon. /// /// The simplification threshold. public void Simplify(double threshold) { var param = PolygonSimplificationParams.Default; param.threshold = threshold; Simplify(param); } /// /// Simplify the polygon. /// /// The simplification parameters. public void Simplify(PolygonSimplificationParams param) { try { var sim = PolygonSimplification2.Instance; var ptr = sim.SimplifyPtr(this, param); Swap(ptr); } catch (NotImplementedException) { } catch (NotSupportedException) { } } /// /// offset the polygon. Does not modify this polygon. /// /// The type of offset. /// The amount to offset. /// The offset results. public void Offset(OFFSET offset, double amount, List> results) { try { var off = PolygonOffset2.Instance; off.CreateOffset(offset, this, amount, results); } catch (NotImplementedException) { } catch (NotSupportedException) { } } } /// /// The abstract polygon definition. /// public abstract class PolygonWithHoles2 : CGALObject, IEnumerable { protected const int BOUNDARY_INDEX = -1; /// /// Default constructor. /// private PolygonWithHoles2() { IsUnbounded = true; } /// /// Construct polygon with the kernel. /// /// internal PolygonWithHoles2(CGALKernel kernel) { Kernel = kernel.PolygonWithHolesKernel2; Ptr = Kernel.Create(); IsUnbounded = true; } /// /// Construct the polygon with the kernel and boundary. /// /// /// A CCW polygon. internal PolygonWithHoles2(CGALKernel kernel, Polygon2 boundary) { Kernel = kernel.PolygonWithHolesKernel2; Ptr = Kernel.CreateFromPolygon(boundary.Ptr); IsUnbounded = false; } /// /// Construct the polygon with the kernel and boundary. /// /// /// A CCW set of points. internal PolygonWithHoles2(CGALKernel kernel, Point2d[] boundary) { Kernel = kernel.PolygonWithHolesKernel2; Ptr = Kernel.CreateFromPoints(boundary, boundary.Length); IsUnbounded = false; } /// /// Construct the polygon with the kernel and pointer. /// /// /// internal PolygonWithHoles2(CGALKernel kernel, IntPtr ptr) : base(ptr) { Kernel = kernel.PolygonWithHolesKernel2; HoleCount = Kernel.HoleCount(Ptr); IsUnbounded = FindIfUnbounded(); } /// /// Is the polygon unbounded. /// ie no boundary polygon has been set. /// public bool IsUnbounded { get; protected set; } /// /// Is the polygon bounded. /// ie a boundary polygon has been set. /// public bool IsBounded => !IsUnbounded; /// /// Number of points in the boindary polygon. /// public int Count => PointCount(POLYGON_ELEMENT.BOUNDARY); /// /// The number of holes in polygon. /// public int HoleCount { get; protected set; } /// /// Is this a simple polygon. /// Certains actions can only be carried out on simple polygons. /// public bool IsSimple => FindIfSimple(POLYGON_ELEMENT.BOUNDARY); /// /// The polygons orientation. /// Certain actions depend on the polygons orientation. /// public ORIENTATION Orientation => FindOrientation(POLYGON_ELEMENT.BOUNDARY); /// /// The orientation expressed as the clock direction. /// public CLOCK_DIR ClockDir => (CLOCK_DIR)Orientation; /// /// Is the polygon degenerate. /// Polygons with less than 3 points are degenerate. /// public bool IsDegenerate => Count < 3 || Orientation == ORIENTATION.ZERO; /// /// Is the polygon cw orientated. /// public bool IsClockWise => ClockDir == CLOCK_DIR.CLOCKWISE; /// /// Is the polygon ccw orientated. /// public bool IsCounterClockWise => ClockDir == CLOCK_DIR.COUNTER_CLOCKWISE; /// /// The polygon kernel. /// protected private PolygonWithHolesKernel2 Kernel { get; private set; } /// /// The type of kernel object uses. /// public string KernelName => Kernel.Name; /// /// Valid polygon with holes must have a simple and ccw boundary /// and all holes must be simple and cw. /// /// public bool IsValid() { if(IsBounded) { if (!FindIfSimple(POLYGON_ELEMENT.BOUNDARY)) return false; if (FindOrientation(POLYGON_ELEMENT.BOUNDARY) != ORIENTATION.POSITIVE) return false; } for(int i = 0; i < HoleCount; i++) { if (!FindIfSimple(POLYGON_ELEMENT.HOLE, i)) return false; if (FindOrientation(POLYGON_ELEMENT.HOLE, i) != ORIENTATION.NEGATIVE) return false; } return true; } /// /// Valid holes must be simple, cw and must be contained /// within the boundary polygon. /// /// /// /// True if the polygon is a valid hole. public static bool IsValidHole(PolygonWithHoles2 pwh, Polygon2 hole) { if (!hole.IsValidHole()) return false; if (!pwh.ContainsPolygon(hole)) return false; return true; } /// /// Clear the polygon. /// public void Clear() { Kernel.Clear(Ptr); IsUnbounded = true; HoleCount = 0; } /// /// Clear the polygons boundary. /// public void ClearBoundary() { Kernel.ClearBoundary(Ptr); IsUnbounded = true; } /// /// Clear the polygons holes. /// public void ClearHoles() { Kernel.ClearHoles(Ptr); HoleCount = 0; } /// /// Get the number of points of a polygon element. /// /// The element type. /// If element type is a hole this is the holes index. /// public int PointCount(POLYGON_ELEMENT element, int index = 0) { if (element == POLYGON_ELEMENT.BOUNDARY) return Kernel.PointCount(Ptr, BOUNDARY_INDEX); else return Kernel.PointCount(Ptr, index); } /// /// Remove a polygon. /// Can remove the boundary or a hole. /// /// The element type. /// If element type is a hole this is the holes index. public void Remove(POLYGON_ELEMENT element, int index = 0) { if (element == POLYGON_ELEMENT.BOUNDARY) { Kernel.ClearBoundary(Ptr); IsUnbounded = true; } else { Kernel.RemoveHole(Ptr, index); HoleCount--; } } /// /// Remove a hole from the polygon. /// /// The holes index. public void RemoveHole(int index) { if (index >= 0 && index <= HoleCount) { Kernel.RemoveHole(Ptr, index); HoleCount--; } } /// /// Reverse the polygon. /// /// The element type. /// If element type is a hole this is the holes index. public void Reverse(POLYGON_ELEMENT element, int index = 0) { if (element == POLYGON_ELEMENT.BOUNDARY) Kernel.ReversePolygon(Ptr, BOUNDARY_INDEX); else Kernel.ReversePolygon(Ptr, index); } /// /// Get a polygons point. /// /// The element type. /// The index of the point in the polygon. /// If element type is a hole this is the holes index. /// public Point2d GetPoint(POLYGON_ELEMENT element, int pointIndex, int holeIndex = 0) { if (element == POLYGON_ELEMENT.BOUNDARY) return Kernel.GetPoint(Ptr, BOUNDARY_INDEX, pointIndex); else return Kernel.GetPoint(Ptr, holeIndex, pointIndex); } /// /// Get the points in the polygon element. /// /// The element type. /// The point array to copy points into. /// The ararys length. /// If element type is a hole this is the holes index. public void GetPoints(POLYGON_ELEMENT element, Point2d[] points, int count, int holeIndex = 0) { ErrorUtil.CheckArray(points, count); if (element == POLYGON_ELEMENT.BOUNDARY) Kernel.GetPoints(Ptr, points, BOUNDARY_INDEX, points.Length); else Kernel.GetPoints(Ptr, points, holeIndex, points.Length); } /// /// Set a polygons point. /// /// The element type. /// The index of the point in the polygon. /// The point to set. /// If element type is a hole this is the holes index. public void SetPoint(POLYGON_ELEMENT element, int pointIndex, Point2d point, int holeIndex = 0) { if (element == POLYGON_ELEMENT.BOUNDARY) Kernel.SetPoint(Ptr, BOUNDARY_INDEX, pointIndex, point); else Kernel.SetPoint(Ptr, holeIndex, pointIndex, point); } /// /// Set all the points in the polygon. If the point array is longer /// than the polygon is current the extra points are appended to the end. /// /// The element type. /// The points to set. /// The ararys length. /// If element type is a hole this is the holes index. public void SetPoints(POLYGON_ELEMENT element, Point2d[] points, int count, int holeIndex = 0) { ErrorUtil.CheckArray(points, count); if (element == POLYGON_ELEMENT.BOUNDARY) Kernel.SetPoints(Ptr, points, BOUNDARY_INDEX, points.Length); else Kernel.SetPoints(Ptr, points, holeIndex, points.Length); } /// /// Triangulate the polygon. /// /// The triangle indices. public abstract void Triangulate(List indices); /// /// Add a hole from a set of points. /// /// A CW set of points. /// The ararys length. public void AddHole(Point2d[] points, int count) { ErrorUtil.CheckArray(points, count); Kernel.AddHoleFromPoints(Ptr, points, count); HoleCount++; } /// /// Find if the polygon has a boundary. /// /// True if the polygon has a boundary. public bool FindIfUnbounded() { return Kernel.IsUnbounded(Ptr); } /// /// Find the polygons bounding box. /// /// The element type. /// If element type is a hole this is the holes index. /// The polygons bounding box. public Box2d FindBoundingBox(POLYGON_ELEMENT element, int index = 0) { if (element == POLYGON_ELEMENT.BOUNDARY) return Kernel.GetBoundingBox(Ptr, BOUNDARY_INDEX); else return Kernel.GetBoundingBox(Ptr, index); } /// /// Find if the polygon is simple. /// /// The element type. /// If element type is a hole this is the holes index. /// True if the polygon is simple. public bool FindIfSimple(POLYGON_ELEMENT element, int index = 0) { if(element == POLYGON_ELEMENT.BOUNDARY) return Kernel.IsSimple(Ptr, BOUNDARY_INDEX); else return Kernel.IsSimple(Ptr, index); } /// /// Find if the polygon is convex. /// /// The element type. /// If element type is a hole this is the holes index. /// True if polygon is convex. public bool FindIfConvex(POLYGON_ELEMENT element, int index = 0) { if (element == POLYGON_ELEMENT.BOUNDARY) return Kernel.IsConvex(Ptr, BOUNDARY_INDEX); else return Kernel.IsConvex(Ptr, index); } /// /// Find the orientation of polygon. /// /// The element type. /// If element type is a hole this is the holes index. /// The orientation of the polygon. public ORIENTATION FindOrientation(POLYGON_ELEMENT element, int index = 0) { if (element == POLYGON_ELEMENT.BOUNDARY) return Kernel.Orientation(Ptr, BOUNDARY_INDEX); else return Kernel.Orientation(Ptr, index); } /// /// Find the orientated side the point is on. /// /// The element type. /// /// If element type is a hole this is the holes index. /// The orientated side of point compared to the polygon. public ORIENTED_SIDE OrientedSide(POLYGON_ELEMENT element, Point2d point, int index = 0) { if (element == POLYGON_ELEMENT.BOUNDARY) return Kernel.OrientedSide(Ptr, BOUNDARY_INDEX, point); else return Kernel.OrientedSide(Ptr, index, point); } /// /// The signed area of the polygon. /// /// The element type. /// If element type is a hole this is the holes index. /// The signed area is positive if polygon is ccw /// and negation if cw. public double FindSignedArea(POLYGON_ELEMENT element, int index = 0) { if (element == POLYGON_ELEMENT.BOUNDARY) return Kernel.SignedArea(Ptr, BOUNDARY_INDEX); else return Kernel.SignedArea(Ptr, index); } /// /// The area of the polygon. /// /// The element type. /// If element type is a hole this is the holes index. /// The polygons area. public double FindArea(POLYGON_ELEMENT element, int index = 0) { return Math.Abs(FindSignedArea(element, index)); } /// /// Enumerate all points in the polygon. /// /// Each point in polygon. public IEnumerator GetEnumerator() { for (int i = 0; i < Count; i++) yield return GetPoint( POLYGON_ELEMENT.BOUNDARY, i); } /// /// Enumerate all points in the polygon. /// /// Each point in polygon. IEnumerator IEnumerable.GetEnumerator() { return GetEnumerator(); } /// /// Return all the points in the polygon in a array. /// /// The array. public Point2d[] ToArray() { var points = new Point2d[Count]; for (int i = 0; i < Count; i++) points[i] = GetPoint(POLYGON_ELEMENT.BOUNDARY, i); return points; } /// /// Get all the points in the polygons boundary into a list. /// public void ToList(List points) { for (int i = 0; i < Count; i++) points.Add(GetPoint(POLYGON_ELEMENT.BOUNDARY, i)); } /// /// Get all the points in the polygon boundary and holes. /// /// The point array to copy into. public void GetAllPoints(List points) { int count = PointCount(POLYGON_ELEMENT.BOUNDARY); var arr = new Point2d[count]; GetPoints(POLYGON_ELEMENT.BOUNDARY, arr, arr.Length); points.AddRange(arr); for (int i = 0; i < HoleCount; i++) { count = PointCount(POLYGON_ELEMENT.HOLE, i); arr = new Point2d[count]; GetPoints(POLYGON_ELEMENT.HOLE, arr, arr.Length, i); points.AddRange(arr); } } /// /// Round each point it polygon to a number of digits. /// /// The number of digits to round to. public void Round(int digits) { int count = PointCount(POLYGON_ELEMENT.BOUNDARY); var arr = new Point2d[count]; GetPoints(POLYGON_ELEMENT.BOUNDARY, arr, arr.Length); for(int i = 0; i < count; i++) arr[i] = arr[i].Rounded(digits); SetPoints(POLYGON_ELEMENT.BOUNDARY, arr, arr.Length); for (int i = 0; i < HoleCount; i++) { count = PointCount(POLYGON_ELEMENT.HOLE, i); arr = new Point2d[count]; GetPoints(POLYGON_ELEMENT.HOLE, arr, arr.Length, i); for (int j = 0; j < count; j++) arr[j] = arr[j].Rounded(digits); SetPoints(POLYGON_ELEMENT.HOLE, arr, arr.Length, i); } } /// /// Convert the polygon to a new polygon with a different kernel. /// May result in different values due to precision issues. /// /// The new kernel type. /// The new polygon. public PolygonWithHoles2 Convert() where T : CGALKernel, new() { var k = typeof(T).Name; var e = CGALEnum.ToKernelEnum(k); var ptr = Kernel.Convert(Ptr, e); return new PolygonWithHoles2(ptr); } /// /// Release the unmanaged resoures. /// protected override void ReleasePtr() { Kernel.Release(Ptr); } /// /// Release the unmanaged pointer. /// protected override void ReleasePtr(IntPtr ptr) { Kernel.Release(ptr); } /// /// Does the polygon fully contain the other polygon. /// /// The other polygon. /// Should the boundary be included. /// True if the polygon is contained within this polygon. private bool ContainsPolygon(Polygon2 polygon, bool inculdeBoundary = true) { if (IsUnbounded) return true; for (int i = 0; i < polygon.Count; i++) { if (!ContainsPoint(polygon.GetPoint(i), inculdeBoundary)) return false; } return true; } /// /// Does this polygon contain the point. /// /// The point. /// Should points on the boundary be /// counted as being inside the polygon. /// True if the polygon contain the point. public bool ContainsPoint(Point2d point, bool inculdeBoundary = true) { var orientation = FindOrientation(POLYGON_ELEMENT.BOUNDARY); return Kernel.ContainsPoint(Ptr, point, orientation, inculdeBoundary); } /// /// Translate the polygon. /// /// The amount to translate. public void Translate(Point2d translation) { Kernel.Translate(Ptr, BOUNDARY_INDEX, translation); int count = HoleCount; for (int i = 0; i < count; i++) Kernel.Translate(Ptr, i, translation); } /// /// Translate the polygon. /// /// The element type. /// The amount to translate. /// If element type is a hole this is the holes index. public void Translate(POLYGON_ELEMENT element, Point2d translation, int index = 0) { if(element == POLYGON_ELEMENT.BOUNDARY) Kernel.Translate(Ptr, BOUNDARY_INDEX, translation); else Kernel.Translate(Ptr, index, translation); } /// /// Rotate the polygon. /// /// The amount to rotate in radians. public void Rotate(Degree rotation) { Kernel.Rotate(Ptr, BOUNDARY_INDEX, rotation.radian); int count = HoleCount; for (int i = 0; i < count; i++) Kernel.Rotate(Ptr, i, rotation.radian); } /// /// Rotate the polygon. /// /// The element type. /// The amount to rotate in radians. /// If element type is a hole this is the holes index. public void Rotate(POLYGON_ELEMENT element, Degree rotation, int index = 0) { if (element == POLYGON_ELEMENT.BOUNDARY) Kernel.Rotate(Ptr, BOUNDARY_INDEX, rotation.radian); else Kernel.Rotate(Ptr, index, rotation.radian); } /// /// Rotate the polygon. /// /// The amount to scale. public void Scale(double scale) { Kernel.Scale(Ptr, BOUNDARY_INDEX, scale); int count = HoleCount; for (int i = 0; i < count; i++) Kernel.Scale(Ptr, i, scale); } /// /// Scale the polygon. /// /// The element type. /// The amount to scale. /// If element type is a hole this is the holes index. public void Scale(POLYGON_ELEMENT element, double scale, int index = 0) { if (element == POLYGON_ELEMENT.BOUNDARY) Kernel.Scale(Ptr, BOUNDARY_INDEX, scale); else Kernel.Scale(Ptr, index, scale); } /// /// Transform the polygon. /// /// The amount to translate. /// The amount to rotate in radians. /// The amount to scale. public void Transform(Point2d translation, Degree rotation, double scale) { Kernel.Transform(Ptr, BOUNDARY_INDEX, translation, rotation.radian, scale); int count = HoleCount; for (int i = 0; i < count; i++) Kernel.Transform(Ptr, i, translation, rotation.radian, scale); } /// /// Transform the polygon. /// /// The element type. /// The amount to translate. /// The amount to rotate in radians. /// The amount to scale. /// If element type is a hole this is the holes index. public void Transform(POLYGON_ELEMENT element, Point2d translation, Degree rotation, double scale, int index = 0) { if (element == POLYGON_ELEMENT.BOUNDARY) Kernel.Transform(Ptr, BOUNDARY_INDEX, translation, rotation.radian, scale); else Kernel.Transform(Ptr, index, translation, rotation.radian, scale); } /// /// Print debug infomation. /// /// public override void Print(StringBuilder builder) { builder.AppendLine(ToString()); builder.AppendLine("Is Bounded = " + IsBounded); if (!IsUnbounded) { var element = POLYGON_ELEMENT.BOUNDARY; builder.AppendLine("Boundary point count = " + PointCount(element)); builder.AppendLine("Boundary is simple = " + FindIfSimple(element)); builder.AppendLine("Boundary is convex = " + FindIfConvex(element)); builder.AppendLine("Boundary orientation = " + FindOrientation(element)); builder.AppendLine("Boundary signed Area = " + FindSignedArea(element)); } for (int i = 0; i < HoleCount; i++) { builder.AppendLine(""); var element = POLYGON_ELEMENT.HOLE; builder.AppendLine("Hole " + i + " point count = " + PointCount(element, i)); builder.AppendLine("Hole " + i + " is simple = " + FindIfSimple(element, i)); builder.AppendLine("Hole " + i + " is convex = " + FindIfConvex(element, i)); builder.AppendLine("Hole " + i + " is orientation = " + FindOrientation(element, i)); builder.AppendLine("Hole " + i + " is signed area = " + FindSignedArea(element, i)); builder.AppendLine(); } } } } ================================================ FILE: CGALDotNet/Polygons/PolygonWithHolesKernel2.cs ================================================ using System; using System.Collections.Generic; using System.Text; using CGALDotNetGeometry.Numerics; using CGALDotNetGeometry.Shapes; namespace CGALDotNet.Polygons { internal abstract class PolygonWithHolesKernel2 : CGALObjectKernel { internal abstract IntPtr Create(); internal abstract void Release(IntPtr ptr); internal abstract int HoleCount(IntPtr ptr); internal abstract int PointCount(IntPtr ptr, int index); internal abstract IntPtr Copy(IntPtr ptr); internal abstract IntPtr Convert(IntPtr ptr, CGAL_KERNEL k); internal abstract void Clear(IntPtr ptr); internal abstract void ClearBoundary(IntPtr ptr); internal abstract void ClearHoles(IntPtr ptr); internal abstract IntPtr CreateFromPolygon(IntPtr ptr); internal abstract IntPtr CreateFromPoints(Point2d[] points, int count); internal abstract Point2d GetPoint(IntPtr ptr, int polyIndex, int pointIndex); internal abstract void GetPoints(IntPtr ptr, Point2d[] points, int polyIndex, int count); internal abstract void SetPoint(IntPtr ptr, int polyIndex, int pointIndex, Point2d point); internal abstract void SetPoints(IntPtr ptr, Point2d[] points, int polyIndex, int count); internal abstract void AddHoleFromPolygon(IntPtr pwhPtr, IntPtr polygonPtr); internal abstract void AddHoleFromPoints(IntPtr ptr, Point2d[] points, int count); internal abstract void RemoveHole(IntPtr ptr, int index); internal abstract IntPtr CopyPolygon(IntPtr ptr, int index); internal abstract void ReversePolygon(IntPtr ptr, int index); internal abstract bool IsUnbounded(IntPtr ptr); internal abstract Box2d GetBoundingBox(IntPtr ptr, int index); internal abstract bool IsSimple(IntPtr ptr, int index); internal abstract bool IsConvex(IntPtr ptr, int index); internal abstract ORIENTATION Orientation(IntPtr ptr, int index); internal abstract ORIENTED_SIDE OrientedSide(IntPtr ptr, int index, Point2d point); internal abstract double SignedArea(IntPtr ptr, int index); internal abstract void Translate(IntPtr ptr, int index, Point2d translation); internal abstract void Rotate(IntPtr ptr, int index, double rotation); internal abstract void Scale(IntPtr ptr, int index, double scale); internal abstract void Transform(IntPtr ptr, int index, Point2d translation, double rotation, double scale); internal abstract bool ContainsPoint(IntPtr ptr, Point2d point, ORIENTATION orientation, bool inculdeBoundary); internal abstract IntPtr ConnectHoles(IntPtr ptr); } } ================================================ FILE: CGALDotNet/Polygons/PolygonWithHolesKernel2_EEK.cs ================================================ using CGALDotNetGeometry.Numerics; using System; using System.Runtime.InteropServices; using CGALDotNetGeometry.Shapes; namespace CGALDotNet.Polygons { internal sealed class PolygonWithHolesKernel2_EEK : PolygonWithHolesKernel2 { internal override string Name => "EEK"; internal static readonly PolygonWithHolesKernel2_EEK Instance = new PolygonWithHolesKernel2_EEK(); internal override IntPtr Create() { return PolygonWithHoles2_EEK_Create(); } internal override void Release(IntPtr ptr) { PolygonWithHoles2_EEK_Release(ptr); } internal override int HoleCount(IntPtr ptr) { return PolygonWithHoles2_EEK_HoleCount(ptr); } internal override int PointCount(IntPtr ptr, int index) { return PolygonWithHoles2_EEK_PointCount(ptr, index); } internal override IntPtr Copy(IntPtr ptr) { return PolygonWithHoles2_EEK_Copy(ptr); } internal override IntPtr Convert(IntPtr ptr, CGAL_KERNEL k) { return PolygonWithHoles2_EEK_Convert(ptr, k); } internal override void Clear(IntPtr ptr) { PolygonWithHoles2_EEK_Clear(ptr); } internal override void ClearBoundary(IntPtr ptr) { PolygonWithHoles2_EEK_ClearBoundary(ptr); } internal override void ClearHoles(IntPtr ptr) { PolygonWithHoles2_EEK_ClearHoles(ptr); } internal override IntPtr CreateFromPolygon(IntPtr ptr) { return PolygonWithHoles2_EEK_CreateFromPolygon(ptr); } internal override IntPtr CreateFromPoints(Point2d[] points, int count) { return PolygonWithHoles2_EEK_CreateFromPoints(points, count); } internal override Point2d GetPoint(IntPtr ptr, int polyIndex, int pointIndex) { return PolygonWithHoles2_EEK_GetPoint(ptr, polyIndex, pointIndex); } internal override void GetPoints(IntPtr ptr, Point2d[] points, int polyIndex, int count) { PolygonWithHoles2_EEK_GetPoints(ptr, points, polyIndex, count); } internal override void SetPoint(IntPtr ptr, int polyIndex, int pointIndex, Point2d point) { PolygonWithHoles2_EEK_SetPoint(ptr, polyIndex, pointIndex, point); } internal override void SetPoints(IntPtr ptr, Point2d[] points, int polyIndex, int count) { PolygonWithHoles2_EEK_SetPoints(ptr, points, polyIndex, count); } internal override void AddHoleFromPolygon(IntPtr pwhPtr, IntPtr polygonPtr) { PolygonWithHoles2_EEK_AddHoleFromPolygon(pwhPtr, polygonPtr); } internal override void AddHoleFromPoints(IntPtr ptr, Point2d[] points, int count) { PolygonWithHoles2_EEK_AddHoleFromPoints(ptr, points, count); } internal override void RemoveHole(IntPtr ptr, int index) { PolygonWithHoles2_EEK_RemoveHole(ptr, index); } internal override IntPtr CopyPolygon(IntPtr ptr, int index) { return PolygonWithHoles2_EEK_CopyPolygon(ptr, index); } internal override void ReversePolygon(IntPtr ptr, int index) { PolygonWithHoles2_EEK_ReversePolygon(ptr, index); } internal override bool IsUnbounded(IntPtr ptr) { return PolygonWithHoles2_EEK_IsUnbounded(ptr); } internal override Box2d GetBoundingBox(IntPtr ptr, int index) { return PolygonWithHoles2_EEK_GetBoundingBox(ptr, index); } internal override bool IsSimple(IntPtr ptr, int index) { return PolygonWithHoles2_EEK_IsSimple(ptr, index); } internal override bool IsConvex(IntPtr ptr, int index) { return PolygonWithHoles2_EEK_IsConvex(ptr, index); } internal override ORIENTATION Orientation(IntPtr ptr, int index) { return PolygonWithHoles2_EEK_Orientation(ptr, index); } internal override ORIENTED_SIDE OrientedSide(IntPtr ptr, int index, Point2d point) { return PolygonWithHoles2_EEK_OrientedSide(ptr, index, point); } internal override double SignedArea(IntPtr ptr, int index) { return PolygonWithHoles2_EEK_SignedArea(ptr, index); } internal override void Translate(IntPtr ptr, int index, Point2d translation) { PolygonWithHoles2_EEK_Translate(ptr, index, translation); } internal override void Rotate(IntPtr ptr, int index, double rotation) { PolygonWithHoles2_EEK_Rotate(ptr, index, rotation); } internal override void Scale(IntPtr ptr, int index, double scale) { PolygonWithHoles2_EEK_Scale(ptr, index, scale); } internal override void Transform(IntPtr ptr, int index, Point2d translation, double rotation, double scale) { PolygonWithHoles2_EEK_Transform(ptr, index, translation, rotation, scale); } internal override bool ContainsPoint(IntPtr ptr, Point2d point, ORIENTATION orientation, bool inculdeBoundary) { return PolygonWithHoles2_EEK_ContainsPoint(ptr, point, orientation, inculdeBoundary); } internal override IntPtr ConnectHoles(IntPtr ptr) { return PolygonWithHoles2_EEK_ConnectHoles(ptr); } [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr PolygonWithHoles2_EEK_Create(); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int PolygonWithHoles2_EEK_Release(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int PolygonWithHoles2_EEK_HoleCount(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int PolygonWithHoles2_EEK_PointCount(IntPtr ptr, int index); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr PolygonWithHoles2_EEK_Copy(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr PolygonWithHoles2_EEK_Convert(IntPtr ptr, CGAL_KERNEL k); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void PolygonWithHoles2_EEK_Clear(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void PolygonWithHoles2_EEK_ClearBoundary(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void PolygonWithHoles2_EEK_ClearHoles(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr PolygonWithHoles2_EEK_CreateFromPolygon(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr PolygonWithHoles2_EEK_CreateFromPoints(Point2d[] points, int count); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern Point2d PolygonWithHoles2_EEK_GetPoint(IntPtr ptr, int polyIndex, int pointIndex); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void PolygonWithHoles2_EEK_GetPoints(IntPtr ptr, [Out] Point2d[] points, int polyIndex, int count); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void PolygonWithHoles2_EEK_SetPoint(IntPtr ptr, int polyIndex, int pointIndex, Point2d point); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void PolygonWithHoles2_EEK_SetPoints(IntPtr ptr, Point2d[] points, int polyIndex, int count); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void PolygonWithHoles2_EEK_AddHoleFromPolygon(IntPtr pwhPtr, IntPtr polygonPtr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void PolygonWithHoles2_EEK_AddHoleFromPoints(IntPtr ptr, Point2d[] points, int count); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void PolygonWithHoles2_EEK_RemoveHole(IntPtr ptr, int index); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr PolygonWithHoles2_EEK_CopyPolygon(IntPtr ptr, int index); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void PolygonWithHoles2_EEK_ReversePolygon(IntPtr ptr, int index); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool PolygonWithHoles2_EEK_IsUnbounded(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern Box2d PolygonWithHoles2_EEK_GetBoundingBox(IntPtr ptr, int index); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool PolygonWithHoles2_EEK_IsSimple(IntPtr ptr, int index); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool PolygonWithHoles2_EEK_IsConvex(IntPtr ptr, int index); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern ORIENTATION PolygonWithHoles2_EEK_Orientation(IntPtr ptr, int index); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern ORIENTED_SIDE PolygonWithHoles2_EEK_OrientedSide(IntPtr ptr, int index, Point2d point); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern double PolygonWithHoles2_EEK_SignedArea(IntPtr ptr, int index); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void PolygonWithHoles2_EEK_Translate(IntPtr ptr, int index, Point2d translation); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void PolygonWithHoles2_EEK_Rotate(IntPtr ptr, int index, double rotation); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void PolygonWithHoles2_EEK_Scale(IntPtr ptr, int index, double scale); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void PolygonWithHoles2_EEK_Transform(IntPtr ptr, int index, Point2d translation, double rotation, double scale); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool PolygonWithHoles2_EEK_ContainsPoint(IntPtr ptr, Point2d point, ORIENTATION orientation,bool inculdeBoundary); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr PolygonWithHoles2_EEK_ConnectHoles(IntPtr ptr); } } ================================================ FILE: CGALDotNet/Polygons/PolygonWithHolesKernel2_EIK.cs ================================================ using CGALDotNetGeometry.Numerics; using System; using System.Runtime.InteropServices; using CGALDotNetGeometry.Shapes; namespace CGALDotNet.Polygons { internal sealed class PolygonWithHolesKernel2_EIK : PolygonWithHolesKernel2 { internal override string Name => "EIK"; internal static readonly PolygonWithHolesKernel2_EIK Instance = new PolygonWithHolesKernel2_EIK(); internal override IntPtr Create() { return PolygonWithHoles2_EIK_Create(); } internal override void Release(IntPtr ptr) { PolygonWithHoles2_EIK_Release(ptr); } internal override int HoleCount(IntPtr ptr) { return PolygonWithHoles2_EIK_HoleCount(ptr); } internal override int PointCount(IntPtr ptr, int index) { return PolygonWithHoles2_EIK_PointCount(ptr, index); } internal override IntPtr Copy(IntPtr ptr) { return PolygonWithHoles2_EIK_Copy(ptr); } internal override IntPtr Convert(IntPtr ptr, CGAL_KERNEL k) { return PolygonWithHoles2_EIK_Convert(ptr, k); } internal override void Clear(IntPtr ptr) { PolygonWithHoles2_EIK_Clear(ptr); } internal override void ClearBoundary(IntPtr ptr) { PolygonWithHoles2_EIK_ClearBoundary(ptr); } internal override void ClearHoles(IntPtr ptr) { PolygonWithHoles2_EIK_ClearHoles(ptr); } internal override IntPtr CreateFromPolygon(IntPtr ptr) { return PolygonWithHoles2_EIK_CreateFromPolygon(ptr); } internal override IntPtr CreateFromPoints(Point2d[] points, int count) { return PolygonWithHoles2_EIK_CreateFromPoints(points, count); } internal override Point2d GetPoint(IntPtr ptr, int polyIndex, int pointIndex) { return PolygonWithHoles2_EIK_GetPoint(ptr, polyIndex, pointIndex); } internal override void GetPoints(IntPtr ptr, Point2d[] points, int polyIndex, int count) { PolygonWithHoles2_EIK_GetPoints(ptr, points, polyIndex, count); } internal override void SetPoint(IntPtr ptr, int polyIndex, int pointIndex, Point2d point) { PolygonWithHoles2_EIK_SetPoint(ptr, polyIndex, pointIndex, point); } internal override void SetPoints(IntPtr ptr, Point2d[] points, int polyIndex, int count) { PolygonWithHoles2_EIK_SetPoints(ptr, points, polyIndex, count); } internal override void AddHoleFromPolygon(IntPtr pwhPtr, IntPtr polygonPtr) { PolygonWithHoles2_EIK_AddHoleFromPolygon(pwhPtr, polygonPtr); } internal override void AddHoleFromPoints(IntPtr ptr, Point2d[] points, int count) { PolygonWithHoles2_EIK_AddHoleFromPoints(ptr, points, count); } internal override void RemoveHole(IntPtr ptr, int index) { PolygonWithHoles2_EIK_RemoveHole(ptr, index); } internal override IntPtr CopyPolygon(IntPtr ptr, int index) { return PolygonWithHoles2_EIK_CopyPolygon(ptr, index); } internal override void ReversePolygon(IntPtr ptr, int index) { PolygonWithHoles2_EIK_ReversePolygon(ptr, index); } internal override bool IsUnbounded(IntPtr ptr) { return PolygonWithHoles2_EIK_IsUnbounded(ptr); } internal override Box2d GetBoundingBox(IntPtr ptr, int index) { return PolygonWithHoles2_EIK_GetBoundingBox(ptr, index); } internal override bool IsSimple(IntPtr ptr, int index) { return PolygonWithHoles2_EIK_IsSimple(ptr, index); } internal override bool IsConvex(IntPtr ptr, int index) { return PolygonWithHoles2_EIK_IsConvex(ptr, index); } internal override ORIENTATION Orientation(IntPtr ptr, int index) { return PolygonWithHoles2_EIK_Orientation(ptr, index); } internal override ORIENTED_SIDE OrientedSide(IntPtr ptr, int index, Point2d point) { return PolygonWithHoles2_EIK_OrientedSide(ptr, index, point); } internal override double SignedArea(IntPtr ptr, int index) { return PolygonWithHoles2_EIK_SignedArea(ptr, index); } internal override void Translate(IntPtr ptr, int index, Point2d translation) { PolygonWithHoles2_EIK_Translate(ptr, index, translation); } internal override void Rotate(IntPtr ptr, int index, double rotation) { PolygonWithHoles2_EIK_Rotate(ptr, index, rotation); } internal override void Scale(IntPtr ptr, int index, double scale) { PolygonWithHoles2_EIK_Scale(ptr, index, scale); } internal override void Transform(IntPtr ptr, int index, Point2d translation, double rotation, double scale) { PolygonWithHoles2_EIK_Transform(ptr, index, translation, rotation, scale); } internal override bool ContainsPoint(IntPtr ptr, Point2d point, ORIENTATION orientation, bool inculdeBoundary) { return PolygonWithHoles2_EIK_ContainsPoint(ptr, point, orientation, inculdeBoundary); } internal override IntPtr ConnectHoles(IntPtr ptr) { return PolygonWithHoles2_EIK_ConnectHoles(ptr); } [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr PolygonWithHoles2_EIK_Create(); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int PolygonWithHoles2_EIK_Release(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int PolygonWithHoles2_EIK_HoleCount(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int PolygonWithHoles2_EIK_PointCount(IntPtr ptr, int index); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr PolygonWithHoles2_EIK_Copy(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr PolygonWithHoles2_EIK_Convert(IntPtr ptr, CGAL_KERNEL k); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void PolygonWithHoles2_EIK_Clear(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void PolygonWithHoles2_EIK_ClearBoundary(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void PolygonWithHoles2_EIK_ClearHoles(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr PolygonWithHoles2_EIK_CreateFromPolygon(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr PolygonWithHoles2_EIK_CreateFromPoints(Point2d[] points, int count); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern Point2d PolygonWithHoles2_EIK_GetPoint(IntPtr ptr, int polyIndex, int pointIndex); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void PolygonWithHoles2_EIK_GetPoints(IntPtr ptr, [Out] Point2d[] points, int polyIndex, int count); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void PolygonWithHoles2_EIK_SetPoint(IntPtr ptr, int polyIndex, int pointIndex, Point2d point); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void PolygonWithHoles2_EIK_SetPoints(IntPtr ptr, Point2d[] points, int polyIndex, int count); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void PolygonWithHoles2_EIK_AddHoleFromPolygon(IntPtr pwhPtr, IntPtr polygonPtr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void PolygonWithHoles2_EIK_AddHoleFromPoints(IntPtr ptr, Point2d[] points, int count); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void PolygonWithHoles2_EIK_RemoveHole(IntPtr ptr, int index); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr PolygonWithHoles2_EIK_CopyPolygon(IntPtr ptr, int index); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void PolygonWithHoles2_EIK_ReversePolygon(IntPtr ptr, int index); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool PolygonWithHoles2_EIK_IsUnbounded(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern Box2d PolygonWithHoles2_EIK_GetBoundingBox(IntPtr ptr, int index); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool PolygonWithHoles2_EIK_IsSimple(IntPtr ptr, int index); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool PolygonWithHoles2_EIK_IsConvex(IntPtr ptr, int index); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern ORIENTATION PolygonWithHoles2_EIK_Orientation(IntPtr ptr, int index); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern ORIENTED_SIDE PolygonWithHoles2_EIK_OrientedSide(IntPtr ptr, int index, Point2d point); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern double PolygonWithHoles2_EIK_SignedArea(IntPtr ptr, int index); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void PolygonWithHoles2_EIK_Translate(IntPtr ptr, int index, Point2d translation); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void PolygonWithHoles2_EIK_Rotate(IntPtr ptr, int index, double rotation); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void PolygonWithHoles2_EIK_Scale(IntPtr ptr, int index, double scale); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void PolygonWithHoles2_EIK_Transform(IntPtr ptr, int index, Point2d translation, double rotation, double scale); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool PolygonWithHoles2_EIK_ContainsPoint(IntPtr ptr, Point2d point, ORIENTATION orientation, bool inculdeBoundary); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr PolygonWithHoles2_EIK_ConnectHoles(IntPtr ptr); } } ================================================ FILE: CGALDotNet/Polyhedra/IMesh.cs ================================================ using System; using System.Collections.Generic; using System.Text; using CGALDotNetGeometry.Numerics; using CGALDotNetGeometry.Shapes; namespace CGALDotNet.Polyhedra { public interface IMesh : IEnumerable { /// /// Number of vertices. /// int VertexCount { get; } /// /// Number of faces. /// int FaceCount { get; } /// /// Number of halfedges. /// int HalfedgeCount { get; } /// /// Number of border edges. /// Since each border edge of a polyhedral surface has exactly one /// border halfedge, this number is equal to size of border halfedges. /// int BorderEdgeCount { get; } /// /// Returns true if the polyhedral surface is combinatorially consistent. /// Must be a valid mesh to check many other properties. /// bool IsValid { get; } /// /// Returns true if there are no border edges. /// bool IsClosed { get; } /// /// Returns true if all faces are triangles. /// bool IsTriangle { get; } /// /// Returns true if all faces are quads. /// bool IsQuad { get; } /// /// Is this a valid triangle mesh. /// bool IsValidTriangleMesh { get; } /// /// Is this a valid closed mesh. /// bool IsValidClosedMesh { get; } /// /// Is this a valid closed triangle mesh. /// bool IsValidClosedTriangleMesh { get; } /// /// The current build stamp. /// int BuildStamp { get; } /// /// Clear the mesh. /// void Clear(); /// /// Clear the normal maps. /// /// True to clear the vertex normal map. /// True to clear the face normal map. void ClearNormalMaps(bool vertices, bool faces); /// /// Create a mesh from the points and indices. /// /// The meshes points. /// The meshes triangles as a index array. Maybe null. /// The meshes quads as a index array. Maybe null. void CreateMesh(Point3d[] points, int[] triangles, int[] quads = null); /// /// Create a triangle mesh from the points and indices. /// /// The meshes points. /// The point arrays length. /// The meshes trinagles as a index array. /// The indices array length. void CreateTriangleMesh(Point3d[] points, int pointCount, int[] indices, int indexCount); /// /// Create a quad mesh from the points and indices. /// /// The meshes points. /// The point arrays length. /// The meshes trinagles as a index array. /// The indices array length. void CreateQuadMesh(Point3d[] points, int pointCount, int[] indices, int indexCount); /// /// Create a mesh with quads and triangles. /// /// The meshes points. /// The point array length. /// The meshes triangles. /// The triangle array length. /// The meshes quads. /// The quads array length. void CreateTriangleQuadMesh(Point3d[] points, int pointsCount, int[] triangles, int triangleCount, int[] quads, int quadsCount); /// /// Create a mesh with riangles, quads, pentagons and hexagons. /// /// The meshs points. /// The length of the point array. /// The faces indices. void CreatePolygonalMesh(Point3d[] points, int pointsCount, PolygonalIndices indices); /// /// Create a mesh consisting of one polygon face. /// /// The faces points /// The length of the point array. /// Should the y coord of the points be used for the z coord. void CreatePolygonMesh(Point2d[] points, int count, bool xz); /// /// Get the triangle and quad indices. /// /// The meshes triangles as a index array. Maybe null. /// The meshes quads as a index array. Maybe null. void GetIndices(int[] triangles, int[] quads = null); /// /// Get the meshes triangles. /// /// The meshes triangles. /// The triangle array length. void GetTriangleIndices(int[] triangles, int trianglesCount); /// /// Get the meshes quads. /// /// The meshes quads. /// The quads array length. void GetQuadIndices(int[] quads, int quadsCount); /// /// Get the meshes triangles and quads. /// /// The meshes triangles. /// The triangle array length. /// The meshes quads. /// The quads array length. void GetTriangleQuadIndices(int[] triangles, int trianglesCount, int[] quads, int quadsCount); /// /// Get the meshes triangles, quads, pentagons and hexagons. /// /// The indices. PolygonalIndices GetPolygonalIndices(); /* /// /// Get the dual meshes triangles, quads, pentagons and hexagons. /// A dual mesh is were faces become vertices and vertices become faces. /// /// The faces indices PolygonalIndices GetDualPolygonalIndices(); */ /// /// Array accessor for the polygon. /// Getting a point wraps around the polygon. /// /// The points index. /// The vertices point. Point3d this[int i] { get; set; } /// /// Get the vertices point. /// /// The vertex index in the mesh. /// The vertices point. /// If index is out of range. Point3d GetPoint(int index); /// /// Get the points in the mesh. /// /// The array to copy points into. /// The point array length. void GetPoints(Point3d[] points, int count); /// /// Set the point at the index. /// /// The points index /// The pointsam> /// If index is out of range. void SetPoint(int index, Point3d point); /// /// Set the points from a array. /// /// The point array. /// The point arrays length. void SetPoints(Point3d[] points, int count); /// /// Get a halfedges segment. /// /// The halfedges index. /// The segment. /// True if halfedge found. bool GetSegment(int index, out Segment3d segment); /// /// Get a segment for each halfedge in the mesh. /// /// The segment array. /// The segment array length. void GetSegments(Segment3d[] segments, int count); /// /// Get the faces triangle. /// Presumes face is a triangle with no checks. /// /// The faces index. /// The faces triangle /// bool GetTriangle(int index, out Triangle3d triangle); /// /// Get a triangle for each face in the mesh. /// Presumes all faces are triangles with no checks. /// /// The trainagle array. /// The traingle arrays length. void GetTriangles(Triangle3d[] triangles, int count); /// /// Get the mesh vertex. /// /// The vertices index. /// The vertex. /// True if the vertex was found. bool GetVertex(int index, out MeshVertex3 vertex); /// /// Get the vertices in the mesh. /// /// The vertex array. /// The vertex array length. void GetVertices(MeshVertex3[] vertices, int count); /// /// Get the mesh face. /// /// The faces index. /// The face. /// True if the face was found. bool GetFace(int index, out MeshFace3 face); /// /// Get the faces in the mesh. /// /// The face array. /// The face array length. void GetFaces(MeshFace3[] faces, int count); /// /// Get the mesh halfedge. /// /// The halfedges index. /// The halfedge. /// True if the halfedge was found. bool GetHalfedge(int index, out MeshHalfedge3 halfedge); /// /// Get the halfedges in the mesh. /// /// The halfedge array. /// The halfedge array length. void GetHalfedges(MeshHalfedge3[] halfedges, int count); /// /// Count the number of triangles, quads and polygons in the mesh. /// /// The number of triangles, quads and polygons in the mesh. PolygonalCount GetPolygonalCount(); /// /// Count the number of triangles, quads and polygons in the dual mesh. /// A dual mesh is were faces become vertices and vertices become faces. /// /// The number of triangles, quads and polygons in the mesh. PolygonalCount GetDualPolygonalCount(); /// /// Get a centroid (the avergae face position) for each face in the mesh. /// /// The point array. /// The points arrays lemgth. void GetCentroids(Point3d[] points, int count); /// /// Computes the vertex normals if needed. /// void ComputeVertexNormals(); /// /// Computes the face normals if needed. /// void ComputeFaceNormals(); /// /// Get the vertex normals. /// /// The normals array. /// The normals array length. void GetVertexNormals(Vector3d[] normals, int count); /// /// Get the face normals. /// /// The normals array. /// The normals array length. void GetFaceNormals(Vector3d[] normals, int count); /// /// Translate each point in the mesh. /// /// The amount to translate. void Translate(Point3d translation); /// /// Rotate each point in the mesh. /// /// The amount to rotate. void Rotate(Quaternion3d rotation); /// /// Scale each point in the mesh. /// /// The amount to scale. void Scale(Point3d scale); /// /// Transform each point in the mesh. /// /// The amount to translate. /// The amount to rotate. /// The amount to scale. void Transform(Point3d translation, Quaternion3d rotation, Point3d scale); /// /// Make all faces triangles. /// void Triangulate(); /// /// Read data from a off file into the pollyhedron. /// /// The files name. void ReadOFF(string filename); /// /// Write data from a off file into the pollyhedron. /// /// The files name. void WriteOFF(string filename); /// /// Print the mesh into a string builder. /// /// void Print(StringBuilder builder); /// /// Reverses the orientation of the vertices in each face. /// void ReverseFaceOrientation(); /// /// Find what side of the mesh the lies in. /// /// The point to check. /// ON_BOUNDED_SIDE if point inside mesh, /// ON_UNBOUNDED_SIDE if point not inside, /// ON_BOUNDARY if point is on the surface. public BOUNDED_SIDE BoundedSide(Point3d point); /// /// Does the mesh contain the point. /// /// The point. /// If point is on the boundary does it count a being contained. /// True if the poly contains the point bool ContainsPoint(Point3d point, bool includeBoundary = true); /// /// Locate the face the rays hits. /// /// The ray. /// The hit result. MeshHitResult LocateFace(Ray3d ray); /// /// Find the face closest to the point. /// /// The point. /// The hit result. MeshHitResult ClosestFace(Point3d point); /// /// Locate the face hit by the ray. /// /// The ray. /// The hit face. /// True if the ray hit a face. bool LocateFace(Ray3d ray, out MeshFace3 face); /// /// Locate the vertex hit by the ray. /// /// The ray. /// The distance the vertex has to be within hit point. /// The hit vertex. /// True if the ray hit a vertex. bool LocateVertex(Ray3d ray, double radius, out MeshVertex3 vertex); /// /// Locate the edge hit by the ray. /// /// The ray. /// The distance the edge has to be within hit point. /// The hit edge. /// True if the ray hit a edge. bool LocateHalfedge(Ray3d ray, double radius, out MeshHalfedge3 edge); } } ================================================ FILE: CGALDotNet/Polyhedra/MeshFace3.cs ================================================ using System; using System.Collections.Generic; using CGALDotNetGeometry.Numerics; namespace CGALDotNet.Polyhedra { public struct MeshFace3 : IEquatable { /// /// The faces index /// public int Index; /// /// THe faces edge /// public int Halfedge; /// /// A face where all compents are null index. /// public static MeshFace3 NullFace { get { var face = new MeshFace3(); face.Index = CGALGlobal.NULL_INDEX; face.Halfedge = CGALGlobal.NULL_INDEX; return face; } } /// /// /// /// public override string ToString() { return string.Format("[MeshFace3: Index={0}, Halfedge={1}]", Index, Halfedge); } /// /// Are these faces equal. /// /// /// /// public static bool operator ==(MeshFace3 v1, MeshFace3 v2) { return v1.Index == v2.Index && v1.Halfedge == v2.Halfedge; } /// /// Are these faces not equal. /// /// /// /// public static bool operator !=(MeshFace3 v1, MeshFace3 v2) { return v1.Index != v2.Index || v1.Halfedge != v2.Halfedge; } /// /// Are these objects equal. /// /// /// public override bool Equals(object obj) { if (!(obj is MeshFace3)) return false; MeshFace3 v = (MeshFace3)obj; return this == v; } /// /// Are these faces equal. /// /// /// public bool Equals(MeshFace3 v) { return this == v; } /// /// The faces hash code. /// /// public override int GetHashCode() { unchecked { int hash = (int)MathUtil.HASH_PRIME_1; hash = (hash * MathUtil.HASH_PRIME_2) ^ Index.GetHashCode(); hash = (hash * MathUtil.HASH_PRIME_2) ^ Halfedge.GetHashCode(); return hash; } } /// /// Enmerate all edges in this edge loop. /// /// The mesh the edges belong too. /// The next edge public IEnumerable EnumerateHalfedges(IMesh mesh) { if (Halfedge != CGALGlobal.NULL_INDEX) { MeshHalfedge3 edge; mesh.GetHalfedge(Halfedge, out edge); foreach (var e in edge.EnumerateHalfedges(mesh)) yield return e; } else { yield break; } } /// /// Enmerate all vertices in this edge loop. /// /// The mesh the edges belong too. /// The next vertex public IEnumerable EnumerateVertices(IMesh mesh) { if (Halfedge != CGALGlobal.NULL_INDEX) { MeshHalfedge3 edge; mesh.GetHalfedge(Halfedge, out edge); foreach (var e in edge.EnumerateVertices(mesh)) yield return e; } else { yield break; } } } } ================================================ FILE: CGALDotNet/Polyhedra/MeshFactory.cs ================================================ using System; using System.Collections.Generic; using System.Linq; using CGALDotNetGeometry.Numerics; using CGALDotNetGeometry.Shapes; namespace CGALDotNet.Polyhedra { public struct UVSphereParams { public int meridians; public int parallels; public double radius; public static UVSphereParams Default { get { var param = new UVSphereParams(); param.parallels = 16; param.meridians = 16; param.radius = 0.5; return param; } } } public struct NormalizedCubeParams { public int divisions; public double radius; public static NormalizedCubeParams Default { get { var param = new NormalizedCubeParams(); param.divisions = 8; param.radius = 0.5; return param; } } } public struct PlaneParams { public double width; public double height; public int divisionsX; public int divisionsZ; public static PlaneParams Default { get { var param = new PlaneParams(); param.width = 1; param.height = 1; param.divisionsX = 4; param.divisionsZ = 4; return param; } } } public struct TorusParams { public int radialDivisions; public int tubularDivisions; public double radius; public double tube; public double arc; public static TorusParams Default { get { var param = new TorusParams(); param.radialDivisions = 16; param.tubularDivisions = 16; param.radius = 0.5; param.tube = 0.2; param.arc = Math.PI * 2; return param; } } } public struct CylinderParams { public double radiusTop; public double radiusBottom; public double height; public int radialDivisions; public int heightDivisions; public static CylinderParams Default { get { var param = new CylinderParams(); param.radiusTop = 0.5; param.radiusBottom = 0.5; param.height = 1; param.radialDivisions = 8; param.heightDivisions = 4; return param; } } } public struct ConeParams { public double radiusBottom; public double height; public int radialDivisions; public int heightDivisions; public static ConeParams Default { get { var param = new ConeParams(); param.radiusBottom = 0.5; param.height = 1; param.radialDivisions = 8; param.heightDivisions = 4; return param; } } internal CylinderParams AsCylinderParam() { var param = new CylinderParams(); param.radiusTop = 0; param.radiusBottom = this.radiusBottom; param.height = this.height; param.radialDivisions = this.radialDivisions; param.heightDivisions = this.heightDivisions; return param; } } public struct CapsuleParams { public int meridians; public int parallels; public double height; public double capHeight; public double radius; public static CapsuleParams Default { get { var param = new CapsuleParams(); param.parallels = 16; param.meridians = 16; param.radius = 0.25; param.height = 0.5; param.capHeight = 0.25; return param; } } } internal class IndexList { internal List points; internal List triangles; internal List quads; internal List pentagons; internal List hexagons; internal void Clear() { if( points != null) points.Clear(); if (triangles != null) triangles.Clear(); if (quads != null) quads.Clear(); if (pentagons != null) pentagons.Clear(); if (hexagons != null) hexagons.Clear(); } internal PolygonalIndices ToIndices() { var indices = new PolygonalIndices(); if (triangles != null) indices.triangles = triangles.ToArray(); if (quads != null) indices.quads = quads.ToArray(); if (pentagons != null) indices.pentagons = pentagons.ToArray(); if (hexagons != null) indices.hexagons = hexagons.ToArray(); return indices; } internal static IndexList CreateTriangleIndexList() { var list = new IndexList(); list.points = new List(); list.triangles = new List(); return list; } internal static IndexList CreatePolygonIndexList() { var list = new IndexList(); list.points = new List(); list.triangles = new List(); list.quads = new List(); list.pentagons = new List(); list.hexagons = new List(); return list; } } /// /// https://github.com/caosdoar/spheres/blob/master/src/spheres.cpp /// https://github.com/mrdoob/three.js/tree/dev/src/geometries /// internal static class MeshFactory { private const double WELD_EPS = 1e-4; private static Point3d[] Origins = { new Point3d(-1.0, -1.0, -1.0), new Point3d(1.0, -1.0, -1.0), new Point3d(1.0, -1.0, 1.0), new Point3d(-1.0, -1.0, 1.0), new Point3d(-1.0, 1.0, -1.0), new Point3d(-1.0, -1.0, 1.0) }; private static Point3d[] Rights = { new Point3d(2.0, 0.0, 0.0), new Point3d(0.0, 0.0, 2.0), new Point3d(-2.0, 0.0, 0.0), new Point3d(0.0, 0.0, -2.0), new Point3d(2.0, 0.0, 0.0), new Point3d(2.0, 0.0, 0.0) }; private static Point3d[] Ups = { new Point3d(0.0, 2.0, 0.0), new Point3d(0.0, 2.0, 0.0), new Point3d(0.0, 2.0, 0.0), new Point3d(0.0, 2.0, 0.0), new Point3d(0.0, 0.0, 2.0), new Point3d(0.0, 0.0, -2.0) }; private static void AddTriangle(this List list, int item1, int item2, int item3) { list.Add(item1); list.Add(item2); list.Add(item3); } private static void AddTriangleAlt(this List list, int item1, int item2, int item3) { list.Add(item3); list.Add(item2); list.Add(item1); } private static void AddQuad(this List list, int item1, int item2, int item3, int item4) { list.Add(item1); list.Add(item2); list.Add(item3); list.Add(item4); } private static void AddPentagon(this List list, int item1, int item2, int item3, int item4, int item5) { list.Add(item1); list.Add(item2); list.Add(item3); list.Add(item4); list.Add(item5); } private static void AddHexagon(this List list, int item1, int item2, int item3, int item4, int item5, int item6) { list.Add(item1); list.Add(item2); list.Add(item3); list.Add(item4); list.Add(item5); list.Add(item6); } internal static void CreateCube(IndexList list, double scale = 1) { list.points.Add(new Point3d(-0.5, -0.5, -0.5) * scale); //0 list.points.Add(new Point3d(0.5, -0.5, -0.5) * scale); //1 list.points.Add(new Point3d(0.5, 0.5, -0.5) * scale); //2 list.points.Add(new Point3d(-0.5, 0.5, -0.5) * scale); //3 list.points.Add(new Point3d(-0.5, 0.5, 0.5) * scale); //4 list.points.Add(new Point3d(0.5, 0.5, 0.5) * scale); //5 list.points.Add(new Point3d(0.5, -0.5, 0.5) * scale); //6 list.points.Add(new Point3d(-0.5, -0.5, 0.5) * scale); //7 if (list.quads != null) { list.quads.AddQuad(3, 2, 1, 0); //face front list.quads.AddQuad(2, 3, 4, 5); //face top list.quads.AddQuad(1, 2, 5, 6); //face right list.quads.AddQuad(0, 7, 4, 3); //face left list.quads.AddQuad(5, 4, 7, 6); //face back list.quads.AddQuad(1, 6, 7, 0); //face bottom } else { list.triangles.AddTriangle(0, 3, 1); //face front list.triangles.AddTriangle(1, 3, 2); list.triangles.AddTriangle(2, 3, 4); //face top list.triangles.AddTriangle(2, 4, 5); list.triangles.AddTriangle(1, 2, 6); //face right list.triangles.AddTriangle(2, 5, 6); list.triangles.AddTriangle(0, 7, 4); //face left list.triangles.AddTriangle(0, 4, 3); list.triangles.AddTriangle(5, 4, 7); //face back list.triangles.AddTriangle(5, 7, 6); list.triangles.AddTriangle(0, 6, 7); //face bottom list.triangles.AddTriangle(0, 1, 6); } } internal static void CreateCube(IndexList list, Box3d box) { Point3d[] corners = new Point3d[8]; box.GetCorners(corners); list.points.Add(corners[0]); //0 list.points.Add(corners[1]); //1 list.points.Add(corners[5]); //2 list.points.Add(corners[4]); //3 list.points.Add(corners[7]); //4 list.points.Add(corners[6]); //5 list.points.Add(corners[2]); //6 list.points.Add(corners[3]); //7 if (list.quads != null) { list.quads.AddQuad(3, 2, 1, 0); //face front list.quads.AddQuad(2, 3, 4, 5); //face top list.quads.AddQuad(1, 2, 5, 6); //face right list.quads.AddQuad(0, 7, 4, 3); //face left list.quads.AddQuad(5, 4, 7, 6); //face back list.quads.AddQuad(1, 6, 7, 0); //face bottom } else { list.triangles.AddTriangle(0, 2, 1); //face front list.triangles.AddTriangle(0, 3, 2); list.triangles.AddTriangle(2, 3, 4); //face top list.triangles.AddTriangle(2, 4, 5); list.triangles.AddTriangle(1, 2, 5); //face right list.triangles.AddTriangle(1, 5, 6); list.triangles.AddTriangle(0, 7, 4); //face left list.triangles.AddTriangle(0, 4, 3); list.triangles.AddTriangle(5, 4, 7); //face back list.triangles.AddTriangle(5, 7, 6); list.triangles.AddTriangle(0, 6, 7); //face bottom list.triangles.AddTriangle(0, 1, 6); } } internal static void CreatePlane(IndexList list, PlaneParams param) { double width_half = param.width / 2; double height_half = param.height / 2; int gridX = param.divisionsX; int gridY = param.divisionsZ; int gridX1 = gridX + 1; int gridY1 = gridY + 1; double segment_width = param.width / gridX; double segment_height = param.height / gridY; for (int iy = 0; iy < gridY1; iy++) { double y = iy * segment_height - height_half; for (int ix = 0; ix < gridX1; ix++) { double x = ix * segment_width - width_half; list.points.Add(new Point3d(x, 0, -y)); } } for (int iy = 0; iy < gridY; iy++) { for (int ix = 0; ix < gridX; ix++) { int a = ix + gridX1 * iy; int b = ix + gridX1 * (iy + 1); int c = (ix + 1) + gridX1 * (iy + 1); int d = (ix + 1) + gridX1 * iy; if(list.quads != null) { list.quads.AddQuad(d, c, b, a); } else { list.triangles.AddTriangle(d, b, a); list.triangles.AddTriangle(d, c, b); } } } } internal static void CreateUVSphere(IndexList list, UVSphereParams param) { double radius = param.radius; list.points.Add(new Point3d(0.0, 1.0, 0.0) * radius); for (int j = 0; j < param.parallels - 1; ++j) { double polar = Math.PI * (j + 1) / (double)param.parallels; double sp = Math.Sin(polar); double cp = Math.Cos(polar); for (int i = 0; i < param.meridians; ++i) { double azimuth = 2.0 * Math.PI * i / (double)param.meridians; double sa = Math.Sin(azimuth); double ca = Math.Cos(azimuth); double x = sp * ca; double y = cp; double z = sp * sa; list.points.Add(new Point3d(x, y, z) * radius); } } list.points.Add(new Point3d(0.0, -1.0, 0.0) * radius); for (int i = 0; i < param.meridians; ++i) { int a = i + 1; int b = (i + 1) % param.meridians + 1; list.triangles.AddTriangle(0, b, a); } for (int j = 0; j < param.parallels - 2; ++j) { int aStart = j * param.meridians + 1; int bStart = (j + 1) * param.meridians + 1; for (int i = 0; i < param.meridians; ++i) { int a = aStart + i; int a1 = aStart + (i + 1) % param.meridians; int b = bStart + i; int b1 = bStart + (i + 1) % param.meridians; if(list.quads != null) { list.quads.AddQuad(a, a1, b1, b); } else { list.triangles.AddTriangle(a, a1, b1); list.triangles.AddTriangle(a, b1, b); } } } for (int i = 0; i < param.meridians; ++i) { int a = i + param.meridians * (param.parallels - 2) + 1; int b = (i + 1) % param.meridians + param.meridians * (param.parallels - 2) + 1; list.triangles.AddTriangle(list.points.Count - 1, a, b); } } internal static void CreateNormalizedCube(IndexList list, NormalizedCubeParams param) { double radius = param.radius; double step = 1.0 / param.divisions; Point3d step3 = new Point3d(step, step, step); for (int face = 0; face < 6; ++face) { Point3d origin = Origins[face]; Point3d right = Rights[face]; Point3d up = Ups[face]; for (int j = 0; j < param.divisions + 1; ++j) { Point3d j3 = new Point3d(j, j, j); for (int i = 0; i < param.divisions + 1; ++i) { Point3d i3 = new Point3d(i, i, i); Point3d p = origin + step3 * (i3 * right + j3 * up); Vector3d v = (Vector3d)p; list.points.Add(v.Normalized * radius); } } } int k = param.divisions + 1; for (int face = 0; face < 6; ++face) { for (int j = 0; j < param.divisions; ++j) { bool bottom = j < (param.divisions / 2); for (int i = 0; i < param.divisions; ++i) { bool left = i < (param.divisions / 2); int a = (face * k + j) * k + i; int b = (face * k + j) * k + i + 1; int c = (face * k + j + 1) * k + i; int d = (face * k + j + 1) * k + i + 1; if (list.quads != null) { list.quads.AddQuad(a, c, d, b); } else { list.triangles.AddTriangle(a, c, d); list.triangles.AddTriangle(a, d, b); } } } } //WeldVertices(list); } internal static void CreateTetrahedron(IndexList list, double scale = 1) { scale *= 0.5; // choose coordinates on the unit sphere double a = 1.0 / 3.0; double b = Math.Sqrt(8.0 / 9.0); double c = Math.Sqrt(2.0 / 9.0); double d = Math.Sqrt(2.0 / 3.0); list.points.Add(new Point3d(0, 1, 0) * scale); list.points.Add(new Point3d(-c, -a, d) * scale); list.points.Add(new Point3d(-c, -a, -d) * scale); list.points.Add(new Point3d(b, -a, 0) * scale); list.triangles.AddTriangle(0, 2, 1); list.triangles.AddTriangle(0, 3, 2); list.triangles.AddTriangle(0, 1, 3); list.triangles.AddTriangle(3, 1, 2); } internal static void CreateOctahedron(IndexList list, double scale = 1) { scale *= 0.5; list.points.Add(new Point3d(1, 0, 0) * scale); list.points.Add(new Point3d(-1, 0, 0) * scale); list.points.Add(new Point3d(0, 1, 0) * scale); list.points.Add(new Point3d(0, -1, 0) * scale); list.points.Add(new Point3d(0, 0, 1) * scale); list.points.Add(new Point3d(0, 0, -1) * scale); list.triangles.AddTriangle(0, 2, 4); list.triangles.AddTriangle(0, 4, 3); list.triangles.AddTriangle(0, 3, 5); list.triangles.AddTriangle(0, 5, 2); list.triangles.AddTriangle(1, 2, 5); list.triangles.AddTriangle(1, 5, 3); list.triangles.AddTriangle(1, 3, 4); list.triangles.AddTriangle(1, 4, 2); } internal static void CreateIcosahedron(IndexList list, double scale = 1) { scale *= 0.5; double t = (1.0 + Math.Sqrt(5.0)) / 2.0; // Vertices list.points.Add(new Vector3d(-1.0, t, 0.0).Normalized * scale); list.points.Add(new Vector3d(1.0, t, 0.0).Normalized * scale); list.points.Add(new Vector3d(-1.0, -t, 0.0).Normalized * scale); list.points.Add(new Vector3d(1.0, -t, 0.0).Normalized * scale); list.points.Add(new Vector3d(0.0, -1.0, t).Normalized * scale); list.points.Add(new Vector3d(0.0, 1.0, t).Normalized * scale); list.points.Add(new Vector3d(0.0, -1.0, -t).Normalized * scale); list.points.Add(new Vector3d(0.0, 1.0, -t).Normalized * scale); list.points.Add(new Vector3d(t, 0.0, -1.0).Normalized * scale); list.points.Add(new Vector3d(t, 0.0, 1.0).Normalized * scale); list.points.Add(new Vector3d(-t, 0.0, -1.0).Normalized * scale); list.points.Add(new Vector3d(-t, 0.0, 1.0).Normalized * scale); // Faces list.triangles.AddTriangle(0, 11, 5); list.triangles.AddTriangle(0, 5, 1); list.triangles.AddTriangle(0, 1, 7); list.triangles.AddTriangle(0, 7, 10); list.triangles.AddTriangle(0, 10, 11); list.triangles.AddTriangle(1, 5, 9); list.triangles.AddTriangle(5, 11, 4); list.triangles.AddTriangle(11, 10, 2); list.triangles.AddTriangle(10, 7, 6); list.triangles.AddTriangle(7, 1, 8); list.triangles.AddTriangle(3, 9, 4); list.triangles.AddTriangle(3, 4, 2); list.triangles.AddTriangle(3, 2, 6); list.triangles.AddTriangle(3, 6, 8); list.triangles.AddTriangle(3, 8, 9); list.triangles.AddTriangle(4, 9, 5); list.triangles.AddTriangle(2, 4, 11); list.triangles.AddTriangle(6, 2, 10); list.triangles.AddTriangle(8, 6, 7); list.triangles.AddTriangle(9, 8, 1); } internal static void CreateDodecahedron(IndexList list, double scale = 1) { scale *= 0.5; double t = (1 + Math.Sqrt(5)) / 2; double r = 1 / t; list.points.Add(new Vector3d(-1, -1, -1).Normalized * scale);//0 list.points.Add(new Vector3d(-1, -1, 1).Normalized * scale); //1 list.points.Add(new Vector3d(-1, 1, -1).Normalized * scale); //2 list.points.Add(new Vector3d(-1, 1, 1).Normalized * scale); //3 list.points.Add(new Vector3d(1, -1, -1).Normalized * scale); //4 list.points.Add(new Vector3d(1, -1, 1).Normalized * scale); //5 list.points.Add(new Vector3d(1, 1, -1).Normalized * scale); //6 list.points.Add(new Vector3d(1, 1, 1).Normalized * scale); //7 list.points.Add(new Vector3d(0, -r, -t).Normalized * scale); //8 list.points.Add(new Vector3d(0, -r, t).Normalized * scale); //9 list.points.Add(new Vector3d(0, r, -t).Normalized * scale); //10 list.points.Add(new Vector3d(0, r, t).Normalized * scale ); //11 list.points.Add(new Vector3d(-r, -t, 0).Normalized * scale); //12 list.points.Add(new Vector3d(-r, t, 0).Normalized * scale ); //13 list.points.Add(new Vector3d(r, -t, 0).Normalized * scale); //14 list.points.Add(new Vector3d(r, t, 0).Normalized * scale); //15 list.points.Add(new Vector3d(-t, 0, -r).Normalized * scale); //16 list.points.Add(new Vector3d(t, 0, -r).Normalized * scale); //17 list.points.Add(new Vector3d(-t, 0, r).Normalized * scale); //18 list.points.Add(new Vector3d(t, 0, r).Normalized * scale); //19 if (list.pentagons != null) { list.pentagons.AddPentagon(3, 11, 7, 15, 13); list.pentagons.AddPentagon(15, 7, 19, 17, 6); list.pentagons.AddPentagon(10, 6, 17, 4, 8); list.pentagons.AddPentagon(2, 10, 8, 0, 16); list.pentagons.AddPentagon(16, 0, 12, 1, 18); list.pentagons.AddPentagon(6, 10, 2, 13, 15); list.pentagons.AddPentagon(2, 16, 18, 3, 13); list.pentagons.AddPentagon(11, 3, 18, 1, 9); list.pentagons.AddPentagon(8, 4, 14, 12, 0); list.pentagons.AddPentagon(11, 9, 5, 19, 7); list.pentagons.AddPentagon(19, 5, 14, 4, 17); list.pentagons.AddPentagon(9, 1, 12, 14, 5); } else { list.triangles.AddTriangle(3, 11, 7); list.triangles.AddTriangle(3, 7, 15); list.triangles.AddTriangle(3, 15, 13); list.triangles.AddTriangle(7, 19, 17); list.triangles.AddTriangle(7, 17, 6); list.triangles.AddTriangle(7, 6, 15); list.triangles.AddTriangle(17, 4, 8); list.triangles.AddTriangle(17, 8, 10); list.triangles.AddTriangle(17, 10, 6); list.triangles.AddTriangle(8, 0, 16); list.triangles.AddTriangle(8, 16, 2); list.triangles.AddTriangle(8, 2, 10); list.triangles.AddTriangle(0, 12, 1); list.triangles.AddTriangle(0, 1, 18); list.triangles.AddTriangle(0, 18, 16); list.triangles.AddTriangle(6, 10, 2); list.triangles.AddTriangle(6, 2, 13); list.triangles.AddTriangle(6, 13, 15); list.triangles.AddTriangle(2, 16, 18); list.triangles.AddTriangle(2, 18, 3); list.triangles.AddTriangle(2, 3, 13); list.triangles.AddTriangle(18, 1, 9); list.triangles.AddTriangle(18, 9, 11); list.triangles.AddTriangle(18, 11, 3); list.triangles.AddTriangle(4, 14, 12); list.triangles.AddTriangle(4, 12, 0); list.triangles.AddTriangle(4, 0, 8); list.triangles.AddTriangle(11, 9, 5); list.triangles.AddTriangle(11, 5, 19); list.triangles.AddTriangle(11, 19, 7); list.triangles.AddTriangle(19, 5, 14); list.triangles.AddTriangle(19, 14, 4); list.triangles.AddTriangle(19, 4, 17); list.triangles.AddTriangle(1, 12, 14); list.triangles.AddTriangle(1, 14, 5); list.triangles.AddTriangle(1, 5, 9); } } internal static void CreateTorus(IndexList list, TorusParams param) { for (int j = 0; j <= param.radialDivisions; j++) { for (int i = 0; i <= param.tubularDivisions; i++) { double u = i / (double)param.tubularDivisions * param.arc; double v = j / (double)param.radialDivisions * Math.PI * 2; var vertex = new Point3d(); vertex.x = (param.radius + param.tube * Math.Cos(v)) * Math.Cos(u); vertex.z = (param.radius + param.tube * Math.Cos(v)) * Math.Sin(u); vertex.y = param.tube * Math.Sin(v); list.points.Add(vertex); } } for (int j = 1; j <= param.radialDivisions; j++) { for (int i = 1; i <= param.tubularDivisions; i++) { int a = (param.tubularDivisions + 1) * j + i - 1; int b = (param.tubularDivisions + 1) * (j - 1) + i - 1; int c = (param.tubularDivisions + 1) * (j - 1) + i; int d = (param.tubularDivisions + 1) * j + i; if(list.quads != null) { list.quads.AddQuad(d, c, b, a); } else { list.triangles.AddTriangle(d, b, a); list.triangles.AddTriangle(d, c, b); } } } //WeldVertices(list); } internal static void CreateCylinder(IndexList list, CylinderParams param) { int index = 0; double thetaStart = 0; double thetaLength = Math.PI * 2; var indexArray = new List>(); double halfHeight = param.height / 2; for (int y = 0; y <= param.heightDivisions; y++) { var indexRow = new List(); double v = y / (double)param.heightDivisions; double radius = v * (param.radiusBottom - param.radiusTop) + param.radiusTop; for (int x = 0; x <= param.radialDivisions; x++) { double u = x / (double)param.radialDivisions; double theta = u * thetaLength + thetaStart; double sinTheta = Math.Sin(theta); double cosTheta = Math.Cos(theta); var vertex = new Point3d(); vertex.x = radius * sinTheta; vertex.y = -v * param.height + halfHeight; vertex.z = radius * cosTheta; list.points.Add(vertex); // save index of vertex in respective row indexRow.Add(index++); } // now save vertices of the row in our index array indexArray.Add(indexRow); } for (int x = 0; x < param.radialDivisions; x++) { for (int y = 0; y < param.heightDivisions; y++) { // we use the index array to access the correct indices int a = indexArray[y][x]; int b = indexArray[y + 1][x]; int c = indexArray[y + 1][x + 1]; int d = indexArray[y][x + 1]; if(list.quads != null) { list.quads.AddQuad(a, b, c, d); } else { list.triangles.AddTriangle(a, b, d); list.triangles.AddTriangle(b, c, d); } } } if (param.radiusTop > 0) GenerateCap(list, param, true, ref index); if (param.radiusBottom > 0) GenerateCap(list, param, false, ref index); //WeldVertices(list); } private static void GenerateCap(IndexList list, CylinderParams param, bool top, ref int index ) { double thetaStart = 0; double thetaLength = Math.PI * 2; // save the index of the first center vertex int centerIndexStart = index; double halfHeight = param.height / 2.0; double radius = top ? param.radiusTop : param.radiusBottom; double sign = top ? 1 : -1; for (int x = 1; x <= param.radialDivisions; x++) { list.points.Add(new Point3d(0, halfHeight * sign, 0)); index++; } // save the index of the last center vertex int centerIndexEnd = index; for (int x = 0; x <= param.radialDivisions; x++) { double u = x / (double)param.radialDivisions; double theta = u * thetaLength + thetaStart; double cosTheta = Math.Cos(theta); double sinTheta = Math.Sin(theta); var vertex = new Point3d(); vertex.x = radius * sinTheta; vertex.y = halfHeight * sign; vertex.z = radius * cosTheta; list.points.Add(vertex); index++; } for (int x = 0; x < param.radialDivisions; x++) { int c = centerIndexStart + x; int i = centerIndexEnd + x; if (top) list.triangles.AddTriangle(i, i + 1, c); else list.triangles.AddTriangle(i + 1, i, c); } } internal static void CreateCapsule(IndexList list, CapsuleParams param) { double radius = param.radius; int halfParallels = param.parallels / 2; double hafHeight = param.height * 0.5; double capHeight = param.capHeight; list.points.Add(new Point3d(0.0, (capHeight + hafHeight), 0.0)); for (int j = 0; j < halfParallels - 1; ++j) { double polar = Math.PI * j / (double)param.parallels; double sp = Math.Sin(polar); double cp = Math.Cos(polar); for (int i = 0; i < param.meridians; ++i) { double azimuth = 2.0 * Math.PI * i / (double)param.meridians; double sa = Math.Sin(azimuth); double ca = Math.Cos(azimuth); double x = sp * ca * radius; double y = (cp * capHeight) + hafHeight; double z = sp * sa * radius; list.points.Add(new Point3d(x, y, z)); } } for (int j = halfParallels - 1; j < param.parallels - 1; ++j) { double polar = Math.PI * (j + 2) / (double)param.parallels; double sp = Math.Sin(polar); double cp = Math.Cos(polar); for (int i = 0; i < param.meridians; ++i) { double azimuth = 2.0 * Math.PI * i / (double)param.meridians; double sa = Math.Sin(azimuth); double ca = Math.Cos(azimuth); double x = sp * ca * radius; double y = (cp * capHeight) - hafHeight; double z = sp * sa * radius; list.points.Add(new Point3d(x, y, z)); } } list.points.Add(new Point3d(0.0, -(capHeight + hafHeight), 0.0)); for (int i = 0; i < param.meridians; ++i) { int a = i + 1; int b = (i + 1) % param.meridians + 1; list.triangles.AddTriangle(0, b, a); } for (int j = 0; j < param.parallels - 2; ++j) { int aStart = j * param.meridians + 1; int bStart = (j + 1) * param.meridians + 1; for (int i = 0; i < param.meridians; ++i) { int a = aStart + i; int a1 = aStart + (i + 1) % param.meridians; int b = bStart + i; int b1 = bStart + (i + 1) % param.meridians; if (list.quads != null) { list.quads.AddQuad(a, a1, b1, b); } else { list.triangles.AddTriangle(a, a1, b1); list.triangles.AddTriangle(a, b1, b); } } } for (int i = 0; i < param.meridians; ++i) { int a = i + param.meridians * (param.parallels - 2) + 1; int b = (i + 1) % param.meridians + param.meridians * (param.parallels - 2) + 1; list.triangles.AddTriangle(list.points.Count - 1, a, b); } } /* private static void RemapIndices(List points, List indices, Dictionary> indexTable, Dictionary pointTable) { if (indices == null) return; for (int k = 0; k < indices.Count; k++) { int i = indices[k]; if (indexTable.ContainsKey(i)) { var point = indexTable[i].First(); i = pointTable[point]; indices[k] = i; } else { var point = points[i]; if (!pointTable.ContainsKey(point)) pointTable.Add(point, i); } } } private static void RemapIndices(List points, List indices, List newPoints) { if (indices == null) return; for (int k = 0; k < indices.Count; k++) { int i = indices[k]; var point = points[i]; indices[k] = newPoints.IndexOf(point); } } /// /// Welds duplicate vertices given some threshold. /// This is not optimized and will be slow for large point sets. /// /// private static void WeldVertices(IndexList list) { double sqthreshold = WELD_EPS * WELD_EPS; //Find the points that are to close and put them in a list together. //That set then goes in a dictionary with any one of the indices as the key. var indexTable = new Dictionary>(); for (int i = 0; i < list.points.Count; i++) { for (int j = 0; j < list.points.Count; j++) { if (i == j) continue; double sqdist = Point3d.SqrDistance(list.points[i], list.points[j]); if (sqdist <= sqthreshold) { if(indexTable.ContainsKey(i)) { indexTable[i].Add(list.points[i]); indexTable[i].Add(list.points[j]); } else if (indexTable.ContainsKey(j)) { indexTable[j].Add(list.points[i]); indexTable[j].Add(list.points[j]); } else { var set = new HashSet(); set.Add(list.points[i]); set.Add(list.points[j]); } } } } //Take the first point in the index table //and make a point table where the point is //the key and any of the points indices is the value. var pointTable = new Dictionary(); foreach (var kvp in indexTable) { int index = kvp.Key; var set = kvp.Value; pointTable.Add(set.First(), index); } //Remap the indies so the same index points to the same point. RemapIndices(list.points, list.triangles, indexTable, pointTable); RemapIndices(list.points, list.quads, indexTable, pointTable); //create a new point list containing only the points in used. var newPoints = new List(); foreach(var kvp in indexTable) newPoints.Add(kvp.Value.First()); //Remap the indices so point to the same point in the new point table //that has had all the duplicate points removed. RemapIndices(list.points, list.triangles, newPoints); RemapIndices(list.points, list.quads, newPoints); //copy back into point list. list.points.Clear(); list.points.AddRange(newPoints); } */ } } ================================================ FILE: CGALDotNet/Polyhedra/MeshHalfedge3.cs ================================================ using System; using System.Collections.Generic; using CGALDotNetGeometry.Numerics; namespace CGALDotNet.Polyhedra { public struct MeshHalfedge3 : IEquatable { /// /// Is the edge a border to a hole. /// public bool IsBorder; /// /// The edges index. /// public int Index; /// /// The edges source vertices index. /// public int Source; /// /// The edges target vertices index. /// public int Target; /// /// The edges opposite edge. /// public int Opposite; /// /// The edges next edge. /// public int Next; /// /// The edges previous edge. /// public int Previous; /// /// The edges face /// public int Face; /// /// A edge where everthing is set to null index. /// public static MeshHalfedge3 NullHalfedge { get { var edge = new MeshHalfedge3(); edge.Index = CGALGlobal.NULL_INDEX; edge.Source = CGALGlobal.NULL_INDEX; edge.Target = CGALGlobal.NULL_INDEX; edge.Opposite = CGALGlobal.NULL_INDEX; edge.Next = CGALGlobal.NULL_INDEX; edge.Previous = CGALGlobal.NULL_INDEX; edge.Face = CGALGlobal.NULL_INDEX; return edge; } } /// /// Get the source point. /// /// The mesh the point belongs to. /// The source point /// If point is null index. public Point3d SourcePoint(IMesh mesh) { if (Source == CGALGlobal.NULL_INDEX) throw new ArgumentException("Source is null"); return mesh.GetPoint(Source); } /// /// Get the target point. /// /// The mesh the point belongs to. /// The target point /// If point is null index. public Point3d TargetPoint(IMesh mesh) { if (Target == CGALGlobal.NULL_INDEX) throw new ArgumentException("Target is null"); return mesh.GetPoint(Target); } /// /// /// /// public override string ToString() { return string.Format("[MeshHalfedge3: Index={0}, Source={1}, Target={2}, Opposite={3}, Next={4}, Previous={5}, Face={6}, IsBorder={7}]", Index, Source, Target, Opposite, Next, Previous, Face, IsBorder); } /// /// Are these edges equal. /// /// /// /// public static bool operator ==(MeshHalfedge3 v1, MeshHalfedge3 v2) { return v1.Index == v2.Index && v1.IsBorder == v2.IsBorder && v1.Source == v2.Source && v1.Target == v2.Target && v1.Opposite == v2.Opposite && v1.Next == v2.Next && v1.Previous == v2.Previous && v1.Face == v2.Face; } /// /// Are these edges not equal. /// /// /// /// public static bool operator !=(MeshHalfedge3 v1, MeshHalfedge3 v2) { return v1.Index != v2.Index || v1.IsBorder != v2.IsBorder || v1.Source != v2.Source || v1.Target != v2.Target || v1.Opposite != v2.Opposite || v1.Next != v2.Next || v1.Previous != v2.Previous || v1.Face != v2.Face; } /// /// Are these objects equal. /// /// /// public override bool Equals(object obj) { if (!(obj is MeshHalfedge3)) return false; MeshHalfedge3 v = (MeshHalfedge3)obj; return this == v; } /// /// Are these edges equal. /// /// /// public bool Equals(MeshHalfedge3 v) { return this == v; } /// /// The edges hahe code /// /// public override int GetHashCode() { unchecked { int hash = (int)MathUtil.HASH_PRIME_1; hash = (hash * MathUtil.HASH_PRIME_2) ^ IsBorder.GetHashCode(); hash = (hash * MathUtil.HASH_PRIME_2) ^ Index.GetHashCode(); hash = (hash * MathUtil.HASH_PRIME_2) ^ Source.GetHashCode(); hash = (hash * MathUtil.HASH_PRIME_2) ^ Target.GetHashCode(); hash = (hash * MathUtil.HASH_PRIME_2) ^ Opposite.GetHashCode(); hash = (hash * MathUtil.HASH_PRIME_2) ^ Next.GetHashCode(); hash = (hash * MathUtil.HASH_PRIME_2) ^ Previous.GetHashCode(); hash = (hash * MathUtil.HASH_PRIME_2) ^ Face.GetHashCode(); return hash; } } /// /// Enmerate all edges in this edge loop. /// /// The mesh the edges belong too. /// The next edge public IEnumerable EnumerateHalfedges(IMesh mesh) { var start = this; var e = start; do { yield return e; if (e.Next != CGALGlobal.NULL_INDEX) mesh.GetHalfedge(e.Next, out e); else yield break; } while (e.Index != start.Index); } /// /// Enmerate all vertices in this edge loop. /// /// The mesh the edges belong too. /// The next vertex public IEnumerable EnumerateVertices(IMesh mesh) { var start = this; var e = start; do { if (e.Source != CGALGlobal.NULL_INDEX) { MeshVertex3 vert; mesh.GetVertex(e.Source, out vert); yield return vert; } if (e.Next != CGALGlobal.NULL_INDEX) mesh.GetHalfedge(e.Next, out e); else yield break; } while (e.Index != start.Index); } } } ================================================ FILE: CGALDotNet/Polyhedra/MeshHitResult.cs ================================================ using System; using System.Collections.Generic; using System.Text; using CGALDotNetGeometry.Numerics; namespace CGALDotNet.Polyhedra { public struct MeshHitResult { public bool Hit => Face != CGALGlobal.NULL_INDEX; public int Face; public Point3d Point; public Point3d Coord; public override string ToString() { return String.Format("[MeshHitResult: Hit={0}, Face={1}, Point={2}, Coord={3}]", Hit, Face, Point, Coord); } public static MeshHitResult NoHitResult { get { var result = new MeshHitResult(); result.Face = CGALGlobal.NULL_INDEX; return result; } } } } ================================================ FILE: CGALDotNet/Polyhedra/MeshVertex3.cs ================================================ using System; using System.Collections.Generic; using CGALDotNetGeometry.Numerics; namespace CGALDotNet.Polyhedra { public struct MeshVertex3 : IEquatable { /// /// The vertices point. /// public Point3d Point; /// /// The vertices degree is how mang edges connect to it. /// public int Degree; /// /// The vertices index. /// public int Index; /// /// The vertices edge /// public int Halfedge; /// /// A vertex where all components are null. /// public static MeshVertex3 NullVertex { get { var vertex = new MeshVertex3(); vertex.Index = -CGALGlobal.NULL_INDEX; vertex.Halfedge = -CGALGlobal.NULL_INDEX; return vertex; } } /// /// /// /// public override string ToString() { return string.Format("[MeshVertex3: Index={0}, Halfedge={1}, Point={2}, Degree={3}]", Index, Halfedge, Point, Degree); } /// /// Are these vertices equal. /// /// /// /// public static bool operator ==(MeshVertex3 v1, MeshVertex3 v2) { return v1.Index == v2.Index && v1.Halfedge == v2.Halfedge && v1.Degree == v2.Degree && v1.Point == v2.Point; } /// /// Are these vertices not equal. /// /// /// /// public static bool operator !=(MeshVertex3 v1, MeshVertex3 v2) { return v1.Index != v2.Index || v1.Halfedge != v2.Halfedge || v1.Degree != v2.Degree || v1.Point != v2.Point; } /// /// Are these objects equal. /// /// /// public override bool Equals(object obj) { if (!(obj is MeshVertex3)) return false; MeshVertex3 v = (MeshVertex3)obj; return this == v; } /// /// Are these vertices equal. /// /// /// public bool Equals(MeshVertex3 v) { return this == v; } /// /// The vertices hash code /// /// public override int GetHashCode() { unchecked { int hash = (int)MathUtil.HASH_PRIME_1; hash = (hash * MathUtil.HASH_PRIME_2) ^ Point.GetHashCode(); hash = (hash * MathUtil.HASH_PRIME_2) ^ Degree.GetHashCode(); hash = (hash * MathUtil.HASH_PRIME_2) ^ Index.GetHashCode(); hash = (hash * MathUtil.HASH_PRIME_2) ^ Halfedge.GetHashCode(); return hash; } } /// /// Enmerate all edges surrounding the vertex. /// /// The mesh the edges belong too. /// The next edge public IEnumerable EnumerateHalfedges(IMesh mesh) { MeshHalfedge3 start; mesh.GetHalfedge(Halfedge, out start); MeshHalfedge3 e = start; do { yield return e; MeshHalfedge3 opp, next; if (e.Next != CGALGlobal.NULL_INDEX) mesh.GetHalfedge(e.Next, out next); else yield break; if (next.Opposite != CGALGlobal.NULL_INDEX) mesh.GetHalfedge(next.Opposite, out opp); else yield break; e = opp; } while (e.Index != start.Index); } } } ================================================ FILE: CGALDotNet/Polyhedra/NefPolyhedron3.cs ================================================ using System; using System.Collections; using System.Collections.Generic; using System.Text; using CGALDotNetGeometry.Numerics; using CGALDotNetGeometry.Shapes; namespace CGALDotNet.Polyhedra { public enum NEF_BOUNDARY : int { EXCLUDED, INCLUDED } public enum NEF_CONTENT : int { EMPTY, COMPLETE } public enum NEF_INTERSECTION : int { CLOSED_HALFSPACE, OPEN_HALFSPACE, PLANE_ONLY } /// /// Generic nef polyhedron definition. /// A 3D Nef polyhedron is a subset of the 3-dimensional space that is the result of forming /// complements and intersections starting from a finite set H of 3-dimensional halfspaces. /// Nef polyhedra are closed under all binary set operations, i.e., intersection, union, /// difference, complement, and under the topological operations boundary, closure, and interior. /// /// The kernel type. public sealed class NefPolyhedron3 : NefPolyhedron3 where K : CGALKernel, new() { /// /// creates a Nef polyhedron and initializes it to the empty /// set if plane == EMPTY and to the whole space if space == COMPLETE. /// /// The nef's space public NefPolyhedron3(NEF_CONTENT space = NEF_CONTENT.EMPTY) : base(new K(), space) { } /// /// creates a Nef polyhedron containing the halfspace on the /// negative side of plane including plane if boundary==INCLUDED, /// excluding plane if boundary==EXCLUDED. /// /// The plane. /// The boundary. internal NefPolyhedron3(Plane3d plane, NEF_BOUNDARY boundary = NEF_BOUNDARY.INCLUDED) : base(new K(), plane, boundary) { } /// /// creates a Nef polyhedron, which represents the same point /// set as the polyhedral surface. /// /// The polyhedron public NefPolyhedron3(Polyhedron3 polyhedra) : base(new K(), polyhedra) { } /// /// Create from a pointer. /// /// The polyhedrons pointer. internal NefPolyhedron3(IntPtr ptr) : base(new K(), ptr) { } /// /// The nef polyhdron as a string. /// /// The nef polyhedron as a string. public override string ToString() { return string.Format("[NefPolyhedra3<{0}>: VertexCount={1}, HalfEdgeCount={2}, FaceCount={3}]", Kernel.Name, VertexCount, HalfEdgeCount, FaceCount); } /// /// Return the intersection of nef and nef1. /// /// /// public NefPolyhedron3 Intersection(NefPolyhedron3 nef) { var ptr = Kernel.Intersection(Ptr, nef.Ptr); return new NefPolyhedron3(ptr); } /// /// Return the union of nef and nef1. /// /// /// public NefPolyhedron3 Join(NefPolyhedron3 nef) { var ptr = Kernel.Join(Ptr, nef.Ptr); return new NefPolyhedron3(ptr); } /// /// Return the difference between nef and nef1. /// /// /// public NefPolyhedron3 Difference(NefPolyhedron3 nef) { var ptr = Kernel.Difference(Ptr, nef.Ptr); return new NefPolyhedron3(ptr); } /// /// Return the symmetric difference of nef and nef1. /// /// /// public NefPolyhedron3 SymmetricDifference(NefPolyhedron3 nef) { var ptr = Kernel.SymmetricDifference(Ptr, nef.Ptr); return new NefPolyhedron3(ptr); } /// /// Returns the complement of nef. /// /// public NefPolyhedron3 Complement() { var ptr = Kernel.Complement(Ptr); return new NefPolyhedron3(ptr); } /// /// Returns the interior of nef. /// /// public NefPolyhedron3 Interior() { var ptr = Kernel.Interior(Ptr); return new NefPolyhedron3(ptr); } /// /// Returns the boundary of nef. /// /// public NefPolyhedron3 Boundary() { var ptr = Kernel.Boundary(Ptr); return new NefPolyhedron3(ptr); } /// /// Returns the closure of nef. /// /// public NefPolyhedron3 Closure() { var ptr = Kernel.Closure(Ptr); return new NefPolyhedron3(ptr); } /// /// Returns the regularization, i.e. the closure of the interior, of nef. /// /// public NefPolyhedron3 Regularization() { var ptr = Kernel.Regularization(Ptr); return new NefPolyhedron3(ptr); } /// /// Returns the MinkowskiSum. /// /// public NefPolyhedron3 MinkowskiSum(NefPolyhedron3 nef) { var ptr = Kernel.MinkowskiSum(Ptr, nef.Ptr); return new NefPolyhedron3(ptr); } /// /// Converts nef into a Polyhedron. /// nef must be simple to convert. /// /// The result of the conversion. /// True if nef is simple and the conversion was successful. public bool ConvertToPolyhedron(out Polyhedron3 poly) { if (IsSimple) { var ptr = Kernel.ConvertToPolyhedron(Ptr); poly = new Polyhedron3(ptr); return true; } else { poly = null; return false; } } /// /// Converts nef into a surface mesh. /// nef must be simple to convert. /// /// The result of the conversion. /// True if nef is simple and the conversion was successful. public bool ConvertToSurfaceMesh(out SurfaceMesh3 mesh) { if (IsSimple) { var ptr = Kernel.ConvertToSurfaceMesh(Ptr); mesh = new SurfaceMesh3(ptr); return true; } else { mesh = null; return false; } } /// /// Get a list of the nef volumes. /// /// Get a list of the nef volumes. public void GetVolumes(List> volumes) { int count = VolumeCount; if (count == 0) return; var array = new IntPtr[count]; Kernel.GetVolumes(Ptr, array, count); for(int i = 0; i < array.Length; i++) volumes.Add(new Polyhedron3(array[i])); } } /// /// The abstract nef polyhedra definition. /// public abstract class NefPolyhedron3 : CGALObject { /// /// Default constructor. /// private NefPolyhedron3() { } /// /// creates a Nef polyhedron and initializes it to the empty /// set if plane == EMPTY and to the whole space if space == COMPLETE. /// /// The polyhedron kernel. /// The nef's space public NefPolyhedron3(CGALKernel kernel, NEF_CONTENT space) { Kernel = kernel.NefPolyhedronKernel3; Ptr = Kernel.CreateFromSpace(space); } /// /// creates a Nef polyhedron containing the halfspace on the /// negative side of plane including plane if boundary==INCLUDED, /// excluding plane if boundary==EXCLUDED. /// /// The polyhedron kernel. /// The plane. /// The boundary. public NefPolyhedron3(CGALKernel kernel, Plane3d plane, NEF_BOUNDARY boundary) { Kernel = kernel.NefPolyhedronKernel3; Ptr = Kernel.CreateFromPlane(plane, boundary); } /// /// creates a Nef polyhedron, which represents the same point /// set as the polyhedral surface. /// /// The polyhedron kernel. /// The polyhedron public NefPolyhedron3(CGALKernel kernel, Polyhedron3 polyhedra) { Kernel = kernel.NefPolyhedronKernel3; Ptr = Kernel.CreateFromPolyhedron(polyhedra.Ptr); } /// /// Construct with a new kernel. /// /// The polyhedron kernel. /// The polyhedrons pointer. internal NefPolyhedron3(CGALKernel kernel, IntPtr ptr) : base(ptr) { Kernel = kernel.NefPolyhedronKernel3; } /// /// The polyhedron kernel. /// Contains the functions to the unmanaged CGAL polhedron. /// protected private NefPolyhedronKernel3 Kernel { get; private set; } /// /// /// public int EdgeCount => Kernel.EdgeCount(Ptr); /// /// Return the number of halfedge pairs. /// public int FaceCount => Kernel.FacetCount(Ptr); /// /// Return the number of halfedges. /// public int HalfEdgeCount => Kernel.HalfEdgeCount(Ptr); /// /// Return the number of faces. /// public int HalfFaceCount => Kernel.HalfFacetCount(Ptr); /// /// Return the number of vertices. /// public int VertexCount => Kernel.VertexCount(Ptr); /// /// Return the number of volumes. /// public int VolumeCount => Kernel.VolumeCount(Ptr); /// /// Returns true, if nef is the empty point set. /// public bool IsEmpty => Kernel.IsEmpty(Ptr); /// /// Rreturns true, if nef is a 2-manifold. /// public bool IsSimple => Kernel.IsSimple(Ptr); /// /// Returns true, if nef is the complete 3D space. /// public bool IsSpace => Kernel.IsSpace(Ptr); /// /// Make nef the empty set if space == EMPTY and the complete /// 3D space if space == COMPLETE. /// public void Clear(NEF_CONTENT space = NEF_CONTENT.EMPTY) { Kernel.Clear(Ptr, space); } /// /// Checks the integrity of nef. /// /// public bool IsValid() { return Kernel.IsValid(Ptr); } /// /// Decompose the nef into convex volumes. /// public void ConvexDecomposition() { Kernel.ConvexDecomposition(Ptr); } /// /// Print the nef polyhedron into a string builder. /// /// public override void Print(StringBuilder builder) { builder.AppendLine(ToString()); builder.AppendLine("VertexCount = " + VertexCount); builder.AppendLine("EdgeCount = " + EdgeCount); builder.AppendLine("FaceCount = " + FaceCount); builder.AppendLine("HalfFaceCount = " + HalfFaceCount); builder.AppendLine("VolumeCount = " + VolumeCount); builder.AppendLine("IsValid = " + IsValid()); builder.AppendLine("IsEmpty = " + IsEmpty); builder.AppendLine("IsSimple = " + IsSimple); builder.AppendLine("IsSpace = " + IsSpace); } /// /// Release the unmanaged pointer. /// protected override void ReleasePtr() { Kernel.Release(Ptr); } } } ================================================ FILE: CGALDotNet/Polyhedra/NefPolyhedronKernel3.cs ================================================ using System; using System.Collections.Generic; using System.Text; using CGALDotNetGeometry.Numerics; using CGALDotNetGeometry.Shapes; namespace CGALDotNet.Polyhedra { internal abstract class NefPolyhedronKernel3 : CGALObjectKernel { internal abstract IntPtr CreateFromSpace(NEF_CONTENT space); internal abstract IntPtr CreateFromPlane(Plane3d plane, NEF_BOUNDARY boundary); internal abstract IntPtr CreateFromPolyhedron(IntPtr ptr); internal abstract void Release(IntPtr ptr); internal abstract void Clear(IntPtr ptr, NEF_CONTENT space); internal abstract bool IsEmpty(IntPtr ptr); internal abstract bool IsSimple(IntPtr ptr); internal abstract bool IsSpace(IntPtr ptr); internal abstract bool IsValid(IntPtr ptr); internal abstract int EdgeCount(IntPtr ptr); internal abstract int FacetCount(IntPtr ptr); internal abstract int HalfEdgeCount(IntPtr ptr); internal abstract int HalfFacetCount(IntPtr ptr); internal abstract int VertexCount(IntPtr ptr); internal abstract int VolumeCount(IntPtr ptr); internal abstract IntPtr Intersection(IntPtr ptr1, IntPtr ptr2); internal abstract IntPtr Join(IntPtr ptr1, IntPtr ptr2); internal abstract IntPtr Difference(IntPtr ptr1, IntPtr ptr2); internal abstract IntPtr SymmetricDifference(IntPtr ptr1, IntPtr ptr2); internal abstract IntPtr Complement(IntPtr ptr); internal abstract IntPtr Interior(IntPtr ptr); internal abstract IntPtr Boundary(IntPtr ptr); internal abstract IntPtr Closure(IntPtr ptr); internal abstract IntPtr Regularization(IntPtr ptr); internal abstract IntPtr MinkowskiSum(IntPtr ptr1, IntPtr ptr2); internal abstract IntPtr ConvertToPolyhedron(IntPtr ptr); internal abstract IntPtr ConvertToSurfaceMesh(IntPtr ptr); internal abstract void ConvexDecomposition(IntPtr ptr); internal abstract void GetVolumes(IntPtr ptr, IntPtr[] volumes, int count); } } ================================================ FILE: CGALDotNet/Polyhedra/NefPolyhedronKernel3_EEK.cs ================================================ using System; using System.Collections.Generic; using System.Runtime.InteropServices; using CGALDotNetGeometry.Numerics; using CGALDotNetGeometry.Shapes; namespace CGALDotNet.Polyhedra { internal class NefPolyhedronKernel3_EEK : NefPolyhedronKernel3 { internal override string Name => "EEK"; internal static readonly NefPolyhedronKernel3 Instance = new NefPolyhedronKernel3_EEK(); internal override IntPtr CreateFromSpace(NEF_CONTENT space) { return NefPolyhedron3_EEK_CreateFromSpace(space); } internal override IntPtr CreateFromPlane(Plane3d plane, NEF_BOUNDARY boundary) { return NefPolyhedron3_EEK_CreateFromPlane(plane, boundary); } internal override IntPtr CreateFromPolyhedron(IntPtr ptr) { return NefPolyhedron3_EEK_CreateFromPolyhedron(ptr); } internal override void Release(IntPtr ptr) { NefPolyhedron3_EEK_Release(ptr); } internal override void Clear(IntPtr ptr, NEF_CONTENT space) { NefPolyhedron3_EEK_Clear(ptr, space); } internal override bool IsEmpty(IntPtr ptr) { return NefPolyhedron3_EEK_IsEmpty(ptr); } internal override bool IsSimple(IntPtr ptr) { return NefPolyhedron3_EEK_IsSimple(ptr); } internal override bool IsSpace(IntPtr ptr) { return NefPolyhedron3_EEK_IsSpace(ptr); } internal override bool IsValid(IntPtr ptr) { return NefPolyhedron3_EEK_IsValid(ptr); } internal override int EdgeCount(IntPtr ptr) { return NefPolyhedron3_EEK_EdgeCount(ptr); } internal override int FacetCount(IntPtr ptr) { return NefPolyhedron3_EEK_FacetCount(ptr); } internal override int HalfEdgeCount(IntPtr ptr) { return NefPolyhedron3_EEK_HalfEdgeCount(ptr); } internal override int HalfFacetCount(IntPtr ptr) { return NefPolyhedron3_EEK_HalfFacetCount(ptr); } internal override int VertexCount(IntPtr ptr) { return NefPolyhedron3_EEK_VertexCount(ptr); } internal override int VolumeCount(IntPtr ptr) { return NefPolyhedron3_EEK_VolumeCount(ptr); } internal override IntPtr Intersection(IntPtr ptr1, IntPtr ptr2) { return NefPolyhedron3_EEK_Intersection(ptr1, ptr2); } internal override IntPtr Join(IntPtr ptr1, IntPtr ptr2) { return NefPolyhedron3_EEK_Join(ptr1, ptr2); } internal override IntPtr Difference(IntPtr ptr1, IntPtr ptr2) { return NefPolyhedron3_EEK_Difference(ptr1, ptr2); } internal override IntPtr SymmetricDifference(IntPtr ptr1, IntPtr ptr2) { return NefPolyhedron3_EEK_SymmetricDifference(ptr1, ptr2); } internal override IntPtr Complement(IntPtr ptr) { return NefPolyhedron3_EEK_Complement(ptr); } internal override IntPtr Interior(IntPtr ptr) { return NefPolyhedron3_EEK_Interior(ptr); } internal override IntPtr Boundary(IntPtr ptr) { return NefPolyhedron3_EEK_Boundary(ptr); } internal override IntPtr Closure(IntPtr ptr) { return NefPolyhedron3_EEK_Closure(ptr); } internal override IntPtr Regularization(IntPtr ptr) { return NefPolyhedron3_EEK_Regularization(ptr); } internal override IntPtr MinkowskiSum(IntPtr ptr1, IntPtr ptr2) { return NefPolyhedron3_EEK_MinkowskiSum(ptr1, ptr2); } internal override IntPtr ConvertToPolyhedron(IntPtr ptr) { return NefPolyhedron3_EEK_ConvertToPolyhedron(ptr); } internal override IntPtr ConvertToSurfaceMesh(IntPtr ptr) { return NefPolyhedron3_EEK_ConvertToSurfaceMesh(ptr); } internal override void ConvexDecomposition(IntPtr ptr) { NefPolyhedron3_EEK_ConvexDecomposition(ptr); } internal override void GetVolumes(IntPtr ptr, IntPtr[] volumes, int count) { NefPolyhedron3_EEK_GetVolumes(ptr, volumes, count); } [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr NefPolyhedron3_EEK_CreateFromSpace(NEF_CONTENT space); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr NefPolyhedron3_EEK_CreateFromPlane(Plane3d plane, NEF_BOUNDARY boundary); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr NefPolyhedron3_EEK_CreateFromPolyhedron(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void NefPolyhedron3_EEK_Release(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void NefPolyhedron3_EEK_Clear(IntPtr ptr, NEF_CONTENT space); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool NefPolyhedron3_EEK_IsEmpty(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool NefPolyhedron3_EEK_IsSimple(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool NefPolyhedron3_EEK_IsSpace(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool NefPolyhedron3_EEK_IsValid(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int NefPolyhedron3_EEK_EdgeCount(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int NefPolyhedron3_EEK_FacetCount(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int NefPolyhedron3_EEK_HalfEdgeCount(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int NefPolyhedron3_EEK_HalfFacetCount(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int NefPolyhedron3_EEK_VertexCount(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int NefPolyhedron3_EEK_VolumeCount(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr NefPolyhedron3_EEK_Intersection(IntPtr ptr1, IntPtr ptr2); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr NefPolyhedron3_EEK_Join(IntPtr ptr1, IntPtr ptr2); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr NefPolyhedron3_EEK_Difference(IntPtr ptr1, IntPtr ptr2); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr NefPolyhedron3_EEK_SymmetricDifference(IntPtr ptr1, IntPtr ptr2); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr NefPolyhedron3_EEK_Complement(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr NefPolyhedron3_EEK_Interior(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr NefPolyhedron3_EEK_Boundary(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr NefPolyhedron3_EEK_Closure(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr NefPolyhedron3_EEK_Regularization(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr NefPolyhedron3_EEK_MinkowskiSum(IntPtr ptr1, IntPtr ptr2); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr NefPolyhedron3_EEK_ConvertToPolyhedron(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr NefPolyhedron3_EEK_ConvertToSurfaceMesh(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void NefPolyhedron3_EEK_ConvexDecomposition(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void NefPolyhedron3_EEK_GetVolumes(IntPtr ptr, [Out] IntPtr[] volumes, int count); } } ================================================ FILE: CGALDotNet/Polyhedra/NefPolyhedronKernel3_EIK.cs ================================================ using System; using System.Collections.Generic; using System.Runtime.InteropServices; using CGALDotNetGeometry.Numerics; using CGALDotNetGeometry.Shapes; namespace CGALDotNet.Polyhedra { internal class NefPolyhedronKernel3_EIK : NefPolyhedronKernel3 { internal override string Name => "EIK"; internal static readonly NefPolyhedronKernel3 Instance = new NefPolyhedronKernel3_EIK(); internal override IntPtr CreateFromSpace(NEF_CONTENT space) { return NefPolyhedron3_EIK_CreateFromSpace(space); } internal override IntPtr CreateFromPlane(Plane3d plane, NEF_BOUNDARY boundary) { return NefPolyhedron3_EIK_CreateFromPlane(plane, boundary); } internal override IntPtr CreateFromPolyhedron(IntPtr ptr) { return NefPolyhedron3_EIK_CreateFromPolyhedron(ptr); } internal override void Release(IntPtr ptr) { NefPolyhedron3_EIK_Release(ptr); } internal override void Clear(IntPtr ptr, NEF_CONTENT space) { NefPolyhedron3_EIK_Clear(ptr, space); } internal override bool IsEmpty(IntPtr ptr) { return NefPolyhedron3_EIK_IsEmpty(ptr); } internal override bool IsSimple(IntPtr ptr) { return NefPolyhedron3_EIK_IsSimple(ptr); } internal override bool IsSpace(IntPtr ptr) { return NefPolyhedron3_EIK_IsSpace(ptr); } internal override bool IsValid(IntPtr ptr) { return NefPolyhedron3_EIK_IsValid(ptr); } internal override int EdgeCount(IntPtr ptr) { return NefPolyhedron3_EIK_EdgeCount(ptr); } internal override int FacetCount(IntPtr ptr) { return NefPolyhedron3_EIK_FacetCount(ptr); } internal override int HalfEdgeCount(IntPtr ptr) { return NefPolyhedron3_EIK_HalfEdgeCount(ptr); } internal override int HalfFacetCount(IntPtr ptr) { return NefPolyhedron3_EIK_HalfFacetCount(ptr); } internal override int VertexCount(IntPtr ptr) { return NefPolyhedron3_EIK_VertexCount(ptr); } internal override int VolumeCount(IntPtr ptr) { return NefPolyhedron3_EIK_VolumeCount(ptr); } internal override IntPtr Intersection(IntPtr ptr1, IntPtr ptr2) { return NefPolyhedron3_EIK_Intersection(ptr1, ptr2); } internal override IntPtr Join(IntPtr ptr1, IntPtr ptr2) { return NefPolyhedron3_EIK_Join(ptr1, ptr2); } internal override IntPtr Difference(IntPtr ptr1, IntPtr ptr2) { return NefPolyhedron3_EIK_Difference(ptr1, ptr2); } internal override IntPtr SymmetricDifference(IntPtr ptr1, IntPtr ptr2) { return NefPolyhedron3_EIK_SymmetricDifference(ptr1, ptr2); } internal override IntPtr Complement(IntPtr ptr) { return NefPolyhedron3_EIK_Complement(ptr); } internal override IntPtr Interior(IntPtr ptr) { return NefPolyhedron3_EIK_Interior(ptr); } internal override IntPtr Boundary(IntPtr ptr) { return NefPolyhedron3_EIK_Boundary(ptr); } internal override IntPtr Closure(IntPtr ptr) { return NefPolyhedron3_EIK_Closure(ptr); } internal override IntPtr Regularization(IntPtr ptr) { return NefPolyhedron3_EIK_Regularization(ptr); } internal override IntPtr MinkowskiSum(IntPtr ptr1, IntPtr ptr2) { return NefPolyhedron3_EIK_MinkowskiSum(ptr1, ptr2); } internal override IntPtr ConvertToPolyhedron(IntPtr ptr) { return NefPolyhedron3_EIK_ConvertToPolyhedron(ptr); } internal override IntPtr ConvertToSurfaceMesh(IntPtr ptr) { return NefPolyhedron3_EIK_ConvertToSurfaceMesh(ptr); } internal override void ConvexDecomposition(IntPtr ptr) { NefPolyhedron3_EIK_ConvexDecomposition(ptr); } internal override void GetVolumes(IntPtr ptr, IntPtr[] volumes, int count) { NefPolyhedron3_EIK_GetVolumes(ptr, volumes, count); } [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr NefPolyhedron3_EIK_CreateFromSpace(NEF_CONTENT space); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr NefPolyhedron3_EIK_CreateFromPlane(Plane3d plane, NEF_BOUNDARY boundary); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr NefPolyhedron3_EIK_CreateFromPolyhedron(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void NefPolyhedron3_EIK_Release(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void NefPolyhedron3_EIK_Clear(IntPtr ptr, NEF_CONTENT space); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool NefPolyhedron3_EIK_IsEmpty(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool NefPolyhedron3_EIK_IsSimple(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool NefPolyhedron3_EIK_IsSpace(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool NefPolyhedron3_EIK_IsValid(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int NefPolyhedron3_EIK_EdgeCount(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int NefPolyhedron3_EIK_FacetCount(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int NefPolyhedron3_EIK_HalfEdgeCount(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int NefPolyhedron3_EIK_HalfFacetCount(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int NefPolyhedron3_EIK_VertexCount(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int NefPolyhedron3_EIK_VolumeCount(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr NefPolyhedron3_EIK_Intersection(IntPtr ptr1, IntPtr ptr2); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr NefPolyhedron3_EIK_Join(IntPtr ptr1, IntPtr ptr2); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr NefPolyhedron3_EIK_Difference(IntPtr ptr1, IntPtr ptr2); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr NefPolyhedron3_EIK_SymmetricDifference(IntPtr ptr1, IntPtr ptr2); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr NefPolyhedron3_EIK_Complement(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr NefPolyhedron3_EIK_Interior(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr NefPolyhedron3_EIK_Boundary(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr NefPolyhedron3_EIK_Closure(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr NefPolyhedron3_EIK_Regularization(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr NefPolyhedron3_EIK_MinkowskiSum(IntPtr ptr1, IntPtr ptr2); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr NefPolyhedron3_EIK_ConvertToPolyhedron(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr NefPolyhedron3_EIK_ConvertToSurfaceMesh(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void NefPolyhedron3_EIK_ConvexDecomposition(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void NefPolyhedron3_EIK_GetVolumes(IntPtr ptr, [Out] IntPtr[] volumes, int count); } } ================================================ FILE: CGALDotNet/Polyhedra/PolygonalCount.cs ================================================ using System; using System.Collections.Generic; using System.Text; namespace CGALDotNet.Polyhedra { public struct PolygonalCount { public int degenerate; public int triangles; public int quads; public int pentagons; public int hexagons; public int greater; public override string ToString() { return string.Format("[PolygonalCount: Degenerate={0}, Triangles={1}, Quads={2}, Pentagons={3}, Hexagons={4}, Greater={5}]", degenerate, triangles, quads, pentagons, hexagons, greater); } public PolygonalIndices Indices() { return new PolygonalIndices(this); } } } ================================================ FILE: CGALDotNet/Polyhedra/PolygonalIndices.cs ================================================ using System; using System.Collections.Generic; using System.Text; namespace CGALDotNet.Polyhedra { public struct PolygonalIndices { public int[] triangles; public int[] quads; public int[] pentagons; public int[] hexagons; public PolygonalIndices(PolygonalCount count) { triangles = count.triangles > 0 ? new int[count.triangles * 3] : null; quads = count.quads > 0 ? new int[count.quads * 4] : null; pentagons = count.pentagons > 0 ? new int[count.pentagons * 5] : null; hexagons = count.hexagons > 0 ? new int[count.hexagons * 6] : null; } public override string ToString() { return string.Format("[PolygonalIndices: Triangles={0}, Quads={1}, Pentagons={2}, Hexagons={3}]", Len(triangles), Len(quads), Len(pentagons), Len(hexagons)); } public int triangleCount => Len(triangles); public int quadCount => Len(quads); public int pentagonCount => Len(pentagons); public int hexagonCount => Len(hexagons); private int Len(int[] array) { return array == null ? 0 : array.Length; } public void Print() { var builder = new StringBuilder(); Print(builder); Console.WriteLine(builder.ToString()); } public void Print(StringBuilder builder) { if (triangleCount != 0) { builder.AppendLine("Triangles " + triangleCount); for (int i = 0; i < triangleCount / 3; i++) { int i0 = triangles[i * 3 + 0]; int i1 = triangles[i * 3 + 1]; int i2 = triangles[i * 3 + 2]; builder.AppendLine(i0 + " " + i1 + " " + i2); } } if (quadCount != 0) { builder.AppendLine("Quads " + quadCount); for (int i = 0; i < quadCount / 4; i++) { int i0 = quads[i * 4 + 0]; int i1 = quads[i * 4 + 1]; int i2 = quads[i * 4 + 2]; int i3 = quads[i * 4 + 3]; builder.AppendLine(i0 + " " + i1 + " " + i2 + " " + i3); } } if (pentagonCount != 0) { builder.AppendLine("Pentagons " + pentagonCount); for (int i = 0; i < pentagonCount / 5; i++) { int i0 = pentagons[i * 5 + 0]; int i1 = pentagons[i * 5 + 1]; int i2 = pentagons[i * 5 + 2]; int i3 = pentagons[i * 5 + 3]; int i4 = pentagons[i * 5 + 4]; builder.AppendLine(i0 + " " + i1 + " " + i2 + " " + i3 + " " + i4); } } if (hexagonCount != 0) { builder.AppendLine("Hexagons " + hexagonCount); for (int i = 0; i < hexagonCount / 6; i++) { int i0 = hexagons[i * 6 + 0]; int i1 = hexagons[i * 6 + 1]; int i2 = hexagons[i * 6 + 2]; int i3 = hexagons[i * 6 + 3]; int i4 = hexagons[i * 6 + 4]; int i5 = hexagons[i * 6 + 5]; builder.AppendLine(i0 + " " + i1 + " " + i2 + " " + i3 + " " + i4 + " " + i5); } } } } } ================================================ FILE: CGALDotNet/Polyhedra/PolyhedraAlgorithm.cs ================================================ using System; using System.Collections.Generic; using System.Text; namespace CGALDotNet.Polyhedra { public abstract class PolyhedraAlgorithm : CGALObject { /// /// /// internal PolyhedraAlgorithm() { } /// /// /// /// internal PolyhedraAlgorithm(IntPtr ptr) : base(ptr) { } /// /// Should the input polygon be checked. /// Can disable for better performance if /// it is know all input if valid. /// public bool CheckInput = true; /// /// Check if the mesh is valid. /// /// The mesh to check. protected void CheckIsValidException(IMesh mesh) { if (mesh == null) throw new NullReferenceException("The mesh is null."); if (!CheckInput) return; if (!mesh.IsValid) throw new InvalidOperationException("The mesh is not valid."); } /// /// Check if the mesh is valid. /// /// The mesh to check. protected bool CheckIsValid(IMesh mesh) { if (mesh == null) throw new NullReferenceException("The mesh is null."); if (!CheckInput) return true; return mesh.IsValid; } /// /// Check if the mesh is a valid triangle mesh. /// /// The mesh to check. protected void CheckIsValidTriangleException(IMesh mesh) { if (mesh == null) throw new NullReferenceException("The mesh is null."); if (!CheckInput) return; if (!mesh.IsValid) throw new InvalidOperationException("The mesh is not valid."); if (!mesh.IsTriangle) throw new InvalidOperationException("The mesh must be a pure triangle mesh."); } /// /// Check if the mesh is a valid triangle mesh. /// /// The mesh to check. protected bool CheckIsValidTriangle(IMesh mesh) { if (mesh == null) throw new NullReferenceException("The mesh is null."); if (!CheckInput) return true; return mesh.IsValidTriangleMesh; } /// /// Check if the mesh is a valid closed mesh. /// /// The mesh to check. protected void CheckIsValidClosedException(IMesh mesh) { if (mesh == null) throw new NullReferenceException("The mesh is null."); if (!CheckInput) return; if (!mesh.IsValid) throw new InvalidOperationException("The mesh is not valid."); if (!mesh.IsClosed) throw new InvalidOperationException("The mesh must be a closed mesh."); } /// /// Check if the mesh is a valid closed mesh. /// /// The polygon to check. protected bool CheckIsValidClosed(IMesh mesh) { if (mesh == null) throw new NullReferenceException("The mesh is null."); if (!CheckInput) return true; return mesh.IsValidClosedMesh; } /// /// Check if the mesh is a valid triangle mesh. /// /// The mesh to check. protected void CheckIsValidClosedTriangleException(IMesh mesh) { if (mesh == null) throw new NullReferenceException("The mesh is null."); if (!CheckInput) return; if (!mesh.IsValid) throw new InvalidOperationException("The mesh is not valid."); if (!mesh.IsTriangle) throw new InvalidOperationException("The mesh must be a pure triangle mesh."); if (!mesh.IsClosed) throw new InvalidOperationException("The mesh must be a closed mesh."); } /// /// Check if the mesh is a valid triangle mesh. /// /// The mesh to check. protected bool CheckIsValidClosedTriangle(IMesh mesh) { if (mesh == null) throw new NullReferenceException("The mesh mesh is null."); if (!CheckInput) return true; return mesh.IsValidClosedTriangleMesh; } } } ================================================ FILE: CGALDotNet/Polyhedra/Polyhedron3.cs ================================================ using System; using System.Collections; using System.Collections.Generic; using System.Text; using CGALDotNetGeometry.Numerics; using CGALDotNetGeometry.Shapes; using CGALDotNet.Processing; using CGALDotNet.Polygons; using CGALDotNet.Extensions; namespace CGALDotNet.Polyhedra { /// /// A polyhedral surface consists of vertices, edges, /// facets and an incidence relation on them. /// Each edge is represented by two halfedges with opposite orientations. /// /// The kernel type. public sealed class Polyhedron3 : Polyhedron3 where K : CGALKernel, new() { /// /// Default constructor. /// public Polyhedron3() : base(new K()) { } /// /// Construct from points and triangle indices. /// public Polyhedron3(Point3d[] points, int[] triangles) : base(new K()) { CreateMesh(points, triangles); } /// /// Construct from points and polygon indices. /// public Polyhedron3(Point3d[] points, PolygonalIndices indices) : base(new K()) { CreatePolygonalMesh(points, points.Length, indices); } /// /// Create from a pointer. /// /// The meshs pointer. internal Polyhedron3(IntPtr ptr) : base(new K(), ptr) { } /// /// The polyhdron as a string. /// /// The mesh as a string. public override string ToString() { return string.Format("[Polyhedron3<{0}>: VertexCount={1}, HalfEdgeCount={2}, FaceCount={3}]", Kernel.Name, VertexCount, HalfedgeCount, FaceCount); } /// /// Create a deep copy of the mesh. /// /// A deep copy of the mesh. public Polyhedron3 Copy() { return new Polyhedron3(Kernel.Copy(Ptr)); } /// /// Subdive the mesh. /// /// The number of iterations to perfrom. /// The subdivision method. public override void Subdivide(int iterations, SUBDIVISION_METHOD method = SUBDIVISION_METHOD.SQRT3) { try { var sub = SubdivisionSurface.Instance; sub.Subdivide(method, this, iterations); IsUpdated = false; } catch (NotImplementedException) { } catch (NotSupportedException) { }; } /// /// Simplify the polyhedra. /// /// A number between 0-1 that represents the percentage of vertices to remove. public override void Simplify(double stop_ratio) { try { var sim = SurfaceSimplification.Instance; sim.Simplify(this, stop_ratio); IsUpdated = false; } catch (NotImplementedException) { } catch (NotSupportedException) { }; } /// /// Refines a triangle mesh /// /// a factor to control density of the output mesh, /// where larger values lead to denser refinements. Defalus to sqrt of 2. /// The number of new vertices. public override int Refine(double density_control_factor = MathUtil.SQRT2_64) { try { IsUpdated = false; var meshing = MeshProcessingMeshing.Instance; return meshing.Refine(this, density_control_factor); } catch (NotImplementedException) { } catch (NotSupportedException) { }; return 0; } /// /// Orient the faces in the mesh. /// /// The orientation method. public override void Orient(ORIENTATE oriente) { try { IsUpdated = false; var orient = MeshProcessingOrientation.Instance; orient.Orient(oriente, this); } catch (NotImplementedException) { } catch (NotSupportedException) { }; } /// /// Reverses the orientation of the vertices in each face. /// public override void ReverseFaceOrientation() { Orient(ORIENTATE.REVERSE_FACE_ORIENTATIONS); } /// /// Split the mesh into its unconnected components. /// /// Each unconnect component as a new mesh. public void Split(List> results) { try { var con = MeshProcessingConnections.Instance; con.SplitUnconnectedComponents(this, results); } catch (NotImplementedException) { } catch (NotSupportedException) { }; } /// /// Remove all unconnected compontents except the largest. /// Largest is defined by the face count. /// /// The numbero of largest components to keep. /// The number of components removed in the mesh. public override int KeepLargest(int num_components_to_keep = 1) { try { var con = MeshProcessingConnections.Instance; return con.KeepLargestComponents(this, num_components_to_keep); } catch (NotImplementedException) { } catch (NotSupportedException) { }; return 0; } /// /// Create a mesh consisting of one polygon face. /// /// The faces polygon. /// Should the y coord of the points be used for the z coord. /// Thrown if the polygon is not simple. public void CreatePolygonMesh(Polygon2 polygon, bool xz) { if (!polygon.IsSimple) throw new InvalidOperationException("Polygon must be simple to convert to mesh mesh."); var points = polygon.ToArray(); CreatePolygonMesh(points, points.Length, xz); } /// /// Create the dual mesh where each face becomes a vertex /// and each vertex becomes a face. /// Must be a valid closed mesh to create the dual. /// /// The duel mesh. /// Is thrown if the mesh is not a valid closed mesh. public Polyhedron3 Dual() { if (!IsValidClosedMesh) throw new InvalidOperationException("Mesh must be a valid closed mesh to create a dual mesh."); int faceCount = FaceCount; var points = new Point3d[faceCount]; GetCentroids(points, faceCount); var indices = GetDualPolygonalIndices(); var dual = new Polyhedron3(); dual.CreatePolygonalMesh(points, points.Length, indices); return dual; } /// /// Convert to a surface mesh. /// /// The surface mesh. public SurfaceMesh3 ToSurfaceMesh() { var points = new Point3d[VertexCount]; GetPoints(points, points.Length); var indices = GetPolygonalIndices(); var mesh = new SurfaceMesh3(); mesh.CreatePolygonalMesh(points, points.Length, indices); return mesh; } /// /// Find the min, max and average edge lengths in the mesh /// /// The min, max and average edge lengths in the mesh. public override MinMaxAvg FindMinMaxAvgEdgeLength() { try { var fea = MeshProcessingFeatures.Instance; return fea.EdgeLengthMinMaxAvg(this); } catch (NotImplementedException) { } catch (NotSupportedException) { }; return new MinMaxAvg(); } /// /// Find the min, max and average face areas in the mesh /// /// The min, max and average face areas in the mesh. public override MinMaxAvg FindMinMaxAvgFaceArea() { try { var fea = MeshProcessingFeatures.Instance; return fea.FaceAreaMinMaxAvg(this); } catch (NotImplementedException) { } catch (NotSupportedException) { }; return new MinMaxAvg(); } /// /// Locate the face the rays hits. /// /// The ray. /// The hit result. public override MeshHitResult LocateFace(Ray3d ray) { try { var locate = MeshProcessingLocate.Instance; return locate.LocateFace(this, ray); } catch (NotImplementedException) { } catch (NotSupportedException) { }; return MeshHitResult.NoHitResult; } /// /// Find the face closest to the point. /// /// The point. /// The hit result. public override MeshHitResult ClosestFace(Point3d point) { try { var locate = MeshProcessingLocate.Instance; return locate.ClosestFace(this, point); } catch (NotImplementedException) { } catch (NotSupportedException) { }; return MeshHitResult.NoHitResult; } } /// /// The abstract polyhedra definition. /// public abstract class Polyhedron3 : CGALObject, IMesh { /// /// Cached values found by running Update. /// private bool m_isValid; private bool m_isClosed; private bool m_isTriangle; private bool m_isQuad; /// /// Default constructor. /// private Polyhedron3() { } /// /// Construct with a new kernel. /// /// The mesh kernel. internal Polyhedron3(CGALKernel kernel) { Kernel = kernel.PolyhedronKernel3; Ptr = Kernel.Create(); } /// /// Construct with a new kernel. /// /// The mesh kernel. /// The meshs pointer. internal Polyhedron3(CGALKernel kernel, IntPtr ptr) : base(ptr) { Kernel = kernel.PolyhedronKernel3; } /// /// The mesh kernel. /// Contains the functions to the unmanaged CGAL polhedron. /// protected private PolyhedronKernel3 Kernel { get; private set; } /// /// Number of vertices. /// public int VertexCount => Kernel.VertexCount(Ptr); /// /// Number of faces. /// public int FaceCount => Kernel.FaceCount(Ptr); /// /// Number of half edges. /// public int HalfedgeCount => Kernel.HalfEdgeCount(Ptr); /// /// Number of border edges. /// Since each border edge of a polyhedral surface has exactly one /// border halfedge, this number is equal to size of border halfedges. /// public int BorderEdgeCount => Kernel.BorderEdgeCount(Ptr); /// /// Number of border halfedges. /// public int BorderHalfEdgeCount => Kernel.BorderHalfEdgeCount(Ptr); /// /// The current build stamp. /// public int BuildStamp => Kernel.GetBuildStamp(Ptr); /// /// Returns true if the polyhedral surface is combinatorially consistent. /// Must be a valid mesh to check many other properties. /// public bool IsValid { get { Update(); return m_isValid; } protected set { m_isValid = value; } } /// /// Returns true if there are no border edges. /// public bool IsClosed { get { Update(); return m_isClosed; } protected set { m_isClosed = value; } } /// /// Returns true if all faces are triangles. /// public bool IsTriangle { get { Update(); return m_isTriangle; } protected set { m_isTriangle = value; } } /// /// Returns true if all faces are quads. /// public bool IsQuad { get { Update(); return m_isQuad; } protected set { m_isQuad = value; } } /// /// Is the mesh a valid triangle mesh. /// public bool IsValidTriangleMesh => IsValid && IsTriangle; /// /// Is the mesh a valid closed mesh. /// public bool IsValidClosedMesh => IsValid && IsClosed; /// /// Is the mesh a valid closed triangle mesh. /// public bool IsValidClosedTriangleMesh => IsValid && IsClosed && IsTriangle; /// /// Has the update function been called. /// protected bool IsUpdated { get; set; } /// /// Mark th mesh as needing to be updated. /// public void SetIsUpdatedToFalse() { IsUpdated = false; } /// /// Clear the mesh. /// public void Clear() { Kernel.Clear(Ptr); IsUpdated = false; } /// /// Clear the index maps. /// The index maps are used to access the meshes elemnts by index. /// They are automaticaly created when a elements is accessed /// be a function requiring it. /// /// True to clear the vertex index map. /// True to clear the face index map. /// True to clear the edges index map. public void ClearIndexMaps(bool vertices, bool faces, bool edges) { Kernel.ClearIndexMaps(Ptr, vertices, faces, edges); } /// /// Clear the normal maps. /// /// True to clear the vertex normal map. /// True to clear the face normal map public void ClearNormalMaps(bool vertices, bool faces) { Kernel.ClearNormalMaps(Ptr, vertices, faces); } /// /// Builds the vertex and/or face index maps if needed. /// /// True to build the vertex index map. /// True to build the face index map. /// True to build the face index map. /// True to force the build even if already built. public void BuildIndices(bool vertices, bool faces, bool edges, bool force = false) { Kernel.BuildIndices(Ptr, vertices, faces, edges, force); } /// /// A tetrahedron is added to the polyhedral surface /// with its vertices initialized to p1, p2, p3, and p4. /// /// /// /// /// /// A edge in the tetrahdron. public int MakeTetrahedron(Point3d p1, Point3d p2, Point3d p3, Point3d p4) { IsUpdated = false; return Kernel.MakeTetrahedron(Ptr, p1, p2, p3, p4); } /// /// A triangle with border edges is added to the /// polyhedral surface with its vertices initialized to p1, p2, and p3. /// /// /// /// /// A edge in the triangle. public int MakeTriangle(Point3d p1, Point3d p2, Point3d p3) { IsUpdated = false; return Kernel.MakeTriangle(Ptr, p1, p2, p3); } /// /// Create a mesh from the points and indices. /// /// The meshes points. /// The meshes triangles as a index array. Maybe null. /// The meshes quads as a index array. Maybe null. public void CreateMesh(Point3d[] points, int[] triangles, int[] quads = null) { bool hasTriangles = triangles != null && triangles.Length > 0; bool hasQuads = quads != null && quads.Length > 0; if (hasTriangles && hasQuads) CreateTriangleQuadMesh(points, points.Length, triangles, triangles.Length, quads, quads.Length); else if (hasTriangles) CreateTriangleMesh(points, points.Length, triangles, triangles.Length); else if (hasQuads) CreateQuadMesh(points, points.Length, quads, quads.Length); } /// /// Create a triangle mesh from the points and indices. /// /// The meshes points. /// The point arrays length. /// The meshes trinagles as a index array. /// The indices array length. public void CreateTriangleMesh(Point3d[] points, int pointCount, int[] indices, int indexCount) { ErrorUtil.CheckArray(points, pointCount); ErrorUtil.CheckArray(indices, indexCount); Clear(); IsUpdated = false; Kernel.CreatePolygonalMesh(Ptr, points, pointCount, indices, indexCount, null, 0, null, 0, null, 0); } /// /// Create a quad mesh from the points and indices. /// /// The meshes points. /// The point arrays length. /// The meshes trinagles as a index array. /// The indices array length. public void CreateQuadMesh(Point3d[] points, int pointCount, int[] indices, int indexCount) { ErrorUtil.CheckArray(points, pointCount); ErrorUtil.CheckArray(indices, indexCount); Clear(); IsUpdated = false; Kernel.CreatePolygonalMesh(Ptr, points, pointCount, null, 0, indices, indexCount, null, 0, null, 0); } /// /// Create a mesh with quads and triangles. /// /// The meshes points. /// The point array length. /// The meshes triangles. /// The triangle array length. /// The meshes quads. /// The quads array length. public void CreateTriangleQuadMesh(Point3d[] points, int pointsCount, int[] triangles, int triangleCount, int[] quads, int quadsCount) { ErrorUtil.CheckArray(points, pointsCount); ErrorUtil.CheckArray(triangles, triangleCount); ErrorUtil.CheckArray(quads, quadsCount); Clear(); IsUpdated = false; Kernel.CreatePolygonalMesh(Ptr, points, pointsCount, triangles, triangleCount, quads, quadsCount, null, 0, null, 0); } /// /// Create a mesh with riangles, quads, pentagons and hexagons. /// /// The meshs points. /// The length of the point array. /// The faces indices. public void CreatePolygonalMesh(Point3d[] points, int pointsCount, PolygonalIndices indices) { ErrorUtil.CheckArray(points, pointsCount); ErrorUtil.CheckArray(indices.triangles, indices.triangleCount); ErrorUtil.CheckArray(indices.quads, indices.quadCount); ErrorUtil.CheckArray(indices.pentagons, indices.pentagonCount); ErrorUtil.CheckArray(indices.hexagons, indices.hexagonCount); Clear(); IsUpdated = false; Kernel.CreatePolygonalMesh(Ptr, points, pointsCount, indices.triangles, indices.triangleCount, indices.quads, indices.quadCount, indices.pentagons, indices.pentagonCount, indices.hexagons, indices.hexagonCount); } /// /// Create a mesh consisting of one polygon face. /// /// The faces points /// The point array length. /// Should the y coord of the points be used for the z coord. public void CreatePolygonMesh(Point2d[] points, int count, bool xz) { ErrorUtil.CheckArray(points, count); Clear(); IsUpdated = false; Kernel.CreatePolygonMesh(Ptr, points, count, xz); } /// /// Get the triangle and quad indices. /// /// The meshes triangles as a index array. Maybe null. /// The meshes quads as a index array. Maybe null. public void GetIndices(int[] triangles, int[] quads = null) { bool hasTriangles = triangles != null && triangles.Length > 0; bool hasQuads = quads != null && quads.Length > 0; if (hasTriangles && hasQuads) GetTriangleQuadIndices(triangles, triangles.Length, quads, quads.Length); else if (hasTriangles) GetTriangleIndices(triangles, triangles.Length); else if (hasQuads) GetQuadIndices(quads, quads.Length); } /// /// Get the meshes triangles. /// /// The meshes triangles. /// The triangle array length. public void GetTriangleIndices(int[] triangles, int trianglesCount) { ErrorUtil.CheckArray(triangles, trianglesCount); Kernel.GetPolygonalIndices(Ptr, triangles, trianglesCount, null, 0, null, 0, null, 0); } /// /// Get the meshes quads. /// /// The meshes quads. /// The quads array length. public void GetQuadIndices(int[] quads, int quadsCount) { ErrorUtil.CheckArray(quads, quadsCount); Kernel.GetPolygonalIndices(Ptr, null, 0, quads, quadsCount, null, 0, null, 0); } /// /// Get the meshes triangles and quads. /// /// The meshes triangles. /// The triangle array length. /// The meshes quads. /// The quads array length. public void GetTriangleQuadIndices(int[] triangles, int trianglesCount, int[] quads, int quadsCount) { ErrorUtil.CheckArray(triangles, trianglesCount); ErrorUtil.CheckArray(quads, quadsCount); Kernel.GetPolygonalIndices(Ptr, triangles, trianglesCount, quads, quadsCount, null, 0, null, 0); } /// /// Get the meshes triangles, quads, pentagons and hexagons. /// /// The indices. public PolygonalIndices GetPolygonalIndices() { var count = GetPolygonalCount(); var indices = count.Indices(); Kernel.GetPolygonalIndices(Ptr, indices.triangles, indices.triangleCount, indices.quads, indices.quadCount, indices.pentagons, indices.pentagonCount, indices.hexagons, indices.hexagonCount); return indices; } /// /// Get the dual meshes triangles, quads, pentagons and hexagons. /// A dual mesh is were faces become vertices and vertices become faces. /// /// The indices public PolygonalIndices GetDualPolygonalIndices() { var count = GetDualPolygonalCount(); var indices = count.Indices(); Kernel.GetDualPolygonalIndices(Ptr, indices.triangles, indices.triangleCount, indices.quads, indices.quadCount, indices.pentagons, indices.pentagonCount, indices.hexagons, indices.hexagonCount); return indices; } /// /// Array accessor for the polygon. /// Getting a point wraps around the polygon. /// /// The points index. /// The vertices point. public Point3d this[int i] { get => GetPoint(i); set => SetPoint(i, value); } /// /// Get the vertices point. /// /// The vertex index in the mesh. /// The vertices point. /// If index is out of range. public Point3d GetPoint(int index) { if (index < 0 || index >= VertexCount) throw new ArgumentOutOfRangeException("Index must be a number >= 0 and < count"); return Kernel.GetPoint(Ptr, index); } /// /// Get the point at the index /// and wrap around the polygon. /// /// The points index. /// The point at the index. public Point3d GetPointWrapped(int index) { index = MathUtil.Wrap(index, VertexCount); return Kernel.GetPoint(Ptr, index); } /// /// Get the point at the index /// and clamp to the polygons last point. /// /// The points index. /// The point at the index. public Point3d GetPointClamped(int index) { index = MathUtil.Clamp(index, 0, VertexCount - 1); return Kernel.GetPoint(Ptr, index); } /// /// Get the vertices point but wraps the index. /// /// The vertex index in the mesh. /// The vertices point. public Point3d GetPointClamp(int index) { index = MathUtil.Wrap(index, VertexCount); return Kernel.GetPoint(Ptr, index); } /// /// Get the points in the mesh. /// /// The array to copy points into. /// The point array length. public void GetPoints(Point3d[] points, int count) { ErrorUtil.CheckArray(points, count); Kernel.GetPoints(Ptr, points, count); } /// /// Set the point at the index. /// /// The points index /// The pointsam> /// If index is out of range. public void SetPoint(int index, Point3d point) { if (index < 0 || index >= VertexCount) throw new ArgumentOutOfRangeException("Index must be a number >= 0 and < count"); IsUpdated = false; Kernel.SetPoint(Ptr, index, point); } /// /// Set the points from a array. /// /// The point array. /// The point arrays length. public void SetPoints(Point3d[] points, int count) { ErrorUtil.CheckArray(points, count); IsUpdated = false; Kernel.SetPoints(Ptr, points, count); } /// /// Get a halfedges segment. /// /// The halfedges index. /// The segment. /// True if halfedge found. public bool GetSegment(int index, out Segment3d segment) { return Kernel.GetSegment(Ptr, index, out segment); } /// /// Get the segment. /// /// The segment index. /// The segment /// If segmentwith the index not found. public Segment3d GetSegment(int index) { if (GetSegment(index, out Segment3d seg)) return seg; else throw new ArgumentException("Cound not get segment " + index); } /// /// Get a segment for each halfedge in the mesh. /// /// The segment array. /// The segment array length. public void GetSegments(Segment3d[] segments, int count) { ErrorUtil.CheckArray(segments, count); Kernel.GetSegments(Ptr, segments, count); } /// /// Get the faces triangle. /// Presumes face is a triangle with no checks. /// /// The faces index. /// The faces triangle /// public bool GetTriangle(int index, out Triangle3d triangle) { return Kernel.GetTriangle(Ptr, index, out triangle); } /// /// Get the triangle. /// /// The triangle index. /// The triangle /// If triangle with the index not found. public Triangle3d GetTriangle(int index) { if (GetTriangle(index, out Triangle3d tri)) return tri; else throw new ArgumentException("Cound not get triangle " + index); } /// /// Get a triangle for each face in the mesh. /// Presumes all faces are triangles with no checks. /// /// The trainagle array. /// The traingle arrays length. public void GetTriangles(Triangle3d[] triangles, int count) { ErrorUtil.CheckArray(triangles, count); Kernel.GetTriangles(Ptr, triangles, count); } /// /// Get the mesh vertex. /// /// The vertices index. /// The vertex. /// True if the vertex was found. public bool GetVertex(int index, out MeshVertex3 vertex) { return Kernel.GetVertex(Ptr, index, out vertex); } /// /// Get the mesh vertex. /// /// The vertexs index. /// The vertexs /// If vertex with the index not found. public MeshVertex3 GetVertex(int index) { if (GetVertex(index, out MeshVertex3 vertex)) return vertex; else throw new ArgumentException("Cound not get vertex " + index); } /// /// Get the vertices in the mesh. /// /// The vertex array. /// The vertex array length. public void GetVertices(MeshVertex3[] vertices, int count) { ErrorUtil.CheckArray(vertices, count); Kernel.GetVertices(Ptr, vertices, count); } /// /// Get the mesh face. /// /// The faces index. /// The face. /// True if the face was found. public bool GetFace(int index, out MeshFace3 face) { return Kernel.GetFace(Ptr, index, out face); } /// /// Get the mesh face. /// /// The faces index. /// The faces /// If face with the index not found. public MeshFace3 GetFace(int index) { if(GetFace(index, out MeshFace3 face)) return face; else throw new ArgumentException("Cound not get face " + index); } /// /// Get the faces in the mesh. /// /// The face array. /// The face array length. public void GetFaces(MeshFace3[] faces, int count) { ErrorUtil.CheckArray(faces, count); Kernel.GetFaces(Ptr, faces, count); } /// /// Get the mesh halfedge. /// /// The halfedges index. /// The halfedge. /// True if the halfedge was found. public bool GetHalfedge(int index, out MeshHalfedge3 halfedge) { return Kernel.GetHalfedge(Ptr, index, out halfedge); } /// /// Get the mesh Halfedge. /// /// The Halfedges index. /// The Halfedges /// If Halfedge with the index not found. public MeshHalfedge3 GetHalfedge(int index) { if (GetHalfedge(index, out MeshHalfedge3 Halfedge)) return Halfedge; else throw new ArgumentException("Cound not get Halfedge " + index); } /// /// Get the halfedges in the mesh. /// /// The halfedge array. /// The halfedge array length. public void GetHalfedges(MeshHalfedge3[] halfedges, int count) { ErrorUtil.CheckArray(halfedges, count); Kernel.GetHalfedges(Ptr, halfedges, count); } /// /// Count the number of triangles, quads and polygons in the mesh. /// /// The number of triangles, quads and polygons in the mesh. public PolygonalCount GetPolygonalCount() { return Kernel.GetPolygonalCount(Ptr); } /// /// Count the number of triangles, quads and polygons in the dual mesh. /// A dual mesh is were faces become vertices and vertices become faces. /// /// The number of triangles, quads and polygons in the mesh. public PolygonalCount GetDualPolygonalCount() { return Kernel.GetDualPolygonalCount(Ptr); } /// /// Get a centroid (the avergae face position) for each face in the mesh. /// /// The point array. /// The points arrays lemgth. public void GetCentroids(Point3d[] points, int count) { ErrorUtil.CheckArray(points, count); Kernel.GetCentroids(Ptr, points, count); } /// /// Computes the vertex normals if needed. /// public void ComputeVertexNormals() { Kernel.ComputeVertexNormals(Ptr); } /// /// Computes the face normals if needed. /// public void ComputeFaceNormals() { Kernel.ComputeFaceNormals(Ptr); } /// /// Get the vertex normals. /// /// The normals array. /// The normals array length. public void GetVertexNormals(Vector3d[] normals, int count) { ErrorUtil.CheckArray(normals, count); Kernel.GetVertexNormals(Ptr, normals, count); } /// /// Get the face normals. /// /// The normals array. /// The normals array length. public void GetFaceNormals(Vector3d[] normals, int count) { ErrorUtil.CheckArray(normals, count); Kernel.GetFaceNormals(Ptr, normals, count); } /// /// Translate each point in the mesh. /// /// The amount to translate. public void Translate(Point3d translation) { var m = Matrix4x4d.Translate(translation); Kernel.Transform(Ptr, m); IsUpdated = false; } /// /// Rotate each point in the mesh. /// /// The amount to rotate. public void Rotate(Quaternion3d rotation) { var m = rotation.ToMatrix4x4d(); Kernel.Transform(Ptr, m); IsUpdated = false; } /// /// Scale each point in the mesh. /// /// The amount to scale. public void Scale(Point3d scale) { var m = Matrix4x4d.Scale(scale); Kernel.Transform(Ptr, m); IsUpdated = false; } /// /// Transform each point in the mesh. /// /// The amount to translate. /// The amount to rotate. /// The amount to scale. public void Transform(Point3d translation, Quaternion3d rotation, Point3d scale) { var m = Matrix4x4d.TranslateRotateScale(translation, rotation, scale); Kernel.Transform(Ptr, m); IsUpdated = false; } /// /// Make all faces triangles. /// public void Triangulate() { if (!IsValid || IsTriangle) return; Kernel.Triangulate(Ptr); IsUpdated = false; } /// /// sorts halfedges such that the non-border edges precede the border edges. /// For each border edge the halfedge iterator will reference the halfedge /// incident to the facet right before the halfedge incident to the hole. /// public void NormalizeBorder() { if (!IsValid) return; Kernel.NormalizeBorder(Ptr); IsUpdated = false; } /// /// returns true if the border halfedges are in normalized representation, /// which is when enumerating all halfedges with the iterator: /// The non-border edges precede the border edges and for border edges, /// the second halfedge is the border halfedge. /// /// public bool NormalizedBorderIsValid() { return Kernel.NormalizedBorderIsValid(Ptr); } /// /// Find what side of the mesh the lies in. /// /// The point to check. /// ON_BOUNDED_SIDE if point inside mesh, /// ON_UNBOUNDED_SIDE if point not inside, /// ON_BOUNDARY if point is on the surface. public BOUNDED_SIDE BoundedSide(Point3d point) { if (IsValid) return Kernel.SideOfTriangleMesh(Ptr, point); else return BOUNDED_SIDE.UNDETERMINED; } /// /// Does the mesh contain the point. /// /// The point. /// If point is on the boundary does it count a being contained. /// True if the poly contains the point public bool ContainsPoint(Point3d point, bool includeBoundary = true) { var side = BoundedSide(point); if (side == BOUNDED_SIDE.UNDETERMINED) return false; if (side == BOUNDED_SIDE.ON_BOUNDED_SIDE) return true; if (includeBoundary && side == BOUNDED_SIDE.ON_BOUNDARY) return true; return false; } /// /// Locate the face the rays hits. /// /// The ray. /// The hit result. public abstract MeshHitResult LocateFace(Ray3d ray); /// /// Find the face closest to the point. /// /// The point. /// The hit result. public abstract MeshHitResult ClosestFace(Point3d point); /// /// Locate the face hit by the ray. /// /// The ray. /// The hit face. /// True if the ray hit a face. public bool LocateFace(Ray3d ray, out MeshFace3 face) { if (ray.IsDegenerate) { face = MeshFace3.NullFace; return false; } var result = LocateFace(ray); if(result.Hit && GetFace(result.Face, out face)) { return true; } else { face = MeshFace3.NullFace; return false; } } /// /// Locate the vertex hit by the ray. /// /// The ray. /// The distance the vertex has to be within hit point. /// The hit vertex. /// True if the ray hit a vertex. public bool LocateVertex(Ray3d ray, double radius, out MeshVertex3 vertex) { if (ray.IsDegenerate) { vertex = MeshVertex3.NullVertex; return false; } var result = LocateFace(ray); if (result.Hit && GetFace(result.Face, out MeshFace3 face)) { double minSqDist = double.PositiveInfinity; var closest = MeshVertex3.NullVertex; foreach(var v in face.EnumerateVertices(this)) { var sqdist = Point3d.SqrDistance(result.Point, v.Point); if (sqdist < minSqDist) { minSqDist = sqdist; closest = v; } } if(closest.Index != CGALGlobal.NULL_INDEX && minSqDist < radius * radius) { vertex = closest; return true; } else { vertex = MeshVertex3.NullVertex; return false; } } else { vertex = MeshVertex3.NullVertex; return false; } } /// /// Locate the edge hit by the ray. /// /// The ray. /// The distance the edge has to be within hit point. /// The hit edge. /// True if the ray hit a edge. public bool LocateHalfedge(Ray3d ray, double radius, out MeshHalfedge3 edge) { if (ray.IsDegenerate) { edge = MeshHalfedge3.NullHalfedge; return false; } var result = LocateFace(ray); if (result.Hit && GetFace(result.Face, out MeshFace3 face)) { double minSqDist = double.PositiveInfinity; var closest = MeshHalfedge3.NullHalfedge; MeshVertex3 source, target; Segment3d seg; foreach (var e in face.EnumerateHalfedges(this)) { if (!GetVertex(e.Source, out source)) continue; if (!GetVertex(e.Target, out target)) continue; seg.A = source.Point; seg.B = target.Point; var p = seg.Closest(result.Point); var sqdist = Point3d.SqrDistance(result.Point, p); if (sqdist < minSqDist) { minSqDist = sqdist; closest = e; } } if (closest.Index != CGALGlobal.NULL_INDEX && minSqDist < radius * radius) { edge = closest; return true; } else { edge = MeshHalfedge3.NullHalfedge; return false; } } else { edge = MeshHalfedge3.NullHalfedge; return false; } } /// /// Tests if a set of faces of a triangulated surface mesh self-intersects. /// Must be a triangle mesh. /// /// True/Fasle if a valid triangle polyhedra,or UNDETERMINED if not. public BOOL_OR_UNDETERMINED DoesSelfIntersect() { if (IsValidTriangleMesh) return Kernel.DoesSelfIntersect(Ptr).ToBoolOrUndetermined(); else return BOOL_OR_UNDETERMINED.UNDETERMINED; } /// /// returns true if the polyhedral surface is combinatorially consistent. /// For level == 1 the normalization of the border edges is checked too. /// This method checks that each face is at least a triangle and that the /// two incident facets of a non-border edge are distinct. /// /// public bool FindIfValid(int level = 0) { return Kernel.IsValid(Ptr, level); } /// /// Computes the bounding box. /// /// The bounding box. public Box3d FindBoundingBox() { return Kernel.GetBoundingBox(Ptr); } /// /// Computes the area of a range of faces /// of a given triangulated surface mesh. /// /// The area or 0 if poyhedron is not valid triangle mesh. public double FindArea() { if (IsValidTriangleMesh) return Kernel.Area(Ptr); else return 0; } /// /// computes the centroid of a volume bounded /// by a closed triangulated surface mesh. /// /// The centroid or 0 if poyhedron is not valid. public Point3d FindCentroid() { if (IsValid) return Kernel.Centroid(Ptr); else return Point3d.Zero; } /// /// Computes the volume of the domain bounded by a /// closed triangulated surface mesh. /// /// The volume or 0 if poyhedron is not valid closed triangle mesh. public double FindVolume() { if (IsValidClosedTriangleMesh) return Kernel.Volume(Ptr); else return 0; } /// /// Returns true if there are no border edges. /// /// True/Fasle if valid, or UNDETERMINED if not a valid polyhedra. public BOOL_OR_UNDETERMINED FindIfClosed() { if (IsValid) return Kernel.IsClosed(Ptr).ToBoolOrUndetermined(); else return BOOL_OR_UNDETERMINED.UNDETERMINED; } /// /// Returns true if all vertices have exactly two incident edges. /// /// True/Fasle if valid, or UNDETERMINED if not a valid polyhedra. public BOOL_OR_UNDETERMINED FindIfBivalent() { if (IsValid) return Kernel.IsPureBivalent(Ptr).ToBoolOrUndetermined(); else return BOOL_OR_UNDETERMINED.UNDETERMINED; } /// /// Returns true if all vertices have exactly three incident edges. /// /// True/Fasle if valid, or UNDETERMINED if not a valid polyhedra. public BOOL_OR_UNDETERMINED FindIfTrivalent() { if (IsValid) return Kernel.IsPureTrivalent(Ptr).ToBoolOrUndetermined(); else return BOOL_OR_UNDETERMINED.UNDETERMINED; } /// /// Returns true if all faces are triangles. /// /// True/Fasle if valid, or UNDETERMINED if not a valid polyhedra. public BOOL_OR_UNDETERMINED FindIfTriangleMesh() { if (IsValid) return Kernel.IsPureTriangle(Ptr).ToBoolOrUndetermined(); else return BOOL_OR_UNDETERMINED.UNDETERMINED; } /// /// Returns true if all faces are quads. /// /// True/Fasle if valid, or UNDETERMINED if not a valid polyhedra. public BOOL_OR_UNDETERMINED FindIfQuadMesh() { if (IsValid) return Kernel.IsPureQuad(Ptr).ToBoolOrUndetermined(); else return BOOL_OR_UNDETERMINED.UNDETERMINED; } /// /// Indicates if the mesh bounds a volume. /// Must be a closed and triangulated. /// /// True/Fasle if a valid triangle closed polyhedra,or UNDETERMINED if not. public BOOL_OR_UNDETERMINED FindIfDoesBoundAVolume() { if (IsValidClosedTriangleMesh) return Kernel.DoesBoundAVolume(Ptr).ToBoolOrUndetermined(); else return BOOL_OR_UNDETERMINED.UNDETERMINED; } /// /// Builds the aabb tree used for location. /// Tree will be automatically built if need so not /// actually necessary to call this function. /// public void BuildAABBTree() { Kernel.BuildAABBTree(Ptr); } /// /// Will delete the aabb tree. /// public void ReleaseAABBTree() { Kernel.ReleaseAABBTree(Ptr); } /// /// Returns true if there exists a face of this poly and /// a face of other poly which intersect, and false otherwise. /// Must be a triangle mesh /// /// The other triangle poly. /// If test_bounded_sides is set to true, /// the overlap of bounded sides are tested as well. In that case, the meshes must be closed. /// True/Fasle if a valid triangle closed polyhedra,or UNDETERMINED if not. public BOOL_OR_UNDETERMINED DoIntersect(Polyhedron3 poly, bool test_bounded_sides = true) { if (IsValidTriangleMesh && poly.IsValidTriangleMesh) { //if test bounded side both must be closed meshes. //If not test bounded side does not matter if not closed. if ((test_bounded_sides && IsClosed && poly.IsClosed) || !test_bounded_sides) { return Kernel.DoIntersects(Ptr, poly.Ptr, test_bounded_sides).ToBoolOrUndetermined(); } else return BOOL_OR_UNDETERMINED.UNDETERMINED; } else return BOOL_OR_UNDETERMINED.UNDETERMINED; } /// /// Subdive the mesh. /// /// The number of iterations to perfrom. /// The subdivision method. public abstract void Subdivide(int iterations, SUBDIVISION_METHOD method = SUBDIVISION_METHOD.SQRT3); /// /// Simplify the polyhedra. /// /// A number between 0-1 that represents the percentage of vertices to remove. public abstract void Simplify(double stop_ratio); /// /// Refines a triangle mesh /// /// a factor to control density of the output mesh, /// where larger values lead to denser refinements. Defalus to sqrt of 2. /// The number of new vertices. public abstract int Refine(double density_control_factor = MathUtil.SQRT2_64); /// /// Orient the faces in the mesh. /// /// The orientation method. public abstract void Orient(ORIENTATE orientate); /// /// Reverses the orientation of the vertices in each face. /// public abstract void ReverseFaceOrientation(); /// /// Remove all unconnected compontents except the largest. /// Largest is defined by the face count. /// /// The numbero of largest components to keep. /// The number of components removed in the mesh. public abstract int KeepLargest(int num_components_to_keep = 1); /// /// Find the min, max and average edge lengths in the mesh /// /// The min, max and average edge lengths in the mesh. public abstract MinMaxAvg FindMinMaxAvgEdgeLength(); /// /// Find the min, max and average face areas in the mesh /// /// The min, max and average face areas in the mesh. public abstract MinMaxAvg FindMinMaxAvgFaceArea(); /// /// Enumerate all points in the mesh. /// /// Each point in mesh. public IEnumerator GetEnumerator() { for (int i = 0; i < VertexCount; i++) yield return GetPoint(i); } /// /// Enumerate all points in the mesh. /// /// Each point in mesh. IEnumerator IEnumerable.GetEnumerator() { return GetEnumerator(); } /// /// Read data from a off file into the pollyhedron. /// /// The files name. public void ReadOFF(string filename) { IsUpdated = false; Kernel.ReadOFF(Ptr, filename); } /// /// Write data from a off file into the pollyhedron. /// /// The files name. public void WriteOFF(string filename) { Kernel.WriteOFF(Ptr, filename); } /// /// Return all the points in the mesh in a array. /// /// The array. public Point3d[] ToArray() { var points = new Point3d[VertexCount]; GetPoints(points, points.Length); return points; } /// /// Return all the points in the mesh in a list. /// /// The list. public List ToList() { int count = VertexCount; var points = new List(count); for (int i = 0; i < count; i++) points.Add(GetPoint(i)); return points; } /// /// https://doc.cgal.org/latest/Polyhedron/classCGAL_1_1Polyhedron__3.html#a73119c0c90bf8612da003305af25a52a /// creates a new facet within the hole incident to h and g by connecting the /// vertex denoted by g with the vertex denoted by h with a new halfedge and /// filling this separated part of the hole with a new facet, such that the /// new facet is incident to g. /// /// Precondition /// h->is_border(), g->is_border(), h != g, h->next() != g, /// and g can be reached along the same hole starting with h. /// /// a halfedge index /// a halfedge index /// Returns the halfedge of the new edge that is incident to the new facet. public int AddFacetToBorder(int h, int g) { IsUpdated = false; return Kernel.AddFacetToBorder(Ptr, h, g); } /// /// creates a new facet within the hole incident to h and g by connecting the /// tip of g with the tip of h with two new halfedges and a new vertex and /// filling this separated part of the hole with a new facet, such that the /// new facet is incident to g. /// /// Precondition /// h->is_border(), g->is_border(), h != g, and g can be reached along the same hole starting with h. /// /// a halfedge index /// a halfedge index /// Returns the halfedge of the new edge that is incident to the new facet and the new vertex. public int AddVertexAndFacetToBorder(int h, int g) { IsUpdated = false; return Kernel.AddVertexAndFacetToBorder(Ptr, h, g); } /// /// barycentric triangulation of h->facet(). /// Creates a new vertex, a copy of h->vertex(), and connects it to each vertex incident /// to h->facet() splitting h->facet() into triangles.h remains incident to the original /// facet, all other triangles are copies of this facet. /// Precondition /// h is not a border halfedge. /// /// a halfedge index /// Returns the halfedge h->next() /// after the operation, i.e., a halfedge pointing to the new vertex.The time is /// proportional to the size of the facet. public int CreateCenterVertex(int h) { IsUpdated = false; return Kernel.CreateCenterVertex(Ptr, h); } /// /// reverses create_center_vertex(). /// Erases the vertex pointed to by g and all incident halfedges thereby merging all /// incident facets.Only g->facet() remains. The neighborhood of g->vertex() may not /// be triangulated, it can have larger facets. /// Precondition /// None of the incident facets of g->vertex() is a hole. There are at least two distinct facets incident to the facets that are incident to g->vertex(). (This prevents the operation from collapsing a volume into two facets glued together with opposite orientations, such as would happen with any vertex of a tetrahedron.) /// Supports_removal must be CGAL::Tag_true. /// /// a halfedge index /// Returns the halfedge g->prev(). /// Thus, the invariant h == erase_center_vertex(create_center_vertex(h)) /// holds if h is not a border halfedge.The time is proportional to the sum of the size of all incident facets. public int EraseCenterVertex(int h) { IsUpdated = false; return Kernel.EraseCenterVertex(Ptr, h); } /// /// removes the incident facet of h and changes all halfedges incident to the facet /// into border edges or removes them from the polyhedral surface if they were already border edges. /// If this creates isolated vertices they get removed as well.See make_hole(h) for a more specialized variant. /// Precondition /// h->is_border() == false. /// Supports_removal must be CGAL::Tag_true /// /// a halfedge index /// public bool EraseConnectedComponent(int h) { IsUpdated = false; return Kernel.EraseConnectedComponent(Ptr, h); } /// /// Erase a facet. /// /// a halfedge index /// returns a range of handles over the facets. public bool EraseFacet(int h) { IsUpdated = false; return Kernel.EraseFacet(Ptr, h); } /// /// fills a hole with a newly created facet. /// Makes all border halfedges of the hole denoted /// by h incident to the new facet.Returns h. /// Precondition /// h.is_border(). /// /// a halfedge index /// public int FillHole(int h) { IsUpdated = false; return Kernel.FillHole(Ptr, h); } /// /// performs an edge flip. /// /// Precondition /// h != Halfedge_handle() and both facets incident to h are triangles. /// /// a halfedge index /// It returns h after rotating the edge h one vertex in the direction of the face orientation. public int FlipEdge(int h) { IsUpdated = false; return Kernel.FlipEdge(Ptr, h); } /// /// joins the two facets incident to h. /// The facet incident to h->opposite() gets removed.Both facets might be holes. /// /// Precondition /// The degree of both vertices incident to h is at least three(no antennas). /// Supports_removal must be CGAL::Tag_true. /// /// a halfedge index /// Returns the predecessor of h around the facet. The invariant join_facet(split_facet(h, g)) /// returns h and keeps the polyhedron unchanged.The time is proportional to the size of /// the facet removed and the time to compute h->prev(). public int JoinFacet(int h) { IsUpdated = false; return Kernel.JoinFacet(Ptr, h); } /// /// glues the boundary of the two facets denoted by h and g together and returns h. /// Both facets and the vertices along the facet denoted by g gets removed.Both facets may be holes. /// The invariant join_loop(h, split_loop(h, i, j)) /// Precondition /// The facets denoted by h and g are different and have equal degree(i.e., number of edges). /// Supports_removal must be CGAL::Tag_true. /// /// a halfedge index /// a halfedge index /// returns h and keeps the polyhedron unchanged. public int JoinLoop(int h, int g) { IsUpdated = false; return Kernel.JoinLoop(Ptr, h, g); } /// /// joins the two vertices incident to h. /// The vertex denoted by h->opposite() gets removed. /// Precondition /// The size of both facets incident to h is at least four(no multi-edges). /// Supports_removal must be CGAL::Tag_true. /// /// a halfedge index /// Returns the predecessor of h around the vertex, i.e., /// h->opposite()->prev(). The invariant join_vertex(split_vertex(h, g)) /// returns h and keeps the polyhedron unchanged.The time is proportional /// to the degree of the vertex removed and the time to compute h->prev() and h->opposite()->prev(). public int JoinVertex(int h) { IsUpdated = false; return Kernel.JoinVertex(Ptr, h); } /// /// removes the incident facet of h and changes all halfedges incident to the facet into border edges. /// /// Precondition /// None of the incident halfedges of the facet is a border edge. /// Supports_removal must be CGAL::Tag_true. /// /// a halfedge index /// Returns h.See erase_facet(h) for a more generalized variant. public int MakeHole(int h) { IsUpdated = false; return Kernel.MakeHole(Ptr, h); } /// /// splits the halfedge h into two halfedges inserting a new vertex that is a copy of h->opposite()->vertex(). /// Is equivalent to split_vertex(h->prev(), h->opposite())->opposite(). The call of prev() can make this method /// slower than a direct call of split_vertex() if the previous halfedge is already known and computing /// it would be costly when the halfedge data structure does not support the prev() member function. /// /// /// a halfedge index /// Returns the new halfedge now pointing to the inserted vertex.The new halfedge is followed /// by the old halfedge, i.e., hnew->next() == h. public int SplitEdge(int h) { IsUpdated = false; return Kernel.SplitEdge(Ptr, h); } /// /// splits the facet incident to h and g into two facets with a new diagonal between /// the two vertices denoted by h and g respectively. /// The second(new) facet is a copy of the first facet. /// Precondition /// h and g are incident to the same facet.h != g (no loops). h->next() != g and g->next() != h (no multi-edges). /// /// a halfedge index /// a halfedge index /// Returns h->next() after the /// operation, i.e., the new diagonal.The new face is to the right of the new diagonal, /// the old face is to the left.The time is proportional to the distance from h to g around the facet. /// public int SplitFacet(int h, int g) { IsUpdated = false; return Kernel.SplitFacet(Ptr, h, g); } /// /// cuts the polyhedron into two parts along the cycle (h,i,j) (edge j runs on the backside of the three dimensional figure above). /// Three new vertices(one copy for each vertex in the cycle) and three new halfedges(one copy for each halfedge in the cycle), /// and two new triangles are created.h,i,j will be incident to the first new triangle. /// Precondition /// h, i, j denote distinct, consecutive vertices of the polyhedron and form a cycle: i.e., h->vertex() == i->opposite()->vertex(), /// … , j->vertex() == h->opposite()->vertex(). The six facets incident to(h, i, j) are all distinct. /// /// a halfedge index /// a halfedge index /// a halfedge index /// The return value will be the halfedge /// incident to the second new triangle which is the copy of h-opposite(). public int SplitLoop(int h, int g, int k) { IsUpdated = false; return Kernel.SplitLoop(Ptr, h, g, k); } /// /// splits the vertex incident to h and g into two vertices, the old vertex remains and a /// new copy is created, and connects them with a new edge. /// Let hnew be h->next()->opposite() after the split, i.e., a halfedge of the new edge. /// The split regroups the halfedges around the two vertices.The halfedge sequence hnew, /// g->next()->opposite(), … , h remains around the old vertex, while the halfedge /// sequence hnew->opposite(), h->next()->opposite() (before the split), … , g is /// regrouped around the new vertex. /// Precondition /// h and g are incident to the same vertex. h != g (antennas are not allowed). /// /// a halfedge index /// a halfedge index /// The split returns hnew, i.e., the new halfedge /// incident to the old vertex.The time is proportional to the distance from h to /// g around the vertex. public int SplitVertex(int h, int g) { IsUpdated = false; return Kernel.SplitVertex(Ptr, h, g); } /// /// Update the mesh if needed. /// protected void Update() { if (IsUpdated) return; IsUpdated = true; if (FindIfValid()) { m_isValid = true; m_isClosed = FindIfClosed().ToBool(); m_isTriangle = FindIfTriangleMesh().ToBool(); m_isQuad = FindIfQuadMesh().ToBool(); } else { m_isValid = false; m_isClosed = false; m_isTriangle = false; m_isQuad = false; } } /// /// Print the mesh into a string builder. /// /// public override void Print(StringBuilder builder) { Update(); builder.AppendLine(ToString()); builder.AppendLine("BuildStamp = " + BuildStamp); builder.AppendLine("VertexCount = " + VertexCount); builder.AppendLine("FaceCount= " + FaceCount); builder.AppendLine("HalfEdgeCount = " + HalfedgeCount); builder.AppendLine("BorderEdgeCount = " + BorderEdgeCount); builder.AppendLine("BorderHalfEdgeCount = " + BorderHalfEdgeCount); builder.AppendLine("IsValid = " + IsValid); builder.AppendLine("NormalizedBorderIsValid = " + NormalizedBorderIsValid()); builder.AppendLine("IsClosed = " + IsClosed); builder.AppendLine("IsTriangle = " + IsTriangle); builder.AppendLine("IsQuad = " + IsQuad); builder.AppendLine("IsBivalent = " + FindIfBivalent()); builder.AppendLine("IsTrivalent = " + FindIfTrivalent()); builder.AppendLine("DoesBoundAVolume = " + FindIfDoesBoundAVolume()); } /// /// /// /// public void PrintVertices(StringBuilder builder) { builder.AppendLine("Vertices"); var verts = new MeshVertex3[VertexCount]; GetVertices(verts, verts.Length); foreach (var v in verts) builder.AppendLine(v.ToString()); } /// /// /// /// public void PrintFaces(StringBuilder builder) { builder.AppendLine("Faces"); var faces = new MeshFace3[FaceCount]; GetFaces(faces, faces.Length); foreach (var f in faces) builder.AppendLine(f.ToString()); } /// /// /// /// public void PrintHalfedges(StringBuilder builder) { builder.AppendLine("Edges"); var edges = new MeshHalfedge3[HalfedgeCount]; GetHalfedges(edges, edges.Length); foreach (var e in edges) builder.AppendLine(e.ToString()); } /// /// Release the unmanaged pointer. /// protected override void ReleasePtr() { Kernel.Release(Ptr); } } } ================================================ FILE: CGALDotNet/Polyhedra/PolyhedronFactory.cs ================================================ using System; using System.Collections.Generic; using System.Text; using CGALDotNetGeometry.Numerics; using CGALDotNetGeometry.Shapes; using CGALDotNet.Processing; namespace CGALDotNet.Polyhedra { public static class PolyhedronFactory where K : CGALKernel, new() { private static IndexList triangleList = IndexList.CreateTriangleIndexList(); private static IndexList polygonList = IndexList.CreatePolygonIndexList(); public static Dictionary> CreateAll(bool allowPolygons = false) { var meshes = new Dictionary>(); meshes.Add("Cube", CreateCube(1, allowPolygons)); meshes.Add("Plane", CreatePlane(allowPolygons)); meshes.Add("Torus", CreateTorus(allowPolygons)); meshes.Add("Cone", CreateCone(allowPolygons)); meshes.Add("Cylinder", CreateCylinder(allowPolygons)); meshes.Add("Capsule", CreateCapsule(allowPolygons)); meshes.Add("UVSphere", CreateUVSphere(allowPolygons)); meshes.Add("NormalizedCube", CreateNormalizedCube(allowPolygons)); meshes.Add("Icosahedron", CreateIcosahedron()); meshes.Add("Tetrahedron", CreateTetrahedron()); meshes.Add("Octahedron", CreateOctahedron()); meshes.Add("Dodecahedron", CreateDodecahedron(1, allowPolygons)); return meshes; } public static Polyhedron3 CreateCube( double scale = 1, bool allowPolygons = false) { var mesh = new Polyhedron3(); if (allowPolygons) { polygonList.Clear(); MeshFactory.CreateCube(polygonList, scale); var indices = polygonList.ToIndices(); var points = polygonList.points.ToArray(); mesh.CreatePolygonalMesh(points, points.Length, indices); } else { triangleList.Clear(); MeshFactory.CreateCube(triangleList, scale); mesh.CreateMesh(triangleList.points.ToArray(), triangleList.triangles.ToArray()); } return mesh; } public static Polyhedron3 CreateCube(Box3d box, bool allowPolygons = false) { var mesh = new Polyhedron3(); if (allowPolygons) { polygonList.Clear(); MeshFactory.CreateCube(polygonList, box); var indices = polygonList.ToIndices(); var points = polygonList.points.ToArray(); mesh.CreatePolygonalMesh(points, points.Length, indices); } else { triangleList.Clear(); MeshFactory.CreateCube(triangleList, box); mesh.CreateMesh(triangleList.points.ToArray(), triangleList.triangles.ToArray()); } return mesh; } public static Polyhedron3 CreatePlane(bool allowPolygons = false) { return CreatePlane(PlaneParams.Default, allowPolygons); } public static Polyhedron3 CreatePlane(PlaneParams param, bool allowPolygons = false) { var mesh = new Polyhedron3(); if (allowPolygons) { polygonList.Clear(); MeshFactory.CreatePlane(polygonList, param); var indices = polygonList.ToIndices(); var points = polygonList.points.ToArray(); mesh.CreatePolygonalMesh(points, points.Length, indices); } else { triangleList.Clear(); MeshFactory.CreatePlane(triangleList, param); mesh.CreateMesh(triangleList.points.ToArray(), triangleList.triangles.ToArray()); } return mesh; } public static Polyhedron3 CreateTorus(bool allowPolygons = false) { return CreateTorus(TorusParams.Default, allowPolygons); } public static Polyhedron3 CreateTorus(TorusParams param, bool allowPolygons = false) { var mesh = new Polyhedron3(); if (allowPolygons) { polygonList.Clear(); MeshFactory.CreateTorus(polygonList, param); var indices = polygonList.ToIndices(); var points = polygonList.points.ToArray(); mesh.CreatePolygonalMesh(points, points.Length, indices); } else { triangleList.Clear(); MeshFactory.CreateTorus(triangleList, param); mesh.CreateMesh(triangleList.points.ToArray(), triangleList.triangles.ToArray()); } WeldVertices(mesh); return mesh; } public static Polyhedron3 CreateCone(bool allowPolygons = false) { return CreateCone(ConeParams.Default, allowPolygons); } public static Polyhedron3 CreateCone(ConeParams param, bool allowPolygons = false) { return CreateCylinder(param.AsCylinderParam(), allowPolygons); } public static Polyhedron3 CreateCylinder(bool allowPolygons = false) { return CreateCylinder(CylinderParams.Default, allowPolygons); } public static Polyhedron3 CreateCylinder(CylinderParams param, bool allowPolygons = false) { var mesh = new Polyhedron3(); if (allowPolygons) { polygonList.Clear(); MeshFactory.CreateCylinder(polygonList, param); var indices = polygonList.ToIndices(); var points = polygonList.points.ToArray(); mesh.CreatePolygonalMesh(points, points.Length, indices); } else { triangleList.Clear(); MeshFactory.CreateCylinder(triangleList, param); mesh.CreateMesh(triangleList.points.ToArray(), triangleList.triangles.ToArray()); } WeldVertices(mesh); return mesh; } public static Polyhedron3 CreateCapsule(bool allowPolygons = false) { return CreateCapsule(CapsuleParams.Default, allowPolygons); } public static Polyhedron3 CreateCapsule(CapsuleParams param, bool allowPolygons = false) { var mesh = new Polyhedron3(); if (allowPolygons) { polygonList.Clear(); MeshFactory.CreateCapsule(polygonList, param); var indices = polygonList.ToIndices(); var points = polygonList.points.ToArray(); mesh.CreatePolygonalMesh(points, points.Length, indices); } else { triangleList.Clear(); MeshFactory.CreateCapsule(triangleList, param); mesh.CreateMesh(triangleList.points.ToArray(), triangleList.triangles.ToArray()); } WeldVertices(mesh); return mesh; } public static Polyhedron3 CreateUVSphere(bool allowPolygons = false) { return CreateUVSphere(UVSphereParams.Default, allowPolygons); } public static Polyhedron3 CreateUVSphere(UVSphereParams param, bool allowPolygons = false) { var mesh = new Polyhedron3(); if (allowPolygons) { polygonList.Clear(); MeshFactory.CreateUVSphere(polygonList, param); var indices = polygonList.ToIndices(); var points = polygonList.points.ToArray(); mesh.CreatePolygonalMesh(points, points.Length, indices); } else { triangleList.Clear(); MeshFactory.CreateUVSphere(triangleList, param); mesh.CreateMesh(triangleList.points.ToArray(), triangleList.triangles.ToArray()); } return mesh; } public static Polyhedron3 CreateNormalizedCube(bool allowPolygons = false) { return CreateNormalizedCube(NormalizedCubeParams.Default, allowPolygons); } public static Polyhedron3 CreateNormalizedCube(NormalizedCubeParams param, bool allowPolygons = false) { var mesh = new Polyhedron3(); if (allowPolygons) { polygonList.Clear(); MeshFactory.CreateNormalizedCube(polygonList, param); var indices = polygonList.ToIndices(); var points = polygonList.points.ToArray(); mesh.CreatePolygonalMesh(points, points.Length, indices); } else { triangleList.Clear(); MeshFactory.CreateNormalizedCube(triangleList, param); mesh.CreateMesh(triangleList.points.ToArray(), triangleList.triangles.ToArray()); } WeldVertices(mesh); return mesh; } public static Polyhedron3 CreateTetrahedron(double scale = 1) { triangleList.Clear(); MeshFactory.CreateTetrahedron(triangleList, scale); var mesh = new Polyhedron3(); mesh.CreateMesh(triangleList.points.ToArray(), triangleList.triangles.ToArray()); return mesh; } public static Polyhedron3 CreateIcosahedron(double scale = 1) { triangleList.Clear(); MeshFactory.CreateIcosahedron(triangleList, scale); var mesh = new Polyhedron3(); mesh.CreateMesh(triangleList.points.ToArray(), triangleList.triangles.ToArray()); return mesh; } public static Polyhedron3 CreateOctahedron(double scale = 1) { triangleList.Clear(); MeshFactory.CreateOctahedron(triangleList, scale); var mesh = new Polyhedron3(); mesh.CreateMesh(triangleList.points.ToArray(), triangleList.triangles.ToArray()); return mesh; } public static Polyhedron3 CreateDodecahedron(double scale = 1, bool allowPolygons = false) { var mesh = new Polyhedron3(); if (allowPolygons) { polygonList.Clear(); MeshFactory.CreateDodecahedron(polygonList, scale); var indices = polygonList.ToIndices(); var points = polygonList.points.ToArray(); mesh.CreatePolygonalMesh(points, points.Length, indices); } else { triangleList.Clear(); MeshFactory.CreateDodecahedron(triangleList, scale); mesh.CreateMesh(triangleList.points.ToArray(), triangleList.triangles.ToArray()); } return mesh; } private static void WeldVertices(Polyhedron3 mesh) { var repair = MeshProcessingRepair.Instance; repair.RepairPolygonSoup(mesh); } } } ================================================ FILE: CGALDotNet/Polyhedra/PolyhedronKernel3.cs ================================================ using System; using System.Collections.Generic; using System.Runtime.InteropServices; using System.Text; using CGALDotNetGeometry.Numerics; using CGALDotNetGeometry.Shapes; namespace CGALDotNet.Polyhedra { internal abstract class PolyhedronKernel3 : CGALObjectKernel { internal abstract IntPtr Create(); internal abstract void Release(IntPtr ptr); internal abstract int GetBuildStamp(IntPtr ptr); internal abstract void Clear(IntPtr ptr); internal abstract void ClearIndexMaps(IntPtr ptr, bool vertices, bool faces, bool edges); internal abstract void ClearNormalMaps(IntPtr ptr, bool vertices, bool faces); internal abstract void BuildIndices(IntPtr ptr, bool vertices, bool faces, bool edges, bool force); internal abstract IntPtr Copy(IntPtr ptr); internal abstract int VertexCount(IntPtr ptr); internal abstract int FaceCount(IntPtr ptr); internal abstract int HalfEdgeCount(IntPtr ptr); internal abstract int BorderEdgeCount(IntPtr ptr); internal abstract int BorderHalfEdgeCount(IntPtr ptr); internal abstract bool IsValid(IntPtr ptr, int level); internal abstract bool IsClosed(IntPtr ptr); internal abstract bool IsPureBivalent(IntPtr ptr); internal abstract bool IsPureTrivalent(IntPtr ptr); internal abstract bool IsPureTriangle(IntPtr ptr); internal abstract bool IsPureQuad(IntPtr ptr); internal abstract Box3d GetBoundingBox(IntPtr ptr); internal abstract int MakeTetrahedron(IntPtr ptr, Point3d p1, Point3d p2, Point3d p3, Point3d p4); internal abstract int MakeTriangle(IntPtr ptr, Point3d p1, Point3d p2, Point3d p3); internal abstract Point3d GetPoint(IntPtr ptr, int index); internal abstract void GetPoints(IntPtr ptr, Point3d[] points, int count); internal abstract void SetPoint(IntPtr ptr, int index, Point3d point); internal abstract void SetPoints(IntPtr ptr, Point3d[] points, int count); internal abstract bool GetSegment(IntPtr ptr, int index, out Segment3d segment); internal abstract bool GetTriangle(IntPtr ptr, int index, out Triangle3d tri); internal abstract bool GetVertex(IntPtr ptr, int index, out MeshVertex3 vert); internal abstract bool GetFace(IntPtr ptr, int index, out MeshFace3 face); internal abstract bool GetHalfedge(IntPtr ptr, int index, out MeshHalfedge3 edge); internal abstract void GetSegments(IntPtr ptr, Segment3d[] segments, int count); internal abstract void GetTriangles(IntPtr ptr, Triangle3d[] triangles, int count); internal abstract void GetVertices(IntPtr ptr, MeshVertex3[] vertices, int count); internal abstract void GetFaces(IntPtr ptr, MeshFace3[] faces, int count); internal abstract void GetHalfedges(IntPtr ptr, MeshHalfedge3[] edges, int count); internal abstract void Transform(IntPtr ptr, Matrix4x4d matrix); internal abstract void InsideOut(IntPtr ptr); internal abstract void Triangulate(IntPtr ptr); internal abstract void NormalizeBorder(IntPtr ptr); internal abstract bool NormalizedBorderIsValid(IntPtr ptr); internal abstract BOUNDED_SIDE SideOfTriangleMesh(IntPtr ptr, Point3d point); internal abstract double Area(IntPtr ptr); internal abstract Point3d Centroid(IntPtr ptr); internal abstract double Volume(IntPtr ptr); internal abstract bool DoesBoundAVolume(IntPtr ptr); internal abstract void BuildAABBTree(IntPtr ptr); internal abstract void ReleaseAABBTree(IntPtr ptr); internal abstract bool DoesSelfIntersect(IntPtr ptr); internal abstract bool DoIntersects(IntPtr ptr, IntPtr otherPtr, bool test_bounded_sides); internal abstract void ReadOFF(IntPtr ptr, string filename); internal abstract void WriteOFF(IntPtr ptr, string filename); internal abstract void GetCentroids(IntPtr ptr, Point3d[] points, int count); internal abstract void ComputeVertexNormals(IntPtr ptr); internal abstract void ComputeFaceNormals(IntPtr ptr); internal abstract void GetVertexNormals(IntPtr ptr, Vector3d[] normals, int count); internal abstract void GetFaceNormals(IntPtr ptr, Vector3d[] normals, int count); internal abstract void CreatePolygonMesh(IntPtr ptr, Point2d[] points, int pointsCount, bool xz); internal abstract PolygonalCount GetPolygonalCount(IntPtr ptr); internal abstract PolygonalCount GetDualPolygonalCount(IntPtr ptr); internal abstract void CreatePolygonalMesh(IntPtr ptr, Point3d[] points, int pointsCount, int[] triangles, int triangleCount, int[] quads, int quadCount, int[] pentagons, int pentagonCount, int[] hexagons, int hexagonCount); internal abstract void GetPolygonalIndices(IntPtr ptr, int[] triangles, int triangleCount, int[] quads, int quadCount, int[] pentagons, int pentagonCount, int[] hexagons, int hexagonCount); internal abstract void GetDualPolygonalIndices(IntPtr ptr, int[] triangles, int triangleCount, int[] quads, int quadCount, int[] pentagons, int pentagonCount, int[] hexagons, int hexagonCount); internal abstract int AddFacetToBorder(IntPtr ptr, int h, int g); internal abstract int AddVertexAndFacetToBorder(IntPtr ptr, int h, int g); internal abstract int CreateCenterVertex(IntPtr ptr, int h); internal abstract int EraseCenterVertex(IntPtr ptr, int h); internal abstract bool EraseConnectedComponent(IntPtr ptr, int h); internal abstract bool EraseFacet(IntPtr ptr, int h); internal abstract int FillHole(IntPtr ptr, int h); internal abstract int FlipEdge(IntPtr ptr, int h); internal abstract int JoinFacet(IntPtr ptr, int h); internal abstract int JoinLoop(IntPtr ptr, int h, int g); internal abstract int JoinVertex(IntPtr ptr, int h); internal abstract int MakeHole(IntPtr ptr, int h); internal abstract int SplitEdge(IntPtr ptr, int h); internal abstract int SplitFacet(IntPtr ptr, int h, int g); internal abstract int SplitLoop(IntPtr ptr, int h, int g, int k); internal abstract int SplitVertex(IntPtr ptr, int h, int g); } } ================================================ FILE: CGALDotNet/Polyhedra/PolyhedronKernel3_EEK.cs ================================================ using System; using System.Collections.Generic; using System.Runtime.InteropServices; using System.Text; using CGALDotNetGeometry.Numerics; using CGALDotNetGeometry.Shapes; namespace CGALDotNet.Polyhedra { internal class PolyhedronKernel3_EEK : PolyhedronKernel3 { internal override string Name => "EEK"; internal static readonly PolyhedronKernel3 Instance = new PolyhedronKernel3_EEK(); internal override IntPtr Create() { return Polyhedron3_EEK_Create(); } internal override void Release(IntPtr ptr) { Polyhedron3_EEK_Release(ptr); } internal override int GetBuildStamp(IntPtr ptr) { return Polyhedron3_EEK_GetBuildStamp(ptr); } internal override void Clear(IntPtr ptr) { Polyhedron3_EEK_Clear(ptr); } internal override void ClearIndexMaps(IntPtr ptr, bool vertices, bool faces, bool edges) { Polyhedron3_EEK_ClearIndexMaps(ptr, vertices, faces, edges); } internal override void ClearNormalMaps(IntPtr ptr, bool vertices, bool faces) { Polyhedron3_EEK_ClearNormalMaps(ptr, vertices, faces); } internal override void BuildIndices(IntPtr ptr, bool vertices, bool faces, bool edges, bool force) { Polyhedron3_EEK_BuildIndices(ptr, vertices, faces, edges, force); } internal override IntPtr Copy(IntPtr ptr) { return Polyhedron3_EEK_Copy(ptr); } internal override int VertexCount(IntPtr ptr) { return Polyhedron3_EEK_VertexCount(ptr); } internal override int FaceCount(IntPtr ptr) { return Polyhedron3_EEK_FaceCount(ptr); } internal override int HalfEdgeCount(IntPtr ptr) { return Polyhedron3_EEK_HalfEdgeCount(ptr); } internal override int BorderEdgeCount(IntPtr ptr) { return Polyhedron3_EEK_BorderEdgeCount(ptr); } internal override int BorderHalfEdgeCount(IntPtr ptr) { return Polyhedron3_EEK_BorderHalfEdgeCount(ptr); } internal override bool IsValid(IntPtr ptr, int level) { return Polyhedron3_EEK_IsValid(ptr, level); } internal override bool IsClosed(IntPtr ptr) { return Polyhedron3_EEK_IsClosed(ptr); } internal override bool IsPureBivalent(IntPtr ptr) { return Polyhedron3_EEK_IsPureBivalent(ptr); } internal override bool IsPureTrivalent(IntPtr ptr) { return Polyhedron3_EEK_IsPureTrivalent(ptr); } internal override bool IsPureTriangle(IntPtr ptr) { return Polyhedron3_EEK_IsPureTriangle(ptr); } internal override bool IsPureQuad(IntPtr ptr) { return Polyhedron3_EEK_IsPureQuad(ptr); } internal override Box3d GetBoundingBox(IntPtr ptr) { return Polyhedron3_EEK_GetBoundingBox(ptr); } internal override int MakeTetrahedron(IntPtr ptr, Point3d p1, Point3d p2, Point3d p3, Point3d p4) { return Polyhedron3_EEK_MakeTetrahedron(ptr, p1, p2, p3, p4); } internal override int MakeTriangle(IntPtr ptr, Point3d p1, Point3d p2, Point3d p3) { return Polyhedron3_EEK_MakeTriangle(ptr, p1, p2, p3); } internal override Point3d GetPoint(IntPtr ptr, int index) { return Polyhedron3_EEK_GetPoint(ptr, index); } internal override void GetPoints(IntPtr ptr, Point3d[] points, int count) { Polyhedron3_EEK_GetPoints(ptr, points, count); } internal override void SetPoint(IntPtr ptr, int index, Point3d point) { Polyhedron3_EEK_SetPoint(ptr, index, point); } internal override void SetPoints(IntPtr ptr, Point3d[] points, int count) { Polyhedron3_EEK_SetPoints(ptr, points, count); } internal override bool GetSegment(IntPtr ptr, int index, out Segment3d segment) { return Polyhedron3_EEK_GetSegment(ptr, index, out segment); } internal override bool GetTriangle(IntPtr ptr, int index, out Triangle3d tri) { return Polyhedron3_EEK_GetTriangle(ptr, index, out tri); } internal override bool GetVertex(IntPtr ptr, int index, out MeshVertex3 vert) { return Polyhedron3_EEK_GetVertex(ptr, index, out vert); } internal override bool GetFace(IntPtr ptr, int index, out MeshFace3 face) { return Polyhedron3_EEK_GetFace(ptr, index, out face); } internal override bool GetHalfedge(IntPtr ptr, int index, out MeshHalfedge3 edge) { return Polyhedron3_EEK_GetHalfedge(ptr, index, out edge); } internal override void GetSegments(IntPtr ptr, Segment3d[] segments, int count) { Polyhedron3_EEK_GetSegments(ptr, segments, count); } internal override void GetTriangles(IntPtr ptr, Triangle3d[] triangles, int count) { Polyhedron3_EEK_GetTriangles(ptr, triangles, count); } internal override void GetVertices(IntPtr ptr, MeshVertex3[] vertices, int count) { Polyhedron3_EEK_GetVertices(ptr, vertices, count); } internal override void GetFaces(IntPtr ptr, MeshFace3[] faces, int count) { Polyhedron3_EEK_GetFaces(ptr, faces, count); } internal override void GetHalfedges(IntPtr ptr, MeshHalfedge3[] edges, int count) { Polyhedron3_EEK_GetHalfedges(ptr, edges, count); } internal override void Transform(IntPtr ptr, Matrix4x4d matrix) { Polyhedron3_EEK_Transform(ptr, matrix); } internal override void InsideOut(IntPtr ptr) { Polyhedron3_EEK_InsideOut(ptr); } internal override void Triangulate(IntPtr ptr) { Polyhedron3_EEK_Triangulate(ptr); } internal override void NormalizeBorder(IntPtr ptr) { Polyhedron3_EEK_NormalizeBorder(ptr); } internal override bool NormalizedBorderIsValid(IntPtr ptr) { return Polyhedron3_EEK_NormalizedBorderIsValid(ptr); } internal override BOUNDED_SIDE SideOfTriangleMesh(IntPtr ptr, Point3d point) { return Polyhedron3_EEK_SideOfTriangleMesh(ptr, point); } internal override bool DoesSelfIntersect(IntPtr ptr) { return Polyhedron3_EEK_DoesSelfIntersect(ptr); } internal override double Area(IntPtr ptr) { return Polyhedron3_EEK_Area(ptr); } internal override Point3d Centroid(IntPtr ptr) { return Polyhedron3_EEK_Centroid(ptr); } internal override double Volume(IntPtr ptr) { return Polyhedron3_EEK_Volume(ptr); } internal override bool DoesBoundAVolume(IntPtr ptr) { return Polyhedron3_EEK_DoesBoundAVolume(ptr); } internal override void BuildAABBTree(IntPtr ptr) { Polyhedron3_EEK_BuildAABBTree(ptr); } internal override void ReleaseAABBTree(IntPtr ptr) { Polyhedron3_EEK_ReleaseAABBTree(ptr); } internal override bool DoIntersects(IntPtr ptr, IntPtr otherPtr, bool test_bounded_sides) { return Polyhedron3_EEK_DoIntersects(ptr, otherPtr, test_bounded_sides); } internal override void ReadOFF(IntPtr ptr, string filename) { Polyhedron3_EEK_ReadOFF(ptr, filename); } internal override void WriteOFF(IntPtr ptr, string filename) { Polyhedron3_EEK_WriteOFF(ptr, filename); } internal override void GetCentroids(IntPtr ptr, Point3d[] points, int count) { Polyhedron3_EEK_GetCentroids(ptr, points, count); } internal override void ComputeVertexNormals(IntPtr ptr) { Polyhedron3_EEK_ComputeVertexNormals(ptr); } internal override void ComputeFaceNormals(IntPtr ptr) { Polyhedron3_EEK_ComputeFaceNormals(ptr); } internal override void GetVertexNormals(IntPtr ptr, Vector3d[] normals, int count) { Polyhedron3_EEK_GetVertexNormals(ptr, normals, count); } internal override void GetFaceNormals(IntPtr ptr, Vector3d[] normals, int count) { Polyhedron3_EEK_GetFaceNormals(ptr, normals, count); } internal override void CreatePolygonMesh(IntPtr ptr, Point2d[] points, int pointsCount, bool xz) { Polyhedron3_EEK_CreatePolygonMesh(ptr, points, pointsCount, xz); } internal override PolygonalCount GetPolygonalCount(IntPtr ptr) { return Polyhedron3_EEK_GetPolygonalCount(ptr); } internal override PolygonalCount GetDualPolygonalCount(IntPtr ptr) { return Polyhedron3_EEK_GetDualPolygonalCount(ptr); } internal override void CreatePolygonalMesh(IntPtr ptr, Point3d[] points, int pointsCount, int[] triangles, int triangleCount, int[] quads, int quadCount, int[] pentagons, int pentagonCount, int[] hexagons, int hexagonCount) { Polyhedron3_EEK_CreatePolygonalMesh(ptr, points, pointsCount, triangles, triangleCount, quads, quadCount, pentagons, pentagonCount, hexagons, hexagonCount); } internal override void GetPolygonalIndices(IntPtr ptr, int[] triangles, int triangleCount, int[] quads, int quadCount, int[] pentagons, int pentagonCount, int[] hexagons, int hexagonCount) { Polyhedron3_EEK_GetPolygonalIndices(ptr, triangles, triangleCount, quads, quadCount, pentagons, pentagonCount, hexagons, hexagonCount); } internal override void GetDualPolygonalIndices(IntPtr ptr, int[] triangles, int triangleCount, int[] quads, int quadCount, int[] pentagons, int pentagonCount, int[] hexagons, int hexagonCount) { Polyhedron3_EEK_GetDualPolygonalIndices(ptr, triangles, triangleCount, quads, quadCount, pentagons, pentagonCount, hexagons, hexagonCount); } internal override int AddFacetToBorder(IntPtr ptr, int h, int g) { return Polyhedron3_EEK_AddFacetToBorder(ptr, h, g); } internal override int AddVertexAndFacetToBorder(IntPtr ptr, int h, int g) { return Polyhedron3_EEK_AddVertexAndFacetToBorder(ptr, h, g); } internal override int CreateCenterVertex(IntPtr ptr, int h) { return Polyhedron3_EEK_CreateCenterVertex(ptr, h); } internal override int EraseCenterVertex(IntPtr ptr, int h) { return Polyhedron3_EEK_EraseCenterVertex(ptr, h); } internal override bool EraseConnectedComponent(IntPtr ptr, int h) { return Polyhedron3_EEK_EraseConnectedComponent(ptr, h); } internal override bool EraseFacet(IntPtr ptr, int h) { return Polyhedron3_EEK_EraseFacet(ptr, h); } internal override int FillHole(IntPtr ptr, int h) { return Polyhedron3_EEK_FillHole(ptr, h); } internal override int FlipEdge(IntPtr ptr, int h) { return Polyhedron3_EEK_FlipEdge(ptr, h); } internal override int JoinFacet(IntPtr ptr, int h) { return Polyhedron3_EEK_JoinFacet(ptr, h); } internal override int JoinLoop(IntPtr ptr, int h, int g) { return Polyhedron3_EEK_JoinLoop(ptr, h, g); } internal override int JoinVertex(IntPtr ptr, int h) { return Polyhedron3_EEK_JoinVertex(ptr, h); } internal override int MakeHole(IntPtr ptr, int h) { return Polyhedron3_EEK_MakeHole(ptr, h); } internal override int SplitEdge(IntPtr ptr, int h) { return Polyhedron3_EEK_SplitEdge(ptr, h); } internal override int SplitFacet(IntPtr ptr, int h, int g) { return Polyhedron3_EEK_SplitFacet(ptr, h, g); } internal override int SplitLoop(IntPtr ptr, int h, int g, int k) { return Polyhedron3_EEK_SplitLoop(ptr, h, g, k); } internal override int SplitVertex(IntPtr ptr, int h, int g) { return Polyhedron3_EEK_SplitVertex(ptr, h, g); } [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr Polyhedron3_EEK_Create(); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void Polyhedron3_EEK_Release(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int Polyhedron3_EEK_GetBuildStamp(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void Polyhedron3_EEK_Clear(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void Polyhedron3_EEK_ClearIndexMaps(IntPtr ptr, bool vertices, bool faces, bool edges); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void Polyhedron3_EEK_ClearNormalMaps(IntPtr ptr, bool vertices, bool faces); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void Polyhedron3_EEK_BuildIndices(IntPtr ptr, bool vertices, bool faces, bool edges, bool force); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr Polyhedron3_EEK_Copy(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int Polyhedron3_EEK_VertexCount(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int Polyhedron3_EEK_FaceCount(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int Polyhedron3_EEK_HalfEdgeCount(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int Polyhedron3_EEK_BorderEdgeCount(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int Polyhedron3_EEK_BorderHalfEdgeCount(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool Polyhedron3_EEK_IsValid(IntPtr ptr, int level); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool Polyhedron3_EEK_IsClosed(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool Polyhedron3_EEK_IsPureBivalent(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool Polyhedron3_EEK_IsPureTrivalent(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool Polyhedron3_EEK_IsPureTriangle(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool Polyhedron3_EEK_IsPureQuad(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern Box3d Polyhedron3_EEK_GetBoundingBox(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int Polyhedron3_EEK_MakeTetrahedron(IntPtr ptr, Point3d p1, Point3d p2, Point3d p3, Point3d p4); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int Polyhedron3_EEK_MakeTriangle(IntPtr ptr, Point3d p1, Point3d p2, Point3d p3); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern Point3d Polyhedron3_EEK_GetPoint(IntPtr ptr, int index); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void Polyhedron3_EEK_GetPoints(IntPtr ptr, [Out] Point3d[] points, int count); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void Polyhedron3_EEK_SetPoint(IntPtr ptr, int index, Point3d point); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void Polyhedron3_EEK_SetPoints(IntPtr ptr, Point3d[] points, int count); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool Polyhedron3_EEK_GetSegment(IntPtr ptr, int index, [Out] out Segment3d segment); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool Polyhedron3_EEK_GetTriangle(IntPtr ptr, int index, [Out] out Triangle3d tri); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool Polyhedron3_EEK_GetVertex(IntPtr ptr, int index, [Out] out MeshVertex3 vert); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool Polyhedron3_EEK_GetFace(IntPtr ptr, int index, [Out] out MeshFace3 face); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool Polyhedron3_EEK_GetHalfedge(IntPtr ptr, int index, [Out] out MeshHalfedge3 edge); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void Polyhedron3_EEK_GetSegments(IntPtr ptr, [Out] Segment3d[] segments, int count); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void Polyhedron3_EEK_GetTriangles(IntPtr ptr, [Out] Triangle3d[] triangles, int count); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void Polyhedron3_EEK_GetVertices(IntPtr ptr, [Out] MeshVertex3[] vertices, int count); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void Polyhedron3_EEK_GetFaces(IntPtr ptr, [Out] MeshFace3[] faces, int count); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void Polyhedron3_EEK_GetHalfedges(IntPtr ptr, [Out] MeshHalfedge3[] edges, int count); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void Polyhedron3_EEK_Transform(IntPtr ptr, Matrix4x4d matrix); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void Polyhedron3_EEK_InsideOut(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void Polyhedron3_EEK_Triangulate(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void Polyhedron3_EEK_NormalizeBorder(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool Polyhedron3_EEK_NormalizedBorderIsValid(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern BOUNDED_SIDE Polyhedron3_EEK_SideOfTriangleMesh(IntPtr ptr, Point3d point); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool Polyhedron3_EEK_DoesSelfIntersect(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern double Polyhedron3_EEK_Area(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern Point3d Polyhedron3_EEK_Centroid(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern double Polyhedron3_EEK_Volume(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool Polyhedron3_EEK_DoesBoundAVolume(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void Polyhedron3_EEK_BuildAABBTree(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void Polyhedron3_EEK_ReleaseAABBTree(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool Polyhedron3_EEK_DoIntersects(IntPtr ptr, IntPtr otherPtr, bool test_bounded_sides); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void Polyhedron3_EEK_ReadOFF(IntPtr ptr, string filename); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void Polyhedron3_EEK_WriteOFF(IntPtr ptr, string filename); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void Polyhedron3_EEK_GetCentroids(IntPtr ptr, [Out] Point3d[] points, int count); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void Polyhedron3_EEK_ComputeVertexNormals(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void Polyhedron3_EEK_ComputeFaceNormals(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void Polyhedron3_EEK_GetVertexNormals(IntPtr ptr, [Out] Vector3d[] normals, int count); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void Polyhedron3_EEK_GetFaceNormals(IntPtr ptr, [Out] Vector3d[] normals, int count); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void Polyhedron3_EEK_CreatePolygonMesh(IntPtr ptr, Point2d[] points, int pointsCount, bool xz); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern PolygonalCount Polyhedron3_EEK_GetPolygonalCount(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern PolygonalCount Polyhedron3_EEK_GetDualPolygonalCount(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void Polyhedron3_EEK_CreatePolygonalMesh(IntPtr ptr, Point3d[] points, int pointsCount, int[] triangles, int triangleCount, int[] quads, int quadCount, int[] pentagons, int pentagonCount, int[] hexagons, int hexagonCount); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void Polyhedron3_EEK_GetPolygonalIndices(IntPtr ptr, [Out] int[] triangles, int triangleCount, [Out] int[] quads, int quadCount, [Out] int[] pentagons, int pentagonCount, [Out] int[] hexagons, int hexagonCount); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void Polyhedron3_EEK_GetDualPolygonalIndices(IntPtr ptr, [Out] int[] triangles, int triangleCount, [Out] int[] quads, int quadCount, [Out] int[] pentagons, int pentagonCount, [Out] int[] hexagons, int hexagonCount); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int Polyhedron3_EEK_AddFacetToBorder(IntPtr ptr, int h, int g); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int Polyhedron3_EEK_AddVertexAndFacetToBorder(IntPtr ptr, int h, int g); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int Polyhedron3_EEK_CreateCenterVertex(IntPtr ptr, int h); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int Polyhedron3_EEK_EraseCenterVertex(IntPtr ptr, int h); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool Polyhedron3_EEK_EraseConnectedComponent(IntPtr ptr, int h); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool Polyhedron3_EEK_EraseFacet(IntPtr ptr, int h); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int Polyhedron3_EEK_FillHole(IntPtr ptr, int h); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int Polyhedron3_EEK_FlipEdge(IntPtr ptr, int h); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int Polyhedron3_EEK_JoinFacet(IntPtr ptr, int h); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int Polyhedron3_EEK_JoinLoop(IntPtr ptr, int h, int g); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int Polyhedron3_EEK_JoinVertex(IntPtr ptr, int h); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int Polyhedron3_EEK_MakeHole(IntPtr ptr, int h); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int Polyhedron3_EEK_SplitEdge(IntPtr ptr, int h); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int Polyhedron3_EEK_SplitFacet(IntPtr ptr, int h, int g); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int Polyhedron3_EEK_SplitLoop(IntPtr ptr, int h, int g, int k); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int Polyhedron3_EEK_SplitVertex(IntPtr ptr, int h, int g); } } ================================================ FILE: CGALDotNet/Polyhedra/PolyhedronKernel3_EIK.cs ================================================ using System; using System.Collections.Generic; using System.Runtime.InteropServices; using System.Text; using CGALDotNetGeometry.Numerics; using CGALDotNetGeometry.Shapes; namespace CGALDotNet.Polyhedra { internal class PolyhedronKernel3_EIK : PolyhedronKernel3 { internal override string Name => "EIK"; internal static readonly PolyhedronKernel3 Instance = new PolyhedronKernel3_EIK(); internal override IntPtr Create() { return Polyhedron3_EIK_Create(); } internal override void Release(IntPtr ptr) { Polyhedron3_EIK_Release(ptr); } internal override int GetBuildStamp(IntPtr ptr) { return Polyhedron3_EIK_GetBuildStamp(ptr); } internal override void Clear(IntPtr ptr) { Polyhedron3_EIK_Clear(ptr); } internal override void ClearIndexMaps(IntPtr ptr, bool vertices, bool faces, bool edges) { Polyhedron3_EIK_ClearIndexMaps(ptr, vertices, faces, edges); } internal override void ClearNormalMaps(IntPtr ptr, bool vertices, bool faces) { Polyhedron3_EIK_ClearNormalMaps(ptr, vertices, faces); } internal override void BuildIndices(IntPtr ptr, bool vertices, bool faces, bool edges, bool force) { Polyhedron3_EIK_BuildIndices(ptr, vertices, faces, edges, force); } internal override IntPtr Copy(IntPtr ptr) { return Polyhedron3_EIK_Copy(ptr); } internal override int VertexCount(IntPtr ptr) { return Polyhedron3_EIK_VertexCount(ptr); } internal override int FaceCount(IntPtr ptr) { return Polyhedron3_EIK_FaceCount(ptr); } internal override int HalfEdgeCount(IntPtr ptr) { return Polyhedron3_EIK_HalfEdgeCount(ptr); } internal override int BorderEdgeCount(IntPtr ptr) { return Polyhedron3_EIK_BorderEdgeCount(ptr); } internal override int BorderHalfEdgeCount(IntPtr ptr) { return Polyhedron3_EIK_BorderHalfEdgeCount(ptr); } internal override bool IsValid(IntPtr ptr, int level) { return Polyhedron3_EIK_IsValid(ptr, level); } internal override bool IsClosed(IntPtr ptr) { return Polyhedron3_EIK_IsClosed(ptr); } internal override bool IsPureBivalent(IntPtr ptr) { return Polyhedron3_EIK_IsPureBivalent(ptr); } internal override bool IsPureTrivalent(IntPtr ptr) { return Polyhedron3_EIK_IsPureTrivalent(ptr); } internal override bool IsPureTriangle(IntPtr ptr) { return Polyhedron3_EIK_IsPureTriangle(ptr); } internal override bool IsPureQuad(IntPtr ptr) { return Polyhedron3_EIK_IsPureQuad(ptr); } internal override Box3d GetBoundingBox(IntPtr ptr) { return Polyhedron3_EIK_GetBoundingBox(ptr); } internal override int MakeTetrahedron(IntPtr ptr, Point3d p1, Point3d p2, Point3d p3, Point3d p4) { return Polyhedron3_EIK_MakeTetrahedron(ptr, p1, p2, p3, p4); } internal override int MakeTriangle(IntPtr ptr, Point3d p1, Point3d p2, Point3d p3) { return Polyhedron3_EIK_MakeTriangle(ptr, p1, p2, p3); } internal override Point3d GetPoint(IntPtr ptr, int index) { return Polyhedron3_EIK_GetPoint(ptr, index); } internal override void GetPoints(IntPtr ptr, Point3d[] points, int count) { Polyhedron3_EIK_GetPoints(ptr, points, count); } internal override void SetPoint(IntPtr ptr, int index, Point3d point) { Polyhedron3_EIK_SetPoint(ptr, index, point); } internal override void SetPoints(IntPtr ptr, Point3d[] points, int count) { Polyhedron3_EIK_SetPoints(ptr, points, count); } internal override bool GetSegment(IntPtr ptr, int index, out Segment3d segment) { return Polyhedron3_EIK_GetSegment(ptr, index, out segment); } internal override bool GetTriangle(IntPtr ptr, int index, out Triangle3d tri) { return Polyhedron3_EIK_GetTriangle(ptr, index, out tri); } internal override bool GetVertex(IntPtr ptr, int index, out MeshVertex3 vert) { return Polyhedron3_EIK_GetVertex(ptr, index, out vert); } internal override bool GetFace(IntPtr ptr, int index, out MeshFace3 face) { return Polyhedron3_EIK_GetFace(ptr, index, out face); } internal override bool GetHalfedge(IntPtr ptr, int index, out MeshHalfedge3 edge) { return Polyhedron3_EIK_GetHalfedge(ptr, index, out edge); } internal override void GetSegments(IntPtr ptr, Segment3d[] segments, int count) { Polyhedron3_EIK_GetSegments(ptr, segments, count); } internal override void GetTriangles(IntPtr ptr, Triangle3d[] triangles, int count) { Polyhedron3_EIK_GetTriangles(ptr, triangles, count); } internal override void GetVertices(IntPtr ptr, MeshVertex3[] vertices, int count) { Polyhedron3_EIK_GetVertices(ptr, vertices, count); } internal override void GetFaces(IntPtr ptr, MeshFace3[] faces, int count) { Polyhedron3_EIK_GetFaces(ptr, faces, count); } internal override void GetHalfedges(IntPtr ptr, MeshHalfedge3[] edges, int count) { Polyhedron3_EIK_GetHalfedges(ptr, edges, count); } internal override void Transform(IntPtr ptr, Matrix4x4d matrix) { Polyhedron3_EIK_Transform(ptr, matrix); } internal override void InsideOut(IntPtr ptr) { Polyhedron3_EIK_InsideOut(ptr); } internal override void Triangulate(IntPtr ptr) { Polyhedron3_EIK_Triangulate(ptr); } internal override void NormalizeBorder(IntPtr ptr) { Polyhedron3_EIK_NormalizeBorder(ptr); } internal override bool NormalizedBorderIsValid(IntPtr ptr) { return Polyhedron3_EIK_NormalizedBorderIsValid(ptr); } internal override BOUNDED_SIDE SideOfTriangleMesh(IntPtr ptr, Point3d point) { return Polyhedron3_EIK_SideOfTriangleMesh(ptr, point); } internal override bool DoesSelfIntersect(IntPtr ptr) { return Polyhedron3_EIK_DoesSelfIntersect(ptr); } internal override double Area(IntPtr ptr) { return Polyhedron3_EIK_Area(ptr); } internal override Point3d Centroid(IntPtr ptr) { return Polyhedron3_EIK_Centroid(ptr); } internal override double Volume(IntPtr ptr) { return Polyhedron3_EIK_Volume(ptr); } internal override bool DoesBoundAVolume(IntPtr ptr) { return Polyhedron3_EIK_DoesBoundAVolume(ptr); } internal override void BuildAABBTree(IntPtr ptr) { Polyhedron3_EIK_BuildAABBTree(ptr); } internal override void ReleaseAABBTree(IntPtr ptr) { Polyhedron3_EIK_ReleaseAABBTree(ptr); } internal override bool DoIntersects(IntPtr ptr, IntPtr otherPtr, bool test_bounded_sides) { return Polyhedron3_EIK_DoIntersects(ptr, otherPtr, test_bounded_sides); } internal override void ReadOFF(IntPtr ptr, string filename) { Polyhedron3_EIK_ReadOFF(ptr, filename); } internal override void WriteOFF(IntPtr ptr, string filename) { Polyhedron3_EIK_WriteOFF(ptr, filename); } internal override void GetCentroids(IntPtr ptr, Point3d[] points, int count) { Polyhedron3_EIK_GetCentroids(ptr, points, count); } internal override void ComputeVertexNormals(IntPtr ptr) { Polyhedron3_EIK_ComputeVertexNormals(ptr); } internal override void ComputeFaceNormals(IntPtr ptr) { Polyhedron3_EIK_ComputeFaceNormals(ptr); } internal override void GetVertexNormals(IntPtr ptr, Vector3d[] normals, int count) { Polyhedron3_EIK_GetVertexNormals(ptr, normals, count); } internal override void GetFaceNormals(IntPtr ptr, Vector3d[] normals, int count) { Polyhedron3_EIK_GetFaceNormals(ptr, normals, count); } internal override void CreatePolygonMesh(IntPtr ptr, Point2d[] points, int pointsCount, bool xz) { Polyhedron3_EIK_CreatePolygonMesh(ptr, points, pointsCount, xz); } internal override PolygonalCount GetPolygonalCount(IntPtr ptr) { return Polyhedron3_EIK_GetPolygonalCount(ptr); } internal override PolygonalCount GetDualPolygonalCount(IntPtr ptr) { return Polyhedron3_EIK_GetDualPolygonalCount(ptr); } internal override void CreatePolygonalMesh(IntPtr ptr, Point3d[] points, int pointsCount, int[] triangles, int triangleCount, int[] quads, int quadCount, int[] pentagons, int pentagonCount, int[] hexagons, int hexagonCount) { Polyhedron3_EIK_CreatePolygonalMesh(ptr, points, pointsCount, triangles, triangleCount, quads, quadCount, pentagons, pentagonCount, hexagons, hexagonCount); } internal override void GetPolygonalIndices(IntPtr ptr, int[] triangles, int triangleCount, int[] quads, int quadCount, int[] pentagons, int pentagonCount, int[] hexagons, int hexagonCount) { Polyhedron3_EIK_GetPolygonalIndices(ptr, triangles, triangleCount, quads, quadCount, pentagons, pentagonCount, hexagons, hexagonCount); } internal override void GetDualPolygonalIndices(IntPtr ptr, int[] triangles, int triangleCount, int[] quads, int quadCount, int[] pentagons, int pentagonCount, int[] hexagons, int hexagonCount) { Polyhedron3_EIK_GetDualPolygonalIndices(ptr, triangles, triangleCount, quads, quadCount, pentagons, pentagonCount, hexagons, hexagonCount); } internal override int AddFacetToBorder(IntPtr ptr, int h, int g) { return Polyhedron3_EIK_AddFacetToBorder(ptr, h, g); } internal override int AddVertexAndFacetToBorder(IntPtr ptr, int h, int g) { return Polyhedron3_EIK_AddVertexAndFacetToBorder(ptr, h, g); } internal override int CreateCenterVertex(IntPtr ptr, int h) { return Polyhedron3_EIK_CreateCenterVertex(ptr, h); } internal override int EraseCenterVertex(IntPtr ptr, int h) { return Polyhedron3_EIK_EraseCenterVertex(ptr, h); } internal override bool EraseConnectedComponent(IntPtr ptr, int h) { return Polyhedron3_EIK_EraseConnectedComponent(ptr, h); } internal override bool EraseFacet(IntPtr ptr, int h) { return Polyhedron3_EIK_EraseFacet(ptr, h); } internal override int FillHole(IntPtr ptr, int h) { return Polyhedron3_EIK_FillHole(ptr, h); } internal override int FlipEdge(IntPtr ptr, int h) { return Polyhedron3_EIK_FlipEdge(ptr, h); } internal override int JoinFacet(IntPtr ptr, int h) { return Polyhedron3_EIK_JoinFacet(ptr, h); } internal override int JoinLoop(IntPtr ptr, int h, int g) { return Polyhedron3_EIK_JoinLoop(ptr, h, g); } internal override int JoinVertex(IntPtr ptr, int h) { return Polyhedron3_EIK_JoinVertex(ptr, h); } internal override int MakeHole(IntPtr ptr, int h) { return Polyhedron3_EIK_MakeHole(ptr, h); } internal override int SplitEdge(IntPtr ptr, int h) { return Polyhedron3_EIK_SplitEdge(ptr, h); } internal override int SplitFacet(IntPtr ptr, int h, int g) { return Polyhedron3_EIK_SplitFacet(ptr, h, g); } internal override int SplitLoop(IntPtr ptr, int h, int g, int k) { return Polyhedron3_EIK_SplitLoop(ptr, h, g, k); } internal override int SplitVertex(IntPtr ptr, int h, int g) { return Polyhedron3_EIK_SplitVertex(ptr, h, g); } [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr Polyhedron3_EIK_Create(); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void Polyhedron3_EIK_Release(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int Polyhedron3_EIK_GetBuildStamp(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void Polyhedron3_EIK_Clear(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void Polyhedron3_EIK_ClearIndexMaps(IntPtr ptr, bool vertices, bool faces, bool edges); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void Polyhedron3_EIK_ClearNormalMaps(IntPtr ptr, bool vertices, bool faces); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void Polyhedron3_EIK_BuildIndices(IntPtr ptr, bool vertices, bool faces, bool edges, bool force); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr Polyhedron3_EIK_Copy(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int Polyhedron3_EIK_VertexCount(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int Polyhedron3_EIK_FaceCount(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int Polyhedron3_EIK_HalfEdgeCount(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int Polyhedron3_EIK_BorderEdgeCount(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int Polyhedron3_EIK_BorderHalfEdgeCount(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool Polyhedron3_EIK_IsValid(IntPtr ptr, int level); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool Polyhedron3_EIK_IsClosed(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool Polyhedron3_EIK_IsPureBivalent(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool Polyhedron3_EIK_IsPureTrivalent(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool Polyhedron3_EIK_IsPureTriangle(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool Polyhedron3_EIK_IsPureQuad(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern Box3d Polyhedron3_EIK_GetBoundingBox(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int Polyhedron3_EIK_MakeTetrahedron(IntPtr ptr, Point3d p1, Point3d p2, Point3d p3, Point3d p4); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int Polyhedron3_EIK_MakeTriangle(IntPtr ptr, Point3d p1, Point3d p2, Point3d p3); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern Point3d Polyhedron3_EIK_GetPoint(IntPtr ptr, int index); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void Polyhedron3_EIK_GetPoints(IntPtr ptr, [Out] Point3d[] points, int count); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void Polyhedron3_EIK_SetPoint(IntPtr ptr, int index, Point3d point); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void Polyhedron3_EIK_SetPoints(IntPtr ptr, Point3d[] points, int count); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool Polyhedron3_EIK_GetSegment(IntPtr ptr, int index, [Out] out Segment3d segment); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool Polyhedron3_EIK_GetTriangle(IntPtr ptr, int index, [Out] out Triangle3d tri); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool Polyhedron3_EIK_GetVertex(IntPtr ptr, int index, [Out] out MeshVertex3 vert); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool Polyhedron3_EIK_GetFace(IntPtr ptr, int index, [Out] out MeshFace3 face); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool Polyhedron3_EIK_GetHalfedge(IntPtr ptr, int index, [Out] out MeshHalfedge3 edge); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void Polyhedron3_EIK_GetSegments(IntPtr ptr, [Out] Segment3d[] segments, int count); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void Polyhedron3_EIK_GetTriangles(IntPtr ptr, [Out] Triangle3d[] triangles, int count); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void Polyhedron3_EIK_GetVertices(IntPtr ptr, [Out] MeshVertex3[] vertices, int count); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void Polyhedron3_EIK_GetFaces(IntPtr ptr, [Out] MeshFace3[] faces, int count); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void Polyhedron3_EIK_GetHalfedges(IntPtr ptr, [Out] MeshHalfedge3[] edges, int count); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void Polyhedron3_EIK_Transform(IntPtr ptr, Matrix4x4d matrix); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void Polyhedron3_EIK_InsideOut(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void Polyhedron3_EIK_Triangulate(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void Polyhedron3_EIK_NormalizeBorder(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool Polyhedron3_EIK_NormalizedBorderIsValid(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern BOUNDED_SIDE Polyhedron3_EIK_SideOfTriangleMesh(IntPtr ptr, Point3d point); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool Polyhedron3_EIK_DoesSelfIntersect(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern double Polyhedron3_EIK_Area(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern Point3d Polyhedron3_EIK_Centroid(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern double Polyhedron3_EIK_Volume(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool Polyhedron3_EIK_DoesBoundAVolume(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void Polyhedron3_EIK_BuildAABBTree(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void Polyhedron3_EIK_ReleaseAABBTree(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool Polyhedron3_EIK_DoIntersects(IntPtr ptr, IntPtr otherPtr, bool test_bounded_sides); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void Polyhedron3_EIK_ReadOFF(IntPtr ptr, string filename); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void Polyhedron3_EIK_WriteOFF(IntPtr ptr, string filename); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void Polyhedron3_EIK_GetCentroids(IntPtr ptr, [Out] Point3d[] points, int count); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void Polyhedron3_EIK_ComputeVertexNormals(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void Polyhedron3_EIK_ComputeFaceNormals(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void Polyhedron3_EIK_GetVertexNormals(IntPtr ptr, [Out] Vector3d[] normals, int count); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void Polyhedron3_EIK_GetFaceNormals(IntPtr ptr, [Out] Vector3d[] normals, int count); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void Polyhedron3_EIK_CreatePolygonMesh(IntPtr ptr, Point2d[] points, int pointsCount, bool xz); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern PolygonalCount Polyhedron3_EIK_GetPolygonalCount(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern PolygonalCount Polyhedron3_EIK_GetDualPolygonalCount(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void Polyhedron3_EIK_CreatePolygonalMesh(IntPtr ptr, Point3d[] points, int pointsCount, int[] triangles, int triangleCount, int[] quads, int quadCount, int[] pentagons, int pentagonCount, int[] hexagons, int hexagonCount); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void Polyhedron3_EIK_GetPolygonalIndices(IntPtr ptr, [Out] int[] triangles, int triangleCount, [Out] int[] quads, int quadCount, [Out] int[] pentagons, int pentagonCount, [Out] int[] hexagons, int hexagonCount); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void Polyhedron3_EIK_GetDualPolygonalIndices(IntPtr ptr, [Out] int[] triangles, int triangleCount, [Out] int[] quads, int quadCount, [Out] int[] pentagons, int pentagonCount, [Out] int[] hexagons, int hexagonCount); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int Polyhedron3_EIK_AddFacetToBorder(IntPtr ptr, int h, int g); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int Polyhedron3_EIK_AddVertexAndFacetToBorder(IntPtr ptr, int h, int g); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int Polyhedron3_EIK_CreateCenterVertex(IntPtr ptr, int h); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int Polyhedron3_EIK_EraseCenterVertex(IntPtr ptr, int h); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool Polyhedron3_EIK_EraseConnectedComponent(IntPtr ptr, int h); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool Polyhedron3_EIK_EraseFacet(IntPtr ptr, int h); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int Polyhedron3_EIK_FillHole(IntPtr ptr, int h); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int Polyhedron3_EIK_FlipEdge(IntPtr ptr, int h); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int Polyhedron3_EIK_JoinFacet(IntPtr ptr, int h); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int Polyhedron3_EIK_JoinLoop(IntPtr ptr, int h, int g); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int Polyhedron3_EIK_JoinVertex(IntPtr ptr, int h); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int Polyhedron3_EIK_MakeHole(IntPtr ptr, int h); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int Polyhedron3_EIK_SplitEdge(IntPtr ptr, int h); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int Polyhedron3_EIK_SplitFacet(IntPtr ptr, int h, int g); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int Polyhedron3_EIK_SplitLoop(IntPtr ptr, int h, int g, int k); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int Polyhedron3_EIK_SplitVertex(IntPtr ptr, int h, int g); } } ================================================ FILE: CGALDotNet/Polyhedra/SurfaceMesh3.cs ================================================ using System; using System.Collections; using System.Collections.Generic; using System.Text; using CGALDotNetGeometry.Numerics; using CGALDotNetGeometry.Shapes; using CGALDotNet.Processing; using CGALDotNet.Polygons; using CGALDotNet.Extensions; namespace CGALDotNet.Polyhedra { /// /// This class is a data structure that can be used as halfedge data structure. /// It is an alternative to the classes Polyhedron3.The main difference is that it is indexed based and not pointer based, /// and that the mechanism for adding information to vertices, halfedges, edges, and faces is much simpler. /// When elements are removed, they are only marked as removed, and a garbage collection function must be called to really remove them. /// /// The kernel type public sealed class SurfaceMesh3 : SurfaceMesh3 where K : CGALKernel, new() { /// /// Default constructor. /// public SurfaceMesh3() : base(new K()) { } /// /// Construct from points and triangle indices. /// public SurfaceMesh3(Point3d[] points, int[] triangles) : base(new K()) { CreateMesh(points, triangles); } /// /// Construct from points and polygon indices. /// public SurfaceMesh3(Point3d[] points, PolygonalIndices indices) : base(new K()) { CreatePolygonalMesh(points, points.Length, indices); } /// /// Create from a pointer. /// /// The surface meshes pointer. internal SurfaceMesh3(IntPtr ptr) : base(new K(), ptr) { } /// /// The mesh as a string. /// /// The mesh as a string. public override string ToString() { return string.Format("[SurfaceMesh3<{0}>: VertexCount={1}, HalfEdgeCount={2}, FaceCount={3}]", Kernel.Name, VertexCount, HalfedgeCount, FaceCount); } /// /// Create a deep copy of the mesh. /// /// The deep copy. public SurfaceMesh3 Copy() { var ptr = Kernel.Copy(Ptr); return new SurfaceMesh3(ptr); } /// /// Subdive the mesh. /// /// The number of iterations to perfrom. /// The subdivision method. public override void Subdivide(int iterations, SUBDIVISION_METHOD method = SUBDIVISION_METHOD.SQRT3) { try { var sub = SubdivisionSurface.Instance; sub.Subdivide(method, this, iterations); IsUpdated = false; } catch (NotImplementedException) { } catch (NotSupportedException) { }; } /// /// Simplify the polyhedra. /// /// A number between 0-1 that represents the percentage of vertices to remove. public override void Simplify(double stop_ratio) { try { var sim = SurfaceSimplification.Instance; sim.Simplify(this, stop_ratio); IsUpdated = false; } catch (NotImplementedException) { } catch (NotSupportedException) { }; } /// /// Refines a triangle mesh /// /// a factor to control density of the output mesh, /// where larger values lead to denser refinements. Defalus to sqrt of 2. /// The number of new vertices. public override int Refine(double density_control_factor = MathUtil.SQRT2_64) { try { IsUpdated = false; var meshing = MeshProcessingMeshing.Instance; return meshing.Refine(this, density_control_factor); } catch (NotImplementedException) { } catch (NotSupportedException) { }; return 0; } /// /// Orient the faces in the mesh. /// /// The orientation method. public override void Orient(ORIENTATE oriente) { try { IsUpdated = false; var orient = MeshProcessingOrientation.Instance; orient.Orient(oriente, this); } catch (NotImplementedException) { } catch (NotSupportedException) { }; } /// /// Reverses the orientation of the vertices in each face. /// public override void ReverseFaceOrientation() { Orient(ORIENTATE.REVERSE_FACE_ORIENTATIONS); } /// /// Split the mesh into its unconnected components. /// /// Each unconnect component as a new mesh. public void Split(List> results) { try { var con = MeshProcessingConnections.Instance; con.SplitUnconnectedComponents(this, results); } catch (NotImplementedException) { } catch (NotSupportedException) { }; } /// /// Remove all unconnected compontents except the largest. /// Largest is defined by the face count. /// /// The numbero of largest components to keep. /// The number of components removed in the mesh. public override int KeepLargest(int num_components_to_keep = 1) { try { var con = MeshProcessingConnections.Instance; return con.KeepLargestComponents(this, num_components_to_keep); } catch (NotImplementedException) { } catch (NotSupportedException) { }; return 0; } /// /// Copy the other mesh to this one. /// /// public void Join(SurfaceMesh3 other) { IsUpdated = false; Kernel.Join(Ptr, other.Ptr); } /// /// Create a mesh consisting of one polygon face. /// /// The faces polygon. /// Should the y coord of the points be used for the z coord. /// Thrown if the polygon is not simple. public void CreatePolygonMesh(Polygon2 polygon, bool xz) { if (!polygon.IsSimple) throw new InvalidOperationException("Polygon must be simple to convert to mesh mesh."); var points = polygon.ToArray(); CreatePolygonMesh(points, points.Length, xz); } /* /// /// Create the dual mesh where each face becomes a vertex /// and each vertex becomes a face. /// Must be a valid closed mesh to create the dual. /// /// The duel mesh. /// Is thrown if the mesh is not a valid closed mesh. public SurfaceMesh3 CreateDualMesh() { if (!IsValidClosedMesh) throw new InvalidOperationException("Mesh must be a valid closed mesh to create a dual mesh."); int faceCount = FaceCount; var points = new Point3d[faceCount]; GetCentroids(points, faceCount); var indices = GetDualPolygonalIndices(); var dual = new SurfaceMesh3(); dual.CreatePolygonalMesh(points, points.Length, indices); return dual; } */ /// /// Convert to a polyhedron mesh. /// /// The polyhedron mesh. public Polyhedron3 ToPolyhedronMesh() { var points = new Point3d[VertexCount]; GetPoints(points, points.Length); var indices = GetPolygonalIndices(); var mesh = new Polyhedron3(); mesh.CreatePolygonalMesh(points, points.Length, indices); return mesh; } /// /// Find the min, max and average edge lengths in the mesh /// /// The min, max and average edge lengths in the mesh. public override MinMaxAvg FindMinMaxAvgEdgeLength() { try { var fea = MeshProcessingFeatures.Instance; return fea.EdgeLengthMinMaxAvg(this); } catch (NotImplementedException) { } catch (NotSupportedException) { }; return new MinMaxAvg(); } /// /// Find the min, max and average face areas in the mesh /// /// The min, max and average face areas in the mesh. public override MinMaxAvg FindMinMaxAvgFaceArea() { try { var fea = MeshProcessingFeatures.Instance; return fea.FaceAreaMinMaxAvg(this); } catch (NotImplementedException) { } catch (NotSupportedException) { }; return new MinMaxAvg(); } /// /// Locate the face the rays hits. /// /// The ray. /// The hit result. public override MeshHitResult LocateFace(Ray3d ray) { try { var locate = MeshProcessingLocate.Instance; return locate.LocateFace(this, ray); } catch (NotImplementedException) { } catch (NotSupportedException) { }; return MeshHitResult.NoHitResult; } /// /// Find the face closest to the point. /// /// The point. /// The hit result. public override MeshHitResult ClosestFace(Point3d point) { try { var locate = MeshProcessingLocate.Instance; return locate.ClosestFace(this, point); } catch (NotImplementedException) { } catch (NotSupportedException) { }; return MeshHitResult.NoHitResult; } } /// /// The surface mesh abstract base class. /// public abstract class SurfaceMesh3 : CGALObject, IMesh { /// /// Cached values found by running Update. /// private bool m_isValid; private bool m_isClosed; private bool m_isTriangle; private bool m_isQuad; /// /// Default constructor. /// private SurfaceMesh3() { } /// /// Construct mesh with the kernel. /// /// The kernel internal SurfaceMesh3(CGALKernel kernel) { Kernel = kernel.SurfaceMeshKernel3; Ptr = Kernel.Create(); } /// /// Construct with a new kernel. /// /// The surface meshes kernel. /// The surface meshes pointer. internal SurfaceMesh3(CGALKernel kernel, IntPtr ptr) : base(ptr) { Kernel = kernel.SurfaceMeshKernel3; } /// /// The meshes kernel type. /// protected private SurfaceMeshKernel3 Kernel { get; private set; } /// /// The number of vertices in the mesh. /// public int VertexCount => Kernel.VertexCount(Ptr); /// /// The number of half edges in the mesh. /// public int HalfedgeCount => Kernel.HalfedgeCount(Ptr); /// /// The number of edges in the mesh. /// public int EdgeCount => Kernel.EdgeCount(Ptr); /// /// The number of faces in the mesh. /// public int FaceCount => Kernel.FaceCount(Ptr); /// /// The number of border edges. /// public int BorderEdgeCount => Kernel.BorderEdgeCount(Ptr); /// /// The current build stamp. /// public int BuildStamp => Kernel.GetBuildStamp(Ptr); /// /// The number of vertices currenly maked to be removed /// but have not. Calling collect garbage will remove them. /// /// The number of vertices marked to be removed. public int RemovedVertexCount => Kernel.RemovedVertexCount(Ptr); /// /// The number of halfedges currenly maked to be removed /// but have not. Calling collect garbage will remove them. /// /// The number of half edges marked to be removed. public int RemovedHalfedgeCount => Kernel.RemovedHalfedgeCount(Ptr); /// /// The number of edges currenly maked to be removed /// but have not. Calling collect garbage will remove them. /// /// The number of edges marked to be removed. public int RemovedEdgeCount => Kernel.RemovedEdgeCount(Ptr); /// /// The number of faces currenly maked to be removed /// but have not. Calling collect garbage will remove them. /// /// The number of face marked to be removed. public int RemovedFaceCount => Kernel.RemovedFaceCount(Ptr); /// /// Returns true if the meshl surface is combinatorially consistent. /// Must be a valid mesh to check many other properties. /// public bool IsValid { get { Update(); return m_isValid; } protected set { m_isValid = value; } } /// /// Returns true if there are no border edges. /// public bool IsClosed { get { Update(); return m_isClosed; } protected set { m_isClosed = value; } } /// /// Returns true if all faces are triangles. /// public bool IsTriangle { get { Update(); return m_isTriangle; } protected set { m_isTriangle = value; } } /// /// Returns true if all faces are quads. /// public bool IsQuad { get { Update(); return m_isQuad; } protected set { m_isQuad = value; } } /// /// Is the mesh a valid triangle mesh. /// public bool IsValidTriangleMesh => IsValid && IsTriangle; /// /// Is the mesh a valid closed mesh. /// public bool IsValidClosedMesh => IsValid && IsClosed; /// /// Is the mesh a valid closed triangle mesh. /// public bool IsValidClosedTriangleMesh => IsValid && IsClosed && IsTriangle; /// /// Has the update function been called. /// protected bool IsUpdated { get; set; } /// /// Mark the mesh as needing to be updated. /// public void SetIsUpdatedToFalse() { IsUpdated = false; } /// /// Clear the mesh. /// public void Clear() { IsUpdated = false; Kernel.Clear(Ptr); } /// /// Clear the index maps. /// The index maps are used to access the meshes elemnts by index. /// They are automaticaly created when a elements is accessed /// be a function requiring it. /// /// True to clear the vertex index map. /// True to clear the face index map. /// True to clear the edges index map. /// True to clear the halfedges index map. public void ClearIndexMaps(bool vertices, bool faces, bool edges, bool halfedges) { Kernel.ClearIndexMaps(Ptr, vertices, faces, edges, halfedges); } /// /// Clear the normal maps. /// /// True to clear the vertex normal map. /// True to clear the face normal map public void ClearNormalMaps(bool vertices, bool faces) { Kernel.ClearNormalMaps(Ptr, vertices, faces); } /// /// Clear the property maps. /// public void ClearProperyMaps() { Kernel.ClearProperyMaps(Ptr); } /// /// Build the index maps. /// The index maps are used to access the meshes elemnts by index. /// They are automaticaly created when a elements is accessed /// be a function requiring it but can be create ahead of time. /// /// True to build the vertex index maps. /// True to build the face index maps. /// True to build the edge index maps. /// True to build the halfedge index maps. /// The index maps wont be build if the mesh knows they are already built and upto date. /// Setting force to true will build them always. public void BuildIndices(bool vertices, bool faces, bool edges, bool halfedges, bool force = false) { Kernel.BuildIndices(Ptr, vertices, faces, edges, halfedges, force); } /// /// /// /// /// /// /// /// internal void PrintIndices(bool vertices, bool faces, bool edges, bool halfedges, bool force = false) { Kernel.PrintIndices(Ptr, vertices, faces, edges, halfedges, force); } /// /// Adds a vertex to the mesh. /// /// The vertices position /// The vertices index in the mesh. public int AddVertex(Point3d point) { IsUpdated = false; return Kernel.AddVertex(Ptr, point); } /// /// Adds a edge between the two vertices. /// /// The index of the vertex in the mesh. /// The index of the vertex in the mesh. /// The index of the edge in the mesh. public int AddEdge(int v0, int v1) { IsUpdated = false; return Kernel.AddEdge(Ptr, v0, v1); } /// /// Adds a triangle face to the mesh. /// /// The index of the vertex in the mesh. /// The index of the vertex in the mesh. /// The index of the vertex in the mesh. /// The index of the face in the mesh. public int AddTriangle(int v0, int v1, int v2) { IsUpdated = false; return Kernel.AddTriangle(Ptr, v0, v1, v2); } /// /// Adds a quad face to the mesh. /// /// The index of the vertex in the mesh. /// The index of the vertex in the mesh. /// The index of the vertex in the mesh. /// The index of the vertex in the mesh. /// The index of the face in the mesh. public int AddQuad(int v0, int v1, int v2, int v3) { IsUpdated = false; return Kernel.AddQuad(Ptr, v0, v1, v2, v3); } /// /// Adds a pentagon face to the mesh. /// /// The index of the vertex in the mesh. /// The index of the vertex in the mesh. /// The index of the vertex in the mesh. /// The index of the vertex in the mesh. /// The index of the vertex in the mesh. /// The index of the face in the mesh. public int AddPentagon(int v0, int v1, int v2, int v3, int v4) { IsUpdated = false; return Kernel.AddPentagon(Ptr, v0, v1, v2, v3, v4); } /// /// Adds a hexagon face to the mesh. /// /// The index of the vertex in the mesh. /// The index of the vertex in the mesh. /// The index of the vertex in the mesh. /// The index of the vertex in the mesh. /// The index of the vertex in the mesh. /// The index of the vertex in the mesh. /// The index of the face in the mesh. public int AddHexagon(int v0, int v1, int v2, int v3, int v4, int v5) { IsUpdated = false; return Kernel.AddHexagon(Ptr, v0, v1, v2, v3, v4, v5); } /// /// Add a polygon face to the mesh. /// /// The indices of the points in the mesm. /// The indices array length. /// The index of the face in the mesh. public int AddPolygon(int[] indices, int count) { ErrorUtil.CheckArray(indices, count); IsUpdated = false; return Kernel.AddFace(Ptr, indices, count); } /// /// Checks if any vertices, halfedges, edges, or faces are marked as removed. /// /// public bool HasGarbage => Kernel.HasGarbage(Ptr); /// /// Really removes vertices, halfedges, edges, and faces which are marked removed. /// By garbage collecting elements get new indices. In case you store indices in an /// auxiliary data structure or in a property these indices are potentially no /// longer refering to the right elements. /// public void CollectGarbage() { Kernel.CollectGarbage(Ptr); } /// /// Controls the recycling or not of simplices previously marked as removed /// upon addition of new elements. /// When set to true (default value), new elements are first picked in the /// garbage(if any) while if set to false only new elements are created. /// /// public bool DoesRecycleGarbage { get { return Kernel.DoesRecycleGarbage(Ptr); } set { Kernel.SetRecycleGarbage(Ptr, value); } } /// /// Array accessor for the polygon. /// Getting a point wraps around the polygon. /// /// /// public Point3d this[int i] { get => GetPoint(i); set => SetPoint(i, value); } /// /// Get the vertices point. /// /// The vertex index in the mesh. /// The vertices point. /// If index is out of range. public Point3d GetPoint(int index) { if(index < 0 || index >= VertexCount) throw new ArgumentOutOfRangeException("Index must be a number >= 0 and < count"); return Kernel.GetPoint(Ptr, index); } /// /// Get the points in the mesh. /// /// The array to copy points into. /// The point array length. public void GetPoints(Point3d[] points, int count) { ErrorUtil.CheckArray(points, count); Kernel.GetPoints(Ptr, points, count); } /// /// Set the point at the index. /// /// The points index /// The pointsam> /// If index is out of range. public void SetPoint(int index, Point3d point) { if (index < 0 || index >= VertexCount) throw new ArgumentOutOfRangeException("Index must be a number >= 0 and < count"); IsUpdated = false; Kernel.SetPoint(Ptr, index, point); } /// /// Set the points from a array. /// /// The point array. /// The point arrays length. public void SetPoints(Point3d[] points, int count) { ErrorUtil.CheckArray(points, count); IsUpdated = false; Kernel.SetPoints(Ptr, points, count); } /// /// Get a halfedges segment. /// /// The halfedges index. /// The segment. /// True if halfedge found. public bool GetSegment(int index, out Segment3d segment) { return Kernel.GetSegment(Ptr, index, out segment); } /// /// Get a segment for each halfedge in the mesh. /// /// The segment array. /// The segment array length. public void GetSegments(Segment3d[] segments, int count) { ErrorUtil.CheckArray(segments, count); Kernel.GetSegments(Ptr, segments, count); } /// /// Get the faces triangle. /// Presumes face is a triangle with no checks. /// /// The faces index. /// The faces triangle /// public bool GetTriangle(int index, out Triangle3d triangle) { return Kernel.GetTriangle(Ptr, index, out triangle); } /// /// Get a triangle for each face in the mesh. /// Presumes all faces are triangles with no checks. /// /// The trainagle array. /// The traingle arrays length. public void GetTriangles(Triangle3d[] triangles, int count) { ErrorUtil.CheckArray(triangles, count); Kernel.GetTriangles(Ptr, triangles, count); } /// /// Get the mesh vertex. /// /// The vertices index. /// The vertex. /// True if the vertex was found. public bool GetVertex(int index, out MeshVertex3 vertex) { return Kernel.GetVertex(Ptr, index, out vertex); } /// /// Get the mesh vertex. /// /// The vertices index. /// The vertex. public MeshVertex3 GetVertex(int index) { Kernel.GetVertex(Ptr, index, out MeshVertex3 vertex); return vertex; } /// /// Get the vertices in the mesh. /// /// The vertex array. /// The vertex array length. public void GetVertices(MeshVertex3[] vertices, int count) { ErrorUtil.CheckArray(vertices, count); Kernel.GetVertices(Ptr, vertices, count); } /// /// Get the mesh face. /// /// The faces index. /// The face. /// True if the face was found. public bool GetFace(int index, out MeshFace3 face) { return Kernel.GetFace(Ptr, index, out face); } /// /// Get the mesh face. /// /// The faces index. /// The face. public MeshFace3 GetFace(int index) { Kernel.GetFace(Ptr, index, out MeshFace3 face); return face; } /// /// Get the faces in the mesh. /// /// The face array. /// The face array length. public void GetFaces(MeshFace3[] faces, int count) { ErrorUtil.CheckArray(faces, count); Kernel.GetFaces(Ptr, faces, count); } /// /// Get the mesh halfedge. /// /// The halfedges index. /// The halfedge. /// True if the halfedge was found. public bool GetHalfedge(int index, out MeshHalfedge3 halfedge) { return Kernel.GetHalfedge(Ptr, index, out halfedge); } /// /// Get the mesh halfedge. /// /// The halfedges index. /// THe healfedge. public MeshHalfedge3 GetHalfedge(int index) { Kernel.GetHalfedge(Ptr, index, out MeshHalfedge3 halfedge); return halfedge; } /// /// Get the halfedges in the mesh. /// /// The halfedge array. /// The halfedge array length. public void GetHalfedges(MeshHalfedge3[] halfedges, int count) { ErrorUtil.CheckArray(halfedges, count); Kernel.GetHalfedges(Ptr, halfedges, count); } /// /// Returns the number of incident halfedges of vertex. /// /// The index of the vertex in the mesh. /// Returns the number of incident halfedges of vertex. public int VertexDegree(int vertex) { return Kernel.VertexDegree(Ptr, vertex); } /// /// Returns the number of incident halfedges of face. /// /// The index of the face in the mesh. /// Returns the number of incident halfedges of face. public int FaceDegree(int face) { return Kernel.FaceDegree(Ptr, face); } /// /// Returns whether vertex is isolated. /// /// The index of the vertex in the mesh. /// Returns whether vertex is isolated. public bool VertexIsIsolated(int vertex) { return Kernel.VertexIsIsolated(Ptr, vertex); } /// /// Returns whether vertex is a border vertex. /// If the data contained in the Surface_mesh is not /// a 2-manifold, then this operation is not /// guaranteed to return the right result. /// /// he index of the vertex in the mesh. /// With the default value for /// check_all_incident_halfedges the function iteratates over the incident /// halfedges. With check_all_incident_halfedges == false the function /// returns true, if the incident halfedge associated to vertex is a /// border halfedge, or if the vertex is isolated. /// Returns whether vertex is a border vertex. public bool VertexIsBorder(int vertex, bool check_all_incident_halfedges = true) { return Kernel.VertexIsBorder(Ptr, vertex, check_all_incident_halfedges); } /// /// Returns whether edge is a border edge, i.e., if any of its two halfedges is a border halfedge. /// /// The index of the edge in the mesh. /// Returns whether edge is a border edge. public bool EdgeIsBorder(int edge) { return Kernel.EdgeIsBorder(Ptr, edge); } /// /// Returns the next halfedge within the incident face. /// /// The index of the halfedge in the mesh. /// Returns the next halfedge within the incident face. public int NextHalfedge(int halfedge) { return Kernel.NextHalfedge(Ptr, halfedge); } /// /// Returns the previous halfedge within the incident face. /// /// The index of the halfedge in the mesh. /// Returns the previous halfedge within the incident face. public int PreviousHalfedge(int halfedge) { return Kernel.PreviousHalfedge(Ptr, halfedge); } /// /// Returns the opposite halfedge of halfedge. /// /// The index of the halfedge in the mesh. /// Returns the opposite halfedge of halfedge. public int OppositeHalfedge(int halfedge) { return Kernel.OppositeHalfedge(Ptr, halfedge); } /// /// Returns the vertex the halfedge emanates from. /// /// The index of the halfedge in the mesh. /// Returns the vertex the halfedge emanates from. public int SourceVertex(int halfedge) { return Kernel.SourceVertex(Ptr, halfedge); } /// /// Returns the vertex the halfedge points to. /// /// The index of the halfedge in the mesh. /// Returns the vertex the halfedge points to. public int TargetVertex(int halfedge) { return Kernel.TargetVertex(Ptr, halfedge); } /// /// Removes vertex from the halfedge data structure without adjusting anything. /// /// The index of the vertex in the mesh. /// True if face removed. public bool RemoveVertex(int vertex) { IsUpdated = false; return Kernel.RemoveVertex(Ptr, vertex); } /// /// Removes the two halfedges corresponding to edge from the halfedge /// data structure without adjusting anything. /// /// The index of the edge in the mesh. /// True if face removed. public bool RemoveEdge(int edge) { IsUpdated = false; return Kernel.RemoveEdge(Ptr, edge); } /// /// Removes face from the halfedge data structure without adjusting anything. /// /// The index of the face in the mesh. /// True if face removed. public bool RemoveFace(int face) { IsUpdated = false; return Kernel.RemoveFace(Ptr, face); } /// /// Has this vertex been marked to be removed. /// /// The vertices index in the mesh. /// Has this vertex been marked to be removed. public bool IsVertexRemoved(int index) { return Kernel.IsVertexRemoved(Ptr, index); } /// /// Has this face been marked to be removed. /// /// The faces index in the mesh. /// Has this face been marked to be removed. public bool IsFaceRemoved(int index) { return Kernel.IsFaceRemoved(Ptr, index); } /// /// Has this halfedge been marked to be removed. /// /// The halfedge index in the mesh. /// Has this halfedge been marked to be removed. public bool IsHalfedgeRemoved(int index) { return Kernel.IsHalfedgeRemoved(Ptr, index); } /// /// Has this edge been marked to be removed. /// /// The edges index in the mesh. /// Has this edge been marked to be removed. public bool IsEdgeRemoved(int index) { return Kernel.IsEdgeRemoved(Ptr, index); } /// /// Performs a validity check on a single vertex. /// /// The index of the vertex in the mesh. /// True if valid. public bool IsVertexValid(int vertex) { return Kernel.IsVertexValid(Ptr, vertex); } /// /// Performs a validity check on a single edge. /// /// The index of the edge in the mesh. /// True if valid. public bool IsEdgeValid(int edge) { return Kernel.IsEdgeValid(Ptr, edge); } /// /// Performs a validity check on a single halfedge. /// /// The index of the halfedge in the mesh. /// True if valid. public bool IsHalfedgeValid(int halfedge) { return Kernel.IsHalfedgeValid(Ptr, halfedge); } /// /// Performs a validity check on a single face. /// /// The index of the face in the mesh. /// True if valid. public bool IsFaceValid(int face) { return Kernel.IsFaceValid(Ptr, face); } /// /// Translate each point in the mesh. /// /// The amount to translate. public void Translate(Point3d translation) { IsUpdated = false; var m = Matrix4x4d.Translate(translation); Kernel.Transform(Ptr, m); } /// /// Rotate each point in the mesh. /// /// The amount to rotate. public void Rotate(Quaternion3d rotation) { IsUpdated = false; var m = rotation.ToMatrix4x4d(); Kernel.Transform(Ptr, m); } /// /// Scale each point in the mesh. /// /// The amount to scale. public void Scale(Point3d scale) { IsUpdated = false; var m = Matrix4x4d.Scale(scale); Kernel.Transform(Ptr, m); } /// /// Transform each point in the mesh. /// /// The amount to translate. /// The amount to rotate. /// The amount to scale. public void Transform(Point3d translation, Quaternion3d rotation, Point3d scale) { IsUpdated = false; var m = Matrix4x4d.TranslateRotateScale(translation, rotation, scale); Kernel.Transform(Ptr, m); } /// /// Create a mesh from the points and indices. /// /// The meshes points. /// The meshes triangles as a index array. Maybe null. /// The meshes quads as a index array. Maybe null. public void CreateMesh(Point3d[] points, int[] triangles, int[] quads = null) { bool hasTriangles = triangles != null && triangles.Length > 0; bool hasQuads = quads != null && quads.Length > 0; if (hasTriangles && hasQuads) CreateTriangleQuadMesh(points, points.Length, triangles, triangles.Length, quads, quads.Length); else if (hasTriangles) CreateTriangleMesh(points, points.Length, triangles, triangles.Length); else if (hasQuads) CreateQuadMesh(points, points.Length, quads, quads.Length); } /// /// Create a triangle mesh from the points and indices. /// /// The meshes points. /// The point arrays length. /// The meshes trinagles as a index array. /// The indices array length. public void CreateTriangleMesh(Point3d[] points, int pointCount, int[] indices, int indexCount) { ErrorUtil.CheckArray(points, pointCount); ErrorUtil.CheckArray(indices, indexCount); Clear(); IsUpdated = false; Kernel.CreatePolygonalMesh(Ptr, points, pointCount, indices, indexCount, null, 0, null, 0, null, 0); } /// /// Create a quad mesh from the points and indices. /// /// The meshes points. /// The point arrays length. /// The meshes trinagles as a index array. /// The indices array length. public void CreateQuadMesh(Point3d[] points, int pointCount, int[] indices, int indexCount) { ErrorUtil.CheckArray(points, pointCount); ErrorUtil.CheckArray(indices, indexCount); Clear(); IsUpdated = false; Kernel.CreatePolygonalMesh(Ptr, points, pointCount, null, 0, indices, indexCount, null, 0, null, 0); } /// /// Create a mesh with quads and triangles. /// /// The meshes points. /// The point array length. /// The meshes triangles. /// The triangle array length. /// The meshes quads. /// The quads array length. public void CreateTriangleQuadMesh(Point3d[] points, int pointsCount, int[] triangles, int triangleCount, int[] quads, int quadsCount) { ErrorUtil.CheckArray(points, pointsCount); ErrorUtil.CheckArray(triangles, triangleCount); ErrorUtil.CheckArray(quads, quadsCount); Clear(); IsUpdated = false; Kernel.CreatePolygonalMesh(Ptr, points, pointsCount, triangles, triangleCount, quads, quadsCount, null, 0, null, 0); } /// /// Create a mesh with riangles, quads, pentagons and hexagons. /// /// The meshs points. /// The length of the point array. /// The faces indices. public void CreatePolygonalMesh(Point3d[] points, int pointsCount, PolygonalIndices indices) { ErrorUtil.CheckArray(points, pointsCount); ErrorUtil.CheckArray(indices.triangles, indices.triangleCount); ErrorUtil.CheckArray(indices.quads, indices.quadCount); ErrorUtil.CheckArray(indices.pentagons, indices.pentagonCount); ErrorUtil.CheckArray(indices.hexagons, indices.hexagonCount); Clear(); IsUpdated = false; Kernel.CreatePolygonalMesh(Ptr, points, pointsCount, indices.triangles, indices.triangleCount, indices.quads, indices.quadCount, indices.pentagons, indices.pentagonCount, indices.hexagons, indices.hexagonCount); } /// /// Create a mesh consisting of one polygon face. /// /// The faces points /// The paoint array length. /// Should the y coord of the points be used for the z coord. public void CreatePolygonMesh(Point2d[] points, int count, bool xz) { ErrorUtil.CheckArray(points, count); Clear(); IsUpdated = false; Kernel.CreatePolygonMesh(Ptr, points, count, xz); } /// /// Get the triangle and quad indices. /// /// The meshes triangles as a index array. Maybe null. /// The meshes quads as a index array. Maybe null. public void GetIndices(int[] triangles, int[] quads = null) { bool hasTriangles = triangles != null && triangles.Length > 0; bool hasQuads = quads != null && quads.Length > 0; if (hasTriangles && hasQuads) GetTriangleQuadIndices(triangles, triangles.Length, quads, quads.Length); else if (hasTriangles) GetTriangleIndices(triangles, triangles.Length); else if (hasQuads) GetQuadIndices(quads, quads.Length); } /// /// Get the meshes triangles. /// /// The meshes triangles. /// The triangle array length. public void GetTriangleIndices(int[] triangles, int trianglesCount) { ErrorUtil.CheckArray(triangles, trianglesCount); Kernel.GetPolygonalIndices(Ptr, triangles, trianglesCount, null, 0, null, 0, null, 0); } /// /// Get the meshes quads. /// /// The meshes quads. /// The quads array length. public void GetQuadIndices(int[] quads, int quadsCount) { ErrorUtil.CheckArray(quads, quadsCount); Kernel.GetPolygonalIndices(Ptr, null, 0, quads, quadsCount, null, 0, null, 0); } /// /// Get the meshes triangles and quads. /// /// The meshes triangles. /// The triangle array length. /// The meshes quads. /// The quads array length. public void GetTriangleQuadIndices(int[] triangles, int trianglesCount, int[] quads, int quadsCount) { ErrorUtil.CheckArray(triangles, trianglesCount); ErrorUtil.CheckArray(quads, quadsCount); Kernel.GetPolygonalIndices(Ptr, triangles, trianglesCount, quads, quadsCount, null, 0, null, 0); } /// /// Get the meshes triangles, quads, pentagons and hexagons. /// /// The indices. public PolygonalIndices GetPolygonalIndices() { var count = GetPolygonalCount(); var indices = count.Indices(); Kernel.GetPolygonalIndices(Ptr, indices.triangles, indices.triangleCount, indices.quads, indices.quadCount, indices.pentagons, indices.pentagonCount, indices.hexagons, indices.hexagonCount); return indices; } /* /// /// Get the dual meshes triangles, quads, pentagons and hexagons. /// A dual mesh is were faces become vertices and vertices become faces. /// /// The indices public PolygonalIndices GetDualPolygonalIndices() { var count = GetDualPolygonalCount(); var indices = count.Indices(); Kernel.GetDualPolygonalIndices(Ptr, indices.triangles, indices.triangleCount, indices.quads, indices.quadCount, indices.pentagons, indices.pentagonCount, indices.hexagons, indices.hexagonCount); return indices; } */ /// /// Whether v is a border vertex. /// /// The vertices index. /// With the default value for /// check_all_incident_halfedges the function iteratates over the incident halfedges. /// With check_all_incident_halfedges == false the function returns true, /// if the incident halfedge associated to vertex v is a border halfedge, /// or if the vertex is isolated. /// Whether v is a border vertex. public bool IsVertexBorder(int index, bool check_all_incident_halfedges) { return Kernel.IsVertexBorder(Ptr, index, check_all_incident_halfedges); } /// /// Whether half edge is a border halfege, that is if its incident face is null. /// /// The halfedges index. /// Whether half edge is a border halfege. public bool IsHalfedgeBorder(int index) { return Kernel.IsHalfedgeBorder(Ptr, index); } /// /// Whether e is a border edge, i.e., if any of its two halfedges is a border halfedge. /// /// The edges index. /// Whether e is a border edge. public bool IsEdgeBorder(int index) { return Kernel.IsEdgeBorder(Ptr, index); } /// /// Count the number of triangles, quads and polygons in the mesh. /// /// The number of triangles, quads and polygons in the mesh. public PolygonalCount GetPolygonalCount() { return Kernel.GetPolygonalCount(Ptr); } /// /// Count the number of triangles, quads and polygons in the dual mesh. /// A dual mesh is were faces become vertices and vertices become faces. /// /// The number of triangles, quads and polygons in the mesh. public PolygonalCount GetDualPolygonalCount() { return Kernel.GetDualPolygonalCount(Ptr); } /// /// Build the aabb tree. /// public void BuildAABBTree() { Kernel.BuildAABBTree(Ptr); } /// /// Release the aabb tree. /// public void ReleaseAABBTree() { Kernel.ReleaseAABBTree(Ptr); } /// /// Find the bounding box of the meshes points. /// /// public Box3d FindBoundingBox() { return Kernel.GetBoundingBox(Ptr); } /// /// Read the mesh from a off file format. /// /// The files name. public void ReadOFF(string filename) { IsUpdated = false; Kernel.ReadOFF(Ptr, filename); } /// /// Write the mesh to off file format. /// /// The files name. public void WriteOFF(string filename) { Kernel.WriteOFF(Ptr, filename); } /// /// Make all faces triangles. /// public void Triangulate() { if (!IsValid || IsTriangle) return; IsUpdated = false; Kernel.Triangulate(Ptr); } /// /// Tests if a set of faces of a triangulated surface mesh self-intersects. /// Must be a triangle mesh. /// /// True/Fasle if a valid triangle mesh,or UNDETERMINED if not. public BOOL_OR_UNDETERMINED DoesSelfIntersect() { if (IsValidTriangleMesh) return Kernel.DoesSelfIntersect(Ptr).ToBoolOrUndetermined(); else return BOOL_OR_UNDETERMINED.UNDETERMINED; } /// /// Perform an expensive validity check on the data structure. /// /// If the mesh is valid. public bool FindIfValid() { return Kernel.IsValid(Ptr); } /// /// Find if all the faces in the mesh are triangles. /// /// True if all the faces in the mesh are triangles, Will be undetermined if no a valid mesh. public BOOL_OR_UNDETERMINED FindIfTriangleMesh() { if (IsValid) return Kernel.CheckFaceVertexCount(Ptr, 3).ToBoolOrUndetermined(); else return BOOL_OR_UNDETERMINED.UNDETERMINED; } /// /// Find if all the faces in the mesh are quads. /// /// True if all the faces in the mesh are quads, Will be undetermined if no a valid mesh. public BOOL_OR_UNDETERMINED FindIfQuadMesh() { if (IsValid) return Kernel.CheckFaceVertexCount(Ptr, 4).ToBoolOrUndetermined(); else return BOOL_OR_UNDETERMINED.UNDETERMINED; } /// /// Find if the mesh is closed, ie has no border edges. /// //// True if all closed, Will be undetermined if no a valid mesh. public BOOL_OR_UNDETERMINED FindIfClosed() { if (IsValid) return Kernel.IsClosed(Ptr).ToBoolOrUndetermined(); else return BOOL_OR_UNDETERMINED.UNDETERMINED; } /// /// Computes the area of a range of faces /// of a given triangulated surface mesh. /// /// The area or 0 if mesh is not valid triangle mesh. public double FindArea() { if (IsValidTriangleMesh) return Kernel.Area(Ptr); else return 0; } /// /// computes the centroid of a volume bounded /// by a closed triangulated surface mesh. /// /// The centroid or 0 if mesh is not valid. public Point3d FindCentroid() { if (IsValid) return Kernel.Centroid(Ptr); else return Point3d.Zero; } /// /// Computes the volume of the domain bounded by a /// closed triangulated surface mesh. /// /// The volume or 0 if mesh is not valid closed triangle mesh. public double FindVolume() { if (IsValidClosedTriangleMesh) return Kernel.Volume(Ptr); else return 0; } /// /// Indicates if the mesh bounds a volume. /// Must be a closed and triangulated. /// /// True/Fasle if a valid triangle closed mesh,or UNDETERMINED if not. public BOOL_OR_UNDETERMINED FindIfDoesBoundAVolume() { if (IsValidClosedTriangleMesh) return Kernel.DoesBoundAVolume(Ptr).ToBoolOrUndetermined(); else return BOOL_OR_UNDETERMINED.UNDETERMINED; } /// /// Find what side of the mesh the lies in. /// /// The point to check. /// ON_BOUNDED_SIDE if point inside mesh, /// ON_UNBOUNDED_SIDE if point not inside, /// ON_BOUNDARY if point is on the surface. public BOUNDED_SIDE BoundedSide(Point3d point) { if (IsValid) return Kernel.SideOfTriangleMesh(Ptr, point); else return BOUNDED_SIDE.UNDETERMINED; } /// /// Does the mesh contain the point. /// /// The point. /// If point is on the boundary does it count a being contained. /// True if the poly contains the point public bool ContainsPoint(Point3d point, bool includeBoundary = true) { var side = BoundedSide(point); if (side == BOUNDED_SIDE.UNDETERMINED) return false; if (side == BOUNDED_SIDE.ON_BOUNDED_SIDE) return true; if (includeBoundary && side == BOUNDED_SIDE.ON_BOUNDARY) return true; return false; } /// /// Locate the face the rays hits. /// /// The ray. /// The hit result. public abstract MeshHitResult LocateFace(Ray3d ray); /// /// Find the face closest to the point. /// /// The point. /// The hit result. public abstract MeshHitResult ClosestFace(Point3d point); /// /// Locate the face hit by the ray. /// /// The ray. /// The hit face. /// True if the ray hit a face. public bool LocateFace(Ray3d ray, out MeshFace3 face) { var result = LocateFace(ray); if (result.Hit && GetFace(result.Face, out face)) { return true; } else { face = MeshFace3.NullFace; return false; } } /// /// Locate the vertex hit by the ray. /// /// The ray. /// The distance the vertex has to be within hit point. /// The hit vertex. /// True if the ray hit a vertex. public bool LocateVertex(Ray3d ray, double radius, out MeshVertex3 vertex) { var result = LocateFace(ray); if (result.Hit && GetFace(result.Face, out MeshFace3 face)) { double minSqDist = double.PositiveInfinity; var closest = MeshVertex3.NullVertex; foreach (var v in face.EnumerateVertices(this)) { var sqdist = Point3d.SqrDistance(result.Point, v.Point); if (sqdist < minSqDist) { minSqDist = sqdist; closest = v; } } if (closest.Index != CGALGlobal.NULL_INDEX && minSqDist < radius * radius) { vertex = closest; return true; } else { vertex = MeshVertex3.NullVertex; return false; } } else { vertex = MeshVertex3.NullVertex; return false; } } /// /// Locate the edge hit by the ray. /// /// The ray. /// The distance the edge has to be within hit point. /// The hit edge. /// True if the ray hit a edge. public bool LocateHalfedge(Ray3d ray, double radius, out MeshHalfedge3 edge) { var result = LocateFace(ray); if (result.Hit && GetFace(result.Face, out MeshFace3 face)) { double minSqDist = double.PositiveInfinity; var closest = MeshHalfedge3.NullHalfedge; MeshVertex3 source, target; Segment3d seg; foreach (var e in face.EnumerateHalfedges(this)) { if (!GetVertex(e.Source, out source)) continue; if (!GetVertex(e.Target, out target)) continue; seg.A = source.Point; seg.B = target.Point; var p = seg.Closest(result.Point); var sqdist = Point3d.SqrDistance(result.Point, p); if (sqdist < minSqDist) { minSqDist = sqdist; closest = e; } } if (closest.Index != CGALGlobal.NULL_INDEX && minSqDist < radius * radius) { edge = closest; return true; } else { edge = MeshHalfedge3.NullHalfedge; return false; } } else { edge = MeshHalfedge3.NullHalfedge; return false; } } /// /// Returns true if there exists a face of this poly and /// a face of other mesh which intersect, and false otherwise. /// Must be a triangle mesh /// /// The other triangle poly. /// If test_bounded_sides is set to true, /// the overlap of bounded sides are tested as well. In that case, the meshes must be closed. /// True/Fasle if a valid triangle closed mesh,or UNDETERMINED if not. public BOOL_OR_UNDETERMINED DoIntersect(SurfaceMesh3 mesh, bool test_bounded_sides = true) { if (IsValidTriangleMesh && mesh.IsValidTriangleMesh) { //if test bounded side both must be closed meshes. //If not test bounded side does not matter if not closed. if ((test_bounded_sides && IsClosed && mesh.IsClosed) || !test_bounded_sides) { return Kernel.DoIntersects(Ptr, mesh.Ptr, test_bounded_sides).ToBoolOrUndetermined(); } else return BOOL_OR_UNDETERMINED.UNDETERMINED; } else return BOOL_OR_UNDETERMINED.UNDETERMINED; } /// /// Find the min, max and average edge lengths in the mesh /// /// The min, max and average edge lengths in the mesh. public abstract MinMaxAvg FindMinMaxAvgEdgeLength(); /// /// Find the min, max and average face areas in the mesh /// /// The min, max and average face areas in the mesh. public abstract MinMaxAvg FindMinMaxAvgFaceArea(); /// /// Subdive the mesh. /// /// The number of iterations to perfrom. /// The subdivision method. public abstract void Subdivide(int iterations, SUBDIVISION_METHOD method = SUBDIVISION_METHOD.SQRT3); /// /// Simplify the polyhedra. /// /// A number between 0-1 that represents the percentage of vertices to remove. public abstract void Simplify(double stop_ratio); /// /// Refines a triangle mesh /// /// a factor to control density of the output mesh, /// where larger values lead to denser refinements. Defalus to sqrt of 2. /// The number of new vertices. public abstract int Refine(double density_control_factor = MathUtil.SQRT2_64); /// /// Orient the faces in the mesh. /// /// The orientation method. public abstract void Orient(ORIENTATE orientate); /// /// Reverses the orientation of the vertices in each face. /// public abstract void ReverseFaceOrientation(); /// /// Remove all unconnected compontents except the largest. /// Largest is defined by the face count. /// /// The numbero of largest components to keep. /// The number of components removed in the mesh. public abstract int KeepLargest(int num_components_to_keep = 1); /// /// Get a centroid (the avergae face position) for each face in the mesh. /// /// The point array. /// The points arrays lemgth. public void GetCentroids(Point3d[] points, int count) { ErrorUtil.CheckArray(points, count); Kernel.GetCentroids(Ptr, points, count); } /// /// Compute the vertex normal map. /// Will only be computed if mesh has /// changed since last computation or /// no current nomral maps have been computed. /// public void ComputeVertexNormals() { Kernel.ComputeVertexNormals(Ptr); } /// /// Compute the face normal map. /// Will only be computed if mesh has /// changed since last computation or /// no current nomral maps have been computed. /// public void ComputeFaceNormals() { Kernel.ComputeFaceNormals(Ptr); } /// /// Get the vertex normals. /// Will be compute if they have not aready. /// /// The normal map array. /// The normal maps array length. public void GetVertexNormals(Vector3d[] normals, int count) { Kernel.GetVertexNormals(Ptr, normals, count); } /// /// Get the face normals. /// Will be compute if they have not aready. /// /// The normal map array. /// The normal maps array length. public void GetFaceNormals(Vector3d[] normals, int count) { Kernel.GetFaceNormals(Ptr, normals, count); } /// /// Enumerate all points in the mesh. /// /// Each point in mesh. public IEnumerator GetEnumerator() { for (int i = 0; i < VertexCount; i++) yield return GetPoint(i); } /// /// Enumerate all points in the mesh. /// /// Each point in mesh. IEnumerator IEnumerable.GetEnumerator() { return GetEnumerator(); } /// /// Return all the points in the mesh in a array. /// /// The array. public Point3d[] ToArray() { var points = new Point3d[VertexCount]; GetPoints(points, points.Length); return points; } /// /// Return all the points in the mesh in a list. /// /// The list. public List ToList() { int count = VertexCount; var points = new List(count); for (int i = 0; i < count; i++) points.Add(GetPoint(i)); return points; } /// /// Update the mesh if needed. /// protected void Update() { if (IsUpdated) return; IsUpdated = true; if (FindIfValid()) { m_isValid = true; m_isClosed = FindIfClosed().ToBool(); m_isTriangle = FindIfTriangleMesh().ToBool(); m_isQuad = FindIfQuadMesh().ToBool(); } else { m_isValid = false; m_isClosed = false; m_isTriangle = false; m_isQuad = false; } } /// /// Print the mesh into a string builder. /// /// public override void Print(StringBuilder builder) { builder.AppendLine(ToString()); builder.AppendLine("BuildStamp = " + BuildStamp); builder.AppendLine("IsValid = " + IsValid); builder.AppendLine("VertexCount = " + VertexCount); builder.AppendLine("FaceCount = " + FaceCount); builder.AppendLine("EdgeCount = " + EdgeCount); builder.AppendLine("RemovedVertexCount = " + RemovedVertexCount); builder.AppendLine("RemovedFaceCount = " + RemovedFaceCount); builder.AppendLine("RemovedHalfdgeCount = " + RemovedHalfedgeCount); builder.AppendLine("RemovedEdgeCount = " + RemovedEdgeCount); builder.AppendLine("BorderEdgeCount = " + BorderEdgeCount); builder.AppendLine("HasGarbage = " + HasGarbage); builder.AppendLine("IsTriangle = " + IsTriangle); builder.AppendLine("IsQuad = " + IsQuad); builder.AppendLine("IsClosed = " + IsClosed); } /// /// /// internal void PrintVertices() { foreach(var p in this) Console.WriteLine(p); } /// /// Release any unmanaged resources. /// protected override void ReleasePtr() { Kernel.Release(Ptr); } } } ================================================ FILE: CGALDotNet/Polyhedra/SurfaceMeshFactory.cs ================================================ using System; using System.Collections.Generic; using System.Text; using CGALDotNetGeometry.Numerics; using CGALDotNetGeometry.Shapes; using CGALDotNet.Processing; namespace CGALDotNet.Polyhedra { public static class SurfaceMeshFactory where K : CGALKernel, new() { private static IndexList triangleList = IndexList.CreateTriangleIndexList(); private static IndexList polygonList = IndexList.CreatePolygonIndexList(); public static Dictionary> CreateAll(bool allowPolygons = false) { var meshes = new Dictionary>(); meshes.Add("Cube", CreateCube(1, allowPolygons)); meshes.Add("Plane", CreatePlane(allowPolygons)); meshes.Add("Torus", CreateTorus(allowPolygons)); meshes.Add("Cone", CreateCone(allowPolygons)); meshes.Add("Cylinder", CreateCylinder(allowPolygons)); meshes.Add("Capsule", CreateCapsule(allowPolygons)); meshes.Add("UVSphere", CreateUVSphere(allowPolygons)); meshes.Add("NormalizedCube", CreateNormalizedCube(allowPolygons)); meshes.Add("Icosahedron", CreateIcosahedron()); meshes.Add("Tetrahedron", CreateTetrahedron()); meshes.Add("Octahedron", CreateOctahedron()); meshes.Add("Dodecahedron", CreateDodecahedron(1, allowPolygons)); return meshes; } public static SurfaceMesh3 CreateCube(double scale = 1, bool allowPolygons = false) { var mesh = new SurfaceMesh3(); if (allowPolygons) { polygonList.Clear(); MeshFactory.CreateCube(polygonList, scale); var indices = polygonList.ToIndices(); var points = polygonList.points.ToArray(); mesh.CreatePolygonalMesh(points, points.Length, indices); } else { triangleList.Clear(); MeshFactory.CreateCube(triangleList, scale); mesh.CreateMesh(triangleList.points.ToArray(), triangleList.triangles.ToArray()); } return mesh; } public static SurfaceMesh3 CreateCube(Box3d box, bool allowPolygons = false) { var mesh = new SurfaceMesh3(); if (allowPolygons) { polygonList.Clear(); MeshFactory.CreateCube(polygonList, box); var indices = polygonList.ToIndices(); var points = polygonList.points.ToArray(); mesh.CreatePolygonalMesh(points, points.Length, indices); } else { triangleList.Clear(); MeshFactory.CreateCube(triangleList, box); mesh.CreateMesh(triangleList.points.ToArray(), triangleList.triangles.ToArray()); } return mesh; } public static SurfaceMesh3 CreatePlane(bool allowPolygons = false) { return CreatePlane(PlaneParams.Default, allowPolygons); } public static SurfaceMesh3 CreatePlane(PlaneParams param, bool allowPolygons = false) { var mesh = new SurfaceMesh3(); if (allowPolygons) { polygonList.Clear(); MeshFactory.CreatePlane(polygonList, param); var indices = polygonList.ToIndices(); var points = polygonList.points.ToArray(); mesh.CreatePolygonalMesh(points, points.Length, indices); } else { triangleList.Clear(); MeshFactory.CreatePlane(triangleList, param); mesh.CreateMesh(triangleList.points.ToArray(), triangleList.triangles.ToArray()); } return mesh; } public static SurfaceMesh3 CreateTorus(bool allowPolygons = false) { return CreateTorus(TorusParams.Default, allowPolygons); } public static SurfaceMesh3 CreateTorus(TorusParams param, bool allowPolygons = false) { var mesh = new SurfaceMesh3(); if (allowPolygons) { polygonList.Clear(); MeshFactory.CreateTorus(polygonList, param); var indices = polygonList.ToIndices(); var points = polygonList.points.ToArray(); mesh.CreatePolygonalMesh(points, points.Length, indices); } else { triangleList.Clear(); MeshFactory.CreateTorus(triangleList, param); mesh.CreateMesh(triangleList.points.ToArray(), triangleList.triangles.ToArray()); } WeldVertices(mesh); return mesh; } public static SurfaceMesh3 CreateCone(bool allowPolygons = false) { return CreateCone(ConeParams.Default, allowPolygons); } public static SurfaceMesh3 CreateCone(ConeParams param, bool allowPolygons = false) { return CreateCylinder(param.AsCylinderParam(), allowPolygons); } public static SurfaceMesh3 CreateCylinder(bool allowPolygons = false) { return CreateCylinder(CylinderParams.Default, allowPolygons); } public static SurfaceMesh3 CreateCylinder(CylinderParams param, bool allowPolygons = false) { var mesh = new SurfaceMesh3(); if (allowPolygons) { polygonList.Clear(); MeshFactory.CreateCylinder(polygonList, param); var indices = polygonList.ToIndices(); var points = polygonList.points.ToArray(); mesh.CreatePolygonalMesh(points, points.Length, indices); } else { triangleList.Clear(); MeshFactory.CreateCylinder(triangleList, param); mesh.CreateMesh(triangleList.points.ToArray(), triangleList.triangles.ToArray()); } WeldVertices(mesh); return mesh; } public static SurfaceMesh3 CreateCapsule(bool allowPolygons = false) { return CreateCapsule(CapsuleParams.Default, allowPolygons); } public static SurfaceMesh3 CreateCapsule(CapsuleParams param, bool allowPolygons = false) { var mesh = new SurfaceMesh3(); if (allowPolygons) { polygonList.Clear(); MeshFactory.CreateCapsule(polygonList, param); var indices = polygonList.ToIndices(); var points = polygonList.points.ToArray(); mesh.CreatePolygonalMesh(points, points.Length, indices); } else { triangleList.Clear(); MeshFactory.CreateCapsule(triangleList, param); mesh.CreateMesh(triangleList.points.ToArray(), triangleList.triangles.ToArray()); } WeldVertices(mesh); return mesh; } public static SurfaceMesh3 CreateUVSphere(bool allowPolygons = false) { return CreateUVSphere(UVSphereParams.Default, allowPolygons); } public static SurfaceMesh3 CreateUVSphere(UVSphereParams param, bool allowPolygons = false) { var mesh = new SurfaceMesh3(); if (allowPolygons) { polygonList.Clear(); MeshFactory.CreateUVSphere(polygonList, param); var indices = polygonList.ToIndices(); var points = polygonList.points.ToArray(); mesh.CreatePolygonalMesh(points, points.Length, indices); } else { triangleList.Clear(); MeshFactory.CreateUVSphere(triangleList, param); mesh.CreateMesh(triangleList.points.ToArray(), triangleList.triangles.ToArray()); } return mesh; } public static SurfaceMesh3 CreateNormalizedCube(bool allowPolygons = false) { return CreateNormalizedCube(NormalizedCubeParams.Default, allowPolygons); } public static SurfaceMesh3 CreateNormalizedCube(NormalizedCubeParams param, bool allowPolygons = false) { var mesh = new SurfaceMesh3(); if (allowPolygons) { polygonList.Clear(); MeshFactory.CreateNormalizedCube(polygonList, param); var indices = polygonList.ToIndices(); var points = polygonList.points.ToArray(); mesh.CreatePolygonalMesh(points, points.Length, indices); } else { triangleList.Clear(); MeshFactory.CreateNormalizedCube(triangleList, param); mesh.CreateMesh(triangleList.points.ToArray(), triangleList.triangles.ToArray()); } WeldVertices(mesh); return mesh; } public static SurfaceMesh3 CreateTetrahedron(double scale = 1) { triangleList.Clear(); MeshFactory.CreateTetrahedron(triangleList, scale); var mesh = new SurfaceMesh3(); mesh.CreateMesh(triangleList.points.ToArray(), triangleList.triangles.ToArray()); return mesh; } public static SurfaceMesh3 CreateIcosahedron(double scale = 1) { triangleList.Clear(); MeshFactory.CreateIcosahedron(triangleList, scale); var mesh = new SurfaceMesh3(); mesh.CreateMesh(triangleList.points.ToArray(), triangleList.triangles.ToArray()); return mesh; } public static SurfaceMesh3 CreateOctahedron(double scale = 1) { triangleList.Clear(); MeshFactory.CreateOctahedron(triangleList, scale); var mesh = new SurfaceMesh3(); mesh.CreateMesh(triangleList.points.ToArray(), triangleList.triangles.ToArray()); return mesh; } public static SurfaceMesh3 CreateDodecahedron(double scale = 1, bool allowPolygons = false) { var mesh = new SurfaceMesh3(); if (allowPolygons) { polygonList.Clear(); MeshFactory.CreateDodecahedron(polygonList, scale); var indices = polygonList.ToIndices(); var points = polygonList.points.ToArray(); mesh.CreatePolygonalMesh(points, points.Length, indices); } else { triangleList.Clear(); MeshFactory.CreateDodecahedron(triangleList, scale); mesh.CreateMesh(triangleList.points.ToArray(), triangleList.triangles.ToArray()); } return mesh; } private static void WeldVertices(SurfaceMesh3 mesh) { var repair = MeshProcessingRepair.Instance; repair.RepairPolygonSoup(mesh); } } } ================================================ FILE: CGALDotNet/Polyhedra/SurfaceMeshKernel3.cs ================================================ using System; using System.Collections.Generic; using System.Runtime.InteropServices; using System.Text; using CGALDotNetGeometry.Numerics; using CGALDotNetGeometry.Shapes; namespace CGALDotNet.Polyhedra { internal abstract class SurfaceMeshKernel3 : CGALObjectKernel { internal abstract IntPtr Create(); internal abstract void Release(IntPtr ptr); internal abstract int GetBuildStamp(IntPtr ptr); internal abstract void Clear(IntPtr ptr); internal abstract void ClearIndexMaps(IntPtr ptr, bool vertices, bool faces, bool edges, bool halfedges); internal abstract void ClearNormalMaps(IntPtr ptr, bool vertices, bool faces); internal abstract void ClearProperyMaps(IntPtr ptr); internal abstract void BuildIndices(IntPtr ptr, bool vertices, bool faces, bool edges, bool halfedges, bool force); internal abstract void PrintIndices(IntPtr ptr, bool vertices, bool faces, bool edges, bool halfedges, bool force); internal abstract IntPtr Copy(IntPtr ptr); internal abstract bool IsValid(IntPtr ptr); internal abstract int VertexCount(IntPtr ptr); internal abstract int HalfedgeCount(IntPtr ptr); internal abstract int EdgeCount(IntPtr ptr); internal abstract int FaceCount(IntPtr ptr); internal abstract int RemovedVertexCount(IntPtr ptr); internal abstract int RemovedHalfedgeCount(IntPtr ptr); internal abstract int RemovedEdgeCount(IntPtr ptr); internal abstract int RemovedFaceCount(IntPtr ptr); internal abstract bool IsVertexRemoved(IntPtr ptr, int index); internal abstract bool IsFaceRemoved(IntPtr ptr, int index); internal abstract bool IsHalfedgeRemoved(IntPtr ptr, int index); internal abstract bool IsEdgeRemoved(IntPtr ptr, int index); internal abstract int AddVertex(IntPtr ptr, Point3d point); internal abstract int AddEdge(IntPtr ptr, int v0, int v1); internal abstract int AddTriangle(IntPtr ptr, int v0, int v1, int v2); internal abstract int AddQuad(IntPtr ptr, int v0, int v1, int v2, int v3); internal abstract int AddPentagon(IntPtr ptr, int v0, int v1, int v2, int v3, int v4); internal abstract int AddHexagon(IntPtr ptr, int v0, int v1, int v2, int v3, int v4, int v5); internal abstract int AddFace(IntPtr ptr, int[] indices, int count); internal abstract bool HasGarbage(IntPtr ptr); internal abstract void CollectGarbage(IntPtr ptr); internal abstract void SetRecycleGarbage(IntPtr ptr, bool collect); internal abstract bool DoesRecycleGarbage(IntPtr ptr); internal abstract int VertexDegree(IntPtr ptr, int index); internal abstract int FaceDegree(IntPtr ptr, int index); internal abstract bool VertexIsIsolated(IntPtr ptr, int index); internal abstract bool VertexIsBorder(IntPtr ptr, int index, bool check_all_incident_halfedges); internal abstract bool EdgeIsBorder(IntPtr ptr, int index); internal abstract int NextHalfedge(IntPtr ptr, int index); internal abstract int PreviousHalfedge(IntPtr ptr, int index); internal abstract int OppositeHalfedge(IntPtr ptr, int index); internal abstract int SourceVertex(IntPtr ptr, int index); internal abstract int TargetVertex(IntPtr ptr, int index); internal abstract int NextAroundSource(IntPtr ptr, int index); internal abstract int NextAroundTarget(IntPtr ptr, int index); internal abstract int PreviousAroundSource(IntPtr ptr, int index); internal abstract int PreviousAroundTarget(IntPtr ptr, int index); internal abstract int EdgesHalfedge(IntPtr ptr, int edgeIndex, int halfedgeIndex); internal abstract bool RemoveVertex(IntPtr ptr, int index); internal abstract bool RemoveEdge(IntPtr ptr, int index); internal abstract bool RemoveFace(IntPtr ptr, int index); internal abstract bool IsVertexValid(IntPtr ptr, int index); internal abstract bool IsEdgeValid(IntPtr ptr, int index); internal abstract bool IsHalfedgeValid(IntPtr ptr, int index); internal abstract bool IsFaceValid(IntPtr ptr, int index); internal abstract Point3d GetPoint(IntPtr ptr, int index); internal abstract void GetPoints(IntPtr ptr, Point3d[] points, int count); internal abstract void SetPoint(IntPtr ptr, int index, Point3d point); internal abstract void SetPoints(IntPtr ptr, Point3d[] points, int count); internal abstract bool GetSegment(IntPtr ptr, int index, out Segment3d segment); internal abstract void GetSegments(IntPtr ptr, Segment3d[] segments, int count); internal abstract bool GetTriangle(IntPtr ptr, int index, out Triangle3d tri); internal abstract void GetTriangles(IntPtr ptr, Triangle3d[] triangles, int count); internal abstract bool GetVertex(IntPtr ptr, int index, out MeshVertex3 vert); internal abstract void GetVertices(IntPtr ptr, MeshVertex3[] vertexArray, int count); internal abstract bool GetFace(IntPtr ptr, int index, out MeshFace3 face); internal abstract void GetFaces(IntPtr ptr, MeshFace3[] faceArray, int count); internal abstract bool GetHalfedge(IntPtr ptr, int index, out MeshHalfedge3 edge); internal abstract void GetHalfedges(IntPtr ptr, MeshHalfedge3[] edgeArray, int count); internal abstract void Transform(IntPtr ptr, Matrix4x4d matrix); internal abstract bool IsVertexBorder(IntPtr ptr, int index, bool check_all_incident_halfedges); internal abstract bool IsHalfedgeBorder(IntPtr ptr, int index); internal abstract bool IsEdgeBorder(IntPtr ptr, int index); internal abstract int BorderEdgeCount(IntPtr ptr); internal abstract bool IsClosed(IntPtr ptr); internal abstract bool CheckFaceVertexCount(IntPtr ptr, int count); internal abstract void Join(IntPtr ptr, IntPtr otherPtr); internal abstract void BuildAABBTree(IntPtr ptr); internal abstract void ReleaseAABBTree(IntPtr ptr); internal abstract Box3d GetBoundingBox(IntPtr ptr); internal abstract void ReadOFF(IntPtr ptr, string filename); internal abstract void WriteOFF(IntPtr ptr, string filename); internal abstract void Triangulate(IntPtr ptr); internal abstract bool DoesSelfIntersect(IntPtr ptr); internal abstract double Area(IntPtr ptr); internal abstract Point3d Centroid(IntPtr ptr); internal abstract double Volume(IntPtr ptr); internal abstract bool DoesBoundAVolume(IntPtr ptr); internal abstract BOUNDED_SIDE SideOfTriangleMesh(IntPtr ptr, Point3d point); internal abstract bool DoIntersects(IntPtr ptr, IntPtr otherPtr, bool test_bounded_sides); internal abstract void GetCentroids(IntPtr ptr, Point3d[] points, int count); internal abstract void ComputeVertexNormals(IntPtr ptr); internal abstract void ComputeFaceNormals(IntPtr ptr); internal abstract void GetVertexNormals(IntPtr ptr, Vector3d[] normals, int count); internal abstract void GetFaceNormals(IntPtr ptr, Vector3d[] normals, int count); internal abstract PolygonalCount GetPolygonalCount(IntPtr ptr); internal abstract PolygonalCount GetDualPolygonalCount(IntPtr ptr); internal abstract void CreatePolygonMesh(IntPtr ptr, Point2d[] points, int count, bool xz); internal abstract void CreatePolygonalMesh(IntPtr ptr, Point3d[] points, int pointsCount, int[] triangles, int triangleCount, int[] quads, int quadCount, int[] pentagons, int pentagonCount, int[] hexagons, int hexagonCount); internal abstract void GetPolygonalIndices(IntPtr ptr, int[] triangles, int triangleCount, int[] quads, int quadCount, int[] pentagons, int pentagonCount, int[] hexagons, int hexagonCount); internal abstract void GetDualPolygonalIndices(IntPtr ptr, int[] triangles, int triangleCount, int[] quads, int quadCount, int[] pentagons, int pentagonCount, int[] hexagons, int hexagonCount); } } ================================================ FILE: CGALDotNet/Polyhedra/SurfaceMeshKernel3_EEK.cs ================================================ using System; using System.Collections.Generic; using System.Runtime.InteropServices; using System.Text; using CGALDotNetGeometry.Numerics; using CGALDotNetGeometry.Shapes; namespace CGALDotNet.Polyhedra { internal class SurfaceMeshKernel3_EEK : SurfaceMeshKernel3 { internal override string Name => "EEK"; internal static readonly SurfaceMeshKernel3 Instance = new SurfaceMeshKernel3_EEK(); internal override IntPtr Create() { return SurfaceMesh3_EEK_Create(); } internal override void Release(IntPtr ptr) { SurfaceMesh3_EEK_Release(ptr); } internal override int GetBuildStamp(IntPtr ptr) { return SurfaceMesh3_EEK_GetBuildStamp(ptr); } internal override void Clear(IntPtr ptr) { SurfaceMesh3_EEK_Clear(ptr); } internal override void ClearIndexMaps(IntPtr ptr, bool vertices, bool faces, bool edges, bool halfedges) { SurfaceMesh3_EEK_ClearIndexMaps(ptr, vertices, faces, edges, halfedges); } internal override void ClearNormalMaps(IntPtr ptr, bool vertices, bool faces) { SurfaceMesh3_EEK_ClearNormalMaps(ptr, vertices, faces); } internal override void ClearProperyMaps(IntPtr ptr) { SurfaceMesh3_EEK_ClearProperyMaps(ptr); } internal override void BuildIndices(IntPtr ptr, bool vertices, bool faces, bool edges, bool halfedges, bool force) { SurfaceMesh3_EEK_BuildIndices(ptr, vertices, faces, edges, halfedges, force); } internal override void PrintIndices(IntPtr ptr, bool vertices, bool faces, bool edges, bool halfedges, bool force) { SurfaceMesh3_EEK_PrintIndices(ptr, vertices, faces, edges, halfedges, force); } internal override IntPtr Copy(IntPtr ptr) { return SurfaceMesh3_EEK_Copy(ptr); } internal override bool IsValid(IntPtr ptr) { return SurfaceMesh3_EEK_IsValid(ptr); } internal override int VertexCount(IntPtr ptr) { return SurfaceMesh3_EEK_VertexCount(ptr); } internal override int HalfedgeCount(IntPtr ptr) { return SurfaceMesh3_EEK_HalfedgeCount(ptr); } internal override int EdgeCount(IntPtr ptr) { return SurfaceMesh3_EEK_EdgeCount(ptr); } internal override int FaceCount(IntPtr ptr) { return SurfaceMesh3_EEK_FaceCount(ptr); } internal override int RemovedVertexCount(IntPtr ptr) { return SurfaceMesh3_EEK_RemovedVertexCount(ptr); } internal override int RemovedHalfedgeCount(IntPtr ptr) { return SurfaceMesh3_EEK_RemovedHalfedgeCount(ptr); } internal override int RemovedEdgeCount(IntPtr ptr) { return SurfaceMesh3_EEK_RemovedEdgeCount(ptr); } internal override int RemovedFaceCount(IntPtr ptr) { return SurfaceMesh3_EEK_RemovedFaceCount(ptr); } internal override bool IsVertexRemoved(IntPtr ptr, int index) { return SurfaceMesh3_EEK_IsVertexRemoved(ptr, index); } internal override bool IsFaceRemoved(IntPtr ptr, int index) { return SurfaceMesh3_EEK_IsFaceRemoved(ptr, index); } internal override bool IsHalfedgeRemoved(IntPtr ptr, int index) { return SurfaceMesh3_EEK_IsHalfedgeRemoved(ptr, index); } internal override bool IsEdgeRemoved(IntPtr ptr, int index) { return SurfaceMesh3_EEK_IsEdgeRemoved(ptr, index); } internal override int AddVertex(IntPtr ptr, Point3d point) { return SurfaceMesh3_EEK_AddVertex(ptr, point); } internal override int AddEdge(IntPtr ptr, int v0, int v1) { return SurfaceMesh3_EEK_AddEdge(ptr, v0, v1); } internal override int AddTriangle(IntPtr ptr, int v0, int v1, int v2) { return SurfaceMesh3_EEK_AddTriangle(ptr, v0, v1, v2); } internal override int AddQuad(IntPtr ptr, int v0, int v1, int v2, int v3) { return SurfaceMesh3_EEK_AddQuad(ptr, v0, v1, v2, v3); } internal override bool HasGarbage(IntPtr ptr) { return SurfaceMesh3_EEK_HasGarbage(ptr); } internal override void CollectGarbage(IntPtr ptr) { SurfaceMesh3_EEK_CollectGarbage(ptr); } internal override void SetRecycleGarbage(IntPtr ptr, bool collect) { SurfaceMesh3_EEK_SetRecycleGarbage(ptr, collect); } internal override bool DoesRecycleGarbage(IntPtr ptr) { return SurfaceMesh3_EEK_DoesRecycleGarbage(ptr); } internal override int VertexDegree(IntPtr ptr, int index) { return SurfaceMesh3_EEK_VertexDegree(ptr, index); } internal override int FaceDegree(IntPtr ptr, int index) { return SurfaceMesh3_EEK_FaceDegree(ptr, index); } internal override bool VertexIsIsolated(IntPtr ptr, int index) { return SurfaceMesh3_EEK_VertexIsIsolated(ptr, index); } internal override bool VertexIsBorder(IntPtr ptr, int index, bool check_all_incident_halfedges) { return SurfaceMesh3_EEK_VertexIsBorder(ptr, index, check_all_incident_halfedges); } internal override bool EdgeIsBorder(IntPtr ptr, int index) { return SurfaceMesh3_EEK_EdgeIsBorder(ptr, index); } internal override int NextHalfedge(IntPtr ptr, int index) { return SurfaceMesh3_EEK_NextHalfedge(ptr, index); } internal override int PreviousHalfedge(IntPtr ptr, int index) { return SurfaceMesh3_EEK_PreviousHalfedge(ptr, index); } internal override int OppositeHalfedge(IntPtr ptr, int index) { return SurfaceMesh3_EEK_OppositeHalfedge(ptr, index); } internal override int SourceVertex(IntPtr ptr, int index) { return SurfaceMesh3_EEK_SourceVertex(ptr, index); } internal override int TargetVertex(IntPtr ptr, int index) { return SurfaceMesh3_EEK_TargetVertex(ptr, index); } internal override int NextAroundSource(IntPtr ptr, int index) { return SurfaceMesh3_EEK_NextAroundSource(ptr, index); } internal override int NextAroundTarget(IntPtr ptr, int index) { return SurfaceMesh3_EEK_NextAroundTarget(ptr, index); } internal override int PreviousAroundSource(IntPtr ptr, int index) { return SurfaceMesh3_EEK_PreviousAroundSource(ptr, index); } internal override int PreviousAroundTarget(IntPtr ptr, int index) { return SurfaceMesh3_EEK_PreviousAroundTarget(ptr, index); } internal override int EdgesHalfedge(IntPtr ptr, int edgeIndex, int halfedgeIndex) { return SurfaceMesh3_EdgesHalfedge(ptr, edgeIndex, halfedgeIndex); } internal override bool RemoveVertex(IntPtr ptr, int index) { return SurfaceMesh3_EEK_RemoveVertex(ptr, index); } internal override bool RemoveEdge(IntPtr ptr, int index) { return SurfaceMesh3_EEK_RemoveEdge(ptr, index); } internal override bool RemoveFace(IntPtr ptr, int index) { return SurfaceMesh3_EEK_RemoveFace(ptr, index); } internal override bool IsVertexValid(IntPtr ptr, int index) { return SurfaceMesh3_EEK_IsVertexValid(ptr, index); } internal override bool IsEdgeValid(IntPtr ptr, int index) { return SurfaceMesh3_EEK_IsEdgeValid(ptr, index); } internal override bool IsHalfedgeValid(IntPtr ptr, int index) { return SurfaceMesh3_EEK_IsHalfedgeValid(ptr, index); } internal override bool IsFaceValid(IntPtr ptr, int index) { return SurfaceMesh3_EEK_IsFaceValid(ptr, index); } internal override Point3d GetPoint(IntPtr ptr, int index) { return SurfaceMesh3_EEK_GetPoint(ptr, index); } internal override void GetPoints(IntPtr ptr, Point3d[] points, int count) { SurfaceMesh3_EEK_GetPoints(ptr, points, count); } internal override void SetPoint(IntPtr ptr, int index, Point3d point) { SurfaceMesh3_EEK_SetPoint(ptr, index, point); } internal override void SetPoints(IntPtr ptr, Point3d[] points, int count) { SurfaceMesh3_EEK_SetPoints(ptr, points, count); } internal override bool GetSegment(IntPtr ptr, int index, out Segment3d segment) { return SurfaceMesh3_EEK_GetSegment(ptr, index, out segment); } internal override void GetSegments(IntPtr ptr, Segment3d[] segments, int count) { SurfaceMesh3_EEK_GetSegments(ptr, segments, count); } internal override bool GetTriangle(IntPtr ptr, int index, out Triangle3d tri) { return SurfaceMesh3_EEK_GetTriangle(ptr, index, out tri); } internal override void GetTriangles(IntPtr ptr, Triangle3d[] triangles, int count) { SurfaceMesh3_EEK_GetTriangles(ptr, triangles, count); } internal override bool GetVertex(IntPtr ptr, int index, out MeshVertex3 vert) { return SurfaceMesh3_EEK_GetVertex(ptr,index, out vert); } internal override void GetVertices(IntPtr ptr, MeshVertex3[] vertexArray, int count) { SurfaceMesh3_EEK_GetVertices(ptr, vertexArray, count); } internal override bool GetFace(IntPtr ptr, int index, out MeshFace3 face) { return SurfaceMesh3_EEK_GetFace(ptr, index, out face); } internal override void GetFaces(IntPtr ptr, MeshFace3[] faceArray, int count) { SurfaceMesh3_EEK_GetFaces(ptr, faceArray, count); } internal override bool GetHalfedge(IntPtr ptr, int index, out MeshHalfedge3 edge) { return SurfaceMesh3_EEK_GetHalfedge(ptr, index, out edge); } internal override void GetHalfedges(IntPtr ptr, MeshHalfedge3[] edgeArray, int count) { SurfaceMesh3_EEK_GetHalfedges(ptr, edgeArray, count); } internal override void Transform(IntPtr ptr, Matrix4x4d matrix) { SurfaceMesh3_EEK_Transform(ptr, matrix); } internal override bool IsVertexBorder(IntPtr ptr, int index, bool check_all_incident_halfedges) { return SurfaceMesh3_EEK_IsVertexBorder(ptr,index, check_all_incident_halfedges); } internal override bool IsHalfedgeBorder(IntPtr ptr, int index) { return SurfaceMesh3_EEK_IsHalfedgeBorder(ptr,index); } internal override bool IsEdgeBorder(IntPtr ptr, int index) { return SurfaceMesh3_EEK_IsEdgeBorder(ptr,index); } internal override int BorderEdgeCount(IntPtr ptr) { return SurfaceMesh3_EEK_BorderEdgeCount(ptr); } internal override bool IsClosed(IntPtr ptr) { return SurfaceMesh3_EEK_IsClosed(ptr); } internal override bool CheckFaceVertexCount(IntPtr ptr, int count) { return SurfaceMesh3_EEK_CheckFaceVertexCount(ptr, count); } internal override int AddPentagon(IntPtr ptr, int v0, int v1, int v2, int v3, int v4) { return SurfaceMesh3_EEK_AddPentagon(ptr, v0, v1, v2, v3, v4); } internal override int AddHexagon(IntPtr ptr, int v0, int v1, int v2, int v3, int v4, int v5) { return SurfaceMesh3_EEK_AddHexagon(ptr, v0, v1, v2, v3, v4, v5); } internal override int AddFace(IntPtr ptr, int[] indices, int count) { return SurfaceMesh3_EEK_AddFace(ptr, indices, count); } internal override void Join(IntPtr ptr, IntPtr otherPtr) { SurfaceMesh3_EEK_Join(ptr, otherPtr); } internal override void BuildAABBTree(IntPtr ptr) { SurfaceMesh3_EEK_BuildAABBTree(ptr); } internal override void ReleaseAABBTree(IntPtr ptr) { SurfaceMesh3_EEK_ReleaseAABBTree(ptr); } internal override Box3d GetBoundingBox(IntPtr ptr) { return SurfaceMesh3_EEK_GetBoundingBox(ptr); } internal override void ReadOFF(IntPtr ptr, string filename) { SurfaceMesh3_EEK_ReadOFF(ptr, filename); } internal override void WriteOFF(IntPtr ptr, string filename) { SurfaceMesh3_EEK_WriteOFF(ptr, filename); } internal override void Triangulate(IntPtr ptr) { SurfaceMesh3_EEK_Triangulate(ptr); } internal override bool DoesSelfIntersect(IntPtr ptr) { return SurfaceMesh3_EEK_DoesBoundAVolume(ptr); } internal override double Area(IntPtr ptr) { return SurfaceMesh3_EEK_Area(ptr); } internal override Point3d Centroid(IntPtr ptr) { return SurfaceMesh3_EEK_Centroid(ptr); } internal override double Volume(IntPtr ptr) { return SurfaceMesh3_EEK_Volume(ptr); } internal override bool DoesBoundAVolume(IntPtr ptr) { return SurfaceMesh3_EEK_DoesBoundAVolume(ptr); } internal override BOUNDED_SIDE SideOfTriangleMesh(IntPtr ptr, Point3d point) { return SurfaceMesh3_EEK_SideOfTriangleMesh(ptr, point); } internal override bool DoIntersects(IntPtr ptr, IntPtr otherPtr, bool test_bounded_sides) { return SurfaceMesh3_EEK_DoIntersects(ptr, otherPtr, test_bounded_sides); } internal override void GetCentroids(IntPtr ptr, Point3d[] points, int count) { SurfaceMesh3_EEK_GetCentroids(ptr, points, count); } internal override void ComputeVertexNormals(IntPtr ptr) { SurfaceMesh3_EEK_ComputeVertexNormals(ptr); } internal override void ComputeFaceNormals(IntPtr ptr) { SurfaceMesh3_EEK_ComputeFaceNormals(ptr); } internal override void GetVertexNormals(IntPtr ptr, Vector3d[] normals, int count) { SurfaceMesh3_EEK_GetVertexNormals(ptr, normals, count); } internal override void GetFaceNormals(IntPtr ptr, Vector3d[] normals, int count) { SurfaceMesh3_EEK_GetFaceNormals(ptr, normals, count); } internal override PolygonalCount GetPolygonalCount(IntPtr ptr) { return SurfaceMesh3_EEK_GetPolygonalCount(ptr); } internal override PolygonalCount GetDualPolygonalCount(IntPtr ptr) { return SurfaceMesh3_EEK_GetDualPolygonalCount(ptr); } internal override void CreatePolygonMesh(IntPtr ptr, Point2d[] points, int count, bool xz) { SurfaceMesh3_EEK_CreatePolygonMesh(ptr, points, count, xz); } internal override void CreatePolygonalMesh(IntPtr ptr, Point3d[] points, int pointsCount, int[] triangles, int triangleCount, int[] quads, int quadCount, int[] pentagons, int pentagonCount, int[] hexagons, int hexagonCount) { SurfaceMesh3_EEK_CreatePolygonalMesh(ptr, points, pointsCount, triangles, triangleCount, quads, quadCount, pentagons, pentagonCount, hexagons, hexagonCount); } internal override void GetPolygonalIndices(IntPtr ptr, int[] triangles, int triangleCount, int[] quads, int quadCount, int[] pentagons, int pentagonCount, int[] hexagons, int hexagonCount) { SurfaceMesh3_EEK_GetPolygonalIndices(ptr, triangles, triangleCount, quads, quadCount, pentagons, pentagonCount, hexagons, hexagonCount); } internal override void GetDualPolygonalIndices(IntPtr ptr, int[] triangles, int triangleCount, int[] quads, int quadCount, int[] pentagons, int pentagonCount, int[] hexagons, int hexagonCount) { SurfaceMesh3_EEK_GetDualPolygonalIndices(ptr, triangles, triangleCount, quads, quadCount, pentagons, pentagonCount, hexagons, hexagonCount); } [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr SurfaceMesh3_EEK_Create(); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void SurfaceMesh3_EEK_Release(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int SurfaceMesh3_EEK_GetBuildStamp(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void SurfaceMesh3_EEK_Clear(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void SurfaceMesh3_EEK_ClearIndexMaps(IntPtr ptr, bool vertices, bool faces, bool halfedges, bool edges); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void SurfaceMesh3_EEK_ClearNormalMaps(IntPtr ptr, bool vertices, bool faces); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void SurfaceMesh3_EEK_ClearProperyMaps(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void SurfaceMesh3_EEK_BuildIndices(IntPtr ptr, bool vertices, bool faces, bool edges, bool halfedges, bool force); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void SurfaceMesh3_EEK_PrintIndices(IntPtr ptr, bool vertices, bool faces, bool edges, bool halfedges, bool build); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr SurfaceMesh3_EEK_Copy(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool SurfaceMesh3_EEK_IsValid(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int SurfaceMesh3_EEK_VertexCount(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int SurfaceMesh3_EEK_HalfedgeCount(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int SurfaceMesh3_EEK_EdgeCount(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int SurfaceMesh3_EEK_FaceCount(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int SurfaceMesh3_EEK_RemovedVertexCount(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int SurfaceMesh3_EEK_RemovedHalfedgeCount(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int SurfaceMesh3_EEK_RemovedEdgeCount(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int SurfaceMesh3_EEK_RemovedFaceCount(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool SurfaceMesh3_EEK_IsVertexRemoved(IntPtr ptr, int index); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool SurfaceMesh3_EEK_IsFaceRemoved(IntPtr ptr, int index); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool SurfaceMesh3_EEK_IsHalfedgeRemoved(IntPtr ptr, int index); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool SurfaceMesh3_EEK_IsEdgeRemoved(IntPtr ptr, int index); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int SurfaceMesh3_EEK_AddVertex(IntPtr ptr, Point3d point); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int SurfaceMesh3_EEK_AddEdge(IntPtr ptr, int v0, int v1); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int SurfaceMesh3_EEK_AddTriangle(IntPtr ptr, int v0, int v1, int v2); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int SurfaceMesh3_EEK_AddQuad(IntPtr ptr, int v0, int v1, int v2, int v3); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int SurfaceMesh3_EEK_AddPentagon(IntPtr ptr, int v0, int v1, int v2, int v3, int v4); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int SurfaceMesh3_EEK_AddHexagon(IntPtr ptr, int v0, int v1, int v2, int v3, int v4, int v5); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int SurfaceMesh3_EEK_AddFace(IntPtr ptr, int[] indices, int count); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool SurfaceMesh3_EEK_HasGarbage(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void SurfaceMesh3_EEK_CollectGarbage(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void SurfaceMesh3_EEK_SetRecycleGarbage(IntPtr ptr, bool collect); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool SurfaceMesh3_EEK_DoesRecycleGarbage(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int SurfaceMesh3_EEK_VertexDegree(IntPtr ptr, int index); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int SurfaceMesh3_EEK_FaceDegree(IntPtr ptr, int index); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool SurfaceMesh3_EEK_VertexIsIsolated(IntPtr ptr, int index); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool SurfaceMesh3_EEK_VertexIsBorder(IntPtr ptr, int index, bool check_all_incident_halfedges); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool SurfaceMesh3_EEK_EdgeIsBorder(IntPtr ptr, int index); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int SurfaceMesh3_EEK_NextHalfedge(IntPtr ptr, int index); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int SurfaceMesh3_EEK_PreviousHalfedge(IntPtr ptr, int index); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int SurfaceMesh3_EEK_OppositeHalfedge(IntPtr ptr, int index); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int SurfaceMesh3_EEK_SourceVertex(IntPtr ptr, int index); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int SurfaceMesh3_EEK_TargetVertex(IntPtr ptr, int index); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool SurfaceMesh3_EEK_RemoveVertex(IntPtr ptr, int index); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int SurfaceMesh3_EEK_NextAroundSource(IntPtr ptr, int index); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int SurfaceMesh3_EEK_NextAroundTarget(IntPtr ptr, int index); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int SurfaceMesh3_EEK_PreviousAroundSource(IntPtr ptr, int index); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int SurfaceMesh3_EEK_PreviousAroundTarget(IntPtr ptr, int index); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int SurfaceMesh3_EdgesHalfedge(IntPtr ptr, int edgeIndex, int halfedgeIndex); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool SurfaceMesh3_EEK_RemoveEdge(IntPtr ptr, int index); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool SurfaceMesh3_EEK_RemoveFace(IntPtr ptr, int index); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool SurfaceMesh3_EEK_IsVertexValid(IntPtr ptr, int index); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool SurfaceMesh3_EEK_IsEdgeValid(IntPtr ptr, int index); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool SurfaceMesh3_EEK_IsHalfedgeValid(IntPtr ptr, int index); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool SurfaceMesh3_EEK_IsFaceValid(IntPtr ptr, int index); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern Point3d SurfaceMesh3_EEK_GetPoint(IntPtr ptr, int index); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void SurfaceMesh3_EEK_GetPoints(IntPtr ptr, [Out] Point3d[] points, int count); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void SurfaceMesh3_EEK_SetPoint(IntPtr ptr, int index, Point3d point); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void SurfaceMesh3_EEK_SetPoints(IntPtr ptr, [Out] Point3d[] points, int count); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool SurfaceMesh3_EEK_GetSegment(IntPtr ptr, int index, [Out] out Segment3d segment); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void SurfaceMesh3_EEK_GetSegments(IntPtr ptr, [Out] Segment3d[] segments, int count); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool SurfaceMesh3_EEK_GetTriangle(IntPtr ptr, int index, [Out] out Triangle3d tri); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void SurfaceMesh3_EEK_GetTriangles(IntPtr ptr, [Out] Triangle3d[] triangles, int count); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool SurfaceMesh3_EEK_GetVertex(IntPtr ptr, int index, [Out] out MeshVertex3 vert); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void SurfaceMesh3_EEK_GetVertices(IntPtr ptr, [Out] MeshVertex3[] vertexArray, int count); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool SurfaceMesh3_EEK_GetFace(IntPtr ptr, int index, [Out] out MeshFace3 face); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void SurfaceMesh3_EEK_GetFaces(IntPtr ptr, [Out] MeshFace3[] faceArray, int count); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool SurfaceMesh3_EEK_GetHalfedge(IntPtr ptr, int index, [Out] out MeshHalfedge3 edge); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void SurfaceMesh3_EEK_GetHalfedges(IntPtr ptr, [Out] MeshHalfedge3[] edgeArray, int count); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void SurfaceMesh3_EEK_Transform(IntPtr ptr, Matrix4x4d matrix); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool SurfaceMesh3_EEK_IsVertexBorder(IntPtr ptr, int index, bool check_all_incident_halfedges); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool SurfaceMesh3_EEK_IsHalfedgeBorder(IntPtr ptr, int index); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool SurfaceMesh3_EEK_IsEdgeBorder(IntPtr ptr, int index); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int SurfaceMesh3_EEK_BorderEdgeCount(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool SurfaceMesh3_EEK_IsClosed(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool SurfaceMesh3_EEK_CheckFaceVertexCount(IntPtr ptr, int count); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void SurfaceMesh3_EEK_Join(IntPtr ptr, IntPtr otherPtr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void SurfaceMesh3_EEK_BuildAABBTree(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void SurfaceMesh3_EEK_ReleaseAABBTree(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern Box3d SurfaceMesh3_EEK_GetBoundingBox(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void SurfaceMesh3_EEK_ReadOFF(IntPtr ptr, string filename); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void SurfaceMesh3_EEK_WriteOFF(IntPtr ptr, string filename); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void SurfaceMesh3_EEK_Triangulate(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool SurfaceMesh3_EEK_DoesSelfIntersect(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern double SurfaceMesh3_EEK_Area(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern Point3d SurfaceMesh3_EEK_Centroid(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern double SurfaceMesh3_EEK_Volume(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool SurfaceMesh3_EEK_DoesBoundAVolume(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern BOUNDED_SIDE SurfaceMesh3_EEK_SideOfTriangleMesh(IntPtr ptr, Point3d point); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool SurfaceMesh3_EEK_DoIntersects(IntPtr ptr, IntPtr otherPtr, bool test_bounded_sides); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void SurfaceMesh3_EEK_GetCentroids(IntPtr ptr, [Out] Point3d[] points, int count); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void SurfaceMesh3_EEK_ComputeVertexNormals(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void SurfaceMesh3_EEK_ComputeFaceNormals(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void SurfaceMesh3_EEK_GetVertexNormals(IntPtr ptr, [Out] Vector3d[] normals, int count); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void SurfaceMesh3_EEK_GetFaceNormals(IntPtr ptr, [Out] Vector3d[] normals, int count); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern PolygonalCount SurfaceMesh3_EEK_GetPolygonalCount(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern PolygonalCount SurfaceMesh3_EEK_GetDualPolygonalCount(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void SurfaceMesh3_EEK_CreatePolygonMesh(IntPtr ptr, Point2d[] points, int count, bool xz); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void SurfaceMesh3_EEK_CreatePolygonalMesh(IntPtr ptr, Point3d[] points, int pointsCount, int[] triangles, int triangleCount, int[] quads, int quadCount, int[] pentagons, int pentagonCount, int[] hexagons, int hexagonCount); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void SurfaceMesh3_EEK_GetPolygonalIndices(IntPtr ptr, [Out] int[] triangles, int triangleCount, [Out] int[] quads, int quadCount, [Out] int[] pentagons, int pentagonCount, [Out] int[] hexagons, int hexagonCount); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void SurfaceMesh3_EEK_GetDualPolygonalIndices(IntPtr ptr, [Out] int[] triangles, int triangleCount, [Out] int[] quads, int quadCount, [Out] int[] pentagons, int pentagonCount, [Out] int[] hexagons, int hexagonCount); } } ================================================ FILE: CGALDotNet/Polyhedra/SurfaceMeshKernel3_EIK.cs ================================================ using System; using System.Collections.Generic; using System.Runtime.InteropServices; using System.Text; using CGALDotNetGeometry.Numerics; using CGALDotNetGeometry.Shapes; namespace CGALDotNet.Polyhedra { internal class SurfaceMeshKernel3_EIK : SurfaceMeshKernel3 { internal override string Name => "EIK"; internal static readonly SurfaceMeshKernel3 Instance = new SurfaceMeshKernel3_EIK(); internal override IntPtr Create() { return SurfaceMesh3_EIK_Create(); } internal override void Release(IntPtr ptr) { SurfaceMesh3_EIK_Release(ptr); } internal override int GetBuildStamp(IntPtr ptr) { return SurfaceMesh3_EIK_GetBuildStamp(ptr); } internal override void Clear(IntPtr ptr) { SurfaceMesh3_EIK_Clear(ptr); } internal override void ClearIndexMaps(IntPtr ptr, bool vertices, bool faces, bool edges, bool halfedges) { SurfaceMesh3_EIK_ClearIndexMaps(ptr, vertices, faces, edges, halfedges); } internal override void ClearNormalMaps(IntPtr ptr, bool vertices, bool faces) { SurfaceMesh3_EIK_ClearNormalMaps(ptr, vertices, faces); } internal override void ClearProperyMaps(IntPtr ptr) { SurfaceMesh3_EIK_ClearProperyMaps(ptr); } internal override void BuildIndices(IntPtr ptr, bool vertices, bool faces, bool edges, bool halfedges, bool force) { SurfaceMesh3_EIK_BuildIndices(ptr, vertices, faces, edges, halfedges, force); } internal override void PrintIndices(IntPtr ptr, bool vertices, bool faces, bool edges, bool halfedges, bool force) { SurfaceMesh3_EIK_PrintIndices(ptr, vertices, faces, edges, halfedges, force); } internal override IntPtr Copy(IntPtr ptr) { return SurfaceMesh3_EIK_Copy(ptr); } internal override bool IsValid(IntPtr ptr) { return SurfaceMesh3_EIK_IsValid(ptr); } internal override int VertexCount(IntPtr ptr) { return SurfaceMesh3_EIK_VertexCount(ptr); } internal override int HalfedgeCount(IntPtr ptr) { return SurfaceMesh3_EIK_HalfedgeCount(ptr); } internal override int EdgeCount(IntPtr ptr) { return SurfaceMesh3_EIK_EdgeCount(ptr); } internal override int FaceCount(IntPtr ptr) { return SurfaceMesh3_EIK_FaceCount(ptr); } internal override int RemovedVertexCount(IntPtr ptr) { return SurfaceMesh3_EIK_RemovedVertexCount(ptr); } internal override int RemovedHalfedgeCount(IntPtr ptr) { return SurfaceMesh3_EIK_RemovedHalfedgeCount(ptr); } internal override int RemovedEdgeCount(IntPtr ptr) { return SurfaceMesh3_EIK_RemovedEdgeCount(ptr); } internal override int RemovedFaceCount(IntPtr ptr) { return SurfaceMesh3_EIK_RemovedFaceCount(ptr); } internal override bool IsVertexRemoved(IntPtr ptr, int index) { return SurfaceMesh3_EIK_IsVertexRemoved(ptr, index); } internal override bool IsFaceRemoved(IntPtr ptr, int index) { return SurfaceMesh3_EIK_IsFaceRemoved(ptr, index); } internal override bool IsHalfedgeRemoved(IntPtr ptr, int index) { return SurfaceMesh3_EIK_IsHalfedgeRemoved(ptr, index); } internal override bool IsEdgeRemoved(IntPtr ptr, int index) { return SurfaceMesh3_EIK_IsEdgeRemoved(ptr, index); } internal override int AddVertex(IntPtr ptr, Point3d point) { return SurfaceMesh3_EIK_AddVertex(ptr, point); } internal override int AddEdge(IntPtr ptr, int v0, int v1) { return SurfaceMesh3_EIK_AddEdge(ptr, v0, v1); } internal override int AddTriangle(IntPtr ptr, int v0, int v1, int v2) { return SurfaceMesh3_EIK_AddTriangle(ptr, v0, v1, v2); } internal override int AddQuad(IntPtr ptr, int v0, int v1, int v2, int v3) { return SurfaceMesh3_EIK_AddQuad(ptr, v0, v1, v2, v3); } internal override bool HasGarbage(IntPtr ptr) { return SurfaceMesh3_EIK_HasGarbage(ptr); } internal override void CollectGarbage(IntPtr ptr) { SurfaceMesh3_EIK_CollectGarbage(ptr); } internal override void SetRecycleGarbage(IntPtr ptr, bool collect) { SurfaceMesh3_EIK_SetRecycleGarbage(ptr, collect); } internal override bool DoesRecycleGarbage(IntPtr ptr) { return SurfaceMesh3_EIK_DoesRecycleGarbage(ptr); } internal override int VertexDegree(IntPtr ptr, int index) { return SurfaceMesh3_EIK_VertexDegree(ptr, index); } internal override int FaceDegree(IntPtr ptr, int index) { return SurfaceMesh3_EIK_FaceDegree(ptr, index); } internal override bool VertexIsIsolated(IntPtr ptr, int index) { return SurfaceMesh3_EIK_VertexIsIsolated(ptr, index); } internal override bool VertexIsBorder(IntPtr ptr, int index, bool check_all_incident_halfedges) { return SurfaceMesh3_EIK_VertexIsBorder(ptr, index, check_all_incident_halfedges); } internal override bool EdgeIsBorder(IntPtr ptr, int index) { return SurfaceMesh3_EIK_EdgeIsBorder(ptr, index); } internal override int NextHalfedge(IntPtr ptr, int index) { return SurfaceMesh3_EIK_NextHalfedge(ptr, index); } internal override int PreviousHalfedge(IntPtr ptr, int index) { return SurfaceMesh3_EIK_PreviousHalfedge(ptr, index); } internal override int OppositeHalfedge(IntPtr ptr, int index) { return SurfaceMesh3_EIK_OppositeHalfedge(ptr, index); } internal override int SourceVertex(IntPtr ptr, int index) { return SurfaceMesh3_EIK_SourceVertex(ptr, index); } internal override int TargetVertex(IntPtr ptr, int index) { return SurfaceMesh3_EIK_TargetVertex(ptr, index); } internal override int NextAroundSource(IntPtr ptr, int index) { return SurfaceMesh3_EIK_NextAroundSource(ptr, index); } internal override int NextAroundTarget(IntPtr ptr, int index) { return SurfaceMesh3_EIK_NextAroundTarget(ptr, index); } internal override int PreviousAroundSource(IntPtr ptr, int index) { return SurfaceMesh3_EIK_PreviousAroundSource(ptr, index); } internal override int PreviousAroundTarget(IntPtr ptr, int index) { return SurfaceMesh3_EIK_PreviousAroundTarget(ptr, index); } internal override int EdgesHalfedge(IntPtr ptr, int edgeIndex, int halfedgeIndex) { return SurfaceMesh3_EdgesHalfedge(ptr, edgeIndex, halfedgeIndex); } internal override bool RemoveVertex(IntPtr ptr, int index) { return SurfaceMesh3_EIK_RemoveVertex(ptr, index); } internal override bool RemoveEdge(IntPtr ptr, int index) { return SurfaceMesh3_EIK_RemoveEdge(ptr, index); } internal override bool RemoveFace(IntPtr ptr, int index) { return SurfaceMesh3_EIK_RemoveFace(ptr, index); } internal override bool IsVertexValid(IntPtr ptr, int index) { return SurfaceMesh3_EIK_IsVertexValid(ptr, index); } internal override bool IsEdgeValid(IntPtr ptr, int index) { return SurfaceMesh3_EIK_IsEdgeValid(ptr, index); } internal override bool IsHalfedgeValid(IntPtr ptr, int index) { return SurfaceMesh3_EIK_IsHalfedgeValid(ptr, index); } internal override bool IsFaceValid(IntPtr ptr, int index) { return SurfaceMesh3_EIK_IsFaceValid(ptr, index); } internal override Point3d GetPoint(IntPtr ptr, int index) { return SurfaceMesh3_EIK_GetPoint(ptr, index); } internal override void GetPoints(IntPtr ptr, Point3d[] points, int count) { SurfaceMesh3_EIK_GetPoints(ptr, points, count); } internal override void SetPoint(IntPtr ptr, int index, Point3d point) { SurfaceMesh3_EIK_SetPoint(ptr, index, point); } internal override void SetPoints(IntPtr ptr, Point3d[] points, int count) { SurfaceMesh3_EIK_SetPoints(ptr, points, count); } internal override bool GetSegment(IntPtr ptr, int index, out Segment3d segment) { return SurfaceMesh3_EIK_GetSegment(ptr, index, out segment); } internal override void GetSegments(IntPtr ptr, Segment3d[] segments, int count) { SurfaceMesh3_EIK_GetSegments(ptr, segments, count); } internal override bool GetTriangle(IntPtr ptr, int index, out Triangle3d tri) { return SurfaceMesh3_EIK_GetTriangle(ptr, index, out tri); } internal override void GetTriangles(IntPtr ptr, Triangle3d[] triangles, int count) { SurfaceMesh3_EIK_GetTriangles(ptr, triangles, count); } internal override bool GetVertex(IntPtr ptr, int index, out MeshVertex3 vert) { return SurfaceMesh3_EIK_GetVertex(ptr, index, out vert); } internal override void GetVertices(IntPtr ptr, MeshVertex3[] vertexArray, int count) { SurfaceMesh3_EIK_GetVertices(ptr, vertexArray, count); } internal override bool GetFace(IntPtr ptr, int index, out MeshFace3 face) { return SurfaceMesh3_EIK_GetFace(ptr, index, out face); } internal override void GetFaces(IntPtr ptr, MeshFace3[] faceArray, int count) { SurfaceMesh3_EIK_GetFaces(ptr, faceArray, count); } internal override bool GetHalfedge(IntPtr ptr, int index, out MeshHalfedge3 edge) { return SurfaceMesh3_EIK_GetHalfedge(ptr, index, out edge); } internal override void GetHalfedges(IntPtr ptr, MeshHalfedge3[] edgeArray, int count) { SurfaceMesh3_EIK_GetHalfedges(ptr, edgeArray, count); } internal override void Transform(IntPtr ptr, Matrix4x4d matrix) { SurfaceMesh3_EIK_Transform(ptr, matrix); } internal override bool IsVertexBorder(IntPtr ptr, int index, bool check_all_incident_halfedges) { return SurfaceMesh3_EIK_IsVertexBorder(ptr, index, check_all_incident_halfedges); } internal override bool IsHalfedgeBorder(IntPtr ptr, int index) { return SurfaceMesh3_EIK_IsHalfedgeBorder(ptr, index); } internal override bool IsEdgeBorder(IntPtr ptr, int index) { return SurfaceMesh3_EIK_IsEdgeBorder(ptr, index); } internal override int BorderEdgeCount(IntPtr ptr) { return SurfaceMesh3_EIK_BorderEdgeCount(ptr); } internal override bool IsClosed(IntPtr ptr) { return SurfaceMesh3_EIK_IsClosed(ptr); } internal override bool CheckFaceVertexCount(IntPtr ptr, int count) { return SurfaceMesh3_EIK_CheckFaceVertexCount(ptr, count); } internal override int AddPentagon(IntPtr ptr, int v0, int v1, int v2, int v3, int v4) { return SurfaceMesh3_EIK_AddPentagon(ptr, v0, v1, v2, v3, v4); } internal override int AddHexagon(IntPtr ptr, int v0, int v1, int v2, int v3, int v4, int v5) { return SurfaceMesh3_EIK_AddHexagon(ptr, v0, v1, v2, v3, v4, v5); } internal override int AddFace(IntPtr ptr, int[] indices, int count) { return SurfaceMesh3_EIK_AddFace(ptr, indices, count); } internal override void Join(IntPtr ptr, IntPtr otherPtr) { SurfaceMesh3_EIK_Join(ptr, otherPtr); } internal override void BuildAABBTree(IntPtr ptr) { SurfaceMesh3_EIK_BuildAABBTree(ptr); } internal override void ReleaseAABBTree(IntPtr ptr) { SurfaceMesh3_EIK_ReleaseAABBTree(ptr); } internal override Box3d GetBoundingBox(IntPtr ptr) { return SurfaceMesh3_EIK_GetBoundingBox(ptr); } internal override void ReadOFF(IntPtr ptr, string filename) { SurfaceMesh3_EIK_ReadOFF(ptr, filename); } internal override void WriteOFF(IntPtr ptr, string filename) { SurfaceMesh3_EIK_WriteOFF(ptr, filename); } internal override void Triangulate(IntPtr ptr) { SurfaceMesh3_EIK_Triangulate(ptr); } internal override bool DoesSelfIntersect(IntPtr ptr) { return SurfaceMesh3_EIK_DoesBoundAVolume(ptr); } internal override double Area(IntPtr ptr) { return SurfaceMesh3_EIK_Area(ptr); } internal override Point3d Centroid(IntPtr ptr) { return SurfaceMesh3_EIK_Centroid(ptr); } internal override double Volume(IntPtr ptr) { return SurfaceMesh3_EIK_Volume(ptr); } internal override bool DoesBoundAVolume(IntPtr ptr) { return SurfaceMesh3_EIK_DoesBoundAVolume(ptr); } internal override BOUNDED_SIDE SideOfTriangleMesh(IntPtr ptr, Point3d point) { return SurfaceMesh3_EIK_SideOfTriangleMesh(ptr, point); } internal override bool DoIntersects(IntPtr ptr, IntPtr otherPtr, bool test_bounded_sides) { return SurfaceMesh3_EIK_DoIntersects(ptr, otherPtr, test_bounded_sides); } internal override void GetCentroids(IntPtr ptr, Point3d[] points, int count) { SurfaceMesh3_EIK_GetCentroids(ptr, points, count); } internal override void ComputeVertexNormals(IntPtr ptr) { SurfaceMesh3_EIK_ComputeVertexNormals(ptr); } internal override void ComputeFaceNormals(IntPtr ptr) { SurfaceMesh3_EIK_ComputeFaceNormals(ptr); } internal override void GetVertexNormals(IntPtr ptr, Vector3d[] normals, int count) { SurfaceMesh3_EIK_GetVertexNormals(ptr, normals, count); } internal override void GetFaceNormals(IntPtr ptr, Vector3d[] normals, int count) { SurfaceMesh3_EIK_GetFaceNormals(ptr, normals, count); } internal override PolygonalCount GetPolygonalCount(IntPtr ptr) { return SurfaceMesh3_EIK_GetPolygonalCount(ptr); } internal override PolygonalCount GetDualPolygonalCount(IntPtr ptr) { return SurfaceMesh3_EIK_GetDualPolygonalCount(ptr); } internal override void CreatePolygonMesh(IntPtr ptr, Point2d[] points, int count, bool xz) { SurfaceMesh3_EIK_CreatePolygonMesh(ptr, points, count, xz); } internal override void CreatePolygonalMesh(IntPtr ptr, Point3d[] points, int pointsCount, int[] triangles, int triangleCount, int[] quads, int quadCount, int[] pentagons, int pentagonCount, int[] hexagons, int hexagonCount) { SurfaceMesh3_EIK_CreatePolygonalMesh(ptr, points, pointsCount, triangles, triangleCount, quads, quadCount, pentagons, pentagonCount, hexagons, hexagonCount); } internal override void GetPolygonalIndices(IntPtr ptr, int[] triangles, int triangleCount, int[] quads, int quadCount, int[] pentagons, int pentagonCount, int[] hexagons, int hexagonCount) { SurfaceMesh3_EIK_GetPolygonalIndices(ptr, triangles, triangleCount, quads, quadCount, pentagons, pentagonCount, hexagons, hexagonCount); } internal override void GetDualPolygonalIndices(IntPtr ptr, int[] triangles, int triangleCount, int[] quads, int quadCount, int[] pentagons, int pentagonCount, int[] hexagons, int hexagonCount) { SurfaceMesh3_EIK_GetDualPolygonalIndices(ptr, triangles, triangleCount, quads, quadCount, pentagons, pentagonCount, hexagons, hexagonCount); } [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr SurfaceMesh3_EIK_Create(); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void SurfaceMesh3_EIK_Release(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int SurfaceMesh3_EIK_GetBuildStamp(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void SurfaceMesh3_EIK_Clear(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void SurfaceMesh3_EIK_ClearIndexMaps(IntPtr ptr, bool vertices, bool faces, bool halfedges, bool edges); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void SurfaceMesh3_EIK_ClearNormalMaps(IntPtr ptr, bool vertices, bool faces); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void SurfaceMesh3_EIK_ClearProperyMaps(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void SurfaceMesh3_EIK_BuildIndices(IntPtr ptr, bool vertices, bool faces, bool edges, bool halfedges, bool force); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void SurfaceMesh3_EIK_PrintIndices(IntPtr ptr, bool vertices, bool faces, bool edges, bool halfedges, bool build); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr SurfaceMesh3_EIK_Copy(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool SurfaceMesh3_EIK_IsValid(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int SurfaceMesh3_EIK_VertexCount(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int SurfaceMesh3_EIK_HalfedgeCount(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int SurfaceMesh3_EIK_EdgeCount(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int SurfaceMesh3_EIK_FaceCount(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int SurfaceMesh3_EIK_RemovedVertexCount(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int SurfaceMesh3_EIK_RemovedHalfedgeCount(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int SurfaceMesh3_EIK_RemovedEdgeCount(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int SurfaceMesh3_EIK_RemovedFaceCount(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool SurfaceMesh3_EIK_IsVertexRemoved(IntPtr ptr, int index); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool SurfaceMesh3_EIK_IsFaceRemoved(IntPtr ptr, int index); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool SurfaceMesh3_EIK_IsHalfedgeRemoved(IntPtr ptr, int index); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool SurfaceMesh3_EIK_IsEdgeRemoved(IntPtr ptr, int index); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int SurfaceMesh3_EIK_AddVertex(IntPtr ptr, Point3d point); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int SurfaceMesh3_EIK_AddEdge(IntPtr ptr, int v0, int v1); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int SurfaceMesh3_EIK_AddTriangle(IntPtr ptr, int v0, int v1, int v2); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int SurfaceMesh3_EIK_AddQuad(IntPtr ptr, int v0, int v1, int v2, int v3); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int SurfaceMesh3_EIK_AddPentagon(IntPtr ptr, int v0, int v1, int v2, int v3, int v4); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int SurfaceMesh3_EIK_AddHexagon(IntPtr ptr, int v0, int v1, int v2, int v3, int v4, int v5); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int SurfaceMesh3_EIK_AddFace(IntPtr ptr, int[] indices, int count); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool SurfaceMesh3_EIK_HasGarbage(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void SurfaceMesh3_EIK_CollectGarbage(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void SurfaceMesh3_EIK_SetRecycleGarbage(IntPtr ptr, bool collect); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool SurfaceMesh3_EIK_DoesRecycleGarbage(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int SurfaceMesh3_EIK_VertexDegree(IntPtr ptr, int index); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int SurfaceMesh3_EIK_FaceDegree(IntPtr ptr, int index); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool SurfaceMesh3_EIK_VertexIsIsolated(IntPtr ptr, int index); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool SurfaceMesh3_EIK_VertexIsBorder(IntPtr ptr, int index, bool check_all_incident_halfedges); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool SurfaceMesh3_EIK_EdgeIsBorder(IntPtr ptr, int index); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int SurfaceMesh3_EIK_NextHalfedge(IntPtr ptr, int index); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int SurfaceMesh3_EIK_PreviousHalfedge(IntPtr ptr, int index); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int SurfaceMesh3_EIK_OppositeHalfedge(IntPtr ptr, int index); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int SurfaceMesh3_EIK_SourceVertex(IntPtr ptr, int index); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int SurfaceMesh3_EIK_TargetVertex(IntPtr ptr, int index); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool SurfaceMesh3_EIK_RemoveVertex(IntPtr ptr, int index); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int SurfaceMesh3_EIK_NextAroundSource(IntPtr ptr, int index); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int SurfaceMesh3_EIK_NextAroundTarget(IntPtr ptr, int index); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int SurfaceMesh3_EIK_PreviousAroundSource(IntPtr ptr, int index); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int SurfaceMesh3_EIK_PreviousAroundTarget(IntPtr ptr, int index); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int SurfaceMesh3_EdgesHalfedge(IntPtr ptr, int edgeIndex, int halfedgeIndex); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool SurfaceMesh3_EIK_RemoveEdge(IntPtr ptr, int index); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool SurfaceMesh3_EIK_RemoveFace(IntPtr ptr, int index); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool SurfaceMesh3_EIK_IsVertexValid(IntPtr ptr, int index); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool SurfaceMesh3_EIK_IsEdgeValid(IntPtr ptr, int index); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool SurfaceMesh3_EIK_IsHalfedgeValid(IntPtr ptr, int index); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool SurfaceMesh3_EIK_IsFaceValid(IntPtr ptr, int index); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern Point3d SurfaceMesh3_EIK_GetPoint(IntPtr ptr, int index); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void SurfaceMesh3_EIK_GetPoints(IntPtr ptr, [Out] Point3d[] points, int count); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void SurfaceMesh3_EIK_SetPoint(IntPtr ptr, int index, Point3d point); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void SurfaceMesh3_EIK_SetPoints(IntPtr ptr, [Out] Point3d[] points, int count); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool SurfaceMesh3_EIK_GetSegment(IntPtr ptr, int index, [Out] out Segment3d segment); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void SurfaceMesh3_EIK_GetSegments(IntPtr ptr, [Out] Segment3d[] segments, int count); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool SurfaceMesh3_EIK_GetTriangle(IntPtr ptr, int index, [Out] out Triangle3d tri); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void SurfaceMesh3_EIK_GetTriangles(IntPtr ptr, [Out] Triangle3d[] triangles, int count); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool SurfaceMesh3_EIK_GetVertex(IntPtr ptr, int index, [Out] out MeshVertex3 vert); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void SurfaceMesh3_EIK_GetVertices(IntPtr ptr, [Out] MeshVertex3[] vertexArray, int count); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool SurfaceMesh3_EIK_GetFace(IntPtr ptr, int index, [Out] out MeshFace3 face); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void SurfaceMesh3_EIK_GetFaces(IntPtr ptr, [Out] MeshFace3[] faceArray, int count); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool SurfaceMesh3_EIK_GetHalfedge(IntPtr ptr, int index, [Out] out MeshHalfedge3 edge); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void SurfaceMesh3_EIK_GetHalfedges(IntPtr ptr, [Out] MeshHalfedge3[] edgeArray, int count); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void SurfaceMesh3_EIK_Transform(IntPtr ptr, Matrix4x4d matrix); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool SurfaceMesh3_EIK_IsVertexBorder(IntPtr ptr, int index, bool check_all_incident_halfedges); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool SurfaceMesh3_EIK_IsHalfedgeBorder(IntPtr ptr, int index); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool SurfaceMesh3_EIK_IsEdgeBorder(IntPtr ptr, int index); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int SurfaceMesh3_EIK_BorderEdgeCount(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool SurfaceMesh3_EIK_IsClosed(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool SurfaceMesh3_EIK_CheckFaceVertexCount(IntPtr ptr, int count); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void SurfaceMesh3_EIK_Join(IntPtr ptr, IntPtr otherPtr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void SurfaceMesh3_EIK_BuildAABBTree(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void SurfaceMesh3_EIK_ReleaseAABBTree(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern Box3d SurfaceMesh3_EIK_GetBoundingBox(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void SurfaceMesh3_EIK_ReadOFF(IntPtr ptr, string filename); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void SurfaceMesh3_EIK_WriteOFF(IntPtr ptr, string filename); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void SurfaceMesh3_EIK_Triangulate(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool SurfaceMesh3_EIK_DoesSelfIntersect(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern double SurfaceMesh3_EIK_Area(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern Point3d SurfaceMesh3_EIK_Centroid(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern double SurfaceMesh3_EIK_Volume(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool SurfaceMesh3_EIK_DoesBoundAVolume(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern BOUNDED_SIDE SurfaceMesh3_EIK_SideOfTriangleMesh(IntPtr ptr, Point3d point); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool SurfaceMesh3_EIK_DoIntersects(IntPtr ptr, IntPtr otherPtr, bool test_bounded_sides); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void SurfaceMesh3_EIK_GetCentroids(IntPtr ptr, [Out] Point3d[] points, int count); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void SurfaceMesh3_EIK_ComputeVertexNormals(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void SurfaceMesh3_EIK_ComputeFaceNormals(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void SurfaceMesh3_EIK_GetVertexNormals(IntPtr ptr, [Out] Vector3d[] normals, int count); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void SurfaceMesh3_EIK_GetFaceNormals(IntPtr ptr, [Out] Vector3d[] normals, int count); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern PolygonalCount SurfaceMesh3_EIK_GetPolygonalCount(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern PolygonalCount SurfaceMesh3_EIK_GetDualPolygonalCount(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void SurfaceMesh3_EIK_CreatePolygonMesh(IntPtr ptr, Point2d[] points, int count, bool xz); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void SurfaceMesh3_EIK_CreatePolygonalMesh(IntPtr ptr, Point3d[] points, int pointsCount, int[] triangles, int triangleCount, int[] quads, int quadCount, int[] pentagons, int pentagonCount, int[] hexagons, int hexagonCount); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void SurfaceMesh3_EIK_GetPolygonalIndices(IntPtr ptr, [Out] int[] triangles, int triangleCount, [Out] int[] quads, int quadCount, [Out] int[] pentagons, int pentagonCount, [Out] int[] hexagons, int hexagonCount); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void SurfaceMesh3_EIK_GetDualPolygonalIndices(IntPtr ptr, [Out] int[] triangles, int triangleCount, [Out] int[] quads, int quadCount, [Out] int[] pentagons, int pentagonCount, [Out] int[] hexagons, int hexagonCount); } } ================================================ FILE: CGALDotNet/Polylines/Polyline2.cs ================================================ using System; using System.Collections; using System.Collections.Generic; using System.Text; using CGALDotNetGeometry.Numerics; using CGALDotNetGeometry.Shapes; using CGALDotNet.Polygons; namespace CGALDotNet.Polylines { /// /// Generic polyline definition. /// /// The kernel type. public sealed class Polyline2 : Polyline2 where K : CGALKernel, new() { /// /// Default constructor. /// public Polyline2() : base(new K()) { } /// /// Create from a set of points. /// /// The polylines points. public Polyline2(Point2d[] points) : base(new K(), points) { } /// /// Create from a pointer. /// /// The polylines pointer. internal Polyline2(IntPtr ptr) : base(new K(), ptr) { } /// /// The polyline as a string. /// /// The polyline as a string. public override string ToString() { return string.Format("[Polyline2<{0}>: Count={1}]", Kernel.Name, Count); } /// /// Copy the polyline. /// /// The copied polyline. public Polyline2 Copy() { var ptr = Kernel.Copy(Ptr); var copy = new Polyline2(ptr); return copy; } /// /// Create a polygon from the line. /// /// Threshold for the firat and last points being equal. /// The polygon. public Polygon2 ToPoylgon(double threshold = MathUtil.EPS_64) { var points = ToList(); if (Point2d.Distance(First, Last) < threshold) points.RemoveAt(points.Count-1); return new Polygon2(points.ToArray()); } } /// /// The abstract polyline definition. /// public abstract class Polyline2 : CGALObject, IEnumerable { /// /// Default constructor. /// private Polyline2() { } /// /// Construct with a new kernel. /// /// The polyline kernel. internal Polyline2(CGALKernel kernel) { Kernel = kernel.PolylineKernel2; Ptr = Kernel.Create(); } /// /// Construct with a new kernel. /// /// The polyline kernel. /// The points to construct from. internal Polyline2(CGALKernel kernel, Point2d[] points) { Kernel = kernel.PolylineKernel2; Ptr = Kernel.Create(); SetPoints(points, points.Length); } /// /// Construct with a new kernel. /// /// The polyline kernel. /// The polylines pointer. internal Polyline2(CGALKernel kernel, IntPtr ptr) : base(ptr) { Kernel = kernel.PolylineKernel2; Count = Kernel.Count(Ptr); } /// /// The number of points in the polyline. /// public int Count { get; private set; } /// /// The capacity of the point array. /// public int Capacity => Kernel.Capacity(Ptr); /// /// Get the first point. /// public Point2d First => this[0]; /// /// Get the last point. /// public Point2d Last => this[Count-1]; /// /// The polylines kernel. /// Contains the functions to the unmanaged CGAL polyline. /// protected private PolylineKernel2 Kernel { get; private set; } /// /// Array accessor for the polyline. /// Getting a point clamps to the last point in polyline. /// /// /// public Point2d this[int i] { get => GetPointClamped(i); set => SetPoint(i, value); } /// /// Clear the polyline of all points. /// public void Clear() { Count = 0; Kernel.Clear(Ptr); } /// /// Shrink the capacity to match the point count. /// public void ShrinkCapacityToFitCount() { Kernel.ShrinkToFit(Ptr); } /// /// Resize the point array. /// New elements will default to zero. /// /// public void Resize(int count) { Count = count; Kernel.Resize(Ptr, count); } /// /// Reverse the polints in the line. /// public void Reverse() { Kernel.Reverse(Ptr); } /// /// Remove the point at the index from the array. /// /// The points index public void Remove(int index) { if (index < 0 || index >= Count) throw new IndexOutOfRangeException("Index out of range."); Count--; Kernel.Erase(Ptr, index); } /// /// Remove a range of points from the array. /// /// The starting index /// The number of points to remove. public void Remove(int start, int count) { if (start < 0 || start >= Count || start + count >= Count || count > Count) throw new IndexOutOfRangeException("Index out of range."); Count -= count; Kernel.EraseRange(Ptr, start, count); } /// /// Remove the last point. /// public void RemoveLast() { if (Count == 0) return; Kernel.Erase(Ptr, Count-1); Count--; } /// /// Remove the point at the index from the array. /// /// The points index. /// The point to insert. public void Insert(int index, Point2d point) { if (index < 0 || index >= Count) throw new IndexOutOfRangeException("Index out of range."); Count++; Kernel.Insert(Ptr, index, point); } /// /// Remove a range of points from the array. /// /// The points to insert. /// The starting index. /// The number of points to insert. public void Insert(Point2d[] points, int start, int count) { if (start < 0 || start >= Count) throw new IndexOutOfRangeException("Index out of range."); ErrorUtil.CheckArray(points, count); Count += count; Kernel.InsertRange(Ptr, start, count, points); } /// /// Add the point to the end of the poylline. /// /// The point to add. public void Add(Point2d point) { Insert(Count - 1, point); } /// /// Does the first and last point match. /// /// The distance threshold that counts as match. /// public bool IsClosed(double threshold = 0) { return Kernel.IsClosed(Ptr, threshold); } /// /// Get the point a the index. /// /// The points index to get. /// The point at index. public Point2d GetPoint(int index) { return Kernel.GetPoint(Ptr, index); } /// /// Get the point at the index /// and wrap around the polyline. /// /// The points index. /// The point at the index. public Point2d GetPointWrapped(int index) { index = MathUtil.Wrap(index, Count); return Kernel.GetPoint(Ptr, index); } /// /// Get the point at the index /// and clamp to the polylines last point. /// /// The points index. /// The point at the index. public Point2d GetPointClamped(int index) { index = MathUtil.Clamp(index, 0, Count - 1); return Kernel.GetPoint(Ptr, index); } /// /// Get all the points in the polyline. /// /// The point array to copy the data into. /// The array length. public void GetPoints(Point2d[] points, int count) { ErrorUtil.CheckArray(points, count); Kernel.GetPoints(Ptr, points, count); } /// /// Get all the polyline points. /// /// The list to copy the data into. public void GetPoints(List points) { for (int i = 0; i < Count; i++) points.Add(GetPoint(i)); } /// /// Get all the polyline segments. /// /// The segment array to copy the data into. /// The array length. public void GetSegments(Segment2d[] segments, int count) { ErrorUtil.CheckArray(segments, count); Kernel.GetSegments(Ptr, segments, count); } /// /// Set the points at the index. /// /// The points index. /// The points value. public void SetPoint(int index, Point2d point) { Kernel.SetPoint(Ptr, index, point); } /// /// Set the points from the array. /// If the array is larger than the polyline then /// the new points will be appended to end of polyline. /// /// The points array. /// The array length. public void SetPoints(Point2d[] points, int count) { ErrorUtil.CheckArray(points, count); Kernel.SetPoints(Ptr, points, count); Count = count; } /// /// Finds the length of the polyline. /// /// public double FindLength() { return Math.Sqrt(Kernel.SqLength(Ptr)); } /// /// Finds the square length of the polyline. /// /// public double FindSquareLength() { return Kernel.SqLength(Ptr); } /// /// Translate the polyline. /// /// The amount to translate. public void Translate(Point2d translation) { Kernel.Translate(Ptr, translation); } /// /// Rotate the polyline. /// /// The amount to rotate in radians. public void Rotate(Radian rotation) { Kernel.Rotate(Ptr, rotation.angle); } /// /// Scale the polyline. /// /// The amount to scale. public void Scale(double scale) { Kernel.Scale(Ptr, scale); } /// /// Transform the polyline with a TRS matrix. /// /// The amount to translate. /// The amount to rotate. /// The amount to scale. public void Transform(Point2d translation, Radian rotation, double scale) { Kernel.Transform(Ptr, translation, rotation.angle, scale); } /// /// Enumerate all points in the polyline. /// /// Each point in polyline. public IEnumerator GetEnumerator() { for (int i = 0; i < Count; i++) yield return GetPoint(i); } /// /// Enumerate all points in the polyline. /// /// Each point in polyline. IEnumerator IEnumerable.GetEnumerator() { return GetEnumerator(); } /// /// Return all the points in the polyline in a array. /// /// The array. public Point2d[] ToArray() { var points = new Point2d[Count]; GetPoints(points, points.Length); return points; } /// /// Return all the points in the polyline in a list. /// /// The list. public List ToList() { var points = new List(Count); for (int i = 0; i < Count; i++) points.Add(GetPoint(i)); return points; } /// /// Convert the polyline to a new polyline with a different kernel. /// May result in different values due to precision issues. /// /// The new kernel type. /// The new polline. public Polyline2 Convert() where T : CGALKernel, new() { var k = typeof(T).Name; var e = CGALEnum.ToKernelEnum(k); var ptr = Kernel.Convert(Ptr, e); return new Polyline2(ptr); } /// /// Print the polyline into a styring builder. /// /// public override void Print(StringBuilder builder) { builder.AppendLine(ToString()); builder.AppendLine("Capacity = " + Capacity); builder.AppendLine("IsClosed = " + IsClosed()); builder.AppendLine("Length = " + FindLength()); } /// /// Release the unmanaged pointer. /// protected override void ReleasePtr() { Kernel.Release(Ptr); } /// /// Release the unmanaged pointer. /// protected override void ReleasePtr(IntPtr ptr) { Kernel.Release(ptr); } } } ================================================ FILE: CGALDotNet/Polylines/Polyline3.cs ================================================ using System; using System.Collections; using System.Collections.Generic; using System.Text; using CGALDotNetGeometry.Numerics; using CGALDotNetGeometry.Shapes; namespace CGALDotNet.Polylines { /// /// Generic polyline definition. /// /// The kernel type. public sealed class Polyline3 : Polyline3 where K : CGALKernel, new() { /// /// Default constructor. /// public Polyline3() : base(new K()) { } /// /// Create from a set of points. /// /// The polylines points. public Polyline3(Point3d[] points) : base(new K(), points) { } /// /// Create from a pointer. /// /// The polylines pointer. internal Polyline3(IntPtr ptr) : base(new K(), ptr) { } /// /// The polyline as a string. /// /// The polyline as a string. public override string ToString() { return string.Format("[Polyline3<{0}>: Count={1}]", Kernel.Name, Count); } /// /// Copy the polyline. /// /// The copied polyline. public Polyline3 Copy() { var ptr = Kernel.Copy(Ptr); var copy = new Polyline3(ptr); return copy; } } /// /// The abstract polyline definition. /// public abstract class Polyline3 : CGALObject, IEnumerable { /// /// Default constructor. /// private Polyline3() { } /// /// Construct with a new kernel. /// /// The polyline kernel. internal Polyline3(CGALKernel kernel) { Kernel = kernel.PolylineKernel3; Ptr = Kernel.Create(); } /// /// Construct with a new kernel. /// /// The polyline kernel. /// The points to construct from. internal Polyline3(CGALKernel kernel, Point3d[] points) { Kernel = kernel.PolylineKernel3; Ptr = Kernel.Create(); SetPoints(points, points.Length); } /// /// Construct with a new kernel. /// /// The polyline kernel. /// The polylines pointer. internal Polyline3(CGALKernel kernel, IntPtr ptr) : base(ptr) { Kernel = kernel.PolylineKernel3; Count = Kernel.Count(Ptr); } /// /// The number of points in the polyline. /// public int Count { get; private set; } /// /// The capacity of the point array. /// public int Capacity => Kernel.Capacity(Ptr); /// /// Get the first point. /// public Point3d First => this[0]; /// /// Get the last point. /// public Point3d Last => this[Count - 1]; /// /// The polylines kernel. /// Contains the functions to the unmanaged CGAL polyline. /// protected private PolylineKernel3 Kernel { get; private set; } /// /// Array accessor for the polyline. /// Getting a point clamps to the last point in polyline. /// /// /// public Point3d this[int i] { get => GetPointClamped(i); set => SetPoint(i, value); } /// /// Clear the polyline of all points. /// public void Clear() { Count = 0; Kernel.Clear(Ptr); } /// /// Shrink the capacity to match the point count. /// public void ShrinkCapacityToFitCount() { Kernel.ShrinkToFit(Ptr); } /// /// Resize the point array. /// New elements will default to zero. /// /// public void Resize(int count) { Count = count; Kernel.Resize(Ptr, count); } /// /// Reverse the polints in the line. /// public void Reverse() { Kernel.Reverse(Ptr); } /// /// Remove the point at the index from the array. /// /// The points index public void Remove(int index) { if (index < 0 || index >= Count) throw new IndexOutOfRangeException("Index out of range."); Count--; Kernel.Erase(Ptr, index); } /// /// Remove a range of points from the array. /// /// The starting index /// The number of points to remove. public void Remove(int start, int count) { if (start < 0 || start >= Count || start + count >= Count || count > Count) throw new IndexOutOfRangeException("Index out of range."); Count -= count; Kernel.EraseRange(Ptr, start, count); } /// /// Remove the last point. /// public void RemoveLast() { if (Count == 0) return; Kernel.Erase(Ptr, Count - 1); Count--; } /// /// Remove the point at the index from the array. /// /// The points index. /// The point to insert. public void Insert(int index, Point3d point) { if (index < 0 || index >= Count) throw new IndexOutOfRangeException("Index out of range."); Count++; Kernel.Insert(Ptr, index, point); } /// /// Remove a range of points from the array. /// /// The points to insert. /// The starting index. /// The number of points to insert. public void Insert(Point3d[] points, int start, int count) { if (start < 0 || start >= Count) throw new IndexOutOfRangeException("Index out of range."); ErrorUtil.CheckArray(points, count); Count += count; Kernel.InsertRange(Ptr, start, count, points); } /// /// Add the point to the end of the poylline. /// /// The point to add. public void Add(Point3d point) { Insert(Count - 1, point); } /// /// Does the first and last point match. /// /// The distance threshold that counts as match. /// public bool IsClosed(double threshold = 0) { return Kernel.IsClosed(Ptr, threshold); } /// /// Get the point a the index. /// /// The points index to get. /// The point at index. public Point3d GetPoint(int index) { return Kernel.GetPoint(Ptr, index); } /// /// Get the point at the index /// and wrap around the polyline. /// /// The points index. /// The point at the index. public Point3d GetPointWrapped(int index) { index = MathUtil.Wrap(index, Count); return Kernel.GetPoint(Ptr, index); } /// /// Get the point at the index /// and clamp to the polylines last point. /// /// The points index. /// The point at the index. public Point3d GetPointClamped(int index) { index = MathUtil.Clamp(index, 0, Count - 1); return Kernel.GetPoint(Ptr, index); } /// /// Get all the points in the polyline. /// /// The point array to copy the data into. /// The array length. public void GetPoints(Point3d[] points, int count) { ErrorUtil.CheckArray(points, count); Kernel.GetPoints(Ptr, points, count); } /// /// Get all the polyline points. /// /// The list to copy the data into. public void GetPoints(List points) { for (int i = 0; i < Count; i++) points.Add(GetPoint(i)); } /// /// Get all the polyline segments. /// /// The segment array to copy the data into. /// The array length. public void GetSegments(Segment3d[] segments, int count) { ErrorUtil.CheckArray(segments, count); Kernel.GetSegments(Ptr, segments, count); } /// /// Set the points at the index. /// /// The points index. /// The points value. public void SetPoint(int index, Point3d point) { Kernel.SetPoint(Ptr, index, point); } /// /// Set the points from the array. /// If the array is larger than the polyline then /// the new points will be appended to end of polyline. /// /// The points array. /// The array length. public void SetPoints(Point3d[] points, int count) { ErrorUtil.CheckArray(points, count); Kernel.SetPoints(Ptr, points, count); Count = count; } /// /// Finds the length of the polyline. /// /// public double FindLength() { return Math.Sqrt(Kernel.SqLength(Ptr)); } /// /// Finds the square length of the polyline. /// /// public double FindSquareLength() { return Kernel.SqLength(Ptr); } /// /// Translate each point in the polyline. /// /// The amount to translate. public void Translate(Point3d translation) { var m = Matrix4x4d.Translate(translation); Kernel.Transform(Ptr, m); } /// /// Rotate each point in the polyline. /// /// The amount to rotate. public void Rotate(Quaternion3d rotation) { var m = rotation.ToMatrix4x4d(); Kernel.Transform(Ptr, m); } /// /// Scale each point in the polyline. /// /// The amount to scale. public void Scale(Point3d scale) { var m = Matrix4x4d.Scale(scale); Kernel.Transform(Ptr, m); } /// /// Transform each point in the polyline. /// /// The amount to translate. /// The amount to rotate. /// The amount to scale. public void Transform(Point3d translation, Quaternion3d rotation, Point3d scale) { var m = Matrix4x4d.TranslateRotateScale(translation, rotation, scale); Kernel.Transform(Ptr, m); } /// /// Enumerate all points in the polyline. /// /// Each point in polyline. public IEnumerator GetEnumerator() { for (int i = 0; i < Count; i++) yield return GetPoint(i); } /// /// Enumerate all points in the polyline. /// /// Each point in polyline. IEnumerator IEnumerable.GetEnumerator() { return GetEnumerator(); } /// /// Return all the points in the polyline in a array. /// /// The array. public Point3d[] ToArray() { var points = new Point3d[Count]; GetPoints(points, points.Length); return points; } /// /// Return all the points in the polyline in a list. /// /// The list. public List ToList() { var points = new List(Count); for (int i = 0; i < Count; i++) points.Add(GetPoint(i)); return points; } /// /// Convert the polyline to a new polyline with a different kernel. /// May result in different values due to precision issues. /// /// The new kernel type. /// The new polline. public Polyline3 Convert() where T : CGALKernel, new() { var k = typeof(T).Name; var e = CGALEnum.ToKernelEnum(k); var ptr = Kernel.Convert(Ptr, e); return new Polyline3(ptr); } /// /// Print the polyline into a styring builder. /// /// public override void Print(StringBuilder builder) { builder.AppendLine(ToString()); builder.AppendLine("Capacity = " + Capacity); builder.AppendLine("IsClosed = " + IsClosed()); builder.AppendLine("Length = " + FindLength()); } /// /// Release the unmanaged pointer. /// protected override void ReleasePtr() { Kernel.Release(Ptr); } /// /// Release the unmanaged pointer. /// protected override void ReleasePtr(IntPtr ptr) { Kernel.Release(ptr); } } } ================================================ FILE: CGALDotNet/Polylines/PolylineKernel2.cs ================================================ using System; using System.Collections.Generic; using System.Text; using CGALDotNetGeometry.Numerics; using CGALDotNetGeometry.Shapes; namespace CGALDotNet.Polylines { internal abstract class PolylineKernel2 : CGALObjectKernel { internal abstract IntPtr Create(); internal abstract IntPtr CreateWithCount(int count); internal abstract void Release(IntPtr ptr); internal abstract int Count(IntPtr ptr); internal abstract IntPtr Copy(IntPtr ptr); internal abstract IntPtr Convert(IntPtr ptr, CGAL_KERNEL k); internal abstract void Clear(IntPtr ptr); internal abstract int Capacity(IntPtr ptr); internal abstract void Resize(IntPtr ptr, int count); internal abstract void Reverse(IntPtr ptr); internal abstract void ShrinkToFit(IntPtr ptr); internal abstract void Erase(IntPtr ptr, int index); internal abstract void EraseRange(IntPtr ptr, int start, int count); internal abstract void Insert(IntPtr ptr, int index, Point2d point); internal abstract void InsertRange(IntPtr ptr, int start, int count, Point2d[] points); internal abstract bool IsClosed(IntPtr ptr, double threshold); internal abstract double SqLength(IntPtr ptr); internal abstract Point2d GetPoint(IntPtr ptr, int index); internal abstract void GetPoints(IntPtr ptr, Point2d[] points, int count); internal abstract void GetSegments(IntPtr ptr, Segment2d[] segments, int count); internal abstract void SetPoint(IntPtr ptr, int index, Point2d point); internal abstract void SetPoints(IntPtr ptr, Point2d[] points, int count); internal abstract void Translate(IntPtr ptr, Point2d translation); internal abstract void Rotate(IntPtr ptr, double rotation); internal abstract void Scale(IntPtr ptr, double scale); internal abstract void Transform(IntPtr ptr, Point2d translation, double rotation, double scale); } } ================================================ FILE: CGALDotNet/Polylines/PolylineKernel2_EEK.cs ================================================ using System; using System.Collections.Generic; using System.Text; using System.Runtime.InteropServices; using CGALDotNetGeometry.Numerics; using CGALDotNetGeometry.Shapes; namespace CGALDotNet.Polylines { internal class PolylineKernel2_EEK : PolylineKernel2 { internal override string Name => "EEK"; internal static readonly PolylineKernel2 Instance = new PolylineKernel2_EEK(); internal override IntPtr Create() { return Polyline2_EEK_Create(); } internal override IntPtr CreateWithCount(int count) { return Polyline2_EEK_CreateWithCount(count); } internal override void Release(IntPtr ptr) { Polyline2_EEK_Release(ptr); } internal override int Count(IntPtr ptr) { return Polyline2_EEK_Count(ptr); } internal override IntPtr Copy(IntPtr ptr) { return Polyline2_EEK_Copy(ptr); } internal override IntPtr Convert(IntPtr ptr, CGAL_KERNEL k) { return Polyline2_EEK_Convert(ptr, k); } internal override void Clear(IntPtr ptr) { Polyline2_EEK_Clear(ptr); } internal override int Capacity(IntPtr ptr) { return Polyline2_EEK_Capacity(ptr); } internal override void Resize(IntPtr ptr, int count) { Polyline2_EEK_Resize(ptr, count); } internal override void Reverse(IntPtr ptr) { Polyline2_EEK_Reverse(ptr); } internal override void ShrinkToFit(IntPtr ptr) { Polyline2_EEK_ShrinkToFit(ptr); } internal override void Erase(IntPtr ptr, int index) { Polyline2_EEK_Erase(ptr, index); } internal override void EraseRange(IntPtr ptr, int start, int count) { Polyline2_EEK_EraseRange(ptr, start, count); } internal override void Insert(IntPtr ptr, int index, Point2d point) { Polyline2_EEK_Insert(ptr, index, point); } internal override void InsertRange(IntPtr ptr, int start, int count, Point2d[] points) { Polyline2_EEK_InsertRange(ptr, start, count, points); } internal override bool IsClosed(IntPtr ptr, double threshold) { return Polyline2_EEK_IsClosed(ptr, threshold); } internal override double SqLength(IntPtr ptr) { return Polyline2_EEK_SqLength(ptr); } internal override Point2d GetPoint(IntPtr ptr, int index) { return Polyline2_EEK_GetPoint(ptr, index); } internal override void GetPoints(IntPtr ptr, Point2d[] points, int count) { Polyline2_EEK_GetPoints(ptr, points, count); } internal override void GetSegments(IntPtr ptr, Segment2d[] segments, int count) { Polyline2_EEK_GetSegments(ptr, segments, count); } internal override void SetPoint(IntPtr ptr, int index, Point2d point) { Polyline2_EEK_SetPoint(ptr, index, point); } internal override void SetPoints(IntPtr ptr, Point2d[] points, int count) { Polyline2_EEK_SetPoints(ptr, points, count); } internal override void Translate(IntPtr ptr, Point2d translation) { Polyline2_EEK_Translate(ptr, translation); } internal override void Rotate(IntPtr ptr, double rotation) { Polyline2_EEK_Rotate(ptr, rotation); } internal override void Scale(IntPtr ptr, double scale) { Polyline2_EEK_Scale(ptr, scale); } internal override void Transform(IntPtr ptr, Point2d translation, double rotation, double scale) { Polyline2_EEK_Transform(ptr, translation, rotation, scale); } [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr Polyline2_EEK_Create(); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr Polyline2_EEK_CreateWithCount(int count); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void Polyline2_EEK_Release(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int Polyline2_EEK_Count(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr Polyline2_EEK_Copy(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr Polyline2_EEK_Convert(IntPtr ptr, CGAL_KERNEL k); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void Polyline2_EEK_Clear(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int Polyline2_EEK_Capacity(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void Polyline2_EEK_Resize(IntPtr ptr, int count); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void Polyline2_EEK_Reverse(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void Polyline2_EEK_ShrinkToFit(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void Polyline2_EEK_Erase(IntPtr ptr, int index); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void Polyline2_EEK_EraseRange(IntPtr ptr, int start, int count); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void Polyline2_EEK_Insert(IntPtr ptr, int index, Point2d point); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void Polyline2_EEK_InsertRange(IntPtr ptr, int start, int count, Point2d[] points); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool Polyline2_EEK_IsClosed(IntPtr ptr, double threshold); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern double Polyline2_EEK_SqLength(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern Point2d Polyline2_EEK_GetPoint(IntPtr ptr, int index); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void Polyline2_EEK_GetPoints(IntPtr ptr, [Out] Point2d[] points, int count); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void Polyline2_EEK_GetSegments(IntPtr ptr, [Out] Segment2d[] segments, int count); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void Polyline2_EEK_SetPoint(IntPtr ptr, int index, Point2d point); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void Polyline2_EEK_SetPoints(IntPtr ptr, Point2d[] points, int count); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void Polyline2_EEK_Translate(IntPtr ptr, Point2d translation); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void Polyline2_EEK_Rotate(IntPtr ptr, double rotation); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void Polyline2_EEK_Scale(IntPtr ptr, double scale); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void Polyline2_EEK_Transform(IntPtr ptr, Point2d translation, double rotation, double scale); } } ================================================ FILE: CGALDotNet/Polylines/PolylineKernel2_EIK.cs ================================================ using System; using System.Collections.Generic; using System.Text; using System.Runtime.InteropServices; using CGALDotNetGeometry.Numerics; using CGALDotNetGeometry.Shapes; namespace CGALDotNet.Polylines { internal class PolylineKernel2_EIK : PolylineKernel2 { internal override string Name => "EIK"; internal static readonly PolylineKernel2 Instance = new PolylineKernel2_EIK(); internal override IntPtr Create() { return Polyline2_EIK_Create(); } internal override IntPtr CreateWithCount(int count) { return Polyline2_EIK_CreateWithCount(count); } internal override void Release(IntPtr ptr) { Polyline2_EIK_Release(ptr); } internal override int Count(IntPtr ptr) { return Polyline2_EIK_Count(ptr); } internal override IntPtr Copy(IntPtr ptr) { return Polyline2_EIK_Copy(ptr); } internal override IntPtr Convert(IntPtr ptr, CGAL_KERNEL k) { return Polyline2_EIK_Convert(ptr, k); } internal override void Clear(IntPtr ptr) { Polyline2_EIK_Clear(ptr); } internal override int Capacity(IntPtr ptr) { return Polyline2_EIK_Capacity(ptr); } internal override void Resize(IntPtr ptr, int count) { Polyline2_EIK_Resize(ptr, count); } internal override void Reverse(IntPtr ptr) { Polyline2_EIK_Reverse(ptr); } internal override void ShrinkToFit(IntPtr ptr) { Polyline2_EIK_ShrinkToFit(ptr); } internal override void Erase(IntPtr ptr, int index) { Polyline2_EIK_Erase(ptr, index); } internal override void EraseRange(IntPtr ptr, int start, int count) { Polyline2_EIK_EraseRange(ptr, start, count); } internal override void Insert(IntPtr ptr, int index, Point2d point) { Polyline2_EIK_Insert(ptr, index, point); } internal override void InsertRange(IntPtr ptr, int start, int count, Point2d[] points) { Polyline2_EIK_InsertRange(ptr, start, count, points); } internal override bool IsClosed(IntPtr ptr, double threshold) { return Polyline2_EIK_IsClosed(ptr, threshold); } internal override double SqLength(IntPtr ptr) { return Polyline2_EIK_SqLength(ptr); } internal override Point2d GetPoint(IntPtr ptr, int index) { return Polyline2_EIK_GetPoint(ptr, index); } internal override void GetPoints(IntPtr ptr, Point2d[] points, int count) { Polyline2_EIK_GetPoints(ptr, points, count); } internal override void GetSegments(IntPtr ptr, Segment2d[] segments, int count) { Polyline2_EIK_GetSegments(ptr, segments, count); } internal override void SetPoint(IntPtr ptr, int index, Point2d point) { Polyline2_EIK_SetPoint(ptr, index, point); } internal override void SetPoints(IntPtr ptr, Point2d[] points, int count) { Polyline2_EIK_SetPoints(ptr, points, count); } internal override void Translate(IntPtr ptr, Point2d translation) { Polyline2_EIK_Translate(ptr, translation); } internal override void Rotate(IntPtr ptr, double rotation) { Polyline2_EIK_Rotate(ptr, rotation); } internal override void Scale(IntPtr ptr, double scale) { Polyline2_EIK_Scale(ptr, scale); } internal override void Transform(IntPtr ptr, Point2d translation, double rotation, double scale) { Polyline2_EIK_Transform(ptr, translation, rotation, scale); } [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr Polyline2_EIK_Create(); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr Polyline2_EIK_CreateWithCount(int count); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void Polyline2_EIK_Release(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int Polyline2_EIK_Count(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr Polyline2_EIK_Copy(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr Polyline2_EIK_Convert(IntPtr ptr, CGAL_KERNEL k); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void Polyline2_EIK_Clear(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int Polyline2_EIK_Capacity(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void Polyline2_EIK_Resize(IntPtr ptr, int count); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void Polyline2_EIK_Reverse(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void Polyline2_EIK_ShrinkToFit(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void Polyline2_EIK_Erase(IntPtr ptr, int index); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void Polyline2_EIK_EraseRange(IntPtr ptr, int start, int count); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void Polyline2_EIK_Insert(IntPtr ptr, int index, Point2d point); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void Polyline2_EIK_InsertRange(IntPtr ptr, int start, int count, Point2d[] points); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool Polyline2_EIK_IsClosed(IntPtr ptr, double threshold); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern double Polyline2_EIK_SqLength(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern Point2d Polyline2_EIK_GetPoint(IntPtr ptr, int index); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void Polyline2_EIK_GetPoints(IntPtr ptr, [Out] Point2d[] points, int count); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void Polyline2_EIK_GetSegments(IntPtr ptr, [Out] Segment2d[] segments, int count); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void Polyline2_EIK_SetPoint(IntPtr ptr, int index, Point2d point); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void Polyline2_EIK_SetPoints(IntPtr ptr, Point2d[] points, int count); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void Polyline2_EIK_Translate(IntPtr ptr, Point2d translation); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void Polyline2_EIK_Rotate(IntPtr ptr, double rotation); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void Polyline2_EIK_Scale(IntPtr ptr, double scale); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void Polyline2_EIK_Transform(IntPtr ptr, Point2d translation, double rotation, double scale); } } ================================================ FILE: CGALDotNet/Polylines/PolylineKernel3.cs ================================================ using System; using System.Collections.Generic; using System.Text; using CGALDotNetGeometry.Numerics; using CGALDotNetGeometry.Shapes; namespace CGALDotNet.Polylines { internal abstract class PolylineKernel3 : CGALObjectKernel { internal abstract IntPtr Create(); internal abstract IntPtr CreateWithCount(int count); internal abstract void Release(IntPtr ptr); internal abstract int Count(IntPtr ptr); internal abstract IntPtr Copy(IntPtr ptr); internal abstract IntPtr Convert(IntPtr ptr, CGAL_KERNEL k); internal abstract void Clear(IntPtr ptr); internal abstract int Capacity(IntPtr ptr); internal abstract void Resize(IntPtr ptr, int count); internal abstract void Reverse(IntPtr ptr); internal abstract void ShrinkToFit(IntPtr ptr); internal abstract void Erase(IntPtr ptr, int index); internal abstract void EraseRange(IntPtr ptr, int start, int count); internal abstract void Insert(IntPtr ptr, int index, Point3d point); internal abstract void InsertRange(IntPtr ptr, int start, int count, Point3d[] points); internal abstract bool IsClosed(IntPtr ptr, double threshold); internal abstract double SqLength(IntPtr ptr); internal abstract Point3d GetPoint(IntPtr ptr, int index); internal abstract void GetPoints(IntPtr ptr, Point3d[] points, int count); internal abstract void GetSegments(IntPtr ptr, Segment3d[] segments, int count); internal abstract void SetPoint(IntPtr ptr, int index, Point3d point); internal abstract void SetPoints(IntPtr ptr, Point3d[] points, int count); internal abstract void Transform(IntPtr ptr, Matrix4x4d matrix); } } ================================================ FILE: CGALDotNet/Polylines/PolylineKernel3_EEK.cs ================================================ using System; using System.Collections.Generic; using System.Text; using System.Runtime.InteropServices; using CGALDotNetGeometry.Numerics; using CGALDotNetGeometry.Shapes; namespace CGALDotNet.Polylines { internal class PolylineKernel3_EEK : PolylineKernel3 { internal override string Name => "EEK"; internal static readonly PolylineKernel3 Instance = new PolylineKernel3_EEK(); internal override IntPtr Create() { return Polyline3_EEK_Create(); } internal override IntPtr CreateWithCount(int count) { return Polyline3_EEK_CreateWithCount(count); } internal override void Release(IntPtr ptr) { Polyline3_EEK_Release(ptr); } internal override int Count(IntPtr ptr) { return Polyline3_EEK_Count(ptr); } internal override IntPtr Copy(IntPtr ptr) { return Polyline3_EEK_Copy(ptr); } internal override IntPtr Convert(IntPtr ptr, CGAL_KERNEL k) { return Polyline3_EEK_Convert(ptr, k); } internal override void Clear(IntPtr ptr) { Polyline3_EEK_Clear(ptr); } internal override int Capacity(IntPtr ptr) { return Polyline3_EEK_Capacity(ptr); } internal override void Resize(IntPtr ptr, int count) { Polyline3_EEK_Resize(ptr, count); } internal override void Reverse(IntPtr ptr) { Polyline3_EEK_Reverse(ptr); } internal override void ShrinkToFit(IntPtr ptr) { Polyline3_EEK_ShrinkToFit(ptr); } internal override void Erase(IntPtr ptr, int index) { Polyline3_EEK_Erase(ptr, index); } internal override void EraseRange(IntPtr ptr, int start, int count) { Polyline3_EEK_EraseRange(ptr, start, count); } internal override void Insert(IntPtr ptr, int index, Point3d point) { Polyline3_EEK_Insert(ptr, index, point); } internal override void InsertRange(IntPtr ptr, int start, int count, Point3d[] points) { Polyline3_EEK_InsertRange(ptr, start, count, points); } internal override bool IsClosed(IntPtr ptr, double threshold) { return Polyline3_EEK_IsClosed(ptr, threshold); } internal override double SqLength(IntPtr ptr) { return Polyline3_EEK_SqLength(ptr); } internal override Point3d GetPoint(IntPtr ptr, int index) { return Polyline3_EEK_GetPoint(ptr, index); } internal override void GetPoints(IntPtr ptr, Point3d[] points, int count) { Polyline3_EEK_GetPoints(ptr, points, count); } internal override void GetSegments(IntPtr ptr, Segment3d[] segments, int count) { Polyline3_EEK_GetSegments(ptr, segments, count); } internal override void SetPoint(IntPtr ptr, int index, Point3d point) { Polyline3_EEK_SetPoint(ptr, index, point); } internal override void SetPoints(IntPtr ptr, Point3d[] points, int count) { Polyline3_EEK_SetPoints(ptr, points, count); } internal override void Transform(IntPtr ptr, Matrix4x4d matrix) { Polyline3_EEK_Transform(ptr, matrix); } [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr Polyline3_EEK_Create(); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr Polyline3_EEK_CreateWithCount(int count); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void Polyline3_EEK_Release(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int Polyline3_EEK_Count(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr Polyline3_EEK_Copy(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr Polyline3_EEK_Convert(IntPtr ptr, CGAL_KERNEL k); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void Polyline3_EEK_Clear(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int Polyline3_EEK_Capacity(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void Polyline3_EEK_Resize(IntPtr ptr, int count); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void Polyline3_EEK_Reverse(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void Polyline3_EEK_ShrinkToFit(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void Polyline3_EEK_Erase(IntPtr ptr, int index); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void Polyline3_EEK_EraseRange(IntPtr ptr, int start, int count); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void Polyline3_EEK_Insert(IntPtr ptr, int index, Point3d point); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void Polyline3_EEK_InsertRange(IntPtr ptr, int start, int count, Point3d[] points); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool Polyline3_EEK_IsClosed(IntPtr ptr, double threshold); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern double Polyline3_EEK_SqLength(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern Point3d Polyline3_EEK_GetPoint(IntPtr ptr, int index); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void Polyline3_EEK_GetPoints(IntPtr ptr, [Out] Point3d[] points, int count); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void Polyline3_EEK_GetSegments(IntPtr ptr, [Out] Segment3d[] segments, int count); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void Polyline3_EEK_SetPoint(IntPtr ptr, int index, Point3d point); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void Polyline3_EEK_SetPoints(IntPtr ptr, Point3d[] points, int count); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void Polyline3_EEK_Transform(IntPtr ptr, Matrix4x4d matrix); } } ================================================ FILE: CGALDotNet/Polylines/PolylineKernel3_EIK.cs ================================================ using System; using System.Collections.Generic; using System.Text; using System.Runtime.InteropServices; using CGALDotNetGeometry.Numerics; using CGALDotNetGeometry.Shapes; namespace CGALDotNet.Polylines { internal class PolylineKernel3_EIK : PolylineKernel3 { internal override string Name => "EIK"; internal static readonly PolylineKernel3 Instance = new PolylineKernel3_EIK(); internal override IntPtr Create() { return Polyline3_EIK_Create(); } internal override IntPtr CreateWithCount(int count) { return Polyline3_EIK_CreateWithCount(count); } internal override void Release(IntPtr ptr) { Polyline3_EIK_Release(ptr); } internal override int Count(IntPtr ptr) { return Polyline3_EIK_Count(ptr); } internal override IntPtr Copy(IntPtr ptr) { return Polyline3_EIK_Copy(ptr); } internal override IntPtr Convert(IntPtr ptr, CGAL_KERNEL k) { return Polyline3_EIK_Convert(ptr, k); } internal override void Clear(IntPtr ptr) { Polyline3_EIK_Clear(ptr); } internal override int Capacity(IntPtr ptr) { return Polyline3_EIK_Capacity(ptr); } internal override void Resize(IntPtr ptr, int count) { Polyline3_EIK_Resize(ptr, count); } internal override void Reverse(IntPtr ptr) { Polyline3_EIK_Reverse(ptr); } internal override void ShrinkToFit(IntPtr ptr) { Polyline3_EIK_ShrinkToFit(ptr); } internal override void Erase(IntPtr ptr, int index) { Polyline3_EIK_Erase(ptr, index); } internal override void EraseRange(IntPtr ptr, int start, int count) { Polyline3_EIK_EraseRange(ptr, start, count); } internal override void Insert(IntPtr ptr, int index, Point3d point) { Polyline3_EIK_Insert(ptr, index, point); } internal override void InsertRange(IntPtr ptr, int start, int count, Point3d[] points) { Polyline3_EIK_InsertRange(ptr, start, count, points); } internal override bool IsClosed(IntPtr ptr, double threshold) { return Polyline3_EIK_IsClosed(ptr, threshold); } internal override double SqLength(IntPtr ptr) { return Polyline3_EIK_SqLength(ptr); } internal override Point3d GetPoint(IntPtr ptr, int index) { return Polyline3_EIK_GetPoint(ptr, index); } internal override void GetPoints(IntPtr ptr, Point3d[] points, int count) { Polyline3_EIK_GetPoints(ptr, points, count); } internal override void GetSegments(IntPtr ptr, Segment3d[] segments, int count) { Polyline3_EIK_GetSegments(ptr, segments, count); } internal override void SetPoint(IntPtr ptr, int index, Point3d point) { Polyline3_EIK_SetPoint(ptr, index, point); } internal override void SetPoints(IntPtr ptr, Point3d[] points, int count) { Polyline3_EIK_SetPoints(ptr, points, count); } internal override void Transform(IntPtr ptr, Matrix4x4d matrix) { Polyline3_EIK_Transform(ptr, matrix); } [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr Polyline3_EIK_Create(); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr Polyline3_EIK_CreateWithCount(int count); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void Polyline3_EIK_Release(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int Polyline3_EIK_Count(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr Polyline3_EIK_Copy(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr Polyline3_EIK_Convert(IntPtr ptr, CGAL_KERNEL k); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void Polyline3_EIK_Clear(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int Polyline3_EIK_Capacity(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void Polyline3_EIK_Resize(IntPtr ptr, int count); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void Polyline3_EIK_Reverse(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void Polyline3_EIK_ShrinkToFit(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void Polyline3_EIK_Erase(IntPtr ptr, int index); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void Polyline3_EIK_EraseRange(IntPtr ptr, int start, int count); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void Polyline3_EIK_Insert(IntPtr ptr, int index, Point3d point); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void Polyline3_EIK_InsertRange(IntPtr ptr, int start, int count, Point3d[] points); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool Polyline3_EIK_IsClosed(IntPtr ptr, double threshold); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern double Polyline3_EIK_SqLength(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern Point3d Polyline3_EIK_GetPoint(IntPtr ptr, int index); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void Polyline3_EIK_GetPoints(IntPtr ptr, [Out] Point3d[] points, int count); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void Polyline3_EIK_GetSegments(IntPtr ptr, [Out] Segment3d[] segments, int count); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void Polyline3_EIK_SetPoint(IntPtr ptr, int index, Point3d point); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void Polyline3_EIK_SetPoints(IntPtr ptr, Point3d[] points, int count); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void Polyline3_EIK_Transform(IntPtr ptr, Matrix4x4d matrix); } } ================================================ FILE: CGALDotNet/Processing/HeatMethod.cs ================================================ using System; using System.Collections.Generic; using System.Text; using CGALDotNetGeometry.Numerics; using CGALDotNet.Polyhedra; namespace CGALDotNet.Processing { /// /// The heat method is an algorithm that solves the single- or multiple-source shortest /// path problem by returning an approximation of the geodesic distance for all vertices /// of a triangle mesh to the closest vertex in a given set of source vertices. /// The geodesic distance between two vertices of a mesh is the distance when walking /// on the surface, potentially through the interior of faces. Two vertices that are /// close in 3D space may be far away on the surface. /// /// public sealed class HeatMethod : HeatMethod where K : CGALKernel, new() { /// /// Create a static instance. /// public static readonly HeatMethod Instance = new HeatMethod(); /// /// Create a new instance. /// public HeatMethod() : base(new K()) { } /// /// Create a new instance from a existing pointer to a unmanaged object. /// /// The unmanaged objects pointer. internal HeatMethod(IntPtr ptr) : base(new K(), ptr) { } /// /// /// /// public override string ToString() { return string.Format("[HeatMethod<{0}>: ]", Kernel.Name); } /// /// Find the distances for each vertex in the mesh to the vertex at the provided index. /// /// The mesh containing the vertices. /// The vertices index to find the distances to. /// The distances for each vertex in the mesh. /// Should the intrinsitic delaunay triangulation be used. /// This will improve the results for meshes that have bad triangle quality. /// The maximum distance value. public double EstimateGeodesicDistances(SurfaceMesh3 mesh, int index, List distances, bool useIDT = true) { CheckIsValidTriangleException(mesh); int count = Kernel.EstimateGeodesicDistances_SM(Ptr, mesh.Ptr, index, useIDT); double max = GetDistances(count, distances); ClearDistances(); return max; } /// /// Find the distances for each vertex in the mesh to the vertex at the provided index. /// /// The mesh containing the vertices. /// The vertices index to find the distances to. /// The distances for each vertex in the mesh. /// This will improve the results for meshes that have bad triangle quality. /// The maximum distance value. public double EstimateGeodesicDistances(Polyhedron3 mesh, int index, List distances) { CheckIsValidTriangleException(mesh); int count = Kernel.EstimateGeodesicDistances_PH(Ptr, mesh.Ptr, index, false); double max = GetDistances(count, distances); ClearDistances(); return max; } } public abstract class HeatMethod : PolyhedraAlgorithm { /// /// /// private HeatMethod() { } /// /// Create a new instance. /// /// internal HeatMethod(CGALKernel kernel) { Kernel = kernel.HeatMethodKernel; Ptr = Kernel.Create(); } /// /// Create a new instance from a existing pointer to a unmanaged object. /// /// /// The unmanaged objects pointer. internal HeatMethod(CGALKernel kernel, IntPtr ptr) : base(ptr) { Kernel = kernel.HeatMethodKernel; Ptr = ptr; } /// /// /// internal HeatMethodKernel Kernel { get; private set; } /// /// /// /// /// /// protected double GetDistances(int count, List distances) { double max = double.NegativeInfinity; for (int i = 0; i < count; i++) { var dist = GetDistance(i); if (dist > max) max = dist; distances.Add(dist); } return max; } /// /// /// /// /// protected double GetDistance(int index) { return Kernel.GetDistance(Ptr, index); } /// /// /// protected void ClearDistances() { Kernel.ClearDistances(Ptr); } /// /// /// protected override void ReleasePtr() { Kernel.Release(Ptr); } } } ================================================ FILE: CGALDotNet/Processing/HeatMethodKernel.cs ================================================ using System; using System.Collections.Generic; using System.Text; using CGALDotNetGeometry.Numerics; using CGALDotNetGeometry.Shapes; namespace CGALDotNet.Processing { internal abstract class HeatMethodKernel : CGALObjectKernel { internal abstract IntPtr Create(); internal abstract void Release(IntPtr ptr); internal abstract double GetDistance(IntPtr ptr, int index); internal abstract void ClearDistances(IntPtr ptr); internal abstract int EstimateGeodesicDistances_SM(IntPtr ptr, IntPtr meshPtr, int vertexIndex, bool useIDT); internal abstract int EstimateGeodesicDistances_PH(IntPtr ptr, IntPtr meshPtr, int vertexIndex, bool useIDT); } } ================================================ FILE: CGALDotNet/Processing/HeatMethodKernel_EEK.cs ================================================ using System; using System.Collections.Generic; using System.Text; using System.Runtime.InteropServices; using CGALDotNetGeometry.Numerics; using CGALDotNetGeometry.Shapes; namespace CGALDotNet.Processing { internal class HeatMethodKernel_EEK : HeatMethodKernel { internal override string Name => "EEK"; internal static readonly HeatMethodKernel Instance = new HeatMethodKernel_EEK(); internal override IntPtr Create() { return HeatMethod_EEK_Create(); } internal override void Release(IntPtr ptr) { HeatMethod_EEK_Release(ptr); } internal override double GetDistance(IntPtr ptr, int index) { return HeatMethod_EEK_GetDistance(ptr, index); } internal override void ClearDistances(IntPtr ptr) { HeatMethod_EEK_ClearDistances(ptr); } internal override int EstimateGeodesicDistances_SM(IntPtr ptr, IntPtr meshPtr, int vertexIndex, bool useIDT) { return HeatMethod_EEK_EstimateGeodesicDistances_SM(ptr, meshPtr, vertexIndex, useIDT); } internal override int EstimateGeodesicDistances_PH(IntPtr ptr, IntPtr meshPtr, int vertexIndex, bool useIDT) { return HeatMethod_EEK_EstimateGeodesicDistances_PH(ptr, meshPtr, vertexIndex, useIDT); } [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr HeatMethod_EEK_Create(); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void HeatMethod_EEK_Release(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern double HeatMethod_EEK_GetDistance(IntPtr ptr, int index); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void HeatMethod_EEK_ClearDistances(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int HeatMethod_EEK_EstimateGeodesicDistances_SM(IntPtr ptr, IntPtr meshPtr, int vertexIndex, bool useIDT); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int HeatMethod_EEK_EstimateGeodesicDistances_PH(IntPtr ptr, IntPtr meshPtr, int vertexIndex, bool useIDT); } } ================================================ FILE: CGALDotNet/Processing/HeatMethodKernel_EIK.cs ================================================ using System; using System.Collections.Generic; using System.Text; using System.Runtime.InteropServices; using CGALDotNetGeometry.Numerics; using CGALDotNetGeometry.Shapes; namespace CGALDotNet.Processing { internal class HeatMethodKernel_EIK : HeatMethodKernel { internal override string Name => "EIK"; internal static readonly HeatMethodKernel Instance = new HeatMethodKernel_EIK(); internal override IntPtr Create() { return HeatMethod_EIK_Create(); } internal override void Release(IntPtr ptr) { HeatMethod_EIK_Release(ptr); } internal override double GetDistance(IntPtr ptr, int index) { return HeatMethod_EIK_GetDistance(ptr, index); } internal override void ClearDistances(IntPtr ptr) { HeatMethod_EIK_ClearDistances(ptr); } internal override int EstimateGeodesicDistances_SM(IntPtr ptr, IntPtr meshPtr, int vertexIndex, bool useIDT) { return HeatMethod_EIK_EstimateGeodesicDistances_SM(ptr, meshPtr, vertexIndex, useIDT); } internal override int EstimateGeodesicDistances_PH(IntPtr ptr, IntPtr meshPtr, int vertexIndex, bool useIDT) { return HeatMethod_EIK_EstimateGeodesicDistances_PH(ptr, meshPtr, vertexIndex, useIDT); } [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr HeatMethod_EIK_Create(); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void HeatMethod_EIK_Release(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern double HeatMethod_EIK_GetDistance(IntPtr ptr, int index); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void HeatMethod_EIK_ClearDistances(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int HeatMethod_EIK_EstimateGeodesicDistances_SM(IntPtr ptr, IntPtr meshPtr, int vertexIndex, bool useIDT); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int HeatMethod_EIK_EstimateGeodesicDistances_PH(IntPtr ptr, IntPtr meshPtr, int vertexIndex, bool useIDT); } } ================================================ FILE: CGALDotNet/Processing/MeshProcessingBoolean.cs ================================================ using System; using System.Collections.Generic; using System.Text; using CGALDotNetGeometry.Numerics; using CGALDotNet.Polyhedra; namespace CGALDotNet.Processing { public enum POLYHEDRA_BOOLEAN { UNION, INTERSECT, DIFFERENCE }; /// /// /// /// public sealed class MeshProcessingBoolean : MeshProcessingBoolean where K : CGALKernel, new() { /// /// /// public static readonly MeshProcessingBoolean Instance = new MeshProcessingBoolean(); /// /// /// public MeshProcessingBoolean() : base(new K()) { } /// /// /// /// internal MeshProcessingBoolean(IntPtr ptr) : base(new K(), ptr) { } /// /// /// /// public override string ToString() { return string.Format("[MeshProcessingBoolean<{0}>: ]", Kernel.Name); } /// /// /// /// /// /// /// /// public bool Op(POLYHEDRA_BOOLEAN op, Polyhedron3 mesh1, Polyhedron3 mesh2, out Polyhedron3 result) { switch (op) { case POLYHEDRA_BOOLEAN.UNION: return Union(mesh1, mesh2, out result); case POLYHEDRA_BOOLEAN.INTERSECT: return Intersection(mesh1, mesh2, out result); case POLYHEDRA_BOOLEAN.DIFFERENCE: return Difference(mesh1, mesh2, out result); } result = null; return false; } /// /// /// /// /// /// /// /// public bool Op(POLYHEDRA_BOOLEAN op, SurfaceMesh3 mesh1, SurfaceMesh3 mesh2, out SurfaceMesh3 result) { switch (op) { case POLYHEDRA_BOOLEAN.UNION: return Union(mesh1, mesh2, out result); case POLYHEDRA_BOOLEAN.INTERSECT: return Intersection(mesh1, mesh2, out result); case POLYHEDRA_BOOLEAN.DIFFERENCE: return Difference(mesh1, mesh2, out result); } result = null; return false; } /// /// /// /// /// /// /// public bool Union(Polyhedron3 mesh1, Polyhedron3 mesh2, out Polyhedron3 result) { CheckIsValidException(mesh1); CheckIsValidException(mesh2); if (Kernel.Union_PH(mesh1.Ptr, mesh2.Ptr, out IntPtr resultPtr)) { result = new Polyhedron3(resultPtr); return true; } else { result = null; return false; } } /// /// /// /// /// /// /// public bool Union(SurfaceMesh3 mesh1, SurfaceMesh3 mesh2, out SurfaceMesh3 result) { CheckIsValidException(mesh1); CheckIsValidException(mesh2); if (Kernel.Union_SM(mesh1.Ptr, mesh2.Ptr, out IntPtr resultPtr)) { result = new SurfaceMesh3(resultPtr); return true; } else { result = null; return false; } } /// /// /// /// /// /// /// public bool Difference(Polyhedron3 mesh1, Polyhedron3 mesh2, out Polyhedron3 result) { CheckIsValidException(mesh1); CheckIsValidException(mesh2); if (Kernel.Difference_PH(mesh1.Ptr, mesh2.Ptr, out IntPtr resultPtr)) { result = new Polyhedron3(resultPtr); return true; } else { result = null; return false; } } /// /// /// /// /// /// /// public bool Difference(SurfaceMesh3 mesh1, SurfaceMesh3 mesh2, out SurfaceMesh3 result) { CheckIsValidException(mesh1); CheckIsValidException(mesh2); if (Kernel.Difference_SM(mesh1.Ptr, mesh2.Ptr, out IntPtr resultPtr)) { result = new SurfaceMesh3(resultPtr); return true; } else { result = null; return false; } } /// /// /// /// /// /// /// public bool Intersection(Polyhedron3 mesh1, Polyhedron3 mesh2, out Polyhedron3 result) { CheckIsValidException(mesh1); CheckIsValidException(mesh2); if (Kernel.Intersection_PH(mesh1.Ptr, mesh2.Ptr, out IntPtr resultPtr)) { result = new Polyhedron3(resultPtr); return true; } else { result = null; return false; } } /// /// /// /// /// /// /// public bool Intersection(SurfaceMesh3 mesh1, SurfaceMesh3 mesh2, out SurfaceMesh3 result) { CheckIsValidException(mesh1); CheckIsValidException(mesh2); if (Kernel.Intersection_PH(mesh1.Ptr, mesh2.Ptr, out IntPtr resultPtr)) { result = new SurfaceMesh3(resultPtr); return true; } else { result = null; return false; } } } /// /// /// public abstract class MeshProcessingBoolean : PolyhedraAlgorithm { /// /// /// private MeshProcessingBoolean() { } /// /// /// /// internal MeshProcessingBoolean(CGALKernel kernel) { Kernel = kernel.MeshProcessingBooleanKernel; Ptr = Kernel.Create(); } /// /// /// /// /// internal MeshProcessingBoolean(CGALKernel kernel, IntPtr ptr) : base(ptr) { Kernel = kernel.MeshProcessingBooleanKernel; Ptr = ptr; } /// /// /// internal MeshProcessingBooleanKernel Kernel { get; private set; } /// /// Release any unmanaged resources. /// protected override void ReleasePtr() { Kernel.Release(Ptr); } } } ================================================ FILE: CGALDotNet/Processing/MeshProcessingBooleanKernel.cs ================================================ using System; using System.Collections.Generic; using System.Text; using CGALDotNetGeometry.Numerics; using CGALDotNetGeometry.Shapes; namespace CGALDotNet.Processing { internal abstract class MeshProcessingBooleanKernel : CGALObjectKernel { internal abstract IntPtr Create(); internal abstract void Release(IntPtr ptr); //Polyhedron internal abstract bool Union_PH(IntPtr meshPtr1, IntPtr meshPtr2, out IntPtr resultPtr); internal abstract bool Difference_PH(IntPtr meshPtr1, IntPtr meshPtr2, out IntPtr resultPtr); internal abstract bool Intersection_PH(IntPtr meshPtr1, IntPtr meshPtr2, out IntPtr resultPtr); internal abstract bool Clip_PH(IntPtr meshPtr1, IntPtr meshPtr2, out IntPtr resultPtr); internal abstract bool PlaneClip_PH(IntPtr meshPtr1, Plane3d plane, out IntPtr resultPtr); internal abstract bool BoxClip_PH(IntPtr meshPtr1, Box3d box, out IntPtr resultPtr); //Surface Mesh internal abstract bool Union_SM(IntPtr meshPtr1, IntPtr meshPtr2, out IntPtr resultPtr); internal abstract bool Difference_SM(IntPtr meshPtr1, IntPtr meshPtr2, out IntPtr resultPtr); internal abstract bool Intersection_SM(IntPtr meshPtr1, IntPtr meshPtr2, out IntPtr resultPtr); internal abstract bool Clip_SM(IntPtr meshPtr1, IntPtr meshPtr2, out IntPtr resultPtr); internal abstract bool PlaneClip_SM(IntPtr meshPtr1, Plane3d plane, out IntPtr resultPtr); internal abstract bool BoxClip_SM(IntPtr meshPtr1, Box3d box, out IntPtr resultPtr); } } ================================================ FILE: CGALDotNet/Processing/MeshProcessingBooleanKernel_EEK.cs ================================================ using System; using System.Collections.Generic; using System.Text; using System.Runtime.InteropServices; using CGALDotNetGeometry.Numerics; using CGALDotNetGeometry.Shapes; namespace CGALDotNet.Processing { internal class MeshProcessingBooleanKernel_EEK : MeshProcessingBooleanKernel { internal override string Name => "EEK"; internal static readonly MeshProcessingBooleanKernel Instance = new MeshProcessingBooleanKernel_EEK(); internal override IntPtr Create() { return MeshProcessingBoolean_EEK_Create(); } internal override void Release(IntPtr ptr) { MeshProcessingBoolean_EEK_Release(ptr); } //Polyhedron internal override bool Union_PH(IntPtr meshPtr1, IntPtr meshPtr2, out IntPtr resultPtr) { return MeshProcessingBoolean_EEK_Union_PH(meshPtr1, meshPtr2, out resultPtr); } internal override bool Difference_PH(IntPtr meshPtr1, IntPtr meshPtr2, out IntPtr resultPtr) { return MeshProcessingBoolean_EEK_Difference_PH(meshPtr1, meshPtr2, out resultPtr); } internal override bool Intersection_PH(IntPtr meshPtr1, IntPtr meshPtr2, out IntPtr resultPtr) { return MeshProcessingBoolean_EEK_Intersection_PH(meshPtr1, meshPtr2, out resultPtr); } internal override bool Clip_PH(IntPtr meshPtr1, IntPtr meshPtr2, out IntPtr resultPtr) { return MeshProcessingBoolean_EEK_Clip_PH(meshPtr1, meshPtr2, out resultPtr); } internal override bool PlaneClip_PH(IntPtr meshPtr1, Plane3d plane, out IntPtr resultPtr) { return MeshProcessingBoolean_EEK_PlaneClip_PH(meshPtr1, plane, out resultPtr); } internal override bool BoxClip_PH(IntPtr meshPtr1, Box3d box, out IntPtr resultPtr) { return MeshProcessingBoolean_EEK_BoxClip_PH(meshPtr1, box, out resultPtr); } //Surface Mesh internal override bool Union_SM(IntPtr meshPtr1, IntPtr meshPtr2, out IntPtr resultPtr) { return MeshProcessingBoolean_EEK_Union_SM(meshPtr1, meshPtr2, out resultPtr); } internal override bool Difference_SM(IntPtr meshPtr1, IntPtr meshPtr2, out IntPtr resultPtr) { return MeshProcessingBoolean_EEK_Difference_SM(meshPtr1, meshPtr2, out resultPtr); } internal override bool Intersection_SM(IntPtr meshPtr1, IntPtr meshPtr2, out IntPtr resultPtr) { return MeshProcessingBoolean_EEK_Intersection_SM(meshPtr1, meshPtr2, out resultPtr); } internal override bool Clip_SM(IntPtr meshPtr1, IntPtr meshPtr2, out IntPtr resultPtr) { return MeshProcessingBoolean_EEK_Clip_SM(meshPtr1, meshPtr2, out resultPtr); } internal override bool PlaneClip_SM(IntPtr meshPtr1, Plane3d plane, out IntPtr resultPtr) { return MeshProcessingBoolean_EEK_PlaneClip_SM(meshPtr1, plane, out resultPtr); } internal override bool BoxClip_SM(IntPtr meshPtr1, Box3d box, out IntPtr resultPtr) { return MeshProcessingBoolean_EEK_BoxClip_SM(meshPtr1, box, out resultPtr); } [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr MeshProcessingBoolean_EEK_Create(); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void MeshProcessingBoolean_EEK_Release(IntPtr ptr); //Polyhedron [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool MeshProcessingBoolean_EEK_Union_PH(IntPtr meshPtr1, IntPtr meshPtr2, out IntPtr resultPtr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool MeshProcessingBoolean_EEK_Difference_PH(IntPtr meshPtr1, IntPtr meshPtr2, out IntPtr resultPtr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool MeshProcessingBoolean_EEK_Intersection_PH(IntPtr meshPtr1, IntPtr meshPtr2, out IntPtr resultPtr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool MeshProcessingBoolean_EEK_Clip_PH(IntPtr meshPtr1, IntPtr meshPtr2, out IntPtr resultPtr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool MeshProcessingBoolean_EEK_PlaneClip_PH(IntPtr meshPtr1, Plane3d plane, out IntPtr resultPtr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool MeshProcessingBoolean_EEK_BoxClip_PH(IntPtr meshPtr1, Box3d box, out IntPtr resultPtr); //Surface Mesh [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool MeshProcessingBoolean_EEK_Union_SM(IntPtr meshPtr1, IntPtr meshPtr2, out IntPtr resultPtr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool MeshProcessingBoolean_EEK_Difference_SM(IntPtr meshPtr1, IntPtr meshPtr2, out IntPtr resultPtr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool MeshProcessingBoolean_EEK_Intersection_SM(IntPtr meshPtr1, IntPtr meshPtr2, out IntPtr resultPtr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool MeshProcessingBoolean_EEK_Clip_SM(IntPtr meshPtr1, IntPtr meshPtr2, out IntPtr resultPtr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool MeshProcessingBoolean_EEK_PlaneClip_SM(IntPtr meshPtr1, Plane3d plane, out IntPtr resultPtr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool MeshProcessingBoolean_EEK_BoxClip_SM(IntPtr meshPtr1, Box3d box, out IntPtr resultPtr); } } ================================================ FILE: CGALDotNet/Processing/MeshProcessingBooleanKernel_EIK.cs ================================================ using System; using System.Collections.Generic; using System.Text; using System.Runtime.InteropServices; using CGALDotNetGeometry.Numerics; using CGALDotNetGeometry.Shapes; namespace CGALDotNet.Processing { internal class MeshProcessingBooleanKernel_EIK : MeshProcessingBooleanKernel { internal override string Name => "EIK"; internal static readonly MeshProcessingBooleanKernel Instance = new MeshProcessingBooleanKernel_EIK(); internal override IntPtr Create() { return MeshProcessingBoolean_EIK_Create(); } internal override void Release(IntPtr ptr) { MeshProcessingBoolean_EIK_Release(ptr); } //Polyhedron internal override bool Union_PH(IntPtr meshPtr1, IntPtr meshPtr2, out IntPtr resultPtr) { return MeshProcessingBoolean_EIK_Union_PH(meshPtr1, meshPtr2, out resultPtr); } internal override bool Difference_PH(IntPtr meshPtr1, IntPtr meshPtr2, out IntPtr resultPtr) { return MeshProcessingBoolean_EIK_Difference_PH(meshPtr1, meshPtr2, out resultPtr); } internal override bool Intersection_PH(IntPtr meshPtr1, IntPtr meshPtr2, out IntPtr resultPtr) { return MeshProcessingBoolean_EIK_Intersection_PH(meshPtr1, meshPtr2, out resultPtr); } internal override bool Clip_PH(IntPtr meshPtr1, IntPtr meshPtr2, out IntPtr resultPtr) { return MeshProcessingBoolean_EIK_Clip_PH(meshPtr1, meshPtr2, out resultPtr); } internal override bool PlaneClip_PH(IntPtr meshPtr1, Plane3d plane, out IntPtr resultPtr) { return MeshProcessingBoolean_EIK_PlaneClip_PH(meshPtr1, plane, out resultPtr); } internal override bool BoxClip_PH(IntPtr meshPtr1, Box3d box, out IntPtr resultPtr) { return MeshProcessingBoolean_EIK_BoxClip_PH(meshPtr1, box, out resultPtr); } //Surface Mesh internal override bool Union_SM(IntPtr meshPtr1, IntPtr meshPtr2, out IntPtr resultPtr) { return MeshProcessingBoolean_EIK_Union_SM(meshPtr1, meshPtr2, out resultPtr); } internal override bool Difference_SM(IntPtr meshPtr1, IntPtr meshPtr2, out IntPtr resultPtr) { return MeshProcessingBoolean_EIK_Difference_SM(meshPtr1, meshPtr2, out resultPtr); } internal override bool Intersection_SM(IntPtr meshPtr1, IntPtr meshPtr2, out IntPtr resultPtr) { return MeshProcessingBoolean_EIK_Intersection_SM(meshPtr1, meshPtr2, out resultPtr); } internal override bool Clip_SM(IntPtr meshPtr1, IntPtr meshPtr2, out IntPtr resultPtr) { return MeshProcessingBoolean_EIK_Clip_SM(meshPtr1, meshPtr2, out resultPtr); } internal override bool PlaneClip_SM(IntPtr meshPtr1, Plane3d plane, out IntPtr resultPtr) { return MeshProcessingBoolean_EIK_PlaneClip_SM(meshPtr1, plane, out resultPtr); } internal override bool BoxClip_SM(IntPtr meshPtr1, Box3d box, out IntPtr resultPtr) { return MeshProcessingBoolean_EIK_BoxClip_SM(meshPtr1, box, out resultPtr); } [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr MeshProcessingBoolean_EIK_Create(); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void MeshProcessingBoolean_EIK_Release(IntPtr ptr); //Polyhedron [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool MeshProcessingBoolean_EIK_Union_PH(IntPtr meshPtr1, IntPtr meshPtr2, out IntPtr resultPtr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool MeshProcessingBoolean_EIK_Difference_PH(IntPtr meshPtr1, IntPtr meshPtr2, out IntPtr resultPtr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool MeshProcessingBoolean_EIK_Intersection_PH(IntPtr meshPtr1, IntPtr meshPtr2, out IntPtr resultPtr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool MeshProcessingBoolean_EIK_Clip_PH(IntPtr meshPtr1, IntPtr meshPtr2, out IntPtr resultPtr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool MeshProcessingBoolean_EIK_PlaneClip_PH(IntPtr meshPtr1, Plane3d plane, out IntPtr resultPtr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool MeshProcessingBoolean_EIK_BoxClip_PH(IntPtr meshPtr1, Box3d box, out IntPtr resultPtr); //Surface Mesh [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool MeshProcessingBoolean_EIK_Union_SM(IntPtr meshPtr1, IntPtr meshPtr2, out IntPtr resultPtr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool MeshProcessingBoolean_EIK_Difference_SM(IntPtr meshPtr1, IntPtr meshPtr2, out IntPtr resultPtr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool MeshProcessingBoolean_EIK_Intersection_SM(IntPtr meshPtr1, IntPtr meshPtr2, out IntPtr resultPtr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool MeshProcessingBoolean_EIK_Clip_SM(IntPtr meshPtr1, IntPtr meshPtr2, out IntPtr resultPtr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool MeshProcessingBoolean_EIK_PlaneClip_SM(IntPtr meshPtr1, Plane3d plane, out IntPtr resultPtr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool MeshProcessingBoolean_EIK_BoxClip_SM(IntPtr meshPtr1, Box3d box, out IntPtr resultPtr); } } ================================================ FILE: CGALDotNet/Processing/MeshProcessingConnections.cs ================================================ using System; using System.Collections.Generic; using System.Text; using CGALDotNet.Polyhedra; namespace CGALDotNet.Processing { /// /// /// /// public sealed class MeshProcessingConnections : MeshProcessingConnections where K : CGALKernel, new() { /// /// /// public static readonly MeshProcessingConnections Instance = new MeshProcessingConnections(); /// /// /// public MeshProcessingConnections() : base(new K()) { } /// /// /// /// internal MeshProcessingConnections(IntPtr ptr) : base(new K(), ptr) { } /// /// /// /// public override string ToString() { return string.Format("[MeshProcessingConnections<{0}>: ]", Kernel.Name); } /* /// /// Returns the number of unconnect components in the mesh. /// /// A valid mesh. /// Returns the number of unconnect components in the mesh. public int UnconnectedComponents(Polyhedron3 mesh) { CheckIsValidException(mesh); return Kernel.ConnectedComponents_PH(mesh.Ptr); } */ /// /// Returns the number of unconnect components in the mesh. /// /// A valid mesh. /// Returns the number of unconnect components in the mesh. public int UnconnectedComponents(SurfaceMesh3 mesh) { CheckIsValidException(mesh); return Kernel.ConnectedComponents_SM(mesh.Ptr); } /// /// Returns a list of face indices that are part of the same component as the provided face index. /// /// A valid mesh. /// The faces index in the mesh. /// A list of face indices that are part of the same component as the provided face index. public void ConnectedFaces(Polyhedron3 mesh, int faceIndex, List results) { CheckIsValidException(mesh); int count = Kernel.ConnectedComponent_PH(Ptr, mesh.Ptr, faceIndex); if (count == 0) return; var indices = new int[count]; Kernel.GetConnectedComponentsFaceIndex_PH(Ptr, mesh.Ptr, indices, count); results.AddRange(indices); } /// /// Returns a list of face indices that are part of the same component as the provided face index. /// /// A valid mesh. /// The faces index in the mesh. /// A list of face indices that are part of the same component as the provided face index. public void ConnectedFaces(SurfaceMesh3 mesh, int faceIndex, List results) { CheckIsValidException(mesh); int count = Kernel.ConnectedComponent_SM(Ptr, mesh.Ptr, faceIndex); if (count == 0) return; var indices = new int[count]; Kernel.GetConnectedComponentsFaceIndex_SM(Ptr, mesh.Ptr, indices, count); results.AddRange(indices); } /// /// Split each component in the mesh into individual meshes. /// /// A valid mesh. /// The split meshes. public void SplitUnconnectedComponents(Polyhedron3 mesh, List> results) { CheckIsValidException(mesh); int count = Kernel.SplitConnectedComponents_PH(Ptr, mesh.Ptr); if (count == 0) return; var ptrs = new IntPtr[count]; Kernel.GetSplitConnectedComponents_PH(Ptr, ptrs, count); for (int i = 0; i < count; i++) results.Add( new Polyhedron3(ptrs[i])); } /// /// Split each component in the mesh into individual meshes. /// /// A valid mesh. /// The split meshes. public void SplitUnconnectedComponents(SurfaceMesh3 mesh, List> results) { CheckIsValidException(mesh); int count = Kernel.SplitConnectedComponents_SM(Ptr, mesh.Ptr); if (count == 0) return; var ptrs = new IntPtr[count]; Kernel.GetSplitConnectedComponents_SM(Ptr, ptrs, count); for (int i = 0; i < count; i++) results.Add(new SurfaceMesh3(ptrs[i])); } /// /// Removes connected components with less than a given number of faces. /// /// A valid mesh. /// The number of faces a component must have so that it is kept /// The number of components removed. public int KeepLargeComponents(Polyhedron3 mesh, int threshold_value) { CheckIsValidException(mesh); return Kernel.KeepLargeConnectedComponents_PH(mesh.Ptr, threshold_value); } /// /// Removes connected components with less than a given number of faces. /// /// A valid mesh. /// The number of faces a component must have so that it is kept /// The number of components removed. public int KeepLargeComponents(SurfaceMesh3 mesh, int threshold_value) { CheckIsValidException(mesh); return Kernel.KeepLargeConnectedComponents_SM(mesh.Ptr, threshold_value); } /// /// Removes the small connected components and all isolated vertices. /// /// A valid mesh. /// Keep this number of the largest connected components. /// The number of components removed. public int KeepLargestComponents(Polyhedron3 mesh, int num_components_to_keep) { CheckIsValidException(mesh); return Kernel.KeepLargestConnectedComponents_PH(mesh.Ptr, num_components_to_keep); } /// /// Removes the small connected components and all isolated vertices. /// /// A valid mesh. /// Keep this number of the largest connected components. /// The number of components removed. public int KeepLargestComponents(SurfaceMesh3 mesh, int num_components_to_keep) { CheckIsValidException(mesh); return Kernel.KeepLargestConnectedComponents_SM(mesh.Ptr, num_components_to_keep); } } /// /// /// public abstract class MeshProcessingConnections : PolyhedraAlgorithm { /// /// /// private MeshProcessingConnections() { } /// /// /// /// internal MeshProcessingConnections(CGALKernel kernel) { Kernel = kernel.MeshProcessingConnectionsKernel; Ptr = Kernel.Create(); } /// /// /// /// /// internal MeshProcessingConnections(CGALKernel kernel, IntPtr ptr) : base(ptr) { Kernel = kernel.MeshProcessingConnectionsKernel; Ptr = ptr; } /// /// /// internal MeshProcessingConnectionsKernel Kernel { get; private set; } /// /// Release any unmanaged resources. /// protected override void ReleasePtr() { Kernel.Release(Ptr); } } } ================================================ FILE: CGALDotNet/Processing/MeshProcessingConnectionsKernel.cs ================================================ using System; using System.Collections.Generic; using System.Text; namespace CGALDotNet.Processing { internal abstract class MeshProcessingConnectionsKernel : CGALObjectKernel { internal abstract IntPtr Create(); internal abstract void Release(IntPtr ptr); //Polyhedron internal abstract int ConnectedComponents_PH(IntPtr meshPtr); internal abstract int ConnectedComponent_PH(IntPtr ptr, IntPtr meshPtr, int index); internal abstract void GetConnectedComponentsFaceIndex_PH(IntPtr ptr, IntPtr meshPtr, int[] indices, int count); internal abstract int SplitConnectedComponents_PH(IntPtr ptr, IntPtr meshPtr); internal abstract void GetSplitConnectedComponents_PH(IntPtr ptr, IntPtr[] meshPtrs, int count); internal abstract int KeepLargeConnectedComponents_PH(IntPtr meshPtr, int threshold_value); internal abstract int KeepLargestConnectedComponents_PH(IntPtr meshPtr, int nb_components_to_keep); //Surface Mesh internal abstract int ConnectedComponents_SM(IntPtr meshPtr); internal abstract int ConnectedComponent_SM(IntPtr ptr, IntPtr meshPtr, int index); internal abstract void GetConnectedComponentsFaceIndex_SM(IntPtr ptr, IntPtr meshPtr, int[] indices, int count); internal abstract int SplitConnectedComponents_SM(IntPtr ptr, IntPtr meshPtr); internal abstract void GetSplitConnectedComponents_SM(IntPtr ptr, IntPtr[] meshPtrs, int count); internal abstract int KeepLargeConnectedComponents_SM(IntPtr meshPtr, int threshold_value); internal abstract int KeepLargestConnectedComponents_SM(IntPtr meshPtr, int nb_components_to_keep); } } ================================================ FILE: CGALDotNet/Processing/MeshProcessingConnectionsKernel_EEK.cs ================================================ using System; using System.Collections.Generic; using System.Text; using System.Runtime.InteropServices; namespace CGALDotNet.Processing { internal class MeshProcessingConnectionsKernel_EEK : MeshProcessingConnectionsKernel { internal override string Name => "EEK"; internal static readonly MeshProcessingConnectionsKernel Instance = new MeshProcessingConnectionsKernel_EEK(); internal override IntPtr Create() { return MeshProcessingConnections_EEK_Create(); } internal override void Release(IntPtr ptr) { MeshProcessingConnections_EEK_Release(ptr); } //Polyhedron internal override int ConnectedComponents_PH(IntPtr meshPtr) { return MeshProcessingConnections_EEK_ConnectedComponents_PH(meshPtr); } internal override int ConnectedComponent_PH(IntPtr ptr, IntPtr meshPtr, int index) { return MeshProcessingConnections_EEK_ConnectedComponent_PH(ptr, meshPtr, index); } internal override void GetConnectedComponentsFaceIndex_PH(IntPtr ptr, IntPtr meshPtr, int[] indices, int count) { MeshProcessingConnections_EEK_GetConnectedComponentsFaceIndex_PH(ptr, meshPtr, indices, count); } internal override int SplitConnectedComponents_PH(IntPtr ptr, IntPtr meshPtr) { return MeshProcessingConnections_EEK_SplitConnectedComponents_PH(ptr, meshPtr); } internal override void GetSplitConnectedComponents_PH(IntPtr ptr, IntPtr[] meshPtrs, int count) { MeshProcessingConnections_EEK_GetSplitConnectedComponents_PH(ptr, meshPtrs, count); } internal override int KeepLargeConnectedComponents_PH(IntPtr meshPtr, int threshold_value) { return MeshProcessingConnections_EEK_KeepLargeConnectedComponents_PH(meshPtr, threshold_value); } internal override int KeepLargestConnectedComponents_PH(IntPtr meshPtr, int nb_components_to_keep) { return MeshProcessingConnections_EEK_KeepLargestConnectedComponents_PH(meshPtr, nb_components_to_keep); } //Surface MEsh internal override int ConnectedComponents_SM(IntPtr meshPtr) { return MeshProcessingConnections_EEK_ConnectedComponents_SM(meshPtr); } internal override int ConnectedComponent_SM(IntPtr ptr, IntPtr meshPtr, int index) { return MeshProcessingConnections_EEK_ConnectedComponent_SM(ptr, meshPtr, index); } internal override void GetConnectedComponentsFaceIndex_SM(IntPtr ptr, IntPtr meshPtr, int[] indices, int count) { MeshProcessingConnections_EEK_GetConnectedComponentsFaceIndex_SM(ptr, meshPtr, indices, count); } internal override int SplitConnectedComponents_SM(IntPtr ptr, IntPtr meshPtr) { return MeshProcessingConnections_EEK_SplitConnectedComponents_SM(ptr, meshPtr); } internal override void GetSplitConnectedComponents_SM(IntPtr ptr, IntPtr[] meshPtrs, int count) { MeshProcessingConnections_EEK_GetSplitConnectedComponents_SM(ptr, meshPtrs, count); } internal override int KeepLargeConnectedComponents_SM(IntPtr meshPtr, int threshold_value) { return MeshProcessingConnections_EEK_KeepLargeConnectedComponents_SM(meshPtr, threshold_value); } internal override int KeepLargestConnectedComponents_SM(IntPtr meshPtr, int nb_components_to_keep) { return MeshProcessingConnections_EEK_KeepLargestConnectedComponents_SM(meshPtr, nb_components_to_keep); } [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr MeshProcessingConnections_EEK_Create(); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void MeshProcessingConnections_EEK_Release(IntPtr ptr); //Polyhedron [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int MeshProcessingConnections_EEK_ConnectedComponents_PH(IntPtr meshPtr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int MeshProcessingConnections_EEK_ConnectedComponent_PH(IntPtr ptr, IntPtr meshPtr, int index); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void MeshProcessingConnections_EEK_GetConnectedComponentsFaceIndex_PH(IntPtr ptr, IntPtr meshPtr, [Out] int[] indices, int count); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int MeshProcessingConnections_EEK_ConnectedComponent_PH(IntPtr meshPtr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int MeshProcessingConnections_EEK_SplitConnectedComponents_PH(IntPtr ptr, IntPtr meshPtr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void MeshProcessingConnections_EEK_GetSplitConnectedComponents_PH(IntPtr ptr, [Out] IntPtr[] meshPtrs, int count); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int MeshProcessingConnections_EEK_KeepLargeConnectedComponents_PH(IntPtr meshPtr, int threshold_value); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int MeshProcessingConnections_EEK_KeepLargestConnectedComponents_PH(IntPtr meshPtr, int nb_components_to_keep); //Surface Mesh [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int MeshProcessingConnections_EEK_ConnectedComponents_SM(IntPtr meshPtr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int MeshProcessingConnections_EEK_ConnectedComponent_SM(IntPtr ptr, IntPtr meshPtr, int index); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void MeshProcessingConnections_EEK_GetConnectedComponentsFaceIndex_SM(IntPtr ptr, IntPtr meshPtr, [Out] int[] indices, int count); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int MeshProcessingConnections_EEK_ConnectedComponent_SM(IntPtr meshPtr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int MeshProcessingConnections_EEK_SplitConnectedComponents_SM(IntPtr ptr, IntPtr meshPtr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void MeshProcessingConnections_EEK_GetSplitConnectedComponents_SM(IntPtr ptr, [Out] IntPtr[] meshPtrs, int count); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int MeshProcessingConnections_EEK_KeepLargeConnectedComponents_SM(IntPtr meshPtr, int threshold_value); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int MeshProcessingConnections_EEK_KeepLargestConnectedComponents_SM(IntPtr meshPtr, int nb_components_to_keep); } } ================================================ FILE: CGALDotNet/Processing/MeshProcessingConnectionsKernel_EIK.cs ================================================ using System; using System.Collections.Generic; using System.Text; using System.Runtime.InteropServices; namespace CGALDotNet.Processing { internal class MeshProcessingConnectionsKernel_EIK : MeshProcessingConnectionsKernel { internal override string Name => "EIK"; internal static readonly MeshProcessingConnectionsKernel Instance = new MeshProcessingConnectionsKernel_EIK(); internal override IntPtr Create() { return MeshProcessingConnections_EIK_Create(); } internal override void Release(IntPtr ptr) { MeshProcessingConnections_EIK_Release(ptr); } //Polyhedron internal override int ConnectedComponents_PH(IntPtr meshPtr) { return MeshProcessingConnections_EIK_ConnectedComponents_PH(meshPtr); } internal override int ConnectedComponent_PH(IntPtr ptr, IntPtr meshPtr, int index) { return MeshProcessingConnections_EIK_ConnectedComponent_PH(ptr, meshPtr, index); } internal override void GetConnectedComponentsFaceIndex_PH(IntPtr ptr, IntPtr meshPtr, int[] indices, int count) { MeshProcessingConnections_EIK_GetConnectedComponentsFaceIndex_PH(ptr, meshPtr, indices, count); } internal override int SplitConnectedComponents_PH(IntPtr ptr, IntPtr meshPtr) { return MeshProcessingConnections_EIK_SplitConnectedComponents_PH(ptr, meshPtr); } internal override void GetSplitConnectedComponents_PH(IntPtr ptr, IntPtr[] meshPtrs, int count) { MeshProcessingConnections_EIK_GetSplitConnectedComponents_PH(ptr, meshPtrs, count); } internal override int KeepLargeConnectedComponents_PH(IntPtr meshPtr, int threshold_value) { return MeshProcessingConnections_EIK_KeepLargeConnectedComponents_PH(meshPtr, threshold_value); } internal override int KeepLargestConnectedComponents_PH(IntPtr meshPtr, int nb_components_to_keep) { return MeshProcessingConnections_EIK_KeepLargestConnectedComponents_PH(meshPtr, nb_components_to_keep); } //Surface MEsh internal override int ConnectedComponents_SM(IntPtr meshPtr) { return MeshProcessingConnections_EIK_ConnectedComponents_SM(meshPtr); } internal override int ConnectedComponent_SM(IntPtr ptr, IntPtr meshPtr, int index) { return MeshProcessingConnections_EIK_ConnectedComponent_SM(ptr, meshPtr, index); } internal override void GetConnectedComponentsFaceIndex_SM(IntPtr ptr, IntPtr meshPtr, int[] indices, int count) { MeshProcessingConnections_EIK_GetConnectedComponentsFaceIndex_SM(ptr, meshPtr, indices, count); } internal override int SplitConnectedComponents_SM(IntPtr ptr, IntPtr meshPtr) { return MeshProcessingConnections_EIK_SplitConnectedComponents_SM(ptr, meshPtr); } internal override void GetSplitConnectedComponents_SM(IntPtr ptr, IntPtr[] meshPtrs, int count) { MeshProcessingConnections_EIK_GetSplitConnectedComponents_SM(ptr, meshPtrs, count); } internal override int KeepLargeConnectedComponents_SM(IntPtr meshPtr, int threshold_value) { return MeshProcessingConnections_EIK_KeepLargeConnectedComponents_SM(meshPtr, threshold_value); } internal override int KeepLargestConnectedComponents_SM(IntPtr meshPtr, int nb_components_to_keep) { return MeshProcessingConnections_EIK_KeepLargestConnectedComponents_SM(meshPtr, nb_components_to_keep); } [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr MeshProcessingConnections_EIK_Create(); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void MeshProcessingConnections_EIK_Release(IntPtr ptr); //Polyhedron [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int MeshProcessingConnections_EIK_ConnectedComponents_PH(IntPtr meshPtr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int MeshProcessingConnections_EIK_ConnectedComponent_PH(IntPtr ptr, IntPtr meshPtr, int index); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void MeshProcessingConnections_EIK_GetConnectedComponentsFaceIndex_PH(IntPtr ptr, IntPtr meshPtr, [Out] int[] indices, int count); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int MeshProcessingConnections_EIK_ConnectedComponent_PH(IntPtr meshPtr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int MeshProcessingConnections_EIK_SplitConnectedComponents_PH(IntPtr ptr, IntPtr meshPtr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void MeshProcessingConnections_EIK_GetSplitConnectedComponents_PH(IntPtr ptr, [Out] IntPtr[] meshPtrs, int count); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int MeshProcessingConnections_EIK_KeepLargeConnectedComponents_PH(IntPtr meshPtr, int threshold_value); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int MeshProcessingConnections_EIK_KeepLargestConnectedComponents_PH(IntPtr meshPtr, int nb_components_to_keep); //Surface Mesh [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int MeshProcessingConnections_EIK_ConnectedComponents_SM(IntPtr meshPtr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int MeshProcessingConnections_EIK_ConnectedComponent_SM(IntPtr ptr, IntPtr meshPtr, int index); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void MeshProcessingConnections_EIK_GetConnectedComponentsFaceIndex_SM(IntPtr ptr, IntPtr meshPtr, [Out] int[] indices, int count); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int MeshProcessingConnections_EIK_ConnectedComponent_SM(IntPtr meshPtr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int MeshProcessingConnections_EIK_SplitConnectedComponents_SM(IntPtr ptr, IntPtr meshPtr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void MeshProcessingConnections_EIK_GetSplitConnectedComponents_SM(IntPtr ptr, [Out] IntPtr[] meshPtrs, int count); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int MeshProcessingConnections_EIK_KeepLargeConnectedComponents_SM(IntPtr meshPtr, int threshold_value); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int MeshProcessingConnections_EIK_KeepLargestConnectedComponents_SM(IntPtr meshPtr, int nb_components_to_keep); } } ================================================ FILE: CGALDotNet/Processing/MeshProcessingFeatures.cs ================================================ using System; using System.Collections.Generic; using System.Text; using CGALDotNetGeometry.Numerics; using CGALDotNet.Polyhedra; using CGALDotNet.Polylines; namespace CGALDotNet.Processing { /// /// /// /// public sealed class MeshProcessingFeatures : MeshProcessingFeatures where K : CGALKernel, new() { /// /// /// public static readonly MeshProcessingFeatures Instance = new MeshProcessingFeatures(); /// /// /// public MeshProcessingFeatures() : base(new K()) { } /// /// /// /// internal MeshProcessingFeatures(IntPtr ptr) : base(new K(), ptr) { } /// /// Detects the edges that are considered to be sharp with respect to the given angle bound. /// /// A valid mesh. /// Angle in deg gives the maximum angle between /// the two normal vectors of adjacent triangles. For an edge of the input polygon mesh, /// if the angle between the two normal vectors of its incident facets is bigger than /// the given bound, then the edge is marked as being a feature edge. /// The halfedge indices of the edges that count as sharp. public void DetectSharpEdges(Polyhedron3 mesh, Degree feature_angle, List featureEdges) { CheckIsValidException(mesh); int num_edges = Kernel.DetectSharpEdges_PH(Ptr, mesh.Ptr, feature_angle.angle); GetFeatureEdges(MESH_TYPE.POLYHEDRON, mesh.Ptr, num_edges, featureEdges); } /// /// Detects the edges that are considered to be sharp with respect to the given angle bound. /// /// A valid mesh. /// Angle in deg gives the maximum angle between /// the two normal vectors of adjacent triangles. For an edge of the input polygon mesh, /// if the angle between the two normal vectors of its incident facets is bigger than /// the given bound, then the edge is marked as being a feature edge. /// The halfedge indices of the edges that count as sharp. public void DetectSharpEdges(SurfaceMesh3 mesh, Degree feature_angle, List featureEdges) { CheckIsValidException(mesh); int num_edges = Kernel.DetectSharpEdges_SM(Ptr, mesh.Ptr, feature_angle.angle); GetFeatureEdges(MESH_TYPE.SURFACE_MESH, mesh.Ptr, num_edges, featureEdges); } /// /// Find the min, max and average edge lengths in the mesh. /// /// A valid mesh. /// The min, max and average edge lengths in the mesh. public MinMaxAvg EdgeLengthMinMaxAvg(Polyhedron3 mesh) { CheckIsValidException(mesh); return Kernel.EdgeLengthMinMaxAvg_PH(mesh.Ptr); } /// /// Find the min, max and average edge lengths in the mesh. /// /// A valid mesh. /// The min, max and average edge lengths in the mesh. public MinMaxAvg EdgeLengthMinMaxAvg(SurfaceMesh3 mesh) { CheckIsValidException(mesh); return Kernel.EdgeLengthMinMaxAvg_SM(mesh.Ptr); } /// /// Find the min, max and average face areas in the mesh. /// /// A valid mesh. /// The min, max and average face areas in the mesh. public MinMaxAvg FaceAreaMinMaxAvg(Polyhedron3 mesh) { CheckIsValidException(mesh); return Kernel.FaceAreaMinMaxAvg_PH(mesh.Ptr); } /// /// Find the min, max and average face areas in the mesh. /// /// A valid mesh. /// The min, max and average face areas in the mesh. public MinMaxAvg FaceAreaMinMaxAvg(SurfaceMesh3 mesh) { CheckIsValidException(mesh); return Kernel.FaceAreaMinMaxAvg_SM(mesh.Ptr); } /// /// Detects the sharp edges of mesh according to angle as the DetectSharpEdges function does. /// The sharp edges are then used to define a segmentation of a mesh, that is done by computing /// a surface patch id for each face. /// /// A valid mesh. /// Angle in deg gives the maximum angle between /// the two normal vectors of adjacent triangles. For an edge of the input polygon mesh, /// if the angle between the two normal vectors of its incident facets is bigger than /// the given bound, then the edge is marked as being a feature edge. /// The halfedge indices of the edges that count as sharp. /// The face indices for each patch found. public void SharpEdgesSegmentation(SurfaceMesh3 mesh, Degree feature_angle, List featureEdges, List> featurePatches) { CheckIsValidException(mesh); var count = Kernel.SharpEdgesSegmentation_SM(Ptr, mesh.Ptr, feature_angle.angle); int num_edges = count.first; int num_patches = count.second; GetFeatureEdges(MESH_TYPE.SURFACE_MESH, mesh.Ptr, num_edges, featureEdges); GetFeaturePatches(MESH_TYPE.SURFACE_MESH, mesh.Ptr, num_patches, featurePatches); } /// /// Detects the sharp edges of pmesh according to angle as the DetectSharpEdges function does. /// The sharp edges are then used to define a segmentation of a mesh, that is done by computing /// a surface patch id for each face. /// /// A valid mesh. /// Angle in deg gives the maximum angle between /// the two normal vectors of adjacent triangles. For an edge of the input polygon mesh, /// if the angle between the two normal vectors of its incident facets is bigger than /// the given bound, then the edge is marked as being a feature edge. /// The face indices for each patch found. public void SharpEdgesSegmentation(SurfaceMesh3 mesh, Degree feature_angle, List> featurePatches) { CheckIsValidException(mesh); var count = Kernel.SharpEdgesSegmentation_SM(Ptr, mesh.Ptr, feature_angle.angle); int num_patches = count.second; GetFeaturePatches(MESH_TYPE.SURFACE_MESH, mesh.Ptr, num_patches, featurePatches); } /// /// /// /// public override string ToString() { return string.Format("[MeshProcessingFeatures<{0}>: ]", Kernel.Name); } } /// /// /// public abstract class MeshProcessingFeatures : PolyhedraAlgorithm { /// /// /// /// internal MeshProcessingFeatures(CGALKernel kernel) { Kernel = kernel.MeshProcessingFeaturesKernel; Ptr = Kernel.Create(); } /// /// /// /// /// internal MeshProcessingFeatures(CGALKernel kernel, IntPtr ptr) : base(ptr) { Kernel = kernel.MeshProcessingFeaturesKernel; Ptr = ptr; } /// /// /// private MeshProcessingFeatures() { } /// /// /// internal MeshProcessingFeaturesKernel Kernel { get; private set; } /// /// /// /// /// /// /// protected void GetFeatureEdges(MESH_TYPE type, IntPtr meshPtr, int num_edges, List featureEdges) { if (num_edges == 0) return; if (type == MESH_TYPE.POLYHEDRON) { var indices = new int[num_edges]; Kernel.GetSharpEdges_PH(Ptr, meshPtr, indices, num_edges); featureEdges.AddRange(indices); } else if (type == MESH_TYPE.SURFACE_MESH) { var indices = new int[num_edges]; Kernel.GetSharpEdges_SM(Ptr, meshPtr, indices, num_edges); featureEdges.AddRange(indices); } } /// /// /// /// /// /// /// /// protected void GetFeaturePatches(MESH_TYPE type, IntPtr meshPtr, int num_patches, List> featurePatches) { if (num_patches == 0) return; if (type == MESH_TYPE.POLYHEDRON) { throw new NotImplementedException(); } else if (type == MESH_TYPE.SURFACE_MESH) { for (int i = 0; i < num_patches; i++) { int num_faces = Kernel.GetPatchBufferFaceCount_SM(Ptr, i); var faces = new List(); for (int j = 0; j < num_faces; j++) { int index = Kernel.GetPatchBufferFaceIndex_SM(Ptr, i, j); if (index == CGALGlobal.NULL_INDEX) continue; faces.Add(index); } if(faces.Count > 0) featurePatches.Add(faces); } Kernel.ClearPatchBuffer_SM(Ptr); } } /// /// Release any unmanaged resources. /// protected override void ReleasePtr() { Kernel.Release(Ptr); } } } ================================================ FILE: CGALDotNet/Processing/MeshProcessingFeaturesKernel.cs ================================================ using System; using System.Collections.Generic; using System.Text; using CGALDotNetGeometry.Numerics; namespace CGALDotNet.Processing { internal abstract class MeshProcessingFeaturesKernel : CGALObjectKernel { internal abstract IntPtr Create(); internal abstract void Release(IntPtr ptr); //Polyhedron internal abstract int DetectSharpEdges_PH(IntPtr feaPtr, IntPtr meshPtr, double feature_angle); internal abstract void GetSharpEdges_PH(IntPtr feaPtr, IntPtr meshPtr, int[] indices, int count); internal abstract Index2 SharpEdgesSegmentation_PH(IntPtr feaPtr, IntPtr meshPtr, double feature_angle); internal abstract void ClearPatchBuffer_PH(IntPtr feaPtr); internal abstract int GetPatchBufferFaceCount_PH(IntPtr feaPtr, int patchIndex); internal abstract int GetPatchBufferFaceIndex_PH(IntPtr feaPtr, int patchIndex, int faceIndex); internal abstract MinMaxAvg EdgeLengthMinMaxAvg_PH(IntPtr ptr); internal abstract MinMaxAvg FaceAreaMinMaxAvg_PH(IntPtr ptr); //Surface Mesh internal abstract int DetectSharpEdges_SM(IntPtr feaPtr, IntPtr meshPtr, double feature_angle); internal abstract void GetSharpEdges_SM(IntPtr feaPtr, IntPtr meshPtr, int[] indices, int count); internal abstract Index2 SharpEdgesSegmentation_SM(IntPtr feaPtr, IntPtr meshPtr, double feature_angle); internal abstract void ClearPatchBuffer_SM(IntPtr feaPtr); internal abstract int GetPatchBufferFaceCount_SM(IntPtr feaPtr, int patchIndex); internal abstract int GetPatchBufferFaceIndex_SM(IntPtr feaPtr, int patchIndex, int faceIndex); internal abstract MinMaxAvg EdgeLengthMinMaxAvg_SM(IntPtr ptr); internal abstract MinMaxAvg FaceAreaMinMaxAvg_SM(IntPtr ptr); } } ================================================ FILE: CGALDotNet/Processing/MeshProcessingFeaturesKernel_EEK.cs ================================================ using System; using System.Collections.Generic; using System.Text; using System.Runtime.InteropServices; using CGALDotNetGeometry.Numerics; namespace CGALDotNet.Processing { internal class MeshProcessingFeaturesKernel_EEK : MeshProcessingFeaturesKernel { internal override string Name => "EEK"; internal static readonly MeshProcessingFeaturesKernel Instance = new MeshProcessingFeaturesKernel_EEK(); internal override IntPtr Create() { return MeshProcessingFeatures_EEK_Create(); } internal override void Release(IntPtr ptr) { MeshProcessingFeatures_EEK_Release(ptr); } //Polyhedron internal override int DetectSharpEdges_PH(IntPtr feaPtr, IntPtr meshPtr, double feature_angle) { return MeshProcessingFeatures_EEK_DetectSharpEdges_PH(feaPtr, meshPtr, feature_angle); } internal override void GetSharpEdges_PH(IntPtr feaPtr, IntPtr meshPtr, int[] indices, int count) { MeshProcessingFeatures_EEK_GetSharpEdges_PH(feaPtr, meshPtr, indices, count); } internal override Index2 SharpEdgesSegmentation_PH(IntPtr feaPtr, IntPtr meshPtr, double feature_angle) { return MeshProcessingFeatures_EEK_SharpEdgesSegmentation_PH(feaPtr, meshPtr, feature_angle); } internal override void ClearPatchBuffer_PH(IntPtr feaPtr) { MeshProcessingFeatures_EEK_ClearPatchBuffer_PH(feaPtr); } internal override int GetPatchBufferFaceCount_PH(IntPtr feaPtr, int patchIndex) { return MeshProcessingFeatures_EEK_GetPatchBufferFaceCount_PH(feaPtr, patchIndex); } internal override int GetPatchBufferFaceIndex_PH(IntPtr feaPtr, int patchIndex, int faceIndex) { return MeshProcessingFeatures_EEK_GetPatchBufferFaceIndex_PH(feaPtr, patchIndex, faceIndex); } internal override MinMaxAvg EdgeLengthMinMaxAvg_PH(IntPtr ptr) { return MeshProcessingFeatures_EEK_EdgeLengthMinMaxAvg_PH(ptr); } internal override MinMaxAvg FaceAreaMinMaxAvg_PH(IntPtr ptr) { return MeshProcessingFeatures_EEK_FaceAreaMinMaxAvg_PH(ptr); } //Surface Mesh internal override int DetectSharpEdges_SM(IntPtr feaPtr, IntPtr meshPtr, double feature_angle) { return MeshProcessingFeatures_EEK_DetectSharpEdges_SM(feaPtr, meshPtr, feature_angle); } internal override void GetSharpEdges_SM(IntPtr feaPtr, IntPtr meshPtr, int[] indices, int count) { MeshProcessingFeatures_EEK_GetSharpEdges_SM(feaPtr, meshPtr, indices, count); } internal override Index2 SharpEdgesSegmentation_SM(IntPtr feaPtr, IntPtr meshPtr, double feature_angle) { return MeshProcessingFeatures_EEK_SharpEdgesSegmentation_SM(feaPtr, meshPtr, feature_angle); } internal override void ClearPatchBuffer_SM(IntPtr feaPtr) { MeshProcessingFeatures_EEK_ClearPatchBuffer_SM(feaPtr); } internal override int GetPatchBufferFaceCount_SM(IntPtr feaPtr, int patchIndex) { return MeshProcessingFeatures_EEK_GetPatchBufferFaceCount_SM(feaPtr, patchIndex); } internal override int GetPatchBufferFaceIndex_SM(IntPtr feaPtr, int patchIndex, int faceIndex) { return MeshProcessingFeatures_EEK_GetPatchBufferFaceIndex_SM(feaPtr, patchIndex, faceIndex); } internal override MinMaxAvg EdgeLengthMinMaxAvg_SM(IntPtr ptr) { return MeshProcessingFeatures_EEK_EdgeLengthMinMaxAvg_SM(ptr); } internal override MinMaxAvg FaceAreaMinMaxAvg_SM(IntPtr ptr) { return MeshProcessingFeatures_EEK_FaceAreaMinMaxAvg_SM(ptr); } [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr MeshProcessingFeatures_EEK_Create(); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void MeshProcessingFeatures_EEK_Release(IntPtr ptr); //Polyhedron [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int MeshProcessingFeatures_EEK_DetectSharpEdges_PH(IntPtr feaPtr, IntPtr meshPtr, double feature_angle); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void MeshProcessingFeatures_EEK_GetSharpEdges_PH(IntPtr feaPtr, IntPtr meshPtr, [Out] int[] indices, int count); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern Index2 MeshProcessingFeatures_EEK_SharpEdgesSegmentation_PH(IntPtr feaPtr, IntPtr meshPtr, double feature_angle); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void MeshProcessingFeatures_EEK_ClearPatchBuffer_PH(IntPtr feaPtr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int MeshProcessingFeatures_EEK_GetPatchBufferFaceCount_PH(IntPtr feaPtr, int patchIndex); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int MeshProcessingFeatures_EEK_GetPatchBufferFaceIndex_PH(IntPtr feaPtr, int patchIndex, int faceIndex); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern MinMaxAvg MeshProcessingFeatures_EEK_EdgeLengthMinMaxAvg_PH(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern MinMaxAvg MeshProcessingFeatures_EEK_FaceAreaMinMaxAvg_PH(IntPtr ptr); //Surface Mesh [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int MeshProcessingFeatures_EEK_DetectSharpEdges_SM(IntPtr feaPtr, IntPtr meshPtr, double feature_angle); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void MeshProcessingFeatures_EEK_GetSharpEdges_SM(IntPtr feaPtr, IntPtr meshPtr, [Out] int[] indices, int count); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern Index2 MeshProcessingFeatures_EEK_SharpEdgesSegmentation_SM(IntPtr feaPtr, IntPtr meshPtr, double feature_angle); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void MeshProcessingFeatures_EEK_ClearPatchBuffer_SM(IntPtr feaPtr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int MeshProcessingFeatures_EEK_GetPatchBufferFaceCount_SM(IntPtr feaPtr, int patchIndex); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int MeshProcessingFeatures_EEK_GetPatchBufferFaceIndex_SM(IntPtr feaPtr, int patchIndex, int faceIndex); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern MinMaxAvg MeshProcessingFeatures_EEK_EdgeLengthMinMaxAvg_SM(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern MinMaxAvg MeshProcessingFeatures_EEK_FaceAreaMinMaxAvg_SM(IntPtr ptr); } } ================================================ FILE: CGALDotNet/Processing/MeshProcessingFeaturesKernel_EIK.cs ================================================ using System; using System.Collections.Generic; using System.Text; using System.Runtime.InteropServices; using CGALDotNetGeometry.Numerics; namespace CGALDotNet.Processing { internal class MeshProcessingFeaturesKernel_EIK : MeshProcessingFeaturesKernel { internal override string Name => "EIK"; internal static readonly MeshProcessingFeaturesKernel Instance = new MeshProcessingFeaturesKernel_EIK(); internal override IntPtr Create() { return MeshProcessingFeatures_EIK_Create(); } internal override void Release(IntPtr ptr) { MeshProcessingFeatures_EIK_Release(ptr); } //Polyhedron internal override int DetectSharpEdges_PH(IntPtr feaPtr, IntPtr meshPtr, double feature_angle) { return MeshProcessingFeatures_EIK_DetectSharpEdges_PH(feaPtr, meshPtr, feature_angle); } internal override void GetSharpEdges_PH(IntPtr feaPtr, IntPtr meshPtr, int[] indices, int count) { MeshProcessingFeatures_EIK_GetSharpEdges_PH(feaPtr, meshPtr, indices, count); } internal override Index2 SharpEdgesSegmentation_PH(IntPtr feaPtr, IntPtr meshPtr, double feature_angle) { return MeshProcessingFeatures_EIK_SharpEdgesSegmentation_PH(feaPtr, meshPtr, feature_angle); } internal override void ClearPatchBuffer_PH(IntPtr feaPtr) { MeshProcessingFeatures_EIK_ClearPatchBuffer_PH(feaPtr); } internal override int GetPatchBufferFaceCount_PH(IntPtr feaPtr, int patchIndex) { return MeshProcessingFeatures_EIK_GetPatchBufferFaceCount_PH(feaPtr, patchIndex); } internal override int GetPatchBufferFaceIndex_PH(IntPtr feaPtr, int patchIndex, int faceIndex) { return MeshProcessingFeatures_EIK_GetPatchBufferFaceIndex_PH(feaPtr, patchIndex, faceIndex); } internal override MinMaxAvg EdgeLengthMinMaxAvg_PH(IntPtr ptr) { return MeshProcessingFeatures_EIK_EdgeLengthMinMaxAvg_PH(ptr); } internal override MinMaxAvg FaceAreaMinMaxAvg_PH(IntPtr ptr) { return MeshProcessingFeatures_EIK_FaceAreaMinMaxAvg_PH(ptr); } //Surface Mesh internal override int DetectSharpEdges_SM(IntPtr feaPtr, IntPtr meshPtr, double feature_angle) { return MeshProcessingFeatures_EIK_DetectSharpEdges_SM(feaPtr, meshPtr, feature_angle); } internal override void GetSharpEdges_SM(IntPtr feaPtr, IntPtr meshPtr, int[] indices, int count) { MeshProcessingFeatures_EIK_GetSharpEdges_SM(feaPtr, meshPtr, indices, count); } internal override Index2 SharpEdgesSegmentation_SM(IntPtr feaPtr, IntPtr meshPtr, double feature_angle) { return MeshProcessingFeatures_EIK_SharpEdgesSegmentation_SM(feaPtr, meshPtr, feature_angle); } internal override void ClearPatchBuffer_SM(IntPtr feaPtr) { MeshProcessingFeatures_EIK_ClearPatchBuffer_SM(feaPtr); } internal override int GetPatchBufferFaceCount_SM(IntPtr feaPtr, int patchIndex) { return MeshProcessingFeatures_EIK_GetPatchBufferFaceCount_SM(feaPtr, patchIndex); } internal override int GetPatchBufferFaceIndex_SM(IntPtr feaPtr, int patchIndex, int faceIndex) { return MeshProcessingFeatures_EIK_GetPatchBufferFaceIndex_SM(feaPtr, patchIndex, faceIndex); } internal override MinMaxAvg EdgeLengthMinMaxAvg_SM(IntPtr ptr) { return MeshProcessingFeatures_EIK_EdgeLengthMinMaxAvg_SM(ptr); } internal override MinMaxAvg FaceAreaMinMaxAvg_SM(IntPtr ptr) { return MeshProcessingFeatures_EIK_FaceAreaMinMaxAvg_SM(ptr); } [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr MeshProcessingFeatures_EIK_Create(); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void MeshProcessingFeatures_EIK_Release(IntPtr ptr); //Polyhedron [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int MeshProcessingFeatures_EIK_DetectSharpEdges_PH(IntPtr feaPtr, IntPtr meshPtr, double feature_angle); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void MeshProcessingFeatures_EIK_GetSharpEdges_PH(IntPtr feaPtr, IntPtr meshPtr, [Out] int[] indices, int count); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern Index2 MeshProcessingFeatures_EIK_SharpEdgesSegmentation_PH(IntPtr feaPtr, IntPtr meshPtr, double feature_angle); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void MeshProcessingFeatures_EIK_ClearPatchBuffer_PH(IntPtr feaPtr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int MeshProcessingFeatures_EIK_GetPatchBufferFaceCount_PH(IntPtr feaPtr, int patchIndex); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int MeshProcessingFeatures_EIK_GetPatchBufferFaceIndex_PH(IntPtr feaPtr, int patchIndex, int faceIndex); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern MinMaxAvg MeshProcessingFeatures_EIK_EdgeLengthMinMaxAvg_PH(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern MinMaxAvg MeshProcessingFeatures_EIK_FaceAreaMinMaxAvg_PH(IntPtr ptr); //Surface Mesh [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int MeshProcessingFeatures_EIK_DetectSharpEdges_SM(IntPtr feaPtr, IntPtr meshPtr, double feature_angle); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void MeshProcessingFeatures_EIK_GetSharpEdges_SM(IntPtr feaPtr, IntPtr meshPtr, [Out] int[] indices, int count); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern Index2 MeshProcessingFeatures_EIK_SharpEdgesSegmentation_SM(IntPtr feaPtr, IntPtr meshPtr, double feature_angle); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void MeshProcessingFeatures_EIK_ClearPatchBuffer_SM(IntPtr feaPtr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int MeshProcessingFeatures_EIK_GetPatchBufferFaceCount_SM(IntPtr feaPtr, int patchIndex); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int MeshProcessingFeatures_EIK_GetPatchBufferFaceIndex_SM(IntPtr feaPtr, int patchIndex, int faceIndex); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern MinMaxAvg MeshProcessingFeatures_EIK_EdgeLengthMinMaxAvg_SM(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern MinMaxAvg MeshProcessingFeatures_EIK_FaceAreaMinMaxAvg_SM(IntPtr ptr); } } ================================================ FILE: CGALDotNet/Processing/MeshProcessingLocate.cs ================================================ using System; using System.Collections.Generic; using System.Text; using CGALDotNetGeometry.Numerics; using CGALDotNetGeometry.Shapes; using CGALDotNet.Polyhedra; using CGALDotNet.Polylines; namespace CGALDotNet.Processing { /// /// /// /// public sealed class MeshProcessingLocate : MeshProcessingLocate where K : CGALKernel, new() { /// /// /// public static readonly MeshProcessingLocate Instance = new MeshProcessingLocate(); /// /// /// public MeshProcessingLocate() : base(new K()) { } /// /// /// /// internal MeshProcessingLocate(IntPtr ptr) : base(new K(), ptr) { } /// /// /// /// public override string ToString() { return string.Format("[MeshProcessingLocate<{0}>: ]", Kernel.Name); } /// /// Find a random point on mesh surface. /// /// The mesh. /// A random point on mesh surface. public Point3d RandomLocationOnMesh(Polyhedron3 mesh) { return Kernel.RandomLocationOnMesh_PH(mesh.Ptr); } /// /// Find a random point on mesh surface. /// /// The mesh. /// A random point on mesh surface. public Point3d RandomLocationOnMesh(SurfaceMesh3 mesh) { return Kernel.RandomLocationOnMesh_SM(mesh.Ptr); } /// /// Find the face the ray intersects with. /// /// The mesh. /// Th ray. /// The hit result with theface index, hit point and the barycentric coords. public MeshHitResult LocateFace(Polyhedron3 mesh, Ray3d ray) { return Kernel.LocateFaceRay_PH(mesh.Ptr, ray); } /// /// Find the face the ray intersects with. /// /// The mesh. /// Th ray. /// The hit result with theface index, hit point and the barycentric coords. public MeshHitResult LocateFace(SurfaceMesh3 mesh, Ray3d ray) { return Kernel.LocateFaceRay_SM(mesh.Ptr, ray); } /// /// Find the closest face to the point. /// /// The mesh. /// Th point. /// The hit result with the face index, closest point and the barycentric coords. public MeshHitResult ClosestFace(Polyhedron3 mesh, Point3d point) { return Kernel.LocateFacePoint_PH(mesh.Ptr, point); } /// /// Find the closest face to the point. /// /// The mesh. /// Th point. /// The hit result with the face index, closest point and the barycentric coords. public MeshHitResult ClosestFace(SurfaceMesh3 mesh, Point3d point) { return Kernel.LocateFacePoint_SM(mesh.Ptr, point); } } /// /// /// public abstract class MeshProcessingLocate : PolyhedraAlgorithm { /// /// /// private MeshProcessingLocate() { } /// /// /// /// internal MeshProcessingLocate(CGALKernel kernel) { Kernel = kernel.MeshProcessingLocateKernel; Ptr = Kernel.Create(); } /// /// /// /// /// internal MeshProcessingLocate(CGALKernel kernel, IntPtr ptr) : base(ptr) { Kernel = kernel.MeshProcessingLocateKernel; Ptr = ptr; } /// /// /// internal MeshProcessingLocateKernel Kernel { get; private set; } /// /// Release any unmanaged resources. /// protected override void ReleasePtr() { Kernel.Release(Ptr); } } } ================================================ FILE: CGALDotNet/Processing/MeshProcessingLocateKernel.cs ================================================ using System; using System.Collections.Generic; using System.Text; using CGALDotNetGeometry.Numerics; using CGALDotNetGeometry.Shapes; using CGALDotNet.Polyhedra; namespace CGALDotNet.Processing { internal abstract class MeshProcessingLocateKernel : CGALObjectKernel { internal abstract IntPtr Create(); internal abstract void Release(IntPtr ptr); //Polyhedron internal abstract Point3d RandomLocationOnMesh_PH(IntPtr ptr); internal abstract MeshHitResult LocateFaceRay_PH(IntPtr ptr, Ray3d ray); internal abstract MeshHitResult LocateFacePoint_PH(IntPtr ptr, Point3d point); //SurfaceMesh internal abstract Point3d RandomLocationOnMesh_SM(IntPtr ptr); internal abstract MeshHitResult LocateFaceRay_SM(IntPtr ptr, Ray3d ray); internal abstract MeshHitResult LocateFacePoint_SM(IntPtr ptr, Point3d point); } } ================================================ FILE: CGALDotNet/Processing/MeshProcessingLocateKernel_EEK.cs ================================================ using System; using System.Collections.Generic; using System.Text; using System.Runtime.InteropServices; using CGALDotNetGeometry.Numerics; using CGALDotNetGeometry.Shapes; using CGALDotNet.Polyhedra; namespace CGALDotNet.Processing { internal class MeshProcessingLocateKernel_EEK : MeshProcessingLocateKernel { internal override string Name => "EEK"; internal static readonly MeshProcessingLocateKernel Instance = new MeshProcessingLocateKernel_EEK(); internal override IntPtr Create() { return MeshProcessingLocate_EEK_Create(); } internal override void Release(IntPtr ptr) { MeshProcessingLocate_EEK_Release(ptr); } //Polyhedron internal override Point3d RandomLocationOnMesh_PH(IntPtr ptr) { return MeshProcessingLocate_EEK_RandomLocationOnMesh_PH(ptr); } internal override MeshHitResult LocateFaceRay_PH(IntPtr ptr, Ray3d ray) { return MeshProcessingLocate_EEK_LocateFaceRay_PH(ptr, ray); } internal override MeshHitResult LocateFacePoint_PH(IntPtr ptr, Point3d point) { return MeshProcessingLocate_EEK_LocateFacePoint_PH(ptr, point); } //SUrfaceMesh internal override Point3d RandomLocationOnMesh_SM(IntPtr ptr) { return MeshProcessingLocate_EEK_RandomLocationOnMesh_SM(ptr); } internal override MeshHitResult LocateFaceRay_SM(IntPtr ptr, Ray3d ray) { return MeshProcessingLocate_EEK_LocateFaceRay_SM(ptr, ray); } internal override MeshHitResult LocateFacePoint_SM(IntPtr ptr, Point3d point) { return MeshProcessingLocate_EEK_LocateFacePoint_SM(ptr, point); } [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr MeshProcessingLocate_EEK_Create(); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void MeshProcessingLocate_EEK_Release(IntPtr ptr); //Polyhedron [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern Point3d MeshProcessingLocate_EEK_RandomLocationOnMesh_PH(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern MeshHitResult MeshProcessingLocate_EEK_LocateFaceRay_PH(IntPtr ptr, Ray3d ray); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern MeshHitResult MeshProcessingLocate_EEK_LocateFacePoint_PH(IntPtr ptr, Point3d point); //SurfaceMesh [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern Point3d MeshProcessingLocate_EEK_RandomLocationOnMesh_SM(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern MeshHitResult MeshProcessingLocate_EEK_LocateFaceRay_SM(IntPtr ptr, Ray3d ray); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern MeshHitResult MeshProcessingLocate_EEK_LocateFacePoint_SM(IntPtr ptr, Point3d point); } } ================================================ FILE: CGALDotNet/Processing/MeshProcessingLocateKernel_EIK.cs ================================================ using System; using System.Collections.Generic; using System.Text; using System.Runtime.InteropServices; using CGALDotNetGeometry.Numerics; using CGALDotNetGeometry.Shapes; using CGALDotNet.Polyhedra; namespace CGALDotNet.Processing { internal class MeshProcessingLocateKernel_EIK : MeshProcessingLocateKernel { internal override string Name => "EIK"; internal static readonly MeshProcessingLocateKernel Instance = new MeshProcessingLocateKernel_EIK(); internal override IntPtr Create() { return MeshProcessingLocate_EIK_Create(); } internal override void Release(IntPtr ptr) { MeshProcessingLocate_EIK_Release(ptr); } //Polyhedron internal override Point3d RandomLocationOnMesh_PH(IntPtr ptr) { return MeshProcessingLocate_EIK_RandomLocationOnMesh_PH(ptr); } internal override MeshHitResult LocateFaceRay_PH(IntPtr ptr, Ray3d ray) { return MeshProcessingLocate_EIK_LocateFaceRay_PH(ptr, ray); } internal override MeshHitResult LocateFacePoint_PH(IntPtr ptr, Point3d point) { return MeshProcessingLocate_EIK_LocateFacePoint_PH(ptr, point); } //SUrfaceMesh internal override Point3d RandomLocationOnMesh_SM(IntPtr ptr) { return MeshProcessingLocate_EIK_RandomLocationOnMesh_SM(ptr); } internal override MeshHitResult LocateFaceRay_SM(IntPtr ptr, Ray3d ray) { return MeshProcessingLocate_EIK_LocateFaceRay_SM(ptr, ray); } internal override MeshHitResult LocateFacePoint_SM(IntPtr ptr, Point3d point) { return MeshProcessingLocate_EIK_LocateFacePoint_SM(ptr, point); } [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr MeshProcessingLocate_EIK_Create(); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void MeshProcessingLocate_EIK_Release(IntPtr ptr); //Polyhedron [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern Point3d MeshProcessingLocate_EIK_RandomLocationOnMesh_PH(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern MeshHitResult MeshProcessingLocate_EIK_LocateFaceRay_PH(IntPtr ptr, Ray3d ray); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern MeshHitResult MeshProcessingLocate_EIK_LocateFacePoint_PH(IntPtr ptr, Point3d point); //SurfaceMesh [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern Point3d MeshProcessingLocate_EIK_RandomLocationOnMesh_SM(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern MeshHitResult MeshProcessingLocate_EIK_LocateFaceRay_SM(IntPtr ptr, Ray3d ray); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern MeshHitResult MeshProcessingLocate_EIK_LocateFacePoint_SM(IntPtr ptr, Point3d point); } } ================================================ FILE: CGALDotNet/Processing/MeshProcessingMeshing.cs ================================================ using System; using System.Collections.Generic; using System.Text; using CGALDotNetGeometry.Numerics; using CGALDotNet.Polyhedra; namespace CGALDotNet.Processing { /// /// /// /// public sealed class MeshProcessingMeshing : MeshProcessingMeshing where K : CGALKernel, new() { /// /// /// public static readonly MeshProcessingMeshing Instance = new MeshProcessingMeshing(); /// /// /// public MeshProcessingMeshing() : base(new K()) { } /// /// /// /// internal MeshProcessingMeshing(IntPtr ptr) : base(new K(), ptr) { } /// /// /// /// public override string ToString() { return string.Format("[MeshProcessingMeshing<{0}>: ]", Kernel.Name); } /// /// Fills output with a closed mesh bounding the volume swept by input when translating its vertices by dir. /// The mesh is oriented so that the faces corresponding to input in output have the same orientation. /// /// The a valid closed mesh. /// The direction vector. /// The extuded mesh. public Polyhedron3 Extrude(Polyhedron3 mesh, Vector3d dir) { CheckIsValidClosedException(mesh); var ptr = Kernel.Extrude_PH(mesh.Ptr, dir); return new Polyhedron3(ptr); } /// /// Fills output with a closed mesh bounding the volume swept by input when translating its vertices by dir. /// The mesh is oriented so that the faces corresponding to input in output have the same orientation. /// /// The a valid closed mesh. /// The direction vector. /// The extuded mesh. public SurfaceMesh3 Extrude(SurfaceMesh3 mesh, Vector3d dir) { CheckIsValidClosedException(mesh); var ptr = Kernel.Extrude_SM(mesh.Ptr, dir); return new SurfaceMesh3(ptr); } /// /// Fairs a region on a triangle mesh based on a ring of k vertices from the index vertex. /// The points of the selected vertices are relocated to yield an as-smooth-as-possible surface patch, /// based on solving a linear bi-Laplacian system with boundary constraints /// The region described by vertices might contain multiple disconnected components. /// Note that the mesh connectivity is not altered in any way, only vertex locations get updated. /// Fairing might fail if fixed vertices, which are used as boundary conditions, /// do not suffice to solve constructed linear system. /// Note that if the vertex range to which fairing is applied contains all the vertices of the triangle mesh, /// fairing does not fail, but the mesh gets shrinked to the origin. /// /// A valid triangle mesh. /// The vertex index in the mesh to start hthe k ring region from. /// The number of vertics to expand the region to. /// If the fairing was successfully run. public bool Fair(Polyhedron3 mesh, int index, int k_ring) { CheckIsValidTriangle(mesh); var i = Kernel.Fair_PH(mesh.Ptr, index, k_ring); bool successful = i.first != 0; //int region_size = i.second; return successful; } /* /// /// Fairs a region on a triangle mesh based on a ring of k vertices from the index vertex. /// The points of the selected vertices are relocated to yield an as-smooth-as-possible surface patch, /// based on solving a linear bi-Laplacian system with boundary constraints /// The region described by vertices might contain multiple disconnected components. /// Note that the mesh connectivity is not altered in any way, only vertex locations get updated. /// Fairing might fail if fixed vertices, which are used as boundary conditions, /// do not suffice to solve constructed linear system. /// Note that if the vertex range to which fairing is applied contains all the vertices of the triangle mesh, /// fairing does not fail, but the mesh gets shrinked to the origin. /// /// A valid triangle mesh. /// The vertex index in the mesh to start hthe k ring region from. /// The number of vertics to expand the region to. /// If the fairing was successfully run. public bool Fair(SurfaceMesh3 mesh, int index, int k_ring) { CheckIsValidTriangle(mesh); //TODO - need to implemt kring var i = Kernel.Fair_SM(mesh.Ptr, index, k_ring); bool successful = i.first != 0; //int region_size = i.second; return successful; } */ /// /// Refines a triangle mesh /// /// A valid triangle mesh. /// a factor to control density of the output mesh, /// where larger values lead to denser refinements. Defalus to sqrt of 2. /// The number of new vertices added. public int Refine(Polyhedron3 mesh, double density_control_factor = MathUtil.SQRT2_64) { if (density_control_factor <= 0) return 0; CheckIsValidTriangleException(mesh); mesh.SetIsUpdatedToFalse(); var count = Kernel.Refine_PH(mesh.Ptr, density_control_factor); int new_vertices = count.first; int new_faces = count.second; return new_vertices; } /// /// Refines a triangle mesh /// /// A valid triangle mesh. /// a factor to control density of the output mesh, /// where larger values lead to denser refinements. Defalus to sqrt of 2. /// The number of new vertices added. public int Refine(SurfaceMesh3 mesh, double density_control_factor = MathUtil.SQRT2_64) { if (density_control_factor <= 0) return 0; CheckIsValidTriangleException(mesh); mesh.SetIsUpdatedToFalse(); var count = Kernel.Refine_SM(mesh.Ptr, density_control_factor); int new_vertices = count.first; int new_faces = count.second; return new_vertices; } /// /// Remeshes a triangulated region of a meshgon mesh. /// This operation sequentially performs edge splits, edge collapses, edge flips, /// tangential relaxation and projection to the initial surface to generate /// a smooth mesh with a prescribed edge length. /// /// A valid triangle mesh. /// The number of times to perform the remeshing. /// the edge length that is targeted in the remeshed patch. /// If 0 is passed then only the edge-flip, tangential relaxation, and projection steps will be done. /// The number of new vertices added. public int IsotropicRemeshing(Polyhedron3 mesh, double target_edge_length, int iterations = 1) { CheckIsValidTriangleException(mesh); if (target_edge_length < 0) target_edge_length = 0; mesh.SetIsUpdatedToFalse(); return Kernel.IsotropicRemeshing_PH(mesh.Ptr, iterations, target_edge_length); } /// /// Remeshes a triangulated region of a meshgon mesh. /// This operation sequentially performs edge splits, edge collapses, edge flips, /// tangential relaxation and projection to the initial surface to generate /// a smooth mesh with a prescribed edge length. /// /// A valid triangle mesh. /// The number of times to perform the remeshing. /// the edge length that is targeted in the remeshed patch. /// If 0 is passed then only the edge-flip, tangential relaxation, and projection steps will be done. /// The number of new vertices added. public int IsotropicRemeshing(SurfaceMesh3 mesh, double target_edge_length, int iterations = 1) { CheckIsValidTriangleException(mesh); if (target_edge_length < 0) target_edge_length = 0; mesh.SetIsUpdatedToFalse(); return Kernel.IsotropicRemeshing_SM(mesh.Ptr, iterations, target_edge_length); } /// /// randomly perturbs the locations of vertices of a triangulated surface mesh. /// By default, the vertices are re-projected onto the input surface after /// perturbation.Note that no geometric checks are done after the perturbation /// (face orientation might become incorrect and self-intersections might be introduced). /// /// A mesh. /// The maximun amount a vertex will be pertured. Must be greater tha 0. public void RandomPerturbation(Polyhedron3 mesh, double perturbation_max_size) { if (perturbation_max_size <= 0) return; mesh.SetIsUpdatedToFalse(); Kernel.RandomPerturbation_PH(mesh.Ptr, perturbation_max_size); } /// /// randomly perturbs the locations of vertices of a triangulated surface mesh. /// By default, the vertices are re-projected onto the input surface after /// perturbation.Note that no geometric checks are done after the perturbation /// (face orientation might become incorrect and self-intersections might be introduced). /// /// A mesh. /// The maximun amount a vertex will be pertured. Must be greater tha 0. public void RandomPerturbation(SurfaceMesh3 mesh, double perturbation_max_size) { if (perturbation_max_size <= 0) return; mesh.SetIsUpdatedToFalse(); Kernel.RandomPerturbation_SM(mesh.Ptr, perturbation_max_size); } /* /// /// Smooths a triangulated mesh. /// This function attempts to make the triangle angle and area distributions as uniform /// as possible by moving(non-constrained) vertices. /// Angle-based smoothing does not change the combinatorial information of the mesh. /// Area-based smoothing might change the combinatorial information, unless specified otherwise. /// It is also possible to make the smoothing algorithm "safer" by rejecting moves that, /// when applied, would worsen the quality of the mesh, e.g.that would decrease the value /// of the smallest angle around a vertex or create self-intersections. /// Optionally, the points are reprojected after each iteration. /// /// A valid triangle mesh. /// The edge angle that counts a feature and wont be smoothed. /// The number of iterations for the sequence of the smoothing iterations performed public void SmoothMeshByAngle(Polyhedron3 mesh, Degree featureAngle, int iterations = 1) { CheckIsValidTriangleException(mesh); if (featureAngle.angle <= 0 || iterations < 0) return; Kernel.SmoothMesh_PH(mesh.Ptr, featureAngle.angle, iterations); } */ /// /// Smooths a triangulated mesh. /// This function attempts to make the triangle angle and area distributions as uniform /// as possible by moving(non-constrained) vertices. /// Angle-based smoothing does not change the combinatorial information of the mesh. /// Area-based smoothing might change the combinatorial information, unless specified otherwise. /// It is also possible to make the smoothing algorithm "safer" by rejecting moves that, /// when applied, would worsen the quality of the mesh, e.g.that would decrease the value /// of the smallest angle around a vertex or create self-intersections. /// Optionally, the points are reprojected after each iteration. /// /// A valid triangle mesh. /// The edge angle that counts a feature and wont be smoothed. /// The number of iterations for the sequence of the smoothing iterations performed public void SmoothMeshByAngle(SurfaceMesh3 mesh, Degree featureAngle, int iterations = 1) { CheckIsValidTriangleException(mesh); if (featureAngle.angle <= 0 || iterations < 0) return; Kernel.SmoothMesh_SM(mesh.Ptr, featureAngle.angle, iterations); } /* /// /// smooths the overall shape of the mesh by using the mean curvature flow. /// The effect depends on the curvature of each area and on a time step which /// represents the amount by which vertices are allowed to move. /// The result conformally maps the initial surface to a sphere. /// /// A valid triangle mesh. /// A time step that corresponds to the speed by which the surface is smoothed. /// A larger time step results in faster convergence but details may be distorted to have a larger /// extent compared to more iterations with a smaller step. Typical values scale in the interval (1e-6, 1]. /// The number of iterations for the sequence of the smoothing iterations performed. public void SmoothShape(Polyhedron3 mesh, double timeStep = 0.0001, int iterations = 1) { CheckIsValidTriangleException(mesh); if (timeStep <= 0 || iterations < 0) return; Kernel.SmoothShape_PH(mesh.Ptr, timeStep, iterations); } */ /* /// /// smooths the overall shape of the mesh by using the mean curvature flow. /// The effect depends on the curvature of each area and on a time step which /// represents the amount by which vertices are allowed to move. /// The result conformally maps the initial surface to a sphere. /// /// A valid triangle mesh. /// A time step that corresponds to the speed by which the surface is smoothed. /// A larger time step results in faster convergence but details may be distorted to have a larger /// extent compared to more iterations with a smaller step. Typical values scale in the interval (1e-6, 1]. /// The number of iterations for the sequence of the smoothing iterations performed. public void SmoothShape(SurfaceMesh3 mesh, double timeStep = 0.0001, int iterations = 1) { CheckIsValidTriangleException(mesh); if (timeStep <= 0 || iterations < 0) return; Kernel.SmoothShape_SM(mesh.Ptr, timeStep, iterations); } */ /// /// splits the edges listed in edges into sub-edges that are not longer than the given threshold max_length. /// Note this function is useful to split constrained edges before calling isotropic_remeshing() with protection /// of constraints activated (to match the constrained edge length required by the remeshing algorithm to be guaranteed to terminate) /// /// A valid mesh. /// The edge length above which an edge from edges is split into to sub-edges /// The number of new edges added to the mesh. public int SplitLongEdges(Polyhedron3 mesh, double target_edge_length) { CheckIsValidException(mesh); if (target_edge_length <= 0) return 0; mesh.SetIsUpdatedToFalse(); int new_halfedges = Kernel.SplitLongEdges_PH(mesh.Ptr, target_edge_length); int new_edges = new_halfedges / 2; return new_edges; } /// /// splits the edges listed in edges into sub-edges that are not longer than the given threshold max_length. /// Note this function is useful to split constrained edges before calling isotropic_remeshing() with protection /// of constraints activated (to match the constrained edge length required by the remeshing algorithm to be guaranteed to terminate) /// /// A valid mesh. /// The edge length above which an edge from edges is split into to sub-edges /// The number of new edges added to the mesh. public int SplitLongEdges(SurfaceMesh3 mesh, double target_edge_length) { CheckIsValidException(mesh); if (target_edge_length <= 0) return 0; mesh.SetIsUpdatedToFalse(); int new_halfedges = Kernel.SplitLongEdges_SM(mesh.Ptr, target_edge_length); int new_edges = new_halfedges / 2; return new_edges; } /// /// Triangulate a single face in the mesh. /// /// A valid mesh. /// The faces index in the mesh. /// True if successful. public bool TriangulateFace(Polyhedron3 mesh, int face) { CheckIsValidException(mesh); mesh.SetIsUpdatedToFalse(); return Kernel.TriangulateFace_PH(mesh.Ptr, face); } /// /// Triangulate a single face in the mesh. /// /// A valid mesh. /// The faces index in the mesh. /// True if successful. public bool TriangulateFace(SurfaceMesh3 mesh, int face) { CheckIsValidException(mesh); mesh.SetIsUpdatedToFalse(); return Kernel.TriangulateFace_SM(mesh.Ptr, face); } /// /// Triangulate a range of faces in the mesh. /// /// A valid mesh. /// The faces to triangulate. /// The length of the face array. /// True if successful. public bool TriangulateFaces(Polyhedron3 mesh, int[] faces, int count) { CheckIsValidException(mesh); ErrorUtil.CheckArray(faces, count); mesh.SetIsUpdatedToFalse(); return Kernel.TriangulateFaces_PH(mesh.Ptr, faces, count); } /// /// Triangulate a range of faces in the mesh. /// /// A valid mesh. /// The faces to triangulate. /// The length of the face array. /// True if successful. public bool TriangulateFaces(SurfaceMesh3 mesh, int[] faces, int count) { CheckIsValidException(mesh); ErrorUtil.CheckArray(faces, count); mesh.SetIsUpdatedToFalse(); return Kernel.TriangulateFaces_SM(mesh.Ptr, faces, count); } } /// /// /// public abstract class MeshProcessingMeshing : PolyhedraAlgorithm { /// /// /// private MeshProcessingMeshing() { } /// /// /// /// internal MeshProcessingMeshing(CGALKernel kernel) { Kernel = kernel.MeshProcessingMeshingKernel; Ptr = Kernel.Create(); } /// /// /// /// /// internal MeshProcessingMeshing(CGALKernel kernel, IntPtr ptr) { Kernel = kernel.MeshProcessingMeshingKernel; Ptr = ptr; } /// /// /// internal MeshProcessingMeshingKernel Kernel { get; private set; } /// /// Release any unmanaged resources. /// protected override void ReleasePtr() { Kernel.Release(Ptr); } } } ================================================ FILE: CGALDotNet/Processing/MeshProcessingMeshingKernel.cs ================================================ using System; using System.Collections.Generic; using System.Text; using CGALDotNetGeometry.Numerics; namespace CGALDotNet.Processing { internal abstract class MeshProcessingMeshingKernel : CGALObjectKernel { internal abstract IntPtr Create(); internal abstract void Release(IntPtr ptr); //Polyhedron internal abstract IntPtr Extrude_PH(IntPtr meshPtr, Vector3d dir); internal abstract Index2 Fair_PH(IntPtr meshPtr, int index, int k_ring); internal abstract Index2 Refine_PH(IntPtr meshPtr, double density_control_factor); internal abstract int IsotropicRemeshing_PH(IntPtr meshPtr, int iterations, double target_edge_length); internal abstract void RandomPerturbation_PH(IntPtr meshPtr, double perturbation_max_size); internal abstract void SmoothMesh_PH(IntPtr meshPtr, double featureAngle, int iterations); internal abstract void SmoothShape_PH(IntPtr meshPtr, double timeStep, int iterations); internal abstract int SplitLongEdges_PH(IntPtr meshPtr, double target_edge_length); internal abstract bool TriangulateFace_PH(IntPtr meshPtr, int index); internal abstract bool TriangulateFaces_PH(IntPtr meshPtr, int[] faces, int count); //Surface Mesh internal abstract IntPtr Extrude_SM(IntPtr meshPtr, Vector3d dir); internal abstract Index2 Fair_SM(IntPtr meshPtr, int index, int k_ring); internal abstract Index2 Refine_SM(IntPtr meshPtr, double density_control_factor); internal abstract int IsotropicRemeshing_SM(IntPtr meshPtr, int iterations, double target_edge_length); internal abstract void RandomPerturbation_SM(IntPtr meshPtr, double perturbation_max_size); internal abstract void SmoothMesh_SM(IntPtr meshPtr, double featureAngle, int iterations); internal abstract void SmoothShape_SM(IntPtr meshPtr, double timeStep, int iterations); internal abstract int SplitLongEdges_SM(IntPtr meshPtr, double target_edge_length); internal abstract bool TriangulateFace_SM(IntPtr meshPtr, int index); internal abstract bool TriangulateFaces_SM(IntPtr meshPtr, int[] faces, int count); } } ================================================ FILE: CGALDotNet/Processing/MeshProcessingMeshingKernel_EEK.cs ================================================ using System; using System.Collections.Generic; using System.Text; using System.Runtime.InteropServices; using CGALDotNetGeometry.Numerics; namespace CGALDotNet.Processing { internal class MeshProcessingMeshingKernel_EEK : MeshProcessingMeshingKernel { internal override string Name => "EEK"; internal static readonly MeshProcessingMeshingKernel Instance = new MeshProcessingMeshingKernel_EEK(); internal override IntPtr Create() { return MeshProcessingMeshing_EEK_Create(); } internal override void Release(IntPtr ptr) { MeshProcessingMeshing_EEK_Release(ptr); } //Polyhedron internal override IntPtr Extrude_PH(IntPtr meshPtr, Vector3d dir) { return MeshProcessingMeshing_EEK_Extrude_PH(meshPtr, dir); } internal override Index2 Fair_PH(IntPtr meshPtr, int index, int k_ring) { return MeshProcessingMeshing_EEK_Fair_PH(meshPtr, index, k_ring); } internal override Index2 Refine_PH(IntPtr meshPtr, double density_control_factor) { return MeshProcessingMeshing_EEK_Refine_PH(meshPtr, density_control_factor); } internal override int IsotropicRemeshing_PH(IntPtr meshPtr, int iterations, double target_edge_length) { return MeshProcessingMeshing_EEK_IsotropicRemeshing_PH(meshPtr, iterations, target_edge_length); } internal override void RandomPerturbation_PH(IntPtr meshPtr, double perturbation_max_size) { MeshProcessingMeshing_EEK_RandomPerturbation_PH (meshPtr, perturbation_max_size); } internal override void SmoothMesh_PH(IntPtr meshPtr, double featureAngle, int iterations) { MeshProcessingMeshing_EEK_SmoothMesh_PH(meshPtr, featureAngle, iterations); } internal override void SmoothShape_PH(IntPtr meshPtr, double timeStep, int iterations) { MeshProcessingMeshing_EEK_SmoothShape_PH(meshPtr, timeStep, iterations); } internal override int SplitLongEdges_PH(IntPtr meshPtr, double target_edge_length) { return MeshProcessingMeshing_EEK_SplitLongEdges_PH(meshPtr, target_edge_length); } internal override bool TriangulateFace_PH(IntPtr meshPtr, int index) { return MeshProcessingMeshing_EEK_TriangulateFace_PH(meshPtr, index); } internal override bool TriangulateFaces_PH(IntPtr meshPtr, int[] faces, int count) { return MeshProcessingMeshing_EEK_TriangulateFaces_PH(meshPtr, faces, count); } //Surface Mesh internal override IntPtr Extrude_SM(IntPtr meshPtr, Vector3d dir) { return MeshProcessingMeshing_EEK_Extrude_SM(meshPtr, dir); } internal override Index2 Fair_SM(IntPtr meshPtr, int index, int k_ring) { return MeshProcessingMeshing_EEK_Fair_SM(meshPtr, index, k_ring); } internal override Index2 Refine_SM(IntPtr meshPtr, double density_control_factor) { return MeshProcessingMeshing_EEK_Refine_SM(meshPtr, density_control_factor); } internal override int IsotropicRemeshing_SM(IntPtr meshPtr, int iterations, double target_edge_length) { return MeshProcessingMeshing_EEK_IsotropicRemeshing_SM(meshPtr, iterations, target_edge_length); } internal override void RandomPerturbation_SM(IntPtr meshPtr, double perturbation_max_size) { MeshProcessingMeshing_EEK_RandomPerturbation_SM(meshPtr, perturbation_max_size); } internal override void SmoothMesh_SM(IntPtr meshPtr, double featureAngle, int iterations) { MeshProcessingMeshing_EEK_SmoothMesh_SM(meshPtr, featureAngle, iterations); } internal override void SmoothShape_SM(IntPtr meshPtr, double timeStep, int iterations) { MeshProcessingMeshing_EEK_SmoothShape_SM(meshPtr, timeStep, iterations); } internal override int SplitLongEdges_SM(IntPtr meshPtr, double target_edge_length) { return MeshProcessingMeshing_EEK_SplitLongEdges_SM(meshPtr, target_edge_length); } internal override bool TriangulateFace_SM(IntPtr meshPtr, int index) { return MeshProcessingMeshing_EEK_TriangulateFace_SM(meshPtr, index); } internal override bool TriangulateFaces_SM(IntPtr meshPtr, int[] faces, int count) { return MeshProcessingMeshing_EEK_TriangulateFaces_SM(meshPtr, faces, count); } [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr MeshProcessingMeshing_EEK_Create(); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void MeshProcessingMeshing_EEK_Release(IntPtr ptr); //Polyhedron [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr MeshProcessingMeshing_EEK_Extrude_PH(IntPtr meshPtr, Vector3d dir); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern Index2 MeshProcessingMeshing_EEK_Fair_PH(IntPtr meshPtr, int index, int k_ring); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern Index2 MeshProcessingMeshing_EEK_Refine_PH(IntPtr meshPtr, double density_control_factor); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int MeshProcessingMeshing_EEK_IsotropicRemeshing_PH(IntPtr meshPtr, int iterations, double target_edge_length); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void MeshProcessingMeshing_EEK_RandomPerturbation_PH(IntPtr meshPtr, double perturbation_max_size); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void MeshProcessingMeshing_EEK_SmoothMesh_PH(IntPtr meshPtr, double featureAngle, int iterations); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void MeshProcessingMeshing_EEK_SmoothShape_PH(IntPtr meshPtr, double timeStep, int iterations); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int MeshProcessingMeshing_EEK_SplitLongEdges_PH(IntPtr meshPtr, double target_edge_length); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool MeshProcessingMeshing_EEK_TriangulateFace_PH(IntPtr meshPtr, int index); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool MeshProcessingMeshing_EEK_TriangulateFaces_PH(IntPtr meshPtr, int[] faces, int count); //SurfaceMesh [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr MeshProcessingMeshing_EEK_Extrude_SM(IntPtr meshPtr, Vector3d dir); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern Index2 MeshProcessingMeshing_EEK_Fair_SM(IntPtr meshPtr, int index, int k_ring); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern Index2 MeshProcessingMeshing_EEK_Refine_SM(IntPtr meshPtr, double density_control_factor); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int MeshProcessingMeshing_EEK_IsotropicRemeshing_SM(IntPtr meshPtr, int iterations, double target_edge_length); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void MeshProcessingMeshing_EEK_RandomPerturbation_SM(IntPtr meshPtr, double perturbation_max_size); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void MeshProcessingMeshing_EEK_SmoothMesh_SM(IntPtr meshPtr, double featureAngle, int iterations); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void MeshProcessingMeshing_EEK_SmoothShape_SM(IntPtr meshPtr, double timeStep, int iterations); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int MeshProcessingMeshing_EEK_SplitLongEdges_SM(IntPtr meshPtr, double target_edge_length); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool MeshProcessingMeshing_EEK_TriangulateFace_SM(IntPtr meshPtr, int index); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool MeshProcessingMeshing_EEK_TriangulateFaces_SM(IntPtr meshPtr, int[] faces, int count); } } ================================================ FILE: CGALDotNet/Processing/MeshProcessingMeshingKernel_EIK.cs ================================================ using System; using System.Collections.Generic; using System.Text; using System.Runtime.InteropServices; using CGALDotNetGeometry.Numerics; namespace CGALDotNet.Processing { internal class MeshProcessingMeshingKernel_EIK : MeshProcessingMeshingKernel { internal override string Name => "EIK"; internal static readonly MeshProcessingMeshingKernel Instance = new MeshProcessingMeshingKernel_EIK(); internal override IntPtr Create() { return MeshProcessingMeshing_EIK_Create(); } internal override void Release(IntPtr ptr) { MeshProcessingMeshing_EIK_Release(ptr); } //Polyhedron internal override IntPtr Extrude_PH(IntPtr meshPtr, Vector3d dir) { return MeshProcessingMeshing_EIK_Extrude_PH(meshPtr, dir); } internal override Index2 Fair_PH(IntPtr meshPtr, int index, int k_ring) { return MeshProcessingMeshing_EIK_Fair_PH(meshPtr, index, k_ring); } internal override Index2 Refine_PH(IntPtr meshPtr, double density_control_factor) { return MeshProcessingMeshing_EIK_Refine_PH(meshPtr, density_control_factor); } internal override int IsotropicRemeshing_PH(IntPtr meshPtr, int iterations, double target_edge_length) { return MeshProcessingMeshing_EIK_IsotropicRemeshing_PH(meshPtr, iterations, target_edge_length); } internal override void RandomPerturbation_PH(IntPtr meshPtr, double perturbation_max_size) { MeshProcessingMeshing_EIK_RandomPerturbation_PH(meshPtr, perturbation_max_size); } internal override void SmoothMesh_PH(IntPtr meshPtr, double featureAngle, int iterations) { MeshProcessingMeshing_EIK_SmoothMesh_PH(meshPtr, featureAngle, iterations); } internal override void SmoothShape_PH(IntPtr meshPtr, double timeStep, int iterations) { MeshProcessingMeshing_EIK_SmoothShape_PH(meshPtr, timeStep, iterations); } internal override int SplitLongEdges_PH(IntPtr meshPtr, double target_edge_length) { return MeshProcessingMeshing_EIK_SplitLongEdges_PH(meshPtr, target_edge_length); } internal override bool TriangulateFace_PH(IntPtr meshPtr, int index) { return MeshProcessingMeshing_EIK_TriangulateFace_PH(meshPtr, index); } internal override bool TriangulateFaces_PH(IntPtr meshPtr, int[] faces, int count) { return MeshProcessingMeshing_EIK_TriangulateFaces_PH(meshPtr, faces, count); } //Surface Mesh internal override IntPtr Extrude_SM(IntPtr meshPtr, Vector3d dir) { return MeshProcessingMeshing_EIK_Extrude_SM(meshPtr, dir); } internal override Index2 Fair_SM(IntPtr meshPtr, int index, int k_ring) { return MeshProcessingMeshing_EIK_Fair_SM(meshPtr, index, k_ring); } internal override Index2 Refine_SM(IntPtr meshPtr, double density_control_factor) { return MeshProcessingMeshing_EIK_Refine_SM(meshPtr, density_control_factor); } internal override int IsotropicRemeshing_SM(IntPtr meshPtr, int iterations, double target_edge_length) { return MeshProcessingMeshing_EIK_IsotropicRemeshing_SM(meshPtr, iterations, target_edge_length); } internal override void RandomPerturbation_SM(IntPtr meshPtr, double perturbation_max_size) { MeshProcessingMeshing_EIK_RandomPerturbation_SM(meshPtr, perturbation_max_size); } internal override void SmoothMesh_SM(IntPtr meshPtr, double featureAngle, int iterations) { MeshProcessingMeshing_EIK_SmoothMesh_SM(meshPtr, featureAngle, iterations); } internal override void SmoothShape_SM(IntPtr meshPtr, double timeStep, int iterations) { MeshProcessingMeshing_EIK_SmoothShape_SM(meshPtr, timeStep, iterations); } internal override int SplitLongEdges_SM(IntPtr meshPtr, double target_edge_length) { return MeshProcessingMeshing_EIK_SplitLongEdges_SM(meshPtr, target_edge_length); } internal override bool TriangulateFace_SM(IntPtr meshPtr, int index) { return MeshProcessingMeshing_EIK_TriangulateFace_SM(meshPtr, index); } internal override bool TriangulateFaces_SM(IntPtr meshPtr, int[] faces, int count) { return MeshProcessingMeshing_EIK_TriangulateFaces_SM(meshPtr, faces, count); } [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr MeshProcessingMeshing_EIK_Create(); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void MeshProcessingMeshing_EIK_Release(IntPtr ptr); //Polyhedron [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr MeshProcessingMeshing_EIK_Extrude_PH(IntPtr meshPtr, Vector3d dir); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern Index2 MeshProcessingMeshing_EIK_Fair_PH(IntPtr meshPtr, int index, int k_ring); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern Index2 MeshProcessingMeshing_EIK_Refine_PH(IntPtr meshPtr, double density_control_factor); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int MeshProcessingMeshing_EIK_IsotropicRemeshing_PH(IntPtr meshPtr, int iterations, double target_edge_length); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void MeshProcessingMeshing_EIK_RandomPerturbation_PH(IntPtr meshPtr, double perturbation_max_size); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void MeshProcessingMeshing_EIK_SmoothMesh_PH(IntPtr meshPtr, double featureAngle, int iterations); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void MeshProcessingMeshing_EIK_SmoothShape_PH(IntPtr meshPtr, double timeStep, int iterations); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int MeshProcessingMeshing_EIK_SplitLongEdges_PH(IntPtr meshPtr, double target_edge_length); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool MeshProcessingMeshing_EIK_TriangulateFace_PH(IntPtr meshPtr, int index); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool MeshProcessingMeshing_EIK_TriangulateFaces_PH(IntPtr meshPtr, int[] faces, int count); //SurfaceMesh [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr MeshProcessingMeshing_EIK_Extrude_SM(IntPtr meshPtr, Vector3d dir); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern Index2 MeshProcessingMeshing_EIK_Fair_SM(IntPtr meshPtr, int index, int k_ring); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern Index2 MeshProcessingMeshing_EIK_Refine_SM(IntPtr meshPtr, double density_control_factor); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int MeshProcessingMeshing_EIK_IsotropicRemeshing_SM(IntPtr meshPtr, int iterations, double target_edge_length); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void MeshProcessingMeshing_EIK_RandomPerturbation_SM(IntPtr meshPtr, double perturbation_max_size); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void MeshProcessingMeshing_EIK_SmoothMesh_SM(IntPtr meshPtr, double featureAngle, int iterations); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void MeshProcessingMeshing_EIK_SmoothShape_SM(IntPtr meshPtr, double timeStep, int iterations); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int MeshProcessingMeshing_EIK_SplitLongEdges_SM(IntPtr meshPtr, double target_edge_length); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool MeshProcessingMeshing_EIK_TriangulateFace_SM(IntPtr meshPtr, int index); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool MeshProcessingMeshing_EIK_TriangulateFaces_SM(IntPtr meshPtr, int[] faces, int count); } } ================================================ FILE: CGALDotNet/Processing/MeshProcessingOrientation.cs ================================================ using System; using System.Collections.Generic; using System.Text; using CGALDotNet.Polyhedra; namespace CGALDotNet.Processing { public enum ORIENTATE { ORIENT, ORIENTATE_TO_BOUND_A_VOLUME, REVERSE_FACE_ORIENTATIONS } /// /// /// /// public sealed class MeshProcessingOrientation : MeshProcessingOrientation where K : CGALKernel, new() { /// /// /// public static readonly MeshProcessingOrientation Instance = new MeshProcessingOrientation(); /// /// /// public MeshProcessingOrientation() : base(new K()) { } /// /// /// /// internal MeshProcessingOrientation(IntPtr ptr) : base(new K(), ptr) { } /// /// /// /// public override string ToString() { return string.Format("[MeshProcessingOrientation<{0}>: ]", Kernel.Name); } /// /// Indicates if mesh bounds a volume. /// /// A closed triangle mesh. public bool DoesBoundAVolume(Polyhedron3 mesh) { CheckIsValidClosedTriangleException(mesh); return Kernel.DoesBoundAVolume_PH(mesh.Ptr); } /// /// Indicates if mesh bounds a volume. /// /// A closed triangle mesh. public bool DoesBoundAVolume(SurfaceMesh3 mesh) { CheckIsValidClosedTriangleException(mesh); return Kernel.DoesBoundAVolume_SM(mesh.Ptr); } /// /// Tests whether a closed triangle mesh has a positive orientation. /// A closed triangle mesh is considered to have a positive orientation /// if the normal vectors to all its faces point outside the domain bounded /// by the triangle mesh.The normal vector to each face is chosen pointing /// on the side of the face where its sequence of vertices is seen counterclockwise. /// /// A closed triangle mesh. public bool IsOutwardOriented(Polyhedron3 mesh) { CheckIsValidClosedTriangleException(mesh); return Kernel.IsOutwardOriented_PH(mesh.Ptr); } /// /// Tests whether a closed triangle mesh has a positive orientation. /// A closed triangle mesh is considered to have a positive orientation /// if the normal vectors to all its faces point outside the domain bounded /// by the triangle mesh.The normal vector to each face is chosen pointing /// on the side of the face where its sequence of vertices is seen counterclockwise. /// /// A closed triangle mesh. public bool IsOutwardOriented(SurfaceMesh3 mesh) { CheckIsValidClosedTriangleException(mesh); return Kernel.IsOutwardOriented_SM(mesh.Ptr); } /// /// Orient the faces in the mesh. /// /// The orientation method. /// A valid closed triangle mesh. public void Orient(ORIENTATE orientate, Polyhedron3 mesh) { switch (orientate) { case ORIENTATE.ORIENT: Orient(mesh); break; case ORIENTATE.ORIENTATE_TO_BOUND_A_VOLUME: OrientToBoundAVolume(mesh); break; case ORIENTATE.REVERSE_FACE_ORIENTATIONS: ReverseFaceOrientations(mesh); break; } } /// /// Orient the faces in the mesh. /// /// The orientation method. /// A valid closed triangle mesh. public void Orient(ORIENTATE orientate, SurfaceMesh3 mesh) { switch (orientate) { case ORIENTATE.ORIENT: Orient(mesh); break; case ORIENTATE.ORIENTATE_TO_BOUND_A_VOLUME: OrientToBoundAVolume(mesh); break; case ORIENTATE.REVERSE_FACE_ORIENTATIONS: ReverseFaceOrientations(mesh); break; } } /// /// Makes each connected component of a closed triangulated surface mesh inward or outward oriented. /// /// A closed triangle mesh. public void Orient(Polyhedron3 mesh) { CheckIsValidClosedTriangleException(mesh); Kernel.Orient_PH(mesh.Ptr); } /// /// Makes each connected component of a closed triangulated surface mesh inward or outward oriented. /// /// A closed triangle mesh. public void Orient(SurfaceMesh3 mesh) { CheckIsValidClosedTriangleException(mesh); Kernel.Orient_SM(mesh.Ptr); } /// /// Orients the connected components of tm to make it bound a volume. /// /// A closed triangle mesh. public void OrientToBoundAVolume(Polyhedron3 mesh) { CheckIsValidClosedTriangleException(mesh); Kernel.OrientToBoundAVolume_PH(mesh.Ptr); } /// /// Orients the connected components of tm to make it bound a volume. /// /// A closed triangle mesh. public void OrientToBoundAVolume(SurfaceMesh3 mesh) { CheckIsValidClosedTriangleException(mesh); Kernel.OrientToBoundAVolume_SM(mesh.Ptr); } /// /// Reverses for each face the order of the vertices along the face boundary. /// /// A valid mesh. public void ReverseFaceOrientations(Polyhedron3 mesh) { CheckIsValidException(mesh); Kernel.ReverseFaceOrientations_PH(mesh.Ptr); } /// /// Reverses for each face the order of the vertices along the face boundary. /// /// A valid mesh. public void ReverseFaceOrientations(SurfaceMesh3 mesh) { CheckIsValidException(mesh); Kernel.ReverseFaceOrientations_SM(mesh.Ptr); } } /// /// /// public abstract class MeshProcessingOrientation : PolyhedraAlgorithm { /// /// /// private MeshProcessingOrientation() { } /// /// /// /// internal MeshProcessingOrientation(CGALKernel kernel) { Kernel = kernel.MeshProcessingOrientationKernel; Ptr = Kernel.Create(); } /// /// /// /// /// internal MeshProcessingOrientation(CGALKernel kernel, IntPtr ptr) : base(ptr) { Kernel = kernel.MeshProcessingOrientationKernel; Ptr = ptr; } /// /// /// internal MeshProcessingOrientationKernel Kernel { get; private set; } /// /// Release any unmanaged resources. /// protected override void ReleasePtr() { Kernel.Release(Ptr); } } } ================================================ FILE: CGALDotNet/Processing/MeshProcessingOrientationKernel.cs ================================================ using System; using System.Collections.Generic; using System.Text; namespace CGALDotNet.Processing { internal abstract class MeshProcessingOrientationKernel : CGALObjectKernel { internal abstract IntPtr Create(); internal abstract void Release(IntPtr ptr); //Polyhedron internal abstract bool DoesBoundAVolume_PH(IntPtr polyPtr); internal abstract bool IsOutwardOriented_PH(IntPtr polyPtr); internal abstract void Orient_PH(IntPtr polyPtr); internal abstract void OrientToBoundAVolume_PH(IntPtr polyPtr); internal abstract void ReverseFaceOrientations_PH(IntPtr polyPtr); //Surface Mesh internal abstract bool DoesBoundAVolume_SM(IntPtr polyPtr); internal abstract bool IsOutwardOriented_SM(IntPtr polyPtr); internal abstract void Orient_SM(IntPtr polyPtr); internal abstract void OrientToBoundAVolume_SM(IntPtr polyPtr); internal abstract void ReverseFaceOrientations_SM(IntPtr polyPtr); } } ================================================ FILE: CGALDotNet/Processing/MeshProcessingOrientationKernel_EEK.cs ================================================ using System; using System.Collections.Generic; using System.Text; using System.Runtime.InteropServices; namespace CGALDotNet.Processing { internal class MeshProcessingOrientationKernel_EEK : MeshProcessingOrientationKernel { internal override string Name => "EEK"; internal static readonly MeshProcessingOrientationKernel Instance = new MeshProcessingOrientationKernel_EEK(); internal override IntPtr Create() { return MeshProcessingOrientation_EEK_Create(); } internal override void Release(IntPtr ptr) { MeshProcessingOrientation_EEK_Release(ptr); } //Polyhedron internal override bool DoesBoundAVolume_PH(IntPtr polyPtr) { return MeshProcessingOrientation_EEK_DoesBoundAVolume_PH(polyPtr); } internal override bool IsOutwardOriented_PH(IntPtr polyPtr) { return MeshProcessingOrientation_EEK_IsOutwardOriented_PH(polyPtr); } internal override void Orient_PH(IntPtr polyPtr) { MeshProcessingOrientation_EEK_Orient_PH(polyPtr); } internal override void OrientToBoundAVolume_PH(IntPtr polyPtr) { MeshProcessingOrientation_EEK_OrientToBoundAVolume_PH(polyPtr); } internal override void ReverseFaceOrientations_PH(IntPtr polyPtr) { MeshProcessingOrientation_EEK_ReverseFaceOrientations_PH(polyPtr); } //Surface Mesh internal override bool DoesBoundAVolume_SM(IntPtr polyPtr) { return MeshProcessingOrientation_EEK_DoesBoundAVolume_SM(polyPtr); } internal override bool IsOutwardOriented_SM(IntPtr polyPtr) { return MeshProcessingOrientation_EEK_IsOutwardOriented_SM(polyPtr); } internal override void Orient_SM(IntPtr polyPtr) { MeshProcessingOrientation_EEK_Orient_SM(polyPtr); } internal override void OrientToBoundAVolume_SM(IntPtr polyPtr) { MeshProcessingOrientation_EEK_OrientToBoundAVolume_SM(polyPtr); } internal override void ReverseFaceOrientations_SM(IntPtr polyPtr) { MeshProcessingOrientation_EEK_ReverseFaceOrientations_SM(polyPtr); } [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr MeshProcessingOrientation_EEK_Create(); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void MeshProcessingOrientation_EEK_Release(IntPtr ptr); //Polyhedron [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool MeshProcessingOrientation_EEK_DoesBoundAVolume_PH(IntPtr polyPtr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool MeshProcessingOrientation_EEK_IsOutwardOriented_PH(IntPtr polyPtr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void MeshProcessingOrientation_EEK_Orient_PH(IntPtr polyPtr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void MeshProcessingOrientation_EEK_OrientToBoundAVolume_PH(IntPtr polyPtr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void MeshProcessingOrientation_EEK_ReverseFaceOrientations_PH(IntPtr polyPtr); //Surface Mesh [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool MeshProcessingOrientation_EEK_DoesBoundAVolume_SM(IntPtr polyPtr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool MeshProcessingOrientation_EEK_IsOutwardOriented_SM(IntPtr polyPtr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void MeshProcessingOrientation_EEK_Orient_SM(IntPtr polyPtr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void MeshProcessingOrientation_EEK_OrientToBoundAVolume_SM(IntPtr polyPtr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void MeshProcessingOrientation_EEK_ReverseFaceOrientations_SM(IntPtr polyPtr); } } ================================================ FILE: CGALDotNet/Processing/MeshProcessingOrientationKernel_EIK.cs ================================================ using System; using System.Collections.Generic; using System.Text; using System.Runtime.InteropServices; namespace CGALDotNet.Processing { internal class MeshProcessingOrientationKernel_EIK : MeshProcessingOrientationKernel { internal override string Name => "EIK"; internal static readonly MeshProcessingOrientationKernel Instance = new MeshProcessingOrientationKernel_EIK(); internal override IntPtr Create() { return MeshProcessingOrientation_EIK_Create(); } internal override void Release(IntPtr ptr) { MeshProcessingOrientation_EIK_Release(ptr); } //Polyhedron internal override bool DoesBoundAVolume_PH(IntPtr polyPtr) { return MeshProcessingOrientation_EIK_DoesBoundAVolume_PH(polyPtr); } internal override bool IsOutwardOriented_PH(IntPtr polyPtr) { return MeshProcessingOrientation_EIK_IsOutwardOriented_PH(polyPtr); } internal override void Orient_PH(IntPtr polyPtr) { MeshProcessingOrientation_EIK_Orient_PH(polyPtr); } internal override void OrientToBoundAVolume_PH(IntPtr polyPtr) { MeshProcessingOrientation_EIK_OrientToBoundAVolume_PH(polyPtr); } internal override void ReverseFaceOrientations_PH(IntPtr polyPtr) { MeshProcessingOrientation_EIK_ReverseFaceOrientations_PH(polyPtr); } //Surface Mesh internal override bool DoesBoundAVolume_SM(IntPtr polyPtr) { return MeshProcessingOrientation_EIK_DoesBoundAVolume_SM(polyPtr); } internal override bool IsOutwardOriented_SM(IntPtr polyPtr) { return MeshProcessingOrientation_EIK_IsOutwardOriented_SM(polyPtr); } internal override void Orient_SM(IntPtr polyPtr) { MeshProcessingOrientation_EIK_Orient_SM(polyPtr); } internal override void OrientToBoundAVolume_SM(IntPtr polyPtr) { MeshProcessingOrientation_EIK_OrientToBoundAVolume_SM(polyPtr); } internal override void ReverseFaceOrientations_SM(IntPtr polyPtr) { MeshProcessingOrientation_EIK_ReverseFaceOrientations_SM(polyPtr); } [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr MeshProcessingOrientation_EIK_Create(); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void MeshProcessingOrientation_EIK_Release(IntPtr ptr); //Polyhedron [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool MeshProcessingOrientation_EIK_DoesBoundAVolume_PH(IntPtr polyPtr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool MeshProcessingOrientation_EIK_IsOutwardOriented_PH(IntPtr polyPtr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void MeshProcessingOrientation_EIK_Orient_PH(IntPtr polyPtr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void MeshProcessingOrientation_EIK_OrientToBoundAVolume_PH(IntPtr polyPtr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void MeshProcessingOrientation_EIK_ReverseFaceOrientations_PH(IntPtr polyPtr); //Surface Mesh [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool MeshProcessingOrientation_EIK_DoesBoundAVolume_SM(IntPtr polyPtr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool MeshProcessingOrientation_EIK_IsOutwardOriented_SM(IntPtr polyPtr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void MeshProcessingOrientation_EIK_Orient_SM(IntPtr polyPtr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void MeshProcessingOrientation_EIK_OrientToBoundAVolume_SM(IntPtr polyPtr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void MeshProcessingOrientation_EIK_ReverseFaceOrientations_SM(IntPtr polyPtr); } } ================================================ FILE: CGALDotNet/Processing/MeshProcessingRepair.cs ================================================ using System; using System.Collections.Generic; using System.Text; using CGALDotNet.Polyhedra; namespace CGALDotNet.Processing { /// /// /// /// public sealed class MeshProcessingRepair : MeshProcessingRepair where K : CGALKernel, new() { /// /// /// public static readonly MeshProcessingRepair Instance = new MeshProcessingRepair(); /// /// /// public MeshProcessingRepair() : base(new K()) { } /// /// /// /// internal MeshProcessingRepair(IntPtr ptr) : base(new K(), ptr) { } /// /// /// /// public override string ToString() { return string.Format("[MeshProcessingRepair<{0}>: ]", Kernel.Name); } /* /// /// Find the number of degenerate edges in the mesh. /// /// The polygon mesh. /// The number of degenerate edges in the mesh. public int DegenerateEdgeCount(Polyhedron3 mesh) { return Kernel.DegenerateEdgeCount_PM(mesh.Ptr); } */ /// /// Find the number of degenerate edges in the mesh. /// /// The polygon mesh. /// The number of degenerate edges in the mesh. public int DegenerateEdgeCount(SurfaceMesh3 mesh) { return Kernel.DegenerateEdgeCount_SM(mesh.Ptr); } /// /// Find the number of degenerate faces in the mesh. /// /// A triangle polygon mesh. /// The number of degenerate faces in the mesh. public int DegenerateTriangleCount(Polyhedron3 mesh) { //CheckIsValidTriangleException(mesh); return Kernel.DegenerateTriangleCount_PH(mesh.Ptr); } /// /// Find the number of degenerate faces in the mesh. /// /// A triangle polygon mesh. /// The number of degenerate faces in the mesh. public int DegenerateTriangleCount(SurfaceMesh3 mesh) { //CheckIsValidTriangleException(mesh); return Kernel.DegenerateTriangleCount_SM(mesh.Ptr); } /// /// Checks whether a triangle face is needle. /// A triangle is said to be a needle if its longest edge is much longer than its shortest edge. /// /// A triangle polygon mesh. /// A bound on the ratio of the longest edge length and the shortest edge length. /// The number of needle triangles. public int NeedleTriangleCount(Polyhedron3 mesh, double threshold) { //CheckIsValidTriangleException(mesh); return Kernel.NeedleTriangleCount_PH(mesh.Ptr, threshold); } /// /// Checks whether a triangle face is needle. /// A triangle is said to be a needle if its longest edge is much longer than its shortest edge. /// /// A triangle polygon mesh. /// A bound on the ratio of the longest edge length and the shortest edge length. /// The number of needle triangles. public int NeedleTriangleCount(SurfaceMesh3 mesh, double threshold) { //CheckIsValidTriangleException(mesh); return Kernel.NeedleTriangleCount_SM(mesh.Ptr, threshold); } /// /// Collects the non-manifold vertices (if any) present in the mesh. /// A non-manifold vertex v is returned via one incident halfedge h such that target(h, pm) = v /// for all the umbrellas that v appears in (an umbrella being the set of faces incident to all /// the halfedges reachable by walking around v using hnext = prev(opposite(h, pm), pm), starting from h). /// /// A triangle polygon mesh. /// The non manifold vertex count. public int NonManifoldVertexCount(Polyhedron3 mesh) { //CheckIsValidTriangleException(mesh); return Kernel.NonManifoldVertexCount_PH(mesh.Ptr); } /// /// Collects the non-manifold vertices (if any) present in the mesh. /// A non-manifold vertex v is returned via one incident halfedge h such that target(h, pm) = v /// for all the umbrellas that v appears in (an umbrella being the set of faces incident to all /// the halfedges reachable by walking around v using hnext = prev(opposite(h, pm), pm), starting from h). /// /// A triangle polygon mesh. /// The non manifold vertex count. public int NonManifoldVertexCount(SurfaceMesh3 mesh) { //CheckIsValidTriangleException(mesh); return Kernel.NonManifoldVertexCount_SM(mesh.Ptr); } /// /// Cleans a given polygon soup through various repairing operations. /// /// More precisely, this function carries out the following tasks, in the same order as they are listed: /// /// merging of duplicate points. /// simplification of polygons to remove geometrically identical consecutive vertices; /// splitting of "pinched" polygons, that is polygons in which a geometric position appears more than once. /// The splitting process results in multiple non-pinched polygons; /// removal of invalid polygons, that is polygons with fewer than 2 vertices; /// removal of duplicate polygons. /// removal of isolated points. /// /// The polygon mesh. public void RepairPolygonSoup(Polyhedron3 mesh) { mesh.SetIsUpdatedToFalse(); Kernel.RepairPolygonSoup_PH(mesh.Ptr); } /// /// Cleans a given polygon soup through various repairing operations. /// /// More precisely, this function carries out the following tasks, in the same order as they are listed: /// /// merging of duplicate points. /// simplification of polygons to remove geometrically identical consecutive vertices; /// splitting of "pinched" polygons, that is polygons in which a geometric position appears more than once. /// The splitting process results in multiple non-pinched polygons; /// removal of invalid polygons, that is polygons with fewer than 2 vertices; /// removal of duplicate polygons. /// removal of isolated points. /// /// The polygon mesh. public void RepairPolygonSoup(SurfaceMesh3 mesh) { mesh.SetIsUpdatedToFalse(); Kernel.RepairPolygonSoup_SM(mesh.Ptr); } /// /// stitches together, whenever possible, two halfedges belonging to the same boundary cycle. /// Two border halfedges h1 and h2 can be stitched if the points associated to the source and /// target vertices of h1 are the same as those of the target and source vertices of h2, respectively. /// /// The polygon mesh. /// The number of stiched boundaries. public int StitchBoundaryCycles(Polyhedron3 mesh) { CheckIsValidException(mesh); mesh.SetIsUpdatedToFalse(); return Kernel.StitchBoundaryCycles_PH(mesh.Ptr); } /// /// stitches together, whenever possible, two halfedges belonging to the same boundary cycle. /// Two border halfedges h1 and h2 can be stitched if the points associated to the source and /// target vertices of h1 are the same as those of the target and source vertices of h2, respectively. /// /// The polygon mesh. /// The number of stiched boundaries. public int StitchBoundaryCycles(SurfaceMesh3 mesh) { CheckIsValidException(mesh); mesh.SetIsUpdatedToFalse(); return Kernel.StitchBoundaryCycles_SM(mesh.Ptr); } /// /// Stitches together border halfedges in a polygon mesh. /// /// The polygon mesh. /// The number of stiched borders. public int StitchBorders(Polyhedron3 mesh) { CheckIsValidException(mesh); mesh.SetIsUpdatedToFalse(); return Kernel.StitchBorders_PH(mesh.Ptr); } /// /// Stitches together border halfedges in a polygon mesh. /// /// The polygon mesh. /// The number of stiched borders. public int StitchBorders(SurfaceMesh3 mesh) { CheckIsValidException(mesh); mesh.SetIsUpdatedToFalse(); return Kernel.StitchBorders_SM(mesh.Ptr); } /* /// /// Merges the duplicated vertices of the edges boundary cycle. /// /// The polygon mesh. /// The index of a half edge in the boundary. /// public int MergeDuplicatedVerticesInBoundaryCycle(Polyhedron3 mesh, int index) { CheckIsValidException(mesh); mesh.SetIsUpdatedToFalse(); return Kernel.MergeDuplicatedVerticesInBoundaryCycle_PH(mesh.Ptr, index); } /// /// Merges the duplicated vertices of the edges boundary cycle. /// /// The polygon mesh. /// The index of a half edge in the boundary. /// public int MergeDuplicatedVerticesInBoundaryCycle(SurfaceMesh3 mesh, int index) { CheckIsValidException(mesh); mesh.SetIsUpdatedToFalse(); return Kernel.MergeDuplicatedVerticesInBoundaryCycle_SM(mesh.Ptr, index); } /// /// Extracts boundary cycles and merges the duplicated vertices of each cycle. /// /// The polygon mesh. /// The number of vertices that were merged. public int MergeDuplicatedVerticesInBoundaryCycles(Polyhedron3 mesh) { CheckIsValidException(mesh); mesh.SetIsUpdatedToFalse(); return Kernel.MergeDuplicatedVerticesInBoundaryCycles_PH(mesh.Ptr); } /// /// Extracts boundary cycles and merges the duplicated vertices of each cycle. /// /// The polygon mesh. /// The number of vertices that were merged. public int MergeDuplicatedVerticesInBoundaryCycles(SurfaceMesh3 mesh) { CheckIsValidException(mesh); mesh.SetIsUpdatedToFalse(); return Kernel.MergeDuplicatedVerticesInBoundaryCycles_SM(mesh.Ptr); } */ /// /// Removes the isolated vertices from any polygon mesh. /// A vertex is considered isolated if it is not incident to any simplex of higher dimension. /// /// The polygon mesh. /// The number of vertices that were removed. public int RemoveIsolatedVertices(Polyhedron3 mesh) { mesh.SetIsUpdatedToFalse(); return Kernel.RemoveIsolatedVertices_PH(mesh.Ptr); } /// /// Removes the isolated vertices from any polygon mesh. /// A vertex is considered isolated if it is not incident to any simplex of higher dimension. /// /// The polygon mesh. /// The number of vertices that were removed. public int RemoveIsolatedVertices(SurfaceMesh3 mesh) { mesh.SetIsUpdatedToFalse(); return Kernel.RemoveIsolatedVertices_SM(mesh.Ptr); } } /// /// /// public abstract class MeshProcessingRepair : PolyhedraAlgorithm { /// /// /// private MeshProcessingRepair() { } /// /// /// /// internal MeshProcessingRepair(CGALKernel kernel) { Kernel = kernel.MeshProcessingRepairKernel; Ptr = Kernel.Create(); } /// /// /// /// /// internal MeshProcessingRepair(CGALKernel kernel, IntPtr ptr) : base(ptr) { Kernel = kernel.MeshProcessingRepairKernel; Ptr = ptr; } /// /// /// internal MeshProcessingRepairKernel Kernel { get; private set; } /// /// Release any unmanaged resources. /// protected override void ReleasePtr() { Kernel.Release(Ptr); } } } ================================================ FILE: CGALDotNet/Processing/MeshProcessingRepairKernel.cs ================================================ using System; using System.Collections.Generic; using System.Text; namespace CGALDotNet.Processing { internal abstract class MeshProcessingRepairKernel : CGALObjectKernel { internal abstract IntPtr Create(); internal abstract void Release(IntPtr ptr); //Polyhedron internal abstract int DegenerateEdgeCount_PH(IntPtr ptr); internal abstract int DegenerateTriangleCount_PH(IntPtr ptr); internal abstract int NeedleTriangleCount_PH(IntPtr ptr, double threshold); internal abstract int NonManifoldVertexCount_PH(IntPtr ptr); internal abstract void RepairPolygonSoup_PH(IntPtr ptr); internal abstract int StitchBoundaryCycles_PH(IntPtr ptr); internal abstract int StitchBorders_PH(IntPtr ptr); internal abstract int MergeDuplicatedVerticesInBoundaryCycle_PH(IntPtr ptr, int index); internal abstract int MergeDuplicatedVerticesInBoundaryCycles_PH(IntPtr ptr); internal abstract int RemoveIsolatedVertices_PH(IntPtr ptr); //SurfaceMesh internal abstract int DegenerateEdgeCount_SM(IntPtr ptr); internal abstract int DegenerateTriangleCount_SM(IntPtr ptr); internal abstract int NeedleTriangleCount_SM(IntPtr ptr, double threshold); internal abstract int NonManifoldVertexCount_SM(IntPtr ptr); internal abstract void RepairPolygonSoup_SM(IntPtr ptr); internal abstract int StitchBoundaryCycles_SM(IntPtr ptr); internal abstract int StitchBorders_SM(IntPtr ptr); internal abstract int MergeDuplicatedVerticesInBoundaryCycle_SM(IntPtr ptr, int index); internal abstract int MergeDuplicatedVerticesInBoundaryCycles_SM(IntPtr ptr); internal abstract int RemoveIsolatedVertices_SM(IntPtr ptr); } } ================================================ FILE: CGALDotNet/Processing/MeshProcessingRepairKernel_EEK.cs ================================================ using System; using System.Collections.Generic; using System.Text; using System.Runtime.InteropServices; namespace CGALDotNet.Processing { internal class MeshProcessingRepairKernel_EEK : MeshProcessingRepairKernel { internal override string Name => "EEK"; internal static readonly MeshProcessingRepairKernel Instance = new MeshProcessingRepairKernel_EEK(); internal override IntPtr Create() { return MeshProcessingRepair_EEK_Create(); } internal override void Release(IntPtr ptr) { MeshProcessingRepair_EEK_Release(ptr); } //Polyhedron internal override int DegenerateEdgeCount_PH(IntPtr ptr) { return MeshProcessingRepair_EEK_DegenerateEdgeCount_PH(ptr); } internal override int DegenerateTriangleCount_PH(IntPtr ptr) { return MeshProcessingRepair_EEK_DegenerateTriangleCount_PH(ptr); } internal override int NeedleTriangleCount_PH(IntPtr ptr, double threshold) { return MeshProcessingRepair_EEK_NeedleTriangleCount_PH(ptr, threshold); } internal override int NonManifoldVertexCount_PH(IntPtr ptr) { return MeshProcessingRepair_EEK_NonManifoldVertexCount_PH(ptr); } internal override void RepairPolygonSoup_PH(IntPtr ptr) { MeshProcessingRepair_EEK_RepairPolygonSoup_PH(ptr); } internal override int StitchBoundaryCycles_PH(IntPtr ptr) { return MeshProcessingRepair_EEK_StitchBoundaryCycles_PH(ptr); } internal override int StitchBorders_PH(IntPtr ptr) { return MeshProcessingRepair_EEK_StitchBorders_PH(ptr); } internal override int MergeDuplicatedVerticesInBoundaryCycle_PH(IntPtr ptr, int index) { return MergeDuplicatedVerticesInBoundaryCycle_PH(ptr, index); } internal override int MergeDuplicatedVerticesInBoundaryCycles_PH(IntPtr ptr) { return MergeDuplicatedVerticesInBoundaryCycles_PH(ptr); } internal override int RemoveIsolatedVertices_PH(IntPtr ptr) { return MeshProcessingRepair_EEK_RemoveIsolatedVertices_PH(ptr); } //SurfaceMesh internal override int DegenerateEdgeCount_SM(IntPtr ptr) { return MeshProcessingRepair_EEK_DegenerateEdgeCount_SM(ptr); } internal override int DegenerateTriangleCount_SM(IntPtr ptr) { return MeshProcessingRepair_EEK_DegenerateTriangleCount_SM(ptr); } internal override int NeedleTriangleCount_SM(IntPtr ptr, double threshold) { return MeshProcessingRepair_EEK_NeedleTriangleCount_SM(ptr, threshold); } internal override int NonManifoldVertexCount_SM(IntPtr ptr) { return MeshProcessingRepair_EEK_NonManifoldVertexCount_SM(ptr); } internal override void RepairPolygonSoup_SM(IntPtr ptr) { MeshProcessingRepair_EEK_RepairPolygonSoup_SM(ptr); } internal override int StitchBoundaryCycles_SM(IntPtr ptr) { return MeshProcessingRepair_EEK_StitchBoundaryCycles_SM(ptr); } internal override int StitchBorders_SM(IntPtr ptr) { return MeshProcessingRepair_EEK_StitchBorders_SM(ptr); } internal override int MergeDuplicatedVerticesInBoundaryCycle_SM(IntPtr ptr, int index) { return MergeDuplicatedVerticesInBoundaryCycle_SM(ptr, index); } internal override int MergeDuplicatedVerticesInBoundaryCycles_SM(IntPtr ptr) { return MergeDuplicatedVerticesInBoundaryCycles_SM(ptr); } internal override int RemoveIsolatedVertices_SM(IntPtr ptr) { return MeshProcessingRepair_EEK_RemoveIsolatedVertices_SM(ptr); } [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr MeshProcessingRepair_EEK_Create(); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void MeshProcessingRepair_EEK_Release(IntPtr ptr); //Polyhedron [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int MeshProcessingRepair_EEK_DegenerateEdgeCount_PH(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int MeshProcessingRepair_EEK_DegenerateTriangleCount_PH(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int MeshProcessingRepair_EEK_NeedleTriangleCount_PH(IntPtr ptr, double threshold); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int MeshProcessingRepair_EEK_NonManifoldVertexCount_PH(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void MeshProcessingRepair_EEK_RepairPolygonSoup_PH(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int MeshProcessingRepair_EEK_StitchBoundaryCycles_PH(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int MeshProcessingRepair_EEK_StitchBorders_PH(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int MeshProcessingRepair_EEK_MergeDuplicatedVerticesInBoundaryCycle_PH(IntPtr ptr, int index); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int MeshProcessingRepair_EEK_MergeDuplicatedVerticesInBoundaryCycles_PH(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int MeshProcessingRepair_EEK_RemoveIsolatedVertices_PH(IntPtr ptr); //SurfaceMesh [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int MeshProcessingRepair_EEK_DegenerateEdgeCount_SM(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int MeshProcessingRepair_EEK_DegenerateTriangleCount_SM(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int MeshProcessingRepair_EEK_NeedleTriangleCount_SM(IntPtr ptr, double threshold); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int MeshProcessingRepair_EEK_NonManifoldVertexCount_SM(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void MeshProcessingRepair_EEK_RepairPolygonSoup_SM(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int MeshProcessingRepair_EEK_StitchBoundaryCycles_SM(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int MeshProcessingRepair_EEK_StitchBorders_SM(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int MeshProcessingRepair_EEK_MergeDuplicatedVerticesInBoundaryCycle_SM(IntPtr ptr, int index); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int MeshProcessingRepair_EEK_MergeDuplicatedVerticesInBoundaryCycles_SM(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int MeshProcessingRepair_EEK_RemoveIsolatedVertices_SM(IntPtr ptr); } } ================================================ FILE: CGALDotNet/Processing/MeshProcessingRepairKernel_EIK.cs ================================================ using System; using System.Collections.Generic; using System.Text; using System.Runtime.InteropServices; namespace CGALDotNet.Processing { internal class MeshProcessingRepairKernel_EIK : MeshProcessingRepairKernel { internal override string Name => "EIK"; internal static readonly MeshProcessingRepairKernel Instance = new MeshProcessingRepairKernel_EIK(); internal override IntPtr Create() { return MeshProcessingRepair_EIK_Create(); } internal override void Release(IntPtr ptr) { MeshProcessingRepair_EIK_Release(ptr); } //Polyhedron internal override int DegenerateEdgeCount_PH(IntPtr ptr) { return MeshProcessingRepair_EIK_DegenerateEdgeCount_PH(ptr); } internal override int DegenerateTriangleCount_PH(IntPtr ptr) { return MeshProcessingRepair_EIK_DegenerateTriangleCount_PH(ptr); } internal override int NeedleTriangleCount_PH(IntPtr ptr, double threshold) { return MeshProcessingRepair_EIK_NeedleTriangleCount_PH(ptr, threshold); } internal override int NonManifoldVertexCount_PH(IntPtr ptr) { return MeshProcessingRepair_EIK_NonManifoldVertexCount_PH(ptr); } internal override void RepairPolygonSoup_PH(IntPtr ptr) { MeshProcessingRepair_EIK_RepairPolygonSoup_PH(ptr); } internal override int StitchBoundaryCycles_PH(IntPtr ptr) { return MeshProcessingRepair_EIK_StitchBoundaryCycles_PH(ptr); } internal override int StitchBorders_PH(IntPtr ptr) { return MeshProcessingRepair_EIK_StitchBorders_PH(ptr); } internal override int MergeDuplicatedVerticesInBoundaryCycle_PH(IntPtr ptr, int index) { return MergeDuplicatedVerticesInBoundaryCycle_PH(ptr, index); } internal override int MergeDuplicatedVerticesInBoundaryCycles_PH(IntPtr ptr) { return MergeDuplicatedVerticesInBoundaryCycles_PH(ptr); } internal override int RemoveIsolatedVertices_PH(IntPtr ptr) { return MeshProcessingRepair_EIK_RemoveIsolatedVertices_PH(ptr); } //SurfaceMesh internal override int DegenerateEdgeCount_SM(IntPtr ptr) { return MeshProcessingRepair_EIK_DegenerateEdgeCount_SM(ptr); } internal override int DegenerateTriangleCount_SM(IntPtr ptr) { return MeshProcessingRepair_EIK_DegenerateTriangleCount_SM(ptr); } internal override int NeedleTriangleCount_SM(IntPtr ptr, double threshold) { return MeshProcessingRepair_EIK_NeedleTriangleCount_SM(ptr, threshold); } internal override int NonManifoldVertexCount_SM(IntPtr ptr) { return MeshProcessingRepair_EIK_NonManifoldVertexCount_SM(ptr); } internal override void RepairPolygonSoup_SM(IntPtr ptr) { MeshProcessingRepair_EIK_RepairPolygonSoup_SM(ptr); } internal override int StitchBoundaryCycles_SM(IntPtr ptr) { return MeshProcessingRepair_EIK_StitchBoundaryCycles_SM(ptr); } internal override int StitchBorders_SM(IntPtr ptr) { return MeshProcessingRepair_EIK_StitchBorders_SM(ptr); } internal override int MergeDuplicatedVerticesInBoundaryCycle_SM(IntPtr ptr, int index) { return MergeDuplicatedVerticesInBoundaryCycle_SM(ptr, index); } internal override int MergeDuplicatedVerticesInBoundaryCycles_SM(IntPtr ptr) { return MergeDuplicatedVerticesInBoundaryCycles_SM(ptr); } internal override int RemoveIsolatedVertices_SM(IntPtr ptr) { return MeshProcessingRepair_EIK_RemoveIsolatedVertices_SM(ptr); } [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr MeshProcessingRepair_EIK_Create(); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void MeshProcessingRepair_EIK_Release(IntPtr ptr); //Polyhedron [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int MeshProcessingRepair_EIK_DegenerateEdgeCount_PH(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int MeshProcessingRepair_EIK_DegenerateTriangleCount_PH(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int MeshProcessingRepair_EIK_NeedleTriangleCount_PH(IntPtr ptr, double threshold); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int MeshProcessingRepair_EIK_NonManifoldVertexCount_PH(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void MeshProcessingRepair_EIK_RepairPolygonSoup_PH(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int MeshProcessingRepair_EIK_StitchBoundaryCycles_PH(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int MeshProcessingRepair_EIK_StitchBorders_PH(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int MeshProcessingRepair_EIK_MergeDuplicatedVerticesInBoundaryCycle_PH(IntPtr ptr, int index); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int MeshProcessingRepair_EIK_MergeDuplicatedVerticesInBoundaryCycles_PH(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int MeshProcessingRepair_EIK_RemoveIsolatedVertices_PH(IntPtr ptr); //SurfaceMesh [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int MeshProcessingRepair_EIK_DegenerateEdgeCount_SM(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int MeshProcessingRepair_EIK_DegenerateTriangleCount_SM(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int MeshProcessingRepair_EIK_NeedleTriangleCount_SM(IntPtr ptr, double threshold); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int MeshProcessingRepair_EIK_NonManifoldVertexCount_SM(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void MeshProcessingRepair_EIK_RepairPolygonSoup_SM(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int MeshProcessingRepair_EIK_StitchBoundaryCycles_SM(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int MeshProcessingRepair_EIK_StitchBorders_SM(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int MeshProcessingRepair_EIK_MergeDuplicatedVerticesInBoundaryCycle_SM(IntPtr ptr, int index); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int MeshProcessingRepair_EIK_MergeDuplicatedVerticesInBoundaryCycles_SM(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int MeshProcessingRepair_EIK_RemoveIsolatedVertices_SM(IntPtr ptr); } } ================================================ FILE: CGALDotNet/Processing/MeshProcessingSlicer.cs ================================================ using System; using System.Collections.Generic; using System.Text; using CGALDotNetGeometry.Numerics; using CGALDotNetGeometry.Shapes; using CGALDotNet.Polyhedra; using CGALDotNet.Polylines; namespace CGALDotNet.Processing { /// /// /// /// public sealed class MeshProcessingSlicer : MeshProcessingSlicer where K : CGALKernel, new() { /// /// /// public static readonly MeshProcessingSlicer Instance = new MeshProcessingSlicer(); /// /// /// public MeshProcessingSlicer() : base(new K()) { } /// /// /// /// internal MeshProcessingSlicer(IntPtr ptr) : base(new K(), ptr) { } /// /// /// /// public override string ToString() { return string.Format("[MeshProcessingSlicer<{0}>: ]", Kernel.Name); } /// /// Find the line formed from the intersection of the plane and the mesh. /// /// The mesh. Is not modified. /// The plane. /// The polylines from the intersection. public void Slice(Polyhedron3 mesh, Plane3d plane, List> results) { int count = Kernel.Slice_PH(Ptr, mesh.Ptr, plane, true); GetLines(count, results); } /// /// Find the line formed from the intersection of the plane and the mesh. /// /// The mesh. Is not modified. /// The plane. /// The polylines from the intersection. public void Slice(SurfaceMesh3 mesh, Plane3d plane, List> results) { int count = Kernel.Slice_SM(Ptr, mesh.Ptr, plane, true); GetLines(count, results); } /// /// Find the lines formed by slicing the mesh from the start /// point to the end point creating a plane at each increment. /// /// The mesh. Is not modified. /// The point to start from. /// The point to end at. /// Amount to increment each plane. /// he polylines from the intersection. public void Slice(Polyhedron3 mesh, Point3d start, Point3d end, double increment, List> results) { int count = Kernel.IncrementalSlice_PH(Ptr, mesh.Ptr, start, end, increment); GetLines(count, results); } /// /// Find the lines formed by slicing the mesh from the start /// point to the end point creating a plane at each increment. /// /// The mesh. Is not modified. /// The point to start from. /// The point to end at. /// Amount to increment each plane. /// he polylines from the intersection. public void Slice(SurfaceMesh3 mesh, Point3d start, Point3d end, double increment, List> results) { int count = Kernel.IncrementalSlice_SM(Ptr, mesh.Ptr, start, end, increment); GetLines(count, results); } /// /// /// /// /// private void GetLines(int count, List> results) { if (count == 0) return; var ptrs = new IntPtr[count]; Kernel.GetLines(Ptr, ptrs, count); for (int i = 0; i < count; i++) { var line = new Polyline3(ptrs[i]); results.Add(line); } } } /// /// /// public abstract class MeshProcessingSlicer : PolyhedraAlgorithm { /// /// /// private MeshProcessingSlicer() { } /// /// /// /// internal MeshProcessingSlicer(CGALKernel kernel) { Kernel = kernel.MeshProcessingSlicerKernel; Ptr = Kernel.Create(); } /// /// /// /// /// internal MeshProcessingSlicer(CGALKernel kernel, IntPtr ptr) : base(ptr) { Kernel = kernel.MeshProcessingSlicerKernel; Ptr = ptr; } /// /// /// internal MeshProcessingSlicerKernel Kernel { get; private set; } /// /// Release any unmanaged resources. /// protected override void ReleasePtr() { Kernel.Release(Ptr); } } } ================================================ FILE: CGALDotNet/Processing/MeshProcessingSlicerKernel.cs ================================================ using System; using System.Collections.Generic; using System.Text; using CGALDotNetGeometry.Numerics; using CGALDotNetGeometry.Shapes; namespace CGALDotNet.Processing { internal abstract class MeshProcessingSlicerKernel : CGALObjectKernel { internal abstract IntPtr Create(); internal abstract void Release(IntPtr ptr); internal abstract void GetLines(IntPtr slicerPtr, IntPtr[] lines, int count); //Polyhedron internal abstract int Slice_PH(IntPtr slicerPtr, IntPtr meshPtr, Plane3d plane, bool useTree); internal abstract int IncrementalSlice_PH(IntPtr slicerPtr, IntPtr meshPtr, Point3d start, Point3d end, double increment); //SUrfaceMesh internal abstract int Slice_SM(IntPtr slicerPtr, IntPtr meshPtr, Plane3d plane, bool useTree); internal abstract int IncrementalSlice_SM(IntPtr slicerPtr, IntPtr meshPtr, Point3d start, Point3d end, double increment); } } ================================================ FILE: CGALDotNet/Processing/MeshProcessingSlicerKernel_EEK.cs ================================================ using System; using System.Collections.Generic; using System.Text; using System.Runtime.InteropServices; using CGALDotNetGeometry.Numerics; using CGALDotNetGeometry.Shapes; namespace CGALDotNet.Processing { internal class MeshProcessingSlicerKernel_EEK : MeshProcessingSlicerKernel { internal override string Name => "EEK"; internal static readonly MeshProcessingSlicerKernel Instance = new MeshProcessingSlicerKernel_EEK(); internal override IntPtr Create() { return MeshProcessingSlicer_EEK_Create(); } internal override void Release(IntPtr ptr) { MeshProcessingSlicer_EEK_Release(ptr); } internal override void GetLines(IntPtr slicerPtr, IntPtr[] lines, int count) { MeshProcessingSlicer_EEK_GetLines(slicerPtr, lines, count); } //Polyhedron internal override int Slice_PH(IntPtr slicerPtr, IntPtr meshPtr, Plane3d plane, bool useTree) { return MeshProcessingSlicer_EEK_Slice_PH(slicerPtr, meshPtr, plane, useTree); } internal override int IncrementalSlice_PH(IntPtr slicerPtr, IntPtr meshPtr, Point3d start, Point3d end, double increment) { return MeshProcessingSlicer_EEK_IncrementalSlice_PH(slicerPtr, meshPtr, start, end, increment); } //Surface Mesh internal override int Slice_SM(IntPtr slicerPtr, IntPtr meshPtr, Plane3d plane, bool useTree) { return MeshProcessingSlicer_EEK_Slice_SM(slicerPtr, meshPtr, plane, useTree); } internal override int IncrementalSlice_SM(IntPtr slicerPtr, IntPtr meshPtr, Point3d start, Point3d end, double increment) { return MeshProcessingSlicer_EEK_IncrementalSlice_SM(slicerPtr, meshPtr, start, end, increment); } [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr MeshProcessingSlicer_EEK_Create(); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void MeshProcessingSlicer_EEK_Release(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void MeshProcessingSlicer_EEK_GetLines(IntPtr slicerPtr, IntPtr[] lines, int count); //Polyhedron [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int MeshProcessingSlicer_EEK_Slice_PH(IntPtr slicerPtr, IntPtr meshPtr, Plane3d plane, bool useTree); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int MeshProcessingSlicer_EEK_IncrementalSlice_PH(IntPtr slicerPtr, IntPtr meshPtr, Point3d start, Point3d end, double increment); //SurfaceMesh [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int MeshProcessingSlicer_EEK_Slice_SM(IntPtr slicerPtr, IntPtr meshPtr, Plane3d plane, bool useTree); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int MeshProcessingSlicer_EEK_IncrementalSlice_SM(IntPtr slicerPtr, IntPtr meshPtr, Point3d start, Point3d end, double increment); } } ================================================ FILE: CGALDotNet/Processing/MeshProcessingSlicerKernel_EIK.cs ================================================ using System; using System.Collections.Generic; using System.Text; using System.Runtime.InteropServices; using CGALDotNetGeometry.Numerics; using CGALDotNetGeometry.Shapes; namespace CGALDotNet.Processing { internal class MeshProcessingSlicerKernel_EIK : MeshProcessingSlicerKernel { internal override string Name => "EIK"; internal static readonly MeshProcessingSlicerKernel Instance = new MeshProcessingSlicerKernel_EIK(); internal override IntPtr Create() { return MeshProcessingSlicer_EIK_Create(); } internal override void Release(IntPtr ptr) { MeshProcessingSlicer_EIK_Release(ptr); } internal override void GetLines(IntPtr slicerPtr, IntPtr[] lines, int count) { MeshProcessingSlicer_EIK_GetLines(slicerPtr, lines, count); } //Polyhedron internal override int Slice_PH(IntPtr slicerPtr, IntPtr meshPtr, Plane3d plane, bool useTree) { return MeshProcessingSlicer_EIK_Slice_PH(slicerPtr, meshPtr, plane, useTree); } internal override int IncrementalSlice_PH(IntPtr slicerPtr, IntPtr meshPtr, Point3d start, Point3d end, double increment) { return MeshProcessingSlicer_EIK_IncrementalSlice_PH(slicerPtr, meshPtr, start, end, increment); } //Surface Mesh internal override int Slice_SM(IntPtr slicerPtr, IntPtr meshPtr, Plane3d plane, bool useTree) { return MeshProcessingSlicer_EIK_Slice_SM(slicerPtr, meshPtr, plane, useTree); } internal override int IncrementalSlice_SM(IntPtr slicerPtr, IntPtr meshPtr, Point3d start, Point3d end, double increment) { return MeshProcessingSlicer_EIK_IncrementalSlice_SM(slicerPtr, meshPtr, start, end, increment); } [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr MeshProcessingSlicer_EIK_Create(); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void MeshProcessingSlicer_EIK_Release(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void MeshProcessingSlicer_EIK_GetLines(IntPtr slicerPtr, IntPtr[] lines, int count); //Polyhedron [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int MeshProcessingSlicer_EIK_Slice_PH(IntPtr slicerPtr, IntPtr meshPtr, Plane3d plane, bool useTree); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int MeshProcessingSlicer_EIK_IncrementalSlice_PH(IntPtr slicerPtr, IntPtr meshPtr, Point3d start, Point3d end, double increment); //SurfaceMesh [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int MeshProcessingSlicer_EIK_Slice_SM(IntPtr slicerPtr, IntPtr meshPtr, Plane3d plane, bool useTree); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int MeshProcessingSlicer_EIK_IncrementalSlice_SM(IntPtr slicerPtr, IntPtr meshPtr, Point3d start, Point3d end, double increment); } } ================================================ FILE: CGALDotNet/Processing/SurfaceSimplification.cs ================================================ using System; using System.Collections.Generic; using CGALDotNet.Polyhedra; using CGALDotNetGeometry.Numerics; namespace CGALDotNet.Processing { /// /// /// /// public sealed class SurfaceSimplification : SurfaceSimplification where K : CGALKernel, new() { /// /// /// public static readonly SurfaceSimplification Instance = new SurfaceSimplification(); /// /// /// public SurfaceSimplification() : base(new K()) { } /// /// /// /// public override string ToString() { return string.Format("[SurfaceSimplification<{0}>: ]", Kernel.Name); } } /// /// /// public abstract class SurfaceSimplification : PolyhedraAlgorithm { /// /// /// private SurfaceSimplification() { } /// /// /// /// internal SurfaceSimplification(CGALKernel kernel) { Kernel = kernel.SurfaceSimplificationKernel; Ptr = Kernel.Create(); } /// /// /// protected private SurfaceSimplificationKernel Kernel { get; private set; } /// /// Simplify the mesh. /// /// A valid triangle mesh. /// A percentage 0-1 of edges to remove. public void Simplify(Polyhedron3 mesh, double stop_ratio) { stop_ratio = MathUtil.Clamp01(stop_ratio); if (stop_ratio == 0) return; CheckIsValidTriangleException(mesh); mesh.SetIsUpdatedToFalse(); Kernel.Simplify_PH(mesh.Ptr, stop_ratio); } /// /// Simplify the mesh. /// /// A valid triangle mesh. /// A percentage 0-1 of edges to remove. public void Simplify(SurfaceMesh3 mesh, double stop_ratio) { stop_ratio = MathUtil.Clamp01(stop_ratio); if (stop_ratio == 0) return; CheckIsValidTriangleException(mesh); mesh.SetIsUpdatedToFalse(); Kernel.Simplify_SM(mesh.Ptr, stop_ratio); } /// /// Release the unmanaged resourses. /// protected override void ReleasePtr() { Kernel.Release(Ptr); } } } ================================================ FILE: CGALDotNet/Processing/SurfaceSimplificationKernel.cs ================================================ using System; using System.Collections.Generic; using System.Text; namespace CGALDotNet.Processing { internal abstract class SurfaceSimplificationKernel : CGALObjectKernel { internal abstract IntPtr Create(); internal abstract void Release(IntPtr ptr); internal abstract void Simplify_PH(IntPtr meshPtr, double stop_ratio); internal abstract void Simplify_SM(IntPtr meshPtr, double stop_ratio); } } ================================================ FILE: CGALDotNet/Processing/SurfaceSimplificationKernel_EIK.cs ================================================ using System; using System.Collections.Generic; using System.Runtime.InteropServices; namespace CGALDotNet.Processing { internal class SurfaceSimplificationKernel_EIK : SurfaceSimplificationKernel { internal override string Name => "EIK"; internal static readonly SurfaceSimplificationKernel Instance = new SurfaceSimplificationKernel_EIK(); internal override IntPtr Create() { return SurfaceSimplification_EIK_Create(); } internal override void Release(IntPtr ptr) { SurfaceSimplification_EIK_Release(ptr); } internal override void Simplify_PH(IntPtr meshPtr, double stop_ratio) { SurfaceSimplification_EIK_Simplify_PH(meshPtr, stop_ratio); } internal override void Simplify_SM(IntPtr meshPtr, double stop_ratio) { SurfaceSimplification_EIK_Simplify_SM(meshPtr, stop_ratio); } [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr SurfaceSimplification_EIK_Create(); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void SurfaceSimplification_EIK_Release(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void SurfaceSimplification_EIK_Simplify_PH(IntPtr meshPtr, double stop_ratio); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void SurfaceSimplification_EIK_Simplify_SM(IntPtr meshPtr, double stop_ratio); } } ================================================ FILE: CGALDotNet/Processing/SurfaceSubdivision.cs ================================================ using System; using System.Collections.Generic; using CGALDotNet.Polyhedra; namespace CGALDotNet.Processing { /// /// /// public enum SUBDIVISION_METHOD { CATMULL_CLARK, LOOP, SQRT3 } /// /// /// /// public sealed class SubdivisionSurface : SubdivisionSurface where K : CGALKernel, new() { /// /// /// public static readonly SubdivisionSurface Instance = new SubdivisionSurface(); /// /// /// public SubdivisionSurface() : base(new K()) { } /// /// /// /// public override string ToString() { return string.Format("[SubdivisionSurface<{0}>: ]", Kernel.Name); } /// /// Subdive each face in the mesh. /// /// /// A valid mesh. Must be a triangle mesh for loop or sqrt3. /// The number of subdivision iterations. public void Subdivide(SUBDIVISION_METHOD method, Polyhedron3 mesh, int iterations) { switch (method) { case SUBDIVISION_METHOD.CATMULL_CLARK: Subdivide_CatmullClark(mesh, iterations); break; case SUBDIVISION_METHOD.LOOP: Subdivide_Loop(mesh, iterations); break; case SUBDIVISION_METHOD.SQRT3: Subdivide_Sqrt3(mesh, iterations); break; default: Subdivide_Sqrt3(mesh, iterations); break; } } /// /// Subdive each face in the mesh. /// /// /// A valid mesh. Must be a triangle mesh for loop or sqrt3. /// The number of subdivision iterations. public void Subdivide(SUBDIVISION_METHOD method, SurfaceMesh3 mesh, int iterations) { switch (method) { case SUBDIVISION_METHOD.CATMULL_CLARK: Subdivide_CatmullClark(mesh, iterations); break; case SUBDIVISION_METHOD.LOOP: Subdivide_Loop(mesh, iterations); break; case SUBDIVISION_METHOD.SQRT3: Subdivide_Sqrt3(mesh, iterations); break; default: Subdivide_Sqrt3(mesh, iterations); break; } } /// /// Subdive each face in the mesh. /// /// A valid mesh. /// The number of subdivision iterations. public void Subdivide_CatmullClark(Polyhedron3 mesh, int iterations) { if (iterations <= 0) return; CheckIsValidException(mesh); Kernel.Subdive_CatmullClark_PH(mesh.Ptr, iterations); } /// /// Subdive each face in the mesh. /// /// A valid mesh. /// The number of subdivision iterations. public void Subdivide_CatmullClark(SurfaceMesh3 mesh, int iterations) { if (iterations <= 0) return; CheckIsValidException(mesh); Kernel.Subdive_CatmullClark_SM(mesh.Ptr, iterations); } /// /// Subdive each face in the mesh. /// /// A valid triangle mesh. /// The number of subdivision iterations. public void Subdivide_Loop(Polyhedron3 mesh, int iterations) { if (iterations <= 0) return; CheckIsValidTriangleException(mesh); Kernel.Subdive_Loop_PH(mesh.Ptr, iterations); } /// /// Subdive each face in the mesh. /// /// A valid triangle mesh. /// The number of subdivision iterations. public void Subdivide_Loop(SurfaceMesh3 mesh, int iterations) { if (iterations <= 0) return; CheckIsValidTriangleException(mesh); Kernel.Subdive_Loop_SM(mesh.Ptr, iterations); } /// /// Subdive each face in the mesh. /// /// A valid triangle mesh. /// The number of subdivision iterations. public void Subdivide_DoSabin(SurfaceMesh3 mesh, int iterations) { if (iterations <= 0) return; CheckIsValidTriangleException(mesh); Kernel.Subdive_DoSabin_SM(mesh.Ptr, iterations); } /// /// Subdive each face in the mesh. /// /// A valid triangle mesh. /// The number of subdivision iterations. public void Subdivide_Sqrt3(Polyhedron3 mesh, int iterations) { if (iterations <= 0) return; CheckIsValidTriangleException(mesh); Kernel.Subdive_Sqrt3_PH(mesh.Ptr, iterations); } /// /// Subdive each face in the mesh. /// /// A valid triangle mesh. /// The number of subdivision iterations. public void Subdivide_Sqrt3(SurfaceMesh3 mesh, int iterations) { if (iterations <= 0) return; CheckIsValidTriangleException(mesh); Kernel.Subdive_Sqrt3_SM(mesh.Ptr, iterations); } } /// /// /// public abstract class SubdivisionSurface : PolyhedraAlgorithm { /// /// /// private SubdivisionSurface() { } /// /// /// /// internal SubdivisionSurface(CGALKernel kernel) { Kernel = kernel.SurfaceSubdivisionKernel; Ptr = Kernel.Create(); } /// /// /// protected private SurfaceSubdivisionKernel Kernel { get; private set; } /// /// Release the unmanaged resourses. /// protected override void ReleasePtr() { Kernel.Release(Ptr); } } } ================================================ FILE: CGALDotNet/Processing/SurfaceSubdivisionKernel.cs ================================================ using System; using System.Collections.Generic; using System.Text; namespace CGALDotNet.Processing { internal abstract class SurfaceSubdivisionKernel : CGALObjectKernel { internal abstract IntPtr Create(); internal abstract void Release(IntPtr ptr); //Polyhedron internal abstract void Subdive_CatmullClark_PH(IntPtr polyPtr, int iterations); internal abstract void Subdive_Loop_PH(IntPtr polyPtr, int iterations); internal abstract void Subdive_Sqrt3_PH(IntPtr polyPtr, int iterations); //Surface Mesh internal abstract void Subdive_CatmullClark_SM(IntPtr polyPtr, int iterations); internal abstract void Subdive_DoSabin_SM(IntPtr polyPtr, int iterations); internal abstract void Subdive_Loop_SM(IntPtr polyPtr, int iterations); internal abstract void Subdive_Sqrt3_SM(IntPtr polyPtr, int iterations); } } ================================================ FILE: CGALDotNet/Processing/SurfaceSubdivisionKernel_EEK.cs ================================================ using System; using System.Collections.Generic; using System.Runtime.InteropServices; namespace CGALDotNet.Processing { internal class SurfaceSubdivisionKernel_EEK : SurfaceSubdivisionKernel { internal override string Name => "EEK"; internal static readonly SurfaceSubdivisionKernel Instance = new SurfaceSubdivisionKernel_EEK(); internal override IntPtr Create() { return SurfaceSubdivision_EEK_Create(); } internal override void Release(IntPtr ptr) { SurfaceSubdivision_EEK_Release(ptr); } //Polyhedron internal override void Subdive_CatmullClark_PH(IntPtr polyPtr, int iterations) { SurfaceSubdivision_EEK_Subdive_CatmullClark_PH(polyPtr, iterations); } internal override void Subdive_Loop_PH(IntPtr polyPtr, int iterations) { SurfaceSubdivision_EEK_Subdive_Loop_PH(polyPtr, iterations); } internal override void Subdive_Sqrt3_PH(IntPtr polyPtr, int iterations) { SurfaceSubdivision_EEK_Subdive_Sqrt3_PH(polyPtr, iterations); } //Surface Mesh internal override void Subdive_CatmullClark_SM(IntPtr polyPtr, int iterations) { SurfaceSubdivision_EEK_Subdive_CatmullClark_SM(polyPtr, iterations); } internal override void Subdive_DoSabin_SM(IntPtr polyPtr, int iterations) { SurfaceSubdivision_EEK_Subdive_DoSabin_SM(polyPtr, iterations); } internal override void Subdive_Loop_SM(IntPtr polyPtr, int iterations) { SurfaceSubdivision_EEK_Subdive_Loop_SM(polyPtr, iterations); } internal override void Subdive_Sqrt3_SM(IntPtr polyPtr, int iterations) { SurfaceSubdivision_EEK_Subdive_Sqrt3_SM(polyPtr, iterations); } [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr SurfaceSubdivision_EEK_Create(); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void SurfaceSubdivision_EEK_Release(IntPtr ptr); //Polyhedron [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void SurfaceSubdivision_EEK_Subdive_CatmullClark_PH(IntPtr polyPtr, int iterations); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void SurfaceSubdivision_EEK_Subdive_Loop_PH(IntPtr polyPtr, int iterations); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void SurfaceSubdivision_EEK_Subdive_Sqrt3_PH(IntPtr polyPtr, int iterations); //Surface Mesh [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void SurfaceSubdivision_EEK_Subdive_CatmullClark_SM(IntPtr polyPtr, int iterations); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void SurfaceSubdivision_EEK_Subdive_DoSabin_SM(IntPtr polyPtr, int iterations); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void SurfaceSubdivision_EEK_Subdive_Loop_SM(IntPtr polyPtr, int iterations); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void SurfaceSubdivision_EEK_Subdive_Sqrt3_SM(IntPtr polyPtr, int iterations); } } ================================================ FILE: CGALDotNet/Processing/SurfaceSubdivisionKernel_EIK.cs ================================================ using System; using System.Collections.Generic; using System.Runtime.InteropServices; namespace CGALDotNet.Processing { internal class SurfaceSubdivisionKernel_EIK : SurfaceSubdivisionKernel { internal override string Name => "EIK"; internal static readonly SurfaceSubdivisionKernel Instance = new SurfaceSubdivisionKernel_EIK(); internal override IntPtr Create() { return SurfaceSubdivision_EIK_Create(); } internal override void Release(IntPtr ptr) { SurfaceSubdivision_EIK_Release(ptr); } //Polyhedron internal override void Subdive_CatmullClark_PH(IntPtr polyPtr, int iterations) { SurfaceSubdivision_EIK_Subdive_CatmullClark_PH(polyPtr, iterations); } internal override void Subdive_Loop_PH(IntPtr polyPtr, int iterations) { SurfaceSubdivision_EIK_Subdive_Loop_PH(polyPtr, iterations); } internal override void Subdive_Sqrt3_PH(IntPtr polyPtr, int iterations) { SurfaceSubdivision_EIK_Subdive_Sqrt3_PH(polyPtr, iterations); } //Surface Mesh internal override void Subdive_CatmullClark_SM(IntPtr polyPtr, int iterations) { SurfaceSubdivision_EIK_Subdive_CatmullClark_SM(polyPtr, iterations); } internal override void Subdive_DoSabin_SM(IntPtr polyPtr, int iterations) { SurfaceSubdivision_EIK_Subdive_DoSabin_SM(polyPtr, iterations); } internal override void Subdive_Loop_SM(IntPtr polyPtr, int iterations) { SurfaceSubdivision_EIK_Subdive_Loop_SM(polyPtr, iterations); } internal override void Subdive_Sqrt3_SM(IntPtr polyPtr, int iterations) { SurfaceSubdivision_EIK_Subdive_Sqrt3_SM(polyPtr, iterations); } [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr SurfaceSubdivision_EIK_Create(); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void SurfaceSubdivision_EIK_Release(IntPtr ptr); //Polyhedron [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void SurfaceSubdivision_EIK_Subdive_CatmullClark_PH(IntPtr polyPtr, int iterations); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void SurfaceSubdivision_EIK_Subdive_Loop_PH(IntPtr polyPtr, int iterations); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void SurfaceSubdivision_EIK_Subdive_Sqrt3_PH(IntPtr polyPtr, int iterations); //Surface Mesh [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void SurfaceSubdivision_EIK_Subdive_CatmullClark_SM(IntPtr polyPtr, int iterations); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void SurfaceSubdivision_EIK_Subdive_DoSabin_SM(IntPtr polyPtr, int iterations); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void SurfaceSubdivision_EIK_Subdive_Loop_SM(IntPtr polyPtr, int iterations); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void SurfaceSubdivision_EIK_Subdive_Sqrt3_SM(IntPtr polyPtr, int iterations); } } ================================================ FILE: CGALDotNet/Properties/launchSettings.json ================================================ { "profiles": { "CGALDotNet": { "commandName": "Project", "nativeDebugging": true } } } ================================================ FILE: CGALDotNet/Triangulations/BaseTriangulation2.cs ================================================ using System; using System.Collections.Generic; using System.Text; using CGALDotNetGeometry.Numerics; using CGALDotNetGeometry.Shapes; namespace CGALDotNet.Triangulations { public enum TRIANGULATION2 { TRIANGULATION, DELAUNAY, CONSTRAINED, CONSTRAINED_DELAUNAY } /// /// Base triangulation class for Triangulation, DelaunayTriangulation, /// ConstrainedTriangulation and ConstrainedDelaunayTriangulation. /// public abstract class BaseTriangulation2 : CGALObject { /// /// /// private BaseTriangulation2() { } /// /// /// /// internal BaseTriangulation2(BaseTriangulationKernel2 kernel) { Kernel = kernel; Ptr = Kernel.Create(); } /// /// /// /// /// internal BaseTriangulation2(BaseTriangulationKernel2 kernel, Point2d[] points) { Kernel = kernel; Ptr = Kernel.Create(); Insert(points, points.Length); } /// /// /// /// /// internal BaseTriangulation2(BaseTriangulationKernel2 kernel, IntPtr ptr) : base(ptr) { Kernel = kernel; } /// /// The triangulations kernel. /// protected private BaseTriangulationKernel2 Kernel { get; private set; } /// /// The number of verices in the triangulation. /// public int VertexCount => Kernel.VertexCount(Ptr); /// /// The number of triangles in the triangulation. /// public int TriangleCount => Kernel.FaceCount(Ptr); /// /// The number of indices need to represent the /// triangulation (number of triangles * 3). /// public int IndiceCount => TriangleCount * 3; /// /// A number that will change if the unmanaged /// triangulation model changes. /// public int BuildStamp => Kernel.BuildStamp(Ptr); /// /// Clear the triangulation. /// public void Clear() { Kernel.Clear(Ptr); } /// /// Is this a valid triangulation. /// /// /// True if valid. public bool IsValid(int level = 0) { return Kernel.IsValid(Ptr, level); } /// /// Force the face and vertex indices to be set. /// public void ForceSetIndices() { Kernel.SetIndices(Ptr); } /// /// Inserts point p in the triangulation. ///If point coincides with an already existing vertex the triangulation remains unchanged. ///If point is on an edge, the two incident faces are split in two. ///If point is strictly inside a face of the triangulation, the face is split in three. ///If point is strictly outside the convex hull, p is linked to all visible points on the ///convex hull to form the new triangulation. /// /// The point to insert. public void Insert(Point2d point) { Kernel.InsertPoint(Ptr, point); } /// /// Inserts points into the triangulation. ///If point coincides with an already existing vertex the triangulation remains unchanged. ///If point is on an edge, the two incident faces are split in two. ///If point is strictly inside a face of the triangulation, the face is split in three. ///If point is strictly outside the convex hull, p is linked to all visible points on the ///convex hull to form the new triangulation. /// /// The points to insert. /// The ararys length. public void Insert(Point2d[] points, int count) { ErrorUtil.CheckArray(points, count); Kernel.InsertPoints(Ptr, points, count); } /// /// Get a array of all the points in the triangulation. /// /// The point array. /// The ararys length. public void GetPoints(Point2d[] points, int count) { ErrorUtil.CheckArray(points, count); Kernel.GetPoints(Ptr, points, count); } /// /// Get a array of the triangle indices. /// /// /// The ararys length. public void GetIndices(int[] indices, int count) { ErrorUtil.CheckArray(indices, count); Kernel.GetIndices(Ptr, indices, count); } /// /// Get the vertices point. /// /// The vertex index. /// The vertices point. /// True if the vertex was found. public bool GetPoint(int index, out Point2d point) { TriVertex2 vertex; if(Kernel.GetVertex(Ptr, index, out vertex)) { point = vertex.Point; return true; } else { point = new Point2d(); return false; } } /// /// Get the point. /// /// The points index. /// The point /// If point with the index not found. public Point2d GetPoint(int index) { if (GetPoint(index, out Point2d point)) return point; else throw new ArgumentException("Cound not get point " + index); } /// /// Get a vertex. /// /// The vertex index. /// The vertex. /// True if the vertex was found. public bool GetVertex(int index, out TriVertex2 vertex) { return Kernel.GetVertex(Ptr, index, out vertex); } /// /// Get the vertex. /// /// The vertexs index. /// The vertexs /// If vertex with the index not found. public TriVertex2 GetVertex(int index) { if (GetVertex(index, out TriVertex2 vertex)) return vertex; else throw new ArgumentException("Cound not get vertex " + index); } /// /// Get a array of all the vertices. /// /// The vertex array. /// The ararys length. public void GetVertices(TriVertex2[] vertices, int count) { ErrorUtil.CheckArray(vertices, count); Kernel.GetVertices(Ptr, vertices, count); } /// /// Get a triangule face. /// /// The faces index /// The face /// True if the face was found. public bool GetFace(int index, out TriFace2 face) { return Kernel.GetFace(Ptr, index, out face); } /// /// Get the face. /// /// The faces index. /// The Faces /// If face with the index not found. public TriFace2 GetFace(int index) { if (GetFace(index, out TriFace2 face)) return face; else throw new ArgumentException("Cound not get face " + index); } /// /// Get a array of all the triangle faces. /// /// A array of faces. /// The ararys length. public void GetFaces(TriFace2[] faces, int count) { ErrorUtil.CheckArray(faces, count); Kernel.GetFaces(Ptr, faces, count); } /// /// Get the segment between the face and a neighbour. /// /// The faces index /// The neighbour (0-2) index in the face. /// The segment. /// True if the face was found. public bool GetSegment(int faceIndex, int neighbourIndex, out Segment2d segment) { return Kernel.GetSegment(Ptr, faceIndex, neighbourIndex, out segment); } /// /// Get the segment between the face and a neighbour. /// /// The faces index /// The neighbour (0-2) index in the face. /// The segment /// If segment with the index not found. public Segment2d GetSegment(int faceIndex, int neighbourIndex) { if (GetSegment(faceIndex, neighbourIndex, out Segment2d tri)) return tri; else throw new ArgumentException("Cound not get seg at face index " + faceIndex); } /// /// Get a faces triangle. /// /// The faces index /// The triangle /// True if the face was found public bool GetTriangle(int faceIndex, out Triangle2d triangle) { return Kernel.GetTriangle(Ptr, faceIndex, out triangle); } /// /// Get the triangle. /// /// The triangles index. /// The triangle /// If triangle with the index not found. public Triangle2d GetTriangle(int index) { if (GetTriangle(index, out Triangle2d tri)) return tri; else throw new ArgumentException("Cound not get tri " + index); } /// /// Get a array of all the triangles. /// /// A array of triangules. /// The ararys length. public void GetTriangles(Triangle2d[] triangles, int count) { ErrorUtil.CheckArray(triangles, count); Kernel.GetTriangles(Ptr, triangles, count); } /// /// Get a faces circumcenter. /// /// The faces index /// The circumcenter. A circle /// that passes through all three of the triangules vertices. /// True if the face was found. public bool GetCircumcenter(int faceIndex, out Point2d circumcenter) { return Kernel.GetCircumcenter(Ptr, faceIndex, out circumcenter); } /// /// Get the circumcenter. /// /// The circumcenters index. /// The circumcenter /// If circumcenter with the index not found. public Point2d GetCircumcenter(int index) { if (GetCircumcenter(index, out Point2d cir)) return cir; else throw new ArgumentException("Cound not get circumcenter " + index); } /// /// Get a array of all the circumcenters. /// /// A array of circumcenters. /// The ararys length. public void GetCircumcenters(Point2d[] circumcenters, int count) { ErrorUtil.CheckArray(circumcenters, count); Kernel.GetCircumcenters(Ptr, circumcenters, count); } /// /// Get the index of the faces neighbour. /// /// The faces index. /// The neighbour (0-2) index in the face. /// The index of the neighbour face in the triangulation. /// -1 if there is no neighbour face at this index. public int NeighbourIndex(int faceIndex, int neighbourIndex) { if (neighbourIndex < 0 || neighbourIndex > 2) return -1; return Kernel.NeighbourIndex(Ptr, faceIndex, neighbourIndex); } /// /// Locate the face the point hits. /// /// The point. /// The face the point has hit. /// True if the point hit a face. public bool LocateFace(Point2d point, out TriFace2 face) { return Kernel.LocateFace(Ptr, point, out face); } /// /// Locate the closest vertex to point. /// /// The point /// The distance the point must be within to count as hitting the vertex. /// The closest vertex. /// True if point hit a face and found a vertex. public bool LocateVertex(Point2d point, double radius, out TriVertex2 vertex) { //Locate the face the point hit. vertex = new TriVertex2(); if (Kernel.LocateFace(Ptr, point, out TriFace2 face)) { //Find the closest vertex in the face to the point. double min = double.PositiveInfinity; TriVertex2 closest = new TriVertex2(); for (int i = 0; i < 3; i++) { int v = face.GetVertexIndex(i); if (v == -1) continue; //If vertex found find its distance to point. if(GetVertex(v, out vertex)) { var sqdist = Point2d.SqrDistance(vertex.Point, point); if(sqdist < min) { min = sqdist; closest = vertex; } } } //Face had no valid vertices. //Should not happen but check anyway. if (min == double.PositiveInfinity || min > radius * radius) return false; else { vertex = closest; return true; } } return false; } /// /// Locate the closest edge and segment to point. /// /// The point /// The distance the point must be within to count as hitting the edge. /// The closest edge. /// True if the point hit a face and found a edge. public bool LocateEdge(Point2d point, double radius, out TriEdge2 edge) { //Locate the face the point hit. edge = new TriEdge2(); if (Kernel.LocateFace(Ptr, point, out TriFace2 face)) { //Find the closest edge to the point in the face. double min = double.PositiveInfinity; TriEdge2 closest = new TriEdge2(); for (int i = 0; i < 3; i++) { int v1 = face.GetVertexIndex(i+0); int v2 = face.GetVertexIndex(i+1); if (v1 == -1 || v2 == -1) continue; if (GetVertex(v1, out TriVertex2 vertex1) && GetVertex(v2, out TriVertex2 vertex2)) { var p1 = vertex1.Point; var p2 = vertex2.Point; var seg = new Segment2d(p1, p2); var sqdist = seg.SqrDistance(point); if (sqdist < min) { min = sqdist; int neighboutIndex = MathUtil.Wrap(i - 1, 3); closest = new TriEdge2(face.Index, neighboutIndex); closest.Segment = new Segment2d(p1, p2); } } } //Face had no valid vertices. //Should not happen but check anyway. if (min == double.PositiveInfinity || min > radius * radius) return false; else { edge = closest; return true; } } return false; } /// /// Remove the vertex. /// /// The vertices index. /// True if removed. public bool RemoveVertex(int index) { return Kernel.RemoveVertex(Ptr, index); } /// /// Flip a edge between the face and a neighbour. /// /// The faces index /// The neighbour (0-2) index in the face. /// True if the edge was flipped. public bool FlipEdge(int faceIndex, int neighbourIndex) { if (neighbourIndex < 0 || neighbourIndex > 2) return false; return Kernel.FlipEdge(Ptr, faceIndex, neighbourIndex); } /// /// Translate the triangulation. /// /// The amount to translate. public void Translate(Point2d translation) { Kernel.Transform(Ptr, translation, 0, 1); } /// /// Rotate the triangulation. /// /// The amount to rotate in radians. public void Rotate(Radian rotation) { Kernel.Transform(Ptr, Point2d.Zero, rotation.angle, 1); } /// /// Scale the triangulation. /// /// The amount to scale. public void Scale(double scale) { Kernel.Transform(Ptr, Point2d.Zero, 0, scale); } /// /// Transform the triangulation with a TRS matrix. /// /// The amount to translate. /// The amount to rotate. /// The amount to scale. public void Transform(Point2d translation, Radian rotation, double scale) { Kernel.Transform(Ptr, translation, rotation.angle, scale); } /// /// /// /// public override void Print(StringBuilder builder) { builder.AppendLine(ToString()); } /// /// Release any unmanaged resources. /// protected override void ReleasePtr() { Kernel.Release(Ptr); } } } ================================================ FILE: CGALDotNet/Triangulations/BaseTriangulation3.cs ================================================ using System; using System.Collections.Generic; using System.Text; using CGALDotNetGeometry.Numerics; using CGALDotNetGeometry.Shapes; namespace CGALDotNet.Triangulations { public enum TRIANGULATION3 { TRIANGULATION, DELAUNAY } /// /// Base triangulation class for Triangulation, DelaunayTriangulation /// and ConstrainedTriangulation. /// public abstract class BaseTriangulation3 : CGALObject { /// /// /// private BaseTriangulation3() { } /// /// /// /// /// internal BaseTriangulation3(BaseTriangulationKernel3 kernel, Point3d[] points) { Kernel = kernel; Ptr = Kernel.Create(); Insert(points, points.Length); } /// /// /// /// internal BaseTriangulation3(BaseTriangulationKernel3 kernel) { Kernel = kernel; Ptr = Kernel.Create(); } /// /// /// /// /// internal BaseTriangulation3(BaseTriangulationKernel3 kernel, IntPtr ptr) : base(ptr) { Kernel = kernel; } /// /// The triangulations kernel. /// protected private BaseTriangulationKernel3 Kernel { get; private set; } /// /// Returns the buildStamp. /// The build stamp will change if /// the triangulation model has changed /// public int BuildStamp => Kernel.BuildStamp(Ptr); /// /// Returns the dimension of the affine hull. /// public int Dimension => Kernel.Dimension(Ptr); /// /// Returns the number of vertices. /// public int VertexCount => Kernel.VertexCount(Ptr); /// /// Returns the number of finite vertices. /// public int FiniteVertexCount => Kernel.FiniteVertexCount(Ptr); /// /// Returns the number of cells or 0 if Dimension less than 3. /// public int TetrahedronCount => Kernel.CellCount(Ptr); /// /// The number of finite cells. /// Returns 0 if Dimension less than 3. /// public int FiniteTetrahedronCount => Kernel.FiniteCellCount(Ptr); /// /// The number of edges. /// Returns 0 if Dimension less than 1. /// public int EdgeCount => Kernel.EdgeCount(Ptr); /// /// The number of finite edges. /// Returns 0 if Dimension less than 1. /// public int FiniteEdgeCount => Kernel.FiniteEdgeCount(Ptr); /// /// The number of facets. /// Returns 0 if Dimension less than 2. /// public int TriangleCount => Kernel.FacetCount(Ptr); /// /// The number of facets. /// Returns 0 if Dimension less than 2. /// public int FiniteTriangleCount => Kernel.FiniteFacetCount(Ptr); /// /// The number of indices needed for the finite tetrahedrons. /// public int TetrahdronIndiceCount => FiniteTetrahedronCount * 4; /// /// Clear the triangulation. /// public void Clear() { Kernel.Clear(Ptr); } /// /// /// /// public bool IsValid() { return Kernel.IsValid(Ptr, false); } /// /// Inserts the point p in the triangulation. /// If point p coincides with an already existing vertex the triangulation remains unchanged. /// If point p lies in the convex hull of the points, it is added naturally: /// if it lies inside a cell, the cell is split into four cells, if it lies /// on a facet, the two incident cells are split into three cells, if it lies /// on an edge, all the cells incident to this edge are split into two cells. /// If point p is strictly outside the convex hull but in the affine hull, p /// is linked to all visible points on the convex hull to form the new triangulation. /// If point p is outside the affine hull of the points, p is linked to all the points, /// and the dimension of the triangulation is incremented. All the points now belong to /// the boundary of the convex hull, so, the infinite vertex is linked to all the points /// to triangulate the new infinite face. /// /// The point to insert public void Insert(Point3d point) { Kernel.InsertPoint(Ptr, point); } /// /// Insert all the points in the array. /// /// The points to insert. /// The arrays length public void Insert(Point3d[] points, int count) { ErrorUtil.CheckArray(points, count); Kernel.InsertPoints(Ptr, points, count); } /// /// Insert a vertex into a cell. /// /// The cells index. /// The point to insert. public void InsertInCell(int index, Point3d point) { Kernel.InsertInCell(Ptr, index, point); } /// /// If the point query lies inside the convex hull of the points, the cell that contains the query in its interior is returned. /// If query lies on a facet, an edge or on a vertex, one of the cells having query on its boundary is returned. /// If the point query lies outside the convex hull of the points, an infinite cell with vertices { p,q,r,∞} is /// returned such that the tetrahedron(p, q, r, query) is positively oriented(the rest of the triangulation lies /// on the other side of facet (p, q, r)). /// Note that locate works even in degenerate dimensions: in dimension 2 (resp. 1, 0) the Cell_handle returned /// is the one that represents the facet(resp.edge, vertex) containing the query point. /// The optional argument start is used as a starting place for the search. /// The optional argument could_lock_zone is used by the concurrency-safe version of the triangulation.When the /// pointer is not null, the locate will try to lock all the cells along the walk. If it succeeds, /// could_lock_zone is true, otherwise it is false. In any case, the locked cells are not unlocked by locate, /// leaving this choice to the user. /// /// The point to query /// The cell thats closest to point. /// The closest cell to point. public bool Locate(Point3d point, out TriCell3 cell) { int index = Kernel.Locate(Ptr, point); if(index != CGALGlobal.NULL_INDEX) { if(GetCell(index, out cell)) { return true; } else { cell = new TriCell3(); return false; } } else { cell = new TriCell3(); return false; } } /// /// Get the centroids of each cell. /// /// The array of points /// The array of points length public void GetCircumcenters(Point3d[] circumcenters, int count) { ErrorUtil.CheckArray(circumcenters, count); Kernel.GetCircumcenters(Ptr, circumcenters, count); } /// /// Get all the points in the triangulation. /// /// The array to copy into. /// The arrays length. public void GetPoints(Point3d[] points, int count) { ErrorUtil.CheckArray(points, count); Kernel.GetPoints(Ptr, points, count); } /// /// Get all the points in the triangulation. /// /// The array to copy into. public void GetPoints(List points) { int count = VertexCount; var array = new Point3d[count]; GetPoints(array, array.Length); points.AddRange(array); } /// /// Get the triangulation vertices. /// /// The vertex array. /// The vertex array length. public void GetVertices(TriVertex3[] vertices, int count) { ErrorUtil.CheckArray(vertices, count); Kernel.GetVertices(Ptr, vertices, count); } /// /// Get a triangulation vertex. /// /// The vertices index /// The vertex. /// public bool GetVertex(int index, out TriVertex3 vertex) { return Kernel.GetVertex(Ptr, index, out vertex); } /// /// Get the triangulation vertices. /// /// The vertex array. /// The vertex array length. public void GetCells(TriCell3[] cells, int count) { ErrorUtil.CheckArray(cells, count); Kernel.GetCells(Ptr, cells, count); } /// /// Get a triangulation vertex. /// /// The vertices index /// The vertex. /// public bool GetCell(int index, out TriCell3 cell) { return Kernel.GetCell(Ptr, index, out cell); } /// /// Get the indices of the cells edges in the triangulation. /// /// The indices array. /// The indices array length. public void GetSegmentIndices(int[] indices, int count) { ErrorUtil.CheckArray(indices, count); Kernel.GetSegmentIndices(Ptr, indices, count); } public void GetSegments(Segment3d[] segments, int count) { ErrorUtil.CheckArray(segments, count); Kernel.GetSegments(Ptr, segments, count); } /// /// Get the indices of the cells triangles in the triangulation. /// /// The indices array. /// The indices array length. public void GetTriangleIndices(int[] indices, int count) { ErrorUtil.CheckArray(indices, count); Kernel.GetTriangleIndices(Ptr, indices, count); } public void GetTriangles(Triangle3d[] triangles, int count) { ErrorUtil.CheckArray(triangles, count); Kernel.GetTriangles(Ptr, triangles, count); } /// /// Get the indices of the tetrahedron cells in the triangulation. /// /// The indices array. /// The indices array length. public void GetTetrahedronIndices(int[] indices, int count) { ErrorUtil.CheckArray(indices, count); Kernel.GetTetrahedraIndices(Ptr, indices, count); } public void GetTetrahedrons(Tetrahedron3d[] tetrahedrons, int count) { ErrorUtil.CheckArray(tetrahedrons, count); Kernel.GetTetrahedrons(Ptr, tetrahedrons, count); } /// /// Translate each point in the mesh. /// /// The amount to translate. public void Translate(Point3d translation) { var m = Matrix4x4d.Translate(translation); Kernel.Transform(Ptr, m); } /// /// Rotate each point in the mesh. /// /// The amount to rotate. public void Rotate(Quaternion3d rotation) { var m = rotation.ToMatrix4x4d(); Kernel.Transform(Ptr, m); } /// /// Scale each point in the mesh. /// /// The amount to scale. public void Scale(Point3d scale) { var m = Matrix4x4d.Scale(scale); Kernel.Transform(Ptr, m); } /// /// Transform each point in the mesh. /// /// The amount to translate. /// The amount to rotate. /// The amount to scale. public void Transform(Point3d translation, Quaternion3d rotation, Point3d scale) { var m = Matrix4x4d.TranslateRotateScale(translation, rotation, scale); Kernel.Transform(Ptr, m); } /// /// /// /// public override void Print(StringBuilder builder) { builder.AppendLine(ToString()); } /// /// Release any unmanaged resources. /// protected override void ReleasePtr() { Kernel.Release(Ptr); } } } ================================================ FILE: CGALDotNet/Triangulations/BaseTriangulationKernel2.cs ================================================ using System; using System.Collections.Generic; using System.Runtime.InteropServices; using System.Text; using CGALDotNetGeometry.Numerics; using CGALDotNetGeometry.Shapes; namespace CGALDotNet.Triangulations { internal abstract class BaseTriangulationKernel2 : CGALObjectKernel { internal abstract IntPtr Create(); internal abstract void Release(IntPtr ptr); internal abstract void Clear(IntPtr ptr); internal abstract IntPtr Copy(IntPtr ptr); internal abstract void SetIndices(IntPtr ptr); internal abstract int BuildStamp(IntPtr ptr); internal abstract bool IsValid(IntPtr ptr, int level); internal abstract int VertexCount(IntPtr ptr); internal abstract int FaceCount(IntPtr ptr); internal abstract void InsertPoint(IntPtr ptr, Point2d point); internal abstract void InsertPoints(IntPtr ptr, Point2d[] points, int count); internal abstract void InsertPolygon(IntPtr triPtr, IntPtr polyPtr); internal abstract void InsertPolygonWithHoles(IntPtr triPtr, IntPtr pwhPtr); internal abstract void GetPoints(IntPtr ptr, Point2d[] points, int count); internal abstract void GetIndices(IntPtr ptr, int[] indices, int count); internal abstract bool GetVertex(IntPtr ptr, int index, out TriVertex2 vertex); internal abstract void GetVertices(IntPtr ptr, TriVertex2[] vertices, int count); internal abstract bool GetFace(IntPtr ptr, int index, out TriFace2 face); internal abstract void GetFaces(IntPtr ptr, TriFace2[] faces, int count); internal abstract bool GetSegment(IntPtr ptr, int faceIndex, int neighbourIndex, out Segment2d segment); internal abstract bool GetTriangle(IntPtr ptr, int faceIndex, out Triangle2d triangle); internal abstract void GetTriangles(IntPtr ptr, Triangle2d[] triangles, int count); internal abstract bool GetCircumcenter(IntPtr ptr, int faceIndex, out Point2d circumcenter); internal abstract void GetCircumcenters(IntPtr ptr, Point2d[] circumcenters, int count); internal abstract int NeighbourIndex(IntPtr ptr, int faceIndex, int index); internal abstract bool LocateFace(IntPtr ptr, Point2d point, out TriFace2 face); internal abstract bool MoveVertex(IntPtr ptr, int index, Point2d point, bool ifNoCollision, out TriVertex2 vertex); internal abstract bool RemoveVertex(IntPtr ptr, int index); internal abstract bool FlipEdge(IntPtr ptr, int faceIndex, int neighbour); internal abstract void Transform(IntPtr ptr, Point2d translation, double rotation, double scale); } } ================================================ FILE: CGALDotNet/Triangulations/BaseTriangulationKernel3.cs ================================================ using System; using System.Collections.Generic; using System.Runtime.InteropServices; using System.Text; using CGALDotNetGeometry.Numerics; using CGALDotNetGeometry.Shapes; namespace CGALDotNet.Triangulations { internal abstract class BaseTriangulationKernel3 : CGALObjectKernel { internal abstract IntPtr Create(); internal abstract void Release(IntPtr ptr); internal abstract void Clear(IntPtr ptr); internal abstract IntPtr Copy(IntPtr ptr); internal abstract int BuildStamp(IntPtr ptr); internal abstract int Dimension(IntPtr ptr); internal abstract bool IsValid(IntPtr ptr, bool verbose); internal abstract int VertexCount(IntPtr ptr); internal abstract int FiniteVertexCount(IntPtr ptr); internal abstract int CellCount(IntPtr ptr); internal abstract int FiniteCellCount(IntPtr ptr); internal abstract int EdgeCount(IntPtr ptr); internal abstract int FiniteEdgeCount(IntPtr ptr); internal abstract int FacetCount(IntPtr ptr); internal abstract int FiniteFacetCount(IntPtr ptr); internal abstract void InsertPoint(IntPtr ptr, Point3d point); internal abstract void InsertPoints(IntPtr ptr, Point3d[] points, int count); internal abstract void InsertInCell(IntPtr ptr, int index, Point3d point); internal abstract int Locate(IntPtr ptr, Point3d point); internal abstract void GetCircumcenters(IntPtr ptr, Point3d[] Circumcenters, int count); internal abstract void GetPoints(IntPtr ptr, Point3d[] points, int count); internal abstract void GetVertices(IntPtr ptr, TriVertex3[] vertices, int count); internal abstract bool GetVertex(IntPtr ptr, int index, out TriVertex3 vertex); internal abstract void GetCells(IntPtr ptr, TriCell3[] cells, int count); internal abstract bool GetCell(IntPtr ptr, int index, out TriCell3 cell); internal abstract void GetSegmentIndices(IntPtr ptr, int[] indices, int count); internal abstract void GetTriangleIndices(IntPtr ptr, int[] indices, int count); internal abstract void GetTetrahedraIndices(IntPtr ptr, int[] indices, int count); internal abstract void GetSegments(IntPtr ptr, Segment3d[] indices, int count); internal abstract void GetTriangles(IntPtr ptr, Triangle3d[] indices, int count); internal abstract void GetTetrahedrons(IntPtr ptr, Tetrahedron3d[] indices, int count); internal abstract void Transform(IntPtr ptr, Matrix4x4d matrix); } } ================================================ FILE: CGALDotNet/Triangulations/ConstrainedDelaunayTriangulation2.cs ================================================ using System; using System.Collections.Generic; using System.Text; using CGALDotNetGeometry.Numerics; using CGALDotNetGeometry.Shapes; using CGALDotNet.Polygons; using CGALDotNet.Hulls; namespace CGALDotNet.Triangulations { /// /// The generic constrained triangulation class. /// /// The kernel public sealed class ConstrainedDelaunayTriangulation2 : ConstrainedDelaunayTriangulation2 where K : CGALKernel, new() { /// /// A static instance of the triangulation. /// public static readonly ConstrainedDelaunayTriangulation2 Instance = new ConstrainedDelaunayTriangulation2(); /// /// /// public ConstrainedDelaunayTriangulation2() : base(new K()) { } /// /// /// /// public ConstrainedDelaunayTriangulation2(Point2d[] points) : base(new K(), points) { } /// /// /// /// internal ConstrainedDelaunayTriangulation2(IntPtr ptr) : base(new K(), ptr) { } /// /// The triangulation as a string. /// /// public override string ToString() { return string.Format("[ConstrainedDelaunayTriangulation2<{0}>: VertexCount={1}, FaceCount={2}]", Kernel.Name, VertexCount, TriangleCount); } /// /// A deep copy of the triangulation. /// /// The deep copy. public ConstrainedDelaunayTriangulation2 Copy() { return new ConstrainedDelaunayTriangulation2(Kernel.Copy(Ptr)); } /// /// Compute the convex of the triagulation. /// /// The convex hull polygon. /// public Polygon2 ComputeHull() { int count = VertexCount; if (count < 3) throw new InvalidOperationException("Trianglution must have at lest 3 points to compute the hull."); var points = ArrayCache.Point2dArray(count); GetPoints(points, count); var hull = ConvexHull2.Instance; return hull.CreateHull(points, count); } } /// /// The abstract triangulation class. /// public abstract class ConstrainedDelaunayTriangulation2 : BaseTriangulation2 { /// /// /// /// internal ConstrainedDelaunayTriangulation2(CGALKernel kernel) : base(kernel.ConstrainedDelaunayTriangulationKernel2) { TriangulationKernel = Kernel as ConstrainedDelaunayTriangulationKernel2; } /// /// /// /// /// internal ConstrainedDelaunayTriangulation2(CGALKernel kernel, Point2d[] points) : base(kernel.ConstrainedDelaunayTriangulationKernel2, points) { TriangulationKernel = Kernel as ConstrainedDelaunayTriangulationKernel2; } /// /// /// /// /// internal ConstrainedDelaunayTriangulation2(CGALKernel kernel, IntPtr ptr) : base(kernel.ConstrainedDelaunayTriangulationKernel2, ptr) { TriangulationKernel = Kernel as ConstrainedDelaunayTriangulationKernel2; } /// /// The kernel with the functions unique to the constrained triangulation. /// protected private ConstrainedDelaunayTriangulationKernel2 TriangulationKernel { get; private set; } /// /// The number of constrainted edges in the triangulation. /// public int ConstrainedEdgeCount => TriangulationKernel.ConstrainedEdgesCount(Ptr); /// /// Move the vertex. /// /// /// /// The moved vertex /// True if the vertex was found. public bool MoveVertex(int index, Point2d point, out TriVertex2 vertex) { return TriangulationKernel.MoveVertex(Ptr, index, point, true, out vertex); } /// /// Insert the polygons points into the triangulation. /// May not retain the poylgons edges. /// /// public void Insert(Polygon2 polygon) { TriangulationKernel.InsertPolygon(Ptr, polygon.Ptr); } /// /// Insert the polygons points into the triangulation. /// May not retain the poylgons edges. /// /// public void Insert(PolygonWithHoles2 pwh) { TriangulationKernel.InsertPolygonWithHoles(Ptr, pwh.Ptr); } /// /// Insert the polygons points and the edges as constraints into the triangulation. /// Will retatin the poylgons edges. /// /// The polygon to insert. public void InsertConstraint(Polygon2 polygon) { TriangulationKernel.InsertPolygonConstraint(Ptr, polygon.Ptr); } /// /// Insert the polygons points and the edges as constraints into the triangulation. /// Will retatin the poylgons edges. /// /// The polygon to insert. public void InsertConstraint(PolygonWithHoles2 pwh) { TriangulationKernel.InsertPolygonWithHolesConstraint(Ptr, pwh.Ptr); } /// /// Get the number of constrainted edges incident to this vertex. /// /// The vertex index in the triagulation. /// The number of constrainted edges to the vertex. public int IncidentConstraintCount(int vertIndex) { return TriangulationKernel.IncidentConstraintCount(Ptr, vertIndex); } /// /// Does this vertex have a constrainted edge. /// /// The vertex index in the triagulation. /// Does this vertex have a constrainted edge. public bool HasIncidentConstraint(int vertIndex) { return TriangulationKernel.HasIncidentConstraints(Ptr, vertIndex); } /// /// Add a segment as a constraint. /// /// The segment to add. public void InsertConstraint(Segment2d segment) { InsertConstraint(segment.A, segment.B); } /// /// Add the two points as a segment constraint. /// /// The segments point a. /// The segments point b. public void InsertConstraint(Point2d a, Point2d b) { TriangulationKernel.InsertSegmentConstraintFromPoints(Ptr, a, b); } /// /// Add a list of segments as constraint to the triangulation. /// /// The segment array. /// The length of the segment array. public void InsertConstraints(Segment2d[] segments, int count) { ErrorUtil.CheckArray(segments, count); TriangulationKernel.InsertSegmentConstraints(Ptr, segments, count); } /// /// Get a array of all the constraint edges in the triangulation. /// /// The edge array. /// The ararys length. public void GetConstraints(TriEdge2[] constraints, int count) { ErrorUtil.CheckArray(constraints, count); TriangulationKernel.GetConstraints(Ptr, constraints, count); } /// /// Get a array of all the constraint segments in the triangulation. /// /// The segment array. /// The ararys length. public void GetConstraints(Segment2d[] constraints, int count) { ErrorUtil.CheckArray(constraints, count); TriangulationKernel.GetConstraints(Ptr, constraints, count); } /// /// Get the constraints incident to the vertex. /// /// The vertex index in the triangulation. /// The array of edges. /// The ararys length. public void GetIncidentConstraints(int vertexIndex, TriEdge2[] constraints, int count) { ErrorUtil.CheckArray(constraints, count); TriangulationKernel.GetIncidentConstraints(Ptr, vertexIndex, constraints, count); } /// /// Remove a constraint between a face and its neighbour. /// /// The faces index in the triangultion. /// The neighbours index in the faces neighbour array between 0-2. public void RemoveConstraint(int faceIndex, int neighbourIndex) { if (neighbourIndex < 0 || neighbourIndex > 2) return; TriangulationKernel.RemoveConstraint(Ptr, faceIndex, neighbourIndex); } /// /// Remove all constraints incident to a vertex. /// /// The vertex index in the triangulation. public void RemoveIncidentConstraints(int vertexIndex) { TriangulationKernel.RemoveIncidentConstraints(Ptr, vertexIndex); } /// /// Get the triangle indices for domain in the triangultion. /// Used to triangulate polygons. /// /// The indices. internal void GetConstrainedDomainIndices(List indices) { int count = IndiceCount; if (count == 0) return; int[] tmp = new int[count]; count = TriangulationKernel.MarkDomains(Ptr, tmp, tmp.Length); for (int i = 0; i < count; i++) indices.Add(tmp[i]); ; } /// /// /// /// public override void Print(StringBuilder builder) { builder.AppendLine(ToString()); builder.AppendLine("IsValid = " + IsValid()); builder.AppendLine("BuildStamp = " + BuildStamp); builder.AppendLine("VertexCount = " + VertexCount); builder.AppendLine("TriangleCount = " + TriangleCount); builder.AppendLine("IndiceCount = " + IndiceCount); builder.AppendLine("Constrained edges = " + ConstrainedEdgeCount); } } } ================================================ FILE: CGALDotNet/Triangulations/ConstrainedDelaunayTriangulationKernel2.cs ================================================ using System; using System.Collections.Generic; using System.Text; using CGALDotNetGeometry.Numerics; using CGALDotNetGeometry.Shapes; namespace CGALDotNet.Triangulations { internal abstract class ConstrainedDelaunayTriangulationKernel2 : BaseTriangulationKernel2 { internal abstract int ConstrainedEdgesCount(IntPtr ptr); internal abstract bool HasIncidentConstraints(IntPtr ptr, int index); internal abstract int IncidentConstraintCount(IntPtr ptr, int index); internal abstract void InsertSegmentConstraintFromPoints(IntPtr ptr, Point2d a, Point2d b); internal abstract void InsertSegmentConstraintFromVertices(IntPtr ptr, int vertIndex1, int vertIndex2); internal abstract void InsertSegmentConstraints(IntPtr ptr, Segment2d[] segments, int count); internal abstract void InsertPolygonConstraint(IntPtr triPtr, IntPtr polyPtr); internal abstract void InsertPolygonWithHolesConstraint(IntPtr triPtr, IntPtr pwhPtr); internal abstract void GetConstraints(IntPtr ptr, TriEdge2[] constraints, int count); internal abstract void GetConstraints(IntPtr ptr, Segment2d[] constraints, int count); internal abstract void GetIncidentConstraints(IntPtr ptr, int vertexIndex, TriEdge2[] constraints, int count); internal abstract void RemoveConstraint(IntPtr ptr, int faceIndex, int neighbourIndex); internal abstract void RemoveIncidentConstraints(IntPtr ptr, int vertexIndex); internal abstract int MarkDomains(IntPtr ptr, int[] indices, int count); } } ================================================ FILE: CGALDotNet/Triangulations/ConstrainedDelaunayTriangulationKernel2_EEK.cs ================================================ using System; using System.Collections.Generic; using System.Text; using System.Runtime.InteropServices; using CGALDotNetGeometry.Numerics; using CGALDotNetGeometry.Shapes; namespace CGALDotNet.Triangulations { internal class ConstrainedDelaunayTriangulationKernel2_EEK : ConstrainedDelaunayTriangulationKernel2 { internal override string Name => "EEK"; internal static readonly ConstrainedDelaunayTriangulationKernel2 Instance = new ConstrainedDelaunayTriangulationKernel2_EEK(); internal override IntPtr Create() { return ConstrainedDelaunayTriangulation2_EEK_Create(); } internal override void Release(IntPtr ptr) { ConstrainedDelaunayTriangulation2_EEK_Release(ptr); } internal override void Clear(IntPtr ptr) { ConstrainedDelaunayTriangulation2_EEK_Clear(ptr); } internal override IntPtr Copy(IntPtr ptr) { return ConstrainedDelaunayTriangulation2_EEK_Copy(ptr); } internal override void SetIndices(IntPtr ptr) { ConstrainedDelaunayTriangulation2_EEK_SetIndices(ptr); } internal override int BuildStamp(IntPtr ptr) { return ConstrainedDelaunayTriangulation2_EEK_BuildStamp(ptr); } internal override bool IsValid(IntPtr ptr, int level) { return ConstrainedDelaunayTriangulation2_EEK_IsValid(ptr, level); } internal override int VertexCount(IntPtr ptr) { return ConstrainedDelaunayTriangulation2_EEK_VertexCount(ptr); } internal override int FaceCount(IntPtr ptr) { return ConstrainedDelaunayTriangulation2_EEK_FaceCount(ptr); } internal override void InsertPoint(IntPtr ptr, Point2d point) { ConstrainedDelaunayTriangulation2_EEK_InsertPoint(ptr, point); } internal override void InsertPoints(IntPtr ptr, Point2d[] points, int count) { ConstrainedDelaunayTriangulation2_EEK_InsertPoints(ptr, points, count); } internal override void InsertPolygon(IntPtr triPtr, IntPtr polyPtr) { ConstrainedDelaunayTriangulation2_EEK_InsertPolygon(triPtr, polyPtr); } internal override void InsertPolygonWithHoles(IntPtr triPtr, IntPtr pwhPtr) { ConstrainedDelaunayTriangulation2_EEK_InsertPolygonWithHoles(triPtr, pwhPtr); } internal override void GetPoints(IntPtr ptr, Point2d[] points, int count) { ConstrainedDelaunayTriangulation2_EEK_GetPoints(ptr, points, count); } internal override void GetIndices(IntPtr ptr, int[] indices, int count) { ConstrainedDelaunayTriangulation2_EEK_GetIndices(ptr, indices, count); } internal override bool GetVertex(IntPtr ptr, int index, out TriVertex2 vertex) { return ConstrainedDelaunayTriangulation2_EEK_GetVertex(ptr, index, out vertex); } internal override void GetVertices(IntPtr ptr, TriVertex2[] vertices, int count) { ConstrainedDelaunayTriangulation2_EEK_GetVertices(ptr, vertices, count); } internal override bool GetFace(IntPtr ptr, int index, out TriFace2 face) { return ConstrainedDelaunayTriangulation2_EEK_GetFace(ptr, index, out face); } internal override void GetFaces(IntPtr ptr, TriFace2[] faces, int count) { ConstrainedDelaunayTriangulation2_EEK_GetFaces(ptr, faces, count); } internal override bool GetSegment(IntPtr ptr, int faceIndex, int neighbourIndex, out Segment2d segment) { return ConstrainedDelaunayTriangulation2_EEK_GetSegment(ptr, faceIndex, neighbourIndex, out segment); } internal override bool GetTriangle(IntPtr ptr, int faceIndex, out Triangle2d triangle) { return ConstrainedDelaunayTriangulation2_EEK_GetTriangle(ptr, faceIndex, out triangle); } internal override void GetTriangles(IntPtr ptr, Triangle2d[] triangles, int count) { ConstrainedDelaunayTriangulation2_EEK_GetTriangles(ptr, triangles, count); } internal override bool GetCircumcenter(IntPtr ptr, int faceIndex, out Point2d circumcenter) { return ConstrainedDelaunayTriangulation2_EEK_GetCircumcenter(ptr, faceIndex, out circumcenter); } internal override void GetCircumcenters(IntPtr ptr, [Out] Point2d[] circumcenters, int count) { ConstrainedDelaunayTriangulation2_EEK_GetCircumcenters(ptr, circumcenters, count); } internal override int NeighbourIndex(IntPtr ptr, int faceIndex, int index) { return ConstrainedDelaunayTriangulation2_EEK_NeighbourIndex(ptr, faceIndex, index); } internal override bool LocateFace(IntPtr ptr, Point2d point, out TriFace2 face) { return ConstrainedDelaunayTriangulation2_EEK_LocateFace(ptr, point, out face); } internal override bool MoveVertex(IntPtr ptr, int index, Point2d point, bool ifNoCollision, out TriVertex2 vertex) { return ConstrainedDelaunayTriangulation2_EEK_MoveVertex(ptr, index, point, ifNoCollision, out vertex); } internal override bool RemoveVertex(IntPtr ptr, int index) { return ConstrainedDelaunayTriangulation2_EEK_RemoveVertex(ptr, index); } internal override bool FlipEdge(IntPtr ptr, int faceIndex, int neighbour) { return ConstrainedDelaunayTriangulation2_EEK_FlipEdge(ptr, faceIndex, neighbour); } //Constrained only. internal override int ConstrainedEdgesCount(IntPtr ptr) { return ConstrainedDelaunayTriangulation2_EEK_ConstrainedEdgesCount(ptr); } internal override bool HasIncidentConstraints(IntPtr ptr, int index) { return ConstrainedDelaunayTriangulation2_EEK_HasIncidentConstraints(ptr, index); } internal override int IncidentConstraintCount(IntPtr ptr, int index) { return ConstrainedDelaunayTriangulation2_EEK_IncidentConstraintCount(ptr, index); } internal override void InsertSegmentConstraintFromPoints(IntPtr ptr, Point2d a, Point2d b) { ConstrainedDelaunayTriangulation2_EEK_InsertSegmentConstraintFromPoints(ptr, a, b); } internal override void InsertSegmentConstraintFromVertices(IntPtr ptr, int vertIndex1, int vertIndex2) { ConstrainedDelaunayTriangulation2_EEK_InsertSegmentConstraintFromVertices(ptr, vertIndex1, vertIndex2); } internal override void InsertSegmentConstraints(IntPtr ptr, Segment2d[] segments, int count) { ConstrainedDelaunayTriangulation2_EEK_InsertSegmentConstraints(ptr, segments, count); } internal override void InsertPolygonConstraint(IntPtr triPtr, IntPtr polyPtr) { ConstrainedDelaunayTriangulation2_EEK_InsertPolygonConstraint(triPtr, polyPtr); } internal override void InsertPolygonWithHolesConstraint(IntPtr triPtr, IntPtr pwhPtr) { ConstrainedDelaunayTriangulation2_EEK_InsertPolygonWithHolesConstraint(triPtr, pwhPtr); } internal override void GetConstraints(IntPtr ptr, TriEdge2[] constraints, int count) { ConstrainedDelaunayTriangulation2_EEK_GetEdgeConstraints(ptr, constraints, count); } internal override void GetConstraints(IntPtr ptr, Segment2d[] constraints, int count) { ConstrainedDelaunayTriangulation2_EEK_GetSegmentConstraints(ptr, constraints, count); } internal override void GetIncidentConstraints(IntPtr ptr, int vertexIndex, TriEdge2[] constraints, int count) { ConstrainedDelaunayTriangulation2_EEK_GetIncidentConstraints(ptr, vertexIndex, constraints, count); } internal override void RemoveConstraint(IntPtr ptr, int faceIndex, int neighbourIndex) { ConstrainedDelaunayTriangulation2_EEK_RemoveConstraint(ptr, faceIndex, neighbourIndex); } internal override void RemoveIncidentConstraints(IntPtr ptr, int vertexIndex) { ConstrainedDelaunayTriangulation2_EEK_RemoveIncidentConstraints(ptr, vertexIndex); } internal override int MarkDomains(IntPtr ptr, int[] indices, int count) { return ConstrainedDelaunayTriangulation2_EEK_MarkDomains(ptr, indices, count); } internal override void Transform(IntPtr ptr, Point2d translation, double rotation, double scale) { ConstrainedDelaunayTriangulation2_EEK_Transform(ptr, translation, rotation, scale); } [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr ConstrainedDelaunayTriangulation2_EEK_Create(); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void ConstrainedDelaunayTriangulation2_EEK_Release(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void ConstrainedDelaunayTriangulation2_EEK_Clear(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr ConstrainedDelaunayTriangulation2_EEK_Copy(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void ConstrainedDelaunayTriangulation2_EEK_SetIndices(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int ConstrainedDelaunayTriangulation2_EEK_BuildStamp(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool ConstrainedDelaunayTriangulation2_EEK_IsValid(IntPtr ptr, int level); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int ConstrainedDelaunayTriangulation2_EEK_VertexCount(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int ConstrainedDelaunayTriangulation2_EEK_FaceCount(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void ConstrainedDelaunayTriangulation2_EEK_InsertPoint(IntPtr ptr, Point2d point); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void ConstrainedDelaunayTriangulation2_EEK_InsertPoints(IntPtr ptr, [In] Point2d[] points, int count); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void ConstrainedDelaunayTriangulation2_EEK_InsertPolygon(IntPtr triPtr, IntPtr polyPtr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void ConstrainedDelaunayTriangulation2_EEK_InsertPolygonWithHoles(IntPtr triPtr, IntPtr pwhPtr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void ConstrainedDelaunayTriangulation2_EEK_GetPoints(IntPtr ptr, [Out] Point2d[] points, int count); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void ConstrainedDelaunayTriangulation2_EEK_GetIndices(IntPtr ptr, [Out] int[] indices, int count); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool ConstrainedDelaunayTriangulation2_EEK_GetVertex(IntPtr ptr, int index, [Out] out TriVertex2 vertex); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void ConstrainedDelaunayTriangulation2_EEK_GetVertices(IntPtr ptr, [Out] TriVertex2[] vertices, int count); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool ConstrainedDelaunayTriangulation2_EEK_GetFace(IntPtr ptr, int index, [Out] out TriFace2 triFace); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void ConstrainedDelaunayTriangulation2_EEK_GetFaces(IntPtr ptr, [Out] TriFace2[] faces, int count); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool ConstrainedDelaunayTriangulation2_EEK_GetSegment(IntPtr ptr, int faceIndex, int neighbourIndex, [Out] out Segment2d segment); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool ConstrainedDelaunayTriangulation2_EEK_GetTriangle(IntPtr ptr, int faceIndex, [Out] out Triangle2d triangle); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void ConstrainedDelaunayTriangulation2_EEK_GetTriangles(IntPtr ptr, [Out] Triangle2d[] triangles, int count); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool ConstrainedDelaunayTriangulation2_EEK_GetCircumcenter(IntPtr ptr, int faceIndex, [Out] out Point2d circumcenter); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void ConstrainedDelaunayTriangulation2_EEK_GetCircumcenters(IntPtr ptr, [Out] Point2d[] circumcenters, int count); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int ConstrainedDelaunayTriangulation2_EEK_NeighbourIndex(IntPtr ptr, int faceIndex, int index); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool ConstrainedDelaunayTriangulation2_EEK_LocateFace(IntPtr ptr, Point2d point, [Out] out TriFace2 face); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool ConstrainedDelaunayTriangulation2_EEK_MoveVertex(IntPtr ptr, int index, Point2d point, bool ifNoCollision, [Out] out TriVertex2 vertex); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool ConstrainedDelaunayTriangulation2_EEK_RemoveVertex(IntPtr ptr, int index); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool ConstrainedDelaunayTriangulation2_EEK_FlipEdge(IntPtr ptr, int faceIndex, int neighbour); //Constrained only. [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int ConstrainedDelaunayTriangulation2_EEK_ConstrainedEdgesCount(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool ConstrainedDelaunayTriangulation2_EEK_HasIncidentConstraints(IntPtr ptr, int index); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int ConstrainedDelaunayTriangulation2_EEK_IncidentConstraintCount(IntPtr ptr, int index); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void ConstrainedDelaunayTriangulation2_EEK_InsertSegmentConstraintFromPoints(IntPtr ptr, Point2d a, Point2d b); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void ConstrainedDelaunayTriangulation2_EEK_InsertSegmentConstraintFromVertices(IntPtr ptr, int vertIndex1, int vertIndex2); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void ConstrainedDelaunayTriangulation2_EEK_InsertSegmentConstraints(IntPtr ptr, [In] Segment2d[] segments, int count); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void ConstrainedDelaunayTriangulation2_EEK_InsertPolygonConstraint(IntPtr triPtr, IntPtr polyPtr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void ConstrainedDelaunayTriangulation2_EEK_InsertPolygonWithHolesConstraint(IntPtr triPtr, IntPtr pwhPtr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void ConstrainedDelaunayTriangulation2_EEK_GetEdgeConstraints(IntPtr ptr, [Out] TriEdge2[] constraints, int count); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void ConstrainedDelaunayTriangulation2_EEK_GetSegmentConstraints(IntPtr ptr, [Out] Segment2d[] constraints, int count); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void ConstrainedDelaunayTriangulation2_EEK_GetIncidentConstraints(IntPtr ptr, int vertexIndex, [Out] TriEdge2[] constraints, int count); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void ConstrainedDelaunayTriangulation2_EEK_RemoveConstraint(IntPtr ptr, int faceIndex, int neighbourIndex); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void ConstrainedDelaunayTriangulation2_EEK_RemoveIncidentConstraints(IntPtr ptr, int vertexIndex); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int ConstrainedDelaunayTriangulation2_EEK_GetPolygonIndices(IntPtr ptrTri, IntPtr polyPtr, [Out] int[] indices, int count, ORIENTATION orientation); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int ConstrainedDelaunayTriangulation2_EEK_GetPolygonWithHolesIndices(IntPtr ptrTri, IntPtr pwhPtr, [Out] int[] indices, int count, ORIENTATION orientation); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int ConstrainedDelaunayTriangulation2_EEK_MarkDomains(IntPtr ptr, [Out] int[] indices, int count); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void ConstrainedDelaunayTriangulation2_EEK_Transform(IntPtr ptr, Point2d translation, double rotation, double scale); } } ================================================ FILE: CGALDotNet/Triangulations/ConstrainedDelaunayTriangulationKernel2_EIK.cs ================================================ using System; using System.Collections.Generic; using System.Text; using System.Runtime.InteropServices; using CGALDotNetGeometry.Numerics; using CGALDotNetGeometry.Shapes; namespace CGALDotNet.Triangulations { internal class ConstrainedDelaunayTriangulationKernel2_EIK : ConstrainedDelaunayTriangulationKernel2 { internal override string Name => "EIK"; internal static readonly ConstrainedDelaunayTriangulationKernel2 Instance = new ConstrainedDelaunayTriangulationKernel2_EIK(); internal override IntPtr Create() { return ConstrainedDelaunayTriangulation2_EIK_Create(); } internal override void Release(IntPtr ptr) { ConstrainedDelaunayTriangulation2_EIK_Release(ptr); } internal override void Clear(IntPtr ptr) { ConstrainedDelaunayTriangulation2_EIK_Clear(ptr); } internal override IntPtr Copy(IntPtr ptr) { return ConstrainedDelaunayTriangulation2_EIK_Copy(ptr); } internal override void SetIndices(IntPtr ptr) { ConstrainedDelaunayTriangulation2_EIK_SetIndices(ptr); } internal override int BuildStamp(IntPtr ptr) { return ConstrainedDelaunayTriangulation2_EIK_BuildStamp(ptr); } internal override bool IsValid(IntPtr ptr, int level) { return ConstrainedDelaunayTriangulation2_EIK_IsValid(ptr, level); } internal override int VertexCount(IntPtr ptr) { return ConstrainedDelaunayTriangulation2_EIK_VertexCount(ptr); } internal override int FaceCount(IntPtr ptr) { return ConstrainedDelaunayTriangulation2_EIK_FaceCount(ptr); } internal override void InsertPoint(IntPtr ptr, Point2d point) { ConstrainedDelaunayTriangulation2_EIK_InsertPoint(ptr, point); } internal override void InsertPoints(IntPtr ptr, Point2d[] points, int count) { ConstrainedDelaunayTriangulation2_EIK_InsertPoints(ptr, points, count); } internal override void InsertPolygon(IntPtr triPtr, IntPtr polyPtr) { ConstrainedDelaunayTriangulation2_EIK_InsertPolygon(triPtr, polyPtr); } internal override void InsertPolygonWithHoles(IntPtr triPtr, IntPtr pwhPtr) { ConstrainedDelaunayTriangulation2_EIK_InsertPolygonWithHoles(triPtr, pwhPtr); } internal override void GetPoints(IntPtr ptr, Point2d[] points, int count) { ConstrainedDelaunayTriangulation2_EIK_GetPoints(ptr, points, count); } internal override void GetIndices(IntPtr ptr, int[] indices, int count) { ConstrainedDelaunayTriangulation2_EIK_GetIndices(ptr, indices, count); } internal override bool GetVertex(IntPtr ptr, int index, out TriVertex2 vertex) { return ConstrainedDelaunayTriangulation2_EIK_GetVertex(ptr, index, out vertex); } internal override void GetVertices(IntPtr ptr, TriVertex2[] vertices, int count) { ConstrainedDelaunayTriangulation2_EIK_GetVertices(ptr, vertices, count); } internal override bool GetFace(IntPtr ptr, int index, out TriFace2 face) { return ConstrainedDelaunayTriangulation2_EIK_GetFace(ptr, index, out face); } internal override void GetFaces(IntPtr ptr, TriFace2[] faces, int count) { ConstrainedDelaunayTriangulation2_EIK_GetFaces(ptr, faces, count); } internal override bool GetSegment(IntPtr ptr, int faceIndex, int neighbourIndex, out Segment2d segment) { return ConstrainedDelaunayTriangulation2_EIK_GetSegment(ptr, faceIndex, neighbourIndex, out segment); } internal override bool GetTriangle(IntPtr ptr, int faceIndex, out Triangle2d triangle) { return ConstrainedDelaunayTriangulation2_EIK_GetTriangle(ptr, faceIndex, out triangle); } internal override void GetTriangles(IntPtr ptr, Triangle2d[] triangles, int count) { ConstrainedDelaunayTriangulation2_EIK_GetTriangles(ptr, triangles, count); } internal override bool GetCircumcenter(IntPtr ptr, int faceIndex, out Point2d circumcenter) { return ConstrainedDelaunayTriangulation2_EIK_GetCircumcenter(ptr, faceIndex, out circumcenter); } internal override void GetCircumcenters(IntPtr ptr, [Out] Point2d[] circumcenters, int count) { ConstrainedDelaunayTriangulation2_EIK_GetCircumcenters(ptr, circumcenters, count); } internal override int NeighbourIndex(IntPtr ptr, int faceIndex, int index) { return ConstrainedDelaunayTriangulation2_EIK_NeighbourIndex(ptr, faceIndex, index); } internal override bool LocateFace(IntPtr ptr, Point2d point, out TriFace2 face) { return ConstrainedDelaunayTriangulation2_EIK_LocateFace(ptr, point, out face); } internal override bool MoveVertex(IntPtr ptr, int index, Point2d point, bool ifNoCollision, out TriVertex2 vertex) { return ConstrainedDelaunayTriangulation2_EIK_MoveVertex(ptr, index, point, ifNoCollision, out vertex); } internal override bool RemoveVertex(IntPtr ptr, int index) { return ConstrainedDelaunayTriangulation2_EIK_RemoveVertex(ptr, index); } internal override bool FlipEdge(IntPtr ptr, int faceIndex, int neighbour) { return ConstrainedDelaunayTriangulation2_EIK_FlipEdge(ptr, faceIndex, neighbour); } //Constrained only. internal override int ConstrainedEdgesCount(IntPtr ptr) { return ConstrainedDelaunayTriangulation2_EIK_ConstrainedEdgesCount(ptr); } internal override bool HasIncidentConstraints(IntPtr ptr, int index) { return ConstrainedDelaunayTriangulation2_EIK_HasIncidentConstraints(ptr, index); } internal override int IncidentConstraintCount(IntPtr ptr, int index) { return ConstrainedDelaunayTriangulation2_EIK_IncidentConstraintCount(ptr, index); } internal override void InsertSegmentConstraintFromPoints(IntPtr ptr, Point2d a, Point2d b) { ConstrainedDelaunayTriangulation2_EIK_InsertSegmentConstraintFromPoints(ptr, a, b); } internal override void InsertSegmentConstraintFromVertices(IntPtr ptr, int vertIndex1, int vertIndex2) { ConstrainedDelaunayTriangulation2_EIK_InsertSegmentConstraintFromVertices(ptr, vertIndex1, vertIndex2); } internal override void InsertSegmentConstraints(IntPtr ptr, Segment2d[] segments, int count) { ConstrainedDelaunayTriangulation2_EIK_InsertSegmentConstraints(ptr, segments, count); } internal override void InsertPolygonConstraint(IntPtr triPtr, IntPtr polyPtr) { ConstrainedDelaunayTriangulation2_EIK_InsertPolygonConstraint(triPtr, polyPtr); } internal override void InsertPolygonWithHolesConstraint(IntPtr triPtr, IntPtr pwhPtr) { ConstrainedDelaunayTriangulation2_EIK_InsertPolygonWithHolesConstraint(triPtr, pwhPtr); } internal override void GetConstraints(IntPtr ptr, TriEdge2[] constraints, int count) { ConstrainedDelaunayTriangulation2_EIK_GetEdgeConstraints(ptr, constraints, count); } internal override void GetConstraints(IntPtr ptr, Segment2d[] constraints, int count) { ConstrainedDelaunayTriangulation2_EIK_GetSegmentConstraints(ptr, constraints, count); } internal override void GetIncidentConstraints(IntPtr ptr, int vertexIndex, TriEdge2[] constraints, int count) { ConstrainedDelaunayTriangulation2_EIK_GetIncidentConstraints(ptr, vertexIndex, constraints, count); } internal override void RemoveConstraint(IntPtr ptr, int faceIndex, int neighbourIndex) { ConstrainedDelaunayTriangulation2_EIK_RemoveConstraint(ptr, faceIndex, neighbourIndex); } internal override void RemoveIncidentConstraints(IntPtr ptr, int vertexIndex) { ConstrainedDelaunayTriangulation2_EIK_RemoveIncidentConstraints(ptr, vertexIndex); } internal override int MarkDomains(IntPtr ptr, int[] indices, int count) { return ConstrainedDelaunayTriangulation2_EIK_MarkDomains(ptr, indices, count); } internal override void Transform(IntPtr ptr, Point2d translation, double rotation, double scale) { ConstrainedDelaunayTriangulation2_EIK_Transform(ptr, translation, rotation, scale); } [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr ConstrainedDelaunayTriangulation2_EIK_Create(); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void ConstrainedDelaunayTriangulation2_EIK_Release(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void ConstrainedDelaunayTriangulation2_EIK_Clear(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr ConstrainedDelaunayTriangulation2_EIK_Copy(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void ConstrainedDelaunayTriangulation2_EIK_SetIndices(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int ConstrainedDelaunayTriangulation2_EIK_BuildStamp(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool ConstrainedDelaunayTriangulation2_EIK_IsValid(IntPtr ptr, int level); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int ConstrainedDelaunayTriangulation2_EIK_VertexCount(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int ConstrainedDelaunayTriangulation2_EIK_FaceCount(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void ConstrainedDelaunayTriangulation2_EIK_InsertPoint(IntPtr ptr, Point2d point); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void ConstrainedDelaunayTriangulation2_EIK_InsertPoints(IntPtr ptr, [In] Point2d[] points, int count); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void ConstrainedDelaunayTriangulation2_EIK_InsertPolygon(IntPtr triPtr, IntPtr polyPtr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void ConstrainedDelaunayTriangulation2_EIK_InsertPolygonWithHoles(IntPtr triPtr, IntPtr pwhPtr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void ConstrainedDelaunayTriangulation2_EIK_GetPoints(IntPtr ptr, [Out] Point2d[] points, int count); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void ConstrainedDelaunayTriangulation2_EIK_GetIndices(IntPtr ptr, [Out] int[] indices, int count); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool ConstrainedDelaunayTriangulation2_EIK_GetVertex(IntPtr ptr, int index, [Out] out TriVertex2 vertex); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void ConstrainedDelaunayTriangulation2_EIK_GetVertices(IntPtr ptr, [Out] TriVertex2[] vertices, int count); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool ConstrainedDelaunayTriangulation2_EIK_GetFace(IntPtr ptr, int index, [Out] out TriFace2 triFace); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void ConstrainedDelaunayTriangulation2_EIK_GetFaces(IntPtr ptr, [Out] TriFace2[] faces, int count); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool ConstrainedDelaunayTriangulation2_EIK_GetSegment(IntPtr ptr, int faceIndex, int neighbourIndex, [Out] out Segment2d segment); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool ConstrainedDelaunayTriangulation2_EIK_GetTriangle(IntPtr ptr, int faceIndex, [Out] out Triangle2d triangle); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void ConstrainedDelaunayTriangulation2_EIK_GetTriangles(IntPtr ptr, [Out] Triangle2d[] triangles, int count); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool ConstrainedDelaunayTriangulation2_EIK_GetCircumcenter(IntPtr ptr, int faceIndex, [Out] out Point2d circumcenter); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void ConstrainedDelaunayTriangulation2_EIK_GetCircumcenters(IntPtr ptr, [Out] Point2d[] circumcenters, int count); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int ConstrainedDelaunayTriangulation2_EIK_NeighbourIndex(IntPtr ptr, int faceIndex, int index); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool ConstrainedDelaunayTriangulation2_EIK_LocateFace(IntPtr ptr, Point2d point, [Out] out TriFace2 face); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool ConstrainedDelaunayTriangulation2_EIK_MoveVertex(IntPtr ptr, int index, Point2d point, bool ifNoCollision, [Out] out TriVertex2 vertex); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool ConstrainedDelaunayTriangulation2_EIK_RemoveVertex(IntPtr ptr, int index); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool ConstrainedDelaunayTriangulation2_EIK_FlipEdge(IntPtr ptr, int faceIndex, int neighbour); //Constrained only. [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int ConstrainedDelaunayTriangulation2_EIK_ConstrainedEdgesCount(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool ConstrainedDelaunayTriangulation2_EIK_HasIncidentConstraints(IntPtr ptr, int index); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int ConstrainedDelaunayTriangulation2_EIK_IncidentConstraintCount(IntPtr ptr, int index); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void ConstrainedDelaunayTriangulation2_EIK_InsertSegmentConstraintFromPoints(IntPtr ptr, Point2d a, Point2d b); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void ConstrainedDelaunayTriangulation2_EIK_InsertSegmentConstraintFromVertices(IntPtr ptr, int vertIndex1, int vertIndex2); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void ConstrainedDelaunayTriangulation2_EIK_InsertSegmentConstraints(IntPtr ptr, [In] Segment2d[] segments, int count); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void ConstrainedDelaunayTriangulation2_EIK_InsertPolygonConstraint(IntPtr triPtr, IntPtr polyPtr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void ConstrainedDelaunayTriangulation2_EIK_InsertPolygonWithHolesConstraint(IntPtr triPtr, IntPtr pwhPtr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void ConstrainedDelaunayTriangulation2_EIK_GetEdgeConstraints(IntPtr ptr, [Out] TriEdge2[] constraints, int count); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void ConstrainedDelaunayTriangulation2_EIK_GetSegmentConstraints(IntPtr ptr, [Out] Segment2d[] constraints, int count); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void ConstrainedDelaunayTriangulation2_EIK_GetIncidentConstraints(IntPtr ptr, int vertexIndex, [Out] TriEdge2[] constraints, int count); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void ConstrainedDelaunayTriangulation2_EIK_RemoveConstraint(IntPtr ptr, int faceIndex, int neighbourIndex); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void ConstrainedDelaunayTriangulation2_EIK_RemoveIncidentConstraints(IntPtr ptr, int vertexIndex); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int ConstrainedDelaunayTriangulation2_EIK_GetPolygonIndices(IntPtr ptrTri, IntPtr polyPtr, [Out] int[] indices, int count, ORIENTATION orientation); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int ConstrainedDelaunayTriangulation2_EIK_GetPolygonWithHolesIndices(IntPtr ptrTri, IntPtr pwhPtr, [Out] int[] indices, int count, ORIENTATION orientation); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int ConstrainedDelaunayTriangulation2_EIK_MarkDomains(IntPtr ptr, [Out] int[] indices, int count); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void ConstrainedDelaunayTriangulation2_EIK_Transform(IntPtr ptr, Point2d translation, double rotation, double scale); } } ================================================ FILE: CGALDotNet/Triangulations/ConstrainedTriangulation2.cs ================================================ using System; using System.Collections.Generic; using System.Text; using CGALDotNetGeometry.Numerics; using CGALDotNetGeometry.Shapes; using CGALDotNet.Polygons; using CGALDotNet.Hulls; namespace CGALDotNet.Triangulations { /// /// The generic constrained triangulation class. /// /// The kernel public sealed class ConstrainedTriangulation2 : ConstrainedTriangulation2 where K : CGALKernel, new() { /// /// A static instance of the triangulation. /// public static readonly ConstrainedTriangulation2 Instance = new ConstrainedTriangulation2(); /// /// /// public ConstrainedTriangulation2() : base(new K()) { } /// /// /// /// public ConstrainedTriangulation2(Point2d[] points) : base(new K(), points) { } /// /// /// /// internal ConstrainedTriangulation2(IntPtr ptr) : base(new K(), ptr) { } /// /// The triangulation as a string. /// /// public override string ToString() { return string.Format("[ConstrainedTriangulation2<{0}>: VertexCount={1}, FaceCount={2}]", Kernel.Name, VertexCount, TriangleCount); } /// /// A deep copy of the triangulation. /// /// The deep copy. public ConstrainedTriangulation2 Copy() { return new ConstrainedTriangulation2(Kernel.Copy(Ptr)); } /// /// Compute the convex of the triagulation. /// /// The convex hull polygon. /// public Polygon2 ComputeHull() { int count = VertexCount; if (count < 3) throw new InvalidOperationException("Trianglution must have at lest 3 points to compute the hull."); var points = ArrayCache.Point2dArray(count); GetPoints(points, count); var hull = ConvexHull2.Instance; return hull.CreateHull(points, count); } } /// /// The abstract triangulation class. /// public abstract class ConstrainedTriangulation2 : BaseTriangulation2 { /// /// /// /// internal ConstrainedTriangulation2(CGALKernel kernel) : base(kernel.ConstrainedTriangulationKernel2) { TriangulationKernel = Kernel as ConstrainedTriangulationKernel2; } /// /// /// /// /// internal ConstrainedTriangulation2(CGALKernel kernel, Point2d[] points) : base(kernel.ConstrainedTriangulationKernel2, points) { TriangulationKernel = Kernel as ConstrainedTriangulationKernel2; } /// /// /// /// /// internal ConstrainedTriangulation2(CGALKernel kernel, IntPtr ptr) : base(kernel.ConstrainedTriangulationKernel2, ptr) { TriangulationKernel = Kernel as ConstrainedTriangulationKernel2; } /// /// The kernel with the functions unique to the constrained triangulation. /// protected private ConstrainedTriangulationKernel2 TriangulationKernel { get; private set; } /// /// The number of constrainted edges in the triangulation. /// public int ConstrainedEdgeCount => TriangulationKernel.ConstrainedEdgesCount(Ptr); /// /// Move the vertex. /// /// /// /// The moved vertex /// True if the vertex was found. public bool MoveVertex(int index, Point2d point, out TriVertex2 vertex) { return TriangulationKernel.MoveVertex(Ptr, index, point, true, out vertex); } /// /// Insert the polygons points into the triangulation. /// May not retain the poylgons edges. /// /// public void Insert(Polygon2 polygon) { TriangulationKernel.InsertPolygon(Ptr, polygon.Ptr); } /// /// Insert the polygons points into the triangulation. /// May not retain the poylgons edges. /// /// public void Insert(PolygonWithHoles2 pwh) { TriangulationKernel.InsertPolygonWithHoles(Ptr, pwh.Ptr); } /// /// Insert the polygons points and the edges as constraints into the triangulation. /// Will retatin the poylgons edges. /// /// The polygon to insert. public void InsertConstraint(Polygon2 polygon) { TriangulationKernel.InsertPolygonConstraint(Ptr, polygon.Ptr); } /// /// Insert the polygons points and the edges as constraints into the triangulation. /// Will retatin the poylgons edges. /// /// The polygon to insert. public void InsertConstraint(PolygonWithHoles2 pwh) { TriangulationKernel.InsertPolygonWithHolesConstraint(Ptr, pwh.Ptr); } /// /// Get the number of constrainted edges incident to this vertex. /// /// The vertex index in the triagulation. /// The number of constrainted edges to the vertex. public int IncidentConstraintCount(int vertIndex) { return TriangulationKernel.IncidentConstraintCount(Ptr, vertIndex); } /// /// Does this vertex have a constrainted edge. /// /// The vertex index in the triagulation. /// Does this vertex have a constrainted edge. public bool HasIncidentConstraint(int vertIndex) { return TriangulationKernel.HasIncidentConstraints(Ptr, vertIndex); } /// /// Add a segment as a constraint. /// /// The segment to add. public void InsertConstraint(Segment2d segment) { InsertConstraint(segment.A, segment.B); } /// /// Add the two points as a segment constraint. /// /// The segments point a. /// The segments point b. public void InsertConstraint(Point2d a, Point2d b) { TriangulationKernel.InsertSegmentConstraintFromPoints(Ptr, a, b); } /// /// Add a list of segments as constraint to the triangulation. /// /// The segment array. /// The length of the segment array. public void InsertConstraints(Segment2d[] segments, int count) { ErrorUtil.CheckArray(segments, count); TriangulationKernel.InsertSegmentConstraints(Ptr, segments, count); } /// /// Get a array of all the constraint edges in the triangulation. /// /// The edge array. /// The ararys length. public void GetConstraints(TriEdge2[] constraints, int count) { ErrorUtil.CheckArray(constraints, count); TriangulationKernel.GetConstraints(Ptr, constraints, count); } /// /// Get a array of all the constraint segments in the triangulation. /// /// The segment array. /// The ararys length. public void GetConstraints(Segment2d[] constraints, int count) { ErrorUtil.CheckArray(constraints, count); TriangulationKernel.GetConstraints(Ptr, constraints, count); } /// /// Get the constraints incident to the vertex. /// /// The vertex index in the triangulation. /// The array of edges. /// The ararys length. public void GetIncidentConstraints(int vertexIndex, TriEdge2[] constraints, int count) { ErrorUtil.CheckArray(constraints, count); TriangulationKernel.GetIncidentConstraints(Ptr, vertexIndex, constraints, count); } /// /// Remove a constraint between a face and its neighbour. /// /// The faces index in the triangultion. /// The neighbours index in the faces neighbour array between 0-2. public void RemoveConstraint(int faceIndex, int neighbourIndex) { if (neighbourIndex < 0 || neighbourIndex > 2) return; TriangulationKernel.RemoveConstraint(Ptr, faceIndex, neighbourIndex); } /// /// Remove all constraints incident to a vertex. /// /// The vertex index in the triangulation. public void RemoveIncidentConstraints(int vertexIndex) { TriangulationKernel.RemoveIncidentConstraints(Ptr, vertexIndex); } /// /// Get the triangle indices for domain in the triangultion. /// Used to triangulate polygons. /// /// The indices. internal void GetConstrainedDomainIndices(List indices) { int count = IndiceCount; if (count == 0) return; int[] tmp = new int[count]; count = TriangulationKernel.MarkDomains(Ptr, tmp, tmp.Length); for (int i = 0; i < count; i++) indices.Add(tmp[i]);; } /// /// /// /// public override void Print(StringBuilder builder) { builder.AppendLine(ToString()); builder.AppendLine("IsValid = " + IsValid()); builder.AppendLine("BuildStamp = " + BuildStamp); builder.AppendLine("VertexCount = " + VertexCount); builder.AppendLine("TriangleCount = " + TriangleCount); builder.AppendLine("IndiceCount = " + IndiceCount); builder.AppendLine("Constrained edges = " + ConstrainedEdgeCount); } } } ================================================ FILE: CGALDotNet/Triangulations/ConstrainedTriangulationKernel2.cs ================================================ using System; using System.Collections.Generic; using System.Text; using CGALDotNetGeometry.Numerics; using CGALDotNetGeometry.Shapes; namespace CGALDotNet.Triangulations { internal abstract class ConstrainedTriangulationKernel2 : BaseTriangulationKernel2 { internal abstract int ConstrainedEdgesCount(IntPtr ptr); internal abstract bool HasIncidentConstraints(IntPtr ptr, int index); internal abstract int IncidentConstraintCount(IntPtr ptr, int index); internal abstract void InsertSegmentConstraintFromPoints(IntPtr ptr, Point2d a, Point2d b); internal abstract void InsertSegmentConstraintFromVertices(IntPtr ptr, int vertIndex1, int vertIndex2); internal abstract void InsertSegmentConstraints(IntPtr ptr, Segment2d[] segments, int count); internal abstract void InsertPolygonConstraint(IntPtr triPtr, IntPtr polyPtr); internal abstract void InsertPolygonWithHolesConstraint(IntPtr triPtr, IntPtr pwhPtr); internal abstract void GetConstraints(IntPtr ptr, TriEdge2[] constraints, int count); internal abstract void GetConstraints(IntPtr ptr, Segment2d[] constraints, int count); internal abstract void GetIncidentConstraints(IntPtr ptr, int vertexIndex, TriEdge2[] constraints, int count); internal abstract void RemoveConstraint(IntPtr ptr, int faceIndex, int neighbourIndex); internal abstract void RemoveIncidentConstraints(IntPtr ptr, int vertexIndex); internal abstract int MarkDomains(IntPtr ptr, int[] indices, int count); } } ================================================ FILE: CGALDotNet/Triangulations/ConstrainedTriangulationKernel2_EEK.cs ================================================ using System; using System.Collections.Generic; using System.Text; using System.Runtime.InteropServices; using CGALDotNetGeometry.Numerics; using CGALDotNetGeometry.Shapes; namespace CGALDotNet.Triangulations { internal class ConstrainedTriangulationKernel2_EEK : ConstrainedTriangulationKernel2 { internal override string Name => "EEK"; internal static readonly ConstrainedTriangulationKernel2 Instance = new ConstrainedTriangulationKernel2_EEK(); internal override IntPtr Create() { return ConstrainedTriangulation2_EEK_Create(); } internal override void Release(IntPtr ptr) { ConstrainedTriangulation2_EEK_Release(ptr); } internal override void Clear(IntPtr ptr) { ConstrainedTriangulation2_EEK_Clear(ptr); } internal override IntPtr Copy(IntPtr ptr) { return ConstrainedTriangulation2_EEK_Copy(ptr); } internal override void SetIndices(IntPtr ptr) { ConstrainedTriangulation2_EEK_SetIndices(ptr); } internal override int BuildStamp(IntPtr ptr) { return ConstrainedTriangulation2_EEK_BuildStamp(ptr); } internal override bool IsValid(IntPtr ptr, int level) { return ConstrainedTriangulation2_EEK_IsValid(ptr, level); } internal override int VertexCount(IntPtr ptr) { return ConstrainedTriangulation2_EEK_VertexCount(ptr); } internal override int FaceCount(IntPtr ptr) { return ConstrainedTriangulation2_EEK_FaceCount(ptr); } internal override void InsertPoint(IntPtr ptr, Point2d point) { ConstrainedTriangulation2_EEK_InsertPoint(ptr, point); } internal override void InsertPoints(IntPtr ptr, Point2d[] points, int count) { ConstrainedTriangulation2_EEK_InsertPoints(ptr, points, count); } internal override void InsertPolygon(IntPtr triPtr, IntPtr polyPtr) { ConstrainedTriangulation2_EEK_InsertPolygon(triPtr, polyPtr); } internal override void InsertPolygonWithHoles(IntPtr triPtr, IntPtr pwhPtr) { ConstrainedTriangulation2_EEK_InsertPolygonWithHoles(triPtr, pwhPtr); } internal override void GetPoints(IntPtr ptr, Point2d[] points, int count) { ConstrainedTriangulation2_EEK_GetPoints(ptr, points, count); } internal override void GetIndices(IntPtr ptr, int[] indices, int count) { ConstrainedTriangulation2_EEK_GetIndices(ptr, indices, count); } internal override bool GetVertex(IntPtr ptr, int index, out TriVertex2 vertex) { return ConstrainedTriangulation2_EEK_GetVertex(ptr, index, out vertex); } internal override void GetVertices(IntPtr ptr, TriVertex2[] vertices, int count) { ConstrainedTriangulation2_EEK_GetVertices(ptr, vertices, count); } internal override bool GetFace(IntPtr ptr, int index, out TriFace2 face) { return ConstrainedTriangulation2_EEK_GetFace(ptr, index, out face); } internal override void GetFaces(IntPtr ptr, TriFace2[] faces, int count) { ConstrainedTriangulation2_EEK_GetFaces(ptr, faces, count); } internal override bool GetSegment(IntPtr ptr, int faceIndex, int neighbourIndex, out Segment2d segment) { return ConstrainedTriangulation2_EEK_GetSegment(ptr, faceIndex, neighbourIndex, out segment); } internal override bool GetTriangle(IntPtr ptr, int faceIndex, out Triangle2d triangle) { return ConstrainedTriangulation2_EEK_GetTriangle(ptr, faceIndex, out triangle); } internal override void GetTriangles(IntPtr ptr, Triangle2d[] triangles, int count) { ConstrainedTriangulation2_EEK_GetTriangles(ptr, triangles, count); } internal override bool GetCircumcenter(IntPtr ptr, int faceIndex, out Point2d circumcenter) { return ConstrainedTriangulation2_EEK_GetCircumcenter(ptr, faceIndex, out circumcenter); } internal override void GetCircumcenters(IntPtr ptr, [Out] Point2d[] circumcenters, int count) { ConstrainedTriangulation2_EEK_GetCircumcenters(ptr, circumcenters, count); } internal override int NeighbourIndex(IntPtr ptr, int faceIndex, int index) { return ConstrainedTriangulation2_EEK_NeighbourIndex(ptr, faceIndex, index); } internal override bool LocateFace(IntPtr ptr, Point2d point, out TriFace2 face) { return ConstrainedTriangulation2_EEK_LocateFace(ptr, point, out face); } internal override bool MoveVertex(IntPtr ptr, int index, Point2d point, bool ifNoCollision, out TriVertex2 vertex) { return ConstrainedTriangulation2_EEK_MoveVertex(ptr, index, point, ifNoCollision, out vertex); } internal override bool RemoveVertex(IntPtr ptr, int index) { return ConstrainedTriangulation2_EEK_RemoveVertex(ptr, index); } internal override bool FlipEdge(IntPtr ptr, int faceIndex, int neighbour) { return ConstrainedTriangulation2_EEK_FlipEdge(ptr, faceIndex, neighbour); } //Constrained only. internal override int ConstrainedEdgesCount(IntPtr ptr) { return ConstrainedTriangulation2_EEK_ConstrainedEdgesCount(ptr); } internal override bool HasIncidentConstraints(IntPtr ptr, int index) { return ConstrainedTriangulation2_EEK_HasIncidentConstraints(ptr, index); } internal override int IncidentConstraintCount(IntPtr ptr, int index) { return ConstrainedTriangulation2_EEK_IncidentConstraintCount(ptr, index); } internal override void InsertSegmentConstraintFromPoints(IntPtr ptr, Point2d a, Point2d b) { ConstrainedTriangulation2_EEK_InsertSegmentConstraintFromPoints(ptr, a, b); } internal override void InsertSegmentConstraintFromVertices(IntPtr ptr, int vertIndex1, int vertIndex2) { ConstrainedTriangulation2_EEK_InsertSegmentConstraintFromVertices(ptr, vertIndex1, vertIndex2); } internal override void InsertSegmentConstraints(IntPtr ptr, Segment2d[] segments, int count) { ConstrainedTriangulation2_EEK_InsertSegmentConstraints(ptr, segments, count); } internal override void InsertPolygonConstraint(IntPtr triPtr, IntPtr polyPtr) { ConstrainedTriangulation2_EEK_InsertPolygonConstraint(triPtr, polyPtr); } internal override void InsertPolygonWithHolesConstraint(IntPtr triPtr, IntPtr pwhPtr) { ConstrainedTriangulation2_EEK_InsertPolygonWithHolesConstraint(triPtr, pwhPtr); } internal override void GetConstraints(IntPtr ptr, TriEdge2[] constraints, int count) { ConstrainedTriangulation2_EEK_GetEdgeConstraints(ptr, constraints, count); } internal override void GetConstraints(IntPtr ptr, Segment2d[] constraints, int count) { ConstrainedTriangulation2_EEK_GetSegmentConstraints(ptr, constraints, count); } internal override void GetIncidentConstraints(IntPtr ptr, int vertexIndex, TriEdge2[] constraints, int count) { ConstrainedTriangulation2_EEK_GetIncidentConstraints(ptr, vertexIndex, constraints, count); } internal override void RemoveConstraint(IntPtr ptr, int faceIndex, int neighbourIndex) { ConstrainedTriangulation2_EEK_RemoveConstraint(ptr, faceIndex, neighbourIndex); } internal override void RemoveIncidentConstraints(IntPtr ptr, int vertexIndex) { ConstrainedTriangulation2_EEK_RemoveIncidentConstraints(ptr, vertexIndex); } internal override int MarkDomains(IntPtr ptr, int[] indices, int count) { return ConstrainedTriangulation2_EEK_MarkDomains(ptr, indices, count); } internal override void Transform(IntPtr ptr, Point2d translation, double rotation, double scale) { ConstrainedTriangulation2_EEK_Transform(ptr, translation, rotation, scale); } [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr ConstrainedTriangulation2_EEK_Create(); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void ConstrainedTriangulation2_EEK_Release(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void ConstrainedTriangulation2_EEK_Clear(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr ConstrainedTriangulation2_EEK_Copy(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void ConstrainedTriangulation2_EEK_SetIndices(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int ConstrainedTriangulation2_EEK_BuildStamp(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool ConstrainedTriangulation2_EEK_IsValid(IntPtr ptr, int level); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int ConstrainedTriangulation2_EEK_VertexCount(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int ConstrainedTriangulation2_EEK_FaceCount(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void ConstrainedTriangulation2_EEK_InsertPoint(IntPtr ptr, Point2d point); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void ConstrainedTriangulation2_EEK_InsertPoints(IntPtr ptr, [In] Point2d[] points, int count); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void ConstrainedTriangulation2_EEK_InsertPolygon(IntPtr triPtr, IntPtr polyPtr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void ConstrainedTriangulation2_EEK_InsertPolygonWithHoles(IntPtr triPtr, IntPtr pwhPtr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void ConstrainedTriangulation2_EEK_GetPoints(IntPtr ptr, [Out] Point2d[] points, int count); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void ConstrainedTriangulation2_EEK_GetIndices(IntPtr ptr, [Out] int[] indices, int count); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool ConstrainedTriangulation2_EEK_GetVertex(IntPtr ptr, int index, [Out] out TriVertex2 vertex); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void ConstrainedTriangulation2_EEK_GetVertices(IntPtr ptr, [Out] TriVertex2[] vertices, int count); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool ConstrainedTriangulation2_EEK_GetFace(IntPtr ptr, int index, [Out] out TriFace2 triFace); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void ConstrainedTriangulation2_EEK_GetFaces(IntPtr ptr, [Out] TriFace2[] faces, int count); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool ConstrainedTriangulation2_EEK_GetSegment(IntPtr ptr, int faceIndex, int neighbourIndex, [Out] out Segment2d segment); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool ConstrainedTriangulation2_EEK_GetTriangle(IntPtr ptr, int faceIndex, [Out] out Triangle2d triangle); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void ConstrainedTriangulation2_EEK_GetTriangles(IntPtr ptr, [Out] Triangle2d[] triangles, int count); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool ConstrainedTriangulation2_EEK_GetCircumcenter(IntPtr ptr, int faceIndex, [Out] out Point2d circumcenter); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void ConstrainedTriangulation2_EEK_GetCircumcenters(IntPtr ptr, [Out] Point2d[] circumcenters, int count); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int ConstrainedTriangulation2_EEK_NeighbourIndex(IntPtr ptr, int faceIndex, int index); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool ConstrainedTriangulation2_EEK_LocateFace(IntPtr ptr, Point2d point, [Out] out TriFace2 face); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool ConstrainedTriangulation2_EEK_MoveVertex(IntPtr ptr, int index, Point2d point, bool ifNoCollision, [Out] out TriVertex2 vertex); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool ConstrainedTriangulation2_EEK_RemoveVertex(IntPtr ptr, int index); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool ConstrainedTriangulation2_EEK_FlipEdge(IntPtr ptr, int faceIndex, int neighbour); //Constrained only. [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int ConstrainedTriangulation2_EEK_ConstrainedEdgesCount(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool ConstrainedTriangulation2_EEK_HasIncidentConstraints(IntPtr ptr, int index); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int ConstrainedTriangulation2_EEK_IncidentConstraintCount(IntPtr ptr, int index); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void ConstrainedTriangulation2_EEK_InsertSegmentConstraintFromPoints(IntPtr ptr, Point2d a, Point2d b); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void ConstrainedTriangulation2_EEK_InsertSegmentConstraintFromVertices(IntPtr ptr, int vertIndex1, int vertIndex2); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void ConstrainedTriangulation2_EEK_InsertSegmentConstraints(IntPtr ptr, [In] Segment2d[] segments, int count); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void ConstrainedTriangulation2_EEK_InsertPolygonConstraint(IntPtr triPtr, IntPtr polyPtr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void ConstrainedTriangulation2_EEK_InsertPolygonWithHolesConstraint(IntPtr triPtr, IntPtr pwhPtr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void ConstrainedTriangulation2_EEK_GetEdgeConstraints(IntPtr ptr, [Out] TriEdge2[] constraints, int count); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void ConstrainedTriangulation2_EEK_GetSegmentConstraints(IntPtr ptr, [Out] Segment2d[] constraints, int count); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void ConstrainedTriangulation2_EEK_GetIncidentConstraints(IntPtr ptr, int vertexIndex, [Out] TriEdge2[] constraints, int count); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void ConstrainedTriangulation2_EEK_RemoveConstraint(IntPtr ptr, int faceIndex, int neighbourIndex); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void ConstrainedTriangulation2_EEK_RemoveIncidentConstraints(IntPtr ptr, int vertexIndex); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int ConstrainedTriangulation2_EEK_GetPolygonIndices(IntPtr ptrTri, IntPtr polyPtr, [Out] int[] indices, int count, ORIENTATION orientation); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int ConstrainedTriangulation2_EEK_GetPolygonWithHolesIndices(IntPtr ptrTri, IntPtr pwhPtr, [Out] int[] indices, int count, ORIENTATION orientation); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int ConstrainedTriangulation2_EEK_MarkDomains(IntPtr ptr, [Out] int[] indices, int count); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void ConstrainedTriangulation2_EEK_Transform(IntPtr ptr, Point2d translation, double rotation, double scale); } } ================================================ FILE: CGALDotNet/Triangulations/ConstrainedTriangulationKernel2_EIK.cs ================================================ using System; using System.Collections.Generic; using System.Text; using System.Runtime.InteropServices; using CGALDotNetGeometry.Numerics; using CGALDotNetGeometry.Shapes; namespace CGALDotNet.Triangulations { internal class ConstrainedTriangulationKernel2_EIK : ConstrainedTriangulationKernel2 { internal override string Name => "EIK"; internal static readonly ConstrainedTriangulationKernel2 Instance = new ConstrainedTriangulationKernel2_EIK(); internal override IntPtr Create() { return ConstrainedTriangulation2_EIK_Create(); } internal override void Release(IntPtr ptr) { ConstrainedTriangulation2_EIK_Release(ptr); } internal override void Clear(IntPtr ptr) { ConstrainedTriangulation2_EIK_Clear(ptr); } internal override IntPtr Copy(IntPtr ptr) { return ConstrainedTriangulation2_EIK_Copy(ptr); } internal override void SetIndices(IntPtr ptr) { ConstrainedTriangulation2_EIK_SetIndices(ptr); } internal override int BuildStamp(IntPtr ptr) { return ConstrainedTriangulation2_EIK_BuildStamp(ptr); } internal override bool IsValid(IntPtr ptr, int level) { return ConstrainedTriangulation2_EIK_IsValid(ptr, level); } internal override int VertexCount(IntPtr ptr) { return ConstrainedTriangulation2_EIK_VertexCount(ptr); } internal override int FaceCount(IntPtr ptr) { return ConstrainedTriangulation2_EIK_FaceCount(ptr); } internal override void InsertPoint(IntPtr ptr, Point2d point) { ConstrainedTriangulation2_EIK_InsertPoint(ptr, point); } internal override void InsertPoints(IntPtr ptr, Point2d[] points, int count) { ConstrainedTriangulation2_EIK_InsertPoints(ptr, points, count); } internal override void InsertPolygon(IntPtr triPtr, IntPtr polyPtr) { ConstrainedTriangulation2_EIK_InsertPolygon(triPtr, polyPtr); } internal override void InsertPolygonWithHoles(IntPtr triPtr, IntPtr pwhPtr) { ConstrainedTriangulation2_EIK_InsertPolygonWithHoles(triPtr, pwhPtr); } internal override void GetPoints(IntPtr ptr, Point2d[] points, int count) { ConstrainedTriangulation2_EIK_GetPoints(ptr, points, count); } internal override void GetIndices(IntPtr ptr, int[] indices, int count) { ConstrainedTriangulation2_EIK_GetIndices(ptr, indices, count); } internal override bool GetVertex(IntPtr ptr, int index, out TriVertex2 vertex) { return ConstrainedTriangulation2_EIK_GetVertex(ptr, index, out vertex); } internal override void GetVertices(IntPtr ptr, TriVertex2[] vertices, int count) { ConstrainedTriangulation2_EIK_GetVertices(ptr, vertices, count); } internal override bool GetFace(IntPtr ptr, int index, out TriFace2 face) { return ConstrainedTriangulation2_EIK_GetFace(ptr, index, out face); } internal override void GetFaces(IntPtr ptr, TriFace2[] faces, int count) { ConstrainedTriangulation2_EIK_GetFaces(ptr, faces, count); } internal override bool GetSegment(IntPtr ptr, int faceIndex, int neighbourIndex, out Segment2d segment) { return ConstrainedTriangulation2_EIK_GetSegment(ptr, faceIndex, neighbourIndex, out segment); } internal override bool GetTriangle(IntPtr ptr, int faceIndex, out Triangle2d triangle) { return ConstrainedTriangulation2_EIK_GetTriangle(ptr, faceIndex, out triangle); } internal override void GetTriangles(IntPtr ptr, Triangle2d[] triangles, int count) { ConstrainedTriangulation2_EIK_GetTriangles(ptr, triangles, count); } internal override bool GetCircumcenter(IntPtr ptr, int faceIndex, out Point2d circumcenter) { return ConstrainedTriangulation2_EIK_GetCircumcenter(ptr, faceIndex, out circumcenter); } internal override void GetCircumcenters(IntPtr ptr, [Out] Point2d[] circumcenters, int count) { ConstrainedTriangulation2_EIK_GetCircumcenters(ptr, circumcenters, count); } internal override int NeighbourIndex(IntPtr ptr, int faceIndex, int index) { return ConstrainedTriangulation2_EIK_NeighbourIndex(ptr, faceIndex, index); } internal override bool LocateFace(IntPtr ptr, Point2d point, out TriFace2 face) { return ConstrainedTriangulation2_EIK_LocateFace(ptr, point, out face); } internal override bool MoveVertex(IntPtr ptr, int index, Point2d point, bool ifNoCollision, out TriVertex2 vertex) { return ConstrainedTriangulation2_EIK_MoveVertex(ptr, index, point, ifNoCollision, out vertex); } internal override bool RemoveVertex(IntPtr ptr, int index) { return ConstrainedTriangulation2_EIK_RemoveVertex(ptr, index); } internal override bool FlipEdge(IntPtr ptr, int faceIndex, int neighbour) { return ConstrainedTriangulation2_EIK_FlipEdge(ptr, faceIndex, neighbour); } //Constrained only. internal override int ConstrainedEdgesCount(IntPtr ptr) { return ConstrainedTriangulation2_EIK_ConstrainedEdgesCount(ptr); } internal override bool HasIncidentConstraints(IntPtr ptr, int index) { return ConstrainedTriangulation2_EIK_HasIncidentConstraints(ptr, index); } internal override int IncidentConstraintCount(IntPtr ptr, int index) { return ConstrainedTriangulation2_EIK_IncidentConstraintCount(ptr, index); } internal override void InsertSegmentConstraintFromPoints(IntPtr ptr, Point2d a, Point2d b) { ConstrainedTriangulation2_EIK_InsertSegmentConstraintFromPoints(ptr, a, b); } internal override void InsertSegmentConstraintFromVertices(IntPtr ptr, int vertIndex1, int vertIndex2) { ConstrainedTriangulation2_EIK_InsertSegmentConstraintFromVertices(ptr, vertIndex1, vertIndex2); } internal override void InsertSegmentConstraints(IntPtr ptr, Segment2d[] segments, int count) { ConstrainedTriangulation2_EIK_InsertSegmentConstraints(ptr, segments, count); } internal override void InsertPolygonConstraint(IntPtr triPtr, IntPtr polyPtr) { ConstrainedTriangulation2_EIK_InsertPolygonConstraint(triPtr, polyPtr); } internal override void InsertPolygonWithHolesConstraint(IntPtr triPtr, IntPtr pwhPtr) { ConstrainedTriangulation2_EIK_InsertPolygonWithHolesConstraint(triPtr, pwhPtr); } internal override void GetConstraints(IntPtr ptr, TriEdge2[] constraints, int count) { ConstrainedTriangulation2_EIK_GetEdgeConstraints(ptr, constraints, count); } internal override void GetConstraints(IntPtr ptr, Segment2d[] constraints, int count) { ConstrainedTriangulation2_EIK_GetSegmentConstraints(ptr, constraints, count); } internal override void GetIncidentConstraints(IntPtr ptr, int vertexIndex, TriEdge2[] constraints, int count) { ConstrainedTriangulation2_EIK_GetIncidentConstraints(ptr, vertexIndex, constraints, count); } internal override void RemoveConstraint(IntPtr ptr, int faceIndex, int neighbourIndex) { ConstrainedTriangulation2_EIK_RemoveConstraint(ptr, faceIndex, neighbourIndex); } internal override void RemoveIncidentConstraints(IntPtr ptr, int vertexIndex) { ConstrainedTriangulation2_EIK_RemoveIncidentConstraints(ptr, vertexIndex); } internal override int MarkDomains(IntPtr ptr, int[] indices, int count) { return ConstrainedTriangulation2_EIK_MarkDomains(ptr, indices, count); } internal override void Transform(IntPtr ptr, Point2d translation, double rotation, double scale) { ConstrainedTriangulation2_EIK_Transform(ptr, translation, rotation, scale); } [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr ConstrainedTriangulation2_EIK_Create(); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void ConstrainedTriangulation2_EIK_Release(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void ConstrainedTriangulation2_EIK_Clear(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr ConstrainedTriangulation2_EIK_Copy(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void ConstrainedTriangulation2_EIK_SetIndices(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int ConstrainedTriangulation2_EIK_BuildStamp(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool ConstrainedTriangulation2_EIK_IsValid(IntPtr ptr, int level); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int ConstrainedTriangulation2_EIK_VertexCount(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int ConstrainedTriangulation2_EIK_FaceCount(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void ConstrainedTriangulation2_EIK_InsertPoint(IntPtr ptr, Point2d point); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void ConstrainedTriangulation2_EIK_InsertPoints(IntPtr ptr, [In] Point2d[] points, int count); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void ConstrainedTriangulation2_EIK_InsertPolygon(IntPtr triPtr, IntPtr polyPtr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void ConstrainedTriangulation2_EIK_InsertPolygonWithHoles(IntPtr triPtr, IntPtr pwhPtr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void ConstrainedTriangulation2_EIK_GetPoints(IntPtr ptr, [Out] Point2d[] points, int count); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void ConstrainedTriangulation2_EIK_GetIndices(IntPtr ptr, [Out] int[] indices, int count); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool ConstrainedTriangulation2_EIK_GetVertex(IntPtr ptr, int index, [Out] out TriVertex2 vertex); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void ConstrainedTriangulation2_EIK_GetVertices(IntPtr ptr, [Out] TriVertex2[] vertices, int count); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool ConstrainedTriangulation2_EIK_GetFace(IntPtr ptr, int index, [Out] out TriFace2 triFace); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void ConstrainedTriangulation2_EIK_GetFaces(IntPtr ptr, [Out] TriFace2[] faces, int count); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool ConstrainedTriangulation2_EIK_GetSegment(IntPtr ptr, int faceIndex, int neighbourIndex, [Out] out Segment2d segment); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool ConstrainedTriangulation2_EIK_GetTriangle(IntPtr ptr, int faceIndex, [Out] out Triangle2d triangle); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void ConstrainedTriangulation2_EIK_GetTriangles(IntPtr ptr, [Out] Triangle2d[] triangles, int count); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool ConstrainedTriangulation2_EIK_GetCircumcenter(IntPtr ptr, int faceIndex, [Out] out Point2d circumcenter); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void ConstrainedTriangulation2_EIK_GetCircumcenters(IntPtr ptr, [Out] Point2d[] circumcenters, int count); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int ConstrainedTriangulation2_EIK_NeighbourIndex(IntPtr ptr, int faceIndex, int index); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool ConstrainedTriangulation2_EIK_LocateFace(IntPtr ptr, Point2d point, [Out] out TriFace2 face); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool ConstrainedTriangulation2_EIK_MoveVertex(IntPtr ptr, int index, Point2d point, bool ifNoCollision, [Out] out TriVertex2 vertex); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool ConstrainedTriangulation2_EIK_RemoveVertex(IntPtr ptr, int index); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool ConstrainedTriangulation2_EIK_FlipEdge(IntPtr ptr, int faceIndex, int neighbour); //Constrained only. [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int ConstrainedTriangulation2_EIK_ConstrainedEdgesCount(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool ConstrainedTriangulation2_EIK_HasIncidentConstraints(IntPtr ptr, int index); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int ConstrainedTriangulation2_EIK_IncidentConstraintCount(IntPtr ptr, int index); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void ConstrainedTriangulation2_EIK_InsertSegmentConstraintFromPoints(IntPtr ptr, Point2d a, Point2d b); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void ConstrainedTriangulation2_EIK_InsertSegmentConstraintFromVertices(IntPtr ptr, int vertIndex1, int vertIndex2); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void ConstrainedTriangulation2_EIK_InsertSegmentConstraints(IntPtr ptr, [In] Segment2d[] segments, int count); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void ConstrainedTriangulation2_EIK_InsertPolygonConstraint(IntPtr triPtr, IntPtr polyPtr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void ConstrainedTriangulation2_EIK_InsertPolygonWithHolesConstraint(IntPtr triPtr, IntPtr pwhPtr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void ConstrainedTriangulation2_EIK_GetEdgeConstraints(IntPtr ptr, [Out] TriEdge2[] constraints, int count); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void ConstrainedTriangulation2_EIK_GetSegmentConstraints(IntPtr ptr, [Out] Segment2d[] constraints, int count); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void ConstrainedTriangulation2_EIK_GetIncidentConstraints(IntPtr ptr, int vertexIndex, [Out] TriEdge2[] constraints, int count); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void ConstrainedTriangulation2_EIK_RemoveConstraint(IntPtr ptr, int faceIndex, int neighbourIndex); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void ConstrainedTriangulation2_EIK_RemoveIncidentConstraints(IntPtr ptr, int vertexIndex); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int ConstrainedTriangulation2_EIK_GetPolygonIndices(IntPtr ptrTri, IntPtr polyPtr, [Out] int[] indices, int count, ORIENTATION orientation); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int ConstrainedTriangulation2_EIK_GetPolygonWithHolesIndices(IntPtr ptrTri, IntPtr pwhPtr, [Out] int[] indices, int count, ORIENTATION orientation); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int ConstrainedTriangulation2_EIK_MarkDomains(IntPtr ptr, [Out] int[] indices, int count); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void ConstrainedTriangulation2_EIK_Transform(IntPtr ptr, Point2d translation, double rotation, double scale); } } ================================================ FILE: CGALDotNet/Triangulations/DelaunayTriangulation2.cs ================================================ using System; using System.Collections.Generic; using System.Text; using CGALDotNetGeometry.Numerics; using CGALDotNetGeometry.Shapes; using CGALDotNet.Polygons; using CGALDotNet.Hulls; namespace CGALDotNet.Triangulations { /// /// The generic delaunay triangulation class. /// /// The kerne public sealed class DelaunayTriangulation2 : DelaunayTriangulation2 where K : CGALKernel, new() { /// /// A static instance of the delaunay triangulation. /// public static readonly DelaunayTriangulation2 Instance = new DelaunayTriangulation2(); /// /// /// public DelaunayTriangulation2() : base(new K()) { } /// /// /// /// public DelaunayTriangulation2(Point2d[] points) : base(new K(), points) { } /// /// /// /// internal DelaunayTriangulation2(IntPtr ptr) : base(new K(), ptr) { } /// /// The triangulation as string. /// /// public override string ToString() { return string.Format("[DelaunayTriangulation2<{0}>: VertexCount={1}, FaceCount={2}]", Kernel.Name, VertexCount, TriangleCount); } /// /// A deep copy of the triangulation. /// /// public DelaunayTriangulation2 Copy() { return new DelaunayTriangulation2(Kernel.Copy(Ptr)); } /// /// Insert the polygons points into the triangulation. /// May not retatin the poylgons edges. /// /// The polygon to insert. public void Insert(Polygon2 polygon) { if (polygon == null) return; Kernel.InsertPolygon(Ptr, polygon.Ptr); } /// /// Insert the polygons points into the triangulation. /// May not retatin the poylgons edges. /// /// The polygon to insert. public void Insert(PolygonWithHoles2 pwh) { if (pwh == null) return; Kernel.InsertPolygonWithHoles(Ptr, pwh.Ptr); } /// /// Compute the convex of the triagulation. /// /// The convex hull polygon. /// public Polygon2 ComputeHull() { int count = VertexCount; if (count < 3) throw new InvalidOperationException("Trianglution must have at lest 3 points to compute the hull."); var points = ArrayCache.Point2dArray(count); GetPoints(points, count); var hull = ConvexHull2.Instance; return hull.CreateHull(points, count); } } /// /// The anstract base class for the delaunay triangulation. /// public abstract class DelaunayTriangulation2 : BaseTriangulation2 { /// /// /// /// internal DelaunayTriangulation2(CGALKernel kernel) : base(kernel.DelaunayTriangulationKernel2) { TriangulationKernel = Kernel as DelaunayTriangulationKernel2; } /// /// /// /// /// internal DelaunayTriangulation2(CGALKernel kernel, Point2d[] points) : base(kernel.DelaunayTriangulationKernel2, points) { TriangulationKernel = Kernel as DelaunayTriangulationKernel2; } /// /// /// /// /// internal DelaunayTriangulation2(CGALKernel kernel, IntPtr ptr) : base(kernel.DelaunayTriangulationKernel2, ptr) { TriangulationKernel = Kernel as DelaunayTriangulationKernel2; } /// /// The kernel with the functions unique to the delaunay triangulation. /// protected private DelaunayTriangulationKernel2 TriangulationKernel { get; private set; } /// /// Move the vertex. /// /// /// /// If there is not already another vertex placed on the point, /// the triangulation is modified such that the new position of vertex same as point. /// The moved vertex /// True if the vertex was found. public bool MoveVertex(int index, Point2d point, bool ifNoCollision, out TriVertex2 vertex) { return TriangulationKernel.MoveVertex(Ptr, index, point, ifNoCollision, out vertex); } /// /// If the dual voronoi diagram of the triangulation is taken /// How many segments and rays would be produced. /// /// The number of segments. /// The number of rays. public void GetVoronoCount(out int numSegments, out int numRays) { TriangulationKernel.VoronoiCount(Ptr, out numSegments, out numRays); } /// /// Get a array of the voronoi's segments. /// /// A array of the voronoi's segments. public Segment2d[] GetVoronoiSegments() { TriangulationKernel.VoronoiCount(Ptr, out int numSegments, out int numRays); var segments = new Segment2d[numSegments]; TriangulationKernel.GetVoronoiSegments(Ptr, segments, segments.Length); return segments; } /// /// Get a array of the voronois rays. /// These are the segment at edge of triangulation that /// a end point can not be determined. /// /// A array of the voronoi's rays. public Ray2d[] GetVoronoiRays() { TriangulationKernel.VoronoiCount(Ptr, out int numSegments, out int numRays); var rays = new Ray2d[numRays]; TriangulationKernel.GetVoronoiRays(Ptr, rays, rays.Length); return rays; } /// /// /// /// public override void Print(StringBuilder builder) { builder.AppendLine(ToString()); builder.AppendLine("IsValid = " + IsValid()); builder.AppendLine("BuildStamp = " + BuildStamp); builder.AppendLine("VertexCount = " + VertexCount); builder.AppendLine("TriangleCount = " + TriangleCount); builder.AppendLine("IndiceCount = " + IndiceCount); } } } ================================================ FILE: CGALDotNet/Triangulations/DelaunayTriangulation3.cs ================================================ using System; using System.Collections.Generic; using System.Text; using CGALDotNetGeometry.Numerics; using CGALDotNetGeometry.Extensions; using CGALDotNet.Meshing; using CGALDotNet.Hulls; using CGALDotNet.Polyhedra; namespace CGALDotNet.Triangulations { /// /// Generic triangulation class. /// /// The kerel. public sealed class DelaunayTriangulation3 : DelaunayTriangulation3 where K : CGALKernel, new() { /// /// Static instance of a triangulation. /// public static readonly DelaunayTriangulation3 Instance = new DelaunayTriangulation3(); /// /// Default constructor. /// public DelaunayTriangulation3() : base(new K()) { } /// /// Construct a triangulation from the points. /// /// The triangulation points. public DelaunayTriangulation3(Point3d[] points) : base(new K(), points) { } /// /// Construct from a existing triangulation. /// /// A pointer to the unmanaged object. internal DelaunayTriangulation3(IntPtr ptr) : base(new K(), ptr) { } /// /// The triangulation as a string. /// /// public override string ToString() { return string.Format("[DelaunayTriangulation3<{0}>: VertexCount={1}, TetrahedronCount={2}, TriangleCount={3}]", Kernel.Name, VertexCount, FiniteTetrahedronCount, FiniteTriangleCount); } /// /// Create a deep copy of the triangulation. /// /// The deep copy. public DelaunayTriangulation3 Copy() { return new DelaunayTriangulation3(Kernel.Copy(Ptr)); } /// /// Refine the triangulation. /// /// The target edge lengths. /// The number of iterations. public void Refine(double targetEdgeLength, int iterations = 1) { int count = VertexCount; var points = ArrayCache.Point3dArray(count); GetPoints(points, count); var tet = TetrahedralRemeshing.Instance; count = tet.Remesh(targetEdgeLength, iterations, points, count); if (count > 0) { points = ArrayCache.Point3dArray(count); tet.GetPoints(points, count); Clear(); Insert(points, points.Length); } } /// /// Compute the convex of the triagulation. /// /// The convex hull polygon. /// public Polyhedron3 ComputeHull() { int count = VertexCount; if (count < 4) throw new InvalidOperationException("Trianglution must have at least 4 points to compute the hull."); var points = new Point3d[count]; GetPoints(points, count); points = points.RemoveNonFinite().ToArray(); var hull = ConvexHull3.Instance; return hull.CreateHullAsPolyhedron(points, points.Length); } } /// /// Abstract base class for the triagulation. /// public abstract class DelaunayTriangulation3 : BaseTriangulation3 { /// /// /// /// internal DelaunayTriangulation3(CGALKernel kernel) : base(kernel.TriangulationKernel3) { TriangulationKernel = Kernel as DelaunayTriangulationKernel3; } /// /// /// /// /// internal DelaunayTriangulation3(CGALKernel kernel, Point3d[] points) : base(kernel.TriangulationKernel3, points) { TriangulationKernel = Kernel as DelaunayTriangulationKernel3; } /// /// /// /// /// internal DelaunayTriangulation3(CGALKernel kernel, IntPtr ptr) : base(kernel.TriangulationKernel3, ptr) { TriangulationKernel = Kernel as DelaunayTriangulationKernel3; } /// /// The kernel with the functions unique to the triangulation. /// protected private DelaunayTriangulationKernel3 TriangulationKernel { get; private set; } /// /// Move a vertex. /// /// The vertices index. /// The point to move to. /// Should the vertex only be moved if there is no coliision. /// If the vertex was moved. public bool Move(int index, Point3d point, bool ifNoCollision = true) { return TriangulationKernel.Move(Ptr, index, point, ifNoCollision); } /// /// Find the index of the nearest vertex to the point. /// /// The point. /// The index of the nearest vertex to the point. public int NearestVertex(Point3d point) { return TriangulationKernel.NearestVertex(Ptr, point); } /// /// Find the index of the nearest vertex to the point. /// Presumes poimt is in a cell. /// /// The cells index. /// The point. /// The index of the nearest vertex to the point. public int NearestVertexInCell(int index, Point3d point) { return TriangulationKernel.NearestVertexInCell(Ptr, index, point); } /// /// Remobe a vertex. /// /// The vertex index. /// True if vertex was removed. public bool RemoveVertex(int index) { return TriangulationKernel.RemoveVertex(Ptr, index); } /// /// /// /// public override void Print(StringBuilder builder) { builder.AppendLine(ToString()); builder.AppendLine("IsValid = " + IsValid()); builder.AppendLine("Dimension = " + Dimension); builder.AppendLine("VertexCount = " + VertexCount); builder.AppendLine("FiniteVertexCount = " + FiniteVertexCount); builder.AppendLine("TetrahedronCount = " + TetrahedronCount); builder.AppendLine("FiniteTetrahedronCount = " + FiniteTetrahedronCount); builder.AppendLine("EdgeCount = " + EdgeCount); builder.AppendLine("FiniteEdgeCount = " + FiniteEdgeCount); builder.AppendLine("TriangleCount = " + TriangleCount); builder.AppendLine("FiniteTriangleCount = " + FiniteTriangleCount); } } } ================================================ FILE: CGALDotNet/Triangulations/DelaunayTriangulationKernel2.cs ================================================ using System; using System.Collections.Generic; using System.Text; using CGALDotNetGeometry.Numerics; using CGALDotNetGeometry.Shapes; namespace CGALDotNet.Triangulations { internal abstract class DelaunayTriangulationKernel2 : BaseTriangulationKernel2 { internal abstract int VoronoiSegmentCount(IntPtr ptr); internal abstract int VoronoiRayCount(IntPtr ptr); internal abstract void GetVoronoiSegments(IntPtr ptr, Segment2d[] segments, int count); internal abstract void GetVoronoiRays(IntPtr ptr, Ray2d[] rays, int count); internal abstract void VoronoiCount(IntPtr ptr, out int numSegments, out int numRays); } } ================================================ FILE: CGALDotNet/Triangulations/DelaunayTriangulationKernel2_EEK.cs ================================================ using System; using System.Collections.Generic; using System.Text; using System.Runtime.InteropServices; using CGALDotNetGeometry.Numerics; using CGALDotNetGeometry.Shapes; namespace CGALDotNet.Triangulations { internal class DelaunayTriangulationKernel2_EEK : DelaunayTriangulationKernel2 { internal override string Name => "EEK"; internal static readonly DelaunayTriangulationKernel2 Instance = new DelaunayTriangulationKernel2_EEK(); internal override IntPtr Create() { return DelaunayTriangulation2_EEK_Create(); } internal override void Release(IntPtr ptr) { DelaunayTriangulation2_EEK_Release(ptr); } internal override void Clear(IntPtr ptr) { DelaunayTriangulation2_EEK_Clear(ptr); } internal override IntPtr Copy(IntPtr ptr) { return DelaunayTriangulation2_EEK_Copy(ptr); } internal override void SetIndices(IntPtr ptr) { DelaunayTriangulation2_EEK_SetIndices(ptr); } internal override int BuildStamp(IntPtr ptr) { return DelaunayTriangulation2_EEK_BuildStamp(ptr); } internal override bool IsValid(IntPtr ptr, int level) { return DelaunayTriangulation2_EEK_IsValid(ptr, level); } internal override int VertexCount(IntPtr ptr) { return DelaunayTriangulation2_EEK_VertexCount(ptr); } internal override int FaceCount(IntPtr ptr) { return DelaunayTriangulation2_EEK_FaceCount(ptr); } internal override void InsertPoint(IntPtr ptr, Point2d point) { DelaunayTriangulation2_EEK_InsertPoint(ptr, point); } internal override void InsertPoints(IntPtr ptr, Point2d[] points, int count) { DelaunayTriangulation2_EEK_InsertPoints(ptr, points, count); } internal override void InsertPolygon(IntPtr triPtr, IntPtr polyPtr) { DelaunayTriangulation2_EEK_InsertPolygon(triPtr, polyPtr); } internal override void InsertPolygonWithHoles(IntPtr triPtr, IntPtr pwhPtr) { DelaunayTriangulation2_EEK_InsertPolygonWithHoles(triPtr, pwhPtr); } internal override void GetPoints(IntPtr ptr, Point2d[] points, int count) { DelaunayTriangulation2_EEK_GetPoints(ptr, points, count); } internal override void GetIndices(IntPtr ptr, int[] indices, int count) { DelaunayTriangulation2_EEK_GetIndices(ptr, indices, count); } internal override bool GetVertex(IntPtr ptr, int index, out TriVertex2 vertex) { return DelaunayTriangulation2_EEK_GetVertex(ptr, index, out vertex); } internal override void GetVertices(IntPtr ptr, TriVertex2[] vertices, int count) { DelaunayTriangulation2_EEK_GetVertices(ptr, vertices, count); } internal override bool GetFace(IntPtr ptr, int index, out TriFace2 face) { return DelaunayTriangulation2_EEK_GetFace(ptr, index, out face); } internal override bool GetSegment(IntPtr ptr, int faceIndex, int neighbourIndex, out Segment2d segment) { return DelaunayTriangulation2_EEK_GetSegment(ptr, faceIndex, neighbourIndex, out segment); } internal override bool GetTriangle(IntPtr ptr, int faceIndex, out Triangle2d triangle) { return DelaunayTriangulation2_EEK_GetTriangle(ptr, faceIndex, out triangle); } internal override void GetTriangles(IntPtr ptr, Triangle2d[] triangles, int count) { DelaunayTriangulation2_EEK_GetTriangles(ptr, triangles, count); } internal override bool GetCircumcenter(IntPtr ptr, int faceIndex, out Point2d circumcenter) { return DelaunayTriangulation2_EEK_GetCircumcenter(ptr, faceIndex, out circumcenter); } internal override void GetCircumcenters(IntPtr ptr, [Out] Point2d[] circumcenters,int count) { DelaunayTriangulation2_EEK_GetCircumcenters(ptr, circumcenters, count); } internal override void GetFaces(IntPtr ptr, TriFace2[] faces, int count) { DelaunayTriangulation2_EEK_GetFaces(ptr, faces, count); } internal override int NeighbourIndex(IntPtr ptr, int faceIndex, int index) { return DelaunayTriangulation2_EEK_NeighbourIndex(ptr, faceIndex, index); } internal override bool LocateFace(IntPtr ptr, Point2d point, out TriFace2 face) { return DelaunayTriangulation2_EEK_LocateFace(ptr, point, out face); } internal override bool MoveVertex(IntPtr ptr, int index, Point2d point, bool ifNoCollision, out TriVertex2 vertex) { return DelaunayTriangulation2_EEK_MoveVertex(ptr, index, point, ifNoCollision, out vertex); } internal override bool RemoveVertex(IntPtr ptr, int index) { return DelaunayTriangulation2_EEK_RemoveVertex(ptr, index); } internal override bool FlipEdge(IntPtr ptr, int faceIndex, int neighbour) { return DelaunayTriangulation2_EEK_FlipEdge(ptr, faceIndex, neighbour); } //Delaunay only internal override int VoronoiSegmentCount(IntPtr ptr) { return DelaunayTriangulation2_EEK_VoronoiSegmentCount(ptr); } internal override int VoronoiRayCount(IntPtr ptr) { return DelaunayTriangulation2_EEK_VoronoiRayCount(ptr); } internal override void GetVoronoiSegments(IntPtr ptr, Segment2d[] segments, int count) { DelaunayTriangulation2_EEK_GetVoronoiSegments(ptr, segments, count); } internal override void GetVoronoiRays(IntPtr ptr, Ray2d[] rays, int count) { DelaunayTriangulation2_EEK_GetVoronoiRays(ptr, rays, count); } internal override void VoronoiCount(IntPtr ptr, out int numSegments, out int numRays) { DelaunayTriangulation2_EEK_VoronoiCount(ptr, out numSegments, out numRays); } internal override void Transform(IntPtr ptr, Point2d translation, double rotation, double scale) { DelaunayTriangulation2_EEK_Transform(ptr, translation, rotation, scale); } [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr DelaunayTriangulation2_EEK_Create(); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void DelaunayTriangulation2_EEK_Release(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void DelaunayTriangulation2_EEK_Clear(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr DelaunayTriangulation2_EEK_Copy(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void DelaunayTriangulation2_EEK_SetIndices(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int DelaunayTriangulation2_EEK_BuildStamp(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool DelaunayTriangulation2_EEK_IsValid(IntPtr ptr, int level); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int DelaunayTriangulation2_EEK_VertexCount(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int DelaunayTriangulation2_EEK_FaceCount(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void DelaunayTriangulation2_EEK_InsertPoint(IntPtr ptr, Point2d point); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void DelaunayTriangulation2_EEK_InsertPoints(IntPtr ptr, [In] Point2d[] points, int count); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void DelaunayTriangulation2_EEK_InsertPolygon(IntPtr triPtr, IntPtr polyPtr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void DelaunayTriangulation2_EEK_InsertPolygonWithHoles(IntPtr triPtr, IntPtr pwhPtr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void DelaunayTriangulation2_EEK_GetPoints(IntPtr ptr, [Out] Point2d[] points, int count); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void DelaunayTriangulation2_EEK_GetIndices(IntPtr ptr, [Out] int[] indices, int count); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool DelaunayTriangulation2_EEK_GetVertex(IntPtr ptr, int index, [Out] out TriVertex2 vertex); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void DelaunayTriangulation2_EEK_GetVertices(IntPtr ptr, [Out] TriVertex2[] vertices, int count); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool DelaunayTriangulation2_EEK_GetFace(IntPtr ptr, int index, [Out] out TriFace2 triFace); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void DelaunayTriangulation2_EEK_GetFaces(IntPtr ptr, [Out] TriFace2[] faces, int count); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool DelaunayTriangulation2_EEK_GetSegment(IntPtr ptr, int faceIndex, int neighbourIndex, [Out] out Segment2d segment); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool DelaunayTriangulation2_EEK_GetTriangle(IntPtr ptr, int faceIndex, [Out] out Triangle2d triangle); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void DelaunayTriangulation2_EEK_GetTriangles(IntPtr ptr, [Out] Triangle2d[] triangles, int count); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool DelaunayTriangulation2_EEK_GetCircumcenter(IntPtr ptr, int faceIndex, [Out] out Point2d circumcenter); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void DelaunayTriangulation2_EEK_GetCircumcenters(IntPtr ptr, [Out] Point2d[] circumcenters, int count); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int DelaunayTriangulation2_EEK_NeighbourIndex(IntPtr ptr, int faceIndex, int index); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool DelaunayTriangulation2_EEK_LocateFace(IntPtr ptr, Point2d point, [Out] out TriFace2 face); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool DelaunayTriangulation2_EEK_MoveVertex(IntPtr ptr, int index, Point2d point, bool ifNoCollision, [Out] out TriVertex2 vertex); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool DelaunayTriangulation2_EEK_RemoveVertex(IntPtr ptr, int index); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool DelaunayTriangulation2_EEK_FlipEdge(IntPtr ptr, int faceIndex, int neighbour); //Delaunay only [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int DelaunayTriangulation2_EEK_VoronoiSegmentCount(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int DelaunayTriangulation2_EEK_VoronoiRayCount(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void DelaunayTriangulation2_EEK_GetVoronoiSegments(IntPtr ptr, [Out] Segment2d[] segments, int count); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void DelaunayTriangulation2_EEK_GetVoronoiRays(IntPtr ptr, [Out] Ray2d[] rays, int count); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void DelaunayTriangulation2_EEK_VoronoiCount(IntPtr ptr, [Out] out int numSegments, [Out] out int numRays); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void DelaunayTriangulation2_EEK_Transform(IntPtr ptr, Point2d translation, double rotation, double scale); } } ================================================ FILE: CGALDotNet/Triangulations/DelaunayTriangulationKernel2_EIK.cs ================================================ using System; using System.Collections.Generic; using System.Text; using System.Runtime.InteropServices; using CGALDotNetGeometry.Numerics; using CGALDotNetGeometry.Shapes; namespace CGALDotNet.Triangulations { internal class DelaunayTriangulationKernel2_EIK : DelaunayTriangulationKernel2 { internal override string Name => "EIK"; internal static readonly DelaunayTriangulationKernel2 Instance = new DelaunayTriangulationKernel2_EIK(); internal override IntPtr Create() { return DelaunayTriangulation2_EIK_Create(); } internal override void Release(IntPtr ptr) { DelaunayTriangulation2_EIK_Release(ptr); } internal override void Clear(IntPtr ptr) { DelaunayTriangulation2_EIK_Clear(ptr); } internal override IntPtr Copy(IntPtr ptr) { return DelaunayTriangulation2_EIK_Copy(ptr); } internal override void SetIndices(IntPtr ptr) { DelaunayTriangulation2_EIK_SetIndices(ptr); } internal override int BuildStamp(IntPtr ptr) { return DelaunayTriangulation2_EIK_BuildStamp(ptr); } internal override bool IsValid(IntPtr ptr, int level) { return DelaunayTriangulation2_EIK_IsValid(ptr, level); } internal override int VertexCount(IntPtr ptr) { return DelaunayTriangulation2_EIK_VertexCount(ptr); } internal override int FaceCount(IntPtr ptr) { return DelaunayTriangulation2_EIK_FaceCount(ptr); } internal override void InsertPoint(IntPtr ptr, Point2d point) { DelaunayTriangulation2_EIK_InsertPoint(ptr, point); } internal override void InsertPoints(IntPtr ptr, Point2d[] points, int count) { DelaunayTriangulation2_EIK_InsertPoints(ptr, points, count); } internal override void InsertPolygon(IntPtr triPtr, IntPtr polyPtr) { DelaunayTriangulation2_EIK_InsertPolygon(triPtr, polyPtr); } internal override void InsertPolygonWithHoles(IntPtr triPtr, IntPtr pwhPtr) { DelaunayTriangulation2_EIK_InsertPolygonWithHoles(triPtr, pwhPtr); } internal override void GetPoints(IntPtr ptr, Point2d[] points, int count) { DelaunayTriangulation2_EIK_GetPoints(ptr, points, count); } internal override void GetIndices(IntPtr ptr, int[] indices, int count) { DelaunayTriangulation2_EIK_GetIndices(ptr, indices, count); } internal override bool GetVertex(IntPtr ptr, int index, out TriVertex2 vertex) { return DelaunayTriangulation2_EIK_GetVertex(ptr, index, out vertex); } internal override void GetVertices(IntPtr ptr, TriVertex2[] vertices, int count) { DelaunayTriangulation2_EIK_GetVertices(ptr, vertices, count); } internal override bool GetFace(IntPtr ptr, int index, out TriFace2 face) { return DelaunayTriangulation2_EIK_GetFace(ptr, index, out face); } internal override bool GetSegment(IntPtr ptr, int faceIndex, int neighbourIndex, out Segment2d segment) { return DelaunayTriangulation2_EIK_GetSegment(ptr, faceIndex, neighbourIndex, out segment); } internal override bool GetTriangle(IntPtr ptr, int faceIndex, out Triangle2d triangle) { return DelaunayTriangulation2_EIK_GetTriangle(ptr, faceIndex, out triangle); } internal override void GetTriangles(IntPtr ptr, Triangle2d[] triangles, int count) { DelaunayTriangulation2_EIK_GetTriangles(ptr, triangles, count); } internal override bool GetCircumcenter(IntPtr ptr, int faceIndex, out Point2d circumcenter) { return DelaunayTriangulation2_EIK_GetCircumcenter(ptr, faceIndex, out circumcenter); } internal override void GetCircumcenters(IntPtr ptr, [Out] Point2d[] circumcenters, int count) { DelaunayTriangulation2_EIK_GetCircumcenters(ptr, circumcenters, count); } internal override void GetFaces(IntPtr ptr, TriFace2[] faces, int count) { DelaunayTriangulation2_EIK_GetFaces(ptr, faces, count); } internal override int NeighbourIndex(IntPtr ptr, int faceIndex, int index) { return DelaunayTriangulation2_EIK_NeighbourIndex(ptr, faceIndex, index); } internal override bool LocateFace(IntPtr ptr, Point2d point, out TriFace2 face) { return DelaunayTriangulation2_EIK_LocateFace(ptr, point, out face); } internal override bool MoveVertex(IntPtr ptr, int index, Point2d point, bool ifNoCollision, out TriVertex2 vertex) { return DelaunayTriangulation2_EIK_MoveVertex(ptr, index, point, ifNoCollision, out vertex); } internal override bool RemoveVertex(IntPtr ptr, int index) { return DelaunayTriangulation2_EIK_RemoveVertex(ptr, index); } internal override bool FlipEdge(IntPtr ptr, int faceIndex, int neighbour) { return DelaunayTriangulation2_EIK_FlipEdge(ptr, faceIndex, neighbour); } //Delaunay only internal override int VoronoiSegmentCount(IntPtr ptr) { return DelaunayTriangulation2_EIK_VoronoiSegmentCount(ptr); } internal override int VoronoiRayCount(IntPtr ptr) { return DelaunayTriangulation2_EIK_VoronoiRayCount(ptr); } internal override void GetVoronoiSegments(IntPtr ptr, Segment2d[] segments, int count) { DelaunayTriangulation2_EIK_GetVoronoiSegments(ptr, segments, count); } internal override void GetVoronoiRays(IntPtr ptr, Ray2d[] rays, int count) { DelaunayTriangulation2_EIK_GetVoronoiRays(ptr, rays, count); } internal override void VoronoiCount(IntPtr ptr, out int numSegments, out int numRays) { DelaunayTriangulation2_EIK_VoronoiCount(ptr, out numSegments, out numRays); } internal override void Transform(IntPtr ptr, Point2d translation, double rotation, double scale) { DelaunayTriangulation2_EIK_Transform(ptr, translation, rotation, scale); } [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr DelaunayTriangulation2_EIK_Create(); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void DelaunayTriangulation2_EIK_Release(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void DelaunayTriangulation2_EIK_Clear(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr DelaunayTriangulation2_EIK_Copy(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void DelaunayTriangulation2_EIK_SetIndices(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int DelaunayTriangulation2_EIK_BuildStamp(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool DelaunayTriangulation2_EIK_IsValid(IntPtr ptr, int level); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int DelaunayTriangulation2_EIK_VertexCount(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int DelaunayTriangulation2_EIK_FaceCount(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void DelaunayTriangulation2_EIK_InsertPoint(IntPtr ptr, Point2d point); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void DelaunayTriangulation2_EIK_InsertPoints(IntPtr ptr, [In] Point2d[] points, int count); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void DelaunayTriangulation2_EIK_InsertPolygon(IntPtr triPtr, IntPtr polyPtr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void DelaunayTriangulation2_EIK_InsertPolygonWithHoles(IntPtr triPtr, IntPtr pwhPtr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void DelaunayTriangulation2_EIK_GetPoints(IntPtr ptr, [Out] Point2d[] points, int count); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void DelaunayTriangulation2_EIK_GetIndices(IntPtr ptr, [Out] int[] indices, int count); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool DelaunayTriangulation2_EIK_GetVertex(IntPtr ptr, int index, [Out] out TriVertex2 vertex); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void DelaunayTriangulation2_EIK_GetVertices(IntPtr ptr, [Out] TriVertex2[] vertices, int count); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool DelaunayTriangulation2_EIK_GetFace(IntPtr ptr, int index, [Out] out TriFace2 triFace); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void DelaunayTriangulation2_EIK_GetFaces(IntPtr ptr, [Out] TriFace2[] faces, int count); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool DelaunayTriangulation2_EIK_GetSegment(IntPtr ptr, int faceIndex, int neighbourIndex, [Out] out Segment2d segment); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool DelaunayTriangulation2_EIK_GetTriangle(IntPtr ptr, int faceIndex, [Out] out Triangle2d triangle); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void DelaunayTriangulation2_EIK_GetTriangles(IntPtr ptr, [Out] Triangle2d[] triangles, int count); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool DelaunayTriangulation2_EIK_GetCircumcenter(IntPtr ptr, int faceIndex, [Out] out Point2d circumcenter); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void DelaunayTriangulation2_EIK_GetCircumcenters(IntPtr ptr, [Out] Point2d[] circumcenters, int count); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int DelaunayTriangulation2_EIK_NeighbourIndex(IntPtr ptr, int faceIndex, int index); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool DelaunayTriangulation2_EIK_LocateFace(IntPtr ptr, Point2d point, [Out] out TriFace2 face); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool DelaunayTriangulation2_EIK_MoveVertex(IntPtr ptr, int index, Point2d point, bool ifNoCollision, [Out] out TriVertex2 vertex); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool DelaunayTriangulation2_EIK_RemoveVertex(IntPtr ptr, int index); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool DelaunayTriangulation2_EIK_FlipEdge(IntPtr ptr, int faceIndex, int neighbour); //Delaunay only [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int DelaunayTriangulation2_EIK_VoronoiSegmentCount(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int DelaunayTriangulation2_EIK_VoronoiRayCount(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void DelaunayTriangulation2_EIK_GetVoronoiSegments(IntPtr ptr, [Out] Segment2d[] segments, int count); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void DelaunayTriangulation2_EIK_GetVoronoiRays(IntPtr ptr, [Out] Ray2d[] rays, int count); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void DelaunayTriangulation2_EIK_VoronoiCount(IntPtr ptr, [Out] out int numSegments, [Out] out int numRays); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void DelaunayTriangulation2_EIK_Transform(IntPtr ptr, Point2d translation, double rotation, double scale); } } ================================================ FILE: CGALDotNet/Triangulations/DelaunayTriangulationKernel3.cs ================================================ using System; using System.Collections.Generic; using System.Text; using CGALDotNetGeometry.Numerics; namespace CGALDotNet.Triangulations { internal abstract class DelaunayTriangulationKernel3 : BaseTriangulationKernel3 { internal abstract bool Move(IntPtr ptr, int index, Point3d point, bool ifNoCollision); internal abstract int NearestVertex(IntPtr ptr, Point3d point); internal abstract int NearestVertexInCell(IntPtr ptr, int index, Point3d point); internal abstract bool RemoveVertex(IntPtr ptr, int index); } } ================================================ FILE: CGALDotNet/Triangulations/DelaunayTriangulationKernel3_EEK.cs ================================================ using System; using System.Collections.Generic; using System.Text; using System.Runtime.InteropServices; using CGALDotNetGeometry.Numerics; using CGALDotNetGeometry.Shapes; namespace CGALDotNet.Triangulations { internal class DelaunayTriangulationKernel3_EEK : DelaunayTriangulationKernel3 { internal override string Name => "EEK"; internal static readonly DelaunayTriangulationKernel3 Instance = new DelaunayTriangulationKernel3_EEK(); internal override IntPtr Create() { return DelaunayTriangulation3_EEK_Create(); } internal override void Release(IntPtr ptr) { DelaunayTriangulation3_EEK_Release(ptr); } internal override void Clear(IntPtr ptr) { DelaunayTriangulation3_EEK_Clear(ptr); } internal override IntPtr Copy(IntPtr ptr) { return DelaunayTriangulation3_EEK_Copy(ptr); } internal override int BuildStamp(IntPtr ptr) { return DelaunayTriangulation3_EEK_BuildStamp(ptr); } internal override int Dimension(IntPtr ptr) { return DelaunayTriangulation3_EEK_Dimension(ptr); } internal override bool IsValid(IntPtr ptr, bool verbose) { return DelaunayTriangulation3_EEK_IsValid(ptr, verbose); } internal override int VertexCount(IntPtr ptr) { return DelaunayTriangulation3_EEK_VertexCount(ptr); } internal override int FiniteVertexCount(IntPtr ptr) { return DelaunayTriangulation3_EEK_FiniteVertexCount(ptr); } internal override int CellCount(IntPtr ptr) { return DelaunayTriangulation3_EEK_CellCount(ptr); } internal override int FiniteCellCount(IntPtr ptr) { return DelaunayTriangulation3_EEK_FiniteCellCount(ptr); } internal override int EdgeCount(IntPtr ptr) { return DelaunayTriangulation3_EEK_EdgeCount(ptr); } internal override int FiniteEdgeCount(IntPtr ptr) { return DelaunayTriangulation3_EEK_FiniteEdgeCount(ptr); } internal override int FacetCount(IntPtr ptr) { return DelaunayTriangulation3_EEK_FacetCount(ptr); } internal override int FiniteFacetCount(IntPtr ptr) { return DelaunayTriangulation3_EEK_FiniteFacetCount(ptr); } internal override void InsertPoint(IntPtr ptr, Point3d point) { DelaunayTriangulation3_EEK_InsertPoint(ptr, point); } internal override void InsertPoints(IntPtr ptr, Point3d[] points, int count) { DelaunayTriangulation3_EEK_InsertPoints(ptr, points, count); } internal override void InsertInCell(IntPtr ptr, int index, Point3d point) { DelaunayTriangulation3_EEK_InsertInCell(ptr, index, point); } internal override int Locate(IntPtr ptr, Point3d point) { return DelaunayTriangulation3_EEK_Locate(ptr, point); } internal override void GetCircumcenters(IntPtr ptr, Point3d[] Circumcenters, int count) { DelaunayTriangulation3_EEK_GetCircumcenters(ptr, Circumcenters, count); } internal override void GetPoints(IntPtr ptr, Point3d[] points, int count) { DelaunayTriangulation3_EEK_GetPoints(ptr, points, count); } internal override void GetVertices(IntPtr ptr, TriVertex3[] vertices, int count) { DelaunayTriangulation3_EEK_GetVertices(ptr, vertices, count); } internal override bool GetVertex(IntPtr ptr, int index, out TriVertex3 vertex) { return DelaunayTriangulation3_EEK_GetVertex(ptr, index, out vertex); } internal override void GetCells(IntPtr ptr, TriCell3[] cells, int count) { DelaunayTriangulation3_EEK_GetCells(ptr, cells, count); } internal override bool GetCell(IntPtr ptr, int index, out TriCell3 cell) { return DelaunayTriangulation3_EEK_GetCell(ptr, index, out cell); } internal override void GetSegmentIndices(IntPtr ptr, int[] indices, int count) { DelaunayTriangulation3_EEK_GetSegmentIndices(ptr, indices, count); } internal override void GetTriangleIndices(IntPtr ptr, int[] indices, int count) { DelaunayTriangulation3_EEK_GetTriangleIndices(ptr, indices, count); } internal override void GetTetrahedraIndices(IntPtr ptr, int[] indices, int count) { DelaunayTriangulation3_EEK_GetTetrahedraIndices(ptr, indices, count); } internal override void GetSegments(IntPtr ptr, Segment3d[] indices, int count) { DelaunayTriangulation3_EEK_GetSegments(ptr, indices, count); } internal override void GetTriangles(IntPtr ptr, Triangle3d[] indices, int count) { DelaunayTriangulation3_EEK_GetTriangles(ptr, indices, count); } internal override void GetTetrahedrons(IntPtr ptr, Tetrahedron3d[] indices, int count) { DelaunayTriangulation3_EEK_GetTetrahedrons(ptr, indices, count); } internal override void Transform(IntPtr ptr, Matrix4x4d matrix) { DelaunayTriangulation3_EEK_Transform(ptr, matrix); } internal override bool Move(IntPtr ptr, int index, Point3d point, bool ifNoCollision) { return DelaunayTriangulation3_EEK_Move(ptr, index, point, ifNoCollision); } internal override int NearestVertex(IntPtr ptr, Point3d point) { return DelaunayTriangulation3_EEK_NearestVertex(ptr, point); } internal override int NearestVertexInCell(IntPtr ptr, int index, Point3d point) { return NearestVertexInCell(ptr, index, point); } internal override bool RemoveVertex(IntPtr ptr, int index) { return DelaunayTriangulation3_EEK_RemoveVertex (ptr, index); } [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr DelaunayTriangulation3_EEK_Create(); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void DelaunayTriangulation3_EEK_Release(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void DelaunayTriangulation3_EEK_Clear(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr DelaunayTriangulation3_EEK_Copy(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int DelaunayTriangulation3_EEK_BuildStamp(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int DelaunayTriangulation3_EEK_Dimension(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool DelaunayTriangulation3_EEK_IsValid(IntPtr ptr, bool verbose); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int DelaunayTriangulation3_EEK_VertexCount(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int DelaunayTriangulation3_EEK_FiniteVertexCount(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int DelaunayTriangulation3_EEK_CellCount(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int DelaunayTriangulation3_EEK_FiniteCellCount(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int DelaunayTriangulation3_EEK_EdgeCount(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int DelaunayTriangulation3_EEK_FiniteEdgeCount(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int DelaunayTriangulation3_EEK_FacetCount(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int DelaunayTriangulation3_EEK_FiniteFacetCount(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void DelaunayTriangulation3_EEK_InsertPoint(IntPtr ptr, Point3d point); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void DelaunayTriangulation3_EEK_InsertPoints(IntPtr ptr, Point3d[] points, int count); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void DelaunayTriangulation3_EEK_InsertInCell(IntPtr ptr, int index, Point3d point); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int DelaunayTriangulation3_EEK_Locate(IntPtr ptr, Point3d point); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void DelaunayTriangulation3_EEK_GetCircumcenters(IntPtr ptr, [Out] Point3d[] Circumcenters, int count); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void DelaunayTriangulation3_EEK_GetPoints(IntPtr ptr, [Out] Point3d[] points, int count); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void DelaunayTriangulation3_EEK_GetVertices(IntPtr ptr, [Out] TriVertex3[] vertices, int count); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool DelaunayTriangulation3_EEK_GetVertex(IntPtr ptr, int index, [Out] out TriVertex3 vertex); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void DelaunayTriangulation3_EEK_GetCells(IntPtr ptr, [Out] TriCell3[] cells, int count); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool DelaunayTriangulation3_EEK_GetCell(IntPtr ptr, int index, out TriCell3 cell); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void DelaunayTriangulation3_EEK_GetSegmentIndices(IntPtr ptr, [Out] int[] indices, int count); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void DelaunayTriangulation3_EEK_GetTriangleIndices(IntPtr ptr, [Out] int[] indices, int count); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void DelaunayTriangulation3_EEK_GetTetrahedraIndices(IntPtr ptr, [Out] int[] indices, int count); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void DelaunayTriangulation3_EEK_GetSegments(IntPtr ptr, [Out] Segment3d[] segments, int count); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void DelaunayTriangulation3_EEK_GetTriangles(IntPtr ptr, [Out] Triangle3d[] triangles, int count); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void DelaunayTriangulation3_EEK_GetTetrahedrons(IntPtr ptr, [Out] Tetrahedron3d[] Tetrahedrons, int count); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void DelaunayTriangulation3_EEK_Transform(IntPtr ptr, Matrix4x4d matrix); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool DelaunayTriangulation3_EEK_Move(IntPtr ptr, int index, Point3d point, bool ifNoCollision); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int DelaunayTriangulation3_EEK_NearestVertex(IntPtr ptr, Point3d point); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int DelaunayTriangulation3_EEK_NearestVertexInCell(IntPtr ptr, int index, Point3d point); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool DelaunayTriangulation3_EEK_RemoveVertex(IntPtr ptr, int index); } } ================================================ FILE: CGALDotNet/Triangulations/TriCell3.cs ================================================ using System; using System.Collections.Generic; using System.Runtime.InteropServices; using System.Text; using CGALDotNetGeometry.Numerics; namespace CGALDotNet.Triangulations { /// /// From Index to HalfEdgeIndex must match layout /// of the unmanaged TriFace2 in the TriFace2 header file. /// [StructLayout(LayoutKind.Sequential)] public unsafe struct TriCell3 : IEquatable { /// /// Is this the infinite cell. /// public bool IsInfinite; /// /// The cells index in the triangulation. /// public int Index; /// /// The cells 4 vertices. /// private fixed int VertexIndices[4]; /// /// The cells 4 neighbor cells. /// private fixed int NeighborIndices[4]; /// /// /// /// public override string ToString() { return string.Format("[TriCell2: Index={0}, IsInfinite={1}, Vertex0={2}, Vertex1={3}, Vertex2={4}, Vertex3={5}]", Index, IsInfinite, VertexIndices[0], VertexIndices[1], VertexIndices[2], VertexIndices[3]); } /// /// Are the two cells equal. /// /// The first cell. /// The second cell. /// True if the cells are equal. public static bool operator ==(TriCell3 f1, TriCell3 f2) { return f1.Index == f2.Index && f1.IsInfinite == f2.IsInfinite && VerticesEqual(f1, f2) && NeighborEqual(f1, f2); } /// /// Are the two cells not equal. /// /// The first cell. /// The second cell. /// True if the cells are not equal. public static bool operator !=(TriCell3 f1, TriCell3 f2) { return f1.Index != f2.Index || f1.IsInfinite != f2.IsInfinite || !VerticesEqual(f1, f2) || !NeighborEqual(f1, f2); } /// /// Are these objects equal. /// /// The other object. /// True if the objects are equal. public override bool Equals(object obj) { if (!(obj is TriCell3)) return false; TriCell3 v = (TriCell3)obj; return this == v; } /// /// Are these cells equal. /// /// The other cell. /// True if the cells are equal. public bool Equals(TriCell3 cell) { return this == cell; } /// /// The cells hash code. /// /// The cells hash code. public override int GetHashCode() { unchecked { int hash = (int)MathUtil.HASH_PRIME_1; hash = (hash * MathUtil.HASH_PRIME_2) ^ Index.GetHashCode(); hash = (hash * MathUtil.HASH_PRIME_2) ^ IsInfinite.GetHashCode(); for(int i = 0; i < 4; i++) hash = (hash * MathUtil.HASH_PRIME_2) ^ VertexIndices[i].GetHashCode(); for (int i = 0; i < 4; i++) hash = (hash * MathUtil.HASH_PRIME_2) ^ NeighborIndices[i].GetHashCode(); return hash; } } /// /// Get a vertex index. /// /// The vertices index 0-3. /// The vertices index in the triangulation. public int GetVertexIndex(int i) { if (i < 0 || i >= 4) throw new ArgumentOutOfRangeException(i + "out of range."); return VertexIndices[i]; } /// /// Get a neighbor cell index. /// /// The neighbor cell index 0-3. /// A neighbor cell index in the triangulation. public int GetNeighborIndex(int i) { if (i < 0 || i >= 4) throw new ArgumentOutOfRangeException(i + "out of range."); return NeighborIndices[i]; } /// /// Enumerate the vertices of the cell. /// /// The triangle the vertices below too. /// The cell vertices. public IEnumerable EnumerateVertices(BaseTriangulation3 tri) { for (int i = 0; i < 4; i++) { if (tri.GetVertex(i, out TriVertex3 v)) { yield return v; } } } /// /// Enumerate the vertices of the cell. /// /// The vertices array. /// The cell vertices. public IEnumerable EnumerateVertices(TriVertex3[] vertices) { for (int i = 0; i < 4; i++) { int index = GetVertexIndex(i); if (index != CGALGlobal.NULL_INDEX) { yield return vertices[index]; } } } /// /// Enumerate the vertices of the cell. /// /// The triangle the vertices below too. /// The cell vertices. public IEnumerable EnumerateNeighbors(BaseTriangulation3 tri) { for (int i = 0; i < 4; i++) { if (tri.GetCell(i, out TriCell3 c)) { yield return c; } } } /// /// Enumerate the neighbors of the cell. /// /// The cell array. /// The cell neighbors. public IEnumerable EnumerateNeighbors(TriCell3[] cells) { for (int i = 0; i < 4; i++) { int index = GetNeighborIndex(i); if (index != CGALGlobal.NULL_INDEX) { yield return cells[index]; } } } /// /// Are the two vertex arrays equal. /// /// /// /// public static bool VerticesEqual(TriCell3 c1, TriCell3 c2) { for (int i = 0; i < 4; i++) { if (c1.VertexIndices[i] != c2.VertexIndices[i]) return false; } return true; } /// /// Are the two neighbor arrays equal. /// /// /// /// public static bool NeighborEqual(TriCell3 c1, TriCell3 c2) { for (int i = 0; i < 4; i++) { if (c1.NeighborIndices[i] != c2.NeighborIndices[i]) return false; } return true; } } } ================================================ FILE: CGALDotNet/Triangulations/TriEdge2.cs ================================================ using System; using System.Collections.Generic; using System.Runtime.InteropServices; using CGALDotNetGeometry.Numerics; using CGALDotNetGeometry.Shapes; namespace CGALDotNet.Triangulations { /// /// From Index to TwinIndex must match layout /// of the unmanaged TriEdge2 in the TriEdge2 header file. /// [StructLayout(LayoutKind.Sequential)] public struct TriEdge2 : IEquatable { /// /// The edges face index in the triangulation. /// public int FaceIndex; /// /// The neighbours index in the face array betwen 0 and 2. /// public int NeighbourIndex; /// /// The edges segment. /// public Segment2d Segment; /// /// /// /// The face index in the triangulation /// The neighbours index in the face array betwen 0 and 2. public TriEdge2(int faceIndex, int neighbourIndex) { FaceIndex = faceIndex; NeighbourIndex = neighbourIndex; Segment = new Segment2d(); } public override string ToString() { return string.Format("[TriEdge2: FaceIndex={0}, NeighbourIndex={1}]", FaceIndex, NeighbourIndex); } /// /// Are the two edges equal. /// /// The first edge. /// The second edge. /// True if the edges are equal. public static bool operator ==(TriEdge2 e1, TriEdge2 e2) { return e1.FaceIndex == e2.FaceIndex && e1.NeighbourIndex == e2.NeighbourIndex; } /// /// Are the two edges not equal. /// /// The first edge. /// The second edge. /// True if the edges are not equal. public static bool operator !=(TriEdge2 e1, TriEdge2 e2) { return e1.FaceIndex != e2.FaceIndex || e1.NeighbourIndex != e2.NeighbourIndex; } /// /// Are these objects equal. /// /// The other object. /// True if the objects are equal. public override bool Equals(object obj) { if (!(obj is TriEdge2)) return false; TriEdge2 v = (TriEdge2)obj; return this == v; } /// /// Are these edges equal. /// /// The other edge. /// True if the edges are equal. public bool Equals(TriEdge2 edge) { return this == edge; } /// /// The edges hash code. /// /// The edges hash code. public override int GetHashCode() { unchecked { int hash = (int)MathUtil.HASH_PRIME_1; hash = (hash * MathUtil.HASH_PRIME_2) ^ FaceIndex.GetHashCode(); hash = (hash * MathUtil.HASH_PRIME_2) ^ NeighbourIndex.GetHashCode(); return hash; } } } } ================================================ FILE: CGALDotNet/Triangulations/TriFace2.cs ================================================ using System; using System.Collections.Generic; using System.Runtime.InteropServices; using System.Text; using CGALDotNetGeometry.Numerics; namespace CGALDotNet.Triangulations { /// /// From Index to HalfEdgeIndex must match layout /// of the unmanaged TriFace2 in the TriFace2 header file. /// [StructLayout(LayoutKind.Sequential)] public unsafe struct TriFace2 : IEquatable { /// /// Is this the infinite face. /// public bool IsInfinite; /// /// The faces index in the triangulation. /// public int Index; /// /// The faces 3 vertices. /// private fixed int VertexIndex[3]; /// /// /// /// public override string ToString() { return string.Format("[TriFace2: Index={0}, IsInfinite={1}, Vertex0={2}, Vertex1={3}, Vertex2={4}]", Index, IsInfinite, VertexIndex[0], VertexIndex[1], VertexIndex[2]); } /// /// Are the two faces equal. /// /// The first face. /// The second face. /// True if the faces are equal. public static bool operator ==(TriFace2 f1, TriFace2 f2) { return f1.Index == f2.Index && f1.IsInfinite == f2.IsInfinite && f1.VertexIndex[0] == f2.VertexIndex[0] && f1.VertexIndex[1] == f2.VertexIndex[1] && f1.VertexIndex[2] == f2.VertexIndex[2]; } /// /// Are the two faces not equal. /// /// The first face. /// The second face. /// True if the faces are not equal. public static bool operator !=(TriFace2 f1, TriFace2 f2) { return f1.Index != f2.Index || f1.IsInfinite != f2.IsInfinite || f1.VertexIndex[0] != f2.VertexIndex[0] || f1.VertexIndex[1] != f2.VertexIndex[1] || f1.VertexIndex[2] != f2.VertexIndex[2]; } /// /// Are these objects equal. /// /// The other object. /// True if the objects are equal. public override bool Equals(object obj) { if (!(obj is TriFace2)) return false; TriFace2 v = (TriFace2)obj; return this == v; } /// /// Are these faces equal. /// /// The other face. /// True if the faces are equal. public bool Equals(TriFace2 face) { return this == face; } /// /// The faces hash code. /// /// The faces hash code. public override int GetHashCode() { unchecked { int hash = (int)MathUtil.HASH_PRIME_1; hash = (hash * MathUtil.HASH_PRIME_2) ^ Index.GetHashCode(); hash = (hash * MathUtil.HASH_PRIME_2) ^ IsInfinite.GetHashCode(); hash = (hash * MathUtil.HASH_PRIME_2) ^ VertexIndex[0].GetHashCode(); hash = (hash * MathUtil.HASH_PRIME_2) ^ VertexIndex[1].GetHashCode(); hash = (hash * MathUtil.HASH_PRIME_2) ^ VertexIndex[2].GetHashCode(); return hash; } } /// /// Get a vertex index and wrap around array. /// /// The vertices index wrapped to 0-2. /// The vertices index in the triangulation. public int GetVertexIndex(int i) { i = MathUtil.Wrap(i, 3); return VertexIndex[i]; } /// /// Enumerate the vertices of the face. /// /// The triangle the vertices below too. /// The face vertices. public IEnumerable EnumerateVertices(BaseTriangulation2 tri) { for(int i = 0; i < 3; i++) { if(tri.GetVertex(i, out TriVertex2 v)) { yield return v; } } } /// /// Enumerate the vertices of the face. /// /// The vertices array. /// The face vertices. public IEnumerable EnumerateVertices(TriVertex2[] vertices) { for (int i = 0; i < 3; i++) { int index = GetVertexIndex(i); if (index != CGALGlobal.NULL_INDEX) { yield return vertices[index]; } } } } } ================================================ FILE: CGALDotNet/Triangulations/TriVertex2.cs ================================================ using System; using System.Collections.Generic; using System.Runtime.InteropServices; using System.Text; using CGALDotNetGeometry.Numerics; namespace CGALDotNet.Triangulations { /// /// From Point to HalfEdgeIndex must match layout /// of the unmanaged TriVertex2 in the TriVertex2 header file. /// [StructLayout(LayoutKind.Sequential)] public struct TriVertex2 : IEquatable { /// /// The vertices point. /// public Point2d Point; /// /// Is this a infinite vertex. /// public bool IsInfinite; /// /// The number of egdes connected to the vertex. /// public int Degree; /// /// The vertices index in the triangulation. /// public int Index; /// /// The one of the vertexs the vertex is connected to. /// public int FaceIndex; public override string ToString() { return string.Format("[TriVertex2: Index={0}, Point={1}, IsInfinite={2}, Degree={3}, Face={4}]", Index, Point, IsInfinite, Degree, FaceIndex); } /// /// Are the two vertexs equal. /// /// The first vertex. /// The second vertex. /// True if the vertexs are equal. public static bool operator ==(TriVertex2 v1, TriVertex2 v2) { return v1.Index == v2.Index && v1.IsInfinite == v2.IsInfinite && v1.Degree == v2.Degree && v1.FaceIndex == v2.FaceIndex && v1.Point == v2.Point; } /// /// Are the two vertexs not equal. /// /// The first vertex. /// The second vertex. /// True if the vertexs are not equal. public static bool operator !=(TriVertex2 v1, TriVertex2 v2) { return v1.Index != v2.Index || v1.IsInfinite != v2.IsInfinite || v1.Degree != v2.Degree || v1.FaceIndex != v2.FaceIndex || v1.Point != v2.Point; } /// /// Are these objects equal. /// /// The other object. /// True if the objects are equal. public override bool Equals(object obj) { if (!(obj is TriVertex2)) return false; TriVertex2 v = (TriVertex2)obj; return this == v; } /// /// Are these vertexs equal. /// /// The other vertex. /// True if the vertexs are equal. public bool Equals(TriVertex2 vertex) { return this == vertex; } /// /// The vertexs hash code. /// /// The vertexs hash code. public override int GetHashCode() { unchecked { int hash = (int)MathUtil.HASH_PRIME_1; hash = (hash * MathUtil.HASH_PRIME_2) ^ Index.GetHashCode(); hash = (hash * MathUtil.HASH_PRIME_2) ^ IsInfinite.GetHashCode(); hash = (hash * MathUtil.HASH_PRIME_2) ^ FaceIndex.GetHashCode(); hash = (hash * MathUtil.HASH_PRIME_2) ^ Degree.GetHashCode(); hash = (hash * MathUtil.HASH_PRIME_2) ^ Point.GetHashCode(); return hash; } } } } ================================================ FILE: CGALDotNet/Triangulations/TriVertex3.cs ================================================ using System; using System.Collections.Generic; using System.Runtime.InteropServices; using System.Text; using CGALDotNetGeometry.Numerics; namespace CGALDotNet.Triangulations { /// /// /// [StructLayout(LayoutKind.Sequential)] public struct TriVertex3 : IEquatable { /// /// The vertices point. /// public Point3d Point; /// /// Is this a infinte vertex. /// public bool IsInfinite; /// /// The vertices degree is the /// number of edges connecting to it. /// public int Degree; /// /// The vertices index in the triangulation. /// public int Index; /// /// The one of the cells the vertex is connected to. /// public int CellIndex; public override string ToString() { return string.Format("[TriVertex3: Index={0}, Point={1}, IsInfinite={2}, Degree={3}, CellIndex={4}]", Index, Point, IsInfinite, Degree, CellIndex); } /// /// Are the two vertices equal. /// /// The first vertex. /// The second vertex. /// True if the vertexs are equal. public static bool operator ==(TriVertex3 v1, TriVertex3 v2) { return v1.Index == v2.Index && v1.IsInfinite == v2.IsInfinite && v1.Degree == v2.Degree && v1.CellIndex == v2.CellIndex && v1.Point == v2.Point; } /// /// Are the two vertices not equal. /// /// The first vertex. /// The second vertex. /// True if the vertexs are not equal. public static bool operator !=(TriVertex3 v1, TriVertex3 v2) { return v1.Index != v2.Index || v1.IsInfinite != v2.IsInfinite || v1.Degree != v2.Degree || v1.CellIndex != v2.CellIndex || v1.Point != v2.Point; } /// /// Are these objects equal. /// /// The other object. /// True if the objects are equal. public override bool Equals(object obj) { if (!(obj is TriVertex3)) return false; TriVertex3 v = (TriVertex3)obj; return this == v; } /// /// Are these vertexs equal. /// /// The other vertex. /// True if the vertexs are equal. public bool Equals(TriVertex3 vertex) { return this == vertex; } /// /// The vertexs hash code. /// /// The vertexs hash code. public override int GetHashCode() { unchecked { int hash = (int)MathUtil.HASH_PRIME_1; hash = (hash * MathUtil.HASH_PRIME_2) ^ IsInfinite.GetHashCode(); hash = (hash * MathUtil.HASH_PRIME_2) ^ Degree.GetHashCode(); hash = (hash * MathUtil.HASH_PRIME_2) ^ Index.GetHashCode(); hash = (hash * MathUtil.HASH_PRIME_2) ^ CellIndex.GetHashCode(); hash = (hash * MathUtil.HASH_PRIME_2) ^ Point.GetHashCode(); return hash; } } /// /// Enumerate around all the other vertices in this vertexs cell. /// /// The triangulation the vertex belongs to. /// All the other vertices in this vertexs cell public IEnumerable EnumerateVertices(BaseTriangulation3 tri) { if (tri.GetCell(CellIndex, out TriCell3 c)) { for (int i = 0; i < 4; i++) { int index = c.GetVertexIndex(i); if (index != Index && tri.GetVertex(index, out TriVertex3 v)) { yield return v; } } } } /// /// Enumerate around all the other vertices in this vertexs cell. /// /// A array of the other vertices in the triangulation. /// A array of the other cells in the triangulation. /// All the other vertices in this vertexs cell public IEnumerable EnumerateVertices(TriVertex3[] vertices, TriCell3[] cells) { if (CellIndex == CGALGlobal.NULL_INDEX) yield break; var c = cells[CellIndex]; for (int i = 0; i < 4; i++) { int index = c.GetVertexIndex(i); if (index == CGALGlobal.NULL_INDEX || index == Index) continue; yield return vertices[index]; } } } } ================================================ FILE: CGALDotNet/Triangulations/Triangulation2.cs ================================================ using System; using System.Collections.Generic; using System.Text; using CGALDotNetGeometry.Numerics; using CGALDotNet.Polygons; using CGALDotNet.Hulls; namespace CGALDotNet.Triangulations { /// /// Generic triangulation class. /// /// The kerel. public sealed class Triangulation2 : Triangulation2 where K : CGALKernel, new() { /// /// Static instance of a triangulation. /// public static readonly Triangulation2 Instance = new Triangulation2(); /// /// Default constructor. /// public Triangulation2() : base(new K()) { } /// /// Construct a triangulation from the points. /// /// The triangulation points. public Triangulation2(Point2d[] points) : base(new K(), points) { } /// /// Construct from a existing triangulation. /// /// A pointer to the unmanaged object. internal Triangulation2(IntPtr ptr) : base(new K(), ptr) { } /// /// The triangulation as a string. /// /// public override string ToString() { return string.Format("[Triangulation2<{0}>: VertexCount={1}, TriangleCount={2}]", Kernel.Name, VertexCount, TriangleCount); } /// /// Create a deep copy of the triangulation. /// /// The deep copy. public Triangulation2 Copy() { return new Triangulation2(Kernel.Copy(Ptr)); } /// /// Insert the points of the polygon into the triagulation. /// May no have the same edges as polygon. /// /// The polygon to insert/ public void InsertPolygon(Polygon2 polygon) { if (polygon == null) return; Kernel.InsertPolygon(Ptr, polygon.Ptr); } /// /// Insert the points of the polygon into the triagulation. /// May no have the same edges as polygon. /// /// The polygon to insert/ public void InsertPolygon(PolygonWithHoles2 pwh) { if (pwh == null) return; Kernel.InsertPolygonWithHoles(Ptr, pwh.Ptr); } /// /// Compute the convex of the triagulation. /// /// The convex hull polygon. /// public Polygon2 ComputeHull() { int count = VertexCount; if (count < 3) throw new InvalidOperationException("Trianglution must have at least 3 points to compute the hull."); var points = ArrayCache.Point2dArray(count); GetPoints(points, count); var hull = ConvexHull2.Instance; return hull.CreateHull(points, count); } } /// /// Abstract base class for the triagulation. /// public abstract class Triangulation2 : BaseTriangulation2 { /// /// /// /// internal Triangulation2(CGALKernel kernel) : base(kernel.TriangulationKernel2) { TriangulationKernel = Kernel as TriangulationKernel2; } /// /// /// /// /// internal Triangulation2(CGALKernel kernel, Point2d[] points) : base(kernel.TriangulationKernel2, points) { TriangulationKernel = Kernel as TriangulationKernel2; } /// /// /// /// /// internal Triangulation2(CGALKernel kernel, IntPtr ptr) : base(kernel.TriangulationKernel2, ptr) { TriangulationKernel = Kernel as TriangulationKernel2; } /// /// The kernel with the functions unique to the triangulation. /// protected private TriangulationKernel2 TriangulationKernel { get; private set; } /// /// Move the vertex. /// /// /// /// If there is not already another vertex placed on the point, /// the triangulation is modified such that the new position of vertex same as point. /// The moved vertex /// True if the vertex was found. public bool MoveVertex(int index, Point2d point, bool ifNoCollision, out TriVertex2 vertex) { return TriangulationKernel.MoveVertex(Ptr, index, point, ifNoCollision, out vertex); } /// /// /// /// public override void Print(StringBuilder builder) { builder.AppendLine(ToString()); builder.AppendLine("IsValid = " + IsValid()); builder.AppendLine("BuildStamp = " + BuildStamp); builder.AppendLine("VertexCount = " + VertexCount); builder.AppendLine("TriangleCount = " + TriangleCount); builder.AppendLine("IndiceCount = " + IndiceCount); } } } ================================================ FILE: CGALDotNet/Triangulations/Triangulation3.cs ================================================ using System; using System.Collections.Generic; using System.Text; using CGALDotNetGeometry.Numerics; using CGALDotNetGeometry.Extensions; using CGALDotNet.Meshing; using CGALDotNet.Hulls; using CGALDotNet.Polyhedra; namespace CGALDotNet.Triangulations { /// /// Generic triangulation class. /// /// The kerel. public sealed class Triangulation3 : Triangulation3 where K : CGALKernel, new() { /// /// Static instance of a triangulation. /// public static readonly Triangulation3 Instance = new Triangulation3(); /// /// Default constructor. /// public Triangulation3() : base(new K()) { } /// /// Construct a triangulation from the points. /// /// The triangulation points. public Triangulation3(Point3d[] points) : base(new K(), points) { } /// /// Construct from a existing triangulation. /// /// A pointer to the unmanaged object. internal Triangulation3(IntPtr ptr) : base(new K(), ptr) { } /// /// The triangulation as a string. /// /// public override string ToString() { return string.Format("[Triangulation3<{0}>: VertexCount={1}, TetrahedronCount={2}, TriangleCount={3}]", Kernel.Name, VertexCount, FiniteTetrahedronCount, FiniteTriangleCount); } /// /// Create a deep copy of the triangulation. /// /// The deep copy. public Triangulation3 Copy() { return new Triangulation3(Kernel.Copy(Ptr)); } /// /// Refine the triangulation. /// /// The target edge lengths. /// The number of iterations. public void Refine(double targetEdgeLength, int iterations = 1) { int count = VertexCount; var points = ArrayCache.Point3dArray(count); GetPoints(points, count); var tet = TetrahedralRemeshing.Instance; count = tet.Remesh(targetEdgeLength, iterations, points, count); if (count > 0) { points = ArrayCache.Point3dArray(count); tet.GetPoints(points, count); Clear(); Insert(points, points.Length); } } /// /// Compute the convex of the triagulation. /// /// The convex hull polygon. /// public Polyhedron3 ComputeHull() { int count = VertexCount; if (count < 4) throw new InvalidOperationException("Trianglution must have at least 4 points to compute the hull."); var points = new Point3d[count]; GetPoints(points, count); points = points.RemoveNonFinite().ToArray(); var hull = ConvexHull3.Instance; return hull.CreateHullAsPolyhedron(points, points.Length); } } /// /// Abstract base class for the triagulation. /// public abstract class Triangulation3 : BaseTriangulation3 { /// /// /// /// internal Triangulation3(CGALKernel kernel) : base(kernel.TriangulationKernel3) { TriangulationKernel = Kernel as TriangulationKernel3; } /// /// /// /// /// internal Triangulation3(CGALKernel kernel, Point3d[] points) : base(kernel.TriangulationKernel3, points) { TriangulationKernel = Kernel as TriangulationKernel3; } /// /// /// /// /// internal Triangulation3(CGALKernel kernel, IntPtr ptr) : base(kernel.TriangulationKernel3, ptr) { TriangulationKernel = Kernel as TriangulationKernel3; } /// /// The kernel with the functions unique to the triangulation. /// protected private TriangulationKernel3 TriangulationKernel { get; private set; } /// /// /// /// public override void Print(StringBuilder builder) { builder.AppendLine(ToString()); builder.AppendLine("IsValid = " + IsValid()); builder.AppendLine("Dimension = " + Dimension); builder.AppendLine("VertexCount = " + VertexCount); builder.AppendLine("FiniteVertexCount = " + FiniteVertexCount); builder.AppendLine("TetrahedronCount = " + TetrahedronCount); builder.AppendLine("FiniteTetrahedronCount = " + FiniteTetrahedronCount); builder.AppendLine("EdgeCount = " + EdgeCount); builder.AppendLine("FiniteEdgeCount = " + FiniteEdgeCount); builder.AppendLine("TriangleCount = " + TriangleCount); builder.AppendLine("FiniteTriangleCount = " + FiniteTriangleCount); } } } ================================================ FILE: CGALDotNet/Triangulations/TriangulationKernel2.cs ================================================ using System; using System.Collections.Generic; using System.Text; using CGALDotNetGeometry.Numerics; using CGALDotNet.Polygons; namespace CGALDotNet.Triangulations { internal abstract class TriangulationKernel2 : BaseTriangulationKernel2 { } } ================================================ FILE: CGALDotNet/Triangulations/TriangulationKernel2_EEK.cs ================================================ using System; using System.Collections.Generic; using System.Text; using System.Runtime.InteropServices; using CGALDotNetGeometry.Numerics; using CGALDotNetGeometry.Shapes; namespace CGALDotNet.Triangulations { internal class TriangulationKernel2_EEK : TriangulationKernel2 { internal override string Name => "EEK"; internal static readonly TriangulationKernel2 Instance = new TriangulationKernel2_EEK(); internal override IntPtr Create() { return Triangulation2_EEK_Create(); } internal override void Release(IntPtr ptr) { Triangulation2_EEK_Release(ptr); } internal override void Clear(IntPtr ptr) { Triangulation2_EEK_Clear(ptr); } internal override IntPtr Copy(IntPtr ptr) { return Triangulation2_EEK_Copy(ptr); } internal override void SetIndices(IntPtr ptr) { Triangulation2_EEK_SetIndices(ptr); } internal override int BuildStamp(IntPtr ptr) { return Triangulation2_EEK_BuildStamp(ptr); } internal override bool IsValid(IntPtr ptr, int level) { return Triangulation2_EEK_IsValid(ptr, level); } internal override int VertexCount(IntPtr ptr) { return Triangulation2_EEK_VertexCount(ptr); } internal override int FaceCount(IntPtr ptr) { return Triangulation2_EEK_FaceCount(ptr); } internal override void InsertPoint(IntPtr ptr, Point2d point) { Triangulation2_EEK_InsertPoint(ptr, point); } internal override void InsertPoints(IntPtr ptr, Point2d[] points, int count) { Triangulation2_EEK_InsertPoints(ptr, points, count); } internal override void InsertPolygon(IntPtr triPtr, IntPtr polyPtr) { Triangulation2_EEK_InsertPolygon(triPtr, polyPtr); } internal override void InsertPolygonWithHoles(IntPtr triPtr, IntPtr pwhPtr) { Triangulation2_EEK_InsertPolygonWithHoles(triPtr, pwhPtr); } internal override void GetPoints(IntPtr ptr, Point2d[] points, int count) { Triangulation2_EEK_GetPoints(ptr, points, count); } internal override void GetIndices(IntPtr ptr, int[] indices, int count) { Triangulation2_EEK_GetIndices(ptr, indices, count); } internal override bool GetVertex(IntPtr ptr, int index, out TriVertex2 vertex) { return Triangulation2_EEK_GetVertex(ptr, index, out vertex); } internal override void GetVertices(IntPtr ptr, TriVertex2[] vertices, int count) { Triangulation2_EEK_GetVertices(ptr, vertices, count); } internal override bool GetFace(IntPtr ptr, int index, out TriFace2 face) { return Triangulation2_EEK_GetFace(ptr, index, out face); } internal override void GetFaces(IntPtr ptr, TriFace2[] faces, int count) { Triangulation2_EEK_GetFaces(ptr, faces, count); } internal override bool GetSegment(IntPtr ptr, int faceIndex, int neighbourIndex, out Segment2d segment) { return Triangulation2_EEK_GetSegment(ptr, faceIndex, neighbourIndex, out segment); } internal override bool GetTriangle(IntPtr ptr, int faceIndex, out Triangle2d triangle) { return Triangulation2_EEK_GetTriangle(ptr, faceIndex, out triangle); } internal override void GetTriangles(IntPtr ptr, Triangle2d[] triangles, int count) { Triangulation2_EEK_GetTriangles(ptr, triangles, count); } internal override bool GetCircumcenter(IntPtr ptr, int faceIndex, out Point2d circumcenter) { return Triangulation2_EEK_GetCircumcenter(ptr, faceIndex, out circumcenter); } internal override void GetCircumcenters(IntPtr ptr, [Out] Point2d[] circumcenters, int count) { Triangulation2_EEK_GetCircumcenters(ptr, circumcenters, count); } internal override int NeighbourIndex(IntPtr ptr, int faceIndex, int index) { return Triangulation2_EEK_NeighbourIndex(ptr, faceIndex, index); } internal override bool LocateFace(IntPtr ptr, Point2d point, out TriFace2 face) { return Triangulation2_EEK_LocateFace(ptr, point, out face); } internal override bool MoveVertex(IntPtr ptr, int index, Point2d point, bool ifNoCollision, out TriVertex2 vertex) { return Triangulation2_EEK_MoveVertex(ptr, index, point, ifNoCollision, out vertex); } internal override bool RemoveVertex(IntPtr ptr, int index) { return Triangulation2_EEK_RemoveVertex(ptr, index); } internal override bool FlipEdge(IntPtr ptr, int faceIndex, int neighbour) { return Triangulation2_EEK_FlipEdge(ptr, faceIndex, neighbour); } internal override void Transform(IntPtr ptr, Point2d translation, double rotation, double scale) { Triangulation2_EEK_Transform(ptr, translation, rotation, scale); } [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr Triangulation2_EEK_Create(); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void Triangulation2_EEK_Release(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void Triangulation2_EEK_Clear(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr Triangulation2_EEK_Copy(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void Triangulation2_EEK_SetIndices(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int Triangulation2_EEK_BuildStamp(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool Triangulation2_EEK_IsValid(IntPtr ptr, int level); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int Triangulation2_EEK_VertexCount(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int Triangulation2_EEK_FaceCount(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void Triangulation2_EEK_InsertPoint(IntPtr ptr, Point2d point); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void Triangulation2_EEK_InsertPoints(IntPtr ptr, [In] Point2d[] points, int count); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void Triangulation2_EEK_InsertPolygon(IntPtr triPtr, IntPtr polyPtr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void Triangulation2_EEK_InsertPolygonWithHoles(IntPtr triPtr, IntPtr pwhPtr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void Triangulation2_EEK_GetPoints(IntPtr ptr, [Out] Point2d[] points, int count); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void Triangulation2_EEK_GetIndices(IntPtr ptr, [Out] int[] indices, int count); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool Triangulation2_EEK_GetVertex(IntPtr ptr, int index, [Out] out TriVertex2 vertex); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void Triangulation2_EEK_GetVertices(IntPtr ptr, [Out] TriVertex2[] vertices, int count); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool Triangulation2_EEK_GetFace(IntPtr ptr, int index, [Out] out TriFace2 triFace); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void Triangulation2_EEK_GetFaces(IntPtr ptr, [Out] TriFace2[] faces, int count); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool Triangulation2_EEK_GetSegment(IntPtr ptr, int faceIndex, int neighbourIndex, [Out] out Segment2d segment); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool Triangulation2_EEK_GetTriangle(IntPtr ptr, int faceIndex, [Out] out Triangle2d triangle); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void Triangulation2_EEK_GetTriangles(IntPtr ptr, [Out] Triangle2d[] triangles, int count); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool Triangulation2_EEK_GetCircumcenter(IntPtr ptr, int faceIndex, [Out] out Point2d circumcenter); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void Triangulation2_EEK_GetCircumcenters(IntPtr ptr, [Out] Point2d[] circumcenters, int count); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int Triangulation2_EEK_NeighbourIndex(IntPtr ptr, int faceIndex, int index); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool Triangulation2_EEK_LocateFace(IntPtr ptr, Point2d point, [Out] out TriFace2 face); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool Triangulation2_EEK_MoveVertex(IntPtr ptr, int index, Point2d point, bool ifNoCollision, [Out] out TriVertex2 vertex); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool Triangulation2_EEK_RemoveVertex(IntPtr ptr, int index); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool Triangulation2_EEK_FlipEdge(IntPtr ptr, int faceIndex, int neighbour); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void Triangulation2_EEK_MakeGabriel(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void Triangulation2_EEK_Optimize(IntPtr ptr, int iterations, double angleBounds, double lengthBounds); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void Triangulation2_EEK_Transform(IntPtr ptr, Point2d translation, double rotation, double scale); } } ================================================ FILE: CGALDotNet/Triangulations/TriangulationKernel2_EIK.cs ================================================ using System; using System.Collections.Generic; using System.Text; using System.Runtime.InteropServices; using CGALDotNetGeometry.Numerics; using CGALDotNetGeometry.Shapes; namespace CGALDotNet.Triangulations { internal class TriangulationKernel2_EIK : TriangulationKernel2 { internal override string Name => "EIK"; internal static readonly TriangulationKernel2 Instance = new TriangulationKernel2_EIK(); internal override IntPtr Create() { return Triangulation2_EIK_Create(); } internal override void Release(IntPtr ptr) { Triangulation2_EIK_Release(ptr); } internal override void Clear(IntPtr ptr) { Triangulation2_EIK_Clear(ptr); } internal override IntPtr Copy(IntPtr ptr) { return Triangulation2_EIK_Copy(ptr); } internal override void SetIndices(IntPtr ptr) { Triangulation2_EIK_SetIndices(ptr); } internal override int BuildStamp(IntPtr ptr) { return Triangulation2_EIK_BuildStamp(ptr); } internal override bool IsValid(IntPtr ptr, int level) { return Triangulation2_EIK_IsValid(ptr, level); } internal override int VertexCount(IntPtr ptr) { return Triangulation2_EIK_VertexCount(ptr); } internal override int FaceCount(IntPtr ptr) { return Triangulation2_EIK_FaceCount(ptr); } internal override void InsertPoint(IntPtr ptr, Point2d point) { Triangulation2_EIK_InsertPoint(ptr, point); } internal override void InsertPoints(IntPtr ptr, Point2d[] points, int count) { Triangulation2_EIK_InsertPoints(ptr, points, count); } internal override void InsertPolygon(IntPtr triPtr, IntPtr polyPtr) { Triangulation2_EIK_InsertPolygon(triPtr, polyPtr); } internal override void InsertPolygonWithHoles(IntPtr triPtr, IntPtr pwhPtr) { Triangulation2_EIK_InsertPolygonWithHoles(triPtr, pwhPtr); } internal override void GetPoints(IntPtr ptr, Point2d[] points, int count) { Triangulation2_EIK_GetPoints(ptr, points, count); } internal override void GetIndices(IntPtr ptr, int[] indices, int count) { Triangulation2_EIK_GetIndices(ptr, indices, count); } internal override bool GetVertex(IntPtr ptr, int index, out TriVertex2 vertex) { return Triangulation2_EIK_GetVertex(ptr, index, out vertex); } internal override void GetVertices(IntPtr ptr, TriVertex2[] vertices, int count) { Triangulation2_EIK_GetVertices(ptr, vertices, count); } internal override bool GetFace(IntPtr ptr, int index, out TriFace2 face) { return Triangulation2_EIK_GetFace(ptr, index, out face); } internal override void GetFaces(IntPtr ptr, TriFace2[] faces, int count) { Triangulation2_EIK_GetFaces(ptr, faces, count); } internal override bool GetSegment(IntPtr ptr, int faceIndex, int neighbourIndex, out Segment2d segment) { return Triangulation2_EIK_GetSegment(ptr, faceIndex, neighbourIndex, out segment); } internal override bool GetTriangle(IntPtr ptr, int faceIndex, out Triangle2d triangle) { return Triangulation2_EIK_GetTriangle(ptr, faceIndex, out triangle); } internal override void GetTriangles(IntPtr ptr, Triangle2d[] triangles, int count) { Triangulation2_EIK_GetTriangles(ptr, triangles, count); } internal override bool GetCircumcenter(IntPtr ptr, int faceIndex, out Point2d circumcenter) { return Triangulation2_EIK_GetCircumcenter(ptr, faceIndex, out circumcenter); } internal override void GetCircumcenters(IntPtr ptr, [Out] Point2d[] circumcenters, int count) { Triangulation2_EIK_GetCircumcenters(ptr, circumcenters, count); } internal override int NeighbourIndex(IntPtr ptr, int faceIndex, int index) { return Triangulation2_EIK_NeighbourIndex(ptr, faceIndex, index); } internal override bool LocateFace(IntPtr ptr, Point2d point, out TriFace2 face) { return Triangulation2_EIK_LocateFace(ptr, point, out face); } internal override bool MoveVertex(IntPtr ptr, int index, Point2d point, bool ifNoCollision, out TriVertex2 vertex) { return Triangulation2_EIK_MoveVertex(ptr, index, point, ifNoCollision, out vertex); } internal override bool RemoveVertex(IntPtr ptr, int index) { return Triangulation2_EIK_RemoveVertex(ptr, index); } internal override bool FlipEdge(IntPtr ptr, int faceIndex, int neighbour) { return Triangulation2_EIK_FlipEdge(ptr, faceIndex, neighbour); } internal override void Transform(IntPtr ptr, Point2d translation, double rotation, double scale) { Triangulation2_EIK_Transform(ptr, translation, rotation, scale); } [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr Triangulation2_EIK_Create(); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void Triangulation2_EIK_Release(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void Triangulation2_EIK_Clear(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr Triangulation2_EIK_Copy(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void Triangulation2_EIK_SetIndices(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int Triangulation2_EIK_BuildStamp(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool Triangulation2_EIK_IsValid(IntPtr ptr, int level); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int Triangulation2_EIK_VertexCount(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int Triangulation2_EIK_FaceCount(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void Triangulation2_EIK_InsertPoint(IntPtr ptr, Point2d point); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void Triangulation2_EIK_InsertPoints(IntPtr ptr, [In] Point2d[] points, int count); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void Triangulation2_EIK_InsertPolygon(IntPtr triPtr, IntPtr polyPtr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void Triangulation2_EIK_InsertPolygonWithHoles(IntPtr triPtr, IntPtr pwhPtr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void Triangulation2_EIK_GetPoints(IntPtr ptr, [Out] Point2d[] points, int count); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void Triangulation2_EIK_GetIndices(IntPtr ptr, [Out] int[] indices, int count); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool Triangulation2_EIK_GetVertex(IntPtr ptr, int index, [Out] out TriVertex2 vertex); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void Triangulation2_EIK_GetVertices(IntPtr ptr, [Out] TriVertex2[] vertices, int count); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool Triangulation2_EIK_GetFace(IntPtr ptr, int index, [Out] out TriFace2 triFace); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void Triangulation2_EIK_GetFaces(IntPtr ptr, [Out] TriFace2[] faces, int count); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool Triangulation2_EIK_GetSegment(IntPtr ptr, int faceIndex, int neighbourIndex, [Out] out Segment2d segment); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool Triangulation2_EIK_GetTriangle(IntPtr ptr, int faceIndex, [Out] out Triangle2d triangle); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void Triangulation2_EIK_GetTriangles(IntPtr ptr, [Out] Triangle2d[] triangles, int count); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool Triangulation2_EIK_GetCircumcenter(IntPtr ptr, int faceIndex, [Out] out Point2d circumcenter); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void Triangulation2_EIK_GetCircumcenters(IntPtr ptr, [Out] Point2d[] circumcenters, int count); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int Triangulation2_EIK_NeighbourIndex(IntPtr ptr, int faceIndex, int index); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool Triangulation2_EIK_LocateFace(IntPtr ptr, Point2d point, [Out] out TriFace2 face); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool Triangulation2_EIK_MoveVertex(IntPtr ptr, int index, Point2d point, bool ifNoCollision, [Out] out TriVertex2 vertex); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool Triangulation2_EIK_RemoveVertex(IntPtr ptr, int index); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool Triangulation2_EIK_FlipEdge(IntPtr ptr, int faceIndex, int neighbour); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void Triangulation2_EIK_MakeGabriel(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void Triangulation2_EIK_Optimize(IntPtr ptr, int iterations, double angleBounds, double lengthBounds); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void Triangulation2_EIK_Transform(IntPtr ptr, Point2d translation, double rotation, double scale); } } ================================================ FILE: CGALDotNet/Triangulations/TriangulationKernel3.cs ================================================ using System; using System.Collections.Generic; using System.Text; namespace CGALDotNet.Triangulations { internal abstract class TriangulationKernel3 : BaseTriangulationKernel3 { } } ================================================ FILE: CGALDotNet/Triangulations/TriangulationKernel3_EEK.cs ================================================ using System; using System.Collections.Generic; using System.Text; using System.Runtime.InteropServices; using CGALDotNetGeometry.Numerics; using CGALDotNetGeometry.Shapes; namespace CGALDotNet.Triangulations { internal class TriangulationKernel3_EEK : TriangulationKernel3 { internal override string Name => "EEK"; internal static readonly TriangulationKernel3 Instance = new TriangulationKernel3_EEK(); internal override IntPtr Create() { return Triangulation3_EEK_Create(); } internal override void Release(IntPtr ptr) { Triangulation3_EEK_Release(ptr); } internal override void Clear(IntPtr ptr) { Triangulation3_EEK_Clear(ptr); } internal override IntPtr Copy(IntPtr ptr) { return Triangulation3_EEK_Copy(ptr); } internal override int BuildStamp(IntPtr ptr) { return Triangulation3_EEK_BuildStamp(ptr); } internal override int Dimension(IntPtr ptr) { return Triangulation3_EEK_Dimension(ptr); } internal override bool IsValid(IntPtr ptr, bool verbose) { return Triangulation3_EEK_IsValid(ptr, verbose); } internal override int VertexCount(IntPtr ptr) { return Triangulation3_EEK_VertexCount(ptr); } internal override int FiniteVertexCount(IntPtr ptr) { return Triangulation3_EEK_FiniteVertexCount(ptr); } internal override int CellCount(IntPtr ptr) { return Triangulation3_EEK_CellCount(ptr); } internal override int FiniteCellCount(IntPtr ptr) { return Triangulation3_EEK_FiniteCellCount(ptr); } internal override int EdgeCount(IntPtr ptr) { return Triangulation3_EEK_EdgeCount(ptr); } internal override int FiniteEdgeCount(IntPtr ptr) { return Triangulation3_EEK_FiniteEdgeCount(ptr); } internal override int FacetCount(IntPtr ptr) { return Triangulation3_EEK_FacetCount(ptr); } internal override int FiniteFacetCount(IntPtr ptr) { return Triangulation3_EEK_FiniteFacetCount(ptr); } internal override void InsertPoint(IntPtr ptr, Point3d point) { Triangulation3_EEK_InsertPoint(ptr, point); } internal override void InsertPoints(IntPtr ptr, Point3d[] points, int count) { Triangulation3_EEK_InsertPoints(ptr, points, count); } internal override void InsertInCell(IntPtr ptr, int index, Point3d point) { Triangulation3_EEK_InsertInCell(ptr, index, point); } internal override int Locate(IntPtr ptr, Point3d point) { return Triangulation3_EEK_Locate(ptr, point); } internal override void GetCircumcenters(IntPtr ptr, Point3d[] Circumcenters, int count) { Triangulation3_EEK_GetCircumcenters(ptr, Circumcenters, count); } internal override void GetPoints(IntPtr ptr, Point3d[] points, int count) { Triangulation3_EEK_GetPoints(ptr, points, count); } internal override void GetVertices(IntPtr ptr, TriVertex3[] vertices, int count) { Triangulation3_EEK_GetVertices(ptr, vertices, count); } internal override bool GetVertex(IntPtr ptr, int index, out TriVertex3 vertex) { return Triangulation3_EEK_GetVertex(ptr, index, out vertex); } internal override void GetCells(IntPtr ptr, TriCell3[] cells, int count) { Triangulation3_EEK_GetCells(ptr, cells, count); } internal override bool GetCell(IntPtr ptr, int index, out TriCell3 cell) { return Triangulation3_EEK_GetCell(ptr, index, out cell); } internal override void GetSegmentIndices(IntPtr ptr, int[] indices, int count) { Triangulation3_EEK_GetSegmentIndices(ptr, indices, count); } internal override void GetTriangleIndices(IntPtr ptr, int[] indices, int count) { Triangulation3_EEK_GetTriangleIndices(ptr, indices, count); } internal override void GetTetrahedraIndices(IntPtr ptr, int[] indices, int count) { Triangulation3_EEK_GetTetrahedraIndices(ptr, indices, count); } internal override void GetSegments(IntPtr ptr, Segment3d[] indices, int count) { Triangulation3_EEK_GetSegments(ptr, indices, count); } internal override void GetTriangles(IntPtr ptr, Triangle3d[] indices, int count) { Triangulation3_EEK_GetTriangles(ptr, indices, count); } internal override void GetTetrahedrons(IntPtr ptr, Tetrahedron3d[] indices, int count) { Triangulation3_EEK_GetTetrahedrons (ptr, indices, count); } internal override void Transform(IntPtr ptr, Matrix4x4d matrix) { Triangulation3_EEK_Transform(ptr, matrix); } [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr Triangulation3_EEK_Create(); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void Triangulation3_EEK_Release(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void Triangulation3_EEK_Clear(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern IntPtr Triangulation3_EEK_Copy(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int Triangulation3_EEK_BuildStamp(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int Triangulation3_EEK_Dimension(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool Triangulation3_EEK_IsValid(IntPtr ptr, bool verbose); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int Triangulation3_EEK_VertexCount(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int Triangulation3_EEK_FiniteVertexCount(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int Triangulation3_EEK_CellCount(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int Triangulation3_EEK_FiniteCellCount(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int Triangulation3_EEK_EdgeCount(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int Triangulation3_EEK_FiniteEdgeCount(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int Triangulation3_EEK_FacetCount(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int Triangulation3_EEK_FiniteFacetCount(IntPtr ptr); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void Triangulation3_EEK_InsertPoint(IntPtr ptr, Point3d point); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void Triangulation3_EEK_InsertPoints(IntPtr ptr, Point3d[] points, int count); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void Triangulation3_EEK_InsertInCell(IntPtr ptr, int index, Point3d point); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern int Triangulation3_EEK_Locate(IntPtr ptr, Point3d point); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void Triangulation3_EEK_GetCircumcenters(IntPtr ptr, [Out] Point3d[] Circumcenters, int count); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void Triangulation3_EEK_GetPoints(IntPtr ptr, [Out] Point3d[] points, int count); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void Triangulation3_EEK_GetVertices(IntPtr ptr, [Out] TriVertex3[] vertices, int count); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool Triangulation3_EEK_GetVertex(IntPtr ptr, int index, [Out] out TriVertex3 vertex); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void Triangulation3_EEK_GetCells(IntPtr ptr, [Out] TriCell3[] cells, int count); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern bool Triangulation3_EEK_GetCell(IntPtr ptr, int index, out TriCell3 cell); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void Triangulation3_EEK_GetSegmentIndices(IntPtr ptr, [Out] int[] indices, int count); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void Triangulation3_EEK_GetTriangleIndices(IntPtr ptr, [Out] int[] indices, int count); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void Triangulation3_EEK_GetTetrahedraIndices(IntPtr ptr, [Out] int[] indices, int count); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void Triangulation3_EEK_GetSegments(IntPtr ptr, [Out] Segment3d[] segments, int count); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void Triangulation3_EEK_GetTriangles(IntPtr ptr, [Out] Triangle3d[] triangles, int count); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void Triangulation3_EEK_GetTetrahedrons(IntPtr ptr, [Out] Tetrahedron3d[] Tetrahedrons, int count); [DllImport(DLL_NAME, CallingConvention = CDECL)] private static extern void Triangulation3_EEK_Transform(IntPtr ptr, Matrix4x4d matrix); } } ================================================ FILE: CGALDotNet/Util/ArrayCache.cs ================================================ using System; using System.Collections.Generic; using System.Text; using CGALDotNetGeometry.Numerics; using CGALDotNetGeometry.Shapes; namespace CGALDotNet { /// /// Cache to reuse arrays. /// Thread safe? /// public class ArrayCache { [ThreadStatic] public static bool Disable = false; [ThreadStatic] private static Point2d[] m_points2d; [ThreadStatic] private static Segment2d[] m_segments2d; [ThreadStatic] private static Point3d[] m_points3d; [ThreadStatic] private static HPoint3d[] m_hpoints3d; [ThreadStatic] private static int[] m_int1, m_int2; public void Clear() { m_points2d = null; m_segments2d = null; m_points3d = null; m_hpoints3d = null; m_int1 = null; m_int2 = null; } /// /// Returns a array of Point2d objects that is at least the size of count. /// /// The minimum size of the array. /// Should the array be cleared first. /// Returns a array of Point2d objects that is at least the size of count. public static Point2d[] Point2dArray(int count, bool clear = false) { if (MakeNewArray(m_points2d, count)) m_points2d = new Point2d[count]; if(clear) Array.Clear(m_points3d, 0, m_points3d.Length); return m_points2d; } /// /// Returns a array of Segment2d objects that is at least the size of count. /// /// The minimum size of the array. /// Should the array be cleared first. /// Returns a array of Segment2d objects that is at least the size of count. public static Segment2d[] Segment2dArray(int count, bool clear = false) { if (MakeNewArray(m_segments2d, count)) m_segments2d = new Segment2d[count]; if (clear) Array.Clear(m_segments2d, 0, m_segments2d.Length); return m_segments2d; } /// /// Returns a array of Point3d objects that is at least the size of count. /// /// The minimum size of the array. /// Should the array be cleared first. /// Returns a array of Point3d objects that is at least the size of count. public static Point3d[] Point3dArray(int count, bool clear = false) { if (MakeNewArray(m_points3d, count)) m_points3d = new Point3d[count]; if (clear) Array.Clear(m_points3d, 0, m_points3d.Length); return m_points3d; } /// /// Returns a array of HPoint3d objects that is at least the size of count. /// /// The minimum size of the array. /// Should the array be cleared first. /// Returns a array of HPoint3d objects that is at least the size of count. public static HPoint3d[] HPoint3dArray(int count, bool clear = false) { if (MakeNewArray(m_hpoints3d, count)) m_hpoints3d = new HPoint3d[count]; if (clear) Array.Clear(m_hpoints3d, 0, m_hpoints3d.Length); return m_hpoints3d; } /// /// Returns a array of ints that is at least the size of count. /// /// The minimum size of the array. /// Should the array be cleared first. /// Returns a array of ints that is at least the size of count. public static int[] IntArray1(int count, bool clear = false) { if (MakeNewArray(m_int1, count)) m_int1 = new int[count]; if (clear) Array.Clear(m_int1, 0, m_int1.Length); return m_int1; } /// /// Returns a array of ints that is at least the size of count. /// /// The minimum size of the array. /// Should the array be cleared first. /// Returns a array of ints that is at least the size of count. public static int[] IntArray2(int count, bool clear = false) { if (MakeNewArray(m_int2, count)) m_int2 = new int[count]; if (clear) Array.Clear(m_int2, 0, m_int2.Length); return m_int2; } /// /// Should a new array be created. /// /// The current array. /// The required new array size. /// Creates a new array if disabled, the current one is null or to small. private static bool MakeNewArray(Array arr, int count) { return (Disable || arr == null || arr.Length < count); } } } ================================================ FILE: CGALDotNet/Util/CGALEnums.cs ================================================ using System; using System.Collections.Generic; namespace CGALDotNet { public enum CGAL_KERNEL { EIK = 0, EEK = 1, EEK_SQRT2 = 2, EEK_KTH_ROOT = 3, EEK_ROOT_OF = 4 } public enum CGAL_KERNEL_LONG { EXACT_PREDICATES_INEXACT_CONSTRUCTION = 0, EXACT_PREDICATES_EXACT_CONSTRUCTION = 1, EXACT_PREDICATES_EXACT_CONSTRUCTION_WITH_SQRT2 = 2, EXACT_PREDICATES_EXACT_CONSTRUCTION_WITH_KTH_ROOT = 3, EXACT_PREDICATES_EXACT_CONSTRUCTION_WITH_ROOT_OF = 4 } public static class CGALEnum { public static BOUNDED_SIDE Opposite(BOUNDED_SIDE e) => (BOUNDED_SIDE)(-(int)e); public static COMPARISON_RESULT Opposite(COMPARISON_RESULT e) => (COMPARISON_RESULT)(-(int)e); public static SIGN Opposite(SIGN e) => (SIGN)(-(int)e); public static CLOCK_DIR Opposite(CLOCK_DIR e) => (CLOCK_DIR)(-(int)e); public static ORIENTATION Opposite(ORIENTATION e) => (ORIENTATION)(-(int)e); public static ORIENTED_SIDE Opposite(ORIENTED_SIDE e) => (ORIENTED_SIDE)(-(int)e); public static bool SameOrientation(ORIENTATION e1, ORIENTED_SIDE e2) => e1 == (ORIENTATION)e2; public static bool OppositeOrientation(ORIENTATION e1, ORIENTED_SIDE e2) => Opposite(e1) == (ORIENTATION)e2; public static T Next(this T src) { T[] Arr = (T[])Enum.GetValues(src.GetType()); int j = Array.IndexOf(Arr, src) + 1; return (Arr.Length == j) ? Arr[0] : Arr[j]; } public static int Count() { return Enum.GetValues(typeof(T)).Length; } public static CGAL_KERNEL ToKernelEnum(string k) { switch (k) { case "EIK": return CGAL_KERNEL.EIK; case "EEK": return CGAL_KERNEL.EEK; case "EEK_SQRT2": return CGAL_KERNEL.EEK_SQRT2; case "EEK_KTH_ROOT": return CGAL_KERNEL.EEK_KTH_ROOT; case "EEK_ROOT_OF": return CGAL_KERNEL.EEK_ROOT_OF; default: throw new Exception("Unhandled case."); } } } public enum ANGLE { OBTUSE = -1, RIGHT = 0, ACUTE = 1 } public enum BOUNDED_SIDE { ON_UNBOUNDED_SIDE = -1, ON_BOUNDARY = 0, ON_BOUNDED_SIDE = 1, UNDETERMINED = 2 } public enum COMPARISON_RESULT { SMALLER = -1, EQUAL = 0, LARGER = 1 } public enum SIGN { NEGATIVE = -1, ZERO = 0, POSITIVE = 1 } public enum CLOCK_DIR { CLOCKWISE = -1, ZERO = 0, COUNTER_CLOCKWISE = 1 } public enum ORIENTATION { NEGATIVE = -1, ZERO = 0, POSITIVE = 1 } public enum ORIENTED_SIDE { ON_NEGATIVE_SIDE = -1, ON_BOUNDARY = 0, ON_POSITIVE_SIDE = 1, UNDETERMINED = 2 } public enum BOOL_OR_UNDETERMINED { FALSE = 0, TRUE = 1, UNDETERMINED = 2 } public enum MESH_TYPE { POLYHEDRON, SURFACE_MESH } } ================================================ FILE: CGALDotNet/Util/ErrorUtil.cs ================================================ using System; using System.Collections.Generic; using System.Text; namespace CGALDotNet { internal static class ErrorUtil { /// /// Check a array that is passed to the c++ dll. /// If the array is invalid it will cause a hard crash. /// Array can be null if count is 0; /// /// /// internal static void CheckArray(Array array, int count) { if (array == null && count == 0) return; if(array == null) throw new InvalidArrayExeception("Array is null."); if (count < 0) throw new InvalidArrayExeception("Count must be >= zero."); if (array.Length < count) throw new InvalidArrayExeception("Array length is less than count."); } } public class CGALUnmanagedResourcesReleasedExeception : Exception { public CGALUnmanagedResourcesReleasedExeception() { } public CGALUnmanagedResourcesReleasedExeception(string message) : base(message) { } public CGALUnmanagedResourcesReleasedExeception(string message, Exception inner) : base(message, inner) { } } public class CGALUnmanagedResourcesNotReleasedExeception : Exception { public CGALUnmanagedResourcesNotReleasedExeception() { } public CGALUnmanagedResourcesNotReleasedExeception(string message) : base(message) { } public CGALUnmanagedResourcesNotReleasedExeception(string message, Exception inner) : base(message, inner) { } } public class InvalidArrayExeception : Exception { public InvalidArrayExeception() { } public InvalidArrayExeception(string message) : base(message) { } public InvalidArrayExeception(string message, Exception inner) : base(message, inner) { } } } ================================================ FILE: CGALDotNet.sln ================================================  Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio Version 17 VisualStudioVersion = 17.0.31919.166 MinimumVisualStudioVersion = 10.0.40219.1 Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CGALDotNet", "CGALDotNet\CGALDotNet.csproj", "{0E5F9C35-2768-4C7D-8592-E783BE3DCBE2}" ProjectSection(ProjectDependencies) = postProject {14E85AE8-4516-4FD7-A464-69F55CAB9E66} = {14E85AE8-4516-4FD7-A464-69F55CAB9E66} EndProjectSection EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CGALDotNetConsole", "CGALDotNetConsole\CGALDotNetConsole.csproj", "{5B091F12-E9FC-4ADB-B8F0-D46A744E3B57}" ProjectSection(ProjectDependencies) = postProject {14E85AE8-4516-4FD7-A464-69F55CAB9E66} = {14E85AE8-4516-4FD7-A464-69F55CAB9E66} EndProjectSection EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "CGALWrapper", "CGALWrapper\CGALWrapper.vcxproj", "{14E85AE8-4516-4FD7-A464-69F55CAB9E66}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{725A109E-7F75-4EDD-A2D9-E8D682B01896}" ProjectSection(SolutionItems) = preProject .editorconfig = .editorconfig EndProjectSection EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CGALDotNetTest", "CGALDotNetTest\CGALDotNetTest.csproj", "{AA90E589-2EA3-4680-B24D-2C18194DD85E}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU Debug|x64 = Debug|x64 Debug|x86 = Debug|x86 Release|Any CPU = Release|Any CPU Release|x64 = Release|x64 Release|x86 = Release|x86 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution {0E5F9C35-2768-4C7D-8592-E783BE3DCBE2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {0E5F9C35-2768-4C7D-8592-E783BE3DCBE2}.Debug|Any CPU.Build.0 = Debug|Any CPU {0E5F9C35-2768-4C7D-8592-E783BE3DCBE2}.Debug|x64.ActiveCfg = Debug|Any CPU {0E5F9C35-2768-4C7D-8592-E783BE3DCBE2}.Debug|x64.Build.0 = Debug|Any CPU {0E5F9C35-2768-4C7D-8592-E783BE3DCBE2}.Debug|x86.ActiveCfg = Debug|Any CPU {0E5F9C35-2768-4C7D-8592-E783BE3DCBE2}.Debug|x86.Build.0 = Debug|Any CPU {0E5F9C35-2768-4C7D-8592-E783BE3DCBE2}.Release|Any CPU.ActiveCfg = Release|Any CPU {0E5F9C35-2768-4C7D-8592-E783BE3DCBE2}.Release|Any CPU.Build.0 = Release|Any CPU {0E5F9C35-2768-4C7D-8592-E783BE3DCBE2}.Release|x64.ActiveCfg = Release|Any CPU {0E5F9C35-2768-4C7D-8592-E783BE3DCBE2}.Release|x64.Build.0 = Release|Any CPU {0E5F9C35-2768-4C7D-8592-E783BE3DCBE2}.Release|x86.ActiveCfg = Release|Any CPU {0E5F9C35-2768-4C7D-8592-E783BE3DCBE2}.Release|x86.Build.0 = Release|Any CPU {5B091F12-E9FC-4ADB-B8F0-D46A744E3B57}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {5B091F12-E9FC-4ADB-B8F0-D46A744E3B57}.Debug|Any CPU.Build.0 = Debug|Any CPU {5B091F12-E9FC-4ADB-B8F0-D46A744E3B57}.Debug|x64.ActiveCfg = Debug|Any CPU {5B091F12-E9FC-4ADB-B8F0-D46A744E3B57}.Debug|x64.Build.0 = Debug|Any CPU {5B091F12-E9FC-4ADB-B8F0-D46A744E3B57}.Debug|x86.ActiveCfg = Debug|Any CPU {5B091F12-E9FC-4ADB-B8F0-D46A744E3B57}.Debug|x86.Build.0 = Debug|Any CPU {5B091F12-E9FC-4ADB-B8F0-D46A744E3B57}.Release|Any CPU.ActiveCfg = Release|Any CPU {5B091F12-E9FC-4ADB-B8F0-D46A744E3B57}.Release|Any CPU.Build.0 = Release|Any CPU {5B091F12-E9FC-4ADB-B8F0-D46A744E3B57}.Release|x64.ActiveCfg = Release|Any CPU {5B091F12-E9FC-4ADB-B8F0-D46A744E3B57}.Release|x64.Build.0 = Release|Any CPU {5B091F12-E9FC-4ADB-B8F0-D46A744E3B57}.Release|x86.ActiveCfg = Release|Any CPU {5B091F12-E9FC-4ADB-B8F0-D46A744E3B57}.Release|x86.Build.0 = Release|Any CPU {14E85AE8-4516-4FD7-A464-69F55CAB9E66}.Debug|Any CPU.ActiveCfg = Debug|Win32 {14E85AE8-4516-4FD7-A464-69F55CAB9E66}.Debug|x64.ActiveCfg = Debug|x64 {14E85AE8-4516-4FD7-A464-69F55CAB9E66}.Debug|x64.Build.0 = Debug|x64 {14E85AE8-4516-4FD7-A464-69F55CAB9E66}.Debug|x86.ActiveCfg = Debug|Win32 {14E85AE8-4516-4FD7-A464-69F55CAB9E66}.Debug|x86.Build.0 = Debug|Win32 {14E85AE8-4516-4FD7-A464-69F55CAB9E66}.Release|Any CPU.ActiveCfg = Release|Win32 {14E85AE8-4516-4FD7-A464-69F55CAB9E66}.Release|x64.ActiveCfg = Release|x64 {14E85AE8-4516-4FD7-A464-69F55CAB9E66}.Release|x64.Build.0 = Release|x64 {14E85AE8-4516-4FD7-A464-69F55CAB9E66}.Release|x86.ActiveCfg = Release|Win32 {14E85AE8-4516-4FD7-A464-69F55CAB9E66}.Release|x86.Build.0 = Release|Win32 {AA90E589-2EA3-4680-B24D-2C18194DD85E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {AA90E589-2EA3-4680-B24D-2C18194DD85E}.Debug|Any CPU.Build.0 = Debug|Any CPU {AA90E589-2EA3-4680-B24D-2C18194DD85E}.Debug|x64.ActiveCfg = Debug|Any CPU {AA90E589-2EA3-4680-B24D-2C18194DD85E}.Debug|x64.Build.0 = Debug|Any CPU {AA90E589-2EA3-4680-B24D-2C18194DD85E}.Debug|x86.ActiveCfg = Debug|Any CPU {AA90E589-2EA3-4680-B24D-2C18194DD85E}.Debug|x86.Build.0 = Debug|Any CPU {AA90E589-2EA3-4680-B24D-2C18194DD85E}.Release|Any CPU.ActiveCfg = Release|Any CPU {AA90E589-2EA3-4680-B24D-2C18194DD85E}.Release|Any CPU.Build.0 = Release|Any CPU {AA90E589-2EA3-4680-B24D-2C18194DD85E}.Release|x64.ActiveCfg = Release|Any CPU {AA90E589-2EA3-4680-B24D-2C18194DD85E}.Release|x64.Build.0 = Release|Any CPU {AA90E589-2EA3-4680-B24D-2C18194DD85E}.Release|x86.ActiveCfg = Release|Any CPU {AA90E589-2EA3-4680-B24D-2C18194DD85E}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {A7C5E29B-94D2-4C83-B2CE-D61B5D0A7B69} EndGlobalSection EndGlobal ================================================ FILE: CGALDotNetConsole/CGALDotNetConsole.csproj ================================================  Exe netcoreapp3.1 AnyCPU ..\..\CGALDotNetGeometry\CGALDotNetGeometry\bin\Release\netcoreapp3.1\CGALDotNetGeometry.dll True True Resources.resx ResXFileCodeGenerator Resources.Designer.cs ================================================ FILE: CGALDotNetConsole/Program.cs ================================================ using System; using System.Text; using System.Collections.Generic; using BenchmarkDotNet.Attributes; using BenchmarkDotNet.Running; using CGALDotNetGeometry.Numerics; using CGALDotNetGeometry.Shapes; using CGALDotNetGeometry.Extensions; using CGALDotNet; using CGALDotNet.Geometry; using CGALDotNet.Polygons; using CGALDotNet.Polylines; using CGALDotNet.Triangulations; using CGALDotNet.Arrangements; using CGALDotNet.Polyhedra; using CGALDotNet.Meshing; using CGALDotNet.Hulls; using CGALDotNet.Processing; using CGALDotNet.Extensions; using CGALDotNet.Collections; using CGALDotNet.Eigen; namespace CGALDotNetConsole { public class Program { static void Main(string[] args) { } } } ================================================ FILE: CGALDotNetConsole/Properties/Resources.Designer.cs ================================================ //------------------------------------------------------------------------------ // // This code was generated by a tool. // Runtime Version:4.0.30319.42000 // // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. // //------------------------------------------------------------------------------ namespace CGALDotNetConsole.Properties { using System; /// /// A strongly-typed resource class, for looking up localized strings, etc. /// // This class was auto-generated by the StronglyTypedResourceBuilder // class via a tool like ResGen or Visual Studio. // To add or remove a member, edit your .ResX file then rerun ResGen // with the /str option, or rebuild your VS project. [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] internal class Resources { private static global::System.Resources.ResourceManager resourceMan; private static global::System.Globalization.CultureInfo resourceCulture; [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] internal Resources() { } /// /// Returns the cached ResourceManager instance used by this class. /// [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] internal static global::System.Resources.ResourceManager ResourceManager { get { if (object.ReferenceEquals(resourceMan, null)) { global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("CGALDotNetConsole.Properties.Resources", typeof(Resources).Assembly); resourceMan = temp; } return resourceMan; } } /// /// Overrides the current thread's CurrentUICulture property for all /// resource lookups using this strongly typed resource class. /// [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] internal static global::System.Globalization.CultureInfo Culture { get { return resourceCulture; } set { resourceCulture = value; } } } } ================================================ FILE: CGALDotNetConsole/Properties/Resources.resx ================================================  text/microsoft-resx 1.3 System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.3500.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.3500.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 ================================================ FILE: CGALDotNetConsole/Properties/launchSettings.json ================================================ { "profiles": { "CGALDotNetConsole": { "commandName": "Project", "nativeDebugging": true } } } ================================================ FILE: CGALDotNetConsole/Timer.cs ================================================ using System; using System.Collections.Generic; using System.Diagnostics; namespace CGALDotNetConsole { public class Timer { public double ElapsedMilliseconds { get; private set; } public double ElapsedSeconds { get; private set; } public long ElapsedTicks => m_watch.ElapsedTicks; public bool IsHighPerformance => Stopwatch.IsHighResolution; public bool IsRunning => m_watch.IsRunning; public long NanoSecondsPerTick => (1000L * 1000L * 1000L) / Stopwatch.Frequency; private Stopwatch m_watch; private static Timer s_timer; public Timer() { m_watch = new Stopwatch(); } /// /// /// /// public override string ToString() { return string.Format("[Timer: IsHighPerformance={0}, NanoSecondsPerTick={1}, ElapsedTicks={2}, ElapsedSeconds={3}]", IsHighPerformance, NanoSecondsPerTick, ElapsedTicks, ElapsedSeconds); } public void Start() { m_watch.Start(); } public double Stop() { m_watch.Stop(); ElapsedMilliseconds = (ElapsedTicks * NanoSecondsPerTick) / 1000000.0; ElapsedSeconds = ElapsedMilliseconds / 1000.0; return ElapsedMilliseconds; } public void StopAndPrintInMilliSeconds() { Stop(); Console.WriteLine(ElapsedMilliseconds + " ms"); } public double Tick() { ElapsedMilliseconds = (ElapsedTicks * NanoSecondsPerTick) / 1000000.0; ElapsedSeconds = ElapsedMilliseconds / 1000.0; return ElapsedMilliseconds; } public void Reset() { ElapsedMilliseconds = 0.0; ElapsedSeconds = 0.0; m_watch.Reset(); } public static void StartTimer() { s_timer = new Timer(); s_timer.Start(); } public static double StopTimer() { return s_timer.Stop(); } } } ================================================ FILE: CGALDotNetTest/AssertX.cs ================================================ using System; using System.Collections.Generic; using Microsoft.VisualStudio.TestTools.UnitTesting; using CGALDotNet; using CGALDotNetGeometry.Numerics; using CGALDotNetGeometry.Shapes; using CGALDotNet.Geometry; using CGALDotNet.Eigen; namespace CGALDotNetTest { public static class AssertX { public static void AlmostEqual(this double d, double d2, double eps = MathUtil.EPS_64) { Assert.IsTrue(MathUtil.AlmostEqual(d, d2, eps)); } public static void AlmostEqual(this Point2d p1, Point2d p2, double eps = MathUtil.EPS_64) { Assert.IsTrue(Point2d.AlmostEqual(p1, p2, eps)); } public static void AlmostEqual(this Point3d p1, Point3d p2, double eps = MathUtil.EPS_64) { Assert.IsTrue(Point3d.AlmostEqual(p1, p2, eps)); } public static void AlmostEqual(this Vector2d p1, Vector2d p2, double eps = MathUtil.EPS_64) { Assert.IsTrue(Vector2d.AlmostEqual(p1, p2, eps)); } public static void AlmostEqual(this Vector3d p1, Vector3d p2, double eps = MathUtil.EPS_64) { Assert.IsTrue(Vector3d.AlmostEqual(p1, p2, eps)); } public static void AlmostEqual(this EigenMatrix m1, EigenMatrix m2, double eps = MathUtil.EPS_64) { Assert.AreEqual(m1.Rows, m2.Rows); Assert.AreEqual(m1.Columns, m2.Columns); for (int i = 0; i < m1.Length; i++) { Assert.IsTrue(MathUtil.AlmostEqual(m1[i], m2[i], eps)); } } public static void AlmostEqual(this EigenColumnVector v1, EigenColumnVector v2, double eps = MathUtil.EPS_64) { Assert.AreEqual(v1.Dimension, v2.Dimension); for (int i = 0; i < v1.Dimension; i++) { Assert.IsTrue(MathUtil.AlmostEqual(v1[i], v2[i], eps)); } } public static void AlmostEqual(this EigenRowVector v1, EigenRowVector v2, double eps = MathUtil.EPS_64) { Assert.AreEqual(v1.Dimension, v2.Dimension); for (int i = 0; i < v1.Dimension; i++) { Assert.IsTrue(MathUtil.AlmostEqual(v1[i], v2[i], eps)); } } } } ================================================ FILE: CGALDotNetTest/CGALDotNetTest.csproj ================================================ netcoreapp3.1 false ..\..\CGALDotNetGeometry\CGALDotNetGeometry\bin\Release\netcoreapp3.1\CGALDotNetGeometry.dll ================================================ FILE: CGALDotNetTest/CGALGlobalTest.cs ================================================ using System; using System.Diagnostics; using Microsoft.VisualStudio.TestTools.UnitTesting; using CGALDotNet; using CGALDotNet.Geometry; using CGALDotNetGeometry.Numerics; using CGALDotNetGeometry.Shapes; namespace CGALDotNetTest { [TestClass] public class CGALGlobalTest { [TestMethod] public void Angle_Vector2() { var t2 = new Vector2d(1, 1); var u2 = new Vector2d(1, 0); var v2 = new Vector2d(0, 1); var w2 = new Vector2d(-1, 1); Assert.AreEqual(CGALGlobal.Angle(t2, u2), ANGLE.ACUTE); Assert.AreEqual(CGALGlobal.Angle(u2, v2), ANGLE.RIGHT); Assert.AreEqual(CGALGlobal.Angle(w2, u2), ANGLE.OBTUSE); } [TestMethod] public void Angle_Vector3() { var t3 = new Vector3d(1, 1, 0); var u3 = new Vector3d(1, 0, 0); var v3 = new Vector3d(0, 1, 0); var w3 = new Vector3d(-1, 1, 0); Assert.AreEqual(CGALGlobal.Angle(t3, u3), ANGLE.ACUTE); Assert.AreEqual(CGALGlobal.Angle(u3, v3), ANGLE.RIGHT); Assert.AreEqual(CGALGlobal.Angle(w3, u3), ANGLE.OBTUSE); Assert.AreEqual(CGALGlobal.Angle(t3.xzy, u3.xzy), ANGLE.ACUTE); Assert.AreEqual(CGALGlobal.Angle(u3.xzy, v3.xzy), ANGLE.RIGHT); Assert.AreEqual(CGALGlobal.Angle(w3.xzy, u3.xzy), ANGLE.OBTUSE); } [TestMethod] public void Angle_EIK() { var t2 = new Vector2(1, 1); var u2 = new Vector2(1, 0); var v2 = new Vector2(0, 1); var w2 = new Vector2(-1, 1); Assert.AreEqual(CGALGlobal.Angle(t2, u2), ANGLE.ACUTE); Assert.AreEqual(CGALGlobal.Angle(u2, v2), ANGLE.RIGHT); Assert.AreEqual(CGALGlobal.Angle(w2, u2), ANGLE.OBTUSE); } [TestMethod] public void Angle_EEK() { var t2 = new Vector2(1, 1); var u2 = new Vector2(1, 0); var v2 = new Vector2(0, 1); var w2 = new Vector2(-1, 1); Assert.AreEqual(CGALGlobal.Angle(t2, u2), ANGLE.ACUTE); Assert.AreEqual(CGALGlobal.Angle(u2, v2), ANGLE.RIGHT); Assert.AreEqual(CGALGlobal.Angle(w2, u2), ANGLE.OBTUSE); } [TestMethod] public void ApproxAngle_Vector2() { var t = new Vector3d(1, 1, 0); var u = new Vector3d(1, 0, 0); var v = new Vector3d(0, 1, 0); var w = new Vector3d(-1, 1, 0); Assert.AreEqual(CGALGlobal.ApproxAngle(t, u).Rounded(6), 45.0); Assert.AreEqual(CGALGlobal.ApproxAngle(u, v).Rounded(6), 90.0); Assert.AreEqual(CGALGlobal.ApproxAngle(w, u).Rounded(6), 135.0); } [TestMethod] public void ApproxAngle_Vector3() { var t = new Vector3d(1, 1, 0); var u = new Vector3d(1, 0, 0); var v = new Vector3d(0, 1, 0); var w = new Vector3d(-1, 1, 0); Assert.AreEqual(CGALGlobal.ApproxAngle(t.xzy, u.xzy).Rounded(6), 45.0); Assert.AreEqual(CGALGlobal.ApproxAngle(u.xzy, v.xzy).Rounded(6), 90.0); Assert.AreEqual(CGALGlobal.ApproxAngle(w.xzy, u.xzy).Rounded(6), 135.0); } [TestMethod] public void AreOrderedAlongLine_Point2() { var p2 = new Point2d(1, 0); var q2 = new Point2d(2, 0); var r2 = new Point2d(3, 0); Assert.IsTrue(CGALGlobal.AreOrderedAlongLine(p2, q2, r2)); } [TestMethod] public void AreOrderedAlongLine_EIK() { var p2 = new Point2(1, 0); var q2 = new Point2(2, 0); var r2 = new Point2(3, 0); Assert.IsTrue(CGALGlobal.AreOrderedAlongLine(p2, q2, r2)); } [TestMethod] public void AreOrderedAlongLine_EEK() { var p2 = new Point2(1, 0); var q2 = new Point2(2, 0); var r2 = new Point2(3, 0); Assert.IsTrue(CGALGlobal.AreOrderedAlongLine(p2, q2, r2)); } [TestMethod] public void AreStrictlyOrderedAlongLine_Point2() { var p2 = new Point2d(1, 0); var q2 = new Point2d(2, 0); var r2 = new Point2d(3, 0); Assert.IsTrue(CGALGlobal.AreStrictlyOrderedAlongLine(p2, q2, r2)); Assert.IsFalse(CGALGlobal.AreStrictlyOrderedAlongLine(p2, r2, r2)); } [TestMethod] public void AreStrictlyOrderedAlongLine_EIK() { var p2 = new Point2(1, 0); var q2 = new Point2(2, 0); var r2 = new Point2(3, 0); Assert.IsTrue(CGALGlobal.AreStrictlyOrderedAlongLine(p2, q2, r2)); Assert.IsFalse(CGALGlobal.AreStrictlyOrderedAlongLine(p2, r2, r2)); } [TestMethod] public void AreStrictlyOrderedAlongLine_EEK() { var p2 = new Point2(1, 0); var q2 = new Point2(2, 0); var r2 = new Point2(3, 0); Assert.IsTrue(CGALGlobal.AreStrictlyOrderedAlongLine(p2, q2, r2)); Assert.IsFalse(CGALGlobal.AreStrictlyOrderedAlongLine(p2, r2, r2)); } [TestMethod] public void Colinear_Point2() { var p2 = new Point2d(1, 0); var q2 = new Point2d(2, 0); var r2 = new Point2d(3, 0); Assert.IsTrue(CGALGlobal.Collinear(p2, q2, r2)); } [TestMethod] public void Colinear_Point3() { var p3 = new Point3d(1, 0, 0); var q3 = new Point3d(2, 0, 0); var r3 = new Point3d(3, 0, 0); Assert.IsTrue(CGALGlobal.Collinear(p3, q3, r3)); Assert.IsTrue(CGALGlobal.Collinear(p3.xzy, q3.xzy, r3.xzy)); } [TestMethod] public void Colinear_EIK() { var p2 = new Point2d(1, 0); var q2 = new Point2d(2, 0); var r2 = new Point2d(3, 0); Assert.IsTrue(CGALGlobal.Collinear(p2, q2, r2)); } [TestMethod] public void Colinear_EEK() { var p2 = new Point2d(1, 0); var q2 = new Point2d(2, 0); var r2 = new Point2d(3, 0); Assert.IsTrue(CGALGlobal.Collinear(p2, q2, r2)); } [TestMethod] public void Barycenter_Point2() { var p = new Point2d(0, 0); var q = new Point2d(1, 0); var r = new Point2d(1, 1); var bc = CGALGlobal.Barycenter(p, q, r); bc.Round(2); Assert.AreEqual(0.67, bc.x); Assert.AreEqual(0.33, bc.y); } [TestMethod] public void Barycenter_Point3() { var p = new Point3d(0, 0, 0); var q = new Point3d(1, 0, 0); var r = new Point3d(1, 1, 0); var bc = CGALGlobal.Barycenter(p, q, r); bc.Round(2); Assert.AreEqual(0.67, bc.x); Assert.AreEqual(0.33, bc.y); } [TestMethod] public void Barycenter_EIK() { var p = new Point2(0, 0); var q = new Point2(1, 0); var r = new Point2(1, 1); var bc = CGALGlobal.Barycenter(p, q, r); bc.Round(2); Assert.AreEqual(0.67, bc.x); Assert.AreEqual(0.33, bc.y); } [TestMethod] public void Barycenter_EEK() { var p = new Point2(0, 0); var q = new Point2(1, 0); var r = new Point2(1, 1); var bc = CGALGlobal.Barycenter(p, q, r); bc.Round(2); Assert.AreEqual(0.67, bc.x); Assert.AreEqual(0.33, bc.y); } [TestMethod] public void Bisector_Point2() { var p = new Point3d(1, 0, 0); var q = new Point3d(1, 1, 0); Assert.AreEqual(CGALGlobal.Bisector(p, q), new Line2d(0, -2, 0)); } [TestMethod] public void Bisector_Line2() { var l1 = new Line2d(new Point2d(0, 0), new Point2d(1, 0)); var l2 = new Line2d(new Point2d(0, 1), new Point2d(1, 1)); Assert.AreEqual(CGALGlobal.Bisector(l1, l2), new Line2d(0, 2, -1)); } [TestMethod] public void Bisector_EIK() { var l1 = new Line2(new Point2d(0, 0), new Point2d(1, 0)); var l2 = new Line2(new Point2d(0, 1), new Point2d(1, 1)); var bs = CGALGlobal.Bisector(l1, l2); Assert.AreEqual(bs.A, 0); Assert.AreEqual(bs.B, 2); Assert.AreEqual(bs.C, -1); } [TestMethod] public void Bisector_EEK() { var l1 = new Line2(new Point2d(0, 0), new Point2d(1, 0)); var l2 = new Line2(new Point2d(0, 1), new Point2d(1, 1)); var bs = CGALGlobal.Bisector(l1, l2); Assert.AreEqual(bs.A, 0); Assert.AreEqual(bs.B, 2); Assert.AreEqual(bs.C, -1); } [TestMethod] public void Coplanar_Point3() { var p = new Point3d(1, 0, 0); var q = new Point3d(2, 0, 0); var r = new Point3d(1, 1, 0); var s = new Point3d(2, 1, 0); var t = new Point3d(2, 0, 1); Assert.IsTrue(CGALGlobal.Coplanar(p, q, r, s)); Assert.IsFalse(CGALGlobal.Coplanar(p, q, r, t)); Assert.IsTrue(CGALGlobal.Coplanar(p.xzy, q.xzy, r.xzy, s.xzy)); Assert.IsFalse(CGALGlobal.Coplanar(p.xzy, q.xzy, r.xzy, t.xzy)); } [TestMethod] public void CoplanarOrientation_Point3() { var p = new Point3d(0, 0, 0); var q = new Point3d(1, 0, 0); var r = new Point3d(0, -1, 0); var s = new Point3d(1, -1, 0); var t = new Point3d(0, 0, 1); Assert.AreEqual(CGALGlobal.CoplanarOrientation(p, q, r, s), ORIENTATION.POSITIVE); Assert.AreEqual(CGALGlobal.CoplanarOrientation(p, q, r, t), ORIENTATION.ZERO); Assert.AreEqual(CGALGlobal.CoplanarOrientation(p, q, r, t.xzy), ORIENTATION.NEGATIVE); } [TestMethod] public void EquidistantLine_Point3() { var p = new Point3d(1, 0, 0); var q = new Point3d(0, 1, 0); var r = new Point3d(0, 0, 1); var l1 = CGALGlobal.EquidistantLine(p, q, r); l1.Normalize(); l1.Round(2); var pos = new Point3d(0.33); var dir = new Vector3d(0.58); var l2 = new Line3d(pos, dir); l2.Round(2); Assert.AreEqual(l1, l2); } [TestMethod] public void OrthogonalVector_Point3() { var p = new Point3d(1, 0, 0); var q = new Point3d(1, 1, 0); var r = new Point3d(0, 1, 0); Assert.AreEqual(CGALGlobal.OrthogonalVector(p, q, r), new Vector3d(0,0,1)); } [TestMethod] public void Parallel_Line2() { var l1 = new Line2d(new Point2d(0, 0), new Point2d(1, 0)); var l2 = new Line2d(new Point2d(1, 0), new Point2d(1, 0)); Assert.IsTrue(CGALGlobal.Parallel(l1 ,l2)); } [TestMethod] public void Parallel_EIK_Line2() { var l1 = new Line2(new Point2d(0, 0), new Point2d(1, 0)); var l2 = new Line2(new Point2d(1, 0), new Point2d(1, 0)); Assert.IsTrue(CGALGlobal.Parallel(l1, l2)); } [TestMethod] public void Parallel_EEK_Line2() { var l1 = new Line2(new Point2d(0, 0), new Point2d(1, 0)); var l2 = new Line2(new Point2d(1, 0), new Point2d(1, 0)); Assert.IsTrue(CGALGlobal.Parallel(l1, l2)); } [TestMethod] public void Parallel_Ray2() { var r1 = new Ray2d(new Point2d(0, 0), new Vector2d(1, 0)); var r2 = new Ray2d(new Point2d(1, 0), new Vector2d(1, 0)); Assert.IsTrue(CGALGlobal.Parallel(r1, r2)); } [TestMethod] public void Parallel_EIK_Ray2() { var r1 = new Ray2(new Point2d(0, 0), new Vector2d(1, 0)); var r2 = new Ray2(new Point2d(1, 0), new Vector2d(1, 0)); Assert.IsTrue(CGALGlobal.Parallel(r1, r2)); } [TestMethod] public void Parallel_EEK_Ray2() { var r1 = new Ray2(new Point2d(0, 0), new Vector2d(1, 0)); var r2 = new Ray2(new Point2d(1, 0), new Vector2d(1, 0)); Assert.IsTrue(CGALGlobal.Parallel(r1, r2)); } [TestMethod] public void Parallel_Segment2() { var s1 = new Segment2d(new Point2d(0, 0), new Point2d(1, 0)); var s2 = new Segment2d(new Point2d(1, 0), new Point2d(1, 0)); Assert.IsTrue(CGALGlobal.Parallel(s1, s2)); } [TestMethod] public void Parallel_EIK_Segment2() { var s1 = new Segment2(new Point2d(0, 0), new Point2d(1, 0)); var s2 = new Segment2(new Point2d(1, 0), new Point2d(1, 0)); Assert.IsTrue(CGALGlobal.Parallel(s1, s2)); } [TestMethod] public void Parallel_EEK_Segment2() { var s1 = new Segment2(new Point2d(0, 0), new Point2d(1, 0)); var s2 = new Segment2(new Point2d(1, 0), new Point2d(1, 0)); Assert.IsTrue(CGALGlobal.Parallel(s1, s2)); } [TestMethod] public void LeftTurn_Point2() { var p = new Point2d(0, 0); var q = new Point2d(1, 0); var r = new Point2d(1, 1); Assert.IsTrue(CGALGlobal.LeftTurn(p, q, r)); } [TestMethod] public void LeftTurn_EIK() { var p = new Point2(0, 0); var q = new Point2(1, 0); var r = new Point2(1, 1); Assert.IsTrue(CGALGlobal.LeftTurn(p, q, r)); } [TestMethod] public void LeftTurn_EEK() { var p = new Point2(0, 0); var q = new Point2(1, 0); var r = new Point2(1, 1); Assert.IsTrue(CGALGlobal.LeftTurn(p, q, r)); } [TestMethod] public void RightTurn_Point2() { var p = new Point2d(0, 0); var q = new Point2d(1, 0); var r = new Point2d(1, 1); Assert.IsTrue(CGALGlobal.RightTurn(r, q, p)); } [TestMethod] public void RightTurn_EIK() { var p = new Point2(0, 0); var q = new Point2(1, 0); var r = new Point2(1, 1); Assert.IsTrue(CGALGlobal.RightTurn(r, q, p)); } [TestMethod] public void RightTurn_EEK() { var p = new Point2(0, 0); var q = new Point2(1, 0); var r = new Point2(1, 1); //Assert.IsTrue(CGALGlobal.RightTurn(r, q, p)); } [TestMethod] public void Orientation_Point2() { var p = new Point2d(0, 0); var q1 = new Point2d(1, 0); var q2 = new Point2d(2, 0); var q3 = new Point2d(3, 0); var r = new Point2d(1, 1); Assert.AreEqual(ORIENTATION.POSITIVE, CGALGlobal.Orientation(p, q1, r)); Assert.AreEqual(ORIENTATION.NEGATIVE, CGALGlobal.Orientation(r, q1, p)); Assert.AreEqual(ORIENTATION.ZERO, CGALGlobal.Orientation(q1, q2, q3)); } [TestMethod] public void Orientation_EIK() { var p = new Point2(0, 0); var q1 = new Point2(1, 0); var q2 = new Point2(2, 0); var q3 = new Point2(3, 0); var r = new Point2(1, 1); Assert.AreEqual(ORIENTATION.POSITIVE, CGALGlobal.Orientation(p, q1, r)); Assert.AreEqual(ORIENTATION.NEGATIVE, CGALGlobal.Orientation(r, q1, p)); Assert.AreEqual(ORIENTATION.ZERO, CGALGlobal.Orientation(q1, q2, q3)); } [TestMethod] public void Orientation_EEK() { var p = new Point2(0, 0); var q1 = new Point2(1, 0); var q2 = new Point2(2, 0); var q3 = new Point2(3, 0); var r = new Point2(1, 1); Assert.AreEqual(ORIENTATION.POSITIVE, CGALGlobal.Orientation(p, q1, r)); Assert.AreEqual(ORIENTATION.NEGATIVE, CGALGlobal.Orientation(r, q1, p)); Assert.AreEqual(ORIENTATION.ZERO, CGALGlobal.Orientation(q1, q2, q3)); } [TestMethod] public void Orientation_Vector2() { var p = new Vector2d(1, 0); var q = new Vector2d(0, 1); var q2 = new Vector2d(0, 1); var r = new Vector2d(1, 1); Assert.AreEqual(ORIENTATION.POSITIVE, CGALGlobal.Orientation(p, r)); Assert.AreEqual(ORIENTATION.NEGATIVE, CGALGlobal.Orientation(r, p)); Assert.AreEqual(ORIENTATION.ZERO, CGALGlobal.Orientation(q, q2)); } [TestMethod] public void Orientation_EIK_Vector2() { var p = new Vector2(1, 0); var q = new Vector2(0, 1); var q2 = new Vector2(0, 1); var r = new Vector2(1, 1); Assert.AreEqual(ORIENTATION.POSITIVE, CGALGlobal.Orientation(p, r)); Assert.AreEqual(ORIENTATION.NEGATIVE, CGALGlobal.Orientation(r, p)); Assert.AreEqual(ORIENTATION.ZERO, CGALGlobal.Orientation(q, q2)); } [TestMethod] public void Orientation_EEK_Vector2() { var p = new Vector2(1, 0); var q = new Vector2(0, 1); var q2 = new Vector2(0, 1); var r = new Vector2(1, 1); Assert.AreEqual(ORIENTATION.POSITIVE, CGALGlobal.Orientation(p, r)); Assert.AreEqual(ORIENTATION.NEGATIVE, CGALGlobal.Orientation(r, p)); Assert.AreEqual(ORIENTATION.ZERO, CGALGlobal.Orientation(q, q2)); } [TestMethod] public void Orientation_Point3() { var p = new Point3d(0, 0, 0); var q = new Point3d(1, 0, 0); var r = new Point3d(1, 1, 0); var v = CGALGlobal.OrthogonalVector(p, q, r); Assert.AreEqual(0, v.x); Assert.AreEqual(0, v.y); Assert.AreEqual(1, v.z); } } } ================================================ FILE: CGALDotNetTest/Eigen/EigenMatrix_Test.cs ================================================ using System; using Microsoft.VisualStudio.TestTools.UnitTesting; using CGALDotNet; using CGALDotNetGeometry.Numerics; using CGALDotNet.Eigen; namespace CGALDotNetTest.Eigen { [TestClass] public class EigenMatrix_Test { [TestMethod] public void Create() { int rows = 2; int cols = 3; var m1 = new EigenMatrix(rows, cols); var a = new double[rows, cols]; var m2 = new EigenMatrix(a); var c = new EigenColumnVector[] { new EigenColumnVector(cols), new EigenColumnVector(cols) }; var m3 = new EigenMatrix(c); Assert.AreEqual(rows, m1.Rows); Assert.AreEqual(cols, m1.Columns); Assert.AreEqual(rows, m2.Rows); Assert.AreEqual(cols, m2.Columns); Assert.AreEqual(rows, m3.Rows); Assert.AreEqual(cols, m3.Columns); } [TestMethod] public void Release() { var m = new EigenMatrix(1,1); m.Dispose(); Assert.IsTrue(m.IsDisposed); } [TestMethod] public void RowColumnsLength() { var m = new EigenMatrix(2, 3); Assert.AreEqual(2, m.Rows); Assert.AreEqual(3, m.Columns); Assert.AreEqual(2 * 3, m.Length); } [TestMethod] public void ArrayAccessors() { var m = new EigenMatrix(2, 3); for (int i = 0; i < m.Length; i++) m[i] = i; for (int i = 0; i < m.Length; i++) Assert.AreEqual(i, m[i]); for (int y = 0; y < m.Columns; y++) { for (int x = 0; x < m.Rows; x++) { m[x, y] = x + y * m.Rows; } } for (int y = 0; y < m.Columns; y++) { for (int x = 0; x < m.Rows; x++) { int i = x + y * m.Rows; Assert.AreEqual(i, m[i]); } } } [TestMethod] public void ScalarMul() { var m = EigenMatrix.Series(2, 3); m = m * 2; int i = 0; for (int x = 0; x < m.Rows; x++) { for (int y = 0; y < m.Columns; y++) { Assert.AreEqual(i * 2, m[x, y]); i++; } } } [TestMethod] public void ScalarDiv() { var m = EigenMatrix.Series(2, 3); m = m / 2.0; int i = 0; for (int x = 0; x < m.Rows; x++) { for (int y = 0; y < m.Columns; y++) { Assert.AreEqual(i / 2.0, m[x, y]); i++; } } } [TestMethod] public void VectorMul() { var m = EigenMatrix.Translate(new Point3d(1, 2, 3)); var v = new EigenColumnVector(0, 0, 0, 1); v = m * v; Assert.AreEqual(1, v.x); Assert.AreEqual(2, v.y); Assert.AreEqual(3, v.z); Assert.AreEqual(1, v.w); } [TestMethod] public void MatrixMul() { var m1 = EigenMatrix.Series(2, 2); var m2 = EigenMatrix.Series(2, 2); var m = new EigenMatrix(2, 3, 6, 11); AssertX.AlmostEqual(m, m1 * m2); } [TestMethod] public void MatrixAdd() { var m1 = EigenMatrix.Series(2, 2); var m2 = EigenMatrix.Series(2, 2); var m = new EigenMatrix(0, 2, 4, 6); AssertX.AlmostEqual(m, m1 + m2); } [TestMethod] public void MatrixSub() { var m1 = EigenMatrix.Series(2, 2); var m2 = EigenMatrix.Series(2, 2); var m = new EigenMatrix(0, 0, 0, 0); AssertX.AlmostEqual(m, m1 - m2); } [TestMethod] public void EigenValues() { var m = new EigenMatrix(1, 2, 2, 3); if(m.EigenValues(out EigenColumnVector values)) { values.Round(2); AssertX.AlmostEqual(new EigenColumnVector(-0.24, 4.24), values); } else { throw new Exception("Failed to find eigen values."); } } [TestMethod] public void EigenVectors() { var m = new EigenMatrix(1, 2, 2, 3); if (m.EigenVectors(out EigenMatrix vectors)) { vectors.Round(3); AssertX.AlmostEqual(new EigenMatrix(-0.851, -0.526, 0.526, -0.851), vectors); } else { throw new Exception("Failed to find eigen values."); } } [TestMethod] public void EigenValuesVectors() { var m = new EigenMatrix(1, 2, 2, 3); if (m.EigenValuesAndVectors(out EigenColumnVector values, out EigenMatrix vectors)) { values.Round(2); AssertX.AlmostEqual(new EigenColumnVector(-0.24, 4.24), values); vectors.Round(3); AssertX.AlmostEqual(new EigenMatrix(-0.851, -0.526, 0.526, -0.851), vectors); } else { throw new Exception("Failed to find eigen values and vectors."); } } [TestMethod] public void ColPivHouseholderQr() { var A = new EigenMatrix(3, 3); A.SetRow(0, 1, 2, 3); A.SetRow(1, 4, 5, 6); A.SetRow(2, 7, 8, 10); var b1 = new EigenColumnVector(3, 3, 4); var b2 = new EigenMatrix(3, 1); b2.SetColumn(0, 3, 3, 4); var x1 = A.ColPivHouseholderQr(b1); x1.Round(2); var x2 = A.ColPivHouseholderQr(b2); x2.Round(2); var x = new EigenColumnVector(-2, 1, 1); AssertX.AlmostEqual(x, x1); AssertX.AlmostEqual(x, x1); } /* [TestMethod] public void PartialPivLu() { var A = new EigenMatrix(3, 3); A.SetRow(0, 1, 2, 3); A.SetRow(1, 4, 5, 6); A.SetRow(2, 7, 8, 10); var b1 = new EigenColumnVector(3, 3, 4); var b2 = new EigenMatrix(3, 1); b2.SetColumn(0, 3, 3, 4); var x1 = A.PartialPivLu(b1); x1.Round(2); var x2 = A.PartialPivLu(b2); x2.Round(2); var x = new EigenColumnVector(-2, 1, 1); AssertX.AlmostEqual(x, x1); AssertX.AlmostEqual(x, x1); } */ [TestMethod] public void FullPivLu() { var A = new EigenMatrix(3, 3); A.SetRow(0, 1, 2, 3); A.SetRow(1, 4, 5, 6); A.SetRow(2, 7, 8, 10); var b1 = new EigenColumnVector(3, 3, 4); var b2 = new EigenMatrix(3, 1); b2.SetColumn(0, 3, 3, 4); var x1 = A.FullPivLu(b1); x1.Round(2); var x2 = A.FullPivLu(b2); x2.Round(2); var x = new EigenColumnVector(-2, 1, 1); AssertX.AlmostEqual(x, x1); AssertX.AlmostEqual(x, x1); } [TestMethod] public void HouseholderQr() { var A = new EigenMatrix(3, 3); A.SetRow(0, 1, 2, 3); A.SetRow(1, 4, 5, 6); A.SetRow(2, 7, 8, 10); var b1 = new EigenColumnVector(3, 3, 4); var b2 = new EigenMatrix(3, 1); b2.SetColumn(0, 3, 3, 4); var x1 = A.HouseholderQr(b1); x1.Round(2); var x2 = A.HouseholderQr(b2); x2.Round(2); var x = new EigenColumnVector(-2, 1, 1); AssertX.AlmostEqual(x, x1); AssertX.AlmostEqual(x, x1); } /* [TestMethod] public void LLT() { var A = new EigenMatrix(3, 3); A.SetRow(0, 1, 2, 3); A.SetRow(1, 4, 5, 6); A.SetRow(2, 7, 8, 10); var b1 = new EigenColumnVector(3, 3, 4); var b2 = new EigenMatrix(3, 1); b2.SetColumn(0, 3, 3, 4); var x1 = A.LLT(b1); x1.Round(2); var x2 = A.LLT(b2); x2.Round(2); var x = new EigenColumnVector(-2, 1, 1); AssertX.AlmostEqual(x, x1); AssertX.AlmostEqual(x, x1); } [TestMethod] public void LDLT() { var A = new EigenMatrix(3, 3); A.SetRow(0, 1, 2, 3); A.SetRow(1, 4, 5, 6); A.SetRow(2, 7, 8, 10); var b1 = new EigenColumnVector(3, 3, 4); var b2 = new EigenMatrix(3, 1); b2.SetColumn(0, 3, 3, 4); var x1 = A.LDLT(b1); x1.Round(2); var x2 = A.LDLT(b2); x2.Round(2); var x = new EigenColumnVector(-2, 1, 1); AssertX.AlmostEqual(x, x1); AssertX.AlmostEqual(x, x1); } */ [TestMethod] public void BdcSvd() { var A = new EigenMatrix(3, 3); A.SetRow(0, 1, 2, 3); A.SetRow(1, 4, 5, 6); A.SetRow(2, 7, 8, 10); var b1 = new EigenColumnVector(3, 3, 4); var b2 = new EigenMatrix(3, 1); b2.SetColumn(0, 3, 3, 4); var x1 = A.BdcSvd(b1); x1.Round(2); var x2 = A.BdcSvd(b2); x2.Round(2); var x = new EigenColumnVector(-2, 1, 1); AssertX.AlmostEqual(x, x1); AssertX.AlmostEqual(x, x1); } [TestMethod] public void JacobiSvd() { var A = new EigenMatrix(3, 3); A.SetRow(0, 1, 2, 3); A.SetRow(1, 4, 5, 6); A.SetRow(2, 7, 8, 10); var b1 = new EigenColumnVector(3, 3, 4); var b2 = new EigenMatrix(3, 1); b2.SetColumn(0, 3, 3, 4); var x1 = A.JacobiSvd(b1); x1.Round(2); var x2 = A.JacobiSvd(b2); x2.Round(2); var x = new EigenColumnVector(-2, 1, 1); AssertX.AlmostEqual(x, x1); AssertX.AlmostEqual(x, x1); } [TestMethod] public void FullPivHouseholderQR() { var A = new EigenMatrix(3, 3); A.SetRow(0, 1, 2, 3); A.SetRow(1, 4, 5, 6); A.SetRow(2, 7, 8, 10); var b1 = new EigenColumnVector(3, 3, 4); var b2 = new EigenMatrix(3, 1); b2.SetColumn(0, 3, 3, 4); var x1 = A.FullPivHouseholderQR(b1); x1.Round(2); var x2 = A.FullPivHouseholderQR(b2); x2.Round(2); var x = new EigenColumnVector(-2, 1, 1); AssertX.AlmostEqual(x, x1); AssertX.AlmostEqual(x, x1); } [TestMethod] public void CompleteOrthogonalDecomposition() { var A = new EigenMatrix(3, 3); A.SetRow(0, 1, 2, 3); A.SetRow(1, 4, 5, 6); A.SetRow(2, 7, 8, 10); var b1 = new EigenColumnVector(3, 3, 4); var b2 = new EigenMatrix(3, 1); b2.SetColumn(0, 3, 3, 4); var x1 = A.CompleteOrthogonalDecomposition(b1); x1.Round(2); var x2 = A.CompleteOrthogonalDecomposition(b2); x2.Round(2); var x = new EigenColumnVector(-2, 1, 1); AssertX.AlmostEqual(x, x1); AssertX.AlmostEqual(x, x1); } } } ================================================ FILE: CGALDotNetTest/Geometry/Box2_EEK_Test.cs ================================================ using CGALDotNet; using CGALDotNet.Geometry; using CGALDotNetGeometry.Numerics; using Microsoft.VisualStudio.TestTools.UnitTesting; namespace CGALDotNetTest.Geometry { [TestClass] public class Box2_EEK_Test { [TestMethod] public void CreateBox() { var min = new Point2d(-1, -2); var max = new Point2d(1, 2); var box = new Box2(min, max); Assert.AreEqual(new Point2d(-1, -2), box.Min); Assert.AreEqual(new Point2d(1, 2), box.Max); } [TestMethod] public void Release() { var box = new Box2(-1, -1); box.Dispose(); Assert.IsTrue(box.IsDisposed); } [TestMethod] public void GetMinMax() { var min = new Point2d(-1, -3); var max = new Point2d(1, 3); var box = new Box2(min, max); Assert.AreEqual(min, box.Min); Assert.AreEqual(max, box.Max); } [TestMethod] public void SetMinMax() { var min = new Point2d(-1, -3); var max = new Point2d(1, 3); var box = new Box2(min, max); box.Min = new Point2d(0, 1); box.Max = new Point2d(2, 4); Assert.AreEqual(new Point2d(0, 1), box.Min); Assert.AreEqual(new Point2d(2, 4), box.Max); } [TestMethod] public void Area() { var box = new Box2(-1, 1); Assert.AreEqual(4, box.Area); } [TestMethod] public void BoundedSide() { var p1 = new Point2d(-2, -2); var p2 = new Point2d(-1, 0); var p3 = new Point2d(0, 0); var box = new Box2(-1, 1); Assert.AreEqual(BOUNDED_SIDE.ON_UNBOUNDED_SIDE, box.BoundedSide(p1)); Assert.AreEqual(BOUNDED_SIDE.ON_BOUNDARY, box.BoundedSide(p2)); Assert.AreEqual(BOUNDED_SIDE.ON_BOUNDED_SIDE, box.BoundedSide(p3)); } [TestMethod] public void ContainsPoint() { var p1 = new Point2d(-2, -2); var p2 = new Point2d(-1, 0); var p3 = new Point2d(0, 0); var box = new Box2(-1, 1); Assert.IsFalse(box.ContainsPoint(p1)); Assert.IsTrue(box.ContainsPoint(p2)); Assert.IsTrue(box.ContainsPoint(p2, true)); Assert.IsTrue(box.ContainsPoint(p3)); } [TestMethod] public void IsDegenerate() { var box = new Box2(0, 0); Assert.IsTrue(box.IsDegenerate); } [TestMethod] public void Transform() { var box = new Box2(-1, 1); box.Translate(new Point2d(1, 1)); Assert.AreEqual(new Point2d(0, 0), box.Min); Assert.AreEqual(new Point2d(2, 2), box.Max); box = new Box2(-1, 1); box.Scale(2); Assert.AreEqual(new Point2d(-2, -2), box.Min); Assert.AreEqual(new Point2d(2, 2), box.Max); box = new Box2(-1, 1); box.Rotate(new Degree(90)); box.Round(2); Assert.AreEqual(new Point2d(-1, -1), box.Min); Assert.AreEqual(new Point2d(1, 1), box.Max); } [TestMethod] public void Copy() { var box = new Box2(-1, 1); var box2 = box.Copy(); Assert.AreNotEqual(box.Ptr, box2.Ptr); Assert.AreEqual(new Point2d(-1, -1), box2.Min); Assert.AreEqual(new Point2d(1, 1), box2.Max); } [TestMethod] public void Convert() { var box1 = new Box2(-1, 1); var box2 = box1.Convert(); Assert.AreNotEqual(box1.Ptr, box2.Ptr); Assert.AreEqual(new Point2d(-1, -1), box2.Min); Assert.AreEqual(new Point2d(1, 1), box2.Max); Assert.AreEqual("EIK", box2.KernelName); } [TestMethod] public void Shape() { var box = new Box2(-1, 1); var shape = box.Shape; Assert.AreEqual(new Point2d(-1, -1), shape.Min); Assert.AreEqual(new Point2d(1, 1), shape.Max); } [TestMethod] public void Round() { var p1 = new Point2d(0.1); var p2 = new Point2d(0.01); var p3 = new Point2d(0.001); var p4 = new Point2d(0.0001); var p5 = new Point2d(0.00001); var p6 = new Point2d(0.000001); var p7 = new Point2d(0.0000001); var p8 = new Point2d(0.00000001); var box1 = new Box2(p1, p1); var box2 = new Box2(p2, p2); var box3 = new Box2(p3, p3); var box4 = new Box2(p4, p4); var box5 = new Box2(p5, p5); var box6 = new Box2(p6, p6); var box7 = new Box2(p7, p7); var box8 = new Box2(p8, p8); box1.Round(1); box2.Round(2); box3.Round(3); box4.Round(4); box5.Round(5); box6.Round(6); box7.Round(7); box8.Round(8); AssertX.AlmostEqual(0.1, box1.Min.x); AssertX.AlmostEqual(0.01, box2.Min.x); AssertX.AlmostEqual(0.001, box3.Min.x); AssertX.AlmostEqual(0.0001, box4.Min.x); AssertX.AlmostEqual(0.00001, box5.Min.x); AssertX.AlmostEqual(0.000001, box6.Min.x); AssertX.AlmostEqual(0.0000001, box7.Min.x); AssertX.AlmostEqual(0.00000001, box8.Min.x); } } } ================================================ FILE: CGALDotNetTest/Geometry/Box2_EIK_Test.cs ================================================ using CGALDotNet; using CGALDotNet.Geometry; using CGALDotNetGeometry.Numerics; using Microsoft.VisualStudio.TestTools.UnitTesting; namespace CGALDotNetTest.Geometry { [TestClass] public class Box2_EIK_Test { [TestMethod] public void CreateBox() { var min = new Point2d(-1, -2); var max = new Point2d(1, 2); var box = new Box2(min, max); Assert.AreEqual(new Point2d(-1, -2), box.Min); Assert.AreEqual(new Point2d(1, 2), box.Max); } [TestMethod] public void Release() { var box = new Box2(-1, -1); box.Dispose(); Assert.IsTrue(box.IsDisposed); } [TestMethod] public void GetMinMax() { var min = new Point2d(-1, -3); var max = new Point2d(1, 3); var box = new Box2(min, max); Assert.AreEqual(min, box.Min); Assert.AreEqual(max, box.Max); } [TestMethod] public void SetMinMax() { var min = new Point2d(-1, -3); var max = new Point2d(1, 3); var box = new Box2(min, max); box.Min = new Point2d(0, 1); box.Max = new Point2d(2, 4); Assert.AreEqual(new Point2d(0, 1), box.Min); Assert.AreEqual(new Point2d(2, 4), box.Max); } [TestMethod] public void Area() { var box = new Box2(-1, 1); Assert.AreEqual(4, box.Area); } [TestMethod] public void BoundedSide() { var p1 = new Point2d(-2, -2); var p2 = new Point2d(-1, 0); var p3 = new Point2d(0, 0); var box = new Box2(-1, 1); Assert.AreEqual(BOUNDED_SIDE.ON_UNBOUNDED_SIDE, box.BoundedSide(p1)); Assert.AreEqual(BOUNDED_SIDE.ON_BOUNDARY, box.BoundedSide(p2)); Assert.AreEqual(BOUNDED_SIDE.ON_BOUNDED_SIDE, box.BoundedSide(p3)); } [TestMethod] public void ContainsPoint() { var p1 = new Point2d(-2, -2); var p2 = new Point2d(-1, 0); var p3 = new Point2d(0, 0); var box = new Box2(-1, 1); Assert.IsFalse(box.ContainsPoint(p1)); Assert.IsTrue(box.ContainsPoint(p2)); Assert.IsTrue(box.ContainsPoint(p2, true)); Assert.IsTrue(box.ContainsPoint(p3)); } [TestMethod] public void IsDegenerate() { var box = new Box2(0, 0); Assert.IsTrue(box.IsDegenerate); } [TestMethod] public void Transform() { var box = new Box2(-1, 1); box.Translate(new Point2d(1, 1)); Assert.AreEqual(new Point2d(0, 0), box.Min); Assert.AreEqual(new Point2d(2, 2), box.Max); box = new Box2(-1, 1); box.Scale(2); Assert.AreEqual(new Point2d(-2, -2), box.Min); Assert.AreEqual(new Point2d(2, 2), box.Max); box = new Box2(-1, 1); box.Rotate(new Degree(90)); box.Round(2); Assert.AreEqual(new Point2d(-1, -1), box.Min); Assert.AreEqual(new Point2d(1, 1), box.Max); } [TestMethod] public void Copy() { var box = new Box2(-1, 1); var box2 = box.Copy(); Assert.AreNotEqual(box.Ptr, box2.Ptr); Assert.AreEqual(new Point2d(-1, -1), box2.Min); Assert.AreEqual(new Point2d(1, 1), box2.Max); } [TestMethod] public void Convert() { var box1 = new Box2(-1, 1); var box2 = box1.Convert(); Assert.AreNotEqual(box1.Ptr, box2.Ptr); Assert.AreEqual(new Point2d(-1, -1), box2.Min); Assert.AreEqual(new Point2d(1, 1), box2.Max); Assert.AreEqual("EEK", box2.KernelName); } [TestMethod] public void Shape() { var box = new Box2(-1, 1); var shape = box.Shape; Assert.AreEqual(new Point2d(-1, -1), shape.Min); Assert.AreEqual(new Point2d(1, 1), shape.Max); } [TestMethod] public void Round() { var p1 = new Point2d(0.1); var p2 = new Point2d(0.01); var p3 = new Point2d(0.001); var p4 = new Point2d(0.0001); var p5 = new Point2d(0.00001); var p6 = new Point2d(0.000001); var p7 = new Point2d(0.0000001); var p8 = new Point2d(0.00000001); var box1 = new Box2(p1, p1); var box2 = new Box2(p2, p2); var box3 = new Box2(p3, p3); var box4 = new Box2(p4, p4); var box5 = new Box2(p5, p5); var box6 = new Box2(p6, p6); var box7 = new Box2(p7, p7); var box8 = new Box2(p8, p8); box1.Round(1); box2.Round(2); box3.Round(3); box4.Round(4); box5.Round(5); box6.Round(6); box7.Round(7); box8.Round(8); AssertX.AlmostEqual(0.1, box1.Min.x); AssertX.AlmostEqual(0.01, box2.Min.x); AssertX.AlmostEqual(0.001, box3.Min.x); AssertX.AlmostEqual(0.0001, box4.Min.x); AssertX.AlmostEqual(0.00001, box5.Min.x); AssertX.AlmostEqual(0.000001, box6.Min.x); AssertX.AlmostEqual(0.0000001, box7.Min.x); AssertX.AlmostEqual(0.00000001, box8.Min.x); } } } ================================================ FILE: CGALDotNetTest/Geometry/HPoint2_EEK_Test.cs ================================================ using System; using System.Diagnostics; using Microsoft.VisualStudio.TestTools.UnitTesting; using CGALDotNet; using CGALDotNetGeometry.Numerics; using CGALDotNetGeometry.Shapes; using CGALDotNet.Geometry; namespace CGALDotNetTest.Geometry { [TestClass] public class HPoint2_EEK_Test { [TestMethod] public void CreatePoint() { var p = new HPoint2(1, 2, 1); Assert.AreEqual(1, p.x); Assert.AreEqual(2, p.y); //Assert.AreEqual(1, p.w); } [TestMethod] public void SetXY() { var p = new HPoint2(1, 2, 1); p.x = 3; p.y = 4; //p.w = 2; AssertX.AlmostEqual(3, p.x); AssertX.AlmostEqual(4, p.y); //AssertX.AlmostEqual(1, p.w); } [TestMethod] public void Release() { var p = new HPoint2(0, 0, 0); p.Dispose(); Assert.IsTrue(p.IsDisposed); } [TestMethod] public void Clamp() { var p = new HPoint2(-1, 4, 1); p.Clamp(0, 3); Assert.AreEqual(0, p.x); Assert.AreEqual(3, p.y); //Assert.AreEqual(1, p.w); } [TestMethod] public void Clamp01() { var p = new HPoint2(-0.1, 3.2, 2); p.Clamp01(); Assert.AreEqual(0, p.x); Assert.AreEqual(1, p.y); //Assert.AreEqual(1, p.w); } [TestMethod] public void Round() { var p1 = new HPoint2(0.1); var p2 = new HPoint2(0.01); var p3 = new HPoint2(0.001); var p4 = new HPoint2(0.0001); var p5 = new HPoint2(0.00001); var p6 = new HPoint2(0.000001); var p7 = new HPoint2(0.0000001); var p8 = new HPoint2(0.00000001); p1.Round(1); p2.Round(2); p3.Round(3); p4.Round(4); p5.Round(5); p6.Round(6); p7.Round(7); p8.Round(8); AssertX.AlmostEqual(0.1, p1.x); AssertX.AlmostEqual(0.01, p2.y); AssertX.AlmostEqual(0.001, p3.y); AssertX.AlmostEqual(0.0001, p4.y); AssertX.AlmostEqual(0.00001, p5.y); AssertX.AlmostEqual(0.000001, p6.y); AssertX.AlmostEqual(0.0000001, p7.y); AssertX.AlmostEqual(0.00000001, p8.y); } [TestMethod] public void Copy() { var p = new HPoint2(3, 4, 1); var p2 = p.Copy(); Assert.AreNotEqual(p.Ptr, p2.Ptr); Assert.AreEqual(3, p2.x); Assert.AreEqual(4, p2.y); //Assert.AreEqual(1, p2.w); } [TestMethod] public void Convert() { var p1 = new HPoint2(1, 2); var p2 = p1.Convert(); Assert.AreNotEqual(p1.Ptr, p2.Ptr); Assert.AreEqual(1, p2.x); Assert.AreEqual(2, p2.y); Assert.AreEqual("EEK", p2.KernelName); } } } ================================================ FILE: CGALDotNetTest/Geometry/HPoint2_EIK_Test.cs ================================================ using System; using System.Diagnostics; using Microsoft.VisualStudio.TestTools.UnitTesting; using CGALDotNet; using CGALDotNetGeometry.Numerics; using CGALDotNetGeometry.Shapes; using CGALDotNet.Geometry; namespace CGALDotNetTest.Geometry { [TestClass] public class HPoint2_EIK_Test { [TestMethod] public void CreatePoint() { var p = new HPoint2(1, 2, 1); Assert.AreEqual(1, p.x); Assert.AreEqual(2, p.y); //Assert.AreEqual(1, p.w); } [TestMethod] public void SetXY() { var p = new HPoint2(1, 2, 1); p.x = 3; p.y = 4; //p.w = 2; AssertX.AlmostEqual(3, p.x); AssertX.AlmostEqual(4, p.y); //AssertX.AlmostEqual(1, p.w); } [TestMethod] public void Release() { var p = new HPoint2(0, 0, 0); p.Dispose(); Assert.IsTrue(p.IsDisposed); } [TestMethod] public void Clamp() { var p = new HPoint2(-1, 4, 1); p.Clamp(0, 3); Assert.AreEqual(0, p.x); Assert.AreEqual(3, p.y); //Assert.AreEqual(1, p.w); } [TestMethod] public void Clamp01() { var p = new HPoint2(-0.1, 3.2, 2); p.Clamp01(); Assert.AreEqual(0, p.x); Assert.AreEqual(1, p.y); //Assert.AreEqual(1, p.w); } [TestMethod] public void Round() { var p1 = new HPoint2(0.1); var p2 = new HPoint2(0.01); var p3 = new HPoint2(0.001); var p4 = new HPoint2(0.0001); var p5 = new HPoint2(0.00001); var p6 = new HPoint2(0.000001); var p7 = new HPoint2(0.0000001); var p8 = new HPoint2(0.00000001); p1.Round(1); p2.Round(2); p3.Round(3); p4.Round(4); p5.Round(5); p6.Round(6); p7.Round(7); p8.Round(8); AssertX.AlmostEqual(0.1, p1.x); AssertX.AlmostEqual(0.01, p2.y); AssertX.AlmostEqual(0.001, p3.y); AssertX.AlmostEqual(0.0001, p4.y); AssertX.AlmostEqual(0.00001, p5.y); AssertX.AlmostEqual(0.000001, p6.y); AssertX.AlmostEqual(0.0000001, p7.y); AssertX.AlmostEqual(0.00000001, p8.y); } [TestMethod] public void Copy() { var p = new HPoint2(3, 4, 1); var p2 = p.Copy(); Assert.AreNotEqual(p.Ptr, p2.Ptr); Assert.AreEqual(3, p2.x); Assert.AreEqual(4, p2.y); //Assert.AreEqual(1, p2.w); } [TestMethod] public void Convert() { var p1 = new HPoint2(1, 2); var p2 = p1.Convert(); Assert.AreNotEqual(p1.Ptr, p2.Ptr); Assert.AreEqual(1, p2.x); Assert.AreEqual(2, p2.y); Assert.AreEqual("EEK", p2.KernelName); } } } ================================================ FILE: CGALDotNetTest/Geometry/Line2_EIK_Test.cs ================================================ using System; using System.Diagnostics; using Microsoft.VisualStudio.TestTools.UnitTesting; using CGALDotNet; using CGALDotNetGeometry.Numerics; using CGALDotNetGeometry.Shapes; using CGALDotNet.Geometry; namespace CGALDotNetTest.Geometry { [TestClass] public class Line2_EIK_Test { [TestMethod] public void Create() { } [TestMethod] public void CreateFromPoints() { } [TestMethod] public void CreateFromPointVector() { } [TestMethod] public void Release() { } [TestMethod] public void Set() { } [TestMethod] public void Get() { } [TestMethod] public void IsDegenerate() { } [TestMethod] public void IsHorizontal() { } [TestMethod] public void IsVertical() { } [TestMethod] public void HasOn() { } [TestMethod] public void HasOnNegativeSide() { } [TestMethod] public void HasOnPositiveSide() { } [TestMethod] public void Opposite() { } [TestMethod] public void Perpendicular() { } [TestMethod] public void X_On_Y() { } [TestMethod] public void Y_On_X() { } [TestMethod] public void Vector() { } [TestMethod] public void Transform() { } [TestMethod] public void Copy() { } [TestMethod] public void Convert() { } } } ================================================ FILE: CGALDotNetTest/Geometry/Point2_EEK_Test.cs ================================================ using System; using System.Diagnostics; using Microsoft.VisualStudio.TestTools.UnitTesting; using CGALDotNet; using CGALDotNetGeometry.Numerics; using CGALDotNetGeometry.Shapes; using CGALDotNet.Geometry; namespace CGALDotNetTest.Geometry { [TestClass] public class Point2_EEK_Test { [TestMethod] public void CreatePoint_EEK() { var p = new Point2(1, 2); Assert.AreEqual(1, p.x); Assert.AreEqual(2, p.y); } [TestMethod] public void SetXY_EEK() { var p = new Point2(1, 2); p.x = 3; p.y = 4; AssertX.AlmostEqual(3, p.x); AssertX.AlmostEqual(4, p.y); } [TestMethod] public void Release_EEK() { var p = new Point2(0, 0); p.Dispose(); Assert.IsTrue(p.IsDisposed); } [TestMethod] public void Clamp_EEK() { var p = new Point2(-1, 4); p.Clamp(0, 3); Assert.AreEqual(0, p.x); Assert.AreEqual(3, p.y); } [TestMethod] public void Clamp01_EEK() { var p = new Point2(-0.1, 3.2); p.Clamp01(); Assert.AreEqual(0, p.x); Assert.AreEqual(1, p.y); } [TestMethod] public void Round_EEK() { var p1 = new Point2(0.1); var p2 = new Point2(0.01); var p3 = new Point2(0.001); var p4 = new Point2(0.0001); var p5 = new Point2(0.00001); var p6 = new Point2(0.000001); var p7 = new Point2(0.0000001); var p8 = new Point2(0.00000001); p1.Round(1); p2.Round(2); p3.Round(3); p4.Round(4); p5.Round(5); p6.Round(6); p7.Round(7); p8.Round(8); AssertX.AlmostEqual(0.1, p1.x); AssertX.AlmostEqual(0.01, p2.x); AssertX.AlmostEqual(0.001, p3.x); AssertX.AlmostEqual(0.0001, p4.x); AssertX.AlmostEqual(0.00001, p5.x); AssertX.AlmostEqual(0.000001, p6.x); AssertX.AlmostEqual(0.0000001, p7.x); AssertX.AlmostEqual(0.00000001, p8.x); } [TestMethod] public void Copy_EEK() { var p = new Point2(3, 4); var p2 = p.Copy(); Assert.AreNotEqual(p.Ptr, p2.Ptr); Assert.AreEqual(3, p2.x); Assert.AreEqual(4, p2.y); } [TestMethod] public void Convert_EEK() { var p1 = new Point2(1, 2); var p2 = p1.Convert(); Assert.AreNotEqual(p1.Ptr, p2.Ptr); Assert.AreEqual(1, p2.x); Assert.AreEqual(2, p2.y); Assert.AreEqual("EEK", p2.KernelName); } } } ================================================ FILE: CGALDotNetTest/Geometry/Point2_EIK_Test.cs ================================================ using System; using System.Diagnostics; using Microsoft.VisualStudio.TestTools.UnitTesting; using CGALDotNet; using CGALDotNetGeometry.Numerics; using CGALDotNetGeometry.Shapes; using CGALDotNet.Geometry; namespace CGALDotNetTest.Geometry { [TestClass] public class Point2_EIK_Test { [TestMethod] public void CreatePoint_EIK() { var p = new Point2(1, 2); Assert.AreEqual(1, p.x); Assert.AreEqual(2, p.y); } [TestMethod] public void SetXY_EIK() { var p = new Point2(1, 2); p.x = 3; p.y = 4; AssertX.AlmostEqual(3, p.x); AssertX.AlmostEqual(4, p.y); } [TestMethod] public void Release_EIK() { var p = new Point2(0, 0); p.Dispose(); Assert.IsTrue(p.IsDisposed); } [TestMethod] public void Clamp_EIK() { var p = new Point2(-1, 4); p.Clamp(0, 3); Assert.AreEqual(0, p.x); Assert.AreEqual(3, p.y); } [TestMethod] public void Clamp01_EIK() { var p = new Point2(-0.1, 3.2); p.Clamp01(); Assert.AreEqual(0, p.x); Assert.AreEqual(1, p.y); } [TestMethod] public void Round_EIK() { var p1 = new Point2(0.1); var p2 = new Point2(0.01); var p3 = new Point2(0.001); var p4 = new Point2(0.0001); var p5 = new Point2(0.00001); var p6 = new Point2(0.000001); var p7 = new Point2(0.0000001); var p8 = new Point2(0.00000001); p1.Round(1); p2.Round(2); p3.Round(3); p4.Round(4); p5.Round(5); p6.Round(6); p7.Round(7); p8.Round(8); AssertX.AlmostEqual(0.1, p1.x); AssertX.AlmostEqual(0.01, p2.x); AssertX.AlmostEqual(0.001, p3.x); AssertX.AlmostEqual(0.0001, p4.x); AssertX.AlmostEqual(0.00001, p5.x); AssertX.AlmostEqual(0.000001, p6.x); AssertX.AlmostEqual(0.0000001, p7.x); AssertX.AlmostEqual(0.00000001, p8.x); } [TestMethod] public void Copy_EIK() { var p = new Point2(3, 4); var p2 = p.Copy(); Assert.AreNotEqual(p.Ptr, p2.Ptr); Assert.AreEqual(3, p2.x); Assert.AreEqual(4, p2.y); } [TestMethod] public void Convert_EIK() { var p1 = new Point2(1,2); var p2 = p1.Convert(); Assert.AreNotEqual(p1.Ptr, p2.Ptr); Assert.AreEqual(1, p2.x); Assert.AreEqual(2, p2.y); Assert.AreEqual("EEK", p2.KernelName); } } } ================================================ FILE: CGALDotNetTest/Geometry/Ray2_EIK_Test.cs ================================================ using System; using System.Diagnostics; using Microsoft.VisualStudio.TestTools.UnitTesting; using CGALDotNet; using CGALDotNetGeometry.Numerics; using CGALDotNetGeometry.Shapes; using CGALDotNet.Geometry; namespace CGALDotNetTest.Geometry { [TestClass] public class Ray2_EIK_Test { [TestMethod] public void Create() { } [TestMethod] public void Release() { } [TestMethod] public void IsDegenerate() { } [TestMethod] public void IsHorizontal() { } [TestMethod] public void IsVertical() { } [TestMethod] public void HasOn() { } [TestMethod] public void Source() { } [TestMethod] public void Vector() { } [TestMethod] public void Opposite() { } [TestMethod] public void Line() { } [TestMethod] public void Transform() { } [TestMethod] public void Copy() { } [TestMethod] public void Convert() { } } } ================================================ FILE: CGALDotNetTest/Geometry/Segment2_EIK_Test.cs ================================================ using System; using System.Diagnostics; using Microsoft.VisualStudio.TestTools.UnitTesting; using CGALDotNet; using CGALDotNetGeometry.Numerics; using CGALDotNetGeometry.Shapes; using CGALDotNet.Geometry; namespace CGALDotNetTest.Geometry { [TestClass] public class Segment2_EIK_Test { [TestMethod] public void Create() { } [TestMethod] public void Release() { } [TestMethod] public void Get() { } [TestMethod] public void Set() { } [TestMethod] public void Min() { } [TestMethod] public void Max() { } [TestMethod] public void IsDegenerate() { } [TestMethod] public void IsHorizontal() { } [TestMethod] public void IsVertical() { } [TestMethod] public void HasOn() { } [TestMethod] public void Vector() { } [TestMethod] public void Line() { } [TestMethod] public void SqrLength() { } [TestMethod] public void Transform() { } [TestMethod] public void Copy() { } [TestMethod] public void Convert() { } } } ================================================ FILE: CGALDotNetTest/Geometry/Triangle2_EIK_Test.cs ================================================ using System; using System.Diagnostics; using Microsoft.VisualStudio.TestTools.UnitTesting; using CGALDotNet; using CGALDotNetGeometry.Numerics; using CGALDotNetGeometry.Shapes; using CGALDotNet.Geometry; namespace CGALDotNetTest.Geometry { [TestClass] public class Triangle2_EIK_Test { [TestMethod] public void Create() { } [TestMethod] public void Release() { } [TestMethod] public void Get() { } [TestMethod] public void Set() { } [TestMethod] public void Area() { } [TestMethod] public void BoundedSide() { } [TestMethod] public void OrientedSide() { } [TestMethod] public void Orientation() { } [TestMethod] public void IsDegenerate() { } [TestMethod] public void Transform() { } [TestMethod] public void Copy() { } [TestMethod] public void Convert() { } } } ================================================ FILE: CGALDotNetTest/Geometry/Vector2_EEK_Test.cs ================================================ using System; using System.Diagnostics; using Microsoft.VisualStudio.TestTools.UnitTesting; using CGALDotNet; using CGALDotNetGeometry.Numerics; using CGALDotNetGeometry.Shapes; using CGALDotNet.Geometry; namespace CGALDotNetTest.Geometry { [TestClass] public class Vector2_EEK_Test { [TestMethod] public void CreatePoint() { var p = new Vector2(1, 2); Assert.AreEqual(1, p.x); Assert.AreEqual(2, p.y); } [TestMethod] public void SetXY() { var p = new Vector2(1, 2); p.x = 3; p.y = 4; AssertX.AlmostEqual(3, p.x); AssertX.AlmostEqual(4, p.y); } [TestMethod] public void Release() { var p = new Vector2(0, 0); p.Dispose(); Assert.IsTrue(p.IsDisposed); } [TestMethod] public void Clamp() { var p = new Vector2(-1, 4); p.Clamp(0, 3); Assert.AreEqual(0, p.x); Assert.AreEqual(3, p.y); } [TestMethod] public void Clamp01() { var p = new Vector2(-0.1, 3.2); p.Clamp01(); Assert.AreEqual(0, p.x); Assert.AreEqual(1, p.y); } [TestMethod] public void Round() { var p1 = new Vector2(0.1); var p2 = new Vector2(0.01); var p3 = new Vector2(0.001); var p4 = new Vector2(0.0001); var p5 = new Vector2(0.00001); var p6 = new Vector2(0.000001); var p7 = new Vector2(0.0000001); var p8 = new Vector2(0.00000001); p1.Round(1); p2.Round(2); p3.Round(3); p4.Round(4); p5.Round(5); p6.Round(6); p7.Round(7); p8.Round(8); AssertX.AlmostEqual(0.1, p1.x); AssertX.AlmostEqual(0.01, p2.y); AssertX.AlmostEqual(0.001, p3.y); AssertX.AlmostEqual(0.0001, p4.y); AssertX.AlmostEqual(0.00001, p5.y); AssertX.AlmostEqual(0.000001, p6.y); AssertX.AlmostEqual(0.0000001, p7.y); AssertX.AlmostEqual(0.00000001, p8.y); } [TestMethod] public void Copy() { var p = new Vector2(3, 4); var p2 = p.Copy(); Assert.AreNotEqual(p.Ptr, p2.Ptr); Assert.AreEqual(3, p2.x); Assert.AreEqual(4, p2.y); } [TestMethod] public void SqrMagnitude() { var p1 = new Vector2(4, 0); var p2 = new Vector2(0, 2); var sqlen1 = p1.SqrMagnitude; var sqlen2 = p2.SqrMagnitude; AssertX.AlmostEqual(16, sqlen1); AssertX.AlmostEqual(4, sqlen2); } [TestMethod] public void Magnitude() { var p1 = new Vector2(4, 0); var p2 = new Vector2(0, 2); var len1 = p1.Magnitude; var len2 = p2.Magnitude; AssertX.AlmostEqual(4, len1); AssertX.AlmostEqual(2, len2); } [TestMethod] public void Normalize() { var p1 = new Vector2(4, 0); var p2 = new Vector2(0, 2); p1.Normalize(); p2.Normalize(); AssertX.AlmostEqual(1, p1.Magnitude); AssertX.AlmostEqual(1, p2.Magnitude); } [TestMethod] public void Convert() { var p1 = new Vector2(1, 2); var p2 = p1.Convert(); Assert.AreNotEqual(p1.Ptr, p2.Ptr); Assert.AreEqual(1, p2.x); Assert.AreEqual(2, p2.y); Assert.AreEqual("EIK", p2.KernelName); } } } ================================================ FILE: CGALDotNetTest/Geometry/Vector2_EIK_Test.cs ================================================ using System; using System.Diagnostics; using Microsoft.VisualStudio.TestTools.UnitTesting; using CGALDotNet; using CGALDotNetGeometry.Numerics; using CGALDotNetGeometry.Shapes; using CGALDotNet.Geometry; namespace CGALDotNetTest.Geometry { [TestClass] public class Vector2_EIK_Test { [TestMethod] public void CreatePoint() { var p = new Vector2(1, 2); Assert.AreEqual(1, p.x); Assert.AreEqual(2, p.y); } [TestMethod] public void SetXY() { var p = new Vector2(1, 2); p.x = 3; p.y = 4; AssertX.AlmostEqual(3, p.x); AssertX.AlmostEqual(4, p.y); } [TestMethod] public void Release() { var p = new Vector2(0, 0); p.Dispose(); Assert.IsTrue(p.IsDisposed); } [TestMethod] public void Clamp() { var p = new Vector2(-1, 4); p.Clamp(0, 3); Assert.AreEqual(0, p.x); Assert.AreEqual(3, p.y); } [TestMethod] public void Clamp01() { var p = new Vector2(-0.1, 3.2); p.Clamp01(); Assert.AreEqual(0, p.x); Assert.AreEqual(1, p.y); } [TestMethod] public void Round() { var p1 = new Vector2(0.1); var p2 = new Vector2(0.01); var p3 = new Vector2(0.001); var p4 = new Vector2(0.0001); var p5 = new Vector2(0.00001); var p6 = new Vector2(0.000001); var p7 = new Vector2(0.0000001); var p8 = new Vector2(0.00000001); p1.Round(1); p2.Round(2); p3.Round(3); p4.Round(4); p5.Round(5); p6.Round(6); p7.Round(7); p8.Round(8); AssertX.AlmostEqual(0.1, p1.x); AssertX.AlmostEqual(0.01, p2.y); AssertX.AlmostEqual(0.001, p3.y); AssertX.AlmostEqual(0.0001, p4.y); AssertX.AlmostEqual(0.00001, p5.y); AssertX.AlmostEqual(0.000001, p6.y); AssertX.AlmostEqual(0.0000001, p7.y); AssertX.AlmostEqual(0.00000001, p8.y); } [TestMethod] public void Copy() { var p = new Vector2(3, 4); var p2 = p.Copy(); Assert.AreNotEqual(p.Ptr, p2.Ptr); Assert.AreEqual(3, p2.x); Assert.AreEqual(4, p2.y); } [TestMethod] public void SqrMagnitude() { var p1 = new Vector2(4, 0); var p2 = new Vector2(0, 2); var sqlen1 = p1.SqrMagnitude; var sqlen2 = p2.SqrMagnitude; AssertX.AlmostEqual(16, sqlen1); AssertX.AlmostEqual(4, sqlen2); } [TestMethod] public void Magnitude() { var p1 = new Vector2(4, 0); var p2 = new Vector2(0, 2); var len1 = p1.Magnitude; var len2 = p2.Magnitude; AssertX.AlmostEqual(4, len1); AssertX.AlmostEqual(2, len2); } [TestMethod] public void Normalize() { var p1 = new Vector2(4, 0); var p2 = new Vector2(0, 2); p1.Normalize(); p2.Normalize(); AssertX.AlmostEqual(1, p1.Magnitude); AssertX.AlmostEqual(1, p2.Magnitude); } [TestMethod] public void Convert() { var p1 = new Vector2(1, 2); var p2 = p1.Convert(); Assert.AreNotEqual(p1.Ptr, p2.Ptr); Assert.AreEqual(1, p2.x); Assert.AreEqual(2, p2.y); Assert.AreEqual("EEK", p2.KernelName); } } } ================================================ FILE: CGALDotNetTest/Polygons/Polygon2_EEK_Test.cs ================================================ using System; using System.Diagnostics; using Microsoft.VisualStudio.TestTools.UnitTesting; using CGALDotNet; using CGALDotNetGeometry.Numerics; using CGALDotNetGeometry.Shapes; using CGALDotNet.Polygons; namespace CGALDotNetTest.Polygons { [TestClass] public class Polygon2_EEK_Test { [TestMethod] public void CreatePolygon() { var poly = new Polygon2(); Assert.AreEqual(0, poly.Count); Assert.IsFalse(poly.IsSimple); Assert.IsTrue(poly.IsDegenerate); } [TestMethod] public void ReleasePolygon() { var poly = new Polygon2(); poly.Dispose(); Assert.IsTrue(poly.IsDisposed); } [TestMethod] public void CreateSimplePolygon() { var points = new Point2d[] { new Point2d(0, 0), new Point2d(5, 0), new Point2d(5, 5), new Point2d(0, 5) }; var poly = new Polygon2(points); Assert.AreEqual(4, poly.Count); Assert.IsTrue(poly.IsSimple); Assert.IsTrue(poly.IsCounterClockWise); Assert.IsTrue(poly.Orientation == ORIENTATION.POSITIVE); Assert.IsTrue(poly.ClockDir == CLOCK_DIR.COUNTER_CLOCKWISE); Assert.IsTrue(poly.FindIfConvex()); } [TestMethod] public void CreateConcavePolygon() { var points = new Point2d[] { new Point2d(0,0), new Point2d(5.1,0), new Point2d(1,1), new Point2d(0.5,6) }; var poly = new Polygon2(points); Assert.AreEqual(4, poly.Count); Assert.IsTrue(poly.IsSimple); Assert.IsTrue(poly.IsCounterClockWise); Assert.IsTrue(poly.Orientation == ORIENTATION.POSITIVE); Assert.IsTrue(poly.ClockDir == CLOCK_DIR.COUNTER_CLOCKWISE); Assert.IsFalse(poly.FindIfConvex()); } [TestMethod] public void CreateNonSimplePolygon() { var points = new Point2d[] { new Point2d(0, 0), new Point2d(8, 4), new Point2d(8, 0), new Point2d(0, 4), }; var poly = new Polygon2(points); Assert.AreEqual(4, poly.Count); Assert.IsFalse(poly.IsSimple); Assert.IsTrue(poly.IsDegenerate); Assert.IsTrue(poly.Orientation == ORIENTATION.ZERO); Assert.IsTrue(poly.ClockDir == CLOCK_DIR.ZERO); } [TestMethod] public void ArrayAcessor() { var poly = PolygonFactory.CreateBox(-1, 1); Assert.AreEqual(new Point2d(-1, -1), poly[0]); poly[0] = new Point2d(-2, -2); Assert.AreEqual(new Point2d(-2, -2), poly[0]); } [TestMethod] public void Clear() { var poly = PolygonFactory.CreateBox(-1, 1); Assert.AreEqual(4, poly.Count); poly.Clear(); Assert.AreEqual(0, poly.Count); } [TestMethod] public void Copy() { var poly = PolygonFactory.CreateBox(-1, 1); var copy = poly.Copy(); Assert.AreEqual(4, poly.Count); Assert.AreEqual(4, copy.Count); for (int i = 0; i < poly.Count; i++) Assert.AreEqual(poly[i], copy[i]); } [TestMethod] public void Convert() { var poly = PolygonFactory.CreateBox(-1, 1); var poly2 = poly.Convert(); Assert.AreEqual(4, poly.Count); Assert.AreEqual(4, poly2.Count); Assert.AreEqual("EIK", poly2.KernelName); for (int i = 0; i < poly.Count; i++) AssertX.AlmostEqual(poly[i], poly2[i]); } [TestMethod] public void GetPoint() { var poly = PolygonFactory.CreateBox(-1, 1); Assert.AreEqual(new Point2d(-1, -1), poly.GetPoint(0)); Assert.AreEqual(new Point2d(1, -1), poly.GetPoint(1)); Assert.AreEqual(new Point2d(1, 1), poly.GetPoint(2)); Assert.AreEqual(new Point2d(-1, 1), poly.GetPoint(3)); Assert.AreEqual(new Point2d(-1, -1), poly.GetPointClamped(-1)); Assert.AreEqual(new Point2d(-1, -1), poly.GetPointClamped(0)); Assert.AreEqual(new Point2d(1, -1), poly.GetPointClamped(1)); Assert.AreEqual(new Point2d(1, 1), poly.GetPointClamped(2)); Assert.AreEqual(new Point2d(-1, 1), poly.GetPointClamped(3)); Assert.AreEqual(new Point2d(-1, 1), poly.GetPointClamped(4)); Assert.AreEqual(new Point2d(-1, 1), poly.GetPointWrapped(-1)); Assert.AreEqual(new Point2d(-1, -1), poly.GetPointWrapped(0)); Assert.AreEqual(new Point2d(1, -1), poly.GetPointWrapped(1)); Assert.AreEqual(new Point2d(1, 1), poly.GetPointWrapped(2)); Assert.AreEqual(new Point2d(-1, 1), poly.GetPointWrapped(3)); Assert.AreEqual(new Point2d(-1, -1), poly.GetPointWrapped(4)); } [TestMethod] public void GetPoints() { var expected = new Point2d[] { new Point2d(-1, -1), new Point2d(1, -1), new Point2d(1, 1), new Point2d(-1, 1) }; var poly = PolygonFactory.CreateBox(-1, 1); var points = new Point2d[4]; poly.GetPoints(points, points.Length); CollectionAssert.AreEqual(expected, points); } [TestMethod] public void GetSegments() { var p0 = new Point2d(-1, -1); var p1 = new Point2d(1, -1); var p2 = new Point2d(1, 1); var p3 = new Point2d(-1, 1); var expected = new Segment2d[] { new Segment2d(p0, p1), new Segment2d(p1, p2), new Segment2d(p2, p3), new Segment2d(p3, p0) }; var poly = PolygonFactory.CreateBox(-1, 1); var segments = new Segment2d[4]; poly.GetSegments(segments, segments.Length); CollectionAssert.AreEqual(expected, segments); } [TestMethod] public void SetPoint() { var poly = PolygonFactory.CreateBox(-1, 1); var p0 = new Point2d(2, 3); var p3 = new Point2d(4, 5); poly.SetPoint(0, p0); poly.SetPoint(3, p3); Assert.AreEqual(p0, poly.GetPoint(0)); Assert.AreEqual(p3, poly.GetPoint(3)); } [TestMethod] public void SetPoints() { var poly = PolygonFactory.CreateBox(-1, 1); var expected = new Point2d[] { new Point2d(-2, -2), new Point2d(2, -2), new Point2d(4, -2), new Point2d(4, 2), new Point2d(2, 2), new Point2d(-2, 2) }; poly.SetPoints(expected, expected.Length); var points = new Point2d[6]; poly.GetPoints(points, points.Length); CollectionAssert.AreEqual(expected, points); } [TestMethod] public void Reverse() { var poly = PolygonFactory.CreateBox(-1, 1); Assert.AreEqual(ORIENTATION.POSITIVE, poly.Orientation); Assert.AreEqual(CLOCK_DIR.COUNTER_CLOCKWISE, poly.ClockDir); Assert.AreEqual(4.0, poly.FindSignedArea()); poly.Reverse(); Assert.AreEqual(ORIENTATION.NEGATIVE, poly.Orientation); Assert.AreEqual(CLOCK_DIR.CLOCKWISE, poly.ClockDir); Assert.AreEqual(-4.0, poly.FindSignedArea()); } [TestMethod] public void FindBoudingBox() { var poly = PolygonFactory.CreateBox(-1, 1); var box = poly.FindBoundingBox(); box.Round(2); Assert.AreEqual(new Point2d(-1, -1), box.Min); Assert.AreEqual(new Point2d(1, 1), box.Max); Assert.AreEqual(2, box.Width); Assert.AreEqual(2, box.Height); } [TestMethod] public void FindIfSimple() { var poly = new Polygon2(); var box = PolygonFactory.CreateBox(-1, 1); Assert.IsFalse(poly.FindIfSimple()); Assert.IsTrue(box.FindIfSimple()); } [TestMethod] public void FindIfConvex() { var poly = new Polygon2(); var box = PolygonFactory.CreateBox(-1, 1); Assert.IsFalse(poly.FindIfConvex()); Assert.IsTrue(box.FindIfConvex()); } [TestMethod] public void FindIfOrientation() { var poly = new Polygon2(); var box = PolygonFactory.CreateBox(-1, 1); Assert.AreEqual(ORIENTATION.ZERO, poly.FindOrientation()); Assert.AreEqual(ORIENTATION.POSITIVE, box.FindOrientation()); box.Reverse(); Assert.AreEqual(ORIENTATION.NEGATIVE, box.FindOrientation()); } [TestMethod] public void OrientatedSide() { var poly = PolygonFactory.CreateBox(-1, 1); var p1 = new Point2d(0, 0); var p2 = new Point2d(2, 2); var p3 = new Point2d(1, 1); Assert.AreEqual(ORIENTED_SIDE.ON_POSITIVE_SIDE, poly.OrientedSide(p1)); Assert.AreEqual(ORIENTED_SIDE.ON_NEGATIVE_SIDE, poly.OrientedSide(p2)); Assert.AreEqual(ORIENTED_SIDE.ON_BOUNDARY, poly.OrientedSide(p3)); } [TestMethod] public void BoundedSide() { var poly = PolygonFactory.CreateBox(-1, 1); var p1 = new Point2d(0, 0); var p2 = new Point2d(2, 2); var p3 = new Point2d(1, 1); Assert.AreEqual(BOUNDED_SIDE.ON_BOUNDED_SIDE, poly.BoundedSide(p1)); Assert.AreEqual(BOUNDED_SIDE.ON_UNBOUNDED_SIDE, poly.BoundedSide(p2)); Assert.AreEqual(BOUNDED_SIDE.ON_BOUNDARY, poly.BoundedSide(p3)); } [TestMethod] public void SignedArea() { var poly = PolygonFactory.CreateBox(-1, 1); Assert.AreEqual(4.0, poly.FindSignedArea()); Assert.AreEqual(4.0, poly.FindArea()); poly.Reverse(); Assert.AreEqual(-4.0, poly.FindSignedArea()); } [TestMethod] public void ContainsPoint() { var poly = PolygonFactory.CreateBox(-1, 1); var p1 = new Point2d(0, 0); var p2 = new Point2d(2, 2); var p3 = new Point2d(1, 1); Assert.IsTrue(poly.ContainsPoint(p1)); Assert.IsFalse(poly.ContainsPoint(p2)); Assert.IsTrue(poly.ContainsPoint(p3)); } } } ================================================ FILE: CGALDotNetTest/Polygons/Polygon2_EIK_Test.cs ================================================ using System; using System.Diagnostics; using Microsoft.VisualStudio.TestTools.UnitTesting; using CGALDotNet; using CGALDotNetGeometry.Numerics; using CGALDotNetGeometry.Shapes; using CGALDotNet.Polygons; namespace CGALDotNetTest.Polygons { [TestClass] public class Polygon2_EIK_Test { [TestMethod] public void CreatePolygon() { var poly = new Polygon2(); Assert.AreEqual(0, poly.Count); Assert.IsFalse(poly.IsSimple); Assert.IsTrue(poly.IsDegenerate); } [TestMethod] public void ReleasePolygon() { var poly = new Polygon2(); poly.Dispose(); Assert.IsTrue(poly.IsDisposed); } [TestMethod] public void CreateSimplePolygon() { var points = new Point2d[] { new Point2d(0, 0), new Point2d(5, 0), new Point2d(5, 5), new Point2d(0, 5) }; var poly = new Polygon2(points); Assert.AreEqual(4, poly.Count); Assert.IsTrue(poly.IsSimple); Assert.IsTrue(poly.IsCounterClockWise); Assert.IsTrue(poly.Orientation == ORIENTATION.POSITIVE); Assert.IsTrue(poly.ClockDir == CLOCK_DIR.COUNTER_CLOCKWISE); Assert.IsTrue(poly.FindIfConvex()); } [TestMethod] public void CreateConcavePolygon() { var points = new Point2d[] { new Point2d(0,0), new Point2d(5.1,0), new Point2d(1,1), new Point2d(0.5,6) }; var poly = new Polygon2(points); Assert.AreEqual(4, poly.Count); Assert.IsTrue(poly.IsSimple); Assert.IsTrue(poly.IsCounterClockWise); Assert.IsTrue(poly.Orientation == ORIENTATION.POSITIVE); Assert.IsTrue(poly.ClockDir == CLOCK_DIR.COUNTER_CLOCKWISE); Assert.IsFalse(poly.FindIfConvex()); } [TestMethod] public void CreateNonSimplePolygon() { var points = new Point2d[] { new Point2d(0, 0), new Point2d(8, 4), new Point2d(8, 0), new Point2d(0, 4), }; var poly = new Polygon2(points); Assert.AreEqual(4, poly.Count); Assert.IsFalse(poly.IsSimple); Assert.IsTrue(poly.IsDegenerate); Assert.IsTrue(poly.Orientation == ORIENTATION.ZERO); Assert.IsTrue(poly.ClockDir == CLOCK_DIR.ZERO); } [TestMethod] public void ArrayAcessor() { var poly = PolygonFactory.CreateBox(-1, 1); Assert.AreEqual(new Point2d(-1, -1), poly[0]); poly[0] = new Point2d(-2, -2); Assert.AreEqual(new Point2d(-2, -2), poly[0]); } [TestMethod] public void Clear() { var poly = PolygonFactory.CreateBox(-1, 1); Assert.AreEqual(4, poly.Count); poly.Clear(); Assert.AreEqual(0, poly.Count); } [TestMethod] public void Copy() { var poly = PolygonFactory.CreateBox(-1, 1); var copy = poly.Copy(); Assert.AreEqual(4, poly.Count); Assert.AreEqual(4, copy.Count); for (int i = 0; i < poly.Count; i++) Assert.AreEqual(poly[i], copy[i]); } [TestMethod] public void Convert() { var poly = PolygonFactory.CreateBox(-1, 1); var poly2 = poly.Convert(); Assert.AreEqual(4, poly.Count); Assert.AreEqual(4, poly2.Count); Assert.AreEqual("EEK", poly2.KernelName); for (int i = 0; i < poly.Count; i++) AssertX.AlmostEqual(poly[i], poly2[i]); } [TestMethod] public void GetPoint() { var poly = PolygonFactory.CreateBox(-1, 1); Assert.AreEqual(new Point2d(-1, -1), poly.GetPoint(0)); Assert.AreEqual(new Point2d(1, -1), poly.GetPoint(1)); Assert.AreEqual(new Point2d(1, 1), poly.GetPoint(2)); Assert.AreEqual(new Point2d(-1, 1), poly.GetPoint(3)); Assert.AreEqual(new Point2d(-1, -1), poly.GetPointClamped(-1)); Assert.AreEqual(new Point2d(-1, -1), poly.GetPointClamped(0)); Assert.AreEqual(new Point2d(1, -1), poly.GetPointClamped(1)); Assert.AreEqual(new Point2d(1, 1), poly.GetPointClamped(2)); Assert.AreEqual(new Point2d(-1, 1), poly.GetPointClamped(3)); Assert.AreEqual(new Point2d(-1, 1), poly.GetPointClamped(4)); Assert.AreEqual(new Point2d(-1, 1), poly.GetPointWrapped(-1)); Assert.AreEqual(new Point2d(-1, -1), poly.GetPointWrapped(0)); Assert.AreEqual(new Point2d(1, -1), poly.GetPointWrapped(1)); Assert.AreEqual(new Point2d(1, 1), poly.GetPointWrapped(2)); Assert.AreEqual(new Point2d(-1, 1), poly.GetPointWrapped(3)); Assert.AreEqual(new Point2d(-1, -1), poly.GetPointWrapped(4)); } [TestMethod] public void GetPoints() { var expected = new Point2d[] { new Point2d(-1, -1), new Point2d(1, -1), new Point2d(1, 1), new Point2d(-1, 1) }; var poly = PolygonFactory.CreateBox(-1, 1); var points = new Point2d[4]; poly.GetPoints(points, points.Length); CollectionAssert.AreEqual(expected, points); } [TestMethod] public void GetSegments() { var p0 = new Point2d(-1, -1); var p1 = new Point2d(1, -1); var p2 = new Point2d(1, 1); var p3 = new Point2d(-1, 1); var expected = new Segment2d[] { new Segment2d(p0, p1), new Segment2d(p1, p2), new Segment2d(p2, p3), new Segment2d(p3, p0) }; var poly = PolygonFactory.CreateBox(-1, 1); var segments = new Segment2d[4]; poly.GetSegments(segments, segments.Length); CollectionAssert.AreEqual(expected, segments); } [TestMethod] public void SetPoint() { var poly = PolygonFactory.CreateBox(-1, 1); var p0 = new Point2d(2, 3); var p3 = new Point2d(4, 5); poly.SetPoint(0, p0); poly.SetPoint(3, p3); Assert.AreEqual(p0, poly.GetPoint(0)); Assert.AreEqual(p3, poly.GetPoint(3)); } [TestMethod] public void SetPoints() { var poly = PolygonFactory.CreateBox(-1, 1); var expected = new Point2d[] { new Point2d(-2, -2), new Point2d(2, -2), new Point2d(4, -2), new Point2d(4, 2), new Point2d(2, 2), new Point2d(-2, 2) }; poly.SetPoints(expected, expected.Length); var points = new Point2d[6]; poly.GetPoints(points, points.Length); CollectionAssert.AreEqual(expected, points); } [TestMethod] public void Reverse() { var poly = PolygonFactory.CreateBox(-1, 1); Assert.AreEqual(ORIENTATION.POSITIVE, poly.Orientation); Assert.AreEqual(CLOCK_DIR.COUNTER_CLOCKWISE, poly.ClockDir); Assert.AreEqual(4.0, poly.FindSignedArea()); poly.Reverse(); Assert.AreEqual(ORIENTATION.NEGATIVE, poly.Orientation); Assert.AreEqual(CLOCK_DIR.CLOCKWISE, poly.ClockDir); Assert.AreEqual(-4.0, poly.FindSignedArea()); } [TestMethod] public void FindBoudingBox() { var poly = PolygonFactory.CreateBox(-1, 1); var box = poly.FindBoundingBox(); box.Round(2); Assert.AreEqual(new Point2d(-1, -1), box.Min); Assert.AreEqual(new Point2d(1, 1), box.Max); Assert.AreEqual(2, box.Width); Assert.AreEqual(2, box.Height); } [TestMethod] public void FindIfSimple() { var poly = new Polygon2(); var box = PolygonFactory.CreateBox(-1, 1); Assert.IsFalse(poly.FindIfSimple()); Assert.IsTrue(box.FindIfSimple()); } [TestMethod] public void FindIfConvex() { var poly = new Polygon2(); var box = PolygonFactory.CreateBox(-1, 1); Assert.IsFalse(poly.FindIfConvex()); Assert.IsTrue(box.FindIfConvex()); } [TestMethod] public void FindIfOrientation() { var poly = new Polygon2(); var box = PolygonFactory.CreateBox(-1, 1); Assert.AreEqual(ORIENTATION.ZERO, poly.FindOrientation()); Assert.AreEqual(ORIENTATION.POSITIVE, box.FindOrientation()); box.Reverse(); Assert.AreEqual(ORIENTATION.NEGATIVE, box.FindOrientation()); } [TestMethod] public void OrientatedSide() { var poly = PolygonFactory.CreateBox(-1, 1); var p1 = new Point2d(0, 0); var p2 = new Point2d(2, 2); var p3 = new Point2d(1, 1); Assert.AreEqual(ORIENTED_SIDE.ON_POSITIVE_SIDE, poly.OrientedSide(p1)); Assert.AreEqual(ORIENTED_SIDE.ON_NEGATIVE_SIDE, poly.OrientedSide(p2)); Assert.AreEqual(ORIENTED_SIDE.ON_BOUNDARY, poly.OrientedSide(p3)); } [TestMethod] public void BoundedSide() { var poly = PolygonFactory.CreateBox(-1, 1); var p1 = new Point2d(0, 0); var p2 = new Point2d(2, 2); var p3 = new Point2d(1, 1); Assert.AreEqual(BOUNDED_SIDE.ON_BOUNDED_SIDE, poly.BoundedSide(p1)); Assert.AreEqual(BOUNDED_SIDE.ON_UNBOUNDED_SIDE, poly.BoundedSide(p2)); Assert.AreEqual(BOUNDED_SIDE.ON_BOUNDARY, poly.BoundedSide(p3)); } [TestMethod] public void SignedArea() { var poly = PolygonFactory.CreateBox(-1, 1); Assert.AreEqual(4.0, poly.FindSignedArea()); Assert.AreEqual(4.0, poly.FindArea()); poly.Reverse(); Assert.AreEqual(-4.0, poly.FindSignedArea()); } [TestMethod] public void ContainsPoint() { var poly = PolygonFactory.CreateBox(-1, 1); var p1 = new Point2d(0, 0); var p2 = new Point2d(2, 2); var p3 = new Point2d(1, 1); Assert.IsTrue(poly.ContainsPoint(p1)); Assert.IsFalse(poly.ContainsPoint(p2)); Assert.IsTrue(poly.ContainsPoint(p3)); } } } ================================================ FILE: CGALDotNetTest/Polygons/PolygonWithHoles2_EEK_Test.cs ================================================ using System; using System.Text; using System.Diagnostics; using System.Collections.Generic; using Microsoft.VisualStudio.TestTools.UnitTesting; using CGALDotNet; using CGALDotNetGeometry.Numerics; using CGALDotNetGeometry.Shapes; using CGALDotNet.Polygons; namespace CGALDotNetTest.Polygons { [TestClass] public class PolygonWithHoles2_EEK_Test { [TestMethod] public void CreatePolygon() { var poly = new PolygonWithHoles2(); Assert.AreEqual(0, poly.Count); Assert.IsFalse(poly.IsSimple); Assert.IsTrue(poly.IsDegenerate); } [TestMethod] public void ReleasePolygon() { var poly = new PolygonWithHoles2(); poly.Dispose(); Assert.IsTrue(poly.IsDisposed); } [TestMethod] public void CreateSimplePolygon() { var points = new Point2d[] { new Point2d(0, 0), new Point2d(5, 0), new Point2d(5, 5), new Point2d(0, 5) }; var poly = new PolygonWithHoles2(points); Assert.AreEqual(4, poly.Count); Assert.IsFalse(poly.IsUnbounded); Assert.IsTrue(poly.IsSimple); Assert.IsTrue(poly.IsCounterClockWise); Assert.IsFalse(poly.IsDegenerate); Assert.IsTrue(poly.Orientation == ORIENTATION.POSITIVE); Assert.IsTrue(poly.ClockDir == CLOCK_DIR.COUNTER_CLOCKWISE); } [TestMethod] public void CreateConcavePolygon() { var points = new Point2d[] { new Point2d(0,0), new Point2d(5.1,0), new Point2d(1,1), new Point2d(0.5,6) }; var poly = new PolygonWithHoles2(points); Assert.IsFalse(poly.IsUnbounded); Assert.AreEqual(4, poly.Count); Assert.IsTrue(poly.IsSimple); Assert.IsTrue(poly.IsCounterClockWise); Assert.IsFalse(poly.IsDegenerate); Assert.IsTrue(poly.Orientation == ORIENTATION.POSITIVE); Assert.IsTrue(poly.ClockDir == CLOCK_DIR.COUNTER_CLOCKWISE); } [TestMethod] public void CreateNonSimplePolygon() { var points = new Point2d[] { new Point2d(0, 0), new Point2d(8, 4), new Point2d(8, 0), new Point2d(0, 4), }; var poly = new PolygonWithHoles2(points); Assert.IsFalse(poly.IsUnbounded); Assert.AreEqual(4, poly.Count); Assert.IsFalse(poly.IsSimple); Assert.IsTrue(poly.IsDegenerate); Assert.IsTrue(poly.Orientation == ORIENTATION.ZERO); Assert.IsTrue(poly.ClockDir == CLOCK_DIR.ZERO); } [TestMethod] public void Copy() { var poly1 = PolygonFactory.CreateDounut(5, 4, 8); var poly2 = poly1.Copy(); Assert.AreEqual(poly1.Count, poly2.Count); Assert.AreEqual(poly1.HoleCount, poly2.HoleCount); for (int i = 0; i < poly1.Count; i++) { var p1 = poly1.GetPoint(POLYGON_ELEMENT.BOUNDARY, i); var p2 = poly2.GetPoint(POLYGON_ELEMENT.BOUNDARY, i); AssertX.AlmostEqual(p1, p2, 0); } for (int i = 0; i < poly1.HoleCount; i++) { var hole1 = poly1.GetHole(i); var hole2 = poly2.GetHole(i); for (int j = 0; j < hole1.Count; j++) { var p1 = hole1.GetPoint(j); var p2 = hole2.GetPoint(j); AssertX.AlmostEqual(p1, p2, 0); } } } [TestMethod] public void Convert() { var poly1 = PolygonFactory.CreateDounut(5, 4, 8); var poly2 = poly1.Convert(); Assert.AreEqual(poly1.Count, poly2.Count); Assert.AreEqual(poly1.HoleCount, poly2.HoleCount); Assert.AreEqual("EIK", poly2.KernelName); for (int i = 0; i < poly1.Count; i++) { var p1 = poly1.GetPoint(POLYGON_ELEMENT.BOUNDARY, i); var p2 = poly2.GetPoint(POLYGON_ELEMENT.BOUNDARY, i); AssertX.AlmostEqual(p1, p2); } for (int i = 0; i < poly1.HoleCount; i++) { var hole1 = poly1.GetHole(i); var hole2 = poly2.GetHole(i); for (int j = 0; j < hole1.Count; j++) { var p1 = hole1.GetPoint(j); var p2 = hole2.GetPoint(j); AssertX.AlmostEqual(p1, p2); } } } [TestMethod] public void Clear() { var poly = PolygonFactory.CreateDounut(2, 1, 4); Assert.IsFalse(poly.IsUnbounded); Assert.AreEqual(4, poly.Count); Assert.AreEqual(1, poly.HoleCount); poly.Clear(); Assert.IsTrue(poly.IsUnbounded); Assert.AreEqual(0, poly.Count); Assert.AreEqual(0, poly.HoleCount); } [TestMethod] public void ClearHoles() { var poly = PolygonFactory.CreateDounut(2, 1, 4); Assert.AreEqual(1, poly.HoleCount); poly.ClearHoles(); Assert.AreEqual(0, poly.HoleCount); } [TestMethod] public void PointCount() { var poly = PolygonFactory.CreateDounut(2, 1, 4); Assert.AreEqual(4, poly.PointCount(POLYGON_ELEMENT.BOUNDARY)); Assert.AreEqual(4, poly.PointCount(POLYGON_ELEMENT.HOLE, 0)); } [TestMethod] public void Remove() { var poly = PolygonFactory.CreateDounut(2, 1, 4); Assert.IsTrue(!poly.IsUnbounded); Assert.AreEqual(1, poly.HoleCount); poly.Remove(POLYGON_ELEMENT.BOUNDARY); poly.Remove(POLYGON_ELEMENT.HOLE, 0); Assert.IsTrue(poly.IsUnbounded); Assert.AreEqual(0, poly.HoleCount); } [TestMethod] public void Reverse() { var poly = PolygonFactory.CreateDounut(2, 1, 4); Assert.AreEqual(ORIENTATION.POSITIVE, poly.FindOrientation(POLYGON_ELEMENT.BOUNDARY)); Assert.AreEqual(ORIENTATION.NEGATIVE, poly.FindOrientation(POLYGON_ELEMENT.HOLE, 0)); poly.Reverse(POLYGON_ELEMENT.BOUNDARY); poly.Reverse(POLYGON_ELEMENT.HOLE, 0); Assert.AreEqual(ORIENTATION.NEGATIVE, poly.FindOrientation(POLYGON_ELEMENT.BOUNDARY)); Assert.AreEqual(ORIENTATION.POSITIVE, poly.FindOrientation(POLYGON_ELEMENT.HOLE, 0)); } [TestMethod] public void GetPoint() { var outer = PolygonFactory.CreateBox(-2, 2); var inner = PolygonFactory.CreateBox(-1, 1); inner.Reverse(); var poly = new PolygonWithHoles2(outer); poly.AddHole(inner); Assert.AreEqual(new Point2d(-2, -2), poly.GetPoint(POLYGON_ELEMENT.BOUNDARY, 0)); Assert.AreEqual(new Point2d(2, -2), poly.GetPoint(POLYGON_ELEMENT.BOUNDARY, 1)); Assert.AreEqual(new Point2d(2, 2), poly.GetPoint(POLYGON_ELEMENT.BOUNDARY, 2)); Assert.AreEqual(new Point2d(-2, 2), poly.GetPoint(POLYGON_ELEMENT.BOUNDARY, 3)); Assert.AreEqual(new Point2d(-1, -1), poly.GetPoint(POLYGON_ELEMENT.HOLE, 0, 0)); Assert.AreEqual(new Point2d(-1, 1), poly.GetPoint(POLYGON_ELEMENT.HOLE, 1, 0)); Assert.AreEqual(new Point2d(1, 1), poly.GetPoint(POLYGON_ELEMENT.HOLE, 2, 0)); Assert.AreEqual(new Point2d(1, -1), poly.GetPoint(POLYGON_ELEMENT.HOLE, 3, 0)); } [TestMethod] public void GetPoints() { var outer = PolygonFactory.CreateBox(-2, 2); var inner = PolygonFactory.CreateBox(-1, 1); inner.Reverse(); var poly = new PolygonWithHoles2(outer); poly.AddHole(inner); var boundary = new Point2d[] { new Point2d(-2, -2), new Point2d(2, -2), new Point2d(2, 2), new Point2d(-2, 2) }; var hole = new Point2d[] { new Point2d(-1, -1), new Point2d(-1, 1), new Point2d(1, 1), new Point2d(1, -1) }; int count = poly.PointCount(POLYGON_ELEMENT.BOUNDARY); var tmp = new Point2d[count]; poly.GetPoints(POLYGON_ELEMENT.BOUNDARY, tmp, tmp.Length); CollectionAssert.AreEqual(boundary, tmp); count = poly.PointCount(POLYGON_ELEMENT.HOLE, 0); tmp = new Point2d[count]; poly.GetPoints(POLYGON_ELEMENT.HOLE, tmp, tmp.Length, 0); CollectionAssert.AreEqual(hole, tmp); } [TestMethod] public void GetAllPoints() { var outer = PolygonFactory.CreateBox(-2, 2); var inner = PolygonFactory.CreateBox(-1, 1); inner.Reverse(); var poly = new PolygonWithHoles2(outer); poly.AddHole(inner); var points = new Point2d[] { new Point2d(-2, -2), new Point2d(2, -2), new Point2d(2, 2), new Point2d(-2, 2), new Point2d(-1, -1), new Point2d(-1, 1), new Point2d(1, 1), new Point2d(1, -1) }; var tmp = new List(); poly.GetAllPoints(tmp); CollectionAssert.AreEqual(points, tmp); } } } ================================================ FILE: CGALDotNetTest/Polygons/PolygonWithHoles2_EIK_Test.cs ================================================ using System; using System.Text; using System.Diagnostics; using System.Collections.Generic; using Microsoft.VisualStudio.TestTools.UnitTesting; using CGALDotNet; using CGALDotNetGeometry.Numerics; using CGALDotNetGeometry.Shapes; using CGALDotNet.Polygons; namespace CGALDotNetTest.Polygons { [TestClass] public class PolygonWithHoles2_EIK_Test { [TestMethod] public void CreatePolygon() { var poly = new PolygonWithHoles2(); Assert.AreEqual(0, poly.Count); Assert.IsFalse(poly.IsSimple); Assert.IsTrue(poly.IsDegenerate); } [TestMethod] public void ReleasePolygon() { var poly = new PolygonWithHoles2(); poly.Dispose(); Assert.IsTrue(poly.IsDisposed); } [TestMethod] public void CreateSimplePolygon() { var points = new Point2d[] { new Point2d(0, 0), new Point2d(5, 0), new Point2d(5, 5), new Point2d(0, 5) }; var poly = new PolygonWithHoles2(points); Assert.AreEqual(4, poly.Count); Assert.IsFalse(poly.IsUnbounded); Assert.IsTrue(poly.IsSimple); Assert.IsTrue(poly.IsCounterClockWise); Assert.IsFalse(poly.IsDegenerate); Assert.IsTrue(poly.Orientation == ORIENTATION.POSITIVE); Assert.IsTrue(poly.ClockDir == CLOCK_DIR.COUNTER_CLOCKWISE); } [TestMethod] public void CreateConcavePolygon() { var points = new Point2d[] { new Point2d(0,0), new Point2d(5.1,0), new Point2d(1,1), new Point2d(0.5,6) }; var poly = new PolygonWithHoles2(points); Assert.IsFalse(poly.IsUnbounded); Assert.AreEqual(4, poly.Count); Assert.IsTrue(poly.IsSimple); Assert.IsTrue(poly.IsCounterClockWise); Assert.IsFalse(poly.IsDegenerate); Assert.IsTrue(poly.Orientation == ORIENTATION.POSITIVE); Assert.IsTrue(poly.ClockDir == CLOCK_DIR.COUNTER_CLOCKWISE); } [TestMethod] public void CreateNonSimplePolygon() { var points = new Point2d[] { new Point2d(0, 0), new Point2d(8, 4), new Point2d(8, 0), new Point2d(0, 4), }; var poly = new PolygonWithHoles2(points); Assert.IsFalse(poly.IsUnbounded); Assert.AreEqual(4, poly.Count); Assert.IsFalse(poly.IsSimple); Assert.IsTrue(poly.IsDegenerate); Assert.IsTrue(poly.Orientation == ORIENTATION.ZERO); Assert.IsTrue(poly.ClockDir == CLOCK_DIR.ZERO); } [TestMethod] public void Copy() { var poly1 = PolygonFactory.CreateDounut(5, 4, 8); var poly2 = poly1.Copy(); Assert.AreEqual(poly1.Count, poly2.Count); Assert.AreEqual(poly1.HoleCount, poly2.HoleCount); for (int i = 0; i < poly1.Count; i++) { var p1 = poly1.GetPoint(POLYGON_ELEMENT.BOUNDARY, i); var p2 = poly2.GetPoint(POLYGON_ELEMENT.BOUNDARY, i); AssertX.AlmostEqual(p1, p2, 0); } for (int i = 0; i < poly1.HoleCount; i++) { var hole1 = poly1.GetHole(i); var hole2 = poly2.GetHole(i); for (int j = 0; j < hole1.Count; j++) { var p1 = hole1.GetPoint(j); var p2 = hole2.GetPoint(j); AssertX.AlmostEqual(p1, p2, 0); } } } [TestMethod] public void Convert() { var poly1 = PolygonFactory.CreateDounut(5, 4, 8); var poly2 = poly1.Convert(); Assert.AreEqual(poly1.Count, poly2.Count); Assert.AreEqual(poly1.HoleCount, poly2.HoleCount); Assert.AreEqual("EEK", poly2.KernelName); for (int i = 0; i < poly1.Count; i++) { var p1 = poly1.GetPoint(POLYGON_ELEMENT.BOUNDARY, i); var p2 = poly2.GetPoint(POLYGON_ELEMENT.BOUNDARY, i); AssertX.AlmostEqual(p1, p2); } for (int i = 0; i < poly1.HoleCount; i++) { var hole1 = poly1.GetHole(i); var hole2 = poly2.GetHole(i); for (int j = 0; j < hole1.Count; j++) { var p1 = hole1.GetPoint(j); var p2 = hole2.GetPoint(j); AssertX.AlmostEqual(p1, p2); } } } [TestMethod] public void Clear() { var poly = PolygonFactory.CreateDounut(2, 1, 4); Assert.IsFalse(poly.IsUnbounded); Assert.AreEqual(4, poly.Count); Assert.AreEqual(1, poly.HoleCount); poly.Clear(); Assert.IsTrue(poly.IsUnbounded); Assert.AreEqual(0, poly.Count); Assert.AreEqual(0, poly.HoleCount); } [TestMethod] public void ClearHoles() { var poly = PolygonFactory.CreateDounut(2, 1, 4); Assert.AreEqual(1, poly.HoleCount); poly.ClearHoles(); Assert.AreEqual(0, poly.HoleCount); } [TestMethod] public void PointCount() { var poly = PolygonFactory.CreateDounut(2, 1, 4); Assert.AreEqual(4, poly.PointCount(POLYGON_ELEMENT.BOUNDARY)); Assert.AreEqual(4, poly.PointCount(POLYGON_ELEMENT.HOLE, 0)); } [TestMethod] public void Remove() { var poly = PolygonFactory.CreateDounut(2, 1, 4); Assert.IsTrue(!poly.IsUnbounded); Assert.AreEqual(1, poly.HoleCount); poly.Remove(POLYGON_ELEMENT.BOUNDARY); poly.Remove(POLYGON_ELEMENT.HOLE, 0); Assert.IsTrue(poly.IsUnbounded); Assert.AreEqual(0, poly.HoleCount); } [TestMethod] public void Reverse() { var poly = PolygonFactory.CreateDounut(2, 1, 4); Assert.AreEqual(ORIENTATION.POSITIVE, poly.FindOrientation(POLYGON_ELEMENT.BOUNDARY)); Assert.AreEqual(ORIENTATION.NEGATIVE, poly.FindOrientation(POLYGON_ELEMENT.HOLE, 0)); poly.Reverse(POLYGON_ELEMENT.BOUNDARY); poly.Reverse(POLYGON_ELEMENT.HOLE, 0); Assert.AreEqual(ORIENTATION.NEGATIVE, poly.FindOrientation(POLYGON_ELEMENT.BOUNDARY)); Assert.AreEqual(ORIENTATION.POSITIVE, poly.FindOrientation(POLYGON_ELEMENT.HOLE, 0)); } [TestMethod] public void GetPoint() { var outer = PolygonFactory.CreateBox(-2, 2); var inner = PolygonFactory.CreateBox(-1, 1); inner.Reverse(); var poly = new PolygonWithHoles2(outer); poly.AddHole(inner); Assert.AreEqual(new Point2d(-2, -2), poly.GetPoint(POLYGON_ELEMENT.BOUNDARY, 0)); Assert.AreEqual(new Point2d(2, -2), poly.GetPoint(POLYGON_ELEMENT.BOUNDARY, 1)); Assert.AreEqual(new Point2d(2, 2), poly.GetPoint(POLYGON_ELEMENT.BOUNDARY, 2)); Assert.AreEqual(new Point2d(-2, 2), poly.GetPoint(POLYGON_ELEMENT.BOUNDARY, 3)); Assert.AreEqual(new Point2d(-1, -1), poly.GetPoint(POLYGON_ELEMENT.HOLE, 0, 0)); Assert.AreEqual(new Point2d(-1, 1), poly.GetPoint(POLYGON_ELEMENT.HOLE, 1, 0)); Assert.AreEqual(new Point2d(1, 1), poly.GetPoint(POLYGON_ELEMENT.HOLE, 2, 0)); Assert.AreEqual(new Point2d(1, -1), poly.GetPoint(POLYGON_ELEMENT.HOLE, 3, 0)); } [TestMethod] public void GetPoints() { var outer = PolygonFactory.CreateBox(-2, 2); var inner = PolygonFactory.CreateBox(-1, 1); inner.Reverse(); var poly = new PolygonWithHoles2(outer); poly.AddHole(inner); var boundary = new Point2d[] { new Point2d(-2, -2), new Point2d(2, -2), new Point2d(2, 2), new Point2d(-2, 2) }; var hole = new Point2d[] { new Point2d(-1, -1), new Point2d(-1, 1), new Point2d(1, 1), new Point2d(1, -1) }; int count = poly.PointCount(POLYGON_ELEMENT.BOUNDARY); var tmp = new Point2d[count]; poly.GetPoints(POLYGON_ELEMENT.BOUNDARY, tmp, tmp.Length); CollectionAssert.AreEqual(boundary, tmp); count = poly.PointCount(POLYGON_ELEMENT.HOLE, 0); tmp = new Point2d[count]; poly.GetPoints(POLYGON_ELEMENT.HOLE, tmp, tmp.Length, 0); CollectionAssert.AreEqual(hole, tmp); } [TestMethod] public void GetAllPoints() { var outer = PolygonFactory.CreateBox(-2, 2); var inner = PolygonFactory.CreateBox(-1, 1); inner.Reverse(); var poly = new PolygonWithHoles2(outer); poly.AddHole(inner); var points = new Point2d[] { new Point2d(-2, -2), new Point2d(2, -2), new Point2d(2, 2), new Point2d(-2, 2), new Point2d(-1, -1), new Point2d(-1, 1), new Point2d(1, 1), new Point2d(1, -1) }; var tmp = new List(); poly.GetAllPoints(tmp); CollectionAssert.AreEqual(points, tmp); } } } ================================================ FILE: CGALDotNetTest/Polyhedra/Polyhedron3_EEK_Test.cs ================================================ using System; using System.Diagnostics; using Microsoft.VisualStudio.TestTools.UnitTesting; using CGALDotNet; using CGALDotNetGeometry.Numerics; using CGALDotNetGeometry.Shapes; using CGALDotNet.Polyhedra; namespace CGALDotNetTest.Polyhedra { [TestClass] public class Polyhedron3_EEK_Test { Point3d[] cube_points = new Point3d[] { new Point3d(-0.5, -0.5, -0.5), new Point3d(0.5, -0.5, -0.5), new Point3d(0.5, 0.5, -0.5), new Point3d(-0.5, 0.5, -0.5), new Point3d(-0.5, 0.5, 0.5), new Point3d(0.5, 0.5, 0.5), new Point3d(0.5, -0.5, 0.5), new Point3d(-0.5, -0.5, 0.5) }; [TestMethod] public void CreatePolyhedron() { var poly = new Polyhedron3(); Assert.AreEqual(0, poly.VertexCount); Assert.IsTrue(poly.IsValid); } [TestMethod] public void ReleasePolyhedron() { var poly = new Polyhedron3(); poly.Dispose(); Assert.IsTrue(poly.IsDisposed); } [TestMethod] public void VertexCount() { var poly = PolyhedronFactory.CreateCube(1, true); Assert.AreEqual(8, poly.VertexCount); } [TestMethod] public void FaceCount() { var poly = PolyhedronFactory.CreateCube(1, true); Assert.AreEqual(6, poly.FaceCount); } [TestMethod] public void HalfedgeCount() { var poly = PolyhedronFactory.CreateCube(1, true); Assert.AreEqual(24, poly.HalfedgeCount); } public void BorderEdgeCount() { } public void BorderHalfEdgeCount() { } [TestMethod] public void IsValid() { var poly = PolyhedronFactory.CreateCube(1, true); Assert.IsTrue(poly.IsValid); } [TestMethod] public void IsClosed() { var poly = PolyhedronFactory.CreateCube(1, true); Assert.IsTrue(poly.IsClosed); } [TestMethod] public void IsTriangle() { var poly = PolyhedronFactory.CreateCube(1, false); Assert.IsTrue(poly.IsTriangle); } [TestMethod] public void IsQuad() { var poly = PolyhedronFactory.CreateCube(1, true); Assert.IsTrue(poly.IsQuad); } [TestMethod] public void Clear() { var poly = PolyhedronFactory.CreateCube(1, true); poly.Clear(); Assert.AreEqual(0, poly.VertexCount); } public void CreateMesh() { } public void CreateTriangleMesh() { } public void CreateQuadMesh() { } public void CreateTriangleQuadMesh() { } public void CreatePolygonalMesh() { } public void CreatePolygonMesh() { } public void GetIndices() { } public void GetTriangleIndices() { } public void GetQuadIndices() { } public void GetTriangleQuadIndices() { } public void GetPolygonalIndices() { } public void GetDualPolygonalIndices() { } [TestMethod] public void GetPoint() { var poly = PolyhedronFactory.CreateCube(1, true); for(int i = 0; i < poly.VertexCount; i++) { Assert.AreEqual(cube_points[i], poly.GetPoint(i)); } } [TestMethod] public void GetPoints() { var poly = PolyhedronFactory.CreateCube(1, true); var points = new Point3d[poly.VertexCount]; poly.GetPoints(points, points.Length); for (int i = 0; i < poly.VertexCount; i++) { Assert.AreEqual(cube_points[i], points[i]); } } [TestMethod] public void SetPoint() { var poly = PolyhedronFactory.CreateCube(1, true); var p0 = new Point3d(1, 2, 3); var p3 = new Point3d(-1, -2, -3); poly.SetPoint(0, p0); poly.SetPoint(3, p3); Assert.AreEqual(p0, poly.GetPoint(0)); Assert.AreEqual(p3, poly.GetPoint(3)); } [TestMethod] public void SetPoints() { var poly = new Polyhedron3(); poly.SetPoints(cube_points, cube_points.Length); for (int i = 0; i < poly.VertexCount; i++) { Assert.AreEqual(cube_points[i], poly.GetPoint(i)); } } public void GetSegment() { } public void GetSegments() { } public void GetTriangle() { } public void GetTriangles() { } public void GetVertex() { } public void GetVertices() { } public void GetFace() { } public void GetFaces() { } public void GetHalfedge() { } public void GetHalfedges() { } public void GetPolygonalCount() { } public void GetDualPolygonalCount() { } public void GetCentroids() { } public void GetVertexNormals() { } public void GetFaceNormals() { } public void Transform() { } public void Triangulate() { } public void BoundedSide() { } public void ContainsPoint() { } public void LocateFace() { } public void LocateVertex() { } public void LocateHalfedge() { } public void DoesSelfIntersect() { } public void FindIfValid() { } public void FindBoundingBox() { } public void FindArea() { } public void FindCentroid() { } public void FindVolume() { } public void FindIfClosed() { } public void FindIfTriangleMesh() { } public void FindIfQuadMesh() { } public void ToArray() { } public void ToList() { } } } ================================================ FILE: CGALDotNetTest/Polyhedra/SurfaceMesh3_EEK_Test.cs ================================================ using System; using System.Diagnostics; using Microsoft.VisualStudio.TestTools.UnitTesting; using CGALDotNet; using CGALDotNetGeometry.Numerics; using CGALDotNetGeometry.Shapes; using CGALDotNet.Polyhedra; namespace CGALDotNetTest.Polyhedra { [TestClass] public class SurfaceMesh3_EEK_Test { /* public int VertexCount(); public int HalfedgeCount(); public int EdgeCount(); public int FaceCount(); public int BorderEdgeCount(); public int BuildStamp(); public int RemovedVertexCount(); public int RemovedHalfedgeCount(); public int RemovedEdgeCount(); public int RemovedFaceCount(); public bool IsValid() { } public bool IsClosed() { } public bool IsTriangle() { } public bool IsQuad() { } public void Clear() { } public int AddVertex(Point3d point) { } public int AddEdge(int v0, int v1) { } public int AddTriangle(int v0, int v1, int v2) { } public int AddQuad(int v0, int v1, int v2, int v3) { } public int AddPentagon(int v0, int v1, int v2, int v3, int v4) { } public int AddHexagon(int v0, int v1, int v2, int v3, int v4, int v5) { } public int AddPolygon(int[] indices, int count) { } public bool HasGarbage => Kernel.HasGarbage(Ptr); public void CollectGarbage() { } public Point3d GetPoint(int index) { } public void GetPoints(Point3d[] points, int count) { } public void SetPoint(int index, Point3d point) { } public void SetPoints(Point3d[] points, int count) { } public bool GetSegment(int index, out Segment3d segment) { } public void GetSegments(Segment3d[] segments, int count) { } public bool GetTriangle(int index, out Triangle3d triangle) { } public void GetTriangles(Triangle3d[] triangles, int count) { } public bool GetVertex(int index, out MeshVertex3 vertex) { } public void GetVertices(MeshVertex3[] vertices, int count) { } public bool GetFace(int index, out MeshFace3 face) { } public void GetFaces(MeshFace3[] faces, int count) { } public bool GetHalfedge(int index, out MeshHalfedge3 halfedge) { } public void GetHalfedges(MeshHalfedge3[] halfedges, int count) { } public int VertexDegree(int vertex) { } public int FaceDegree(int face) { } public bool VertexIsIsolated(int vertex) { } public bool VertexIsBorder(int vertex, bool check_all_incident_halfedges = true) } public bool EdgeIsBorder(int edge) } public int NextHalfedge(int halfedge) { } public int PreviousHalfedge(int halfedge) { } public int OppositeHalfedge(int halfedge) { } public int SourceVertex(int halfedge) { } public int TargetVertex(int halfedge) { } public bool RemoveVertex(int vertex) { } public bool RemoveEdge(int edge) { } public bool RemoveFace(int face) { } public bool IsVertexRemoved(int index) { } public bool IsFaceRemoved(int index) { } public bool IsHalfedgeRemoved(int index) { } public bool IsEdgeRemoved(int index) { } public bool IsVertexValid(int vertex) { } public bool IsEdgeValid(int edge) { } public bool IsHalfedgeValid(int halfedge) { } public bool IsFaceValid(int face) { } public void Transform(Point3d translation, Quaternion3d rotation, Point3d scale) { } public void CreateMesh(Point3d[] points, int[] triangles, int[] quads = null) { } public void CreateTriangleMesh(Point3d[] points, int pointCount, int[] indices, int indexCount) { } public void CreateQuadMesh(Point3d[] points, int pointCount, int[] indices, int indexCount) { } public void CreateTriangleQuadMesh(Point3d[] points, int pointsCount, int[] triangles, int triangleCount, int[] quads, int quadsCount) { } public void CreatePolygonalMesh(Point3d[] points, int pointsCount, PolygonalIndices indices) { } public void CreatePolygonMesh(Point2d[] points, int count, bool xz) { } public void GetIndices(int[] triangles, int[] quads = null) { } public void GetTriangleIndices(int[] triangles, int trianglesCount) { } public void GetQuadIndices(int[] quads, int quadsCount) { } public void GetTriangleQuadIndices(int[] triangles, int trianglesCount, int[] quads, int quadsCount) { } public PolygonalIndices GetPolygonalIndices() { } public bool IsVertexBorder(int index, bool check_all_incident_halfedges) { } public bool IsHalfedgeBorder(int index) { } public bool IsEdgeBorder(int index) { } public PolygonalCount GetPolygonalCount() { } public Box3d FindBoundingBox() { } public void Triangulate() { } public BOOL_OR_UNDETERMINED DoesSelfIntersect() { } public BOUNDED_SIDE BoundedSide(Point3d point) { } public bool ContainsPoint(Point3d point, bool includeBoundary = true) { } public abstract MeshHitResult LocateFace(Ray3d ray); public abstract MeshHitResult ClosestFace(Point3d point); public bool LocateFace(Ray3d ray, out MeshFace3 face) { } public bool LocateVertex(Ray3d ray, double radius, out MeshVertex3 vertex) { } public bool LocateHalfedge(Ray3d ray, double radius, out MeshHalfedge3 edge) { } public BOOL_OR_UNDETERMINED DoIntersect(SurfaceMesh3 mesh, bool test_bounded_sides = true) { } public void ComputeVertexNormals() { } public void ComputeFaceNormals() { } public void GetVertexNormals(Vector3d[] normals, int count) { } public void GetFaceNormals(Vector3d[] normals, int count) { } public Point3d[] ToArray() { } public List ToList() { } protected override void ReleasePtr() { } */ } } ================================================ FILE: CGALDotNetTest/Processing/MeshProcessingConnectionsPolyhedronTest.cs ================================================ using System; using System.Collections.Generic; using System.Text; using Microsoft.VisualStudio.TestTools.UnitTesting; using CGALDotNet; using CGALDotNetGeometry.Numerics; using CGALDotNetGeometry.Shapes; using CGALDotNetGeometry.Extensions; using CGALDotNet.Polyhedra; using CGALDotNet.Processing; using CGALDotNet.Extensions; namespace CGALDotNetTest.Processing { [TestClass] public class MeshProcessingConnectionsPolyhedronTest { private MeshProcessingConnections Processor => MeshProcessingConnections.Instance; private Polyhedron3 testMesh; private Polyhedron3 TestMesh { get { if (testMesh == null) { var cube1 = SurfaceMeshFactory.CreateCube(); cube1.Translate(new Point3d(-1, 0, 0)); var cube2 = SurfaceMeshFactory.CreateCube(1, true); cube2.Translate(new Point3d(1, 0, 0)); cube1.Join(cube2); testMesh = cube1.ToPolyhedronMesh(); } return testMesh.Copy(); } } /* [TestMethod] public void UnconnectedComponents() { Assert.AreEqual(2, Processor.UnconnectedComponents(TestMesh)); } */ [TestMethod] public void ConnectedFaces() { var faces = new List(); Processor.ConnectedFaces(TestMesh, 0, faces); Assert.AreEqual(12, faces.Count); Assert.IsFalse(faces.HasNullIndex()); } [TestMethod] public void SplitUnconnectedComponents() { var faces = new List>(); Processor.SplitUnconnectedComponents(TestMesh, faces); Assert.AreEqual(2, faces.Count); } [TestMethod] public void KeepLargeComponents() { int removed = Processor.KeepLargeComponents(TestMesh, 12); Assert.AreEqual(1, removed); } [TestMethod] public void KeepLargestComponents() { int removed = Processor.KeepLargestComponents(TestMesh, 1); Assert.AreEqual(1, removed); } } } ================================================ FILE: CGALDotNetTest/Processing/MeshProcessingConnectionsSurfaceMeshTest.cs ================================================ using System; using System.Collections.Generic; using System.Text; using Microsoft.VisualStudio.TestTools.UnitTesting; using CGALDotNet; using CGALDotNetGeometry.Numerics; using CGALDotNetGeometry.Shapes; using CGALDotNetGeometry.Extensions; using CGALDotNet.Polyhedra; using CGALDotNet.Processing; using CGALDotNet.Extensions; namespace CGALDotNetTest.Processing { [TestClass] public class MeshProcessingConnectionsSurfaceMeshTest { private MeshProcessingConnections Processor => MeshProcessingConnections.Instance; private SurfaceMesh3 testMesh; private SurfaceMesh3 TestMesh { get { if (testMesh == null) { var cube1 = SurfaceMeshFactory.CreateCube(); cube1.Translate(new Point3d(-1, 0, 0)); var cube2 = SurfaceMeshFactory.CreateCube(1, true); cube2.Translate(new Point3d(1, 0, 0)); cube1.Join(cube2); testMesh = cube1; } return testMesh.Copy(); } } [TestMethod] public void UnconnectedComponents() { Assert.AreEqual(2, Processor.UnconnectedComponents(TestMesh)); } [TestMethod] public void ConnectedFaces() { var faces = new List(); Processor.ConnectedFaces(TestMesh, 0, faces); Assert.AreEqual(12, faces.Count); Assert.IsFalse(faces.HasNullIndex()); } [TestMethod] public void SplitUnconnectedComponents() { var faces = new List>(); Processor.SplitUnconnectedComponents(TestMesh, faces); Assert.AreEqual(2, faces.Count); } [TestMethod] public void KeepLargeComponents() { int removed = Processor.KeepLargeComponents(TestMesh, 12); Assert.AreEqual(1, removed); } [TestMethod] public void KeepLargestComponents() { int removed = Processor.KeepLargestComponents(TestMesh, 1); Assert.AreEqual(1, removed); } } } ================================================ FILE: CGALDotNetTest/Processing/MeshProcessingFeaturesPolyhedronTest.cs ================================================ using System; using System.Collections.Generic; using System.Text; using Microsoft.VisualStudio.TestTools.UnitTesting; using CGALDotNet; using CGALDotNetGeometry.Numerics; using CGALDotNetGeometry.Extensions; using CGALDotNet.Polyhedra; using CGALDotNet.Processing; namespace CGALDotNetTest.Processing { [TestClass] public class MeshProcessingFeaturesPolyhedronTest { private MeshProcessingFeatures Processor => MeshProcessingFeatures.Instance; private Polyhedron3 testMesh; private Polyhedron3 TestMesh { get { if (testMesh == null) { testMesh = PolyhedronFactory.CreateCube(1, true); } return testMesh.Copy(); } } [TestMethod] public void DetectSharpEdges() { var featureEdges = new List(); var angle = new Degree(90); Processor.DetectSharpEdges(TestMesh, angle, featureEdges); Assert.AreEqual(12, featureEdges.Count); Assert.IsFalse(featureEdges.HasNullIndex()); } /* [TestMethod] public void SharpEdgesSegmentation() { var featureEdges = new List(); var featurePatches = new List>(); var angle = new Degree(90); Processor.SharpEdgesSegmentation(TestMesh, angle, featureEdges, featurePatches); Assert.AreEqual(12, featureEdges.Count); Assert.AreEqual(5, featurePatches.Count); Assert.IsFalse(featureEdges.HasNullIndex()); foreach (var patch in featurePatches) Assert.IsFalse(patch.HasNullIndex()); } */ [TestMethod] public void EdgeLengthMinMaxAvg() { var mesh = TestMesh; mesh.Scale(new Point3d(2, 0.5, 1)); var minmax = Processor.EdgeLengthMinMaxAvg(mesh); Assert.AreEqual(0.5, minmax.Min); Assert.AreEqual(2, minmax.Max); Assert.AreEqual(1.17, Math.Round(minmax.Average, 2)); } [TestMethod] public void FaceAreaMinMaxAvg() { var mesh = TestMesh; mesh.Scale(new Point3d(2, 0.5, 1)); var minmax = Processor.FaceAreaMinMaxAvg(mesh); Assert.AreEqual(0.25, minmax.Min); Assert.AreEqual(1, minmax.Max); Assert.AreEqual(0.58, Math.Round(minmax.Average, 2)); } } } ================================================ FILE: CGALDotNetTest/Processing/MeshProcessingFeaturesSurfaceMeshTest.cs ================================================ using System; using System.Collections.Generic; using System.Text; using Microsoft.VisualStudio.TestTools.UnitTesting; using CGALDotNet; using CGALDotNetGeometry.Numerics; using CGALDotNetGeometry.Shapes; using CGALDotNetGeometry.Extensions; using CGALDotNet.Polyhedra; using CGALDotNet.Processing; namespace CGALDotNetTest.Processing { [TestClass] public class MeshProcessingFeaturesSurfaceMeshTest { private MeshProcessingFeatures Processor => MeshProcessingFeatures.Instance; private SurfaceMesh3 testMesh; private SurfaceMesh3 TestMesh { get { if (testMesh == null) { testMesh = SurfaceMeshFactory.CreateCube(1, true); } return testMesh.Copy(); } } [TestMethod] public void DetectSharpEdges() { var featureEdges = new List(); var angle = new Degree(90); Processor.DetectSharpEdges(TestMesh, angle, featureEdges); Assert.AreEqual(12, featureEdges.Count); Assert.IsFalse(featureEdges.HasNullIndex()); } [TestMethod] public void SharpEdgesSegmentation() { var featureEdges = new List(); var featurePatches = new List>(); var angle = new Degree(90); Processor.SharpEdgesSegmentation(TestMesh, angle, featureEdges, featurePatches); Assert.AreEqual(12, featureEdges.Count); Assert.AreEqual(5, featurePatches.Count); Assert.IsFalse(featureEdges.HasNullIndex()); foreach(var patch in featurePatches) Assert.IsFalse(patch.HasNullIndex()); } [TestMethod] public void EdgeLengthMinMaxAvg() { var mesh = TestMesh; mesh.Scale(new Point3d(2, 0.5, 1)); var minmax = Processor.EdgeLengthMinMaxAvg(mesh); Assert.AreEqual(0.5, minmax.Min); Assert.AreEqual(2, minmax.Max); Assert.AreEqual(1.17, Math.Round(minmax.Average, 2)); } [TestMethod] public void FaceAreaMinMaxAvg() { var mesh = TestMesh; mesh.Scale(new Point3d(2, 0.5, 1)); var minmax = Processor.FaceAreaMinMaxAvg(mesh); Console.WriteLine(minmax); Assert.AreEqual(0.25, minmax.Min); Assert.AreEqual(1, minmax.Max); Assert.AreEqual(0.58, Math.Round(minmax.Average, 2)); } } } ================================================ FILE: CGALDotNetTest/Processing/MeshProcessingLocatePolyhedronTest.cs ================================================ using System; using System.Collections.Generic; using System.Text; using Microsoft.VisualStudio.TestTools.UnitTesting; using CGALDotNet; using CGALDotNetGeometry.Numerics; using CGALDotNetGeometry.Shapes; using CGALDotNet.Polyhedra; using CGALDotNet.Processing; using CGALDotNet.Extensions; namespace CGALDotNetTest.Processing { [TestClass] public class MeshProcessingLocatePolyhedronTest { private MeshProcessingLocate Processor => MeshProcessingLocate.Instance; private Polyhedron3 testMesh; private Polyhedron3 TestMesh { get { if (testMesh == null) { testMesh = PolyhedronFactory.CreateCube(); } return testMesh.Copy(); } } [TestMethod] public void RandomLocationOnMesh() { var point = Processor.RandomLocationOnMesh(TestMesh); } [TestMethod] public void LocateFace() { var ray = new Ray3d(new Point3d(2, 0, 0), new Vector3d(-1, 0 ,0)); var result = Processor.LocateFace(TestMesh, ray); Assert.AreEqual(4, result.Face); Assert.AreEqual(new Point3d(0.5, 0, 0), result.Point); Assert.AreEqual(new Point3d(0.5, 0, 0.5), result.Coord); } [TestMethod] public void ClosestFace() { var point = new Point3d(2, 0, 0); var result = Processor.ClosestFace(TestMesh, point); Assert.AreEqual(4, result.Face); Assert.AreEqual(new Point3d(0.5, 0, 0), result.Point); Assert.AreEqual(new Point3d(0.5, 0, 0.5), result.Coord); } } } ================================================ FILE: CGALDotNetTest/Processing/MeshProcessingLocateSurfaceMeshTest.cs ================================================ using System; using System.Collections.Generic; using System.Text; using Microsoft.VisualStudio.TestTools.UnitTesting; using CGALDotNet; using CGALDotNetGeometry.Numerics; using CGALDotNetGeometry.Shapes; using CGALDotNet.Polyhedra; using CGALDotNet.Processing; using CGALDotNet.Extensions; namespace CGALDotNetTest.Processing { [TestClass] public class MeshProcessingLocateSurfaceMeshTest { private MeshProcessingLocate Processor => MeshProcessingLocate.Instance; private SurfaceMesh3 testMesh; private SurfaceMesh3 TestMesh { get { if (testMesh == null) { testMesh = SurfaceMeshFactory.CreateCube(); } return testMesh.Copy(); } } [TestMethod] public void RandomLocationOnMesh() { var point = Processor.RandomLocationOnMesh(TestMesh); } [TestMethod] public void LocateFace() { var ray = new Ray3d(new Point3d(2, 0, 0), new Vector3d(-1, 0, 0)); var result = Processor.LocateFace(TestMesh, ray); Assert.AreEqual(4, result.Face); Assert.AreEqual(new Point3d(0.5, 0, 0), result.Point); Assert.AreEqual(new Point3d(0.5, 0, 0.5), result.Coord); } [TestMethod] public void ClosestFace() { var point = new Point3d(2, 0, 0); var result = Processor.ClosestFace(TestMesh, point); Assert.AreEqual(4, result.Face); Assert.AreEqual(new Point3d(0.5, 0, 0), result.Point); Assert.AreEqual(new Point3d(0.5, 0, 0.5), result.Coord); } } } ================================================ FILE: CGALDotNetTest/Processing/MeshProcessingMeshingPolyhedronTest.cs ================================================ using System; using System.Collections.Generic; using System.Text; using Microsoft.VisualStudio.TestTools.UnitTesting; using CGALDotNet; using CGALDotNetGeometry.Numerics; using CGALDotNetGeometry.Shapes; using CGALDotNet.Polyhedra; using CGALDotNet.Processing; using CGALDotNet.Extensions; namespace CGALDotNetTest.Processing { [TestClass] public class MeshProcessingMeshingPolyhedronTest { private MeshProcessingMeshing Processor => MeshProcessingMeshing.Instance; private Polyhedron3 testMesh; private Polyhedron3 TestMesh { get { if (testMesh == null) { testMesh = PolyhedronFactory.CreateCube(1, true); } return testMesh.Copy(); } } [TestMethod] public void Extrude() { var extured = Processor.Extrude(TestMesh, new Vector3d(0, 1, 0)); } [TestMethod] public void Fair() { var success = Processor.Fair(TestMesh, 0, 1); Assert.IsTrue(success); } [TestMethod] public void Refine() { var mesh = TestMesh; mesh.Triangulate(); double factor = 5; int new_verts = Processor.Refine(mesh, factor); } [TestMethod] public void IsotropicRemeshing() { var mesh = TestMesh; mesh.Triangulate(); int new_verts = Processor.IsotropicRemeshing(mesh, 0.1, 2); } [TestMethod] public void RandomPerturbation() { var mesh = TestMesh; mesh.Triangulate(); Processor.RandomPerturbation(mesh, 0.1); } /* [TestMethod] public void SmoothByAngle() { var mesh = TestMesh; mesh.Triangulate(); var featureAngle = new Degree(120); Processor.SmoothMeshByAngle(mesh, featureAngle, 1); } */ /* [TestMethod] public void SmoothShape() { var mesh = TestMesh; mesh.Triangulate(); double time_step = 0.001; Processor.SmoothShape(mesh, time_step, 1); Console.WriteLine("Vertices = " + mesh.VertexCount); mesh.PrintVertices(); } */ [TestMethod] public void SplitLongEdges() { var mesh = TestMesh; int new_edges = Processor.SplitLongEdges(mesh, 0.1); } [TestMethod] public void TriangulateFace() { var mesh = TestMesh; bool success = Processor.TriangulateFace(mesh, 0); Assert.IsTrue(success); Assert.AreEqual(7, mesh.FaceCount); } [TestMethod] public void TriangulateFaces() { var mesh = TestMesh; bool success = Processor.TriangulateFaces(mesh, new int[] { 0, 1 }, 2); Assert.IsTrue(success); Assert.AreEqual(8, mesh.FaceCount); } } } ================================================ FILE: CGALDotNetTest/Processing/MeshProcessingMeshingSurfaceMeshTest.cs ================================================ using System; using System.Collections.Generic; using System.Text; using Microsoft.VisualStudio.TestTools.UnitTesting; using CGALDotNet; using CGALDotNetGeometry.Numerics; using CGALDotNetGeometry.Shapes; using CGALDotNet.Polyhedra; using CGALDotNet.Processing; using CGALDotNet.Extensions; namespace CGALDotNetTest.Processing { [TestClass] public class MeshProcessingMeshingSurfaceMeshTest { private MeshProcessingMeshing Processor => MeshProcessingMeshing.Instance; private SurfaceMesh3 testMesh; private SurfaceMesh3 TestMesh { get { if (testMesh == null) { testMesh = SurfaceMeshFactory.CreateCube(1, true); } return testMesh.Copy(); } } [TestMethod] public void Extrude() { var extured = Processor.Extrude(TestMesh, new Vector3d(0, 1, 0)); } /* [TestMethod] public void Fair() { var success = Processor.Fair(TestMesh, 0, 1); Assert.IsTrue(success); } */ [TestMethod] public void Refine() { var mesh = TestMesh; mesh.Triangulate(); double factor = 5; int new_verts = Processor.Refine(mesh, factor); } [TestMethod] public void IsotropicRemeshing() { var mesh = TestMesh; mesh.Triangulate(); int new_verts = Processor.IsotropicRemeshing(mesh, 0.1, 2); } [TestMethod] public void RandomPerturbation() { var mesh = TestMesh; mesh.Triangulate(); Processor.RandomPerturbation(mesh, 0.1); } [TestMethod] public void SmoothByAngle() { var mesh = TestMesh; mesh.Triangulate(); var featureAngle = new Degree(120); Processor.SmoothMeshByAngle(mesh, featureAngle, 1); } /* [TestMethod] public void SmoothShape() { var mesh = TestMesh; mesh.Triangulate(); double time_step = 0.001; Processor.SmoothShape(mesh, time_step, 1); Console.WriteLine("Vertices = " + mesh.VertexCount); mesh.PrintVertices(); } */ [TestMethod] public void SplitLongEdges() { var mesh = TestMesh; int new_edges = Processor.SplitLongEdges(mesh, 0.1); } [TestMethod] public void TriangulateFace() { var mesh = TestMesh; bool success = Processor.TriangulateFace(mesh, 0); Assert.IsTrue(success); Assert.AreEqual(7, mesh.FaceCount); } [TestMethod] public void TriangulateFaces() { var mesh = TestMesh; bool success = Processor.TriangulateFaces(mesh, new int[] {0, 1}, 2); Assert.IsTrue(success); Assert.AreEqual(8, mesh.FaceCount); } } } ================================================ FILE: CGALDotNetTest/Processing/MeshProcessingOrientationPolyhedronTest.cs ================================================ using System; using System.Collections.Generic; using System.Text; using Microsoft.VisualStudio.TestTools.UnitTesting; using CGALDotNet; using CGALDotNetGeometry.Numerics; using CGALDotNetGeometry.Shapes; using CGALDotNet.Polyhedra; using CGALDotNet.Processing; using CGALDotNet.Extensions; namespace CGALDotNetTest.Processing { [TestClass] public class MeshProcessingOrientationPolyhedronTest { private MeshProcessingOrientation Processor => MeshProcessingOrientation.Instance; private Polyhedron3 testMesh; private Polyhedron3 TestMesh { get { if (testMesh == null) { testMesh = PolyhedronFactory.CreateCube(); } return testMesh.Copy(); } } [TestMethod] public void DoesBoundAVolume() { Assert.IsTrue(Processor.DoesBoundAVolume(TestMesh)); } [TestMethod] public void IsOutwardOriented() { Assert.IsTrue(Processor.IsOutwardOriented(TestMesh)); } [TestMethod] public void Orient() { Processor.Orient(TestMesh); } [TestMethod] public void OrientToBoundAVolume() { Processor.OrientToBoundAVolume(TestMesh); } [TestMethod] public void ReverseFaceOrientations() { Processor.ReverseFaceOrientations(TestMesh); } } } ================================================ FILE: CGALDotNetTest/Processing/MeshProcessingOrientationSurfaceMeshTest.cs ================================================ using System; using System.Collections.Generic; using System.Text; using Microsoft.VisualStudio.TestTools.UnitTesting; using CGALDotNet; using CGALDotNetGeometry.Numerics; using CGALDotNetGeometry.Shapes; using CGALDotNet.Polyhedra; using CGALDotNet.Processing; using CGALDotNet.Extensions; namespace CGALDotNetTest.Processing { [TestClass] public class MeshProcessingOrientationSurfaceMeshTest { private MeshProcessingOrientation Processor => MeshProcessingOrientation.Instance; private SurfaceMesh3 testMesh; private SurfaceMesh3 TestMesh { get { if (testMesh == null) { testMesh = SurfaceMeshFactory.CreateCube(); } return testMesh.Copy(); } } [TestMethod] public void DoesBoundAVolume() { Assert.IsTrue(Processor.DoesBoundAVolume(TestMesh)); } [TestMethod] public void IsOutwardOriented() { Assert.IsTrue(Processor.IsOutwardOriented(TestMesh)); } [TestMethod] public void Orient() { Processor.Orient(TestMesh); } [TestMethod] public void OrientToBoundAVolume() { Processor.OrientToBoundAVolume(TestMesh); } [TestMethod] public void ReverseFaceOrientations() { Processor.ReverseFaceOrientations(TestMesh); } } } ================================================ FILE: CGALDotNetTest/Processing/MeshProcessingRepairPolyhedronTest.cs ================================================ using System; using System.Collections.Generic; using System.Text; using Microsoft.VisualStudio.TestTools.UnitTesting; using CGALDotNet; using CGALDotNetGeometry.Numerics; using CGALDotNetGeometry.Shapes; using CGALDotNet.Polyhedra; using CGALDotNet.Processing; using CGALDotNet.Extensions; namespace CGALDotNetTest.Processing { [TestClass] public class MeshProcessingRepairPolyhedronTest { private MeshProcessingRepair Processor => MeshProcessingRepair.Instance; private Polyhedron3 TriangleSoup { get { var points = new Point3d[] { new Point3d(0,0,0), new Point3d(1,0,0), new Point3d(1,1,0), new Point3d(0,0,0), new Point3d(0,1,0), new Point3d(1,1,0), }; var indices = new int[] { 0, 1, 2, 3, 5, 4 }; return new Polyhedron3(points, indices); } } /* [TestMethod] public void DegenerateEdgeCount() { var points = new Point3d[] { new Point3d(0,0,0), new Point3d(0,0,0), new Point3d(1,1,0) }; var indices = new int[] { 0, 1, 2, }; var mesh = new Polyhedron3(points, indices); int count = Processor.DegenerateEdgeCount(mesh); Assert.AreEqual(1, count); } */ [TestMethod] public void DegenerateTriangleCount() { var points = new Point3d[] { new Point3d(0,0,0), new Point3d(0,0,0), new Point3d(1,1,0) }; var indices = new int[] { 0, 1, 2, }; var mesh = new Polyhedron3(points, indices); int count = Processor.DegenerateTriangleCount(mesh); Assert.AreEqual(1, count); } [TestMethod] public void NeedleTriangleCount() { var points = new Point3d[] { new Point3d(0,0,0), new Point3d(0.01,0,0), new Point3d(1,1,0) }; var indices = new int[] { 0, 1, 2, }; var mesh = new Polyhedron3(points, indices); int count = Processor.NeedleTriangleCount(mesh, 0.1); Assert.AreEqual(1, count); } /* [TestMethod] public void NonManifoldVertexCount() { var mesh = new Polyhedron3(points, indices); int count = Processor.NonManifoldVertexCount(mesh); } */ [TestMethod] public void RepairPolygonSoup() { var mesh = TriangleSoup; Processor.RepairPolygonSoup(mesh); Assert.AreEqual(4, mesh.VertexCount); Assert.AreEqual(10, mesh.HalfedgeCount); Assert.AreEqual(2, mesh.FaceCount); } [TestMethod] public void StitchBoundaryCycles() { var mesh = TriangleSoup; Processor.StitchBoundaryCycles(mesh); //mesh.Print(); } [TestMethod] public void StitchBorders() { var mesh = TriangleSoup; Processor.StitchBorders(mesh); Assert.AreEqual(4, mesh.VertexCount); Assert.AreEqual(10, mesh.HalfedgeCount); Assert.AreEqual(2, mesh.FaceCount); } /* [TestMethod] public void MergeDuplicatedVerticesInBoundaryCycle() { var points = new Point3d[] { new Point3d(0,0,0), new Point3d(0,0,0), new Point3d(1,0,0), new Point3d(1,1,0) }; var indices = new int[] { 0, 1, 2, 3 }; var mesh = new Polyhedron3(); mesh.CreateTriangleQuadMesh(points, points.Length, null, 0, indices, indices.Length); mesh.Print(); Processor.MergeDuplicatedVerticesInBoundaryCycle(mesh, 0); mesh.Print(); } [TestMethod] public void MergeDuplicatedVerticesInBoundaryCycles() { var points = new Point3d[] { new Point3d(0,0,0), new Point3d(0,0,0), new Point3d(1,0,0), new Point3d(1,1,0) }; var indices = new int[] { 0, 1, 2, 3 }; var mesh = new Polyhedron3(); mesh.CreateTriangleQuadMesh(points, points.Length, null, 0, indices, indices.Length); mesh.Print(); Processor.MergeDuplicatedVerticesInBoundaryCycles(mesh); mesh.Print(); } */ [TestMethod] public void RemoveIsolatedVertices() { var points = new Point3d[] { new Point3d(0,0,0), new Point3d(1,0,0), new Point3d(1,1,0), new Point3d(0,0,0), new Point3d(10,0,0) }; var indices = new int[] { 0, 1, 2 }; var mesh = new Polyhedron3(points, indices); Assert.AreEqual(5, mesh.VertexCount); Processor.RemoveIsolatedVertices(mesh); Assert.AreEqual(3, mesh.VertexCount); } } } ================================================ FILE: CGALDotNetTest/Processing/MeshProcessingRepairSurfaceMeshTest.cs ================================================ using System; using System.Collections.Generic; using System.Text; using Microsoft.VisualStudio.TestTools.UnitTesting; using CGALDotNet; using CGALDotNetGeometry.Numerics; using CGALDotNetGeometry.Shapes; using CGALDotNet.Polyhedra; using CGALDotNet.Processing; using CGALDotNet.Extensions; namespace CGALDotNetTest.Processing { [TestClass] public class MeshProcessingRepairSurfaceMeshTest { private MeshProcessingRepair Processor => MeshProcessingRepair.Instance; private SurfaceMesh3 TriangleSoup { get { var points = new Point3d[] { new Point3d(0,0,0), new Point3d(1,0,0), new Point3d(1,1,0), new Point3d(0,0,0), new Point3d(0,1,0), new Point3d(1,1,0), }; var indices = new int[] { 0, 1, 2, 3, 5, 4 }; return new SurfaceMesh3(points, indices); } } [TestMethod] public void DegenerateEdgeCount() { var points = new Point3d[] { new Point3d(0,0,0), new Point3d(0,0,0), new Point3d(1,1,0) }; var indices = new int[] { 0, 1, 2, }; var mesh = new SurfaceMesh3(points, indices); int count = Processor.DegenerateEdgeCount(mesh); Assert.AreEqual(1, count); } [TestMethod] public void DegenerateTriangleCount() { var points = new Point3d[] { new Point3d(0,0,0), new Point3d(0,0,0), new Point3d(1,1,0) }; var indices = new int[] { 0, 1, 2, }; var mesh = new SurfaceMesh3(points, indices); int count = Processor.DegenerateTriangleCount(mesh); Assert.AreEqual(1, count); } [TestMethod] public void NeedleTriangleCount() { var points = new Point3d[] { new Point3d(0,0,0), new Point3d(0.01,0,0), new Point3d(1,1,0) }; var indices = new int[] { 0, 1, 2, }; var mesh = new SurfaceMesh3(points, indices); int count = Processor.NeedleTriangleCount(mesh, 0.1); Assert.AreEqual(1, count); } /* [TestMethod] public void NonManifoldVertexCount() { var mesh = new SurfaceMesh3(points, indices); int count = Processor.NonManifoldVertexCount(mesh); } */ [TestMethod] public void RepairPolygonSoup() { var mesh = TriangleSoup; Processor.RepairPolygonSoup(mesh); Assert.AreEqual(4, mesh.VertexCount); Assert.AreEqual(10, mesh.HalfedgeCount); Assert.AreEqual(2, mesh.FaceCount); } [TestMethod] public void StitchBoundaryCycles() { var mesh = TriangleSoup; Processor.StitchBoundaryCycles(mesh); //mesh.Print(); } [TestMethod] public void StitchBorders() { var mesh = TriangleSoup; Processor.StitchBorders(mesh); Assert.AreEqual(4, mesh.VertexCount); Assert.AreEqual(10, mesh.HalfedgeCount); Assert.AreEqual(2, mesh.FaceCount); } /* [TestMethod] public void MergeDuplicatedVerticesInBoundaryCycle() { var points = new Point3d[] { new Point3d(0,0,0), new Point3d(0,0,0), new Point3d(1,0,0), new Point3d(1,1,0) }; var indices = new int[] { 0, 1, 2, 3 }; var mesh = new SurfaceMesh3(); mesh.CreateTriangleQuadMesh(points, points.Length, null, 0, indices, indices.Length); mesh.Print(); Processor.MergeDuplicatedVerticesInBoundaryCycle(mesh, 0); mesh.Print(); } [TestMethod] public void MergeDuplicatedVerticesInBoundaryCycles() { var points = new Point3d[] { new Point3d(0,0,0), new Point3d(0,0,0), new Point3d(1,0,0), new Point3d(1,1,0) }; var indices = new int[] { 0, 1, 2, 3 }; var mesh = new SurfaceMesh3(); mesh.CreateTriangleQuadMesh(points, points.Length, null, 0, indices, indices.Length); mesh.Print(); Processor.MergeDuplicatedVerticesInBoundaryCycles(mesh); mesh.Print(); } */ [TestMethod] public void RemoveIsolatedVertices() { var points = new Point3d[] { new Point3d(0,0,0), new Point3d(1,0,0), new Point3d(1,1,0), new Point3d(0,0,0), new Point3d(10,0,0) }; var indices = new int[] { 0, 1, 2 }; var mesh = new SurfaceMesh3(points, indices); Assert.AreEqual(5, mesh.VertexCount); Processor.RemoveIsolatedVertices(mesh); Assert.AreEqual(3, mesh.VertexCount); } } } ================================================ FILE: CGALWrapper/Arrangments/ArrFace2.h ================================================ #pragma once #include "../CGALWrapper.h" #include "CGAL/Point_2.h" struct ArrFace2 { BOOL IsFictitious; BOOL IsUnbounded; BOOL HasOuterEdges; int HoleCount; int Index; int HalfEdgeIndex; static ArrFace2 NullFace() { ArrFace2 f; f.IsFictitious = false; f.IsUnbounded = false; f.HoleCount = NULL_INDEX; f.Index = NULL_INDEX; f.HalfEdgeIndex = NULL_INDEX; return f; } template static ArrFace2 FromFace(FACE face) { ArrFace2 f; f.IsFictitious = face->is_fictitious(); f.IsUnbounded = face->is_unbounded(); f.HasOuterEdges = face->has_outer_ccb(); f.HoleCount = (int)face->number_of_holes(); f.Index = face->data(); if (face->has_outer_ccb()) { auto first = face->outer_ccb(); f.HalfEdgeIndex = first->data(); } else { f.HalfEdgeIndex = -1; } return f; } }; ================================================ FILE: CGALWrapper/Arrangments/ArrHalfEdge2.h ================================================ #pragma once #include "../CGALWrapper.h" struct ArrHalfEdge2 { BOOL IsFictitious; int Index; int SourceIndex; int TargetIndex; int FaceIndex; int NextIndex; int PreviousIndex; int TwinIndex; static ArrHalfEdge2 NullEdge() { ArrHalfEdge2 e; e.IsFictitious = false; e.Index = NULL_INDEX; e.SourceIndex = NULL_INDEX; e.TargetIndex = NULL_INDEX; e.FaceIndex = NULL_INDEX; e.NextIndex = NULL_INDEX; e.PreviousIndex = NULL_INDEX; e.TwinIndex = NULL_INDEX; return e; } template static ArrHalfEdge2 FromHalfEdge(EDGE edge) { ArrHalfEdge2 e; e.IsFictitious = edge->is_fictitious(); e.Index = edge->data(); e.SourceIndex = edge->source()->data(); e.TargetIndex = edge->target()->data(); e.FaceIndex = edge->face()->data(); e.NextIndex = edge->next()->data(); e.PreviousIndex = edge->prev()->data(); e.TwinIndex = edge->twin()->data(); return e; } }; ================================================ FILE: CGALWrapper/Arrangments/ArrMultiLocator.h ================================================ #pragma once #include "../CGALWrapper.h" #include "../Geometry/Geometry2.h" #include "CGAL/Point_2.h" #include #include #include #include #include #include enum class ARR_LOCATOR : int { NONE, NAIVE, WALK, LANDMARKS, TRAPEZOID }; template class ArrMultiLocator { public: typedef CGAL::Arr_point_location_result Locator_Result; typedef typename Locator_Result::Type Locator_Result_Type; typedef CGAL::Arr_naive_point_location Naive_Locator; typedef CGAL::Arr_walk_along_line_point_location Walk_Locator; typedef CGAL::Arr_landmarks_point_location Landmarks_Locator; typedef CGAL::Arr_trapezoid_ric_point_location Trapezoid_Locator; private: ARR_LOCATOR current_locator_type; Naive_Locator* naive_locator; Walk_Locator* walk_locator; Landmarks_Locator* landmark_locator; Trapezoid_Locator* trapezoid_locator; public: ArrMultiLocator() { current_locator_type = ARR_LOCATOR::NONE; naive_locator = nullptr; walk_locator = nullptr; landmark_locator = nullptr; trapezoid_locator = nullptr; } ~ArrMultiLocator() { ReleaseLocator(); } void CreateLocator(ARR_LOCATOR type, Arrangement& arr) { if (current_locator_type == type) return; ReleaseLocator(); current_locator_type = type; switch (type) { case ARR_LOCATOR::NAIVE: naive_locator = new Naive_Locator(); naive_locator->attach(arr); break; case ARR_LOCATOR::WALK: walk_locator = new Walk_Locator(); walk_locator->attach(arr); break; case ARR_LOCATOR::LANDMARKS: landmark_locator = new Landmarks_Locator(); landmark_locator->attach(arr); break; case ARR_LOCATOR::TRAPEZOID: trapezoid_locator = new Trapezoid_Locator(); trapezoid_locator->attach(arr); break; } } void ReleaseLocator() { switch (current_locator_type) { case ARR_LOCATOR::NAIVE: naive_locator->detach(); delete naive_locator; naive_locator = nullptr; break; case ARR_LOCATOR::WALK: walk_locator->detach(); delete walk_locator; walk_locator = nullptr; break; case ARR_LOCATOR::LANDMARKS: landmark_locator->detach(); delete landmark_locator; landmark_locator = nullptr; break; case ARR_LOCATOR::TRAPEZOID: trapezoid_locator->detach(); delete trapezoid_locator; trapezoid_locator = nullptr; break; } current_locator_type = ARR_LOCATOR::NONE; } Locator_Result_Type Locate(const Arrangement& arr, Point2d point) { switch (current_locator_type) { case ARR_LOCATOR::NAIVE: return naive_locator->locate(point.ToCGAL()); case ARR_LOCATOR::WALK: return walk_locator->locate(point.ToCGAL()); case ARR_LOCATOR::LANDMARKS: return landmark_locator->locate(point.ToCGAL()); case ARR_LOCATOR::TRAPEZOID: return trapezoid_locator->locate(point.ToCGAL()); default: Walk_Locator locator; locator.attach(arr); return locator.locate(point.ToCGAL()); } } Locator_Result_Type RayShootUp(const Arrangement& arr, Point2d point) { switch (current_locator_type) { case ARR_LOCATOR::WALK: return walk_locator->ray_shoot_up(point.ToCGAL()); case ARR_LOCATOR::TRAPEZOID: return trapezoid_locator->ray_shoot_up(point.ToCGAL()); default: Walk_Locator locator; locator.attach(arr); return locator.ray_shoot_up(point.ToCGAL()); } } Locator_Result_Type RayShootDown(const Arrangement& arr, Point2d point) { switch (current_locator_type) { case ARR_LOCATOR::WALK: return walk_locator->ray_shoot_down(point.ToCGAL()); case ARR_LOCATOR::TRAPEZOID: return trapezoid_locator->ray_shoot_down(point.ToCGAL()); default: Walk_Locator locator; locator.attach(arr); return locator.ray_shoot_down(point.ToCGAL()); } } template BOOL Intersects(Arrangement& arr, Segment2d segment) { auto seg = segment.ToCGAL(); switch (current_locator_type) { case ARR_LOCATOR::WALK: return do_intersect(arr, seg, *walk_locator); case ARR_LOCATOR::TRAPEZOID: return do_intersect(arr, seg, *trapezoid_locator); default: Walk_Locator locator; locator.attach(arr); return do_intersect(arr, seg, locator); } } void InsertPoint(Arrangement& arr, Point2d point) { switch (current_locator_type) { case ARR_LOCATOR::WALK: insert_point(arr, point.ToCGAL(), *walk_locator); break; case ARR_LOCATOR::TRAPEZOID: insert_point(arr, point.ToCGAL(), *trapezoid_locator); break; default: Walk_Locator locator; locator.attach(arr); insert_point(arr, point.ToCGAL(), locator); break; } } template void InsertSegment(Arrangement& arr, Segment2d segment) { auto seg = segment.ToCGAL(); switch (current_locator_type) { case ARR_LOCATOR::WALK: insert(arr, seg, *walk_locator); break; case ARR_LOCATOR::TRAPEZOID: insert(arr, seg, *trapezoid_locator); break; default: Walk_Locator locator; locator.attach(arr); insert(arr, seg, locator); break; } } template void InsertNonIntersectingSegment(Arrangement& arr, Segment2d segment) { auto seg = segment.ToCGAL(); switch (current_locator_type) { case ARR_LOCATOR::WALK: insert_non_intersecting_curve(arr, seg, *walk_locator); break; case ARR_LOCATOR::TRAPEZOID: insert_non_intersecting_curve(arr, seg, *trapezoid_locator); break; default: Walk_Locator locator; locator.attach(arr); insert_non_intersecting_curve(arr, seg, locator); break; } } }; ================================================ FILE: CGALWrapper/Arrangments/ArrVertex2.h ================================================ #pragma once #include "../CGALWrapper.h" #include "../Geometry/Geometry2.h" #include "../Geometry/Geometry3.h" #include "CGAL/Point_2.h" struct ArrVertex2 { Point2d Point; int Degree; BOOL IsIsolated; int Index; int FaceIndex; int HalfEdgeIndex; static ArrVertex2 NullVertex() { ArrVertex2 v; v.Point = { 0, 0 }; v.Degree = 0; v.IsIsolated = false; v.Index = NULL_INDEX; v.FaceIndex = NULL_INDEX; v.HalfEdgeIndex = NULL_INDEX; return v; } template static ArrVertex2 FromVertex(VERT vert) { ArrVertex2 v; v.Index = vert->data(); v.Point = Point2d::FromCGAL(vert->point()); v.Degree = (int)vert->degree(); v.IsIsolated = vert->is_isolated(); if (vert->is_isolated()) { v.FaceIndex = vert->face()->data(); v.HalfEdgeIndex = -1; } else { v.FaceIndex = -1; auto first = vert->incident_halfedges(); v.HalfEdgeIndex = first->data(); } return v; } }; ================================================ FILE: CGALWrapper/Arrangments/Arrangement2.h ================================================ #pragma once #include "../CGALWrapper.h" #include "../Geometry/Geometry2.h" #include "../Polygons/Polygon2.h" #include "../Polygons/PolygonWithHoles2.h" #include "ArrMultiLocator.h" #include "ArrangementMap.h" #include "ArrVertex2.h" #include "ArrHalfEdge2.h" #include "ArrFace2.h" #include #include "CGAL/Point_2.h" #include #include #include #include #include enum class ARR_ELEMENT_HIT : int { NONE, VERTEX, HALF_EDGE, FACE }; struct ArrQuery { ARR_ELEMENT_HIT Element; int Index; }; template class Arrangement2 { public: typedef CGAL::Arr_segment_traits_2 Traits_2; typedef Traits_2::Point_2 Point_2; typedef Traits_2::X_monotone_curve_2 Segment_2; typedef CGAL::Arr_extended_dcel Dcel; typedef CGAL::Arrangement_2 Arrangement_2; typedef ArrMultiLocator Locator; typedef typename Locator::Walk_Locator Walk_Locator; typedef typename Locator::Locator_Result_Type Locator_Result_Type; typedef std::pair Batch_Query_Result; typedef typename Arrangement_2::Vertex_const_handle Vertex_const; typedef typename Arrangement_2::Halfedge_const_handle Halfedge_const; typedef typename Arrangement_2::Face_const_handle Face_const; typedef typename Arrangement_2::Vertex_handle Vertex; typedef typename Arrangement_2::Halfedge_handle Halfedge; typedef typename Arrangement_2::Face_handle Face; typedef typename Arrangement_2::Halfedge_around_vertex_const_circulator Vertex_const_circulator; typedef typename Arrangement_2::Halfedge_around_vertex_circulator Vertex_circulator; private: Arrangement_2 model; Locator locator; ArrangementMap map; public: Arrangement2() { } ~Arrangement2() { } inline static Arrangement2* NewArrangement2() { return new Arrangement2(); } inline static void DeleteArrangement2(void* ptr) { auto obj = static_cast(ptr); if (obj != nullptr) { delete obj; obj = nullptr; } } inline static Arrangement2* CastToArrangement(void* ptr) { return static_cast(ptr); } static BOOL IsValid(void* ptr) { auto arr = CastToArrangement(ptr); return arr->model.is_valid(); } static void Clear(void* ptr) { auto arr = CastToArrangement(ptr); arr->model.clear(); arr->map.ClearMaps(); } static BOOL IsEmpty(void* ptr) { auto arr = CastToArrangement(ptr); return arr->model.is_empty(); } static int BuildStamp(void* ptr) { auto arr = CastToArrangement(ptr); return arr->map.BuildStamp(); } static void Assign(void* ptr, void* ptrOther) { auto arr = CastToArrangement(ptr); auto other = CastToArrangement(ptrOther); arr->model.assign(other->model); } static void* Overlay(void* ptr, void* ptrOther) { auto arr = CastToArrangement(ptr); auto other = CastToArrangement(ptrOther); auto result = new Arrangement2(); overlay(arr->model, other->model, result->model); return result; } static int VertexCount(void* ptr) { auto arr = CastToArrangement(ptr); return (int)arr->model.number_of_vertices(); } static int VerticesAtInfinityCount(void* ptr) { auto arr = CastToArrangement(ptr); return (int)arr->model.number_of_vertices_at_infinity(); } static int IsolatedVerticesCount(void* ptr) { auto arr = CastToArrangement(ptr); return (int)arr->model.number_of_isolated_vertices(); } static int HalfEdgeCount(void* ptr) { auto arr = CastToArrangement(ptr); return (int)arr->model.number_of_halfedges(); } static int FaceCount(void* ptr) { auto arr = CastToArrangement(ptr); return (int)arr->model.number_of_faces(); } static int EdgeCount(void* ptr) { auto arr = CastToArrangement(ptr); return (int)arr->model.number_of_edges(); } static int UnboundedFaceCount(void* ptr) { auto arr = CastToArrangement(ptr); return (int)arr->model.number_of_unbounded_faces(); } static void GetPoints(void* ptr, Point2d* points, int count) { auto arr = CastToArrangement(ptr); int i = 0; for (auto iter = arr->model.vertices_begin(); iter != arr->model.vertices_end(); ++iter, ++i) { points[i] = Point2d::FromCGAL(iter->point()); } } static void GetSegments(void* ptr, Segment2d* segments, int count) { auto arr = CastToArrangement(ptr); int i = 0; for (auto iter = arr->model.edges_begin(); iter != arr->model.edges_end(); ++iter, ++i) { auto a = iter->curve().source(); auto b = iter->curve().target(); segments[i] = Segment2d::FromCGAL(a, b); } } static void GetVertices(void* ptr, ArrVertex2* vertices, int count) { auto arr = CastToArrangement(ptr); int i = 0; arr->map.SetIndices(arr->model); for (auto vert = arr->model.vertices_begin(); vert != arr->model.vertices_end(); ++vert, ++i) { vertices[i] = ArrVertex2::FromVertex(vert); } } static BOOL GetVertex(void* ptr, int index, ArrVertex2& arrVert) { auto arr = CastToArrangement(ptr); arr->map.SetIndices(arr->model); auto vert = arr->map.FindVertex(arr->model, index); if (vert != nullptr) { arrVert = ArrVertex2::FromVertex(*vert); return TRUE; } else { arrVert = ArrVertex2::NullVertex(); return FALSE; } } static void GetHalfEdges(void* ptr, ArrHalfEdge2* edges, int count) { auto arr = CastToArrangement(ptr); int i = 0; arr->map.SetIndices(arr->model); for (auto edge = arr->model.halfedges_begin(); edge != arr->model.halfedges_end(); ++edge, ++i) { edges[i] = ArrHalfEdge2::FromHalfEdge(edge); } } static BOOL GetHalfEdge(void* ptr, int index, ArrHalfEdge2& arrEdge) { auto arr = CastToArrangement(ptr); arr->map.SetIndices(arr->model); auto edge = arr->map.FindEdge(arr->model, index); if (edge != nullptr) { arrEdge = ArrHalfEdge2::FromHalfEdge(*edge); return TRUE; } else { arrEdge = ArrHalfEdge2::NullEdge(); return FALSE; } } static void GetFaces(void* ptr, ArrFace2* faces, int count) { auto arr = CastToArrangement(ptr); int i = 0; arr->map.SetIndices(arr->model); for (auto face = arr->model.faces_begin(); face != arr->model.faces_end(); ++face) { if (!face->is_unbounded()) faces[i++] = ArrFace2::FromFace(face); } } static BOOL GetFace(void* ptr, int index, ArrFace2& arrFace) { auto arr = CastToArrangement(ptr); arr->map.SetIndices(arr->model); auto face = arr->map.FindFace(arr->model, index); if (face != nullptr) { if (!(*face)->is_unbounded()) { arrFace = ArrFace2::FromFace(*face); return TRUE; } else { arrFace = ArrFace2::NullFace(); return FALSE; } } else { arrFace = ArrFace2::NullFace(); return FALSE; } } static int GetFaceHoleCount(void* ptr, int index) { auto arr = CastToArrangement(ptr); arr->map.SetIndices(arr->model); auto face = arr->map.FindFace(arr->model, index); if (face != nullptr) { return CountHoles(*face); } else { return NULL_INDEX; } } static int GetHoleVertexCount(void* ptr, int faceIndex, int holeIndex) { auto arr = CastToArrangement(ptr); arr->map.SetIndices(arr->model); auto face = arr->map.FindFace(arr->model, faceIndex); if (face != nullptr) { return CountHoleVertices(*face, holeIndex); } else { return NULL_INDEX; } } static void CreateLocator(void* ptr, ARR_LOCATOR type) { auto arr = CastToArrangement(ptr); arr->locator.CreateLocator(type, arr->model); } static void ReleaseLocator(void* ptr) { auto arr = CastToArrangement(ptr); arr->locator.ReleaseLocator(); } static BOOL PointQuery(void* ptr, Point2d point, ArrQuery& result) { auto arr = CastToArrangement(ptr); arr->map.SetIndices(arr->model); auto q = arr->locator.Locate(arr->model, point); return HandleQuery(arr, q, result); } static BOOL BatchedPointQuery(void* ptr, Point2d* p, ArrQuery* r, int count) { auto arr = CastToArrangement(ptr); arr->map.SetIndices(arr->model); auto list = ToList(p, count); std::vector results; locate(arr->model, list.begin(), list.end(), std::back_inserter(results)); BOOL hit = FALSE; int i = 0; for (auto it = results.begin(); it != results.end(); ++it, ++i) { if (HandleQuery(arr, it->second, r[i])) hit = TRUE; } return hit; } static BOOL RayQuery(void* ptr, Point2d point, BOOL up, ArrQuery& result) { auto arr = CastToArrangement(ptr); arr->map.SetIndices(arr->model); if (up) { auto q = arr->locator.RayShootUp(arr->model, point); return HandleQuery(arr, q, result); } else { auto q = arr->locator.RayShootDown(arr->model, point); return HandleQuery(arr, q, result); } } static BOOL IntersectsSegment(void* ptr, Segment2d segment) { auto arr = CastToArrangement(ptr); return arr->locator.Intersects(arr->model, segment); } static void InsertPoint(void* ptr, Point2d point) { auto arr = CastToArrangement(ptr); arr->locator.InsertPoint(arr->model, point); arr->map.OnModelChanged(); } static void InsertPolygon(void* ptr, void* polyPtr, BOOL nonItersecting) { auto arr = CastToArrangement(ptr);; auto polygon = Polygon2::CastToPolygon2(polyPtr); int count = (int)polygon->container().size(); for (int i = 0; i < count; i++) { int i0 = i; int i1 = i + 1; if (i == count - 1) i1 = 0; auto a = polygon->vertex(i0); auto b = polygon->vertex(i1); auto segment = Segment2d::FromCGAL(a, b); if (segment.a == segment.b) continue; if (nonItersecting) arr->locator.InsertNonIntersectingSegment(arr->model, segment); else arr->locator.InsertSegment(arr->model, segment); } arr->map.OnModelChanged(); } static void InsertPolygon(Arrangement2* arr, Polygon2* polygon, BOOL nonItersecting) { int count = (int)polygon->container().size(); for (int i = 0; i < count; i++) { int i0 = i; int i1 = i + 1; if (i == count - 1) i1 = 0; auto a = polygon->vertex(i0); auto b = polygon->vertex(i1); auto segment = Segment2d::FromCGAL(a, b); if (segment.a == segment.b) continue; if (nonItersecting) arr->locator.InsertNonIntersectingSegment(arr->model, segment); else arr->locator.InsertSegment(arr->model, segment); } arr->map.OnModelChanged(); } static void InsertPolygonWithHoles(void* ptr, void* pwhPtr, BOOL nonItersecting) { auto arr = CastToArrangement(ptr); auto pwh = PolygonWithHoles2::CastToPolygonWithHoles2(pwhPtr); if (!pwh->is_unbounded()) InsertPolygon(&arr, &pwh->outer_boundary(), nonItersecting); for (auto& hole : pwh->holes()) InsertPolygon(&arr, &hole, nonItersecting); arr->map.OnModelChanged(); } static void InsertSegment(void* ptr, Segment2d segment, BOOL nonItersecting) { if (segment.a == segment.b) return; auto arr = CastToArrangement(ptr); if(nonItersecting) arr->locator.InsertNonIntersectingSegment(arr->model, segment); else arr->locator.InsertSegment(arr->model, segment); arr->map.OnModelChanged(); } static void InsertSegments(void* ptr, Segment2d* segments, int count, BOOL nonItersecting) { auto arr = CastToArrangement(ptr); for (auto i = 0; i < count; i++) { if (segments[i].a == segments[i].b) continue; if (nonItersecting) arr->locator.InsertNonIntersectingSegment(arr->model, segments[i]); else arr->locator.InsertSegment(arr->model, segments[i]); } arr->map.OnModelChanged(); } static BOOL RemoveVertex(void* ptr, int index) { auto arr = CastToArrangement(ptr); auto v = arr->map.FindVertex(arr->model, index); if (v != nullptr) { if (remove_vertex(arr->model, *v)) { arr->map.OnModelChanged(); return TRUE; } } return FALSE; } static BOOL RemoveVertex(void* ptr, Point2d point) { auto arr = CastToArrangement(ptr); auto q = arr->locator.Locate(arr->model, point); const Vertex_const* vert; if (vert = boost::get(&q)) { auto v = arr->model.non_const_handle(*vert); if (remove_vertex(arr->model, v)) { arr->map.OnModelChanged(); return TRUE; } } return FALSE; } static BOOL RemoveEdge(void* ptr, int index) { auto arr = CastToArrangement(ptr); auto e = arr->map.FindEdge(arr->model, index); if (e != nullptr) { remove_edge(arr->model, *e); arr->map.OnModelChanged(); return TRUE; } return FALSE; } static BOOL RemoveEdge(void* ptr, Segment2d segment) { auto arr = CastToArrangement(ptr); auto q1 = arr->locator.Locate(arr->model, segment.a); const Vertex_const* vert1; if (vert1 = boost::get(&q1)) { if ((*vert1)->is_isolated()) return FALSE; auto q2 = arr->locator.Locate(arr->model, segment.b); const Vertex_const* vert2; if (vert2 = boost::get(&q2)) { if ((*vert2)->is_isolated()) return FALSE; auto first = (*vert1)->incident_halfedges(); auto curr = first; auto next = first; do { ++next; if ((next->source() == (*vert2) || next->target() == (*vert2))) { auto e = arr->model.non_const_handle(next); remove_edge(arr->model, e); arr->map.OnModelChanged(); return TRUE; } } while (++curr != first); } } return FALSE; } private: static BOOL HandleQuery(Arrangement2* arr, Locator_Result_Type query, ArrQuery& result) { const Vertex_const* vert; const Halfedge_const* edge; const Face_const* face; if (face = boost::get(&query)) { arr->map.SetIndices(arr->model); result.Element = ARR_ELEMENT_HIT::FACE; result.Index = (*face)->data(); return TRUE; } else if (edge = boost::get(&query)) { arr->map.SetIndices(arr->model); result.Element = ARR_ELEMENT_HIT::HALF_EDGE; result.Index = (*edge)->data(); return TRUE; } else if (vert = boost::get(&query)) { arr->map.SetIndices(arr->model); result.Element = ARR_ELEMENT_HIT::VERTEX; result.Index = (*vert)->data(); return TRUE; } else { result.Element = ARR_ELEMENT_HIT::NONE; result.Index = -1; return FALSE; } } static std::vector ToList(Point2d* points, int count) { auto list = std::vector(count); for (int i = 0; i < count; i++) list.push_back(points[i].ToCGAL()); return list; } static int CountHoles(Face face) { int count = 0; for (auto hole = face->holes_begin(); hole != face->holes_end(); ++hole) { count++; } return count; } static int CountHoleVertices(Face face, int index) { int holeCount = 0; for (auto hole = face->holes_begin(); hole != face->holes_end(); ++hole) { if (holeCount == index) { auto curr = (*hole)->next(); auto first = curr; int vertCount = 0; do { vertCount++; curr = curr->next(); } while (curr != first); return vertCount; } holeCount++; } return NULL_INDEX; } }; ================================================ FILE: CGALWrapper/Arrangments/Arrangement2_EEK.cpp ================================================ #include "Arrangement2_EEK.h" #include "Arrangement2.h" #include #include void* Arrangement2_EEK_Create() { return Arrangement2::NewArrangement2(); } void Arrangement2_EEK_Release(void* ptr) { Arrangement2::DeleteArrangement2(ptr); } BOOL Arrangement2_EEK_IsValid(void* ptr) { return Arrangement2::IsValid(ptr); } void Arrangement2_EEK_Clear(void* ptr) { return Arrangement2::Clear(ptr); } BOOL Arrangement2_EEK_IsEmpty(void* ptr) { return Arrangement2::IsEmpty(ptr); } int Arrangement2_EEK_BuildStamp(void* ptr) { return Arrangement2::BuildStamp(ptr); } void Arrangement2_EEK_Assign(void* ptr, void* ptrOther) { Arrangement2::Assign(ptr, ptrOther); } void* Arrangement2_EEK_Overlay(void* ptr, void* ptrOther) { return Arrangement2::Overlay(ptr, ptrOther); } int Arrangement2_EEK_VertexCount(void* ptr) { return Arrangement2::VertexCount(ptr); } int Arrangement2_EEK_IsolatedVerticesCount(void* ptr) { return Arrangement2::IsolatedVerticesCount(ptr); } int Arrangement2_EEK_VerticesAtInfinityCount(void* ptr) { return Arrangement2::VerticesAtInfinityCount(ptr); } int Arrangement2_EEK_HalfEdgeCount(void* ptr) { return Arrangement2::HalfEdgeCount(ptr); } int Arrangement2_EEK_FaceCount(void* ptr) { return Arrangement2::FaceCount(ptr); } int Arrangement2_EEK_EdgeCount(void* ptr) { return Arrangement2::EdgeCount(ptr); } int Arrangement2_EEK_UnboundedFaceCount(void* ptr) { return Arrangement2::UnboundedFaceCount(ptr); } void Arrangement2_EEK_GetPoints(void* ptr, Point2d* points, int count) { Arrangement2::GetPoints(ptr, points, count); } void Arrangement2_EEK_GetSegments(void* ptr, Segment2d* segments, int count) { Arrangement2::GetSegments(ptr, segments, count); } void Arrangement2_EEK_GetVertices(void* ptr, ArrVertex2* vertices, int count) { Arrangement2::GetVertices(ptr, vertices, count); } BOOL Arrangement2_EEK_GetVertex(void* ptr, int index, ArrVertex2& arrVertex) { return Arrangement2::GetVertex(ptr, index, arrVertex); } void Arrangement2_EEK_GetHalfEdges(void* ptr, ArrHalfEdge2* edges, int count) { Arrangement2::GetHalfEdges(ptr, edges, count); } BOOL Arrangement2_EEK_GetHalfEdge(void* ptr, int index, ArrHalfEdge2& arrEdge) { return Arrangement2::GetHalfEdge(ptr, index, arrEdge); } void Arrangement2_EEK_GetFaces(void* ptr, ArrFace2* faces, int count) { Arrangement2::GetFaces(ptr, faces, count); } BOOL Arrangement2_EEK_GetFace(void* ptr, int index, ArrFace2& arrFace) { return Arrangement2::GetFace(ptr, index, arrFace); } int Arrangement2_EEK_GetFaceHoleCount(void* ptr, int index) { return Arrangement2::GetFaceHoleCount(ptr, index); } int Arrangement2_EEK_GetHoleVertexCount(void* ptr, int faceIndex, int holeIndex) { return Arrangement2::GetHoleVertexCount(ptr, faceIndex, holeIndex); } void Arrangement2_EEK_CreateLocator(void* ptr, ARR_LOCATOR type) { Arrangement2::CreateLocator(ptr, type); } void Arrangement2_EEK_ReleaseLocator(void* ptr) { Arrangement2::ReleaseLocator(ptr); } BOOL Arrangement2_EEK_PointQuery(void* ptr, Point2d point, ArrQuery& result) { return Arrangement2::PointQuery(ptr, point, result); } BOOL Arrangement2_EEK_BatchedPointQuery(void* ptr, Point2d* points, ArrQuery* results, int count) { return Arrangement2::BatchedPointQuery(ptr, points, results, count); } BOOL Arrangement2_EEK_RayQuery(void* ptr, Point2d point, BOOL up, ArrQuery& result) { return Arrangement2::RayQuery(ptr, point, up, result); } BOOL Arrangement2_EEK_IntersectsSegment(void* ptr, Segment2d segment) { return Arrangement2::IntersectsSegment(ptr, segment); } void Arrangement2_EEK_InsertPoint(void* ptr, Point2d point) { Arrangement2::InsertPoint(ptr, point); } void Arrangement2_EEK_InsertPolygon(void* ptr, void* polyPtr, BOOL nonItersecting) { Arrangement2::InsertPolygon(ptr, polyPtr, nonItersecting); } void Arrangement2_EEK_InsertPolygonWithHoles(void* ptr, void* pwhPtr, BOOL nonItersecting) { Arrangement2::InsertPolygonWithHoles(ptr, pwhPtr, nonItersecting); } void Arrangement2_EEK_InsertSegment(void* ptr, Segment2d segment, BOOL nonItersecting) { Arrangement2::InsertSegment(ptr, segment, nonItersecting); } void Arrangement2_EEK_InsertSegments(void* ptr, Segment2d* segments, int count, BOOL nonItersecting) { Arrangement2::InsertSegments(ptr, segments, count, nonItersecting); } BOOL Arrangement2_EEK_RemoveVertexByIndex(void* ptr, int index) { return Arrangement2::RemoveVertex(ptr, index); } BOOL Arrangement2_EEK_RemoveVertexByPoint(void* ptr, Point2d point) { return Arrangement2::RemoveVertex(ptr, point); } BOOL Arrangement2_EEK_RemoveEdgeByIndex(void* ptr, int index) { return Arrangement2::RemoveEdge(ptr, index); } BOOL Arrangement2_EEK_RemoveEdgeBySegment(void* ptr, Segment2d segment) { return Arrangement2::RemoveEdge(ptr, segment); } ================================================ FILE: CGALWrapper/Arrangments/Arrangement2_EEK.h ================================================ #pragma once #include "../CGALWrapper.h" #include "../Geometry/Geometry2.h" #include "Arrangement2.h" extern "C" { CGALWRAPPER_API void* Arrangement2_EEK_Create(); CGALWRAPPER_API void Arrangement2_EEK_Release(void* ptr); CGALWRAPPER_API BOOL Arrangement2_EEK_IsValid(void* ptr); CGALWRAPPER_API void Arrangement2_EEK_Clear(void* ptr); CGALWRAPPER_API BOOL Arrangement2_EEK_IsEmpty(void* ptr); CGALWRAPPER_API int Arrangement2_EEK_BuildStamp(void* ptr); CGALWRAPPER_API void Arrangement2_EEK_Assign(void* ptr, void* ptrOther); CGALWRAPPER_API void* Arrangement2_EEK_Overlay(void* ptr, void* ptrOther); CGALWRAPPER_API int Arrangement2_EEK_VertexCount(void* ptr); CGALWRAPPER_API int Arrangement2_EEK_IsolatedVerticesCount(void* ptr); CGALWRAPPER_API int Arrangement2_EEK_VerticesAtInfinityCount(void* ptr); CGALWRAPPER_API int Arrangement2_EEK_HalfEdgeCount(void* ptr); CGALWRAPPER_API int Arrangement2_EEK_FaceCount(void* ptr); CGALWRAPPER_API int Arrangement2_EEK_EdgeCount(void* ptr); CGALWRAPPER_API int Arrangement2_EEK_UnboundedFaceCount(void* ptr); CGALWRAPPER_API void Arrangement2_EEK_GetPoints(void* ptr, Point2d* points, int count); CGALWRAPPER_API void Arrangement2_EEK_GetSegments(void* ptr, Segment2d* segments, int count); CGALWRAPPER_API void Arrangement2_EEK_GetVertices(void* ptr, ArrVertex2* vertices, int count); CGALWRAPPER_API BOOL Arrangement2_EEK_GetVertex(void* ptr, int index, ArrVertex2& arrVertex); CGALWRAPPER_API void Arrangement2_EEK_GetHalfEdges(void* ptr, ArrHalfEdge2* edges, int count); CGALWRAPPER_API BOOL Arrangement2_EEK_GetHalfEdge(void* ptr, int index, ArrHalfEdge2& arrEdge); CGALWRAPPER_API void Arrangement2_EEK_GetFaces(void* ptr, ArrFace2* faces, int count); CGALWRAPPER_API BOOL Arrangement2_EEK_GetFace(void* ptr, int index, ArrFace2& arrFace); CGALWRAPPER_API int Arrangement2_EEK_GetFaceHoleCount(void* ptr, int index); CGALWRAPPER_API int Arrangement2_EEK_GetHoleVertexCount(void* ptr, int faceIndex, int holeIndex); CGALWRAPPER_API void Arrangement2_EEK_CreateLocator(void* ptr, ARR_LOCATOR type); CGALWRAPPER_API void Arrangement2_EEK_ReleaseLocator(void* ptr); CGALWRAPPER_API BOOL Arrangement2_EEK_PointQuery(void* ptr, Point2d point, ArrQuery& result); CGALWRAPPER_API BOOL Arrangement2_EEK_BatchedPointQuery(void* ptr, Point2d* points, ArrQuery* results, int count); CGALWRAPPER_API BOOL Arrangement2_EEK_RayQuery(void* ptr, Point2d point, BOOL up, ArrQuery& result); CGALWRAPPER_API BOOL Arrangement2_EEK_IntersectsSegment(void* ptr, Segment2d segment); CGALWRAPPER_API void Arrangement2_EEK_InsertPoint(void* ptr, Point2d point); CGALWRAPPER_API void Arrangement2_EEK_InsertPolygon(void* ptr, void* polyPtr, BOOL nonItersecting); CGALWRAPPER_API void Arrangement2_EEK_InsertPolygonWithHoles(void* ptr, void* pwhPtr, BOOL nonItersecting); CGALWRAPPER_API void Arrangement2_EEK_InsertSegment(void* ptr, Segment2d segment, BOOL nonItersecting); CGALWRAPPER_API void Arrangement2_EEK_InsertSegments(void* ptr, Segment2d* segments, int count, BOOL nonItersecting); CGALWRAPPER_API BOOL Arrangement2_EEK_RemoveVertexByIndex(void* ptr, int index); CGALWRAPPER_API BOOL Arrangement2_EEK_RemoveVertexByPoint(void* ptr, Point2d point); CGALWRAPPER_API BOOL Arrangement2_EEK_RemoveEdgeByIndex(void* ptr, int index); CGALWRAPPER_API BOOL Arrangement2_EEK_RemoveEdgeBySegment(void* ptr, Segment2d segment); } ================================================ FILE: CGALWrapper/Arrangments/ArrangementMap.h ================================================ #pragma once #include "../CGALWrapper.h" #include "../Geometry/Geometry2.h" #include "../Collections/IndexMap.h" #include #include "CGAL/Point_2.h" #include #include template class ArrangementMap { private: IndexMap vertexMap; IndexMap faceMap; IndexMap edgeMap; int buildStamp; public: ArrangementMap() { } int BuildStamp() { return buildStamp; } void IncrementBuildStamp() { ++buildStamp; } template void BuildMaps(ARR& model) { BuildVertexMap(model); BuildFaceMap(model); } void ClearMaps() { vertexMap.Clear(); faceMap.Clear(); edgeMap.Clear(); } void OnModelChanged() { OnVerticesChanged(); OnFacesChanged(); OnEdgesChanged(); } template void SetIndices(ARR& model) { SetVertexIndices(model); SetFaceIndices(model); SetEdgeIndices(model); } void OnVerticesChanged() { buildStamp++; vertexMap.Clear(); } void OnFacesChanged() { buildStamp++; faceMap.Clear(); } void OnEdgesChanged() { buildStamp++; edgeMap.Clear(); } template VERTEX* FindVertex(ARR& model, int index) { if (index == NULL_INDEX) return nullptr; SetVertexIndices(model); BuildVertexMap(model); return vertexMap.Find(index); } template FACE* FindFace(ARR& model, int index) { if (index == NULL_INDEX) return nullptr; SetFaceIndices(model); BuildFaceMap(model); return faceMap.Find(index); } template EDGE* FindEdge(ARR& model, int index) { if (index == NULL_INDEX) return nullptr; SetEdgeIndices(model); BuildEdgeMap(model); return edgeMap.Find(index); } template void SetVertexIndices(ARR& model) { if (vertexMap.indicesSet) return; vertexMap.Clear(); for (auto vert = model.vertices_begin(); vert != model.vertices_end(); ++vert) vert->set_data(vertexMap.NextIndex()); vertexMap.indicesSet = true; } template void BuildVertexMap(ARR& model) { if (vertexMap.mapBuilt) return; vertexMap.ClearMap(); for (auto vert = model.vertices_begin(); vert != model.vertices_end(); ++vert) vertexMap.Insert(vert->data(), vert); vertexMap.mapBuilt = true; } template void SetFaceIndices(ARR& model) { if (faceMap.indicesSet) return; faceMap.Clear(); for (auto face = model.faces_begin(); face != model.faces_end(); ++face) { if (!face->is_unbounded()) face->set_data(faceMap.NextIndex()); else face->set_data(-1); } faceMap.indicesSet = true; } template void BuildFaceMap(ARR& model) { if (faceMap.mapBuilt) return; faceMap.ClearMap(); for (auto face = model.faces_begin(); face != model.faces_end(); ++face) { if(!face->is_unbounded()) faceMap.Insert(face->data(), face); } faceMap.mapBuilt = true; } template void SetEdgeIndices(ARR& model) { if (edgeMap.indicesSet) return; edgeMap.Clear(); for (auto edge = model.halfedges_begin(); edge != model.halfedges_end(); ++edge) edge->set_data(edgeMap.NextIndex()); edgeMap.indicesSet = true; } template void BuildEdgeMap(ARR& model) { if (edgeMap.mapBuilt) return; edgeMap.ClearMap(); for (auto edge = model.halfedges_begin(); edge != model.halfedges_end(); ++edge) edgeMap.Insert(edge->data(), edge); edgeMap.mapBuilt = true; } }; ================================================ FILE: CGALWrapper/Arrangments/SweepLine.h ================================================ #pragma once #include "../CGALWrapper.h" #include "../Geometry/Geometry2.h" #include #include #include #include template class SweepLine { private: typedef CGAL::Arr_segment_traits_2 Traits; typedef typename K::Point_2 Point_2; typedef typename Traits::Curve_2 Segment_2; std::list pointBuffer; std::list segmentBuffer; public: inline static SweepLine* NewSweepLine() { return new SweepLine(); } inline static void DeleteSweepLine(void* ptr) { auto obj = static_cast(ptr); if (obj != nullptr) { delete obj; obj = nullptr; } } inline static SweepLine* CastToSweepLine(void* ptr) { return static_cast(ptr); } static void ClearPointBuffer(void* ptr) { auto sweep = CastToSweepLine(ptr); sweep->pointBuffer.clear(); } static void ClearSegmentBuffer(void* ptr) { auto sweep = CastToSweepLine(ptr); sweep->segmentBuffer.clear(); } static int PointBufferSize(void* ptr) { auto sweep = CastToSweepLine(ptr); return (int)sweep->pointBuffer.size(); } static int SegmentBufferSize(void* ptr) { auto sweep = CastToSweepLine(ptr); return (int)sweep->segmentBuffer.size(); } static BOOL DoIntersect(void* ptr, Segment2d* segments, int count) { auto sweep = CastToSweepLine(ptr); auto list = ToList(segments, count); return CGAL::do_curves_intersect(list.begin(), list.end()); } static int ComputeSubcurves(void* ptr, Segment2d* segments, int count) { auto sweep = CastToSweepLine(ptr); auto list = ToList(segments, count); sweep->segmentBuffer.clear(); CGAL::compute_subcurves(list.begin(), list.end(), std::back_inserter(sweep->segmentBuffer)); return (int)sweep->segmentBuffer.size(); } static int ComputeIntersectionPoints(void* ptr, Segment2d* segments, int count) { auto sweep = CastToSweepLine(ptr); auto list = ToList(segments, count); sweep->pointBuffer.clear(); CGAL::compute_intersection_points(list.begin(), list.end(), std::back_inserter(sweep->pointBuffer)); return (int)sweep->pointBuffer.size(); } static void GetPoints(void* ptr, Point2d* points, int count) { auto sweep = CastToSweepLine(ptr); int i = 0; for (auto point = sweep->pointBuffer.begin(); point != sweep->pointBuffer.end(); ++point, ++i) points[i] = Point2d::FromCGAL(*point); } static void GetSegments(void* ptr, Segment2d* segments, int count) { auto sweep = CastToSweepLine(ptr); int i = 0; for (auto seg = sweep->segmentBuffer.begin(); seg != sweep->segmentBuffer.end(); ++seg, ++i) { auto a = seg->source(); auto b = seg->target(); segments[i] = Segment2d::FromCGAL(a, b); } } static std::vector ToList(Segment2d* segments, int count) { auto list = std::vector(); for (int i = 0; i < count; i++) list.push_back(segments[i].ToCGAL()); return list; } static Segment_2* ToArray(Segment2d* segments, int count) { auto arr = new Segment_2[count]; for (int i = 0; i < count; i++) arr[i] = segments[i].ToCGAL(); return arr; } }; ================================================ FILE: CGALWrapper/Arrangments/SweepLine_EEK.cpp ================================================ #include "SweepLine_EEK.h" #include "SweepLine.h" void* SweepLine2_EEK_Create() { return SweepLine::NewSweepLine(); } void SweepLine2_EEK_Release(void* ptr) { SweepLine::DeleteSweepLine(ptr); } void SweepLine2_EEK_ClearPointBuffer(void* ptr) { SweepLine::ClearPointBuffer(ptr); } void SweepLine2_EEK_ClearSegmentBuffer(void* ptr) { SweepLine::ClearSegmentBuffer(ptr); } int SweepLine2_EEK_PointBufferSize(void* ptr) { return SweepLine::PointBufferSize(ptr); } int SweepLine2_EEK_SegmentBufferSize(void* ptr) { return SweepLine::SegmentBufferSize(ptr); } BOOL SweepLine2_EEK_DoIntersect(void* ptr, Segment2d* segments, int count) { return SweepLine::DoIntersect(ptr, segments, count); } int SweepLine2_EEK_ComputeSubcurves(void* ptr, Segment2d* segments, int count) { return SweepLine::ComputeSubcurves(ptr, segments, count); } int SweepLine2_EEK_ComputeIntersectionPoints(void* ptr, Segment2d* segments, int count) { return SweepLine::ComputeIntersectionPoints(ptr, segments, count); } void SweepLine2_EEK_GetPoints(void* ptr, Point2d* points, int count) { SweepLine::GetPoints(ptr, points, count); } void SweepLine2_EEK_GetSegments(void* ptr, Segment2d* segments, int count) { SweepLine::GetSegments(ptr, segments, count); } ================================================ FILE: CGALWrapper/Arrangments/SweepLine_EEK.h ================================================ #pragma once #include "../CGALWrapper.h" #include "../Geometry/Geometry2.h" #include "SweepLine.h" extern "C" { CGALWRAPPER_API void* SweepLine2_EEK_Create(); CGALWRAPPER_API void SweepLine2_EEK_Release(void* ptr); CGALWRAPPER_API void SweepLine2_EEK_ClearPointBuffer(void* ptr); CGALWRAPPER_API void SweepLine2_EEK_ClearSegmentBuffer(void* ptr); CGALWRAPPER_API int SweepLine2_EEK_PointBufferSize(void* ptr); CGALWRAPPER_API int SweepLine2_EEK_SegmentBufferSize(void* ptr); CGALWRAPPER_API BOOL SweepLine2_EEK_DoIntersect(void* ptr, Segment2d* segments, int count); CGALWRAPPER_API int SweepLine2_EEK_ComputeSubcurves(void* ptr, Segment2d* segments, int count); CGALWRAPPER_API int SweepLine2_EEK_ComputeIntersectionPoints(void* ptr, Segment2d* segments, int count); CGALWRAPPER_API void SweepLine2_EEK_GetPoints(void* ptr, Point2d* points, int count); CGALWRAPPER_API void SweepLine2_EEK_GetSegments(void* ptr, Segment2d* segments, int count); } ================================================ FILE: CGALWrapper/Arrangments/SweepLine_EIK.cpp ================================================ #include "SweepLine_EIK.h" #include "SweepLine.h" void* SweepLine2_EIK_Create() { return SweepLine::NewSweepLine(); } void SweepLine2_EIK_Release(void* ptr) { SweepLine::DeleteSweepLine(ptr); } void SweepLine2_EIK_ClearPointBuffer(void* ptr) { SweepLine::ClearPointBuffer(ptr); } void SweepLine2_EIK_ClearSegmentBuffer(void* ptr) { SweepLine::ClearSegmentBuffer(ptr); } int SweepLine2_EIK_PointBufferSize(void* ptr) { return SweepLine::PointBufferSize(ptr); } int SweepLine2_EIK_SegmentBufferSize(void* ptr) { return SweepLine::SegmentBufferSize(ptr); } BOOL SweepLine2_EIK_DoIntersect(void* ptr, Segment2d* segments, int count) { return SweepLine::DoIntersect(ptr, segments, count); } int SweepLine2_EIK_ComputeSubcurves(void* ptr, Segment2d* segments, int count) { return SweepLine::ComputeSubcurves(ptr, segments, count); } int SweepLine2_EIK_ComputeIntersectionPoints(void* ptr, Segment2d* segments, int count) { return SweepLine::ComputeIntersectionPoints(ptr, segments, count); } void SweepLine2_EIK_GetPoints(void* ptr, Point2d* points, int count) { SweepLine::GetPoints(ptr, points, count); } void SweepLine2_EIK_GetSegments(void* ptr, Segment2d* segments, int count) { SweepLine::GetSegments(ptr, segments, count); } ================================================ FILE: CGALWrapper/Arrangments/SweepLine_EIK.h ================================================ #pragma once #include "../CGALWrapper.h" #include "../Geometry/Geometry2.h" #include "SweepLine.h" extern "C" { CGALWRAPPER_API void* SweepLine2_EIK_Create(); CGALWRAPPER_API void SweepLine2_EIK_Release(void* ptr); CGALWRAPPER_API void SweepLine2_EIK_ClearPointBuffer(void* ptr); CGALWRAPPER_API void SweepLine2_EIK_ClearSegmentBuffer(void* ptr); CGALWRAPPER_API int SweepLine2_EIK_PointBufferSize(void* ptr); CGALWRAPPER_API int SweepLine2_EIK_SegmentBufferSize(void* ptr); CGALWRAPPER_API BOOL SweepLine2_EIK_DoIntersect(void* ptr, Segment2d* segments, int count); CGALWRAPPER_API int SweepLine2_EIK_ComputeSubcurves(void* ptr, Segment2d* segments, int count); CGALWRAPPER_API int SweepLine2_EIK_ComputeIntersectionPoints(void* ptr, Segment2d* segments, int count); CGALWRAPPER_API void SweepLine2_EIK_GetPoints(void* ptr, Point2d* points, int count); CGALWRAPPER_API void SweepLine2_EIK_GetSegments(void* ptr, Segment2d* segments, int count); } ================================================ FILE: CGALWrapper/CGALWrapper.h ================================================ #pragma once #define CGALWRAPPER_API __declspec(dllexport) #define NULL_INDEX -1 #define WIN32_LEAN_AND_MEAN #define NOMINMAX #include #include #include #include #include #include #include #include #include #include #include #include "CGAL/Point_2.h" #include #include #include typedef CGAL::Exact_predicates_inexact_constructions_kernel EIK; typedef CGAL::Exact_predicates_exact_constructions_kernel EEK; typedef CGAL::Exact_predicates_exact_constructions_kernel_with_sqrt EEK_SQRT2; typedef CGAL::Exact_predicates_exact_constructions_kernel_with_kth_root EEK_KTH_ROOT; typedef CGAL::Exact_predicates_exact_constructions_kernel_with_root_of EEK_ROOT_OF; enum class CGAL_KERNEL : int { EXACT_PREDICATES_INEXACT_CONSTRUCTION = 0, EXACT_PREDICATES_EXACT_CONSTRUCTION = 1, EXACT_PREDICATES_EXACT_CONSTRUCTION_WITH_SQRT2 = 2, EXACT_PREDICATES_EXACT_CONSTRUCTION_WITH_KTH_ROOT = 3, EXACT_PREDICATES_EXACT_CONSTRUCTION_WITH_ROOT_OF = 4 }; enum class POLYGON_ELEMENT : int { BOUNDARY = 0, HOLE = 1 }; ================================================ FILE: CGALWrapper/CGALWrapper.rc ================================================ // Microsoft Visual C++ generated resource script. // #include "resource.h" #define APSTUDIO_READONLY_SYMBOLS ///////////////////////////////////////////////////////////////////////////// // // Generated from the TEXTINCLUDE 2 resource. // #include "winres.h" ///////////////////////////////////////////////////////////////////////////// #undef APSTUDIO_READONLY_SYMBOLS ///////////////////////////////////////////////////////////////////////////// // English (United States) resources #if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) LANGUAGE 9, 1 #ifdef APSTUDIO_INVOKED ///////////////////////////////////////////////////////////////////////////// // // TEXTINCLUDE // 1 TEXTINCLUDE BEGIN "resource.h\0" END 2 TEXTINCLUDE BEGIN "#include ""winres.h""\r\n" "\0" END 3 TEXTINCLUDE BEGIN "\r\n" "\0" END #endif // APSTUDIO_INVOKED #endif // English (United States) resources ///////////////////////////////////////////////////////////////////////////// #ifndef APSTUDIO_INVOKED ///////////////////////////////////////////////////////////////////////////// // // Generated from the TEXTINCLUDE 3 resource. // ///////////////////////////////////////////////////////////////////////////// #endif // not APSTUDIO_INVOKED ================================================ FILE: CGALWrapper/CGALWrapper.vcxproj ================================================ Debug Win32 Release Win32 Debug x64 Release x64 16.0 Win32Proj {14e85ae8-4516-4fd7-a464-69f55cab9e66} CGALWrapper 10.0 DynamicLibrary true v143 Unicode DynamicLibrary false v143 true Unicode DynamicLibrary true v143 Unicode DynamicLibrary false v143 true Unicode true false true false Level3 true WIN32;_DEBUG;CGALWRAPPER_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) true Use pch.h Windows true false Level3 true true true WIN32;NDEBUG;CGALWRAPPER_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) true Use pch.h Windows true true true false Level3 true _DEBUG;CGALWRAPPER_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) true NotUsing pch.h C:\dev\vcpkg\installed\x64-windows\include;%(AdditionalIncludeDirectories) /bigobj %(AdditionalOptions) Windows true false %(AdditionalLibraryDirectories) C:\dev\vcpkg\installed\x64-windows\lib\gmp.lib;C:\dev\vcpkg\installed\x64-windows\lib\mpfr.lib;%(AdditionalDependencies) Level3 true true true NDEBUG;CGALWRAPPER_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) true NotUsing pch.h C:\dev\vcpkg\installed\x64-windows\include;%(AdditionalIncludeDirectories) /bigobj %(AdditionalOptions) true 26495;26451;26812;6387;6031;6385;6812;%(DisableSpecificWarnings) Windows true true true false %(AdditionalLibraryDirectories) C:\dev\vcpkg\installed\x64-windows\lib\gmp.lib;C:\dev\vcpkg\installed\x64-windows\lib\mpfr.lib;%(AdditionalDependencies) Create Create Create Create ================================================ FILE: CGALWrapper/CGALWrapper.vcxproj.filters ================================================  {4FC737F1-C7A5-4376-A066-2A32D752A2FF} cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx {93995380-89BD-4b04-88EB-625FBE52EBFB} h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms {5d8d6fe4-c5ac-46b9-b198-41588c5c0f96} {c1a4e981-a230-4e33-9d7c-122f7f03caaa} {52bcf3aa-6773-4300-87e1-f8fb778f5af1} {88c3aad0-96b4-4bbe-928a-08872ee87f46} {2e0a034f-4a47-4736-8348-e07b217b9889} {0e3ede1a-3015-4a20-a650-2a82785d9280} {52bfc570-b5b1-4323-b124-201edfd0b624} {e994d2c5-19a5-484a-a5d4-a184067961f7} {e348a134-e84d-4f25-925a-bb64636fd6b4} {58adffc0-ff8b-4646-be31-1a01eec5cadd} {024c45c4-a4b5-4e27-834d-320f1012d7be} {0b18a7ac-011a-4aaa-9829-a5d3ee47825c} {7da444bc-d4ef-4f6c-ad36-9108f57a099e} {b95b8396-79b1-4ba4-9def-493e1efeefb9} Header Files Header Files Header Files Header Files Header Files\Geometry Header Files\Polygons Header Files\Polygons Header Files\Polygons Header Files\Polygons Header Files\Polygons Header Files\Polygons Header Files\Arrangements Header Files\Arrangements Header Files\Arrangements Header Files\Triangulations Header Files\Triangulations Header Files\Polygons Header Files\Polygons Header Files Header Files\Triangulations Header Files\Triangulations Header Files\Triangulations Header Files\Triangulations Header Files\Triangulations Header Files\Triangulations Header Files\Triangulations Header Files\Triangulations Header Files\Arrangements Header Files\Geometry Header Files\Geometry Header Files\Hulls Header Files\Hulls Header Files Header Files Header Files\Geometry Header Files\Polygons Header Files\Polygons Header Files\Geometry Header Files\Circlar Header Files\Circlar Header Files\Triangulations Header Files\Arrangements Header Files\Arrangements Header Files\Arrangements Header Files\Arrangements Header Files\Arrangements Header Files\Polygons Header Files\Polygons Header Files\Polygons Header Files\Polygons Header Files\Polygons Header Files\Polygons Polyhedra Polyhedra Header Files\Triangulations Header Files\Triangulations Header Files Header Files Header Files Header Files Header Files Header Files Header Files Header Files Header Files Header Files Header Files Header Files Header Files Header Files Header Files Header Files Header Files Header Files Header Files Header Files Header Files Header Files Header Files Header Files Header Files Header Files Header Files Header Files Header Files Header Files Header Files Header Files Header Files Header Files Header Files Header Files Header Files Header Files Header Files Header Files Header Files Header Files Header Files Header Files Header Files Header Files Header Files Header Files Header Files Header Files Header Files Header Files Header Files Header Files Header Files Header Files Header Files Header Files Header Files Header Files Header Files Header Files Header Files Header Files Header Files Header Files Header Files Header Files Header Files Header Files Header Files Header Files Header Files Header Files Header Files Header Files Header Files Header Files Header Files Header Files Header Files Header Files Header Files Header Files Header Files Header Files Header Files Header Files Header Files Header Files Header Files Header Files Header Files Header Files Header Files Header Files Header Files Header Files Header Files Header Files Header Files Header Files Header Files Header Files Header Files Header Files Header Files Header Files Header Files Header Files Header Files Header Files Header Files Source Files Source Files\Polygons Source Files\Polygons Source Files\Polygons Source Files\Arrangements Source Files\Triangulations Source Files\Polygons Source Files\Triangulations Source Files\Triangulations Source Files\Geometry Source Files\Hulls Source Files Source Files\Polygons Source Files\Geometry Source Files\Circlar Source Files\Arrangements Source Files\Polygons Source Files\Polygons Source Files\Polygons Source Files\Triangulations Source Files\Polyhedra Source Files Source Files Source Files Source Files Source Files Source Files Source Files Source Files Source Files Source Files Source Files Source Files Source Files Source Files Source Files Source Files Source Files Source Files Source Files Source Files Source Files Source Files Source Files Source Files Source Files Source Files Source Files Source Files Source Files Source Files Source Files Source Files Source Files Source Files Source Files Source Files Source Files Source Files Source Files Source Files Source Files Source Files Source Files Source Files Source Files Source Files Source Files Source Files Source Files Source Files Source Files Source Files Source Files Source Files Source Files Source Files Source Files Source Files Source Files Source Files Source Files Source Files Source Files Source Files Source Files Source Files Source Files Source Files Source Files Source Files Source Files Source Files Source Files Source Files Resource Files ================================================ FILE: CGALWrapper/Circlar/Circle2.h ================================================ #pragma once #include "../CGALWrapper.h" #include "../Geometry/Geometry2.h" #include #include template class Circle2 { public: typedef CGAL::Point_2 Point_2; typedef CGAL::Circle_2 Circle_2; static Circle_2* CastToCircle(void* ptr) { return static_cast(ptr); } static Circle_2* NewCircle2(Point2d center, double sq_radius, CGAL::Orientation orientation) { auto p = center.ToCGAL(); return new Circle_2(p, sq_radius, orientation); } static void DeleteCircle2(void* ptr) { auto obj = static_cast(ptr); if (obj != nullptr) { delete obj; obj = nullptr; } } }; ================================================ FILE: CGALWrapper/Circlar/Circle2_EEK.cpp ================================================ #pragma once #include "Circle2_EEK.h" #include "Circle2.h" #include #include #include #include #include void* Circle2_EEK_Create(Point2d center, double sq_radius, CGAL::Orientation orientation) { return Circle2::NewCircle2(center, sq_radius, orientation); } void Circle2_EEK_Release(void* ptr) { Circle2::DeleteCircle2(ptr); } ================================================ FILE: CGALWrapper/Circlar/Circle2_EEK.h ================================================ #pragma once #include "../CGALWrapper.h" #include "../Geometry/Geometry2.h" #include extern "C" { CGALWRAPPER_API void* Circle2_EEK_Create(Point2d center, double sq_radius, CGAL::Orientation orientation); CGALWRAPPER_API void Circle2_EEK_Release(void* ptr); }; ================================================ FILE: CGALWrapper/Collections/IndexMap.h ================================================ #pragma once #include #include template class IndexMap { private: int nextIndex = 0; std::unordered_map map; public: IndexMap() { nextIndex = 0; indicesSet = false; mapBuilt = false; } bool indicesSet; bool mapBuilt; void Clear() { ClearMap(); ResetIndices(); } void ClearMap() { mapBuilt = false; map.clear(); } void ResetIndices() { indicesSet = false; nextIndex = 0; } int NextIndex() { return nextIndex++; } void Insert(int index, T item) { map.insert(std::pair(index, item)); } T* Find(int index) { auto item = map.find(index); if (item != map.end()) return &item->second; else return nullptr; } }; ================================================ FILE: CGALWrapper/Collections/NativeList.cpp ================================================ #include "NativeList.h" #include void* NativeList_Create() { return new NativeList(); } void* NativeList_CreateWithCount(int count) { return new NativeList(count); } void NativeList_Release(void* listPtr) { auto obj = static_cast(listPtr); if (obj != nullptr) { delete obj; obj = nullptr; } } void NativeList_Add(void* listPtr, void* ptr) { auto list = NativeList::CastToNativeList(listPtr); list->Add(ptr); } void NativeList_AddRange(void* listPtr, void** ptr_array, int count) { auto list = NativeList::CastToNativeList(listPtr); list->AddRange(ptr_array, count); } int NativeList_Capacity(void* listPtr) { auto list = NativeList::CastToNativeList(listPtr); return list->Capacity(); } void NativeList_Clear(void* listPtr) { auto list = NativeList::CastToNativeList(listPtr); list->Clear(); } int NativeList_Count(void* listPtr) { auto list = NativeList::CastToNativeList(listPtr); return list->Count(); } BOOL NativeList_Contains(void* listPtr, void* ptr) { auto list = NativeList::CastToNativeList(listPtr); return list->Contains(ptr); } void* NativeList_Copy(void* listPtr) { auto list = NativeList::CastToNativeList(listPtr); return list->Copy(); } void* NativeList_Get(void* listPtr, int index) { auto list = NativeList::CastToNativeList(listPtr); return list->Get(index); } void NativeList_Set(void* listPtr, int index, void* ptr) { auto list = NativeList::CastToNativeList(listPtr); list->Set(index, ptr); } int NativeList_IndexOf(void* listPtr, void* ptr) { auto list = NativeList::CastToNativeList(listPtr); return list->IndexOf(ptr); } void NativeList_Insert(void* listPtr, void* ptr, int index) { auto list = NativeList::CastToNativeList(listPtr); list->Insert(ptr, index); } BOOL NativeList_Remove(void* listPtr, void* ptr) { auto list = NativeList::CastToNativeList(listPtr); int before = list->Count(); list->Remove(ptr); return list->Count() == before - 1; } void NativeList_RemoveAt(void* listPtr, int index) { auto list = NativeList::CastToNativeList(listPtr); list->RemoveAt(index); } void NativeList_Reverse(void* listPtr) { auto list = NativeList::CastToNativeList(listPtr); list->Reverse(); } void NativeList_TrimExcess(void* listPtr) { auto list = NativeList::CastToNativeList(listPtr); list->TrimExcess(); } NativeList::NativeList() { } NativeList::NativeList(int count) { vec.reserve(count); } NativeList::~NativeList() { } void NativeList::Add(void* ptr) { vec.push_back(ptr); } void NativeList::AddRange(void** ptr_array, int count) { vec.insert(vec.end(), ptr_array, ptr_array + count); } int NativeList::Capacity() { return (int)vec.capacity(); } void NativeList::Clear() { vec.clear(); } int NativeList::Count() { return (int)vec.size(); } BOOL NativeList::Contains(void* ptr) { return IndexOf(ptr) != -1; } void* NativeList::Copy() { auto copy = new NativeList(); copy->vec = vec; return copy; } void* NativeList::Get(int index) { if (InRange(index)) return vec[index]; else return nullptr; } void NativeList::Set(int index, void* ptr) { if (InRange(index)) vec[index] = ptr; } int NativeList::IndexOf(void* ptr) { for (int i = 0; i < Count(); i++) if (vec[i] == ptr) return i; return -1; } void NativeList::Insert(void* ptr, int index) { if(InRange(index)) vec.insert(vec.begin() + index, ptr); } void NativeList::Remove(void* ptr) { int i = IndexOf(ptr); if (i == -1) return; RemoveAt(i); } void NativeList::RemoveAt(int index) { if (InRange(index)) vec.erase(vec.begin() + index); } void NativeList::Reverse() { std::reverse(vec.begin(), vec.end()); } void NativeList::TrimExcess() { vec.shrink_to_fit(); } bool NativeList::InRange(int index) { if (index < 0 || index >= Count()) return false; else return true; } bool NativeList::NotInRange(int index) { return !InRange(index); } ================================================ FILE: CGALWrapper/Collections/NativeList.h ================================================ #pragma once #include "../CGALWrapper.h" #include extern "C" { CGALWRAPPER_API void* NativeList_Create(); CGALWRAPPER_API void* NativeList_CreateWithCount(int count); CGALWRAPPER_API void NativeList_Release(void* listPtr); CGALWRAPPER_API void NativeList_Add(void* listPtr, void* ptr); CGALWRAPPER_API void NativeList_AddRange(void* listPtr, void** ptr_array, int count); CGALWRAPPER_API int NativeList_Capacity(void* listPtr); CGALWRAPPER_API void NativeList_Clear(void* listPtr); CGALWRAPPER_API int NativeList_Count(void* listPtr); CGALWRAPPER_API BOOL NativeList_Contains(void* listPtr, void* ptr); CGALWRAPPER_API void* NativeList_Copy(void* listPtr); CGALWRAPPER_API void* NativeList_Get(void* listPtr, int index); CGALWRAPPER_API void NativeList_Set(void* listPtr, int index, void* ptr); CGALWRAPPER_API int NativeList_IndexOf(void* listPtr, void* ptr); CGALWRAPPER_API void NativeList_Insert(void* listPtr, void* ptr, int index); CGALWRAPPER_API BOOL NativeList_Remove(void* listPtr, void* ptr); CGALWRAPPER_API void NativeList_RemoveAt(void* listPtr, int index); CGALWRAPPER_API void NativeList_Reverse(void* listPtr); CGALWRAPPER_API void NativeList_TrimExcess(void* listPtr); } class NativeList { private: std::vector vec; public: NativeList(); NativeList(int count); ~NativeList(); inline static NativeList* CastToNativeList(void* ptr) { return static_cast(ptr); } void Add(void* ptr); void AddRange(void** ptr_array, int count); int Capacity(); void Clear(); int Count(); BOOL Contains(void* ptr); void* Copy(); void* Get(int index); void Set(int index, void* ptr); int IndexOf(void* ptr); void Insert(void* ptr, int index); void Remove(void* ptr); void RemoveAt(int index); void Reverse(); void TrimExcess(); private: bool InRange(int index); bool NotInRange(int index); }; ================================================ FILE: CGALWrapper/Eigen/EigenColumnVector.cpp ================================================ #include "EigenColumnVector.h" #include typedef Eigen::Matrix ColumnVector; typedef Eigen::Matrix RowVector; typedef Eigen::Matrix Matrix; void* EigenColumnVector_CreateVector(int rows) { auto v = new ColumnVector(rows, 1); for (int i = 0; i < rows; i++) (*v)(i) = 0; return v; } void EigenColumnVector_Release(void* ptr) { auto obj = static_cast(ptr); if (obj != nullptr) { delete obj; obj = nullptr; } } ColumnVector* CastToColumnVector(void* ptr) { return static_cast(ptr); } ColumnVector* NewColumnVector(const ColumnVector& v) { return new ColumnVector(v.rows(), 1); } ColumnVector* NewColumnVector() { return new ColumnVector(); } RowVector* NewRowVector(); int EigenColumnVector_Dimension(void* ptr) { auto m = CastToColumnVector(ptr); return (int)m->rows(); } double EigenColumnVector_Get(void* ptr, int x) { auto m = CastToColumnVector(ptr); return (*m)(x); } void EigenColumnVector_Set(void* ptr, int x, double value) { auto m = CastToColumnVector(ptr); (*m)(x) = value; } double EigenColumnVector_Dot(void* ptr1, void* ptr2) { auto v1 = CastToColumnVector(ptr1); auto v2 = CastToColumnVector(ptr2); return v1->dot(*v2); } void* EigenColumnVector_Normalized(void* ptr) { auto v = CastToColumnVector(ptr); auto n = NewColumnVector(*v); (*n) = v->normalized(); return n; } void EigenColumnVector_Normalize(void* ptr) { auto v = CastToColumnVector(ptr); v->normalize(); } double EigenColumnVector_Norm(void* ptr) { auto v = CastToColumnVector(ptr); return v->norm(); } void* EigenColumnVector_Transpose(void* ptr) { auto v1 = CastToColumnVector(ptr); auto v2 = NewRowVector(); (*v2) = v1->transpose(); return v2; } void* EigenColumnVector_Adjoint(void* ptr) { auto v1 = CastToColumnVector(ptr); auto v2 = NewColumnVector(); (*v2) = v1->adjoint(); return v2; } void* EigenColumnVector_Conjugate(void* ptr) { auto v1 = CastToColumnVector(ptr); auto v2 = NewColumnVector(); (*v2) = v1->conjugate(); return v2; } void EigenColumnVector_Resize(void* ptr, int dimension) { auto v = CastToColumnVector(ptr); v->resize(dimension); } ================================================ FILE: CGALWrapper/Eigen/EigenColumnVector.h ================================================ #pragma once #include "../CGALWrapper.h" #include "../Geometry/Geometry2.h" #include "../Geometry/Geometry3.h" #include extern "C" { CGALWRAPPER_API void* EigenColumnVector_CreateVector(int rows); CGALWRAPPER_API void EigenColumnVector_Release(void* ptr); CGALWRAPPER_API int EigenColumnVector_Dimension(void* ptr); CGALWRAPPER_API double EigenColumnVector_Get(void* ptr, int x); CGALWRAPPER_API void EigenColumnVector_Set(void* ptr, int x, double value); CGALWRAPPER_API double EigenColumnVector_Dot(void* ptr1, void* ptr2); CGALWRAPPER_API void* EigenColumnVector_Normalized(void* ptr); CGALWRAPPER_API void EigenColumnVector_Normalize(void* ptr); CGALWRAPPER_API double EigenColumnVector_Norm(void* ptr); CGALWRAPPER_API void* EigenColumnVector_Transpose(void* ptr); CGALWRAPPER_API void* EigenColumnVector_Adjoint(void* ptr); CGALWRAPPER_API void* EigenColumnVector_Conjugate(void* ptr); CGALWRAPPER_API void EigenColumnVector_Resize(void* ptr, int dimension); } ================================================ FILE: CGALWrapper/Eigen/EigenMatrix.cpp ================================================ #include #include "EigenMatrix.h" #include #include typedef Eigen::Matrix ColumnVector; typedef Eigen::Matrix RowVector; typedef Eigen::Matrix Matrix; ColumnVector* CastToColumnVector(void* ptr); ColumnVector* NewColumnVector(); ColumnVector* NewColumnVector(const ColumnVector& v); RowVector* CastToRowVector(void* ptr); RowVector* NewRowVector(); RowVector* NewRowVector(const RowVector& v); void* EigenMatrix_Create(int rows, int columns) { auto m = new Matrix(rows, columns); for (int y = 0; y < columns; y++) for (int x = 0; x < rows; x++) (*m)(x, y) = 0; return m; } void* EigenMatrix_CreateIdentity(int rows, int columns) { auto m = new Matrix(rows, columns); for (int y = 0; y < columns; y++) { for (int x = 0; x < rows; x++) { if (x == y) (*m)(x,y) = 1; else (*m)(x, y) = 0; } } return m; } void EigenMatrix_Release(void* ptr) { auto obj = static_cast(ptr); if (obj != nullptr) { delete obj; obj = nullptr; } } Matrix* CastToMatrix(void* ptr) { return static_cast(ptr); } Matrix* NewMatrix(const Matrix& m) { return new Matrix(m.rows(), m.cols()); } Matrix* NewMatrix() { return new Matrix(); } int EigenMatrix_Rows(void* ptr) { auto m = CastToMatrix(ptr); return (int)m->rows(); } int EigenMatrix_Columns(void* ptr) { auto m = CastToMatrix(ptr); return (int)m->cols(); } double EigenMatrix_GetXY(void* ptr, int x, int y) { auto m = CastToMatrix(ptr); return (*m)(x, y); } void EigenMatrix_SetXY(void* ptr, int x, int y, double value) { auto m = CastToMatrix(ptr); (*m)(x, y) = value; } double EigenMatrix_GetX(void* ptr, int x) { auto m = CastToMatrix(ptr); return (*m)(x); } void EigenMatrix_SetX(void* ptr, int x, double value) { auto m = CastToMatrix(ptr); (*m)(x) = value; } void* EigenMatrix_Transpose(void* ptr) { auto m = CastToMatrix(ptr); auto m2 = NewMatrix(); (*m2) = m->transpose(); return m2; } void* EigenMatrix_Conjugate(void* ptr) { auto m = CastToMatrix(ptr); auto m2 = NewMatrix(); (*m2) = m->conjugate(); return m2; } void* EigenMatrix_Adjoint(void* ptr) { auto m = CastToMatrix(ptr); auto m2 = NewMatrix(); (*m2) = m->adjoint(); return m2; } void* EigenMatrix_Inverse(void* ptr) { auto m = CastToMatrix(ptr); auto m2 = NewMatrix(); (*m2) = m->inverse(); return m2; } BOOL EigenMatrix_IsInvertible(void* ptr) { auto m = CastToMatrix(ptr); Eigen::FullPivLU lu(*m); return lu.isInvertible(); } void* EigenMatrix_TryInverse(void* ptr) { auto m = CastToMatrix(ptr); Eigen::FullPivLU lu(*m); if (lu.isInvertible()) { auto inv = NewMatrix(); (*inv) = lu.inverse(); return inv; } else { return nullptr; } } double EigenMatrix_Determinant(void* ptr) { auto m = CastToMatrix(ptr); return m->determinant(); } double EigenMatrix_Trace(void* ptr) { auto m = CastToMatrix(ptr); return m->trace(); } BOOL EigenMatrix_IsIdentity(void* ptr) { auto m = CastToMatrix(ptr); return m->isIdentity(); } BOOL EigenMatrix_IsDiagonal(void* ptr) { auto m = CastToMatrix(ptr); return m->isDiagonal(); } BOOL EigenMatrix_IsUpperTriangular(void* ptr) { auto m = CastToMatrix(ptr); return m->isUpperTriangular(); } BOOL EigenMatrix_IsLowerTriangular(void* ptr) { auto m = CastToMatrix(ptr); return m->isLowerTriangular(); } void* EigenMatrix_MulScalar(void* ptr1, double s) { auto m1 = CastToMatrix(ptr1); auto m = NewMatrix(*m1); (*m) = (*m1) * s; return m; } void* EigenMatrix_DivideScalar(void* ptr1, double s) { auto m1 = CastToMatrix(ptr1); auto m = NewMatrix(*m1); (*m) = (*m1) / s; return m; } void* EigenMatrix_MulMatrix(void* ptr1, void* ptr2) { auto m1 = CastToMatrix(ptr1); auto m2 = CastToMatrix(ptr2); auto m = NewMatrix(*m1); (*m) = (*m1) * (*m2); return m; } void* EigenMatrix_AddMatrix(void* ptr1, void* ptr2) { auto m1 = CastToMatrix(ptr1); auto m2 = CastToMatrix(ptr2); auto m = NewMatrix(*m1); (*m) = (*m1) + (*m2); return m; } void* EigenMatrix_SubMatrix(void* ptr1, void* ptr2) { auto m1 = CastToMatrix(ptr1); auto m2 = CastToMatrix(ptr2); auto m = NewMatrix(*m1); (*m) = (*m1) - (*m2); return m; } void* EigenMatrix_MulColumnVector(void* ptr1, void* ptr2) { auto m1 = CastToMatrix(ptr1); auto v2 = CastToColumnVector(ptr2); auto v = NewColumnVector(*v2); (*v) = (*m1) * (*v2); return v; } void* EigenMatrix_MulRowVector(void* ptr1, void* ptr2) { auto m1 = CastToMatrix(ptr1); auto v2 = CastToRowVector(ptr2); auto v = NewRowVector(*v2); (*v) = (*m1) * (*v2); return v; } void* EigenMatrix_Block(void* ptr, int startRox, int startCol, int blockRows, int blockCols) { auto m = CastToMatrix(ptr); auto m2 = NewMatrix(); (*m2) = m->block(startRox, startCol, blockRows, blockCols); return m2; } void* EigenMatrix_Reshaped(void* ptr, int rows, int cols) { auto m = CastToMatrix(ptr); auto m2 = NewMatrix(); (*m2) = m->reshaped(rows, cols); return m2; } void* EigenMatrix_ColPivHouseholderQr_Vec(void* ptr1, void* ptr2) { auto m = CastToMatrix(ptr1); auto v = CastToColumnVector(ptr2); auto x = NewColumnVector(); (*x) = m->colPivHouseholderQr().solve(*v); return x; } void* EigenMatrix_ColPivHouseholderQr_Mat(void* ptr1, void* ptr2) { auto m = CastToMatrix(ptr1); auto v = CastToMatrix(ptr2); auto x = NewMatrix(); (*x) = m->colPivHouseholderQr().solve(*v); return x; } void* EigenMatrix_PartialPivLu_Vec(void* ptr1, void* ptr2) { auto m = CastToMatrix(ptr1); auto v = CastToColumnVector(ptr2); auto x = NewColumnVector(); (*x) = m->partialPivLu().solve(*v); return x; } void* EigenMatrix_PartialPivLu_Mat(void* ptr1, void* ptr2) { auto m = CastToMatrix(ptr1); auto v = CastToMatrix(ptr2); auto x = NewMatrix(); (*x) = m->partialPivLu().solve(*v); return x; } void* EigenMatrix_FullPivLu_Vec(void* ptr1, void* ptr2) { auto m = CastToMatrix(ptr1); auto v = CastToColumnVector(ptr2); auto x = NewColumnVector(); (*x) = m->fullPivLu().solve(*v); return x; } void* EigenMatrix_FullPivLu_Mat(void* ptr1, void* ptr2) { auto m = CastToMatrix(ptr1); auto v = CastToMatrix(ptr2); auto x = NewMatrix(); (*x) = m->fullPivLu().solve(*v); return x; } void* EigenMatrix_HouseholderQr_Vec(void* ptr1, void* ptr2) { auto m = CastToMatrix(ptr1); auto v = CastToColumnVector(ptr2); auto x = NewColumnVector(); (*x) = m->householderQr().solve(*v); return x; } void* EigenMatrix_HouseholderQr_Mat(void* ptr1, void* ptr2) { auto m = CastToMatrix(ptr1); auto v = CastToMatrix(ptr2); auto x = NewMatrix(); (*x) = m->householderQr().solve(*v); return x; } void* EigenMatrix_LLT_Vec(void* ptr1, void* ptr2) { auto m = CastToMatrix(ptr1); auto v = CastToColumnVector(ptr2); auto x = NewColumnVector(); (*x) = m->llt().solve(*v); return x; } void* EigenMatrix_LLT_Mat(void* ptr1, void* ptr2) { auto m = CastToMatrix(ptr1); auto v = CastToMatrix(ptr2); auto x = NewMatrix(); (*x) = m->llt().solve(*v); return x; } void* EigenMatrix_LDLT_Vec(void* ptr1, void* ptr2) { auto m1 = CastToMatrix(ptr1); auto v = CastToColumnVector(ptr2); auto x = NewColumnVector(); (*x) = m1->ldlt().solve(*v); return x; } void* EigenMatrix_LDLT_Mat(void* ptr1, void* ptr2) { auto m1 = CastToMatrix(ptr1); auto v = CastToMatrix(ptr2); auto x = NewMatrix(); (*x) = m1->ldlt().solve(*v); return x; } void* EigenMatrix_BdcSvd_Vec(void* ptr1, void* ptr2, int options) { auto m = CastToMatrix(ptr1); auto v = CastToColumnVector(ptr2); auto x = NewColumnVector(); (*x) = m->bdcSvd(options).solve(*v); return x; } void* EigenMatrix_BdcSvd_Mat(void* ptr1, void* ptr2, int options) { auto m = CastToMatrix(ptr1); auto v = CastToMatrix(ptr2); auto x = NewMatrix(); (*x) = m->bdcSvd(options).solve(*v); return x; } void* EigenMatrix_JacobiSvd_Vec(void* ptr1, void* ptr2, int options) { auto m = CastToMatrix(ptr1); auto v = CastToColumnVector(ptr2); auto x = NewColumnVector(); (*x) = m->jacobiSvd(options).solve(*v); return x; } void* EigenMatrix_JacobiSvd_Mat(void* ptr1, void* ptr2, int options) { auto m = CastToMatrix(ptr1); auto v = CastToMatrix(ptr2); auto x = NewMatrix(); (*x) = m->jacobiSvd(options).solve(*v); return x; } void* EigenMatrix_FullPivHouseholderQr_Vec(void* ptr1, void* ptr2) { auto m = CastToMatrix(ptr1); auto v = CastToColumnVector(ptr2); auto x = NewColumnVector(); (*x) = m->fullPivHouseholderQr().solve(*v); return x; } void* EigenMatrix_FullPivHouseholderQr_Mat(void* ptr1, void* ptr2) { auto m = CastToMatrix(ptr1); auto v = CastToMatrix(ptr2); auto x = NewMatrix(); (*x) = m->fullPivHouseholderQr().solve(*v); return x; } void* EigenMatrix_CompleteOrthogonalDecomposition_Vec(void* ptr1, void* ptr2) { auto m = CastToMatrix(ptr1); auto v = CastToColumnVector(ptr2); auto x = NewColumnVector(); (*x) = m->completeOrthogonalDecomposition().solve(*v); return x; } void* EigenMatrix_CompleteOrthogonalDecomposition_Mat(void* ptr1, void* ptr2) { auto m = CastToMatrix(ptr1); auto v = CastToMatrix(ptr2); auto x = NewMatrix(); (*x) = m->completeOrthogonalDecomposition().solve(*v); return x; } double EigenMatrix_RelativeError_Vec(void* ptr1, void* ptr2, void* ptr3) { auto A = CastToMatrix(ptr1); auto b = CastToColumnVector(ptr2); auto x = CastToColumnVector(ptr3); return ((*A) * (*x) - (*b)).norm() / b->norm(); } double EigenMatrix_RelativeError_Mat(void* ptr1, void* ptr2, void* ptr3) { auto A = CastToMatrix(ptr1); auto b = CastToMatrix(ptr2); auto x = CastToMatrix(ptr3); return ((*A) * (*x) - (*b)).norm() / b->norm(); } void* EigenMatrix_Eigenvalues(void* ptr) { auto m = CastToMatrix(ptr); Eigen::SelfAdjointEigenSolver solver(*m); if (solver.info() != Eigen::Success) return nullptr; else { auto x = NewColumnVector(); (*x) = solver.eigenvalues(); return x; } } void* EigenMatrix_Eigenvectors(void* ptr) { auto m = CastToMatrix(ptr); Eigen::SelfAdjointEigenSolver solver(*m); if (solver.info() != Eigen::Success) return nullptr; else { auto x = NewMatrix(); (*x) = solver.eigenvectors(); return x; } } BOOL EigenMatrix_EigenValuesVectors(void* ptr, void** values, void** vectors) { auto m = CastToMatrix(ptr); Eigen::SelfAdjointEigenSolver solver(*m); *values = nullptr; *vectors = nullptr; if (solver.info() != Eigen::Success) { return FALSE; } else { auto _values = solver.eigenvalues(); auto _vectors = solver.eigenvectors(); auto v = NewColumnVector(_values); for (auto i = 0; i < _values.size(); i++) (*v)[i] = _values[i]; auto m = NewMatrix(_vectors); for (auto i = 0; i < _vectors.size(); i++) (*m)(i) = _vectors(i); (*values) = v; (*vectors) = m; return TRUE; } } ================================================ FILE: CGALWrapper/Eigen/EigenMatrix.h ================================================ #pragma once #include "../CGALWrapper.h" #include "../Geometry/Geometry2.h" #include "../Geometry/Geometry3.h" #include extern "C" { CGALWRAPPER_API void* EigenMatrix_Create(int rows, int columns); CGALWRAPPER_API void* EigenMatrix_CreateIdentity(int rows, int columns); CGALWRAPPER_API void EigenMatrix_Release(void* ptr); CGALWRAPPER_API int EigenMatrix_Rows(void* ptr); CGALWRAPPER_API int EigenMatrix_Columns(void* ptr); CGALWRAPPER_API double EigenMatrix_GetXY(void* ptr, int x, int y); CGALWRAPPER_API void EigenMatrix_SetXY(void* ptr, int x, int y, double value); CGALWRAPPER_API double EigenMatrix_GetX(void* ptr, int x); CGALWRAPPER_API void EigenMatrix_SetX(void* ptr, int x, double value); CGALWRAPPER_API void* EigenMatrix_Transpose(void* ptr); CGALWRAPPER_API void* EigenMatrix_Conjugate(void* ptr); CGALWRAPPER_API void* EigenMatrix_Adjoint(void* ptr); CGALWRAPPER_API void* EigenMatrix_Inverse(void* ptr); CGALWRAPPER_API BOOL EigenMatrix_IsInvertible(void* ptr); CGALWRAPPER_API void* EigenMatrix_TryInverse(void* ptr); CGALWRAPPER_API double EigenMatrix_Determinant(void* ptr); CGALWRAPPER_API double EigenMatrix_Trace(void* ptr); CGALWRAPPER_API BOOL EigenMatrix_IsIdentity(void* ptr); CGALWRAPPER_API BOOL EigenMatrix_IsDiagonal(void* ptr); CGALWRAPPER_API BOOL EigenMatrix_IsUpperTriangular(void* ptr); CGALWRAPPER_API BOOL EigenMatrix_IsLowerTriangular(void* ptr); CGALWRAPPER_API void* EigenMatrix_MulScalar(void* ptr1, double s); CGALWRAPPER_API void* EigenMatrix_DivideScalar(void* ptr1, double s); CGALWRAPPER_API void* EigenMatrix_MulMatrix(void* ptr1, void* ptr2); CGALWRAPPER_API void* EigenMatrix_AddMatrix(void* ptr1, void* ptr2); CGALWRAPPER_API void* EigenMatrix_SubMatrix(void* ptr1, void* ptr2); CGALWRAPPER_API void* EigenMatrix_MulColumnVector(void* ptr1, void* ptr2); CGALWRAPPER_API void* EigenMatrix_MulRowVector(void* ptr1, void* ptr2); CGALWRAPPER_API void* EigenMatrix_Block(void* ptr, int startRox, int startCol, int blockRows, int blockCols); CGALWRAPPER_API void* EigenMatrix_Reshaped(void* ptr, int rows, int cols); CGALWRAPPER_API void* EigenMatrix_ColPivHouseholderQr_Vec(void* ptr1, void* ptr2); CGALWRAPPER_API void* EigenMatrix_ColPivHouseholderQr_Mat(void* ptr1, void* ptr2); CGALWRAPPER_API void* EigenMatrix_PartialPivLu_Vec(void* ptr1, void* ptr2); CGALWRAPPER_API void* EigenMatrix_PartialPivLu_Mat(void* ptr1, void* ptr2); CGALWRAPPER_API void* EigenMatrix_FullPivLu_Vec(void* ptr1, void* ptr2); CGALWRAPPER_API void* EigenMatrix_FullPivLu_Mat(void* ptr1, void* ptr2); CGALWRAPPER_API void* EigenMatrix_HouseholderQr_Vec(void* ptr1, void* ptr2); CGALWRAPPER_API void* EigenMatrix_HouseholderQr_Mat(void* ptr1, void* ptr2); CGALWRAPPER_API void* EigenMatrix_LLT_Vec(void* ptr1, void* ptr2); CGALWRAPPER_API void* EigenMatrix_LLT_Mat(void* ptr1, void* ptr2); CGALWRAPPER_API void* EigenMatrix_LDLT_Vec(void* ptr1, void* ptr2); CGALWRAPPER_API void* EigenMatrix_LDLT_Mat(void* ptr1, void* ptr2); CGALWRAPPER_API void* EigenMatrix_BdcSvd_Vec(void* ptr1, void* ptr2, int options); CGALWRAPPER_API void* EigenMatrix_BdcSvd_Mat(void* ptr1, void* ptr2, int options); CGALWRAPPER_API void* EigenMatrix_JacobiSvd_Vec(void* ptr1, void* ptr2, int options); CGALWRAPPER_API void* EigenMatrix_JacobiSvd_Mat(void* ptr1, void* ptr2, int options); CGALWRAPPER_API void* EigenMatrix_FullPivHouseholderQr_Vec(void* ptr1, void* ptr2); CGALWRAPPER_API void* EigenMatrix_FullPivHouseholderQr_Mat(void* ptr1, void* ptr2); CGALWRAPPER_API void* EigenMatrix_CompleteOrthogonalDecomposition_Vec(void* ptr1, void* ptr2); CGALWRAPPER_API void* EigenMatrix_CompleteOrthogonalDecomposition_Mat(void* ptr1, void* ptr2); CGALWRAPPER_API double EigenMatrix_RelativeError_Vec(void* ptr1, void* ptr2, void* ptr3); CGALWRAPPER_API double EigenMatrix_RelativeError_Mat(void* ptr1, void* ptr2, void* ptr3); CGALWRAPPER_API void* EigenMatrix_Eigenvalues(void* ptr); CGALWRAPPER_API void* EigenMatrix_Eigenvectors(void* ptr); CGALWRAPPER_API BOOL EigenMatrix_EigenValuesVectors(void* ptr, void** values, void** vectors); } ================================================ FILE: CGALWrapper/Eigen/EigenRowVector.cpp ================================================ #include "EigenRowVector.h" #include typedef Eigen::Matrix ColumnVector; typedef Eigen::Matrix RowVector; typedef Eigen::Matrix Matrix; void* EigenRowVector_CreateVector(int columns) { auto v = new RowVector(1, columns); for (int i = 0; i < columns; i++) (*v)(i) = 0; return v; } void EigenRowVector_Release(void* ptr) { auto obj = static_cast(ptr); if (obj != nullptr) { delete obj; obj = nullptr; } } RowVector* CastToRowVector(void* ptr) { return static_cast(ptr); } RowVector* NewRowVector(const RowVector& v) { return new RowVector(1, v.cols()); } RowVector* NewRowVector() { return new RowVector(); } ColumnVector* NewColumnVector(); int EigenRowVector_Dimension(void* ptr) { auto m = CastToRowVector(ptr); return (int)m->cols(); } double EigenRowVector_Get(void* ptr, int x) { auto m = CastToRowVector(ptr); return (*m)(x); } void EigenRowVector_Set(void* ptr, int x, double value) { auto m = CastToRowVector(ptr); (*m)(x) = value; } double EigenRowVector_Dot(void* ptr1, void* ptr2) { auto v1 = CastToRowVector(ptr1); auto v2 = CastToRowVector(ptr2); return v1->dot(*v2); } void* EigenRowVector_Normalized(void* ptr) { auto v = CastToRowVector(ptr); auto n = NewRowVector(*v); (*n) = v->normalized(); return n; } void EigenRowVector_Normalize(void* ptr) { auto v = CastToRowVector(ptr); v->normalize(); } double EigenRowVector_Norm(void* ptr) { auto v = CastToRowVector(ptr); return v->norm(); } void* EigenRowVector_Transpose(void* ptr) { auto v1 = CastToRowVector(ptr); auto v2 = NewColumnVector(); (*v2) = v1->transpose(); return v2; } void* EigenRowVector_Adjoint(void* ptr) { auto v1 = CastToRowVector(ptr); auto v2 = NewRowVector(); (*v2) = v1->adjoint(); return v2; } void* EigenRowVector_Conjugate(void* ptr) { auto v1 = CastToRowVector(ptr); auto v2 = NewRowVector(); (*v2) = v1->conjugate(); return v2; } void EigenRowVector_Resize(void* ptr, int dimension) { auto v = CastToRowVector(ptr); v->resize(dimension); } ================================================ FILE: CGALWrapper/Eigen/EigenRowVector.h ================================================ #pragma once #include "../CGALWrapper.h" #include "../Geometry/Geometry2.h" #include "../Geometry/Geometry3.h" #include extern "C" { CGALWRAPPER_API void* EigenRowVector_CreateVector(int columns); CGALWRAPPER_API void EigenRowVector_Release(void* ptr); CGALWRAPPER_API int EigenRowVector_Dimension(void* ptr); CGALWRAPPER_API double EigenRowVector_Get(void* ptr, int x); CGALWRAPPER_API void EigenRowVector_Set(void* ptr, int x, double value); CGALWRAPPER_API double EigenRowVector_Dot(void* ptr1, void* ptr2); CGALWRAPPER_API void* EigenRowVector_Normalized(void* ptr); CGALWRAPPER_API void EigenRowVector_Normalize(void* ptr); CGALWRAPPER_API double EigenRowVector_Norm(void* ptr); CGALWRAPPER_API void* EigenRowVector_Transpose(void* ptr); CGALWRAPPER_API void* EigenRowVector_Adjoint(void* ptr); CGALWRAPPER_API void* EigenRowVector_Conjugate(void* ptr); CGALWRAPPER_API void EigenRowVector_Resize(void* ptr, int dimension); } ================================================ FILE: CGALWrapper/Geometry/Box2_EEK.cpp ================================================ #include "Box2_EEK.h" #include #include #include typedef CGAL::Iso_rectangle_2 Box2; typedef CGAL::Aff_transformation_2 Transformation2; void* Box2_EEK_Create(const Point2d& min, const Point2d& max) { auto _min = min.ToCGAL(); auto _max = max.ToCGAL(); return new Box2(_min, _max); } void Box2_EEK_Release(void* ptr) { auto obj = static_cast(ptr); if (obj != nullptr) { delete obj; obj = nullptr; } } Box2* CastToBox2(void* ptr) { return static_cast(ptr); } Box2* NewBox2() { return new Box2(); } Point2d Box2_EEK_GetMin(void* ptr) { auto rec = CastToBox2(ptr); return Point2d::FromCGAL(rec->min()); } void Box2_EEK_SetMin(void* ptr, const Point2d& point) { auto rec = CastToBox2(ptr); (*rec) = Box2(point.ToCGAL(), rec->max()); } Point2d Box2_EEK_GetMax(void* ptr) { auto rec = CastToBox2(ptr); return Point2d::FromCGAL(rec->max()); } void Box2_EEK_SetMax(void* ptr, const Point2d& point) { auto rec = CastToBox2(ptr); (*rec) = Box2(rec->min(), point.ToCGAL()); } double Box2_EEK_Area(void* ptr) { auto rec = CastToBox2(ptr); return CGAL::to_double(rec->area()); } CGAL::Bounded_side Box2_EEK_BoundedSide(void* ptr, const Point2d& point) { auto rec = CastToBox2(ptr); auto p = point.ToCGAL(); return rec->bounded_side(p); } BOOL Box2_EEK_ContainsPoint(void* ptr, const Point2d& point, BOOL inculdeBoundary) { auto rec = CastToBox2(ptr); auto side = rec->bounded_side(point.ToCGAL()); if (inculdeBoundary && side == CGAL::Bounded_side::ON_BOUNDARY) return true; return side == CGAL::Bounded_side::ON_BOUNDED_SIDE; } BOOL Box2_EEK_IsDegenerate(void* ptr) { auto rec = CastToBox2(ptr); return rec->is_degenerate(); } void Box2_EEK_Transform(void* ptr, const Point2d& translation, double rotation, double scale) { auto rec = CastToBox2(ptr); Transformation2 T(CGAL::TRANSLATION, translation.ToVector()); Transformation2 R(CGAL::ROTATION, sin(rotation), cos(rotation)); Transformation2 S(CGAL::SCALING, scale); (*rec) = rec->transform(T * R * S); } void* Box2_EEK_Copy(void* ptr) { auto rec = CastToBox2(ptr); auto nrec = NewBox2(); (*nrec) = *rec; return nrec; } template static void* Convert(Box2* rec) { CGAL::Cartesian_converter convert; auto min = convert(rec->min()); auto max = convert(rec->max()); return new CGAL::Iso_rectangle_2(min, max); } void* Box2_EEK_Convert(void* ptr, CGAL_KERNEL k) { auto rec = CastToBox2(ptr); switch (k) { case CGAL_KERNEL::EXACT_PREDICATES_INEXACT_CONSTRUCTION: return Convert(rec); case CGAL_KERNEL::EXACT_PREDICATES_EXACT_CONSTRUCTION: return Convert(rec); default: return Convert(rec); } } ================================================ FILE: CGALWrapper/Geometry/Box2_EEK.h ================================================ #pragma once #include "../CGALWrapper.h" #include "../Geometry/Geometry2.h" #include extern "C" { CGALWRAPPER_API void* Box2_EEK_Create(const Point2d& min, const Point2d& max); CGALWRAPPER_API void Box2_EEK_Release(void* ptr); CGALWRAPPER_API void* Box2_EEK_Copy(void* ptr); CGALWRAPPER_API Point2d Box2_EEK_GetMin(void* ptr); CGALWRAPPER_API void Box2_EEK_SetMin(void* ptr, const Point2d& point); CGALWRAPPER_API Point2d Box2_EEK_GetMax(void* ptr); CGALWRAPPER_API void Box2_EEK_SetMax(void* ptr, const Point2d& point); CGALWRAPPER_API double Box2_EEK_Area(void* ptr); CGALWRAPPER_API CGAL::Bounded_side Box2_EEK_BoundedSide(void* ptr, const Point2d& point); CGALWRAPPER_API BOOL Box2_EEK_ContainsPoint(void* ptr, const Point2d& point, BOOL inculdeBoundary); CGALWRAPPER_API BOOL Box2_EEK_IsDegenerate(void* ptr); CGALWRAPPER_API void Box2_EEK_Transform(void* ptr, const Point2d& translation, double rotation, double scale); CGALWRAPPER_API void* Box2_EEK_Convert(void* ptr, CGAL_KERNEL k); } ================================================ FILE: CGALWrapper/Geometry/Box2_EIK.cpp ================================================ #include "Box2_EIK.h" #include #include #include typedef CGAL::Iso_rectangle_2 Box2; typedef CGAL::Aff_transformation_2 Transformation2; void* Box2_EIK_Create(const Point2d& min, const Point2d& max) { auto _min = min.ToCGAL(); auto _max = max.ToCGAL(); return new Box2(_min, _max); } void Box2_EIK_Release(void* ptr) { auto obj = static_cast(ptr); if (obj != nullptr) { delete obj; obj = nullptr; } } Box2* CastToBox2(void* ptr) { return static_cast(ptr); } Box2* NewBox2() { return new Box2(); } Point2d Box2_EIK_GetMin(void* ptr) { auto rec = CastToBox2(ptr); return Point2d::FromCGAL(rec->min()); } void Box2_EIK_SetMin(void* ptr, const Point2d& point) { auto rec = CastToBox2(ptr); (*rec) = Box2(point.ToCGAL(), rec->max()); } Point2d Box2_EIK_GetMax(void* ptr) { auto rec = CastToBox2(ptr); return Point2d::FromCGAL(rec->max()); } void Box2_EIK_SetMax(void* ptr, const Point2d& point) { auto rec = CastToBox2(ptr); (*rec) = Box2(rec->min(), point.ToCGAL()); } double Box2_EIK_Area(void* ptr) { auto rec = CastToBox2(ptr); return CGAL::to_double(rec->area()); } CGAL::Bounded_side Box2_EIK_BoundedSide(void* ptr, const Point2d& point) { auto rec = CastToBox2(ptr); auto p = point.ToCGAL(); return rec->bounded_side(p); } BOOL Box2_EIK_ContainsPoint(void* ptr, const Point2d& point, BOOL inculdeBoundary) { auto rec = CastToBox2(ptr); auto side = rec->bounded_side(point.ToCGAL()); if (inculdeBoundary && side == CGAL::Bounded_side::ON_BOUNDARY) return true; return side == CGAL::Bounded_side::ON_BOUNDED_SIDE; } BOOL Box2_EIK_IsDegenerate(void* ptr) { auto rec = CastToBox2(ptr); return rec->is_degenerate(); } void Box2_EIK_Transform(void* ptr, const Point2d& translation, double rotation, double scale) { auto rec = CastToBox2(ptr); Transformation2 T(CGAL::TRANSLATION, translation.ToVector()); Transformation2 R(CGAL::ROTATION, sin(rotation), cos(rotation)); Transformation2 S(CGAL::SCALING, scale); (*rec) = rec->transform(T * R * S); } void* Box2_EIK_Copy(void* ptr) { auto rec = CastToBox2(ptr); auto nrec = NewBox2(); (*nrec) = *rec; return nrec; } template static void* Convert(Box2* rec) { CGAL::Cartesian_converter convert; auto min = convert(rec->min()); auto max = convert(rec->max()); return new CGAL::Iso_rectangle_2(min, max); } void* Box2_EIK_Convert(void* ptr, CGAL_KERNEL k) { auto rec = CastToBox2(ptr); switch (k) { case CGAL_KERNEL::EXACT_PREDICATES_INEXACT_CONSTRUCTION: return Convert(rec); case CGAL_KERNEL::EXACT_PREDICATES_EXACT_CONSTRUCTION: return Convert(rec); default: return Convert(rec); } } ================================================ FILE: CGALWrapper/Geometry/Box2_EIK.h ================================================ #pragma once #include "../CGALWrapper.h" #include "../Geometry/Geometry2.h" #include extern "C" { CGALWRAPPER_API void* Box2_EIK_Create(const Point2d& min, const Point2d& max); CGALWRAPPER_API void Box2_EIK_Release(void* ptr); CGALWRAPPER_API void* Box2_EIK_Copy(void* ptr); CGALWRAPPER_API Point2d Box2_EIK_GetMin(void* ptr); CGALWRAPPER_API void Box2_EIK_SetMin(void* ptr, const Point2d& point); CGALWRAPPER_API Point2d Box2_EIK_GetMax(void* ptr); CGALWRAPPER_API void Box2_EIK_SetMax(void* ptr, const Point2d& point); CGALWRAPPER_API double Box2_EIK_Area(void* ptr); CGALWRAPPER_API CGAL::Bounded_side Box2_EIK_BoundedSide(void* ptr, const Point2d& point); CGALWRAPPER_API BOOL Box2_EIK_ContainsPoint(void* ptr, const Point2d& point, BOOL inculdeBoundary); CGALWRAPPER_API BOOL Box2_EIK_IsDegenerate(void* ptr); CGALWRAPPER_API void Box2_EIK_Transform(void* ptr, const Point2d& translation, double rotation, double scale); CGALWRAPPER_API void* Box2_EIK_Convert(void* ptr, CGAL_KERNEL k); } ================================================ FILE: CGALWrapper/Geometry/Geometry2.h ================================================ #pragma once #include "../CGALWrapper.h" #include "CGAL/Point_2.h" #include "CGAL/Point_3.h" #include "CGAL/Vector_2.h" #include "CGAL/Segment_2.h" #include /* * Structs to pass data from C# and c++. * Must be c style layout. * * A standard-layout class is a class that: * * Has no non-static data members of type non-standard-layout class (or array of such types) or reference, * Has no virtual functions and no virtual base classes, * Has the same access control for all non-static data members, * Has no non-standard-layout base classes, * Either has no non-static data members in the most derived class and at most one base class with non-static data members, * or has no base classes with non-static data members, and * Has no base classes of the same type as the first non-static data member. * */ struct Point2d { double x; double y; template CGAL::Point_2 ToCGAL() const { return CGAL::Point_2(x, y); } template CGAL::Point_3 ToCGAL3() const { return CGAL::Point_3(x, y, 0); } template CGAL::Point_3 ToCGAL3XZ() const { return CGAL::Point_3(x, 0, y); } template static Point2d FromCGAL(CGAL::Point_2 p) { double x = CGAL::to_double(p.x()); double y = CGAL::to_double(p.y()); return { x, y }; } template static Point2d FromCGAL(CGAL::Vector_2 v) { double x = CGAL::to_double(v.x()); double y = CGAL::to_double(v.y()); return { x, y }; } template CGAL::Vector_2 ToVector() const { return CGAL::Vector_2(x, y); } bool operator==(const Point2d& rhs) const { return x == rhs.x && y == rhs.y; } bool operator!=(const Point2d& rhs) const { return !operator==(rhs); } Point2d operator+(const Point2d& rhs) const { return { x + rhs.x , y + rhs.y}; } Point2d operator-(const Point2d& rhs) const { return { x - rhs.x , y - rhs.y }; } Point2d operator/(double rhs) const { return { x / rhs , y / rhs }; } Point2d operator*(double rhs) const { return { x * rhs , y * rhs }; } friend std::ostream& operator<<(std::ostream& output, const Point2d& rhs) { output << "(" << rhs.x << ", " << rhs.y << ")"; return output; } }; //used to represent a weighted or homogenous point. struct HPoint2d { double hx; double hy; double hw; template CGAL::Weighted_point_2 ToCGALWeightedPoint() const { return CGAL::Weighted_point_2(CGAL::Point_2(hx, hy), hw); } template static HPoint2d FromCGAL(CGAL::Weighted_point_2 p) { double x = CGAL::to_double(p.hx()); double y = CGAL::to_double(p.hy()); double w = CGAL::to_double(p.hw()); return { x, y, w }; } bool operator==(const HPoint2d& rhs) const { return hx == rhs.hx && hy == rhs.hy && hw == rhs.hw; } bool operator!=(const HPoint2d& rhs) const { return !operator==(rhs); } HPoint2d operator+(const HPoint2d& rhs) const { return { hx + rhs.hx , hy + rhs.hy, hw + rhs.hw }; } HPoint2d operator-(const HPoint2d& rhs) const { return { hx - rhs.hx , hy - rhs.hy, hw - rhs.hw }; } HPoint2d operator/(double rhs) const { return { hx / rhs , hy / rhs, hw / rhs }; } HPoint2d operator*(double rhs) const { return { hx * rhs , hy * rhs, hw * rhs }; } friend std::ostream& operator<<(std::ostream& output, const HPoint2d& rhs) { output << "(" << rhs.hx << ", " << rhs.hy << ", " << rhs.hw << ")"; return output; } }; struct Vector2d { double x; double y; template CGAL::Vector_2 ToCGAL() const { return CGAL::Vector_2(x, y); } template static Vector2d FromCGAL(CGAL::Vector_2 p) { double x = CGAL::to_double(p.x()); double y = CGAL::to_double(p.y()); return { x, y }; } template CGAL::Point_2 ToPoint() const { return CGAL::Point_2(x, y); } bool operator==(const Vector2d& rhs) const { return x == rhs.x && y == rhs.y; } bool operator!=(const Vector2d& rhs) const { return !operator==(rhs); } friend std::ostream& operator<<(std::ostream& output, const Vector2d& rhs) { output << "(" << rhs.x << ", " << rhs.y << ")"; return output; } }; struct Segment2d { Point2d a; Point2d b; template SEG ToCGAL() const { return { a.ToCGAL(), b.ToCGAL() }; } template static Segment2d FromCGAL(CGAL::Point_2 a, CGAL::Point_2 b) { auto A = Point2d::FromCGAL(a); auto B = Point2d::FromCGAL(b); return { A, B }; } template static Segment2d FromCGAL(CGAL::Segment_2 seg) { auto A = Point2d::FromCGAL(seg.source()); auto B = Point2d::FromCGAL(seg.target()); return { A, B }; } }; struct Line2d { double a, b, c; template LINE ToCGAL() const { return { a, b, c }; } template static Line2d FromCGAL(K a, K b, K c) { double A = CGAL::to_double(a); double B = CGAL::to_double(b); double C = CGAL::to_double(c); return { A, B, C }; } }; struct Triangle2d { Point2d a; Point2d b; Point2d c; template TRI ToCGAL() const { return { a.ToCGAL(), b.ToCGAL(), c.ToCGAL() }; } template static Triangle2d FromCGAL(CGAL::Point_2 a, CGAL::Point_2 b, CGAL::Point_2 c) { auto A = Point2d::FromCGAL(a); auto B = Point2d::FromCGAL(b); auto C = Point2d::FromCGAL(c); return { A, B, C }; } }; struct Ray2d { Point2d pos; Vector2d dir; template RAY ToCGAL() const { return { pos.ToCGAL(), dir.ToCGAL() }; } template static Ray2d FromCGAL(CGAL::Point_2 pos, CGAL::Vector_2 dir) { auto Pos = Point2d::FromCGAL(pos); auto Dir = Vector2d::FromCGAL(dir); return { Pos, Dir }; } }; struct Box2d { Point2d min; Point2d max; template BOX ToCGAL() const { return { min.ToCGAL(), max.ToCGAL() }; } template static Box2d FromCGAL(CGAL::Point_2 min, CGAL::Point_2 max) { auto Min = Point2d::FromCGAL(min); auto Max = Point2d::FromCGAL(max); return { Min, Max }; } template static Box2d FromCGAL(CGAL::Bbox_2 box) { double xmin = CGAL::to_double(box.xmin()); double ymin = CGAL::to_double(box.ymin()); double xmax = CGAL::to_double(box.xmax()); double ymax = CGAL::to_double(box.ymax()); Point2d min = { xmin, ymin }; Point2d max = { xmax, ymax }; return { min, max }; } }; struct Circle2d { Point2d center; double radius; }; ================================================ FILE: CGALWrapper/Geometry/Geometry3.h ================================================ #pragma once #include "../CGALWrapper.h" #include "CGAL/Point_3.h" #include "CGAL/Vector_3.h" #include #include #include #include #include /* * Structs to pass data from C# and c++. * Must be c style layout. * * A standard-layout class is a class that: * * Has no non-static data members of type non-standard-layout class (or array of such types) or reference, * Has no virtual functions and no virtual base classes, * Has the same access control for all non-static data members, * Has no non-standard-layout base classes, * Either has no non-static data members in the most derived class and at most one base class with non-static data members, * or has no base classes with non-static data members, and * Has no base classes of the same type as the first non-static data member. * */ struct Point3d { double x; double y; double z; template CGAL::Point_3 ToCGAL() const { return CGAL::Point_3(x, y, z); } template CGAL::Weighted_point_3 ToCGALWeightedPoint() const { return CGAL::Weighted_point_3(CGAL::Point_3(x, y, z), 1); } template static Point3d FromCGAL(CGAL::Point_3 p) { double x = CGAL::to_double(p.x()); double y = CGAL::to_double(p.y()); double z = CGAL::to_double(p.z()); return { x, y, z }; } template static Point3d FromCGAL(CGAL::Point_2 p) { double x = CGAL::to_double(p.x()); double y = CGAL::to_double(p.y()); double z = 0; return { x, y, z }; } template static Point3d FromCGAL(CGAL::Vector_3 v) { double x = CGAL::to_double(v.x()); double y = CGAL::to_double(v.y()); double z = CGAL::to_double(v.z()); return { x, y, z }; } template CGAL::Vector_3 ToVector() const { return CGAL::Vector_3(x, y, z); } bool operator==(const Point3d& rhs) const { return x == rhs.x && y == rhs.y && z == rhs.z; } bool operator!=(const Point3d& rhs) const { return !operator==(rhs); } Point3d operator+(const Point3d& rhs) const { return { x + rhs.x , y + rhs.y, z + rhs.z }; } Point3d operator-(const Point3d& rhs) const { return { x - rhs.x , y - rhs.y, z - rhs.z }; } Point3d operator/(double rhs) const { return { x / rhs , y / rhs, z / rhs }; } Point3d operator*(double rhs) const { return { x * rhs , y * rhs, z * rhs }; } friend std::ostream& operator<<(std::ostream& output, const Point3d& rhs) { output << "(" << rhs.x << ", " << rhs.y << ", " << rhs.z << ")"; return output; } }; //used to represent a weighted or homogenous point. struct HPoint3d { double hx; double hy; double hz; double hw; template CGAL::Weighted_point_3 ToCGALWeightedPoint() const { return CGAL::Weighted_point_3(CGAL::Point_3(hx, hy, hz), hw); } template static HPoint3d FromCGAL(CGAL::Weighted_point_3 p) { double hx = CGAL::to_double(p.hx()); double hy = CGAL::to_double(p.hy()); double hz = CGAL::to_double(p.hz()); double hw = CGAL::to_double(p.hw()); return { hx, hy, hz, hw }; } bool operator==(const HPoint3d& rhs) const { return hx == rhs.hx && hy == rhs.hy && hz == rhs.hz && hw == rhs.hw; } bool operator!=(const HPoint3d& rhs) const { return !operator==(rhs); } HPoint3d operator+(const HPoint3d& rhs) const { return { hx + rhs.hx , hy + rhs.hy, hz + rhs.hz, hw + rhs.hw }; } HPoint3d operator-(const HPoint3d& rhs) const { return { hx - rhs.hx , hy - rhs.hy, hz - rhs.hz, hw - rhs.hw }; } HPoint3d operator/(double rhs) const { return { hx / rhs , hy / rhs, hz / rhs, hw / rhs }; } HPoint3d operator*(double rhs) const { return { hx * rhs , hy * rhs, hz * rhs, hw * rhs }; } friend std::ostream& operator<<(std::ostream& output, const HPoint3d& rhs) { output << "(" << rhs.hx << ", " << rhs.hy << ", " << rhs.hz << ", " << rhs.hw << ")"; return output; } }; struct Vector3d { double x; double y; double z; template CGAL::Vector_3 ToCGAL() const { return CGAL::Vector_3(x, y, z); } template static Vector3d FromCGAL(CGAL::Vector_3 p) { double x = CGAL::to_double(p.x()); double y = CGAL::to_double(p.y()); double z = CGAL::to_double(p.z()); return { x, y, z }; } template CGAL::Point_3 ToPoint() const { return CGAL::Point_3(x, y, z); } bool operator==(const Vector3d& rhs) const { return x == rhs.x && y == rhs.y && z == rhs.z; } bool operator!=(const Vector3d& rhs) const { return !operator==(rhs); } friend std::ostream& operator<<(std::ostream& output, const Vector3d& rhs) { output << "(" << rhs.x << ", " << rhs.y << ", " << rhs.z << ")"; return output; } }; struct Segment3d { Point3d a; Point3d b; template SEG ToCGAL() const { return { a.ToCGAL(), b.ToCGAL() }; } template static Segment3d FromCGAL(CGAL::Point_3 a, CGAL::Point_3 b) { auto A = Point3d::FromCGAL(a); auto B = Point3d::FromCGAL(b); return { A, B }; } template static Segment3d FromCGAL(CGAL::Segment_3 seg) { auto A = Point3d::FromCGAL(seg.source()); auto B = Point3d::FromCGAL(seg.target()); return { A, B }; } }; struct Line3d { Point3d position; Vector3d direction; template LINE ToCGAL() const { return { position.ToCGAL(), direction.ToCGAL() }; } template static Line3d FromCGAL(CGAL::Point_3 pos, CGAL::Vector_3 dir) { return { Point3d::FromCGAL(pos), Vector3d::FromCGAL(dir) }; } }; struct TriangleIndex { int a, b, c; }; struct Plane3d { Point3d position; Vector3d direction; template PLANE ToCGAL() const { return { position.ToCGAL(), direction.ToCGAL() }; } template static Plane3d FromCGAL(CGAL::Point_3 pos, CGAL::Vector_3 dir) { return { Point3d::FromCGAL(pos), Vector3d::FromCGAL(dir) }; } }; struct Box3d { Point3d min; Point3d max; template BOX ToCGAL() const { return { min.ToCGAL(), max.ToCGAL() }; } template static Box3d FromCGAL(CGAL::Point_3 min, CGAL::Point_3 max) { auto Min = Point3d::FromCGAL(min); auto Max = Point3d::FromCGAL(max); return { Min, Max }; } template static Box3d FromCGAL(CGAL::Bbox_3 box) { double xmin = CGAL::to_double(box.xmin()); double ymin = CGAL::to_double(box.ymin()); double zmin = CGAL::to_double(box.zmin()); double xmax = CGAL::to_double(box.xmax()); double ymax = CGAL::to_double(box.ymax()); double zmax = CGAL::to_double(box.zmax()); Point3d min = { xmin, ymin, zmin }; Point3d max = { xmax, ymax, zmax }; return { min, max }; } }; struct Ray3d { Point3d position; Vector3d direction; template RAY ToCGAL() const { return { position.ToCGAL(), direction.ToCGAL() }; } template static Ray3d FromCGAL(CGAL::Point_3 pos, CGAL::Vector_3 dir) { return { Point3d::FromCGAL(pos), Vector3d::FromCGAL(dir) }; } }; struct Triangle3d { Point3d a; Point3d b; Point3d c; template TRI ToCGAL() const { return { a.ToCGAL(), b.ToCGAL(), c.ToCGAL() }; } template static Triangle3d FromCGAL(CGAL::Point_3 a, CGAL::Point_3 b, CGAL::Point_3 c) { auto A = Point3d::FromCGAL(a); auto B = Point3d::FromCGAL(b); auto C = Point3d::FromCGAL(c); return { A, B, C }; } template static Triangle3d FromCGAL(CGAL::Triangle_3 tri) { auto A = Point3d::FromCGAL(tri[0]); auto B = Point3d::FromCGAL(tri[1]); auto C = Point3d::FromCGAL(tri[2]); return { A, B, C }; } }; struct Tetahedron3d { Point3d a; Point3d b; Point3d c; Point3d d; template static Tetahedron3d FromCGAL(CGAL::Point_3 a, CGAL::Point_3 b, CGAL::Point_3 c, CGAL::Point_3 d) { auto A = Point3d::FromCGAL(a); auto B = Point3d::FromCGAL(b); auto C = Point3d::FromCGAL(c); auto D = Point3d::FromCGAL(d); return { A, B, C, D }; } }; ================================================ FILE: CGALWrapper/Geometry/HPoint2_EEK.cpp ================================================ #include "HPoint2_EEK.h" #include #include #include typedef CGAL::Weighted_point_2 HPoint2; typedef CGAL::Point_2 Point2; void* HPoint2_EEK_Create() { return new HPoint2(); } void* HPoint2_EEK_CreateFromPoint(const HPoint2d& point) { auto p = point.ToCGALWeightedPoint(); return new HPoint2(p.x(), p.y()); } void HPoint2_EEK_Release(void* ptr) { auto obj = static_cast(ptr); if (obj != nullptr) { delete obj; obj = nullptr; } } HPoint2* CastToHPoint2(void* ptr) { return static_cast(ptr); } double HPoint2_EEK_GetX(void* ptr) { auto p = CastToHPoint2(ptr); return CGAL::to_double(p->hx()); } double HPoint2_EEK_GetY(void* ptr) { auto p = CastToHPoint2(ptr); return CGAL::to_double(p->hy()); } double HPoint2_EEK_GetW(void* ptr) { auto p = CastToHPoint2(ptr); return CGAL::to_double(p->hw()); } void HPoint2_EEK_SetX(void* ptr, double x) { auto p = CastToHPoint2(ptr); (*p) = HPoint2(Point2(x, p->y()), p->hw()); } void HPoint2_EEK_SetY(void* ptr, double y) { auto p = CastToHPoint2(ptr); (*p) = HPoint2(Point2(p->x(), y), p->hw()); } void HPoint2_EEK_SetW(void* ptr, double w) { auto p = CastToHPoint2(ptr); (*p) = HPoint2(Point2(p->x(), p->y()), p->hw()); } void* HPoint2_EEK_Copy(void* ptr) { auto p = CastToHPoint2(ptr); auto p2 = new HPoint2(); (*p2) = *p; return p2; } void* HPoint2_EEK_Convert(void* ptr) { typedef CGAL::Cartesian_converter EEK_to_EIK; EEK_to_EIK convert; auto p = CastToHPoint2(ptr); auto hx = convert((*p)[0]); auto hy = convert((*p)[1]); auto hw = convert((*p)[2]); return new CGAL::Weighted_point_2(CGAL::Point_2(hx, hy), hw); } template static void* Convert(HPoint2* hp) { CGAL::Cartesian_converter convert; auto hx = convert((*hp)[0]); auto hy = convert((*hp)[1]); auto hw = convert((*hp)[2]); auto p = CGAL::Point_2(hx, hy); return new CGAL::Weighted_point_2(p, hw); } void* HPoint2_EEK_Convert(void* ptr, CGAL_KERNEL k) { auto p = CastToHPoint2(ptr); switch (k) { case CGAL_KERNEL::EXACT_PREDICATES_INEXACT_CONSTRUCTION: return Convert(p); case CGAL_KERNEL::EXACT_PREDICATES_EXACT_CONSTRUCTION: return Convert(p); default: return Convert(p); } } ================================================ FILE: CGALWrapper/Geometry/HPoint2_EEK.h ================================================ #pragma once #include "../CGALWrapper.h" #include "../Geometry/Geometry2.h" #include extern "C" { CGALWRAPPER_API void* HPoint2_EEK_Create(); CGALWRAPPER_API void* HPoint2_EEK_CreateFromPoint(const HPoint2d& point); CGALWRAPPER_API void HPoint2_EEK_Release(void* ptr); CGALWRAPPER_API double HPoint2_EEK_GetX(void* ptr); CGALWRAPPER_API double HPoint2_EEK_GetY(void* ptr); CGALWRAPPER_API double HPoint2_EEK_GetW(void* ptr); CGALWRAPPER_API void HPoint2_EEK_SetX(void* ptr, double x); CGALWRAPPER_API void HPoint2_EEK_SetY(void* ptr, double y); CGALWRAPPER_API void HPoint2_EEK_SetW(void* ptr, double y); CGALWRAPPER_API void* HPoint2_EEK_Copy(void* ptr); CGALWRAPPER_API void* HPoint2_EEK_Convert(void* ptr, CGAL_KERNEL k); } ================================================ FILE: CGALWrapper/Geometry/HPoint2_EIK.cpp ================================================ #include "HPoint2_EIK.h" #include #include #include typedef CGAL::Weighted_point_2 HPoint2; typedef CGAL::Point_2 Point2; void* HPoint2_EIK_Create() { return new HPoint2(); } void* HPoint2_EIK_CreateFromPoint(const HPoint2d& point) { auto p = point.ToCGALWeightedPoint(); return new HPoint2(p.x(), p.y()); } void HPoint2_EIK_Release(void* ptr) { auto obj = static_cast(ptr); if (obj != nullptr) { delete obj; obj = nullptr; } } HPoint2* CastToHPoint2(void* ptr) { return static_cast(ptr); } double HPoint2_EIK_GetX(void* ptr) { auto p = CastToHPoint2(ptr); return CGAL::to_double(p->hx()); } double HPoint2_EIK_GetY(void* ptr) { auto p = CastToHPoint2(ptr); return CGAL::to_double(p->hy()); } double HPoint2_EIK_GetW(void* ptr) { auto p = CastToHPoint2(ptr); return CGAL::to_double(p->hw()); } void HPoint2_EIK_SetX(void* ptr, double x) { auto p = CastToHPoint2(ptr); (*p) = HPoint2(Point2(x, p->y()), p->hw()); } void HPoint2_EIK_SetY(void* ptr, double y) { auto p = CastToHPoint2(ptr); (*p) = HPoint2(Point2(p->x(), y), p->hw()); } void HPoint2_EIK_SetW(void* ptr, double w) { auto p = CastToHPoint2(ptr); (*p) = HPoint2(Point2(p->x(), p->y()), p->hw()); } void* HPoint2_EIK_Copy(void* ptr) { auto p = CastToHPoint2(ptr); auto p2 = new HPoint2(); (*p2) = *p; return p2; } template static void* Convert(HPoint2* hp) { CGAL::Cartesian_converter convert; auto hx = convert((*hp)[0]); auto hy = convert((*hp)[1]); auto hw = convert((*hp)[2]); auto p = CGAL::Point_2(hx, hy); return new CGAL::Weighted_point_2(p, hw); } void* HPoint2_EIK_Convert(void* ptr, CGAL_KERNEL k) { auto p = CastToHPoint2(ptr); switch (k) { case CGAL_KERNEL::EXACT_PREDICATES_INEXACT_CONSTRUCTION: return Convert(p); case CGAL_KERNEL::EXACT_PREDICATES_EXACT_CONSTRUCTION: return Convert(p); default: return Convert(p); } } ================================================ FILE: CGALWrapper/Geometry/HPoint2_EIK.h ================================================ #pragma once #include "../CGALWrapper.h" #include "../Geometry/Geometry2.h" #include extern "C" { CGALWRAPPER_API void* HPoint2_EIK_Create(); CGALWRAPPER_API void* HPoint2_EIK_CreateFromPoint(const HPoint2d& point); CGALWRAPPER_API void HPoint2_EIK_Release(void* ptr); CGALWRAPPER_API double HPoint2_EIK_GetX(void* ptr); CGALWRAPPER_API double HPoint2_EIK_GetY(void* ptr); CGALWRAPPER_API double HPoint2_EIK_GetW(void* ptr); CGALWRAPPER_API void HPoint2_EIK_SetX(void* ptr, double x); CGALWRAPPER_API void HPoint2_EIK_SetY(void* ptr, double y); CGALWRAPPER_API void HPoint2_EIK_SetW(void* ptr, double y); CGALWRAPPER_API void* HPoint2_EIK_Copy(void* ptr); CGALWRAPPER_API void* HPoint2_EIK_Convert(void* ptr, CGAL_KERNEL k); } ================================================ FILE: CGALWrapper/Geometry/Index.h ================================================ #pragma once struct Index2 { int first; int second; }; struct Index3 { int first; int second; int third; }; struct Index4 { int first; int second; int third; int fourth; }; ================================================ FILE: CGALWrapper/Geometry/IntersectionResult.h ================================================ #pragma once #include "../CGALWrapper.h" #include "Geometry2.h" #include #include #include #include #include #include #include #include #include enum INTERSECTION_RESULT_2D : int { NONE, POINT2, LINE2, RAY2, SEGMENT2, BOX2, TRIANGLE2, POLYGON2 }; struct IntersectionResult2d { Point2d points[6]; int count; INTERSECTION_RESULT_2D type; }; #ifdef min #undef min #endif //min #ifdef max #undef max #endif //max template class IntersectionResult { typedef CGAL::Point_2 Point2; typedef CGAL::Line_2 Line2; typedef CGAL::Ray_2 Ray2; typedef CGAL::Segment_2 Segment2; typedef CGAL::Triangle_2 Triangle2; typedef CGAL::Iso_rectangle_2 Box2; typedef std::vector Polygon2; public: static IntersectionResult2d ToPoint(CGAL::Object obj) { if (obj == nullptr || obj.is_empty()) return {}; Point2 point; if (assign(point, obj)) { IntersectionResult2d result = {}; result.type = INTERSECTION_RESULT_2D::POINT2; result.count = 1; result.points[0] = Point2d::FromCGAL(point); return result; } return {}; } static IntersectionResult2d ToBox(CGAL::Object obj) { if (obj == nullptr || obj.is_empty()) return {}; Box2 box; if (assign(box, obj)) { IntersectionResult2d result = {}; result.type = INTERSECTION_RESULT_2D::BOX2; result.count = 2; result.points[0] = Point2d::FromCGAL(box.min()); result.points[1] = Point2d::FromCGAL(box.max()); return result; } return {}; } static IntersectionResult2d ToPointOrSegment(CGAL::Object obj) { if (obj == nullptr || obj.is_empty()) return {}; Point2 point; Segment2 seg; if (assign(point, obj)) { IntersectionResult2d result = {}; result.type = INTERSECTION_RESULT_2D::POINT2; result.count = 1; result.points[0] = Point2d::FromCGAL(point); return result; } else if (assign(seg, obj)) { IntersectionResult2d result = {}; result.type = INTERSECTION_RESULT_2D::SEGMENT2; result.count = 2; result.points[0] = Point2d::FromCGAL(seg.source()); result.points[1] = Point2d::FromCGAL(seg.target()); return result; } return {}; } static IntersectionResult2d ToPointSegmentTriangleOrPolygon(CGAL::Object obj) { if (obj == nullptr || obj.is_empty()) return {}; Point2 point; Segment2 seg; Triangle2 tri; Polygon2 polygon; if (assign(point, obj)) { IntersectionResult2d result = {}; result.type = INTERSECTION_RESULT_2D::POINT2; result.count = 1; result.points[0] = Point2d::FromCGAL(point); return result; } else if (assign(seg, obj)) { IntersectionResult2d result = {}; result.type = INTERSECTION_RESULT_2D::SEGMENT2; result.count = 2; result.points[0] = Point2d::FromCGAL(seg.source()); result.points[1] = Point2d::FromCGAL(seg.target()); return result; } else if (assign(tri, obj)) { IntersectionResult2d result = {}; result.type = INTERSECTION_RESULT_2D::TRIANGLE2; result.count = 3; result.points[0] = Point2d::FromCGAL(tri[0]); result.points[1] = Point2d::FromCGAL(tri[1]); result.points[2] = Point2d::FromCGAL(tri[2]); return result; } else if (assign(polygon, obj)) { IntersectionResult2d result = {}; result.type = INTERSECTION_RESULT_2D::POLYGON2; result.count = (int)polygon.size(); for (int i = 0; i < result.count; i++) result.points[i] = Point2d::FromCGAL(polygon[i]); return result; } return {}; } static IntersectionResult2d ToPointOrRay(CGAL::Object obj) { if (obj == nullptr || obj.is_empty()) return {}; Point2 point; Ray2 ray; if (assign(point, obj)) { IntersectionResult2d result = {}; result.type = INTERSECTION_RESULT_2D::POINT2; result.count = 1; result.points[0] = Point2d::FromCGAL(point); return result; } else if (assign(ray, obj)) { IntersectionResult2d result = {}; result.type = INTERSECTION_RESULT_2D::RAY2; result.count = 2; result.points[0] = Point2d::FromCGAL(ray.source()); result.points[1] = Point2d::FromCGAL(ray.to_vector()); return result; } return {}; } static IntersectionResult2d ToPointOrLine(CGAL::Object obj) { if (obj == nullptr || obj.is_empty()) return {}; Point2 point; Line2 line; if (assign(point, obj)) { IntersectionResult2d result = {}; result.type = INTERSECTION_RESULT_2D::POINT2; result.count = 1; result.points[0] = Point2d::FromCGAL(point); return result; } else if (assign(line, obj)) { IntersectionResult2d result = {}; result.type = INTERSECTION_RESULT_2D::LINE2; result.count = 2; result.points[0].x = CGAL::to_double(line.a()); result.points[0].y = CGAL::to_double(line.b()); result.points[1].x = CGAL::to_double(line.c()); return result; } return {}; } static IntersectionResult2d ToPointSegmentOrRay(CGAL::Object obj) { if (obj == nullptr || obj.is_empty()) return {}; Point2 point; Segment2 seg; Ray2 ray; if (assign(point, obj)) { IntersectionResult2d result = {}; result.type = INTERSECTION_RESULT_2D::POINT2; result.count = 1; result.points[0] = Point2d::FromCGAL(point); return result; } else if (assign(seg, obj)) { IntersectionResult2d result = {}; result.type = INTERSECTION_RESULT_2D::SEGMENT2; result.count = 2; result.points[0] = Point2d::FromCGAL(seg.source()); result.points[1] = Point2d::FromCGAL(seg.target()); return result; } else if (assign(ray, obj)) { IntersectionResult2d result = {}; result.type = INTERSECTION_RESULT_2D::RAY2; result.count = 2; result.points[0] = Point2d::FromCGAL(ray.source()); result.points[1] = Point2d::FromCGAL(ray.to_vector()); return result; } return {}; } static IntersectionResult2d ToAny(CGAL::Object obj) { if (obj == nullptr || obj.is_empty()) return {}; Point2 point; Segment2 seg; Line2 line; Ray2 ray; Triangle2 tri; Box2 box; Polygon2 polygon; if (assign(point, obj)) { IntersectionResult2d result = {}; result.type = INTERSECTION_RESULT_2D::POINT2; result.count = 1; result.points[0] = Point2d::FromCGAL(point); return result; } else if (assign(seg, obj)) { IntersectionResult2d result = {}; result.type = INTERSECTION_RESULT_2D::SEGMENT2; result.count = 2; result.points[0] = Point2d::FromCGAL(seg.source()); result.points[1] = Point2d::FromCGAL(seg.target()); return result; } else if (assign(line, obj)) { IntersectionResult2d result = {}; result.type = INTERSECTION_RESULT_2D::LINE2; result.count = 2; result.points[0].x = CGAL::to_double(line.a()); result.points[0].y = CGAL::to_double(line.b()); result.points[1].x = CGAL::to_double(line.c()); return result; } else if (assign(ray, obj)) { IntersectionResult2d result = {}; result.type = INTERSECTION_RESULT_2D::RAY2; result.count = 2; result.points[0] = Point2d::FromCGAL(ray.source()); result.points[1] = Point2d::FromCGAL(ray.to_vector()); return result; } else if (assign(tri, obj)) { IntersectionResult2d result = {}; result.type = INTERSECTION_RESULT_2D::TRIANGLE2; result.count = 3; result.points[0] = Point2d::FromCGAL(tri[0]); result.points[1] = Point2d::FromCGAL(tri[1]); result.points[2] = Point2d::FromCGAL(tri[2]); return result; } else if (assign(box, obj)) { IntersectionResult2d result = {}; result.type = INTERSECTION_RESULT_2D::BOX2; result.count = 2; result.points[0] = Point2d::FromCGAL(box.min()); result.points[1] = Point2d::FromCGAL(box.max()); return result; } else if (assign(polygon, obj)) { IntersectionResult2d result = {}; result.type = INTERSECTION_RESULT_2D::POLYGON2; result.count = (int)polygon.size(); for (int i = 0; i < result.count; i++) result.points[i] = Point2d::FromCGAL(polygon[i]); return result; } return {}; } }; ================================================ FILE: CGALWrapper/Geometry/Intersections_geometry.h ================================================ #pragma once #include "../CGALWrapper.h" #include "Geometry2.h" #include "IntersectionResult.h" #include #include #include #include #include #include #include #include #include template class Intersections_Geometry { public: typedef CGAL::Point_2 Point2; typedef CGAL::Line_2 Line2; typedef CGAL::Ray_2 Ray2; typedef CGAL::Segment_2 Segment2; typedef CGAL::Triangle_2 Triangle2; typedef CGAL::Iso_rectangle_2 Box2; typedef std::vector Polygon2; /***************************************************** * * * Geometry Casting Functions * * * ******************************************************/ inline static Point2* CastToPoint2(void* ptr) { return static_cast(ptr); } inline static Line2* CastToLine2(void* ptr) { return static_cast(ptr); } inline static Ray2* CastToRay2(void* ptr) { return static_cast(ptr); } inline static Segment2* CastToSegment2(void* ptr) { return static_cast(ptr); } inline static Triangle2* CastToTriangle2(void* ptr) { return static_cast(ptr); } inline static Box2* CastToBox2(void* ptr) { return static_cast(ptr); } /***************************************************** * * * Point2 DoIntersect Functions * * * ******************************************************/ static BOOL DoIntersect_PointLine(void* point, void* line) { auto p = CastToPoint2(point); auto l = CastToLine2(line); return CGAL::do_intersect(*p, *l); } static BOOL DoIntersect_PointRay(void* point, void* ray) { auto p = CastToPoint2(point); auto r = CastToRay2(ray); return CGAL::do_intersect(*p, *r); } static BOOL DoIntersect_PointSegment(void* point, void* seg) { auto p = CastToPoint2(point); auto s = CastToSegment2(seg); return CGAL::do_intersect(*p, *s); } static BOOL DoIntersect_PointTriangle(void* point, void* tri) { auto p = CastToPoint2(point); auto t = CastToTriangle2(tri); return CGAL::do_intersect(*p, *t); } static BOOL DoIntersect_PointBox(void* point, void* box) { auto p = CastToPoint2(point); auto b = CastToBox2(box); return CGAL::do_intersect(*p, *b); } /***************************************************** * * * Line2 DoIntersect Functions * * * ******************************************************/ static BOOL DoIntersect_LinePoint(void* line, void* point) { auto p = CastToPoint2(point); auto l = CastToLine2(line); return CGAL::do_intersect(*p, *l); } static BOOL DoIntersect_LineLine(void* line, void* line2) { auto l = CastToLine2(line); auto l2 = CastToLine2(line2); return CGAL::do_intersect(*l, *l2); } static BOOL DoIntersect_LineRay(void* line, void* ray) { auto l = CastToLine2(line); auto r = CastToRay2(ray); return CGAL::do_intersect(*l, *r); } static BOOL DoIntersect_LineSegment(void* line, void* segment) { auto l = CastToLine2(line); auto s = CastToSegment2(segment); return CGAL::do_intersect(*l, *s); } static BOOL DoIntersect_LineTriangle(void* line, void* triangle) { auto l = CastToLine2(line); auto t = CastToTriangle2(triangle); return CGAL::do_intersect(*l, *t); } static BOOL DoIntersect_LineBox(void* line, void* box) { auto l = CastToLine2(line); auto b = CastToBox2(box); return CGAL::do_intersect(*l, *b); } /***************************************************** * * * Ray2 DoIntersect Functions * * * ******************************************************/ static BOOL DoIntersect_RayPoint(void* ray, void* point) { auto r = CastToRay2(ray); auto p = CastToPoint2(point); return CGAL::do_intersect(*r, *p); } static BOOL DoIntersect_RayLine(void* ray, void* line) { auto r = CastToRay2(ray); auto l = CastToLine2(line); return CGAL::do_intersect(*r, *l); } static BOOL DoIntersect_RayRay(void* ray, void* ray2) { auto r = CastToRay2(ray); auto r2 = CastToRay2(ray2); return CGAL::do_intersect(*r, *r2); } static BOOL DoIntersect_RaySegment(void* ray, void* segment) { auto r = CastToRay2(ray); auto s = CastToSegment2(segment); return CGAL::do_intersect(*r, *s); } static BOOL DoIntersect_RayTriangle(void* ray, void* triangle) { auto r = CastToRay2(ray); auto t = CastToTriangle2(triangle); return CGAL::do_intersect(*r, *t); } static BOOL DoIntersect_RayBox(void* ray, void* box) { auto r = CastToRay2(ray); auto b = CastToBox2(box); return CGAL::do_intersect(*r, *b); } /***************************************************** * * * Segment2 DoIntersect Functions * * * ******************************************************/ static BOOL DoIntersect_SegmentPoint(void* segment, void* point) { auto s = CastToSegment2(segment); auto p = CastToPoint2(point); return CGAL::do_intersect(*s, *p); } static BOOL DoIntersect_SegmentLine(void* segment, void* line) { auto s = CastToSegment2(segment); auto l = CastToLine2(line); return CGAL::do_intersect(*s, *l); } static BOOL DoIntersect_SegmentRay(void* segment, void* ray) { auto s = CastToSegment2(segment); auto r = CastToRay2(ray); return CGAL::do_intersect(*s, *r); } static BOOL DoIntersect_SegmentSegment(void* segment, void* segment2) { auto s = CastToSegment2(segment); auto s2 = CastToSegment2(segment2); return CGAL::do_intersect(*s, *s2); } static BOOL DoIntersect_SegmentTriangle(void* segment, void* triangle) { auto s = CastToSegment2(segment); auto t = CastToTriangle2(triangle); return CGAL::do_intersect(*s, *t); } static BOOL DoIntersect_SegmentBox(void* segment, void* box) { auto s = CastToSegment2(segment); auto b = CastToBox2(box); return CGAL::do_intersect(*s, *b); } /***************************************************** * * * Triangle2 DoIntersect Functions * * * ******************************************************/ static BOOL DoIntersect_TrianglePoint(void* triangle, void* point) { auto t = CastToTriangle2(triangle); auto p = CastToPoint2(point); return CGAL::do_intersect(*t, *p); } static BOOL DoIntersect_TriangleLine(void* triangle, void* line) { auto t = CastToTriangle2(triangle); auto l = CastToLine2(line); return CGAL::do_intersect(*t, *l); } static BOOL DoIntersect_TriangleRay(void* triangle, void* ray) { auto t = CastToTriangle2(triangle); auto r = CastToRay2(ray); return CGAL::do_intersect(*t, *r); } static BOOL DoIntersect_TriangleSegment(void* triangle, void* segment) { auto t = CastToTriangle2(triangle); auto s = CastToSegment2(segment); return CGAL::do_intersect(*t, *s); } static BOOL DoIntersect_TriangleTriangle(void* triangle, void* triangle2) { auto t = CastToTriangle2(triangle); auto t2 = CastToTriangle2(triangle2); return CGAL::do_intersect(*t, *t2); } static BOOL DoIntersect_TriangleBox(void* triangle, void* box) { auto t = CastToTriangle2(triangle); auto b = CastToBox2(box); return CGAL::do_intersect(*t, *b); } /***************************************************** * * * Box2 DoIntersect Functions * * * ******************************************************/ static BOOL DoIntersect_BoxPoint(void* box, void* point) { auto b = CastToBox2(box); auto p = CastToPoint2(point); return CGAL::do_intersect(*b, *p); } static BOOL DoIntersect_BoxLine(void* box, void* line) { auto b = CastToBox2(box); auto l = CastToLine2(line); return CGAL::do_intersect(*b, *l); } static BOOL DoIntersect_BoxRay(void* box, void* ray) { auto b = CastToBox2(box); auto r = CastToRay2(ray); return CGAL::do_intersect(*b, *r); } static BOOL DoIntersect_BoxSegment(void* box, void* segment) { auto b = CastToBox2(box); auto s = CastToSegment2(segment); return CGAL::do_intersect(*b, *s); } static BOOL DoIntersect_BoxTriangle(void* box, void* triangle) { auto b = CastToBox2(box); auto t = CastToTriangle2(triangle); return CGAL::do_intersect(*b, *t); } static BOOL DoIntersect_BoxBox(void* box, void* box2) { auto b = CastToBox2(box); auto b2 = CastToBox2(box2); return CGAL::do_intersect(*b, *b2); } /***************************************************** * * * Point2 Intersection Functions * * * ******************************************************/ static IntersectionResult2d Intersection_PointLine(void* point, void* line) { auto p = CastToPoint2(point); auto l = CastToLine2(line); return IntersectionResult::ToPoint(CGAL::intersection(*p, *l)); } static IntersectionResult2d Intersection_PointRay(void* point, void* ray) { auto p = CastToPoint2(point); auto r = CastToRay2(ray); return IntersectionResult::ToPoint(CGAL::intersection(*p, *r)); } static IntersectionResult2d Intersection_PointSegment(void* point, void* segment) { auto p = CastToPoint2(point); auto s = CastToSegment2(segment); return IntersectionResult::ToPoint(CGAL::intersection(*p, *s)); } static IntersectionResult2d Intersection_PointTriangle(void* point, void* triangle) { auto p = CastToPoint2(point); auto t = CastToTriangle2(triangle); return IntersectionResult::ToPoint(CGAL::intersection(*p, *t)); } static IntersectionResult2d Intersection_PointBox(void* point, void* box) { auto p = CastToPoint2(point); auto b = CastToBox2(box); return IntersectionResult::ToPoint(CGAL::intersection(*p, *b)); } /***************************************************** * * * Line2 Intersection Functions * * * ******************************************************/ static IntersectionResult2d Intersection_LinePoint(void* line, void* point) { auto p = CastToPoint2(point); auto l = CastToLine2(line); return IntersectionResult::ToPoint(CGAL::intersection(*p, *l)); } static IntersectionResult2d Intersection_LineLine(void* line, void* line2) { auto l = CastToLine2(line); auto l2 = CastToLine2(line2); return IntersectionResult::ToPointOrLine(CGAL::intersection(*l, *l2)); } static IntersectionResult2d Intersection_LineRay(void* line, void* ray) { auto l = CastToLine2(line); auto r = CastToRay2(ray); return IntersectionResult::ToPointOrRay(CGAL::intersection(*l, *r)); } static IntersectionResult2d Intersection_LineSegment(void* line, void* segment) { auto l = CastToLine2(line); auto s = CastToSegment2(segment); return IntersectionResult::ToPointOrSegment(CGAL::intersection(*l, *s)); } static IntersectionResult2d Intersection_LineTriangle(void* line, void* triangle) { auto l = CastToLine2(line); auto t = CastToTriangle2(triangle); return IntersectionResult::ToPointOrSegment(CGAL::intersection(*l, *t)); } static IntersectionResult2d Intersection_LineBox(void* line, void* box) { auto l = CastToLine2(line); auto b = CastToBox2(box); return IntersectionResult::ToPointOrSegment(CGAL::intersection(*l, *b)); } /***************************************************** * * * Ray2 Intersection Functions * * * ******************************************************/ static IntersectionResult2d Intersection_RayPoint(void* ray, void* point) { auto r = CastToRay2(ray); auto p = CastToPoint2(point); return IntersectionResult::ToPoint(CGAL::intersection(*r, *p)); } static IntersectionResult2d Intersection_RayLine(void* ray, void* line) { auto r = CastToRay2(ray); auto l = CastToLine2(line); return IntersectionResult::ToPointOrRay(CGAL::intersection(*r, *l)); } static IntersectionResult2d Intersection_RayRay(void* ray, void* ray2) { auto r = CastToRay2(ray); auto r2 = CastToRay2(ray2); return IntersectionResult::ToPointSegmentOrRay(CGAL::intersection(*r, *r2)); } static IntersectionResult2d Intersection_RaySegment(void* ray, void* segment) { auto r = CastToRay2(ray); auto s = CastToSegment2(segment); return IntersectionResult::ToPointOrSegment(CGAL::intersection(*r, *s)); } static IntersectionResult2d Intersection_RayTriangle(void* ray, void* triangle) { auto r = CastToRay2(ray); auto t = CastToTriangle2(triangle); return IntersectionResult::ToPointOrSegment(CGAL::intersection(*r, *t)); } static IntersectionResult2d Intersection_RayBox(void* ray, void* box) { auto r = CastToRay2(ray); auto b = CastToBox2(box); return IntersectionResult::ToPointOrSegment(CGAL::intersection(*r, *b)); } /***************************************************** * * * Segment2 Intersection Functions * * * ******************************************************/ static IntersectionResult2d Intersection_SegmentPoint(void* segment, void* point) { auto s = CastToSegment2(segment); auto p = CastToPoint2(point); return IntersectionResult::ToPoint(CGAL::intersection(*s, *p)); } static IntersectionResult2d Intersection_SegmentLine(void* segment, void* line) { auto s = CastToSegment2(segment); auto l = CastToLine2(line); return IntersectionResult::ToPointOrSegment(CGAL::intersection(*s, *l)); } static IntersectionResult2d Intersection_SegmentRay(void* segment, void* ray) { auto s = CastToSegment2(segment); auto r = CastToRay2(ray); return IntersectionResult::ToPointOrSegment(CGAL::intersection(*s, *r)); } static IntersectionResult2d Intersection_SegmentSegment(void* segment, void* segment2) { auto s = CastToSegment2(segment); auto s2 = CastToSegment2(segment2); return IntersectionResult::ToPointOrSegment(CGAL::intersection(*s, *s2)); } static IntersectionResult2d Intersection_SegmentTriangle(void* segment, void* triangle) { auto s = CastToSegment2(segment); auto t = CastToTriangle2(triangle); return IntersectionResult::ToPointOrSegment(CGAL::intersection(*s, *t)); } static IntersectionResult2d Intersection_SegmentBox(void* segment, void* box) { auto s = CastToSegment2(segment); auto b = CastToBox2(box); return IntersectionResult::ToPointOrSegment(CGAL::intersection(*s, *b)); } /***************************************************** * * * Triangle2 Intersection Functions * * * ******************************************************/ static IntersectionResult2d Intersection_TrianglePoint(void* triangle, void* point) { auto t = CastToTriangle2(triangle); auto p = CastToPoint2(point); return IntersectionResult::ToPoint(CGAL::intersection(*t, *p)); } static IntersectionResult2d Intersection_TriangleLine(void* triangle, void* line) { auto t = CastToTriangle2(triangle); auto l = CastToLine2(line); return IntersectionResult::ToPointOrSegment(CGAL::intersection(*t, *l)); } static IntersectionResult2d Intersection_TriangleRay(void* triangle, void* ray) { auto t = CastToTriangle2(triangle); auto r = CastToRay2(ray); return IntersectionResult::ToPointOrSegment(CGAL::intersection(*t, *r)); } static IntersectionResult2d Intersection_TriangleSegment(void* triangle, void* segment) { auto t = CastToTriangle2(triangle); auto s = CastToSegment2(segment); return IntersectionResult::ToPointOrSegment(CGAL::intersection(*t, *s)); } static IntersectionResult2d Intersection_TriangleTriangle(void* triangle, void* triangle2) { auto t = CastToTriangle2(triangle); auto t2 = CastToTriangle2(triangle2); return IntersectionResult::ToPointSegmentTriangleOrPolygon(CGAL::intersection(*t, *t2)); } static IntersectionResult2d Intersection_TriangleBox(void* triangle, void* box) { auto t = CastToTriangle2(triangle); auto b = CastToBox2(box); return IntersectionResult::ToPointSegmentTriangleOrPolygon(CGAL::intersection(*t, *b)); } /***************************************************** * * * Box2 Intersection Functions * * * ******************************************************/ static IntersectionResult2d Intersection_BoxPoint(void* box, void* point) { auto b = CastToBox2(box); auto p = CastToPoint2(point); return IntersectionResult::ToPoint(CGAL::intersection(*b, *p)); } static IntersectionResult2d Intersection_BoxLine(void* box, void* line) { auto b = CastToBox2(box);; auto l = CastToLine2(line); return IntersectionResult::ToPointOrSegment(CGAL::intersection(*b, *l)); } static IntersectionResult2d Intersection_BoxRay(void* box, void* ray) { auto b = CastToBox2(box); auto r = CastToRay2(ray); return IntersectionResult::ToPointOrSegment(CGAL::intersection(*b, *r)); } static IntersectionResult2d Intersection_BoxSegment(void* box, void* segment) { auto b = CastToBox2(box); auto s = CastToSegment2(segment); return IntersectionResult::ToPointOrSegment(CGAL::intersection(*b, *s)); } static IntersectionResult2d Intersection_BoxTriangle(void* box, void* triangle) { auto b = CastToBox2(box); auto t = CastToTriangle2(triangle); return IntersectionResult::ToPointSegmentTriangleOrPolygon(CGAL::intersection(*b, *t)); } static IntersectionResult2d Intersection_BoxBox(void* box, void* box2) { auto b = CastToBox2(box); auto b2 = CastToBox2(box2); return IntersectionResult::ToBox(CGAL::intersection(*b, *b2)); } /***************************************************** * * * Point2 SqrDistance Functions * * * ******************************************************/ static double SqrDistance_PointPoint(void* point, void* point2) { auto p = CastToPoint2(point); auto p2 = CastToPoint2(point2); return CGAL::to_double(CGAL::squared_distance(*p, *p2)); } static double SqrDistance_PointLine(void* point, void* line) { auto p = CastToPoint2(point); auto l = CastToLine2(line); return CGAL::to_double(CGAL::squared_distance(*p, *l)); } static double SqrDistance_PointRay(void* point, void* ray) { auto p = CastToPoint2(point); auto r = CastToRay2(ray); return CGAL::to_double(CGAL::squared_distance(*p, *r)); } static double SqrDistance_PointSegment(void* point, void* segment) { auto p = CastToPoint2(point); auto s = CastToSegment2(segment); return CGAL::to_double(CGAL::squared_distance(*p, *s)); } static double SqrDistance_PointTriangle(void* point, void* triangle) { auto p = CastToPoint2(point); auto t = CastToTriangle2(triangle); return CGAL::to_double(CGAL::squared_distance(*p, *t)); } /***************************************************** * * * Line2 SqrDistance Functions * * * ******************************************************/ static double SqrDistance_LinePoint(void* line, void* point) { auto p = CastToPoint2(point); auto l = CastToLine2(line); return CGAL::to_double(CGAL::squared_distance(*p, *l)); } static double SqrDistance_LineLine(void* line, void* line2) { auto l = CastToLine2(line); auto l2 = CastToLine2(line2); return CGAL::to_double(CGAL::squared_distance(*l, *l2)); } static double SqrDistance_LineRay(void* line, void* ray) { auto l = CastToLine2(line); auto r = CastToRay2(ray); return CGAL::to_double(CGAL::squared_distance(*l, *r)); } static double SqrDistance_LineSegment(void* line, void* segment) { auto l = CastToLine2(line); auto s = CastToSegment2(segment); return CGAL::to_double(CGAL::squared_distance(*l, *s)); } static double SqrDistance_LineTriangle(void* line, void* triangle) { auto l = CastToLine2(line); auto t = CastToTriangle2(triangle); return CGAL::to_double(CGAL::squared_distance(*l, *t)); } /***************************************************** * * * Ray2 SqrDistance Functions * * * ******************************************************/ static double SqrDistance_RayPoint(void* ray, void* point) { auto r = CastToRay2(ray); auto p = CastToPoint2(point); return CGAL::to_double(CGAL::squared_distance(*r, *p)); } static double SqrDistance_RayLine(void* ray, void* line) { auto r = CastToRay2(ray); auto l = CastToLine2(line); return CGAL::to_double(CGAL::squared_distance(*r, *l)); } static double SqrDistance_RayRay(void* ray, void* ray2) { auto r = CastToRay2(ray); auto r2 = CastToRay2(ray2); return CGAL::to_double(CGAL::squared_distance(*r, *r2)); } static double SqrDistance_RaySegment(void* ray, void* segment) { auto r = CastToRay2(ray); auto s = CastToSegment2(segment); return CGAL::to_double(CGAL::squared_distance(*r, *s)); } static double SqrDistance_RayTriangle(void* ray, void* triangle) { auto r = CastToRay2(ray); auto t = CastToTriangle2(triangle); return CGAL::to_double(CGAL::squared_distance(*r, *t)); } /***************************************************** * * * Segment2 SqrDistance Functions * * * ******************************************************/ static double SqrDistance_SegmentPoint(void* segment, void* point) { auto s = CastToSegment2(segment); auto p = CastToPoint2(point); return CGAL::to_double(CGAL::squared_distance(*s, *p)); } static double SqrDistance_SegmentLine(void* segment, void* line) { auto s = CastToSegment2(segment); auto l = CastToLine2(line); return CGAL::to_double(CGAL::squared_distance(*s, *l)); } static double SqrDistance_SegmentRay(void* segment, void* ray) { auto s = CastToSegment2(segment); auto r = CastToRay2(ray); return CGAL::to_double(CGAL::squared_distance(*s, *r)); } static double SqrDistance_SegmentSegment(void* segment, void* segment2) { auto s = CastToSegment2(segment); auto s2 = CastToSegment2(segment2); return CGAL::to_double(CGAL::squared_distance(*s, *s2)); } static double SqrDistance_SegmentTriangle(void* segment, void* triangle) { auto s = CastToSegment2(segment); auto t = CastToTriangle2(triangle); return CGAL::to_double(CGAL::squared_distance(*s, *t)); } /***************************************************** * * * Triangle2 SqrDistance Functions * * * ******************************************************/ static double SqrDistance_TrianglePoint(void* triangle, void* point) { auto t = CastToTriangle2(triangle); auto p = CastToPoint2(point); return CGAL::to_double(CGAL::squared_distance(*t, *p)); } static double SqrDistance_TriangleLine(void* triangle, void* line) { auto t = CastToTriangle2(triangle); auto l = CastToLine2(line); return CGAL::to_double(CGAL::squared_distance(*t, *l)); } static double SqrDistance_TriangleRay(void* triangle, void* ray) { auto t = CastToTriangle2(triangle); auto r = CastToRay2(ray); return CGAL::to_double(CGAL::squared_distance(*t, *r)); } static double SqrDistance_TriangleSegment(void* triangle, void* segment) { auto t = CastToTriangle2(triangle); auto s = CastToSegment2(segment); return CGAL::to_double(CGAL::squared_distance(*t, *s)); } static double SqrDistance_TriangleTriangle(void* triangle, void* triangle2) { auto t = CastToTriangle2(triangle); auto t2 = CastToTriangle2(triangle2); return CGAL::to_double(CGAL::squared_distance(*t, *t2)); } }; ================================================ FILE: CGALWrapper/Geometry/Intersections_geometry_EEK.cpp ================================================ #include "Intersections_geometry_EEK.h" #include "Intersections_geometry.h" /***************************************************** * * * Point2 DoIntersect Functions * * * ******************************************************/ BOOL Intersections_Geometry_EEK_DoIntersect_PointLine(void* point, void* line) { return Intersections_Geometry::DoIntersect_PointLine(point, line); } BOOL Intersections_Geometry_EEK_DoIntersect_PointRay(void* point, void* ray) { return Intersections_Geometry::DoIntersect_PointRay(point, ray); } BOOL Intersections_Geometry_EEK_DoIntersect_PointSegment(void* point, void* segment) { return Intersections_Geometry::DoIntersect_PointSegment(point, segment); } BOOL Intersections_Geometry_EEK_DoIntersect_PointTriangle(void* point, void* triangle) { return Intersections_Geometry::DoIntersect_PointTriangle(point, triangle); } BOOL Intersections_Geometry_EEK_DoIntersect_PointBox(void* point, void* box) { return Intersections_Geometry::DoIntersect_PointBox(point, box); } /***************************************************** * * * Line2 DoIntersect Functions * * * ******************************************************/ BOOL Intersections_Geometry_EEK_DoIntersect_LinePoint(void* line, void* point) { return Intersections_Geometry::DoIntersect_LinePoint(line, point); } BOOL Intersections_Geometry_EEK_DoIntersect_LineLine(void* line, void* line2) { return Intersections_Geometry::DoIntersect_LineLine(line, line2); } BOOL Intersections_Geometry_EEK_DoIntersect_LineRay(void* line, void* ray) { return Intersections_Geometry::DoIntersect_LineRay(line, ray); } BOOL Intersections_Geometry_EEK_DoIntersect_LineSegment(void* line, void* segment) { return Intersections_Geometry::DoIntersect_LineSegment(line, segment); } BOOL Intersections_Geometry_EEK_DoIntersect_LineTriangle(void* line, void* triangle) { return Intersections_Geometry::DoIntersect_LineTriangle(line, triangle); } BOOL Intersections_Geometry_EEK_DoIntersect_LineBox(void* line, void* box) { return Intersections_Geometry::DoIntersect_LineBox(line, box); } /***************************************************** * * * Ray2 DoIntersect Functions * * * ******************************************************/ BOOL Intersections_Geometry_EEK_DoIntersect_RayPoint(void* ray, void* point) { return Intersections_Geometry::DoIntersect_RayPoint(ray, point); } BOOL Intersections_Geometry_EEK_DoIntersect_RayLine(void* ray, void* line) { return Intersections_Geometry::DoIntersect_RayLine(ray, line); } BOOL Intersections_Geometry_EEK_DoIntersect_RayRay(void* ray, void* ray2) { return Intersections_Geometry::DoIntersect_RayRay(ray, ray2); } BOOL Intersections_Geometry_EEK_DoIntersect_RaySegment(void* ray, void* segment) { return Intersections_Geometry::DoIntersect_RaySegment(ray, segment); } BOOL Intersections_Geometry_EEK_DoIntersect_RayTriangle(void* ray, void* triangle) { return Intersections_Geometry::DoIntersect_RayTriangle(ray, triangle); } BOOL Intersections_Geometry_EEK_DoIntersect_RayBox(void* ray, void* box) { return Intersections_Geometry::DoIntersect_RayBox(ray, box); } /***************************************************** * * * Segment2 DoIntersect Functions * * * ******************************************************/ BOOL Intersections_Geometry_EEK_DoIntersect_SegmentPoint(void* segment, void* point) { return Intersections_Geometry::DoIntersect_SegmentPoint(segment, point); } BOOL Intersections_Geometry_EEK_DoIntersect_SegmentLine(void* segment, void* line) { return Intersections_Geometry::DoIntersect_SegmentLine(segment, line); } BOOL Intersections_Geometry_EEK_DoIntersect_SegmentRay(void* segment, void* ray) { return Intersections_Geometry::DoIntersect_SegmentRay(segment, ray); } BOOL Intersections_Geometry_EEK_DoIntersect_SegmentSegment(void* segment, void* segment2) { return Intersections_Geometry::DoIntersect_SegmentSegment(segment, segment2); } BOOL Intersections_Geometry_EEK_DoIntersect_SegmentTriangle(void* segment, void* triangle) { return Intersections_Geometry::DoIntersect_SegmentTriangle(segment, triangle); } BOOL Intersections_Geometry_EEK_DoIntersect_SegmentBox(void* segment, void* box) { return Intersections_Geometry::DoIntersect_SegmentBox(segment, box); } /***************************************************** * * * Triangle DoIntersect Functions * * * ******************************************************/ BOOL Intersections_Geometry_EEK_DoIntersect_TrianglePoint(void* triangle, void* point) { return Intersections_Geometry::DoIntersect_TrianglePoint(triangle, point); } BOOL Intersections_Geometry_EEK_DoIntersect_TriangleLine(void* triangle, void* line) { return Intersections_Geometry::DoIntersect_TriangleLine(triangle, line); } BOOL Intersections_Geometry_EEK_DoIntersect_TriangleRay(void* triangle, void* ray) { return Intersections_Geometry::DoIntersect_TriangleRay(triangle, ray); } BOOL Intersections_Geometry_EEK_DoIntersect_TriangleSegment(void* triangle, void* segment) { return Intersections_Geometry::DoIntersect_TriangleSegment(triangle, segment); } BOOL Intersections_Geometry_EEK_DoIntersect_TriangleTriangle(void* triangle, void* triangle2) { return Intersections_Geometry::DoIntersect_TriangleTriangle(triangle, triangle2); } BOOL Intersections_Geometry_EEK_DoIntersect_TriangleBox(void* triangle, void* box) { return Intersections_Geometry::DoIntersect_TriangleBox(triangle, box); } /***************************************************** * * * Box2 DoIntersect Functions * * * ******************************************************/ BOOL Intersections_Geometry_EEK_DoIntersect_BoxPoint(void* box, void* point) { return Intersections_Geometry::DoIntersect_BoxPoint(box, point); } BOOL Intersections_Geometry_EEK_DoIntersect_BoxLine(void* box, void* line) { return Intersections_Geometry::DoIntersect_BoxLine(box, line); } BOOL Intersections_Geometry_EEK_DoIntersect_BoxRay(void* box, void* ray) { return Intersections_Geometry::DoIntersect_BoxRay(box, ray); } BOOL Intersections_Geometry_EEK_DoIntersect_BoxSegment(void* box, void* segment) { return Intersections_Geometry::DoIntersect_BoxSegment(box, segment); } BOOL Intersections_Geometry_EEK_DoIntersect_BoxTriangle(void* box, void* triangle) { return Intersections_Geometry::DoIntersect_BoxTriangle(box, triangle); } BOOL Intersections_Geometry_EEK_DoIntersect_BoxBox(void* box, void* box2) { return Intersections_Geometry::DoIntersect_BoxBox(box, box2); } /***************************************************** * * * Point2 Intersection Functions * * * ******************************************************/ IntersectionResult2d Intersections_Geometry_EEK_Intersection_PointLine(void* point, void* line) { return Intersections_Geometry::Intersection_PointLine(point, line); } IntersectionResult2d Intersections_Geometry_EEK_Intersection_PointRay(void* point, void* ray) { return Intersections_Geometry::Intersection_PointRay(point, ray); } IntersectionResult2d Intersections_Geometry_EEK_Intersection_PointSegment(void* point, void* segment) { return Intersections_Geometry::Intersection_PointSegment(point, segment); } IntersectionResult2d Intersections_Geometry_EEK_Intersection_PointTriangle(void* point, void* triangle) { return Intersections_Geometry::Intersection_PointTriangle(point, triangle); } IntersectionResult2d Intersections_Geometry_EEK_Intersection_PointBox(void* point, void* box) { return Intersections_Geometry::Intersection_PointBox(point, box); } /***************************************************** * * * Line Intersection Functions * * * ******************************************************/ IntersectionResult2d Intersections_Geometry_EEK_Intersection_LinePoint(void* line, void* point) { return Intersections_Geometry::Intersection_LinePoint(point, line); } IntersectionResult2d Intersections_Geometry_EEK_Intersection_LineLine(void* line, void* line2) { return Intersections_Geometry::Intersection_LineLine(line, line2); } IntersectionResult2d Intersections_Geometry_EEK_Intersection_LineRay(void* line, void* ray) { return Intersections_Geometry::Intersection_LineRay(line, ray); } IntersectionResult2d Intersections_Geometry_EEK_Intersection_LineSegment(void* line, void* segment) { return Intersections_Geometry::Intersection_LineSegment(line, segment); } IntersectionResult2d Intersections_Geometry_EEK_Intersection_LineTriangle(void* line, void* triangle) { return Intersections_Geometry::Intersection_LineTriangle(line, triangle); } IntersectionResult2d Intersections_Geometry_EEK_Intersection_LineBox(void* line, void* box) { return Intersections_Geometry::Intersection_LineBox(line, box); } /***************************************************** * * * Ray2 Intersection Functions * * * ******************************************************/ IntersectionResult2d Intersections_Geometry_EEK_Intersection_RayPoint(void* ray, void* point) { return Intersections_Geometry::Intersection_RayPoint(ray, point); } IntersectionResult2d Intersections_Geometry_EEK_Intersection_RayLine(void* ray, void* line) { return Intersections_Geometry::Intersection_RayLine(ray, line); } IntersectionResult2d Intersections_Geometry_EEK_Intersection_RayRay(void* ray, void* ray2) { return Intersections_Geometry::Intersection_RayRay(ray, ray2); } IntersectionResult2d Intersections_Geometry_EEK_Intersection_RaySegment(void* ray, void* segment) { return Intersections_Geometry::Intersection_RaySegment(ray, segment); } IntersectionResult2d Intersections_Geometry_EEK_Intersection_RayTriangle(void* ray, void* triangle) { return Intersections_Geometry::Intersection_RayTriangle(ray, triangle); } IntersectionResult2d Intersections_Geometry_EEK_Intersection_RayBox(void* ray, void* box) { return Intersections_Geometry::Intersection_RayBox(ray, box); } /***************************************************** * * * Segment2 Intersection Functions * * * ******************************************************/ IntersectionResult2d Intersections_Geometry_EEK_Intersection_SegmentPoint(void* segment, void* point) { return Intersections_Geometry::Intersection_SegmentPoint(segment, point); } IntersectionResult2d Intersections_Geometry_EEK_Intersection_SegmentLine(void* segment, void* line) { return Intersections_Geometry::Intersection_SegmentLine(segment, line); } IntersectionResult2d Intersections_Geometry_EEK_Intersection_SegmentRay(void* segment, void* ray) { return Intersections_Geometry::Intersection_SegmentRay(segment, ray); } IntersectionResult2d Intersections_Geometry_EEK_Intersection_SegmentSegment(void* segment, void* segment2) { return Intersections_Geometry::Intersection_SegmentSegment(segment, segment); } IntersectionResult2d Intersections_Geometry_EEK_Intersection_SegmentTriangle(void* segment, void* triangle) { return Intersections_Geometry::Intersection_SegmentTriangle(segment, triangle); } IntersectionResult2d Intersections_Geometry_EEK_Intersection_SegmentBox(void* segment, void* box) { return Intersections_Geometry::Intersection_SegmentBox(segment, box); } /***************************************************** * * * Triangle2 Intersection Functions * * * ******************************************************/ IntersectionResult2d Intersections_Geometry_EEK_Intersection_TrianglePoint(void* triangle, void* point) { return Intersections_Geometry::Intersection_TrianglePoint(triangle, point); } IntersectionResult2d Intersections_Geometry_EEK_Intersection_TriangleLine(void* triangle, void* line) { return Intersections_Geometry::Intersection_TriangleLine(triangle, line); } IntersectionResult2d Intersections_Geometry_EEK_Intersection_TriangleRay(void* triangle, void* ray) { return Intersections_Geometry::Intersection_TriangleRay(triangle, ray); } IntersectionResult2d Intersections_Geometry_EEK_Intersection_TriangleSegment(void* triangle, void* segment) { return Intersections_Geometry::Intersection_TriangleSegment(triangle, segment); } IntersectionResult2d Intersections_Geometry_EEK_Intersection_TriangleTriangle(void* triangle, void* triangle2) { return Intersections_Geometry::Intersection_TriangleTriangle(triangle, triangle2); } IntersectionResult2d Intersections_Geometry_EEK_Intersection_TriangleBox(void* triangle, void* box) { return Intersections_Geometry::Intersection_TriangleBox(triangle, box); } /***************************************************** * * * Box2 Intersection Functions * * * ******************************************************/ IntersectionResult2d Intersections_Geometry_EEK_Intersection_BoxPoint(void* box, void* point) { return Intersections_Geometry::Intersection_BoxPoint(box, point); } IntersectionResult2d Intersections_Geometry_EEK_Intersection_BoxLine(void* box, void* line) { return Intersections_Geometry::Intersection_BoxLine(box, line); } IntersectionResult2d Intersections_Geometry_EEK_Intersection_BoxRay(void* box, void* ray) { return Intersections_Geometry::Intersection_BoxRay(box, ray); } IntersectionResult2d Intersections_Geometry_EEK_Intersection_BoxSegment(void* box, void* segment) { return Intersections_Geometry::Intersection_BoxSegment(box, segment); } IntersectionResult2d Intersections_Geometry_EEK_Intersection_BoxTriangle(void* box, void* triangle) { return Intersections_Geometry::Intersection_BoxTriangle(box, triangle); } IntersectionResult2d Intersections_Geometry_EEK_Intersection_BoxBox(void* box, void* box2) { return Intersections_Geometry::Intersection_BoxBox(box, box2); } /***************************************************** * * * Point2 SqrDistance Functions * * * ******************************************************/ double Intersections_Geometry_EEK_SqrDistance_PointPoint(void* point, void* point2) { return Intersections_Geometry::SqrDistance_PointPoint(point, point2); } double Intersections_Geometry_EEK_SqrDistance_PointLine(void* point, void* line) { return Intersections_Geometry::SqrDistance_PointLine(point, line); } double Intersections_Geometry_EEK_SqrDistance_PointRay(void* point, void* ray) { return Intersections_Geometry::SqrDistance_PointRay(point, ray); } double Intersections_Geometry_EEK_SqrDistance_PointSegment(void* point, void* segment) { return Intersections_Geometry::SqrDistance_PointSegment(point, segment); } double Intersections_Geometry_EEK_SqrDistance_PointTriangle(void* point, void* triangle) { return Intersections_Geometry::SqrDistance_PointTriangle(point, triangle); } /***************************************************** * * * Line2 SqrDistance Functions * * * ******************************************************/ double Intersections_Geometry_EEK_SqrDistance_LinePoint(void* line, void* point) { return Intersections_Geometry::SqrDistance_LinePoint(line, point); } double Intersections_Geometry_EEK_SqrDistance_LineLine(void* line, void* line2) { return Intersections_Geometry::SqrDistance_LineLine(line, line2); } double Intersections_Geometry_EEK_SqrDistance_LineRay(void* line, void* ray) { return Intersections_Geometry::SqrDistance_LineRay(line, ray); } double Intersections_Geometry_EEK_SqrDistance_LineSegment(void* line, void* segment) { return Intersections_Geometry::SqrDistance_LineSegment(line, segment); } double Intersections_Geometry_EEK_SqrDistance_LineTriangle(void* line, void* triangle) { return Intersections_Geometry::SqrDistance_LineTriangle(line, triangle); } /***************************************************** * * * Ray2 SqrDistance Functions * * * ******************************************************/ double Intersections_Geometry_EEK_SqrDistance_RayPoint(void* ray, void* point) { return Intersections_Geometry::SqrDistance_RayPoint(ray, point); } double Intersections_Geometry_EEK_SqrDistance_RayLine(void* ray, void* line) { return Intersections_Geometry::SqrDistance_RayLine(ray, line); } double Intersections_Geometry_EEK_SqrDistance_RayRay(void* ray, void* ray2) { return Intersections_Geometry::SqrDistance_RayRay(ray, ray2); } double Intersections_Geometry_EEK_SqrDistance_RaySegment(void* ray, void* segment) { return Intersections_Geometry::SqrDistance_RaySegment(ray, segment); } double Intersections_Geometry_EEK_SqrDistance_RayTriangle(void* ray, void* triangle) { return Intersections_Geometry::SqrDistance_RayTriangle(ray, triangle); } /***************************************************** * * * Segment2 SqrDistance Functions * * * ******************************************************/ double Intersections_Geometry_EEK_SqrDistance_SegmentPoint(void* segment, void* point) { return Intersections_Geometry::SqrDistance_SegmentPoint(segment, point); } double Intersections_Geometry_EEK_SqrDistance_SegmentLine(void* segment, void* line) { return Intersections_Geometry::SqrDistance_SegmentLine(segment, line); } double Intersections_Geometry_EEK_SqrDistance_SegmentRay(void* segment, void* ray) { return Intersections_Geometry::SqrDistance_SegmentRay(segment, ray); } double Intersections_Geometry_EEK_SqrDistance_SegmentSegment(void* segment, void* segment2) { return Intersections_Geometry::SqrDistance_SegmentSegment(segment, segment2); } double Intersections_Geometry_EEK_SqrDistance_SegmentTriangle(void* segment, void* triangle) { return Intersections_Geometry::SqrDistance_SegmentTriangle(segment, triangle); } /***************************************************** * * * Triangle2 SqrDistance Functions * * * ******************************************************/ double Intersections_Geometry_EEK_SqrDistance_TrianglePoint(void* triangle, void* point) { return Intersections_Geometry::SqrDistance_TrianglePoint(triangle, point); } double Intersections_Geometry_EEK_SqrDistance_TriangleLine(void* triangle, void* line) { return Intersections_Geometry::SqrDistance_TriangleLine(triangle, line); } double Intersections_Geometry_EEK_SqrDistance_TriangleRay(void* triangle, void* ray) { return Intersections_Geometry::SqrDistance_TriangleRay(triangle, ray); } double Intersections_Geometry_EEK_SqrDistance_TriangleSegment(void* triangle, void* segment) { return Intersections_Geometry::SqrDistance_TriangleSegment(triangle, segment); } double Intersections_Geometry_EEK_SqrDistance_TriangleTriangle(void* triangle, void* triangle2) { return Intersections_Geometry::SqrDistance_TriangleTriangle(triangle, triangle2); } ================================================ FILE: CGALWrapper/Geometry/Intersections_geometry_EEK.h ================================================ #pragma once #include "../CGALWrapper.h" #include "Geometry2.h" #include "Intersections_geometry.h" #include #include extern "C" { /***************************************************** * * * void* DoIntersect Functions * * * ******************************************************/ CGALWRAPPER_API BOOL Intersections_Geometry_EEK_DoIntersect_PointLine(void* point, void* line); CGALWRAPPER_API BOOL Intersections_Geometry_EEK_DoIntersect_PointRay(void* point, void* ray); CGALWRAPPER_API BOOL Intersections_Geometry_EEK_DoIntersect_PointSegment(void* point, void* segment); CGALWRAPPER_API BOOL Intersections_Geometry_EEK_DoIntersect_PointTriangle(void* point, void* triangle); CGALWRAPPER_API BOOL Intersections_Geometry_EEK_DoIntersect_PointBox(void* point, void* box); /***************************************************** * * * void* DoIntersect Functions * * * ******************************************************/ CGALWRAPPER_API BOOL Intersections_Geometry_EEK_DoIntersect_LinePoint(void* line, void* point); CGALWRAPPER_API BOOL Intersections_Geometry_EEK_DoIntersect_LineLine(void* line, void* line2); CGALWRAPPER_API BOOL Intersections_Geometry_EEK_DoIntersect_LineRay(void* line, void* ray); CGALWRAPPER_API BOOL Intersections_Geometry_EEK_DoIntersect_LineSegment(void* line, void* segment); CGALWRAPPER_API BOOL Intersections_Geometry_EEK_DoIntersect_LineTriangle(void* line, void* triangle); CGALWRAPPER_API BOOL Intersections_Geometry_EEK_DoIntersect_LineBox(void* line, void* box); /***************************************************** * * * void* DoIntersect Functions * * * ******************************************************/ CGALWRAPPER_API BOOL Intersections_Geometry_EEK_DoIntersect_RayPoint(void* ray, void* point); CGALWRAPPER_API BOOL Intersections_Geometry_EEK_DoIntersect_RayLine(void* ray, void* line); CGALWRAPPER_API BOOL Intersections_Geometry_EEK_DoIntersect_RayRay(void* ray, void* ray2); CGALWRAPPER_API BOOL Intersections_Geometry_EEK_DoIntersect_RaySegment(void* ray, void* segment); CGALWRAPPER_API BOOL Intersections_Geometry_EEK_DoIntersect_RayTriangle(void* ray, void* triangle); CGALWRAPPER_API BOOL Intersections_Geometry_EEK_DoIntersect_RayBox(void* ray, void* box); /***************************************************** * * * void* DoIntersect Functions * * * ******************************************************/ CGALWRAPPER_API BOOL Intersections_Geometry_EEK_DoIntersect_SegmentPoint(void* segment, void* point); CGALWRAPPER_API BOOL Intersections_Geometry_EEK_DoIntersect_SegmentLine(void* segment, void* line); CGALWRAPPER_API BOOL Intersections_Geometry_EEK_DoIntersect_SegmentRay(void* segment, void* ray); CGALWRAPPER_API BOOL Intersections_Geometry_EEK_DoIntersect_SegmentSegment(void* segment, void* segment2); CGALWRAPPER_API BOOL Intersections_Geometry_EEK_DoIntersect_SegmentTriangle(void* segment, void* triangle); CGALWRAPPER_API BOOL Intersections_Geometry_EEK_DoIntersect_SegmentBox(void* segment, void* box); /***************************************************** * * * void* DoIntersect Functions * * * ******************************************************/ CGALWRAPPER_API BOOL Intersections_Geometry_EEK_DoIntersect_TrianglePoint(void* triangle, void* point); CGALWRAPPER_API BOOL Intersections_Geometry_EEK_DoIntersect_TriangleLine(void* triangle, void* line); CGALWRAPPER_API BOOL Intersections_Geometry_EEK_DoIntersect_TriangleRay(void* triangle, void* ray); CGALWRAPPER_API BOOL Intersections_Geometry_EEK_DoIntersect_TriangleSegment(void* triangle, void* segment); CGALWRAPPER_API BOOL Intersections_Geometry_EEK_DoIntersect_TriangleTriangle(void* triangle, void* triangle2); CGALWRAPPER_API BOOL Intersections_Geometry_EEK_DoIntersect_TriangleBox(void* triangle, void* box); /***************************************************** * * * void* DoIntersect Functions * * * ******************************************************/ CGALWRAPPER_API BOOL Intersections_Geometry_EEK_DoIntersect_BoxPoint(void* box, void* point); CGALWRAPPER_API BOOL Intersections_Geometry_EEK_DoIntersect_BoxLine(void* box, void* line); CGALWRAPPER_API BOOL Intersections_Geometry_EEK_DoIntersect_BoxRay(void* box, void* ray); CGALWRAPPER_API BOOL Intersections_Geometry_EEK_DoIntersect_BoxSegment(void* box, void* segment); CGALWRAPPER_API BOOL Intersections_Geometry_EEK_DoIntersect_BoxTriangle(void* box, void* triangle); CGALWRAPPER_API BOOL Intersections_Geometry_EEK_DoIntersect_BoxBox(void* box, void* box2); /***************************************************** * * * void* Intersection Functions * * * ******************************************************/ CGALWRAPPER_API IntersectionResult2d Intersections_Geometry_EEK_Intersection_PointLine(void* point, void* line); CGALWRAPPER_API IntersectionResult2d Intersections_Geometry_EEK_Intersection_PointRay(void* point, void* ray); CGALWRAPPER_API IntersectionResult2d Intersections_Geometry_EEK_Intersection_PointSegment(void* point, void* segment); CGALWRAPPER_API IntersectionResult2d Intersections_Geometry_EEK_Intersection_PointTriangle(void* point, void* triangle); CGALWRAPPER_API IntersectionResult2d Intersections_Geometry_EEK_Intersection_PointBox(void* point, void* box); /***************************************************** * * * void* Intersection Functions * * * ******************************************************/ CGALWRAPPER_API IntersectionResult2d Intersections_Geometry_EEK_Intersection_LinePoint(void* line, void* point); CGALWRAPPER_API IntersectionResult2d Intersections_Geometry_EEK_Intersection_LineLine(void* line, void* line2); CGALWRAPPER_API IntersectionResult2d Intersections_Geometry_EEK_Intersection_LineRay(void* line, void* ray); CGALWRAPPER_API IntersectionResult2d Intersections_Geometry_EEK_Intersection_LineSegment(void* line, void* segment); CGALWRAPPER_API IntersectionResult2d Intersections_Geometry_EEK_Intersection_LineTriangle(void* line, void* triangle); CGALWRAPPER_API IntersectionResult2d Intersections_Geometry_EEK_Intersection_LineBox(void* line, void* box); /***************************************************** * * * void* Intersection Functions * * * ******************************************************/ CGALWRAPPER_API IntersectionResult2d Intersections_Geometry_EEK_Intersection_RayPoint(void* ray, void* point); CGALWRAPPER_API IntersectionResult2d Intersections_Geometry_EEK_Intersection_RayLine(void* ray, void* line); CGALWRAPPER_API IntersectionResult2d Intersections_Geometry_EEK_Intersection_RayRay(void* ray, void* ray2); CGALWRAPPER_API IntersectionResult2d Intersections_Geometry_EEK_Intersection_RaySegment(void* ray, void* segment); CGALWRAPPER_API IntersectionResult2d Intersections_Geometry_EEK_Intersection_RayTriangle(void* ray, void* triangle); CGALWRAPPER_API IntersectionResult2d Intersections_Geometry_EEK_Intersection_RayBox(void* ray, void* box); /***************************************************** * * * void* Intersection Functions * * * ******************************************************/ CGALWRAPPER_API IntersectionResult2d Intersections_Geometry_EEK_Intersection_SegmentPoint(void* segment, void* point); CGALWRAPPER_API IntersectionResult2d Intersections_Geometry_EEK_Intersection_SegmentLine(void* segment, void* line); CGALWRAPPER_API IntersectionResult2d Intersections_Geometry_EEK_Intersection_SegmentRay(void* segment, void* ray); CGALWRAPPER_API IntersectionResult2d Intersections_Geometry_EEK_Intersection_SegmentSegment(void* segment, void* segment2); CGALWRAPPER_API IntersectionResult2d Intersections_Geometry_EEK_Intersection_SegmentTriangle(void* segment, void* triangle); CGALWRAPPER_API IntersectionResult2d Intersections_Geometry_EEK_Intersection_SegmentBox(void* segment, void* box); /***************************************************** * * * void* Intersection Functions * * * ******************************************************/ CGALWRAPPER_API IntersectionResult2d Intersections_Geometry_EEK_Intersection_TrianglePoint(void* triangle, void* point); CGALWRAPPER_API IntersectionResult2d Intersections_Geometry_EEK_Intersection_TriangleLine(void* triangle, void* line); CGALWRAPPER_API IntersectionResult2d Intersections_Geometry_EEK_Intersection_TriangleRay(void* triangle, void* ray); CGALWRAPPER_API IntersectionResult2d Intersections_Geometry_EEK_Intersection_TriangleSegment(void* triangle, void* segment); CGALWRAPPER_API IntersectionResult2d Intersections_Geometry_EEK_Intersection_TriangleTriangle(void* triangle, void* triangle2); CGALWRAPPER_API IntersectionResult2d Intersections_Geometry_EEK_Intersection_TriangleBox(void* triangle, void* box); /***************************************************** * * * void* Intersection Functions * * * ******************************************************/ CGALWRAPPER_API IntersectionResult2d Intersections_Geometry_EEK_Intersection_BoxPoint(void* box, void* point); CGALWRAPPER_API IntersectionResult2d Intersections_Geometry_EEK_Intersection_BoxLine(void* box, void* line); CGALWRAPPER_API IntersectionResult2d Intersections_Geometry_EEK_Intersection_BoxRay(void* box, void* ray); CGALWRAPPER_API IntersectionResult2d Intersections_Geometry_EEK_Intersection_BoxSegment(void* box, void* segment); CGALWRAPPER_API IntersectionResult2d Intersections_Geometry_EEK_Intersection_BoxTriangle(void* box, void* triangle); CGALWRAPPER_API IntersectionResult2d Intersections_Geometry_EEK_Intersection_BoxBox(void* box, void* box2); /***************************************************** * * * void* SqrDistance Functions * * * ******************************************************/ CGALWRAPPER_API double Intersections_Geometry_EEK_SqrDistance_PointPoint(void* point, void* point2); CGALWRAPPER_API double Intersections_Geometry_EEK_SqrDistance_PointLine(void* point, void* line); CGALWRAPPER_API double Intersections_Geometry_EEK_SqrDistance_PointRay(void* point, void* ray); CGALWRAPPER_API double Intersections_Geometry_EEK_SqrDistance_PointSegment(void* point, void* segment); CGALWRAPPER_API double Intersections_Geometry_EEK_SqrDistance_PointTriangle(void* point, void* triangle); /***************************************************** * * * void* SqrDistance Functions * * * ******************************************************/ CGALWRAPPER_API double Intersections_Geometry_EEK_SqrDistance_LinePoint(void* line, void* point); CGALWRAPPER_API double Intersections_Geometry_EEK_SqrDistance_LineLine(void* line, void* line2); CGALWRAPPER_API double Intersections_Geometry_EEK_SqrDistance_LineRay(void* line, void* ray); CGALWRAPPER_API double Intersections_Geometry_EEK_SqrDistance_LineSegment(void* line, void* segment); CGALWRAPPER_API double Intersections_Geometry_EEK_SqrDistance_LineTriangle(void* line, void* triangle); /***************************************************** * * * void* SqrDistance Functions * * * ******************************************************/ CGALWRAPPER_API double Intersections_Geometry_EEK_SqrDistance_RayPoint(void* ray, void* point); CGALWRAPPER_API double Intersections_Geometry_EEK_SqrDistance_RayLine(void* ray, void* line); CGALWRAPPER_API double Intersections_Geometry_EEK_SqrDistance_RayRay(void* ray, void* ray2); CGALWRAPPER_API double Intersections_Geometry_EEK_SqrDistance_RaySegment(void* ray, void* segment); CGALWRAPPER_API double Intersections_Geometry_EEK_SqrDistance_RayTriangle(void* ray, void* triangle); /***************************************************** * * * void* SqrDistance Functions * * * ******************************************************/ CGALWRAPPER_API double Intersections_Geometry_EEK_SqrDistance_SegmentPoint(void* segment, void* point); CGALWRAPPER_API double Intersections_Geometry_EEK_SqrDistance_SegmentLine(void* segment, void* line); CGALWRAPPER_API double Intersections_Geometry_EEK_SqrDistance_SegmentRay(void* segment, void* ray); CGALWRAPPER_API double Intersections_Geometry_EEK_SqrDistance_SegmentSegment(void* segment, void* segment2); CGALWRAPPER_API double Intersections_Geometry_EEK_SqrDistance_SegmentTriangle(void* segment, void* triangle); /***************************************************** * * * void* SqrDistance Functions * * * ******************************************************/ CGALWRAPPER_API double Intersections_Geometry_EEK_SqrDistance_TrianglePoint(void* triangle, void* point); CGALWRAPPER_API double Intersections_Geometry_EEK_SqrDistance_TriangleLine(void* triangle, void* line); CGALWRAPPER_API double Intersections_Geometry_EEK_SqrDistance_TriangleRay(void* triangle, void* ray); CGALWRAPPER_API double Intersections_Geometry_EEK_SqrDistance_TriangleSegment(void* triangle, void* segment); CGALWRAPPER_API double Intersections_Geometry_EEK_SqrDistance_TriangleTriangle(void* triangle, void* triangle2); }; ================================================ FILE: CGALWrapper/Geometry/Intersections_geometry_EIK.cpp ================================================ #include "Intersections_geometry_EIK.h" #include "Intersections_geometry.h" /***************************************************** * * * Point2 DoIntersect Functions * * * ******************************************************/ BOOL Intersections_Geometry_EIK_DoIntersect_PointLine(void* point, void* line) { return Intersections_Geometry::DoIntersect_PointLine(point, line); } BOOL Intersections_Geometry_EIK_DoIntersect_PointRay(void* point, void* ray) { return Intersections_Geometry::DoIntersect_PointRay(point, ray); } BOOL Intersections_Geometry_EIK_DoIntersect_PointSegment(void* point, void* segment) { return Intersections_Geometry::DoIntersect_PointSegment(point, segment); } BOOL Intersections_Geometry_EIK_DoIntersect_PointTriangle(void* point, void* triangle) { return Intersections_Geometry::DoIntersect_PointTriangle(point, triangle); } BOOL Intersections_Geometry_EIK_DoIntersect_PointBox(void* point, void* box) { return Intersections_Geometry::DoIntersect_PointBox(point, box); } /***************************************************** * * * Line2 DoIntersect Functions * * * ******************************************************/ BOOL Intersections_Geometry_EIK_DoIntersect_LinePoint(void* line, void* point) { return Intersections_Geometry::DoIntersect_LinePoint(line, point); } BOOL Intersections_Geometry_EIK_DoIntersect_LineLine(void* line, void* line2) { return Intersections_Geometry::DoIntersect_LineLine(line, line2); } BOOL Intersections_Geometry_EIK_DoIntersect_LineRay(void* line, void* ray) { return Intersections_Geometry::DoIntersect_LineRay(line, ray); } BOOL Intersections_Geometry_EIK_DoIntersect_LineSegment(void* line, void* segment) { return Intersections_Geometry::DoIntersect_LineSegment(line, segment); } BOOL Intersections_Geometry_EIK_DoIntersect_LineTriangle(void* line, void* triangle) { return Intersections_Geometry::DoIntersect_LineTriangle(line, triangle); } BOOL Intersections_Geometry_EIK_DoIntersect_LineBox(void* line, void* box) { return Intersections_Geometry::DoIntersect_LineBox(line, box); } /***************************************************** * * * Ray2 DoIntersect Functions * * * ******************************************************/ BOOL Intersections_Geometry_EIK_DoIntersect_RayPoint(void* ray, void* point) { return Intersections_Geometry::DoIntersect_RayPoint(ray, point); } BOOL Intersections_Geometry_EIK_DoIntersect_RayLine(void* ray, void* line) { return Intersections_Geometry::DoIntersect_RayLine(ray, line); } BOOL Intersections_Geometry_EIK_DoIntersect_RayRay(void* ray, void* ray2) { return Intersections_Geometry::DoIntersect_RayRay(ray, ray2); } BOOL Intersections_Geometry_EIK_DoIntersect_RaySegment(void* ray, void* segment) { return Intersections_Geometry::DoIntersect_RaySegment(ray, segment); } BOOL Intersections_Geometry_EIK_DoIntersect_RayTriangle(void* ray, void* triangle) { return Intersections_Geometry::DoIntersect_RayTriangle(ray, triangle); } BOOL Intersections_Geometry_EIK_DoIntersect_RayBox(void* ray, void* box) { return Intersections_Geometry::DoIntersect_RayBox(ray, box); } /***************************************************** * * * Segment2 DoIntersect Functions * * * ******************************************************/ BOOL Intersections_Geometry_EIK_DoIntersect_SegmentPoint(void* segment, void* point) { return Intersections_Geometry::DoIntersect_SegmentPoint(segment, point); } BOOL Intersections_Geometry_EIK_DoIntersect_SegmentLine(void* segment, void* line) { return Intersections_Geometry::DoIntersect_SegmentLine(segment, line); } BOOL Intersections_Geometry_EIK_DoIntersect_SegmentRay(void* segment, void* ray) { return Intersections_Geometry::DoIntersect_SegmentRay(segment, ray); } BOOL Intersections_Geometry_EIK_DoIntersect_SegmentSegment(void* segment, void* segment2) { return Intersections_Geometry::DoIntersect_SegmentSegment(segment, segment2); } BOOL Intersections_Geometry_EIK_DoIntersect_SegmentTriangle(void* segment, void* triangle) { return Intersections_Geometry::DoIntersect_SegmentTriangle(segment, triangle); } BOOL Intersections_Geometry_EIK_DoIntersect_SegmentBox(void* segment, void* box) { return Intersections_Geometry::DoIntersect_SegmentBox(segment, box); } /***************************************************** * * * Triangle DoIntersect Functions * * * ******************************************************/ BOOL Intersections_Geometry_EIK_DoIntersect_TrianglePoint(void* triangle, void* point) { return Intersections_Geometry::DoIntersect_TrianglePoint(triangle, point); } BOOL Intersections_Geometry_EIK_DoIntersect_TriangleLine(void* triangle, void* line) { return Intersections_Geometry::DoIntersect_TriangleLine(triangle, line); } BOOL Intersections_Geometry_EIK_DoIntersect_TriangleRay(void* triangle, void* ray) { return Intersections_Geometry::DoIntersect_TriangleRay(triangle, ray); } BOOL Intersections_Geometry_EIK_DoIntersect_TriangleSegment(void* triangle, void* segment) { return Intersections_Geometry::DoIntersect_TriangleSegment(triangle, segment); } BOOL Intersections_Geometry_EIK_DoIntersect_TriangleTriangle(void* triangle, void* triangle2) { return Intersections_Geometry::DoIntersect_TriangleTriangle(triangle, triangle2); } BOOL Intersections_Geometry_EIK_DoIntersect_TriangleBox(void* triangle, void* box) { return Intersections_Geometry::DoIntersect_TriangleBox(triangle, box); } /***************************************************** * * * Box2 DoIntersect Functions * * * ******************************************************/ BOOL Intersections_Geometry_EIK_DoIntersect_BoxPoint(void* box, void* point) { return Intersections_Geometry::DoIntersect_BoxPoint(box, point); } BOOL Intersections_Geometry_EIK_DoIntersect_BoxLine(void* box, void* line) { return Intersections_Geometry::DoIntersect_BoxLine(box, line); } BOOL Intersections_Geometry_EIK_DoIntersect_BoxRay(void* box, void* ray) { return Intersections_Geometry::DoIntersect_BoxRay(box, ray); } BOOL Intersections_Geometry_EIK_DoIntersect_BoxSegment(void* box, void* segment) { return Intersections_Geometry::DoIntersect_BoxSegment(box, segment); } BOOL Intersections_Geometry_EIK_DoIntersect_BoxTriangle(void* box, void* triangle) { return Intersections_Geometry::DoIntersect_BoxTriangle(box, triangle); } BOOL Intersections_Geometry_EIK_DoIntersect_BoxBox(void* box, void* box2) { return Intersections_Geometry::DoIntersect_BoxBox(box, box2); } /***************************************************** * * * Point2 Intersection Functions * * * ******************************************************/ IntersectionResult2d Intersections_Geometry_EIK_Intersection_PointLine(void* point, void* line) { return Intersections_Geometry::Intersection_PointLine(point, line); } IntersectionResult2d Intersections_Geometry_EIK_Intersection_PointRay(void* point, void* ray) { return Intersections_Geometry::Intersection_PointRay(point, ray); } IntersectionResult2d Intersections_Geometry_EIK_Intersection_PointSegment(void* point, void* segment) { return Intersections_Geometry::Intersection_PointSegment(point, segment); } IntersectionResult2d Intersections_Geometry_EIK_Intersection_PointTriangle(void* point, void* triangle) { return Intersections_Geometry::Intersection_PointTriangle(point, triangle); } IntersectionResult2d Intersections_Geometry_EIK_Intersection_PointBox(void* point, void* box) { return Intersections_Geometry::Intersection_PointBox(point, box); } /***************************************************** * * * Line Intersection Functions * * * ******************************************************/ IntersectionResult2d Intersections_Geometry_EIK_Intersection_LinePoint(void* line, void* point) { return Intersections_Geometry::Intersection_LinePoint(point, line); } IntersectionResult2d Intersections_Geometry_EIK_Intersection_LineLine(void* line, void* line2) { return Intersections_Geometry::Intersection_LineLine(line, line2); } IntersectionResult2d Intersections_Geometry_EIK_Intersection_LineRay(void* line, void* ray) { return Intersections_Geometry::Intersection_LineRay(line, ray); } IntersectionResult2d Intersections_Geometry_EIK_Intersection_LineSegment(void* line, void* segment) { return Intersections_Geometry::Intersection_LineSegment(line, segment); } IntersectionResult2d Intersections_Geometry_EIK_Intersection_LineTriangle(void* line, void* triangle) { return Intersections_Geometry::Intersection_LineTriangle(line, triangle); } IntersectionResult2d Intersections_Geometry_EIK_Intersection_LineBox(void* line, void* box) { return Intersections_Geometry::Intersection_LineBox(line, box); } /***************************************************** * * * Ray2 Intersection Functions * * * ******************************************************/ IntersectionResult2d Intersections_Geometry_EIK_Intersection_RayPoint(void* ray, void* point) { return Intersections_Geometry::Intersection_RayPoint(ray, point); } IntersectionResult2d Intersections_Geometry_EIK_Intersection_RayLine(void* ray, void* line) { return Intersections_Geometry::Intersection_RayLine(ray, line); } IntersectionResult2d Intersections_Geometry_EIK_Intersection_RayRay(void* ray, void* ray2) { return Intersections_Geometry::Intersection_RayRay(ray, ray2); } IntersectionResult2d Intersections_Geometry_EIK_Intersection_RaySegment(void* ray, void* segment) { return Intersections_Geometry::Intersection_RaySegment(ray, segment); } IntersectionResult2d Intersections_Geometry_EIK_Intersection_RayTriangle(void* ray, void* triangle) { return Intersections_Geometry::Intersection_RayTriangle(ray, triangle); } IntersectionResult2d Intersections_Geometry_EIK_Intersection_RayBox(void* ray, void* box) { return Intersections_Geometry::Intersection_RayBox(ray, box); } /***************************************************** * * * Segment2 Intersection Functions * * * ******************************************************/ IntersectionResult2d Intersections_Geometry_EIK_Intersection_SegmentPoint(void* segment, void* point) { return Intersections_Geometry::Intersection_SegmentPoint(segment, point); } IntersectionResult2d Intersections_Geometry_EIK_Intersection_SegmentLine(void* segment, void* line) { return Intersections_Geometry::Intersection_SegmentLine(segment, line); } IntersectionResult2d Intersections_Geometry_EIK_Intersection_SegmentRay(void* segment, void* ray) { return Intersections_Geometry::Intersection_SegmentRay(segment, ray); } IntersectionResult2d Intersections_Geometry_EIK_Intersection_SegmentSegment(void* segment, void* segment2) { return Intersections_Geometry::Intersection_SegmentSegment(segment, segment); } IntersectionResult2d Intersections_Geometry_EIK_Intersection_SegmentTriangle(void* segment, void* triangle) { return Intersections_Geometry::Intersection_SegmentTriangle(segment, triangle); } IntersectionResult2d Intersections_Geometry_EIK_Intersection_SegmentBox(void* segment, void* box) { return Intersections_Geometry::Intersection_SegmentBox(segment, box); } /***************************************************** * * * Triangle2 Intersection Functions * * * ******************************************************/ IntersectionResult2d Intersections_Geometry_EIK_Intersection_TrianglePoint(void* triangle, void* point) { return Intersections_Geometry::Intersection_TrianglePoint(triangle, point); } IntersectionResult2d Intersections_Geometry_EIK_Intersection_TriangleLine(void* triangle, void* line) { return Intersections_Geometry::Intersection_TriangleLine(triangle, line); } IntersectionResult2d Intersections_Geometry_EIK_Intersection_TriangleRay(void* triangle, void* ray) { return Intersections_Geometry::Intersection_TriangleRay(triangle, ray); } IntersectionResult2d Intersections_Geometry_EIK_Intersection_TriangleSegment(void* triangle, void* segment) { return Intersections_Geometry::Intersection_TriangleSegment(triangle, segment); } IntersectionResult2d Intersections_Geometry_EIK_Intersection_TriangleTriangle(void* triangle, void* triangle2) { return Intersections_Geometry::Intersection_TriangleTriangle(triangle, triangle2); } IntersectionResult2d Intersections_Geometry_EIK_Intersection_TriangleBox(void* triangle, void* box) { return Intersections_Geometry::Intersection_TriangleBox(triangle, box); } /***************************************************** * * * Box2 Intersection Functions * * * ******************************************************/ IntersectionResult2d Intersections_Geometry_EIK_Intersection_BoxPoint(void* box, void* point) { return Intersections_Geometry::Intersection_BoxPoint(box, point); } IntersectionResult2d Intersections_Geometry_EIK_Intersection_BoxLine(void* box, void* line) { return Intersections_Geometry::Intersection_BoxLine(box, line); } IntersectionResult2d Intersections_Geometry_EIK_Intersection_BoxRay(void* box, void* ray) { return Intersections_Geometry::Intersection_BoxRay(box, ray); } IntersectionResult2d Intersections_Geometry_EIK_Intersection_BoxSegment(void* box, void* segment) { return Intersections_Geometry::Intersection_BoxSegment(box, segment); } IntersectionResult2d Intersections_Geometry_EIK_Intersection_BoxTriangle(void* box, void* triangle) { return Intersections_Geometry::Intersection_BoxTriangle(box, triangle); } IntersectionResult2d Intersections_Geometry_EIK_Intersection_BoxBox(void* box, void* box2) { return Intersections_Geometry::Intersection_BoxBox(box, box2); } /***************************************************** * * * Point2 SqrDistance Functions * * * ******************************************************/ double Intersections_Geometry_EIK_SqrDistance_PointPoint(void* point, void* point2) { return Intersections_Geometry::SqrDistance_PointPoint(point, point2); } double Intersections_Geometry_EIK_SqrDistance_PointLine(void* point, void* line) { return Intersections_Geometry::SqrDistance_PointLine(point, line); } double Intersections_Geometry_EIK_SqrDistance_PointRay(void* point, void* ray) { return Intersections_Geometry::SqrDistance_PointRay(point, ray); } double Intersections_Geometry_EIK_SqrDistance_PointSegment(void* point, void* segment) { return Intersections_Geometry::SqrDistance_PointSegment(point, segment); } double Intersections_Geometry_EIK_SqrDistance_PointTriangle(void* point, void* triangle) { return Intersections_Geometry::SqrDistance_PointTriangle(point, triangle); } /***************************************************** * * * Line2 SqrDistance Functions * * * ******************************************************/ double Intersections_Geometry_EIK_SqrDistance_LinePoint(void* line, void* point) { return Intersections_Geometry::SqrDistance_LinePoint(line, point); } double Intersections_Geometry_EIK_SqrDistance_LineLine(void* line, void* line2) { return Intersections_Geometry::SqrDistance_LineLine(line, line2); } double Intersections_Geometry_EIK_SqrDistance_LineRay(void* line, void* ray) { return Intersections_Geometry::SqrDistance_LineRay(line, ray); } double Intersections_Geometry_EIK_SqrDistance_LineSegment(void* line, void* segment) { return Intersections_Geometry::SqrDistance_LineSegment(line, segment); } double Intersections_Geometry_EIK_SqrDistance_LineTriangle(void* line, void* triangle) { return Intersections_Geometry::SqrDistance_LineTriangle(line, triangle); } /***************************************************** * * * Ray2 SqrDistance Functions * * * ******************************************************/ double Intersections_Geometry_EIK_SqrDistance_RayPoint(void* ray, void* point) { return Intersections_Geometry::SqrDistance_RayPoint(ray, point); } double Intersections_Geometry_EIK_SqrDistance_RayLine(void* ray, void* line) { return Intersections_Geometry::SqrDistance_RayLine(ray, line); } double Intersections_Geometry_EIK_SqrDistance_RayRay(void* ray, void* ray2) { return Intersections_Geometry::SqrDistance_RayRay(ray, ray2); } double Intersections_Geometry_EIK_SqrDistance_RaySegment(void* ray, void* segment) { return Intersections_Geometry::SqrDistance_RaySegment(ray, segment); } double Intersections_Geometry_EIK_SqrDistance_RayTriangle(void* ray, void* triangle) { return Intersections_Geometry::SqrDistance_RayTriangle(ray, triangle); } /***************************************************** * * * Segment2 SqrDistance Functions * * * ******************************************************/ double Intersections_Geometry_EIK_SqrDistance_SegmentPoint(void* segment, void* point) { return Intersections_Geometry::SqrDistance_SegmentPoint(segment, point); } double Intersections_Geometry_EIK_SqrDistance_SegmentLine(void* segment, void* line) { return Intersections_Geometry::SqrDistance_SegmentLine(segment, line); } double Intersections_Geometry_EIK_SqrDistance_SegmentRay(void* segment, void* ray) { return Intersections_Geometry::SqrDistance_SegmentRay(segment, ray); } double Intersections_Geometry_EIK_SqrDistance_SegmentSegment(void* segment, void* segment2) { return Intersections_Geometry::SqrDistance_SegmentSegment(segment, segment2); } double Intersections_Geometry_EIK_SqrDistance_SegmentTriangle(void* segment, void* triangle) { return Intersections_Geometry::SqrDistance_SegmentTriangle(segment, triangle); } /***************************************************** * * * Triangle2 SqrDistance Functions * * * ******************************************************/ double Intersections_Geometry_EIK_SqrDistance_TrianglePoint(void* triangle, void* point) { return Intersections_Geometry::SqrDistance_TrianglePoint(triangle, point); } double Intersections_Geometry_EIK_SqrDistance_TriangleLine(void* triangle, void* line) { return Intersections_Geometry::SqrDistance_TriangleLine(triangle, line); } double Intersections_Geometry_EIK_SqrDistance_TriangleRay(void* triangle, void* ray) { return Intersections_Geometry::SqrDistance_TriangleRay(triangle, ray); } double Intersections_Geometry_EIK_SqrDistance_TriangleSegment(void* triangle, void* segment) { return Intersections_Geometry::SqrDistance_TriangleSegment(triangle, segment); } double Intersections_Geometry_EIK_SqrDistance_TriangleTriangle(void* triangle, void* triangle2) { return Intersections_Geometry::SqrDistance_TriangleTriangle(triangle, triangle2); } ================================================ FILE: CGALWrapper/Geometry/Intersections_geometry_EIK.h ================================================ #pragma once #include "../CGALWrapper.h" #include "Geometry2.h" #include "Intersections_geometry.h" #include #include extern "C" { /***************************************************** * * * void* DoIntersect Functions * * * ******************************************************/ CGALWRAPPER_API BOOL Intersections_Geometry_EIK_DoIntersect_PointLine(void* point, void* line); CGALWRAPPER_API BOOL Intersections_Geometry_EIK_DoIntersect_PointRay(void* point, void* ray); CGALWRAPPER_API BOOL Intersections_Geometry_EIK_DoIntersect_PointSegment(void* point, void* segment); CGALWRAPPER_API BOOL Intersections_Geometry_EIK_DoIntersect_PointTriangle(void* point, void* triangle); CGALWRAPPER_API BOOL Intersections_Geometry_EIK_DoIntersect_PointBox(void* point, void* box); /***************************************************** * * * void* DoIntersect Functions * * * ******************************************************/ CGALWRAPPER_API BOOL Intersections_Geometry_EIK_DoIntersect_LinePoint(void* line, void* point); CGALWRAPPER_API BOOL Intersections_Geometry_EIK_DoIntersect_LineLine(void* line, void* line2); CGALWRAPPER_API BOOL Intersections_Geometry_EIK_DoIntersect_LineRay(void* line, void* ray); CGALWRAPPER_API BOOL Intersections_Geometry_EIK_DoIntersect_LineSegment(void* line, void* segment); CGALWRAPPER_API BOOL Intersections_Geometry_EIK_DoIntersect_LineTriangle(void* line, void* triangle); CGALWRAPPER_API BOOL Intersections_Geometry_EIK_DoIntersect_LineBox(void* line, void* box); /***************************************************** * * * void* DoIntersect Functions * * * ******************************************************/ CGALWRAPPER_API BOOL Intersections_Geometry_EIK_DoIntersect_RayPoint(void* ray, void* point); CGALWRAPPER_API BOOL Intersections_Geometry_EIK_DoIntersect_RayLine(void* ray, void* line); CGALWRAPPER_API BOOL Intersections_Geometry_EIK_DoIntersect_RayRay(void* ray, void* ray2); CGALWRAPPER_API BOOL Intersections_Geometry_EIK_DoIntersect_RaySegment(void* ray, void* segment); CGALWRAPPER_API BOOL Intersections_Geometry_EIK_DoIntersect_RayTriangle(void* ray, void* triangle); CGALWRAPPER_API BOOL Intersections_Geometry_EIK_DoIntersect_RayBox(void* ray, void* box); /***************************************************** * * * void* DoIntersect Functions * * * ******************************************************/ CGALWRAPPER_API BOOL Intersections_Geometry_EIK_DoIntersect_SegmentPoint(void* segment, void* point); CGALWRAPPER_API BOOL Intersections_Geometry_EIK_DoIntersect_SegmentLine(void* segment, void* line); CGALWRAPPER_API BOOL Intersections_Geometry_EIK_DoIntersect_SegmentRay(void* segment, void* ray); CGALWRAPPER_API BOOL Intersections_Geometry_EIK_DoIntersect_SegmentSegment(void* segment, void* segment2); CGALWRAPPER_API BOOL Intersections_Geometry_EIK_DoIntersect_SegmentTriangle(void* segment, void* triangle); CGALWRAPPER_API BOOL Intersections_Geometry_EIK_DoIntersect_SegmentBox(void* segment, void* box); /***************************************************** * * * void* DoIntersect Functions * * * ******************************************************/ CGALWRAPPER_API BOOL Intersections_Geometry_EIK_DoIntersect_TrianglePoint(void* triangle, void* point); CGALWRAPPER_API BOOL Intersections_Geometry_EIK_DoIntersect_TriangleLine(void* triangle, void* line); CGALWRAPPER_API BOOL Intersections_Geometry_EIK_DoIntersect_TriangleRay(void* triangle, void* ray); CGALWRAPPER_API BOOL Intersections_Geometry_EIK_DoIntersect_TriangleSegment(void* triangle, void* segment); CGALWRAPPER_API BOOL Intersections_Geometry_EIK_DoIntersect_TriangleTriangle(void* triangle, void* triangle2); CGALWRAPPER_API BOOL Intersections_Geometry_EIK_DoIntersect_TriangleBox(void* triangle, void* box); /***************************************************** * * * void* DoIntersect Functions * * * ******************************************************/ CGALWRAPPER_API BOOL Intersections_Geometry_EIK_DoIntersect_BoxPoint(void* box, void* point); CGALWRAPPER_API BOOL Intersections_Geometry_EIK_DoIntersect_BoxLine(void* box, void* line); CGALWRAPPER_API BOOL Intersections_Geometry_EIK_DoIntersect_BoxRay(void* box, void* ray); CGALWRAPPER_API BOOL Intersections_Geometry_EIK_DoIntersect_BoxSegment(void* box, void* segment); CGALWRAPPER_API BOOL Intersections_Geometry_EIK_DoIntersect_BoxTriangle(void* box, void* triangle); CGALWRAPPER_API BOOL Intersections_Geometry_EIK_DoIntersect_BoxBox(void* box, void* box2); /***************************************************** * * * void* Intersection Functions * * * ******************************************************/ CGALWRAPPER_API IntersectionResult2d Intersections_Geometry_EIK_Intersection_PointLine(void* point, void* line); CGALWRAPPER_API IntersectionResult2d Intersections_Geometry_EIK_Intersection_PointRay(void* point, void* ray); CGALWRAPPER_API IntersectionResult2d Intersections_Geometry_EIK_Intersection_PointSegment(void* point, void* segment); CGALWRAPPER_API IntersectionResult2d Intersections_Geometry_EIK_Intersection_PointTriangle(void* point, void* triangle); CGALWRAPPER_API IntersectionResult2d Intersections_Geometry_EIK_Intersection_PointBox(void* point, void* box); /***************************************************** * * * void* Intersection Functions * * * ******************************************************/ CGALWRAPPER_API IntersectionResult2d Intersections_Geometry_EIK_Intersection_LinePoint(void* line, void* point); CGALWRAPPER_API IntersectionResult2d Intersections_Geometry_EIK_Intersection_LineLine(void* line, void* line2); CGALWRAPPER_API IntersectionResult2d Intersections_Geometry_EIK_Intersection_LineRay(void* line, void* ray); CGALWRAPPER_API IntersectionResult2d Intersections_Geometry_EIK_Intersection_LineSegment(void* line, void* segment); CGALWRAPPER_API IntersectionResult2d Intersections_Geometry_EIK_Intersection_LineTriangle(void* line, void* triangle); CGALWRAPPER_API IntersectionResult2d Intersections_Geometry_EIK_Intersection_LineBox(void* line, void* box); /***************************************************** * * * void* Intersection Functions * * * ******************************************************/ CGALWRAPPER_API IntersectionResult2d Intersections_Geometry_EIK_Intersection_RayPoint(void* ray, void* point); CGALWRAPPER_API IntersectionResult2d Intersections_Geometry_EIK_Intersection_RayLine(void* ray, void* line); CGALWRAPPER_API IntersectionResult2d Intersections_Geometry_EIK_Intersection_RayRay(void* ray, void* ray2); CGALWRAPPER_API IntersectionResult2d Intersections_Geometry_EIK_Intersection_RaySegment(void* ray, void* segment); CGALWRAPPER_API IntersectionResult2d Intersections_Geometry_EIK_Intersection_RayTriangle(void* ray, void* triangle); CGALWRAPPER_API IntersectionResult2d Intersections_Geometry_EIK_Intersection_RayBox(void* ray, void* box); /***************************************************** * * * void* Intersection Functions * * * ******************************************************/ CGALWRAPPER_API IntersectionResult2d Intersections_Geometry_EIK_Intersection_SegmentPoint(void* segment, void* point); CGALWRAPPER_API IntersectionResult2d Intersections_Geometry_EIK_Intersection_SegmentLine(void* segment, void* line); CGALWRAPPER_API IntersectionResult2d Intersections_Geometry_EIK_Intersection_SegmentRay(void* segment, void* ray); CGALWRAPPER_API IntersectionResult2d Intersections_Geometry_EIK_Intersection_SegmentSegment(void* segment, void* segment2); CGALWRAPPER_API IntersectionResult2d Intersections_Geometry_EIK_Intersection_SegmentTriangle(void* segment, void* triangle); CGALWRAPPER_API IntersectionResult2d Intersections_Geometry_EIK_Intersection_SegmentBox(void* segment, void* box); /***************************************************** * * * void* Intersection Functions * * * ******************************************************/ CGALWRAPPER_API IntersectionResult2d Intersections_Geometry_EIK_Intersection_TrianglePoint(void* triangle, void* point); CGALWRAPPER_API IntersectionResult2d Intersections_Geometry_EIK_Intersection_TriangleLine(void* triangle, void* line); CGALWRAPPER_API IntersectionResult2d Intersections_Geometry_EIK_Intersection_TriangleRay(void* triangle, void* ray); CGALWRAPPER_API IntersectionResult2d Intersections_Geometry_EIK_Intersection_TriangleSegment(void* triangle, void* segment); CGALWRAPPER_API IntersectionResult2d Intersections_Geometry_EIK_Intersection_TriangleTriangle(void* triangle, void* triangle2); CGALWRAPPER_API IntersectionResult2d Intersections_Geometry_EIK_Intersection_TriangleBox(void* triangle, void* box); /***************************************************** * * * void* Intersection Functions * * * ******************************************************/ CGALWRAPPER_API IntersectionResult2d Intersections_Geometry_EIK_Intersection_BoxPoint(void* box, void* point); CGALWRAPPER_API IntersectionResult2d Intersections_Geometry_EIK_Intersection_BoxLine(void* box, void* line); CGALWRAPPER_API IntersectionResult2d Intersections_Geometry_EIK_Intersection_BoxRay(void* box, void* ray); CGALWRAPPER_API IntersectionResult2d Intersections_Geometry_EIK_Intersection_BoxSegment(void* box, void* segment); CGALWRAPPER_API IntersectionResult2d Intersections_Geometry_EIK_Intersection_BoxTriangle(void* box, void* triangle); CGALWRAPPER_API IntersectionResult2d Intersections_Geometry_EIK_Intersection_BoxBox(void* box, void* box2); /***************************************************** * * * void* SqrDistance Functions * * * ******************************************************/ CGALWRAPPER_API double Intersections_Geometry_EIK_SqrDistance_PointPoint(void* point, void* point2); CGALWRAPPER_API double Intersections_Geometry_EIK_SqrDistance_PointLine(void* point, void* line); CGALWRAPPER_API double Intersections_Geometry_EIK_SqrDistance_PointRay(void* point, void* ray); CGALWRAPPER_API double Intersections_Geometry_EIK_SqrDistance_PointSegment(void* point, void* segment); CGALWRAPPER_API double Intersections_Geometry_EIK_SqrDistance_PointTriangle(void* point, void* triangle); /***************************************************** * * * void* SqrDistance Functions * * * ******************************************************/ CGALWRAPPER_API double Intersections_Geometry_EIK_SqrDistance_LinePoint(void* line, void* point); CGALWRAPPER_API double Intersections_Geometry_EIK_SqrDistance_LineLine(void* line, void* line2); CGALWRAPPER_API double Intersections_Geometry_EIK_SqrDistance_LineRay(void* line, void* ray); CGALWRAPPER_API double Intersections_Geometry_EIK_SqrDistance_LineSegment(void* line, void* segment); CGALWRAPPER_API double Intersections_Geometry_EIK_SqrDistance_LineTriangle(void* line, void* triangle); /***************************************************** * * * void* SqrDistance Functions * * * ******************************************************/ CGALWRAPPER_API double Intersections_Geometry_EIK_SqrDistance_RayPoint(void* ray, void* point); CGALWRAPPER_API double Intersections_Geometry_EIK_SqrDistance_RayLine(void* ray, void* line); CGALWRAPPER_API double Intersections_Geometry_EIK_SqrDistance_RayRay(void* ray, void* ray2); CGALWRAPPER_API double Intersections_Geometry_EIK_SqrDistance_RaySegment(void* ray, void* segment); CGALWRAPPER_API double Intersections_Geometry_EIK_SqrDistance_RayTriangle(void* ray, void* triangle); /***************************************************** * * * void* SqrDistance Functions * * * ******************************************************/ CGALWRAPPER_API double Intersections_Geometry_EIK_SqrDistance_SegmentPoint(void* segment, void* point); CGALWRAPPER_API double Intersections_Geometry_EIK_SqrDistance_SegmentLine(void* segment, void* line); CGALWRAPPER_API double Intersections_Geometry_EIK_SqrDistance_SegmentRay(void* segment, void* ray); CGALWRAPPER_API double Intersections_Geometry_EIK_SqrDistance_SegmentSegment(void* segment, void* segment2); CGALWRAPPER_API double Intersections_Geometry_EIK_SqrDistance_SegmentTriangle(void* segment, void* triangle); /***************************************************** * * * void* SqrDistance Functions * * * ******************************************************/ CGALWRAPPER_API double Intersections_Geometry_EIK_SqrDistance_TrianglePoint(void* triangle, void* point); CGALWRAPPER_API double Intersections_Geometry_EIK_SqrDistance_TriangleLine(void* triangle, void* line); CGALWRAPPER_API double Intersections_Geometry_EIK_SqrDistance_TriangleRay(void* triangle, void* ray); CGALWRAPPER_API double Intersections_Geometry_EIK_SqrDistance_TriangleSegment(void* triangle, void* segment); CGALWRAPPER_API double Intersections_Geometry_EIK_SqrDistance_TriangleTriangle(void* triangle, void* triangle2); }; ================================================ FILE: CGALWrapper/Geometry/Intersections_shapes.h ================================================ #pragma once #include "../CGALWrapper.h" #include "Geometry2.h" #include "IntersectionResult.h" #include #include #include #include #include #include #include #include #include template class Intersections_Shapes { typedef CGAL::Point_2 Point2; typedef CGAL::Line_2 Line2; typedef CGAL::Ray_2 Ray2; typedef CGAL::Segment_2 Segment2; typedef CGAL::Triangle_2 Triangle2; typedef CGAL::Iso_rectangle_2 Box2; typedef std::vector Polygon2; public: /***************************************************** * * * Point2d DoIntersect Functions * * * ******************************************************/ static BOOL DoIntersect(Point2d point, Line2d line) { auto p = point.ToCGAL(); auto l = line.ToCGAL(); return CGAL::do_intersect(p, l); } static BOOL DoIntersect(Point2d point, Ray2d ray) { auto p = point.ToCGAL(); auto r = ray.ToCGAL(); return CGAL::do_intersect(p, r); } static BOOL DoIntersect(Point2d point, Segment2d segment) { auto p = point.ToCGAL(); auto s = segment.ToCGAL(); return CGAL::do_intersect(p, s); } static BOOL DoIntersect(Point2d point, Triangle2d triangle) { auto p = point.ToCGAL(); auto t = triangle.ToCGAL(); return CGAL::do_intersect(p, t); } static BOOL DoIntersect(Point2d point, Box2d box) { auto p = point.ToCGAL(); auto b = box.ToCGAL(); return CGAL::do_intersect(p, b); } /***************************************************** * * * Line2d DoIntersect Functions * * * ******************************************************/ static BOOL DoIntersect(Line2d line, Point2d point) { auto p = point.ToCGAL(); auto l = line.ToCGAL(); return CGAL::do_intersect(p, l); } static BOOL DoIntersect(Line2d line, Line2d line2) { auto l = line.ToCGAL(); auto l2 = line2.ToCGAL(); return CGAL::do_intersect(l, l2); } static BOOL DoIntersect(Line2d line, Ray2d ray) { auto l = line.ToCGAL(); auto r = ray.ToCGAL(); return CGAL::do_intersect(l, r); } static BOOL DoIntersect(Line2d line, Segment2d segment) { auto l = line.ToCGAL(); auto s = segment.ToCGAL(); return CGAL::do_intersect(l, s); } static BOOL DoIntersect(Line2d line, Triangle2d triangle) { auto l = line.ToCGAL(); auto t = triangle.ToCGAL(); return CGAL::do_intersect(l, t); } static BOOL DoIntersect(Line2d line, Box2d box) { auto l = line.ToCGAL(); auto b = box.ToCGAL(); return CGAL::do_intersect(l, b); } /***************************************************** * * * Ray2d DoIntersect Functions * * * ******************************************************/ static BOOL DoIntersect(Ray2d ray, Point2d point) { auto r = ray.ToCGAL(); auto p = point.ToCGAL(); return CGAL::do_intersect(r, p); } static BOOL DoIntersect(Ray2d ray, Line2d line) { auto r = ray.ToCGAL(); auto l = line.ToCGAL(); return CGAL::do_intersect(r, l); } static BOOL DoIntersect(Ray2d ray, Ray2d ray2) { auto r = ray.ToCGAL(); auto r2 = ray2.ToCGAL(); return CGAL::do_intersect(r, r2); } static BOOL DoIntersect(Ray2d ray, Segment2d segment) { auto r = ray.ToCGAL(); auto s = segment.ToCGAL(); return CGAL::do_intersect(r, s); } static BOOL DoIntersect(Ray2d ray, Triangle2d triangle) { auto r = ray.ToCGAL(); auto t = triangle.ToCGAL(); return CGAL::do_intersect(r, t); } static BOOL DoIntersect(Ray2d ray, Box2d box) { auto r = ray.ToCGAL(); auto b = box.ToCGAL(); return CGAL::do_intersect(r, b); } /***************************************************** * * * Segment2d DoIntersect Functions * * * ******************************************************/ static BOOL DoIntersect(Segment2d segment, Point2d point) { auto s = segment.ToCGAL(); auto p = point.ToCGAL(); return CGAL::do_intersect(s, p); } static BOOL DoIntersect(Segment2d segment, Line2d line) { auto s = segment.ToCGAL(); auto l = line.ToCGAL(); return CGAL::do_intersect(s, l); } static BOOL DoIntersect(Segment2d segment, Ray2d ray) { auto s = segment.ToCGAL(); auto r = ray.ToCGAL(); return CGAL::do_intersect(s, r); } static BOOL DoIntersect(Segment2d segment, Segment2d segment2) { auto s = segment.ToCGAL(); auto s2 = segment2.ToCGAL(); return CGAL::do_intersect(s, s2); } static BOOL DoIntersect(Segment2d segment, Triangle2d triangle) { auto s = segment.ToCGAL(); auto t = triangle.ToCGAL(); return CGAL::do_intersect(s, t); } static BOOL DoIntersect(Segment2d segment, Box2d box) { auto s = segment.ToCGAL(); auto b = box.ToCGAL(); return CGAL::do_intersect(s, b); } /***************************************************** * * * Triangle2d DoIntersect Functions * * * ******************************************************/ static BOOL DoIntersect(Triangle2d triangle, Point2d point) { auto t = triangle.ToCGAL(); auto p = point.ToCGAL(); return CGAL::do_intersect(t, p); } static BOOL DoIntersect(Triangle2d triangle, Line2d line) { auto t = triangle.ToCGAL(); auto l = line.ToCGAL(); return CGAL::do_intersect(t, l); } static BOOL DoIntersect(Triangle2d triangle, Ray2d ray) { auto t = triangle.ToCGAL(); auto r = ray.ToCGAL(); return CGAL::do_intersect(t, r); } static BOOL DoIntersect(Triangle2d triangle, Segment2d segment) { auto t = triangle.ToCGAL(); auto s = segment.ToCGAL(); return CGAL::do_intersect(t, s); } static BOOL DoIntersect(Triangle2d triangle, Triangle2d triangle2) { auto t = triangle.ToCGAL(); auto t2 = triangle2.ToCGAL(); return CGAL::do_intersect(t, t2); } static BOOL DoIntersect(Triangle2d triangle, Box2d box) { auto t = triangle.ToCGAL(); auto b = box.ToCGAL(); return CGAL::do_intersect(t, b); } /***************************************************** * * * Box2d DoIntersect Functions * * * ******************************************************/ static BOOL DoIntersect(Box2d box, Point2d point) { auto b = box.ToCGAL(); auto p = point.ToCGAL(); return CGAL::do_intersect(b, p); } static BOOL DoIntersect(Box2d box, Line2d line) { auto b = box.ToCGAL(); auto l = line.ToCGAL(); return CGAL::do_intersect(b, l); } static BOOL DoIntersect(Box2d box, Ray2d ray) { auto b = box.ToCGAL(); auto r = ray.ToCGAL(); return CGAL::do_intersect(b, r); } static BOOL DoIntersect(Box2d box, Segment2d segment) { auto b = box.ToCGAL(); auto s = segment.ToCGAL(); return CGAL::do_intersect(b, s); } static BOOL DoIntersect(Box2d box, Triangle2d triangle) { auto b = box.ToCGAL(); auto t = triangle.ToCGAL(); return CGAL::do_intersect(b, t); } static BOOL DoIntersect(Box2d box, Box2d box2) { auto b = box.ToCGAL(); auto b2 = box2.ToCGAL(); return CGAL::do_intersect(b, b2); } /***************************************************** * * * Point2d Intersection Functions * * * ******************************************************/ static IntersectionResult2d Intersection(Point2d point, Line2d line) { auto p = point.ToCGAL(); auto l = line.ToCGAL(); return IntersectionResult::ToPoint(CGAL::intersection(p, l)); } static IntersectionResult2d Intersection(Point2d point, Ray2d ray) { auto p = point.ToCGAL(); auto r = ray.ToCGAL(); return IntersectionResult::ToPoint(CGAL::intersection(p, r)); } static IntersectionResult2d Intersection(Point2d point, Segment2d segment) { auto p = point.ToCGAL(); auto s = segment.ToCGAL(); return IntersectionResult::ToPoint(CGAL::intersection(p, s)); } static IntersectionResult2d Intersection(Point2d point, Triangle2d triangle) { auto p = point.ToCGAL(); auto t = triangle.ToCGAL(); return IntersectionResult::ToPoint(CGAL::intersection(p, t)); } static IntersectionResult2d Intersection(Point2d point, Box2d box) { auto p = point.ToCGAL(); auto b = box.ToCGAL(); return IntersectionResult::ToPoint(CGAL::intersection(p, b)); } /***************************************************** * * * Line2d Intersection Functions * * * ******************************************************/ static IntersectionResult2d Intersection(Line2d line, Point2d point) { auto p = point.ToCGAL(); auto l = line.ToCGAL(); return IntersectionResult::ToPoint(CGAL::intersection(p, l)); } static IntersectionResult2d Intersection(Line2d line, Line2d line2) { auto l = line.ToCGAL(); auto l2 = line2.ToCGAL(); return IntersectionResult::ToPointOrLine(CGAL::intersection(l, l2)); } static IntersectionResult2d Intersection(Line2d line, Ray2d ray) { auto l = line.ToCGAL(); auto r = ray.ToCGAL(); return IntersectionResult::ToPointOrRay(CGAL::intersection(l, r)); } static IntersectionResult2d Intersection(Line2d line, Segment2d segment) { auto l = line.ToCGAL(); auto s = segment.ToCGAL(); return IntersectionResult::ToPointOrSegment(CGAL::intersection(l, s)); } static IntersectionResult2d Intersection(Line2d line, Triangle2d triangle) { auto l = line.ToCGAL(); auto t = triangle.ToCGAL(); return IntersectionResult::ToPointOrSegment(CGAL::intersection(l, t)); } static IntersectionResult2d Intersection(Line2d line, Box2d box) { auto l = line.ToCGAL(); auto b = box.ToCGAL(); return IntersectionResult::ToPointOrSegment(CGAL::intersection(l, b)); } /***************************************************** * * * Ray2d Intersection Functions * * * ******************************************************/ static IntersectionResult2d Intersection(Ray2d ray, Point2d point) { auto r = ray.ToCGAL(); auto p = point.ToCGAL(); return IntersectionResult::ToPoint(CGAL::intersection(r, p)); } static IntersectionResult2d Intersection(Ray2d ray, Line2d line) { auto r = ray.ToCGAL(); auto l = line.ToCGAL(); return IntersectionResult::ToPointOrRay(CGAL::intersection(r, l)); } static IntersectionResult2d Intersection(Ray2d ray, Ray2d ray2) { auto r = ray.ToCGAL(); auto r2 = ray2.ToCGAL(); return IntersectionResult::ToPointSegmentOrRay(CGAL::intersection(r, r2)); } static IntersectionResult2d Intersection(Ray2d ray, Segment2d segment) { auto r = ray.ToCGAL(); auto s = segment.ToCGAL(); return IntersectionResult::ToPointOrSegment(CGAL::intersection(r, s)); } static IntersectionResult2d Intersection(Ray2d ray, Triangle2d triangle) { auto r = ray.ToCGAL(); auto t = triangle.ToCGAL(); return IntersectionResult::ToPointOrSegment(CGAL::intersection(r, t)); } static IntersectionResult2d Intersection(Ray2d ray, Box2d box) { auto r = ray.ToCGAL();; auto b = box.ToCGAL(); return IntersectionResult::ToPointOrSegment(CGAL::intersection(r, b)); } /***************************************************** * * * Segment2d Intersection Functions * * * ******************************************************/ static IntersectionResult2d Intersection(Segment2d segment, Point2d point) { auto s = segment.ToCGAL(); auto p = point.ToCGAL(); return IntersectionResult::ToPoint(CGAL::intersection(s, p)); } static IntersectionResult2d Intersection(Segment2d segment, Line2d line) { auto s = segment.ToCGAL(); auto l = line.ToCGAL(); return IntersectionResult::ToPointOrSegment(CGAL::intersection(s, l)); } static IntersectionResult2d Intersection(Segment2d segment, Ray2d ray) { auto s = segment.ToCGAL(); auto r = ray.ToCGAL(); return IntersectionResult::ToPointOrSegment(CGAL::intersection(s, r)); } static IntersectionResult2d Intersection(Segment2d segment, Segment2d segment2) { auto s = segment.ToCGAL(); auto s2 = segment2.ToCGAL(); return IntersectionResult::ToPointOrSegment(CGAL::intersection(s, s2)); } static IntersectionResult2d Intersection(Segment2d segment, Triangle2d triangle) { auto s = segment.ToCGAL(); auto t = triangle.ToCGAL(); return IntersectionResult::ToPointOrSegment(CGAL::intersection(s, t)); } static IntersectionResult2d Intersection(Segment2d segment, Box2d box) { auto s = segment.ToCGAL(); auto b = box.ToCGAL(); return IntersectionResult::ToPointOrSegment(CGAL::intersection(s, b)); } /***************************************************** * * * Triangle2d Intersection Functions * * * ******************************************************/ static IntersectionResult2d Intersection(Triangle2d triangle, Point2d point) { auto t = triangle.ToCGAL(); auto p = point.ToCGAL(); return IntersectionResult::ToPoint(CGAL::intersection(t, p)); } static IntersectionResult2d Intersection(Triangle2d triangle, Line2d line) { auto t = triangle.ToCGAL(); auto l = line.ToCGAL(); return IntersectionResult::ToPointOrSegment(CGAL::intersection(t, l)); } static IntersectionResult2d Intersection(Triangle2d triangle, Ray2d ray) { auto t = triangle.ToCGAL(); auto r = ray.ToCGAL(); return IntersectionResult::ToPointOrSegment(CGAL::intersection(t, r)); } static IntersectionResult2d Intersection(Triangle2d triangle, Segment2d segment) { auto t = triangle.ToCGAL(); auto s = segment.ToCGAL(); return IntersectionResult::ToPointOrSegment(CGAL::intersection(t, s)); } static IntersectionResult2d Intersection(Triangle2d triangle, Triangle2d triangle2) { auto t = triangle.ToCGAL(); auto t2 = triangle2.ToCGAL(); return IntersectionResult::ToPointSegmentTriangleOrPolygon(CGAL::intersection(t, t2)); } static IntersectionResult2d Intersection(Triangle2d triangle, Box2d box) { auto t = triangle.ToCGAL(); auto b = box.ToCGAL(); return IntersectionResult::ToPointSegmentTriangleOrPolygon(CGAL::intersection(t, b)); } /***************************************************** * * * Box2d Intersection Functions * * * ******************************************************/ static IntersectionResult2d Intersection(Box2d box, Point2d point) { auto b = box.ToCGAL(); auto p = point.ToCGAL(); return IntersectionResult::ToPoint(CGAL::intersection(b, p)); } static IntersectionResult2d Intersection(Box2d box, Line2d line) { auto b = box.ToCGAL();; auto l = line.ToCGAL(); return IntersectionResult::ToPointOrSegment(CGAL::intersection(b, l)); } static IntersectionResult2d Intersection(Box2d box, Ray2d ray) { auto b = box.ToCGAL(); auto r = ray.ToCGAL(); return IntersectionResult::ToPointOrSegment(CGAL::intersection(b, r)); } static IntersectionResult2d Intersection(Box2d box, Segment2d segment) { auto b = box.ToCGAL(); auto s = segment.ToCGAL(); return IntersectionResult::ToPointOrSegment(CGAL::intersection(b, s)); } static IntersectionResult2d Intersection(Box2d box, Triangle2d triangle) { auto b = box.ToCGAL(); auto t = triangle.ToCGAL(); return IntersectionResult::ToPointSegmentTriangleOrPolygon(CGAL::intersection(b, t)); } static IntersectionResult2d Intersection(Box2d box, Box2d box2) { auto b = box.ToCGAL(); auto b2 = box2.ToCGAL(); return IntersectionResult::ToBox(CGAL::intersection(b, b2)); } /***************************************************** * * * Point2d SqrDistance Functions * * * ******************************************************/ static double SqrDistance(Point2d point, Point2d point2) { auto p = point.ToCGAL(); auto p2 = point2.ToCGAL(); return CGAL::to_double(CGAL::squared_distance(p, p2)); } static double SqrDistance(Point2d point, Line2d line) { auto p = point.ToCGAL(); auto l = line.ToCGAL(); return CGAL::to_double(CGAL::squared_distance(p, l)); } static double SqrDistance(Point2d point, Ray2d ray) { auto p = point.ToCGAL(); auto r = ray.ToCGAL(); return CGAL::to_double(CGAL::squared_distance(p, r)); } static double SqrDistance(Point2d point, Segment2d segment) { auto p = point.ToCGAL(); auto s = segment.ToCGAL(); return CGAL::to_double(CGAL::squared_distance(p, s)); } static double SqrDistance(Point2d point, Triangle2d triangle) { auto p = point.ToCGAL(); auto t = triangle.ToCGAL(); return CGAL::to_double(CGAL::squared_distance(p, t)); } /***************************************************** * * * Line2d SqrDistance Functions * * * ******************************************************/ static double SqrDistance(Line2d line, Point2d point) { auto p = point.ToCGAL(); auto l = line.ToCGAL(); return CGAL::to_double(CGAL::squared_distance(p, l)); } static double SqrDistance(Line2d line, Line2d line2) { auto l = line.ToCGAL(); auto l2 = line2.ToCGAL(); return CGAL::to_double(CGAL::squared_distance(l, l2)); } static double SqrDistance(Line2d line, Ray2d ray) { auto l = line.ToCGAL(); auto r = ray.ToCGAL(); return CGAL::to_double(CGAL::squared_distance(l, r)); } static double SqrDistance(Line2d line, Segment2d segment) { auto l = line.ToCGAL(); auto s = segment.ToCGAL(); return CGAL::to_double(CGAL::squared_distance(l, s)); } static double SqrDistance(Line2d line, Triangle2d triangle) { auto l = line.ToCGAL(); auto t = triangle.ToCGAL(); return CGAL::to_double(CGAL::squared_distance(l, t)); } /***************************************************** * * * Ray2d SqrDistance Functions * * * ******************************************************/ static double SqrDistance(Ray2d ray, Point2d point) { auto r = ray.ToCGAL(); auto p = point.ToCGAL(); return CGAL::to_double(CGAL::squared_distance(r, p)); } static double SqrDistance(Ray2d ray, Line2d line) { auto r = ray.ToCGAL(); auto l = line.ToCGAL(); return CGAL::to_double(CGAL::squared_distance(r, l)); } static double SqrDistance(Ray2d ray, Ray2d ray2) { auto r = ray.ToCGAL(); auto r2 = ray2.ToCGAL(); return CGAL::to_double(CGAL::squared_distance(r, r2)); } static double SqrDistance(Ray2d ray, Segment2d segment) { auto r = ray.ToCGAL(); auto s = segment.ToCGAL(); return CGAL::to_double(CGAL::squared_distance(r, s)); } static double SqrDistance(Ray2d ray, Triangle2d triangle) { auto r = ray.ToCGAL(); auto t = triangle.ToCGAL(); return CGAL::to_double(CGAL::squared_distance(r, t)); } /***************************************************** * * * Segment2d SqrDistance Functions * * * ******************************************************/ static double SqrDistance(Segment2d segment, Point2d point) { auto s = segment.ToCGAL(); auto p = point.ToCGAL(); return CGAL::to_double(CGAL::squared_distance(s, p)); } static double SqrDistance(Segment2d segment, Line2d line) { auto s = segment.ToCGAL(); auto l = line.ToCGAL(); return CGAL::to_double(CGAL::squared_distance(s, l)); } static double SqrDistance(Segment2d segment, Ray2d ray) { auto s = segment.ToCGAL(); auto r = ray.ToCGAL(); return CGAL::to_double(CGAL::squared_distance(s, r)); } static double SqrDistance(Segment2d segment, Segment2d segment2) { auto s = segment.ToCGAL(); auto s2 = segment2.ToCGAL(); return CGAL::to_double(CGAL::squared_distance(s, s2)); } static double SqrDistance(Segment2d segment, Triangle2d triangle) { auto s = segment.ToCGAL(); auto t = triangle.ToCGAL(); return CGAL::to_double(CGAL::squared_distance(s, t)); } /***************************************************** * * * Triangle2d SqrDistance Functions * * * ******************************************************/ static double SqrDistance(Triangle2d triangle, Point2d point) { auto t = triangle.ToCGAL(); auto p = point.ToCGAL(); return CGAL::to_double(CGAL::squared_distance(t, p)); } static double SqrDistance(Triangle2d triangle, Line2d line) { auto t = triangle.ToCGAL(); auto l = line.ToCGAL(); return CGAL::to_double(CGAL::squared_distance(t, l)); } static double SqrDistance(Triangle2d triangle, Ray2d ray) { auto t = triangle.ToCGAL(); auto r = ray.ToCGAL(); return CGAL::to_double(CGAL::squared_distance(t, r)); } static double SqrDistance(Triangle2d triangle, Segment2d segment) { auto t = triangle.ToCGAL(); auto s = segment.ToCGAL(); return CGAL::to_double(CGAL::squared_distance(t, s)); } static double SqrDistance(Triangle2d triangle, Triangle2d triangle2) { auto t = triangle.ToCGAL(); auto t2 = triangle2.ToCGAL(); return CGAL::to_double(CGAL::squared_distance(t, t2)); } }; ================================================ FILE: CGALWrapper/Geometry/Intersections_shapes_EIK.cpp ================================================ #include "Intersections_shapes_EIK.h" #include "Intersections_shapes.h" /***************************************************** * * * Point2d DoIntersect Functions * * * ******************************************************/ BOOL Intersections_Shapes_EIK_DoIntersect_PointLine(Point2d point, Line2d line) { return Intersections_Shapes::DoIntersect(point, line); } BOOL Intersections_Shapes_EIK_DoIntersect_PointRay(Point2d point, Ray2d ray) { return Intersections_Shapes::DoIntersect(point, ray); } BOOL Intersections_Shapes_EIK_DoIntersect_PointSegment(Point2d point, Segment2d segment) { return Intersections_Shapes::DoIntersect(point, segment); } BOOL Intersections_Shapes_EIK_DoIntersect_PointTriangle(Point2d point, Triangle2d triangle) { return Intersections_Shapes::DoIntersect(point, triangle); } BOOL Intersections_Shapes_EIK_DoIntersect_PointBox(Point2d point, Box2d box) { return Intersections_Shapes::DoIntersect(point, box); } /***************************************************** * * * Line2d DoIntersect Functions * * * ******************************************************/ BOOL Intersections_Shapes_EIK_DoIntersect_LinePoint(Line2d line, Point2d point) { return Intersections_Shapes::DoIntersect(line, point); } BOOL Intersections_Shapes_EIK_DoIntersect_LineLine(Line2d line, Line2d line2) { return Intersections_Shapes::DoIntersect(line, line2); } BOOL Intersections_Shapes_EIK_DoIntersect_LineRay(Line2d line, Ray2d ray) { return Intersections_Shapes::DoIntersect(line, ray); } BOOL Intersections_Shapes_EIK_DoIntersect_LineSegment(Line2d line, Segment2d segment) { return Intersections_Shapes::DoIntersect(line, segment); } BOOL Intersections_Shapes_EIK_DoIntersect_LineTriangle(Line2d line, Triangle2d triangle) { return Intersections_Shapes::DoIntersect(line, triangle); } BOOL Intersections_Shapes_EIK_DoIntersect_LineBox(Line2d line, Box2d box) { return Intersections_Shapes::DoIntersect(line, box); } /***************************************************** * * * Ray2d DoIntersect Functions * * * ******************************************************/ BOOL Intersections_Shapes_EIK_DoIntersect_RayPoint(Ray2d ray, Point2d point) { return Intersections_Shapes::DoIntersect(ray, point); } BOOL Intersections_Shapes_EIK_DoIntersect_RayLine(Ray2d ray, Line2d line) { return Intersections_Shapes::DoIntersect(ray, line); } BOOL Intersections_Shapes_EIK_DoIntersect_RayRay(Ray2d ray, Ray2d ray2) { return Intersections_Shapes::DoIntersect(ray, ray2); } BOOL Intersections_Shapes_EIK_DoIntersect_RaySegment(Ray2d ray, Segment2d segment) { return Intersections_Shapes::DoIntersect(ray, segment); } BOOL Intersections_Shapes_EIK_DoIntersect_RayTriangle(Ray2d ray, Triangle2d triangle) { return Intersections_Shapes::DoIntersect(ray, triangle); } BOOL Intersections_Shapes_EIK_DoIntersect_RayBox(Ray2d ray, Box2d box) { return Intersections_Shapes::DoIntersect(ray, box); } /***************************************************** * * * Segment2d DoIntersect Functions * * * ******************************************************/ BOOL Intersections_Shapes_EIK_DoIntersect_SegmentPoint(Segment2d segment, Point2d point) { return Intersections_Shapes::DoIntersect(segment, point); } BOOL Intersections_Shapes_EIK_DoIntersect_SegmentLine(Segment2d segment, Line2d line) { return Intersections_Shapes::DoIntersect(segment, line); } BOOL Intersections_Shapes_EIK_DoIntersect_SegmentRay(Segment2d segment, Ray2d ray) { return Intersections_Shapes::DoIntersect(segment, ray); } BOOL Intersections_Shapes_EIK_DoIntersect_SegmentSegment(Segment2d segment, Segment2d segment2) { return Intersections_Shapes::DoIntersect(segment, segment2); } BOOL Intersections_Shapes_EIK_DoIntersect_SegmentTriangle(Segment2d segment, Triangle2d triangle) { return Intersections_Shapes::DoIntersect(segment, triangle); } BOOL Intersections_Shapes_EIK_DoIntersect_SegmentBox(Segment2d segment, Box2d box) { return Intersections_Shapes::DoIntersect(segment, box); } /***************************************************** * * * Triangle2d DoIntersect Functions * * * ******************************************************/ BOOL Intersections_Shapes_EIK_DoIntersect_TrianglePoint(Triangle2d triangle, Point2d point) { return Intersections_Shapes::DoIntersect(triangle, point); } BOOL Intersections_Shapes_EIK_DoIntersect_TriangleLine(Triangle2d triangle, Line2d line) { return Intersections_Shapes::DoIntersect(triangle, line); } BOOL Intersections_Shapes_EIK_DoIntersect_TriangleRay(Triangle2d triangle, Ray2d ray) { return Intersections_Shapes::DoIntersect(triangle, ray); } BOOL Intersections_Shapes_EIK_DoIntersect_TriangleSegment(Triangle2d triangle, Segment2d segment) { return Intersections_Shapes::DoIntersect(triangle, segment); } BOOL Intersections_Shapes_EIK_DoIntersect_TriangleTriangle(Triangle2d triangle, Triangle2d triangle2) { return Intersections_Shapes::DoIntersect(triangle, triangle2); } BOOL Intersections_Shapes_EIK_DoIntersect_TriangleBox(Triangle2d triangle, Box2d box) { return Intersections_Shapes::DoIntersect(triangle, box); } /***************************************************** * * * Box2d DoIntersect Functions * * * ******************************************************/ BOOL Intersections_Shapes_EIK_DoIntersect_BoxPoint(Box2d box, Point2d point) { return Intersections_Shapes::DoIntersect(box, point); } BOOL Intersections_Shapes_EIK_DoIntersect_BoxLine(Box2d box, Line2d line) { return Intersections_Shapes::DoIntersect(box, line); } BOOL Intersections_Shapes_EIK_DoIntersect_BoxRay(Box2d box, Ray2d ray) { return Intersections_Shapes::DoIntersect(box, ray); } BOOL Intersections_Shapes_EIK_DoIntersect_BoxSegment(Box2d box, Segment2d segment) { return Intersections_Shapes::DoIntersect(box, segment); } BOOL Intersections_Shapes_EIK_DoIntersect_BoxTriangle(Box2d box, Triangle2d triangle) { return Intersections_Shapes::DoIntersect(box, triangle); } BOOL Intersections_Shapes_EIK_DoIntersect_BoxBox(Box2d box, Box2d box2) { return Intersections_Shapes::DoIntersect(box, box2); } /***************************************************** * * * Point2d Intersection Functions * * * ******************************************************/ IntersectionResult2d Intersections_Shapes_EIK_Intersection_PointLine(Point2d point, Line2d line) { return Intersections_Shapes::Intersection(point, line); } IntersectionResult2d Intersections_Shapes_EIK_Intersection_PointRay(Point2d point, Ray2d ray) { return Intersections_Shapes::Intersection(point, ray); } IntersectionResult2d Intersections_Shapes_EIK_Intersection_PointSegment(Point2d point, Segment2d segment) { return Intersections_Shapes::Intersection(point, segment); } IntersectionResult2d Intersections_Shapes_EIK_Intersection_PointTriangle(Point2d point, Triangle2d triangle) { return Intersections_Shapes::Intersection(point, triangle); } IntersectionResult2d Intersections_Shapes_EIK_Intersection_PointBox(Point2d point, Box2d box) { return Intersections_Shapes::Intersection(point, box); } /***************************************************** * * * Line2d Intersection Functions * * * ******************************************************/ IntersectionResult2d Intersections_Shapes_EIK_Intersection_LinePoint(Line2d line, Point2d point) { return Intersections_Shapes::Intersection(point, line); } IntersectionResult2d Intersections_Shapes_EIK_Intersection_LineLine(Line2d line, Line2d line2) { return Intersections_Shapes::Intersection(line, line2); } IntersectionResult2d Intersections_Shapes_EIK_Intersection_LineRay(Line2d line, Ray2d ray) { return Intersections_Shapes::Intersection(line, ray); } IntersectionResult2d Intersections_Shapes_EIK_Intersection_LineSegment(Line2d line, Segment2d segment) { return Intersections_Shapes::Intersection(line, segment); } IntersectionResult2d Intersections_Shapes_EIK_Intersection_LineTriangle(Line2d line, Triangle2d triangle) { return Intersections_Shapes::Intersection(line, triangle); } IntersectionResult2d Intersections_Shapes_EIK_Intersection_LineBox(Line2d line, Box2d box) { return Intersections_Shapes::Intersection(line, box); } /***************************************************** * * * Ray2d Intersection Functions * * * ******************************************************/ IntersectionResult2d Intersections_Shapes_EIK_Intersection_RayPoint(Ray2d ray, Point2d point) { return Intersections_Shapes::Intersection(ray, point); } IntersectionResult2d Intersections_Shapes_EIK_Intersection_RayLine(Ray2d ray, Line2d line) { return Intersections_Shapes::Intersection(ray, line); } IntersectionResult2d Intersections_Shapes_EIK_Intersection_RayRay(Ray2d ray, Ray2d ray2) { return Intersections_Shapes::Intersection(ray, ray2); } IntersectionResult2d Intersections_Shapes_EIK_Intersection_RaySegment(Ray2d ray, Segment2d segment) { return Intersections_Shapes::Intersection(ray, segment); } IntersectionResult2d Intersections_Shapes_EIK_Intersection_RayTriangle(Ray2d ray, Triangle2d triangle) { return Intersections_Shapes::Intersection(ray, triangle); } IntersectionResult2d Intersections_Shapes_EIK_Intersection_RayBox(Ray2d ray, Box2d box) { return Intersections_Shapes::Intersection(ray, box); } /***************************************************** * * * Segment2d Intersection Functions * * * ******************************************************/ IntersectionResult2d Intersections_Shapes_EIK_Intersection_SegmentPoint(Segment2d segment, Point2d point) { return Intersections_Shapes::Intersection(segment, point); } IntersectionResult2d Intersections_Shapes_EIK_Intersection_SegmentLine(Segment2d segment, Line2d line) { return Intersections_Shapes::Intersection(segment, line); } IntersectionResult2d Intersections_Shapes_EIK_Intersection_SegmentRay(Segment2d segment, Ray2d ray) { return Intersections_Shapes::Intersection(segment, ray); } IntersectionResult2d Intersections_Shapes_EIK_Intersection_SegmentSegment(Segment2d segment, Segment2d segment2) { return Intersections_Shapes::Intersection(segment, segment); } IntersectionResult2d Intersections_Shapes_EIK_Intersection_SegmentTriangle(Segment2d segment, Triangle2d triangle) { return Intersections_Shapes::Intersection(segment, triangle); } IntersectionResult2d Intersections_Shapes_EIK_Intersection_SegmentBox(Segment2d segment, Box2d box) { return Intersections_Shapes::Intersection(segment, box); } /***************************************************** * * * Triangle2d Intersection Functions * * * ******************************************************/ IntersectionResult2d Intersections_Shapes_EIK_Intersection_TrianglePoint(Triangle2d triangle, Point2d point) { return Intersections_Shapes::Intersection(triangle, point); } IntersectionResult2d Intersections_Shapes_EIK_Intersection_TriangleLine(Triangle2d triangle, Line2d line) { return Intersections_Shapes::Intersection(triangle, line); } IntersectionResult2d Intersections_Shapes_EIK_Intersection_TriangleRay(Triangle2d triangle, Ray2d ray) { return Intersections_Shapes::Intersection(triangle, ray); } IntersectionResult2d Intersections_Shapes_EIK_Intersection_TriangleSegment(Triangle2d triangle, Segment2d segment) { return Intersections_Shapes::Intersection(triangle, segment); } IntersectionResult2d Intersections_Shapes_EIK_Intersection_TriangleTriangle(Triangle2d triangle, Triangle2d triangle2) { return Intersections_Shapes::Intersection(triangle, triangle2); } IntersectionResult2d Intersections_Shapes_EIK_Intersection_TriangleBox(Triangle2d triangle, Box2d box) { return Intersections_Shapes::Intersection(triangle, box); } /***************************************************** * * * Box2d Intersection Functions * * * ******************************************************/ IntersectionResult2d Intersections_Shapes_EIK_Intersection_BoxPoint(Box2d box, Point2d point) { return Intersections_Shapes::Intersection(box, point); } IntersectionResult2d Intersections_Shapes_EIK_Intersection_BoxLine(Box2d box, Line2d line) { return Intersections_Shapes::Intersection(box, line); } IntersectionResult2d Intersections_Shapes_EIK_Intersection_BoxRay(Box2d box, Ray2d ray) { return Intersections_Shapes::Intersection(box, ray); } IntersectionResult2d Intersections_Shapes_EIK_Intersection_BoxSegment(Box2d box, Segment2d segment) { return Intersections_Shapes::Intersection(box, segment); } IntersectionResult2d Intersections_Shapes_EIK_Intersection_BoxTriangle(Box2d box, Triangle2d triangle) { return Intersections_Shapes::Intersection(box, triangle); } IntersectionResult2d Intersections_Shapes_EIK_Intersection_BoxBox(Box2d box, Box2d box2) { return Intersections_Shapes::Intersection(box, box2); } /***************************************************** * * * Point2d SqrDistance Functions * * * ******************************************************/ double Intersections_Shapes_EIK_SqrDistance_PointPoint(Point2d point, Point2d point2) { return Intersections_Shapes::SqrDistance(point, point2); } double Intersections_Shapes_EIK_SqrDistance_PointLine(Point2d point, Line2d line) { return Intersections_Shapes::SqrDistance(point, line); } double Intersections_Shapes_EIK_SqrDistance_PointRay(Point2d point, Ray2d ray) { return Intersections_Shapes::SqrDistance(point, ray); } double Intersections_Shapes_EIK_SqrDistance_PointSegment(Point2d point, Segment2d segment) { return Intersections_Shapes::SqrDistance(point, segment); } double Intersections_Shapes_EIK_SqrDistance_PointTriangle(Point2d point, Triangle2d triangle) { return Intersections_Shapes::SqrDistance(point, triangle); } /***************************************************** * * * Line2d SqrDistance Functions * * * ******************************************************/ double Intersections_Shapes_EIK_SqrDistance_LinePoint(Line2d line, Point2d point) { return Intersections_Shapes::SqrDistance(line, point); } double Intersections_Shapes_EIK_SqrDistance_LineLine(Line2d line, Line2d line2) { return Intersections_Shapes::SqrDistance(line, line2); } double Intersections_Shapes_EIK_SqrDistance_LineRay(Line2d line, Ray2d ray) { return Intersections_Shapes::SqrDistance(line, ray); } double Intersections_Shapes_EIK_SqrDistance_LineSegment(Line2d line, Segment2d segment) { return Intersections_Shapes::SqrDistance(line, segment); } double Intersections_Shapes_EIK_SqrDistance_LineTriangle(Line2d line, Triangle2d triangle) { return Intersections_Shapes::SqrDistance(line, triangle); } /***************************************************** * * * Ray2d SqrDistance Functions * * * ******************************************************/ double Intersections_Shapes_EIK_SqrDistance_RayPoint(Ray2d ray, Point2d point) { return Intersections_Shapes::SqrDistance(ray, point); } double Intersections_Shapes_EIK_SqrDistance_RayLine(Ray2d ray, Line2d line) { return Intersections_Shapes::SqrDistance(ray, line); } double Intersections_Shapes_EIK_SqrDistance_RayRay(Ray2d ray, Ray2d ray2) { return Intersections_Shapes::SqrDistance(ray, ray2); } double Intersections_Shapes_EIK_SqrDistance_RaySegment(Ray2d ray, Segment2d segment) { return Intersections_Shapes::SqrDistance(ray, segment); } double Intersections_Shapes_EIK_SqrDistance_RayTriangle(Ray2d ray, Triangle2d triangle) { return Intersections_Shapes::SqrDistance(ray, triangle); } /***************************************************** * * * Segment2d SqrDistance Functions * * * ******************************************************/ double Intersections_Shapes_EIK_SqrDistance_SegmentPoint(Segment2d segment, Point2d point) { return Intersections_Shapes::SqrDistance(segment, point); } double Intersections_Shapes_EIK_SqrDistance_SegmentLine(Segment2d segment, Line2d line) { return Intersections_Shapes::SqrDistance(segment, line); } double Intersections_Shapes_EIK_SqrDistance_SegmentRay(Segment2d segment, Ray2d ray) { return Intersections_Shapes::SqrDistance(segment, ray); } double Intersections_Shapes_EIK_SqrDistance_SegmentSegment(Segment2d segment, Segment2d segment2) { return Intersections_Shapes::SqrDistance(segment, segment2); } double Intersections_Shapes_EIK_SqrDistance_SegmentTriangle(Segment2d segment, Triangle2d triangle) { return Intersections_Shapes::SqrDistance(segment, triangle); } /***************************************************** * * * Triangle2d SqrDistance Functions * * * ******************************************************/ double Intersections_Shapes_EIK_SqrDistance_TrianglePoint(Triangle2d triangle, Point2d point) { return Intersections_Shapes::SqrDistance(triangle, point); } double Intersections_Shapes_EIK_SqrDistance_TriangleLine(Triangle2d triangle, Line2d line) { return Intersections_Shapes::SqrDistance(triangle, line); } double Intersections_Shapes_EIK_SqrDistance_TriangleRay(Triangle2d triangle, Ray2d ray) { return Intersections_Shapes::SqrDistance(triangle, ray); } double Intersections_Shapes_EIK_SqrDistance_TriangleSegment(Triangle2d triangle, Segment2d segment) { return Intersections_Shapes::SqrDistance(triangle, segment); } double Intersections_Shapes_EIK_SqrDistance_TriangleTriangle(Triangle2d triangle, Triangle2d triangle2) { return Intersections_Shapes::SqrDistance(triangle, triangle2); } ================================================ FILE: CGALWrapper/Geometry/Intersections_shapes_EIK.h ================================================ #pragma once #include "../CGALWrapper.h" #include "Geometry2.h" #include "Intersections_shapes.h" #include #include extern "C" { /***************************************************** * * * Point2d DoIntersect Functions * * * ******************************************************/ CGALWRAPPER_API BOOL Intersections_Shapes_EIK_DoIntersect_PointLine(Point2d point, Line2d line); CGALWRAPPER_API BOOL Intersections_Shapes_EIK_DoIntersect_PointRay(Point2d point, Ray2d ray); CGALWRAPPER_API BOOL Intersections_Shapes_EIK_DoIntersect_PointSegment(Point2d point, Segment2d segment); CGALWRAPPER_API BOOL Intersections_Shapes_EIK_DoIntersect_PointTriangle(Point2d point, Triangle2d triangle); CGALWRAPPER_API BOOL Intersections_Shapes_EIK_DoIntersect_PointBox(Point2d point, Box2d box); /***************************************************** * * * Line2d DoIntersect Functions * * * ******************************************************/ CGALWRAPPER_API BOOL Intersections_Shapes_EIK_DoIntersect_LinePoint(Line2d line, Point2d point); CGALWRAPPER_API BOOL Intersections_Shapes_EIK_DoIntersect_LineLine(Line2d line, Line2d line2); CGALWRAPPER_API BOOL Intersections_Shapes_EIK_DoIntersect_LineRay(Line2d line, Ray2d ray); CGALWRAPPER_API BOOL Intersections_Shapes_EIK_DoIntersect_LineSegment(Line2d line, Segment2d segment); CGALWRAPPER_API BOOL Intersections_Shapes_EIK_DoIntersect_LineTriangle(Line2d line, Triangle2d triangle); CGALWRAPPER_API BOOL Intersections_Shapes_EIK_DoIntersect_LineBox(Line2d line, Box2d box); /***************************************************** * * * Ray2d DoIntersect Functions * * * ******************************************************/ CGALWRAPPER_API BOOL Intersections_Shapes_EIK_DoIntersect_RayPoint(Ray2d ray, Point2d point); CGALWRAPPER_API BOOL Intersections_Shapes_EIK_DoIntersect_RayLine(Ray2d ray, Line2d line); CGALWRAPPER_API BOOL Intersections_Shapes_EIK_DoIntersect_RayRay(Ray2d ray, Ray2d ray2); CGALWRAPPER_API BOOL Intersections_Shapes_EIK_DoIntersect_RaySegment(Ray2d ray, Segment2d segment); CGALWRAPPER_API BOOL Intersections_Shapes_EIK_DoIntersect_RayTriangle(Ray2d ray, Triangle2d triangle); CGALWRAPPER_API BOOL Intersections_Shapes_EIK_DoIntersect_RayBox(Ray2d ray, Box2d box); /***************************************************** * * * Segment2d DoIntersect Functions * * * ******************************************************/ CGALWRAPPER_API BOOL Intersections_Shapes_EIK_DoIntersect_SegmentPoint(Segment2d segment, Point2d point); CGALWRAPPER_API BOOL Intersections_Shapes_EIK_DoIntersect_SegmentLine(Segment2d segment, Line2d line); CGALWRAPPER_API BOOL Intersections_Shapes_EIK_DoIntersect_SegmentRay(Segment2d segment, Ray2d ray); CGALWRAPPER_API BOOL Intersections_Shapes_EIK_DoIntersect_SegmentSegment(Segment2d segment, Segment2d segment2); CGALWRAPPER_API BOOL Intersections_Shapes_EIK_DoIntersect_SegmentTriangle(Segment2d segment, Triangle2d triangle); CGALWRAPPER_API BOOL Intersections_Shapes_EIK_DoIntersect_SegmentBox(Segment2d segment, Box2d box); /***************************************************** * * * Triangle2d DoIntersect Functions * * * ******************************************************/ CGALWRAPPER_API BOOL Intersections_Shapes_EIK_DoIntersect_TrianglePoint(Triangle2d triangle, Point2d point); CGALWRAPPER_API BOOL Intersections_Shapes_EIK_DoIntersect_TriangleLine(Triangle2d triangle, Line2d line); CGALWRAPPER_API BOOL Intersections_Shapes_EIK_DoIntersect_TriangleRay(Triangle2d triangle, Ray2d ray); CGALWRAPPER_API BOOL Intersections_Shapes_EIK_DoIntersect_TriangleSegment(Triangle2d triangle, Segment2d segment); CGALWRAPPER_API BOOL Intersections_Shapes_EIK_DoIntersect_TriangleTriangle(Triangle2d triangle, Triangle2d triangle2); CGALWRAPPER_API BOOL Intersections_Shapes_EIK_DoIntersect_TriangleBox(Triangle2d triangle, Box2d box); /***************************************************** * * * Box2d DoIntersect Functions * * * ******************************************************/ CGALWRAPPER_API BOOL Intersections_Shapes_EIK_DoIntersect_BoxPoint(Box2d box, Point2d point); CGALWRAPPER_API BOOL Intersections_Shapes_EIK_DoIntersect_BoxLine(Box2d box, Line2d line); CGALWRAPPER_API BOOL Intersections_Shapes_EIK_DoIntersect_BoxRay(Box2d box, Ray2d ray); CGALWRAPPER_API BOOL Intersections_Shapes_EIK_DoIntersect_BoxSegment(Box2d box, Segment2d segment); CGALWRAPPER_API BOOL Intersections_Shapes_EIK_DoIntersect_BoxTriangle(Box2d box, Triangle2d triangle); CGALWRAPPER_API BOOL Intersections_Shapes_EIK_DoIntersect_BoxBox(Box2d box, Box2d box2); /***************************************************** * * * Point2d Intersection Functions * * * ******************************************************/ CGALWRAPPER_API IntersectionResult2d Intersections_Shapes_EIK_Intersection_PointLine(Point2d point, Line2d line); CGALWRAPPER_API IntersectionResult2d Intersections_Shapes_EIK_Intersection_PointRay(Point2d point, Ray2d ray); CGALWRAPPER_API IntersectionResult2d Intersections_Shapes_EIK_Intersection_PointSegment(Point2d point, Segment2d segment); CGALWRAPPER_API IntersectionResult2d Intersections_Shapes_EIK_Intersection_PointTriangle(Point2d point, Triangle2d triangle); CGALWRAPPER_API IntersectionResult2d Intersections_Shapes_EIK_Intersection_PointBox(Point2d point, Box2d box); /***************************************************** * * * Line2d Intersection Functions * * * ******************************************************/ CGALWRAPPER_API IntersectionResult2d Intersections_Shapes_EIK_Intersection_LinePoint(Line2d line, Point2d point); CGALWRAPPER_API IntersectionResult2d Intersections_Shapes_EIK_Intersection_LineLine(Line2d line, Line2d line2); CGALWRAPPER_API IntersectionResult2d Intersections_Shapes_EIK_Intersection_LineRay(Line2d line, Ray2d ray); CGALWRAPPER_API IntersectionResult2d Intersections_Shapes_EIK_Intersection_LineSegment(Line2d line, Segment2d segment); CGALWRAPPER_API IntersectionResult2d Intersections_Shapes_EIK_Intersection_LineTriangle(Line2d line, Triangle2d triangle); CGALWRAPPER_API IntersectionResult2d Intersections_Shapes_EIK_Intersection_LineBox(Line2d line, Box2d box); /***************************************************** * * * Ray2d Intersection Functions * * * ******************************************************/ CGALWRAPPER_API IntersectionResult2d Intersections_Shapes_EIK_Intersection_RayPoint(Ray2d ray, Point2d point); CGALWRAPPER_API IntersectionResult2d Intersections_Shapes_EIK_Intersection_RayLine(Ray2d ray, Line2d line); CGALWRAPPER_API IntersectionResult2d Intersections_Shapes_EIK_Intersection_RayRay(Ray2d ray, Ray2d ray2); CGALWRAPPER_API IntersectionResult2d Intersections_Shapes_EIK_Intersection_RaySegment(Ray2d ray, Segment2d segment); CGALWRAPPER_API IntersectionResult2d Intersections_Shapes_EIK_Intersection_RayTriangle(Ray2d ray, Triangle2d triangle); CGALWRAPPER_API IntersectionResult2d Intersections_Shapes_EIK_Intersection_RayBox(Ray2d ray, Box2d box); /***************************************************** * * * Segment2d Intersection Functions * * * ******************************************************/ CGALWRAPPER_API IntersectionResult2d Intersections_Shapes_EIK_Intersection_SegmentPoint(Segment2d segment, Point2d point); CGALWRAPPER_API IntersectionResult2d Intersections_Shapes_EIK_Intersection_SegmentLine(Segment2d segment, Line2d line); CGALWRAPPER_API IntersectionResult2d Intersections_Shapes_EIK_Intersection_SegmentRay(Segment2d segment, Ray2d ray); CGALWRAPPER_API IntersectionResult2d Intersections_Shapes_EIK_Intersection_SegmentSegment(Segment2d segment, Segment2d segment2); CGALWRAPPER_API IntersectionResult2d Intersections_Shapes_EIK_Intersection_SegmentTriangle(Segment2d segment, Triangle2d triangle); CGALWRAPPER_API IntersectionResult2d Intersections_Shapes_EIK_Intersection_SegmentBox(Segment2d segment, Box2d box); /***************************************************** * * * Triangle2d Intersection Functions * * * ******************************************************/ CGALWRAPPER_API IntersectionResult2d Intersections_Shapes_EIK_Intersection_TrianglePoint(Triangle2d triangle, Point2d point); CGALWRAPPER_API IntersectionResult2d Intersections_Shapes_EIK_Intersection_TriangleLine(Triangle2d triangle, Line2d line); CGALWRAPPER_API IntersectionResult2d Intersections_Shapes_EIK_Intersection_TriangleRay(Triangle2d triangle, Ray2d ray); CGALWRAPPER_API IntersectionResult2d Intersections_Shapes_EIK_Intersection_TriangleSegment(Triangle2d triangle, Segment2d segment); CGALWRAPPER_API IntersectionResult2d Intersections_Shapes_EIK_Intersection_TriangleTriangle(Triangle2d triangle, Triangle2d triangle2); CGALWRAPPER_API IntersectionResult2d Intersections_Shapes_EIK_Intersection_TriangleBox(Triangle2d triangle, Box2d box); /***************************************************** * * * Box2d Intersection Functions * * * ******************************************************/ CGALWRAPPER_API IntersectionResult2d Intersections_Shapes_EIK_Intersection_BoxPoint(Box2d box, Point2d point); CGALWRAPPER_API IntersectionResult2d Intersections_Shapes_EIK_Intersection_BoxLine(Box2d box, Line2d line); CGALWRAPPER_API IntersectionResult2d Intersections_Shapes_EIK_Intersection_BoxRay(Box2d box, Ray2d ray); CGALWRAPPER_API IntersectionResult2d Intersections_Shapes_EIK_Intersection_BoxSegment(Box2d box, Segment2d segment); CGALWRAPPER_API IntersectionResult2d Intersections_Shapes_EIK_Intersection_BoxTriangle(Box2d box, Triangle2d triangle); CGALWRAPPER_API IntersectionResult2d Intersections_Shapes_EIK_Intersection_BoxBox(Box2d box, Box2d box2); /***************************************************** * * * Point2d SqrDistance Functions * * * ******************************************************/ CGALWRAPPER_API double Intersections_Shapes_EIK_SqrDistance_PointPoint(Point2d point, Point2d point2); CGALWRAPPER_API double Intersections_Shapes_EIK_SqrDistance_PointLine(Point2d point, Line2d line); CGALWRAPPER_API double Intersections_Shapes_EIK_SqrDistance_PointRay(Point2d point, Ray2d ray); CGALWRAPPER_API double Intersections_Shapes_EIK_SqrDistance_PointSegment(Point2d point, Segment2d segment); CGALWRAPPER_API double Intersections_Shapes_EIK_SqrDistance_PointTriangle(Point2d point, Triangle2d triangle); /***************************************************** * * * Line2d SqrDistance Functions * * * ******************************************************/ CGALWRAPPER_API double Intersections_Shapes_EIK_SqrDistance_LinePoint(Line2d line, Point2d point); CGALWRAPPER_API double Intersections_Shapes_EIK_SqrDistance_LineLine(Line2d line, Line2d line2); CGALWRAPPER_API double Intersections_Shapes_EIK_SqrDistance_LineRay(Line2d line, Ray2d ray); CGALWRAPPER_API double Intersections_Shapes_EIK_SqrDistance_LineSegment(Line2d line, Segment2d segment); CGALWRAPPER_API double Intersections_Shapes_EIK_SqrDistance_LineTriangle(Line2d line, Triangle2d triangle); /***************************************************** * * * Ray2d SqrDistance Functions * * * ******************************************************/ CGALWRAPPER_API double Intersections_Shapes_EIK_SqrDistance_RayPoint(Ray2d ray, Point2d point); CGALWRAPPER_API double Intersections_Shapes_EIK_SqrDistance_RayLine(Ray2d ray, Line2d line); CGALWRAPPER_API double Intersections_Shapes_EIK_SqrDistance_RayRay(Ray2d ray, Ray2d ray2); CGALWRAPPER_API double Intersections_Shapes_EIK_SqrDistance_RaySegment(Ray2d ray, Segment2d segment); CGALWRAPPER_API double Intersections_Shapes_EIK_SqrDistance_RayTriangle(Ray2d ray, Triangle2d triangle); /***************************************************** * * * Segment2d SqrDistance Functions * * * ******************************************************/ CGALWRAPPER_API double Intersections_Shapes_EIK_SqrDistance_SegmentPoint(Segment2d segment, Point2d point); CGALWRAPPER_API double Intersections_Shapes_EIK_SqrDistance_SegmentLine(Segment2d segment, Line2d line); CGALWRAPPER_API double Intersections_Shapes_EIK_SqrDistance_SegmentRay(Segment2d segment, Ray2d ray); CGALWRAPPER_API double Intersections_Shapes_EIK_SqrDistance_SegmentSegment(Segment2d segment, Segment2d segment2); CGALWRAPPER_API double Intersections_Shapes_EIK_SqrDistance_SegmentTriangle(Segment2d segment, Triangle2d triangle); /***************************************************** * * * Triangle2d SqrDistance Functions * * * ******************************************************/ CGALWRAPPER_API double Intersections_Shapes_EIK_SqrDistance_TrianglePoint(Triangle2d triangle, Point2d point); CGALWRAPPER_API double Intersections_Shapes_EIK_SqrDistance_TriangleLine(Triangle2d triangle, Line2d line); CGALWRAPPER_API double Intersections_Shapes_EIK_SqrDistance_TriangleRay(Triangle2d triangle, Ray2d ray); CGALWRAPPER_API double Intersections_Shapes_EIK_SqrDistance_TriangleSegment(Triangle2d triangle, Segment2d segment); CGALWRAPPER_API double Intersections_Shapes_EIK_SqrDistance_TriangleTriangle(Triangle2d triangle, Triangle2d triangle2); }; ================================================ FILE: CGALWrapper/Geometry/Line2_EEK.cpp ================================================ #include "Line2_EEK.h" #include #include typedef CGAL::Line_2 Line2; typedef CGAL::Point_2 Point2; typedef CGAL::Aff_transformation_2 Transformation2; Point2* CastToPoint2(void* ptr); void* Line2_EEK_Create(double a, double b, double c) { return new Line2(a, b, c); } void* Line2_EEK_CreateFromPoints(const Point2d& p1, const Point2d& p2) { return new Line2(p1.ToCGAL(), p2.ToCGAL()); } void* Line2_EEK_CreateFromPointVector(const Point2d& p, const Vector2d& v) { return new Line2(p.ToCGAL(), v.ToCGAL()); } void Line2_EEK_Release(void* ptr) { auto obj = static_cast(ptr); if (obj != nullptr) { delete obj; obj = nullptr; } } Line2* NewLine2() { return new Line2(); } Line2* CastToLine2(void* ptr) { return static_cast(ptr); } double Line2_EEK_GetA(void* ptr) { auto line = CastToLine2(ptr); return CGAL::to_double(line->a()); } double Line2_EEK_GetB(void* ptr) { auto line = CastToLine2(ptr); return CGAL::to_double(line->b()); } double Line2_EEK_GetC(void* ptr) { auto line = CastToLine2(ptr); return CGAL::to_double(line->c()); } void Line2_EEK_SetA(void* ptr, double a) { auto line = CastToLine2(ptr); (*line) = Line2(a, line->b(), line->c()); } void Line2_EEK_SetB(void* ptr, double b) { auto line = CastToLine2(ptr); (*line) = Line2(line->a(), b, line->c()); } void Line2_EEK_SetC(void* ptr, double c) { auto line = CastToLine2(ptr); (*line) = Line2(line->a(), line->b(), c); } BOOL Line2_EEK_IsDegenerate(void* ptr) { auto line = CastToLine2(ptr); return line->is_degenerate(); } BOOL Line2_EEK_IsHorizontal(void* ptr) { auto line = CastToLine2(ptr); return line->is_horizontal(); } BOOL Line2_EEK_IsVertical(void* ptr) { auto line = CastToLine2(ptr); return line->is_vertical(); } BOOL Line2_EEK_HasOn(void* linePtr, const Point2d& point) { auto line = CastToLine2(linePtr); return line->has_on(point.ToCGAL()); } BOOL Line2_EEK_HasOnNegativeSide(void* linePtr, const Point2d& point) { auto line = CastToLine2(linePtr); return line->has_on_negative_side(point.ToCGAL()); } BOOL Line2_EEK_HasOnPositiveSide(void* linePtr, const Point2d& point) { auto line = CastToLine2(linePtr); return line->has_on_positive_side(point.ToCGAL()); } void* Line2_EEK_Opposite(void* ptr) { auto line = CastToLine2(ptr); auto nline = NewLine2(); (*nline) = line->opposite(); return nline; } void* Line2_EEK_Perpendicular(void* ptr, const Point2d& point) { auto line = CastToLine2(ptr); auto nline = NewLine2(); (*nline) = line->perpendicular(point.ToCGAL()); return nline; } double Line2_EEK_X_On_Y(void* ptr, double y) { auto line = CastToLine2(ptr); return CGAL::to_double(line->x_at_y(y)); } double Line2_EEK_Y_On_X(void* ptr, double x) { auto line = CastToLine2(ptr); return CGAL::to_double(line->y_at_x(x)); } Vector2d Line2_EEK_Vector(void* ptr) { auto line = CastToLine2(ptr); auto v = line->to_vector(); return Vector2d::FromCGAL(v); } void Line2_EEK_Transform(void* ptr, const Point2d& translation, double rotation, double scale) { auto line = CastToLine2(ptr); Transformation2 T(CGAL::TRANSLATION, translation.ToVector()); Transformation2 R(CGAL::ROTATION, sin(rotation), cos(rotation)); Transformation2 S(CGAL::SCALING, scale); (*line) = line->transform(T * R * S); } void* Line2_EEK_Copy(void* ptr) { auto l = CastToLine2(ptr); auto l2 = new Line2(); (*l2) = *l; return l2; } void* Line2_EEK_Convert(void* ptr) { typedef CGAL::Cartesian_converter Converter; Converter convert; auto l = CastToLine2(ptr); auto a = convert(l->a()); auto b = convert(l->b()); auto c = convert(l->c()); return new CGAL::Line_2(a, b, c); } template static void* Convert(Line2* l) { CGAL::Cartesian_converter convert; auto a = convert(l->a()); auto b = convert(l->b()); auto c = convert(l->c()); return new CGAL::Line_2(a, b, c); } void* Line2_EEK_Convert(void* ptr, CGAL_KERNEL k) { auto l = CastToLine2(ptr); switch (k) { case CGAL_KERNEL::EXACT_PREDICATES_INEXACT_CONSTRUCTION: return Convert(l); case CGAL_KERNEL::EXACT_PREDICATES_EXACT_CONSTRUCTION: return Convert(l); default: return Convert(l); } } ================================================ FILE: CGALWrapper/Geometry/Line2_EEK.h ================================================ #pragma once #include "../CGALWrapper.h" #include "../Geometry/Geometry2.h" #include "../Geometry/Point2_EEK.h" #include extern "C" { CGALWRAPPER_API void* Line2_EEK_Create(double a, double b, double c); CGALWRAPPER_API void* Line2_EEK_CreateFromPoints(const Point2d& p1, const Point2d& p2); CGALWRAPPER_API void* Line2_EEK_CreateFromPointVector(const Point2d& p, const Vector2d& v); CGALWRAPPER_API void Line2_EEK_Release(void* ptr); CGALWRAPPER_API double Line2_EEK_GetA(void* ptr); CGALWRAPPER_API double Line2_EEK_GetB(void* ptr); CGALWRAPPER_API double Line2_EEK_GetC(void* ptr); CGALWRAPPER_API void Line2_EEK_SetA(void* ptr, double a); CGALWRAPPER_API void Line2_EEK_SetB(void* ptr, double b); CGALWRAPPER_API void Line2_EEK_SetC(void* ptr, double c); CGALWRAPPER_API BOOL Line2_EEK_IsDegenerate(void* ptr); CGALWRAPPER_API BOOL Line2_EEK_IsHorizontal(void* ptr); CGALWRAPPER_API BOOL Line2_EEK_IsVertical(void* ptr); CGALWRAPPER_API BOOL Line2_EEK_HasOn(void* linePtr, const Point2d& point); CGALWRAPPER_API BOOL Line2_EEK_HasOnNegativeSide(void* linePtr, const Point2d& point); CGALWRAPPER_API BOOL Line2_EEK_HasOnPositiveSide(void* linePtr, const Point2d& point); CGALWRAPPER_API void* Line2_EEK_Opposite(void* ptr); CGALWRAPPER_API void* Line2_EEK_Perpendicular(void* ptr, const Point2d& point); CGALWRAPPER_API double Line2_EEK_X_On_Y(void* ptr, double y); CGALWRAPPER_API double Line2_EEK_Y_On_X(void* ptr, double x); CGALWRAPPER_API Vector2d Line2_EEK_Vector(void* ptr); CGALWRAPPER_API void Line2_EEK_Transform(void* ptr, const Point2d& translation, double rotation, double scale); CGALWRAPPER_API void* Line2_EEK_Copy(void* ptr); CGALWRAPPER_API void* Line2_EEK_Convert(void* ptr, CGAL_KERNEL k); } ================================================ FILE: CGALWrapper/Geometry/Line2_EIK.cpp ================================================ #include "Line2_EIK.h" #include #include typedef CGAL::Line_2 Line2; typedef CGAL::Point_2 Point2; typedef CGAL::Aff_transformation_2 Transformation2; Point2* CastToPoint2(void* ptr); void* Line2_EIK_Create(double a, double b, double c) { return new Line2(a, b, c); } void* Line2_EIK_CreateFromPoints(const Point2d& p1, const Point2d& p2) { return new Line2(p1.ToCGAL(), p2.ToCGAL()); } void* Line2_EIK_CreateFromPointVector(const Point2d& p, const Vector2d& v) { return new Line2(p.ToCGAL(), v.ToCGAL()); } void Line2_EIK_Release(void* ptr) { auto obj = static_cast(ptr); if (obj != nullptr) { delete obj; obj = nullptr; } } Line2* NewLine2() { return new Line2(); } Line2* CastToLine2(void* ptr) { return static_cast(ptr); } double Line2_EIK_GetA(void* ptr) { auto line = CastToLine2(ptr); return CGAL::to_double(line->a()); } double Line2_EIK_GetB(void* ptr) { auto line = CastToLine2(ptr); return CGAL::to_double(line->b()); } double Line2_EIK_GetC(void* ptr) { auto line = CastToLine2(ptr); return CGAL::to_double(line->c()); } void Line2_EIK_SetA(void* ptr, double a) { auto line = CastToLine2(ptr); (*line) = Line2(a, line->b(), line->c()); } void Line2_EIK_SetB(void* ptr, double b) { auto line = CastToLine2(ptr); (*line) = Line2(line->a(), b, line->c()); } void Line2_EIK_SetC(void* ptr, double c) { auto line = CastToLine2(ptr); (*line) = Line2(line->a(), line->b(), c); } BOOL Line2_EIK_IsDegenerate(void* ptr) { auto line = CastToLine2(ptr); return line->is_degenerate(); } BOOL Line2_EIK_IsHorizontal(void* ptr) { auto line = CastToLine2(ptr); return line->is_horizontal(); } BOOL Line2_EIK_IsVertical(void* ptr) { auto line = CastToLine2(ptr); return line->is_vertical(); } BOOL Line2_EIK_HasOn(void* linePtr, const Point2d& point) { auto line = CastToLine2(linePtr); return line->has_on(point.ToCGAL()); } BOOL Line2_EIK_HasOnNegativeSide(void* linePtr, const Point2d& point) { auto line = CastToLine2(linePtr); return line->has_on_negative_side(point.ToCGAL()); } BOOL Line2_EIK_HasOnPositiveSide(void* linePtr, const Point2d& point) { auto line = CastToLine2(linePtr); return line->has_on_positive_side(point.ToCGAL()); } void* Line2_EIK_Opposite(void* ptr) { auto line = CastToLine2(ptr); auto nline = NewLine2(); (*nline) = line->opposite(); return nline; } void* Line2_EIK_Perpendicular(void* ptr, const Point2d& point) { auto line = CastToLine2(ptr); auto nline = NewLine2(); (*nline) = line->perpendicular(point.ToCGAL()); return nline; } double Line2_EIK_X_On_Y(void* ptr, double y) { auto line = CastToLine2(ptr); return CGAL::to_double(line->x_at_y(y)); } double Line2_EIK_Y_On_X(void* ptr, double x) { auto line = CastToLine2(ptr); return CGAL::to_double(line->y_at_x(x)); } Vector2d Line2_EIK_Vector(void* ptr) { auto line = CastToLine2(ptr); auto v = line->to_vector(); return Vector2d::FromCGAL(v); } void Line2_EIK_Transform(void* ptr, const Point2d& translation, double rotation, double scale) { auto line = CastToLine2(ptr); Transformation2 T(CGAL::TRANSLATION, translation.ToVector()); Transformation2 R(CGAL::ROTATION, sin(rotation), cos(rotation)); Transformation2 S(CGAL::SCALING, scale); (*line) = line->transform(T * R * S); } void* Line2_EIK_Copy(void* ptr) { auto l = CastToLine2(ptr); auto l2 = new Line2(); (*l2) = *l; return l2; } template static void* Convert(Line2* l) { CGAL::Cartesian_converter convert; auto a = convert(l->a()); auto b = convert(l->b()); auto c = convert(l->c()); return new CGAL::Line_2(a, b, c); } void* Line2_EIK_Convert(void* ptr, CGAL_KERNEL k) { auto l = CastToLine2(ptr); switch (k) { case CGAL_KERNEL::EXACT_PREDICATES_INEXACT_CONSTRUCTION: return Convert(l); case CGAL_KERNEL::EXACT_PREDICATES_EXACT_CONSTRUCTION: return Convert(l); default: return Convert(l); } } ================================================ FILE: CGALWrapper/Geometry/Line2_EIK.h ================================================ #pragma once #include "../CGALWrapper.h" #include "../Geometry/Geometry2.h" #include "../Geometry/Point2_EIK.h" #include extern "C" { CGALWRAPPER_API void* Line2_EIK_Create(double a, double b, double c); CGALWRAPPER_API void* Line2_EIK_CreateFromPoints(const Point2d& p1, const Point2d& p2); CGALWRAPPER_API void* Line2_EIK_CreateFromPointVector(const Point2d& p, const Vector2d& v); CGALWRAPPER_API void Line2_EIK_Release(void* ptr); CGALWRAPPER_API double Line2_EIK_GetA(void* ptr); CGALWRAPPER_API double Line2_EIK_GetB(void* ptr); CGALWRAPPER_API double Line2_EIK_GetC(void* ptr); CGALWRAPPER_API void Line2_EIK_SetA(void* ptr, double a); CGALWRAPPER_API void Line2_EIK_SetB(void* ptr, double b); CGALWRAPPER_API void Line2_EIK_SetC(void* ptr, double c); CGALWRAPPER_API BOOL Line2_EIK_IsDegenerate(void* ptr); CGALWRAPPER_API BOOL Line2_EIK_IsHorizontal(void* ptr); CGALWRAPPER_API BOOL Line2_EIK_IsVertical(void* ptr); CGALWRAPPER_API BOOL Line2_EIK_HasOn(void* linePtr, const Point2d& point); CGALWRAPPER_API BOOL Line2_EIK_HasOnNegativeSide(void* linePtr, const Point2d& point); CGALWRAPPER_API BOOL Line2_EIK_HasOnPositiveSide(void* linePtr, const Point2d& point); CGALWRAPPER_API void* Line2_EIK_Opposite(void* ptr); CGALWRAPPER_API void* Line2_EIK_Perpendicular(void* ptr, const Point2d& point); CGALWRAPPER_API double Line2_EIK_X_On_Y(void* ptr, double y); CGALWRAPPER_API double Line2_EIK_Y_On_X(void* ptr, double x); CGALWRAPPER_API Vector2d Line2_EIK_Vector(void* ptr); CGALWRAPPER_API void Line2_EIK_Transform(void* ptr, const Point2d& translation, double rotation, double scale); CGALWRAPPER_API void* Line2_EIK_Copy(void* ptr); CGALWRAPPER_API void* Line2_EIK_Convert(void* ptr, CGAL_KERNEL k); } ================================================ FILE: CGALWrapper/Geometry/Matrices.h ================================================ #pragma once #include "../CGALWrapper.h" #include /* * Structs to pass data from C# and c++. * Must be c style layout. * * A standard-layout class is a class that: * * Has no non-static data members of type non-standard-layout class (or array of such types) or reference, * Has no virtual functions and no virtual base classes, * Has the same access control for all non-static data members, * Has no non-standard-layout base classes, * Either has no non-static data members in the most derived class and at most one base class with non-static data members, * or has no base classes with non-static data members, and * Has no base classes of the same type as the first non-static data member. * */ struct Matrix4x4d { double m00, m10, m20, m30; double m01, m11, m21, m31; double m02, m12, m22, m32; double m03, m13, m23, m33; template CGAL::Aff_transformation_3 ToCGAL() const { return CGAL::Aff_transformation_3( m00, m01, m02, m03, m10, m11, m12, m13, m20, m21, m22, m23, /*m30, m31, m32,*/ m33); } }; ================================================ FILE: CGALWrapper/Geometry/MinMax.h ================================================ #pragma once struct MinMax { double min; double max; }; struct MinMaxAvg { double min; double max; double avg; }; ================================================ FILE: CGALWrapper/Geometry/Point2_EEK.cpp ================================================ #include "Point2_EEK.h" #include #include typedef CGAL::Point_2 Point2; void* Point2_EEK_Create() { return new Point2(); } void* Point2_EEK_CreateFromPoint(const Point2d& point) { auto p = point.ToCGAL(); return new Point2(p.x(), p.y()); } void Point2_EEK_Release(void* ptr) { auto obj = static_cast(ptr); if (obj != nullptr) { delete obj; obj = nullptr; } } Point2* CastToPoint2(void* ptr) { return static_cast(ptr); } double Point2_EEK_GetX(void* ptr) { auto p = CastToPoint2(ptr); return CGAL::to_double(p->x()); } double Point2_EEK_GetY(void* ptr) { auto p = CastToPoint2(ptr); return CGAL::to_double(p->y()); } void Point2_EEK_SetX(void* ptr, double x) { auto p = CastToPoint2(ptr); (*p) = Point2(x, p->y()); } void Point2_EEK_SetY(void* ptr, double y) { auto p = CastToPoint2(ptr); (*p) = Point2(p->x(), y); } void* Point2_EEK_Copy(void* ptr) { auto p = CastToPoint2(ptr); auto p2 = new Point2(); (*p2) = *p; return p2; } template static void* Convert(Point2* p) { CGAL::Cartesian_converter convert; auto x = convert((*p)[0]); auto y = convert((*p)[1]); return new CGAL::Point_2(x, y); } void* Point2_EEK_Convert(void* ptr, CGAL_KERNEL k) { auto p = CastToPoint2(ptr); switch (k) { case CGAL_KERNEL::EXACT_PREDICATES_INEXACT_CONSTRUCTION: return Convert(p); case CGAL_KERNEL::EXACT_PREDICATES_EXACT_CONSTRUCTION: return Convert(p); default: return Convert(p); } } ================================================ FILE: CGALWrapper/Geometry/Point2_EEK.h ================================================ #pragma once #include "../CGALWrapper.h" #include "../Geometry/Geometry2.h" #include extern "C" { CGALWRAPPER_API void* Point2_EEK_Create(); CGALWRAPPER_API void* Point2_EEK_CreateFromPoint(const Point2d& point); CGALWRAPPER_API void Point2_EEK_Release(void* ptr); CGALWRAPPER_API double Point2_EEK_GetX(void* ptr); CGALWRAPPER_API double Point2_EEK_GetY(void* ptr); CGALWRAPPER_API void Point2_EEK_SetX(void* ptr, double x); CGALWRAPPER_API void Point2_EEK_SetY(void* ptr, double y); CGALWRAPPER_API void* Point2_EEK_Copy(void* ptr); CGALWRAPPER_API void* Point2_EEK_Convert(void* ptr, CGAL_KERNEL k); } ================================================ FILE: CGALWrapper/Geometry/Point2_EIK.cpp ================================================ #include "Point2_EIK.h" #include #include typedef CGAL::Point_2 Point2; void* Point2_EIK_Create() { return new Point2(); } void* Point2_EIK_CreateFromPoint(const Point2d& point) { auto p = point.ToCGAL(); return new Point2(p.x(), p.y()); } void Point2_EIK_Release(void* ptr) { auto obj = static_cast(ptr); if (obj != nullptr) { delete obj; obj = nullptr; } } Point2* CastToPoint2(void* ptr) { return static_cast(ptr); } double Point2_EIK_GetX(void* ptr) { auto p = CastToPoint2(ptr); return CGAL::to_double(p->x()); } double Point2_EIK_GetY(void* ptr) { auto p = CastToPoint2(ptr); return CGAL::to_double(p->y()); } void Point2_EIK_SetX(void* ptr, double x) { auto p = CastToPoint2(ptr); (*p) = Point2(x, p->y()); } void Point2_EIK_SetY(void* ptr, double y) { auto p = CastToPoint2(ptr); (*p) = Point2(p->x(), y); } void* Point2_EIK_Copy(void* ptr) { auto p = CastToPoint2(ptr); auto p2 = new Point2(); (*p2) = *p; return p2; } void* Point2_EIK_Convert(void* ptr) { typedef CGAL::Cartesian_converter Converter; Converter convert; auto p = CastToPoint2(ptr); auto x = convert(p->x()); auto y = convert(p->y()); return new CGAL::Point_2(x, y); } template static void* Convert(Point2* p) { CGAL::Cartesian_converter convert; auto x = convert((*p)[0]); auto y = convert((*p)[1]); return new CGAL::Point_2(x, y); } void* Point2_EIK_Convert(void* ptr, CGAL_KERNEL k) { auto p = CastToPoint2(ptr); switch (k) { case CGAL_KERNEL::EXACT_PREDICATES_INEXACT_CONSTRUCTION: return Convert(p); case CGAL_KERNEL::EXACT_PREDICATES_EXACT_CONSTRUCTION: return Convert(p); default: return Convert(p); } } ================================================ FILE: CGALWrapper/Geometry/Point2_EIK.h ================================================ #pragma once #include "../CGALWrapper.h" #include "../Geometry/Geometry2.h" #include extern "C" { CGALWRAPPER_API void* Point2_EIK_Create(); CGALWRAPPER_API void* Point2_EIK_CreateFromPoint(const Point2d& point); CGALWRAPPER_API void Point2_EIK_Release(void* ptr); CGALWRAPPER_API double Point2_EIK_GetX(void* ptr); CGALWRAPPER_API double Point2_EIK_GetY(void* ptr); CGALWRAPPER_API void Point2_EIK_SetX(void* ptr, double x); CGALWRAPPER_API void Point2_EIK_SetY(void* ptr, double y); CGALWRAPPER_API void* Point2_EIK_Copy(void* ptr); CGALWRAPPER_API void* Point2_EIK_Convert(void* ptr, CGAL_KERNEL k); } ================================================ FILE: CGALWrapper/Geometry/Ray2_EEK.cpp ================================================ #include "Ray2_EEK.h" #include #include typedef CGAL::Ray_2 Ray2; typedef CGAL::Line_2 Line2; typedef CGAL::Point_2 Point2; typedef CGAL::Aff_transformation_2 Transformation2; void* Ray2_EEK_Create(const Point2d& position, const Vector2d& direction) { auto p = position.ToCGAL(); auto d = direction.ToCGAL(); return new Ray2(p, d); } void Ray2_EEK_Release(void* ptr) { auto obj = static_cast(ptr); if (obj != nullptr) { delete obj; obj = nullptr; } } Ray2* CastToRay2(void* ptr) { return static_cast(ptr); } Ray2* NewRay2() { return new Ray2(); } BOOL Ray2_EEK_IsDegenerate(void* ptr) { auto ray = CastToRay2(ptr); return ray->is_degenerate(); } BOOL Ray2_EEK_IsHorizontal(void* ptr) { auto ray = CastToRay2(ptr); return ray->is_horizontal(); } BOOL Ray2_EEK_IsVertical(void* ptr) { auto ray = CastToRay2(ptr); return ray->is_vertical(); } BOOL Ray2_EEK_HasOn(void* rayPtr, const Point2d& point) { auto ray = CastToRay2(rayPtr); return ray->has_on(point.ToCGAL()); } Point2d Ray2_EEK_Source(void* ptr) { auto ray = CastToRay2(ptr); auto p = ray->source(); return Point2d::FromCGAL(p); } Vector2d Ray2_EEK_Vector(void* ptr) { auto ray = CastToRay2(ptr); auto v = ray->to_vector(); return Vector2d::FromCGAL(v); } void* Ray2_EEK_Opposite(void* ptr) { auto ray = CastToRay2(ptr); auto nray = NewRay2(); (*nray) = ray->opposite(); return nray; } void* Ray2_EEK_Line(void* ptr) { auto ray = CastToRay2(ptr); auto line = new Line2(); (*line) = ray->supporting_line(); return line; } void Ray2_EEK_Transform(void* ptr, const Point2d& translation, double rotation, double scale) { auto ray = CastToRay2(ptr); Transformation2 T(CGAL::TRANSLATION, translation.ToVector()); Transformation2 R(CGAL::ROTATION, sin(rotation), cos(rotation)); Transformation2 S(CGAL::SCALING, scale); (*ray) = ray->transform(T * R * S); } void* Ray2_EEK_Copy(void* ptr) { auto r = CastToRay2(ptr); auto r2 = new Ray2(); (*r2) = *r; return r2; } template static void* Convert(Ray2* r) { CGAL::Cartesian_converter convert; auto p = convert(r->source()); auto d = convert(r->direction()); return new CGAL::Ray_2(p, d); } void* Ray2_EEK_Convert(void* ptr, CGAL_KERNEL k) { auto r = CastToRay2(ptr); switch (k) { case CGAL_KERNEL::EXACT_PREDICATES_INEXACT_CONSTRUCTION: return Convert(r); case CGAL_KERNEL::EXACT_PREDICATES_EXACT_CONSTRUCTION: return Convert(r); default: return Convert(r); } } ================================================ FILE: CGALWrapper/Geometry/Ray2_EEK.h ================================================ #pragma once #include "../CGALWrapper.h" #include "../Geometry/Geometry2.h" #include extern "C" { CGALWRAPPER_API void* Ray2_EEK_Create(const Point2d& position, const Vector2d& direction); CGALWRAPPER_API void Ray2_EEK_Release(void* ptr); CGALWRAPPER_API BOOL Ray2_EEK_IsDegenerate(void* ptr); CGALWRAPPER_API BOOL Ray2_EEK_IsHorizontal(void* ptr); CGALWRAPPER_API BOOL Ray2_EEK_IsVertical(void* ptr); CGALWRAPPER_API BOOL Ray2_EEK_HasOn(void* rayPtr, const Point2d& point); CGALWRAPPER_API Point2d Ray2_EEK_Source(void* ptr); CGALWRAPPER_API Vector2d Ray2_EEK_Vector(void* ptr); CGALWRAPPER_API void* Ray2_EEK_Opposite(void* ptr); CGALWRAPPER_API void* Ray2_EEK_Line(void* ptr); CGALWRAPPER_API void Ray2_EEK_Transform(void* ptr, const Point2d& translation, double rotation, double scale); CGALWRAPPER_API void* Ray2_EEK_Copy(void* ptr, CGAL_KERNEL k); } ================================================ FILE: CGALWrapper/Geometry/Ray2_EIK.cpp ================================================ #include "Ray2_EIK.h" #include #include #include typedef CGAL::Ray_2 Ray2; typedef CGAL::Line_2 Line2; typedef CGAL::Point_2 Point2; typedef CGAL::Aff_transformation_2 Transformation2; void* Ray2_EIK_Create(const Point2d& position, const Vector2d& direction) { auto p = position.ToCGAL(); auto d = direction.ToCGAL(); return new Ray2(p, d); } void Ray2_EIK_Release(void* ptr) { auto obj = static_cast(ptr); if (obj != nullptr) { delete obj; obj = nullptr; } } Ray2* CastToRay2(void* ptr) { return static_cast(ptr); } Ray2* NewRay2() { return new Ray2(); } BOOL Ray2_EIK_IsDegenerate(void* ptr) { auto ray = CastToRay2(ptr); return ray->is_degenerate(); } BOOL Ray2_EIK_IsHorizontal(void* ptr) { auto ray = CastToRay2(ptr); return ray->is_horizontal(); } BOOL Ray2_EIK_IsVertical(void* ptr) { auto ray = CastToRay2(ptr); return ray->is_vertical(); } BOOL Ray2_EIK_HasOn(void* rayPtr, const Point2d& point) { auto ray = CastToRay2(rayPtr); return ray->has_on(point.ToCGAL()); } Point2d Ray2_EIK_Source(void* ptr) { auto ray = CastToRay2(ptr); auto p = ray->source(); return Point2d::FromCGAL(p); } Vector2d Ray2_EIK_Vector(void* ptr) { auto ray = CastToRay2(ptr); auto v = ray->to_vector(); return Vector2d::FromCGAL(v); } void* Ray2_EIK_Opposite(void* ptr) { auto ray = CastToRay2(ptr); auto nray = NewRay2(); (*nray) = ray->opposite(); return nray; } void* Ray2_EIK_Line(void* ptr) { auto ray = CastToRay2(ptr); auto line = new Line2(); (*line) = ray->supporting_line(); return line; } void Ray2_EIK_Transform(void* ptr, const Point2d& translation, double rotation, double scale) { auto ray = CastToRay2(ptr); Transformation2 T(CGAL::TRANSLATION, translation.ToVector()); Transformation2 R(CGAL::ROTATION, sin(rotation), cos(rotation)); Transformation2 S(CGAL::SCALING, scale); (*ray) = ray->transform(T * R * S); } template static void* Convert(Ray2* r) { CGAL::Cartesian_converter convert; auto p = convert(r->source()); auto d = convert(r->direction()); return new CGAL::Ray_2(p, d); } void* Ray2_EIK_Convert(void* ptr, CGAL_KERNEL k) { auto r = CastToRay2(ptr); switch (k) { case CGAL_KERNEL::EXACT_PREDICATES_INEXACT_CONSTRUCTION: return Convert(r); case CGAL_KERNEL::EXACT_PREDICATES_EXACT_CONSTRUCTION: return Convert(r); default: return Convert(r); } } ================================================ FILE: CGALWrapper/Geometry/Ray2_EIK.h ================================================ #pragma once #include "../CGALWrapper.h" #include "../Geometry/Geometry2.h" #include extern "C" { CGALWRAPPER_API void* Ray2_EIK_Create(const Point2d& position, const Vector2d& direction); CGALWRAPPER_API void Ray2_EIK_Release(void* ptr); CGALWRAPPER_API BOOL Ray2_EIK_IsDegenerate(void* ptr); CGALWRAPPER_API BOOL Ray2_EIK_IsHorizontal(void* ptr); CGALWRAPPER_API BOOL Ray2_EIK_IsVertical(void* ptr); CGALWRAPPER_API BOOL Ray2_EIK_HasOn(void* rayPtr, const Point2d& point); CGALWRAPPER_API Point2d Ray2_EIK_Source(void* ptr); CGALWRAPPER_API Vector2d Ray2_EIK_Vector(void* ptr); CGALWRAPPER_API void* Ray2_EIK_Opposite(void* ptr); CGALWRAPPER_API void* Ray2_EIK_Line(void* ptr); CGALWRAPPER_API void Ray2_EIK_Transform(void* ptr, const Point2d& translation, double rotation, double scale); CGALWRAPPER_API void* Ray2_EIK_Copy(void* ptr, CGAL_KERNEL k); } ================================================ FILE: CGALWrapper/Geometry/Segment2_EEK.cpp ================================================ #include "Segment2_EEK.h" #include #include #include typedef CGAL::Segment_2 Segment2; typedef CGAL::Line_2 Line2; typedef CGAL::Point_2 Point2; typedef CGAL::Aff_transformation_2 Transformation2; void* Segment2_EEK_Create(const Point2d& a, const Point2d& b) { auto A = a.ToCGAL(); auto B = b.ToCGAL(); return new Segment2(A, B); } void Segment2_EEK_Release(void* ptr) { auto obj = static_cast(ptr); if (obj != nullptr) { delete obj; obj = nullptr; } } Segment2* CastToSegment2(void* ptr) { return static_cast(ptr); } Segment2* NewSegment2() { return new Segment2(); } Point2d Segment2_EEK_GetVertex(void* ptr, int i) { auto seg = CastToSegment2(ptr); return Point2d::FromCGAL(seg->vertex(i)); } void Segment2_EEK_SetVertex(void* ptr, int i, const Point2d& point) { if (i < 0 || i >= 2) return; auto seg = CastToSegment2(ptr); (*seg)[i] = point.ToCGAL(); } Point2d Segment2_EEK_Min(void* ptr) { auto seg = CastToSegment2(ptr); return Point2d::FromCGAL(seg->min()); } Point2d Segment2_EEK_Max(void* ptr) { auto seg = CastToSegment2(ptr); return Point2d::FromCGAL(seg->max()); } BOOL Segment2_EEK_IsDegenerate(void* ptr) { auto seg = CastToSegment2(ptr); return seg->is_degenerate(); } BOOL Segment2_EEK_IsHorizontal(void* ptr) { auto seg = CastToSegment2(ptr); return seg->is_horizontal(); } BOOL Segment2_EEK_IsVertical(void* ptr) { auto seg = CastToSegment2(ptr); return seg->is_vertical(); } BOOL Segment2_EEK_HasOn(void* segPtr, const Point2d& point) { auto seg = CastToSegment2(segPtr); return seg->has_on(point.ToCGAL()); } Vector2d Segment2_EEK_Vector(void* ptr) { auto seg = CastToSegment2(ptr); auto v = seg->to_vector(); return Vector2d::FromCGAL(v); } void* Segment2_EEK_Line(void* ptr) { auto seg = CastToSegment2(ptr); auto line = new Line2(); (*line) = seg->supporting_line(); return line; } double Segment2_EEK_SqrLength(void* ptr) { auto seg = CastToSegment2(ptr); return CGAL::to_double(seg->squared_length()); } void Segment2_EEK_Transform(void* ptr, const Point2d& translation, double rotation, double scale) { auto seg = CastToSegment2(ptr); Transformation2 T(CGAL::TRANSLATION, translation.ToVector()); Transformation2 R(CGAL::ROTATION, sin(rotation), cos(rotation)); Transformation2 S(CGAL::SCALING, scale); (*seg) = seg->transform(T * R * S); } void* Segment2_EEK_Copy(void* ptr) { auto s = CastToSegment2(ptr); auto s2 = new Segment2(); (*s2) = *s; return s2; } template static void* Convert(Segment2* s) { CGAL::Cartesian_converter convert; auto a = convert(s->source()); auto b = convert(s->target()); return new CGAL::Segment_2(a, b); } void* Segment2_EEK_Convert(void* ptr, CGAL_KERNEL k) { auto s = CastToSegment2(ptr); switch (k) { case CGAL_KERNEL::EXACT_PREDICATES_INEXACT_CONSTRUCTION: return Convert(s); case CGAL_KERNEL::EXACT_PREDICATES_EXACT_CONSTRUCTION: return Convert(s); default: return Convert(s); } } ================================================ FILE: CGALWrapper/Geometry/Segment2_EEK.h ================================================ #pragma once #include "../CGALWrapper.h" #include "../Geometry/Geometry2.h" #include extern "C" { CGALWRAPPER_API void* Segment2_EEK_Create(const Point2d& a, const Point2d& b); CGALWRAPPER_API void Segment2_EEK_Release(void* ptr); CGALWRAPPER_API Point2d Segment2_EEK_GetVertex(void* ptr, int i); CGALWRAPPER_API void Segment2_EEK_SetVertex(void* ptr, int i, const Point2d& point); CGALWRAPPER_API Point2d Segment2_EEK_Min(void* ptr); CGALWRAPPER_API Point2d Segment2_EEK_Max(void* ptr); CGALWRAPPER_API BOOL Segment2_EEK_IsDegenerate(void* ptr); CGALWRAPPER_API BOOL Segment2_EEK_IsHorizontal(void* ptr); CGALWRAPPER_API BOOL Segment2_EEK_IsVertical(void* ptr); CGALWRAPPER_API BOOL Segment2_EEK_HasOn(void* segPtr, const Point2d& point); CGALWRAPPER_API Vector2d Segment2_EEK_Vector(void* ptr); CGALWRAPPER_API void* Segment2_EEK_Line(void* ptr); CGALWRAPPER_API double Segment2_EEK_SqrLength(void* ptr); CGALWRAPPER_API void Segment2_EEK_Transform(void* ptr, const Point2d& translation, double rotation, double scale); CGALWRAPPER_API void* Segment2_EEK_Copy(void* ptr); CGALWRAPPER_API void* Segment2_EEK_Convert(void* ptr, CGAL_KERNEL k); } ================================================ FILE: CGALWrapper/Geometry/Segment2_EIK.cpp ================================================ #include "Segment2_EIK.h" #include #include #include typedef CGAL::Segment_2 Segment2; typedef CGAL::Line_2 Line2; typedef CGAL::Point_2 Point2; typedef CGAL::Aff_transformation_2 Transformation2; void* Segment2_EIK_Create(const Point2d& a, const Point2d& b) { auto A = a.ToCGAL(); auto B = b.ToCGAL(); return new Segment2(A, B); } void Segment2_EIK_Release(void* ptr) { auto obj = static_cast(ptr); if (obj != nullptr) { delete obj; obj = nullptr; } } Segment2* CastToSegment2(void* ptr) { return static_cast(ptr); } Segment2* NewSegment2() { return new Segment2(); } Point2d Segment2_EIK_GetVertex(void* ptr, int i) { auto seg = CastToSegment2(ptr); return Point2d::FromCGAL(seg->vertex(i)); } void Segment2_EIK_SetVertex(void* ptr, int i, const Point2d& point) { auto seg = CastToSegment2(ptr); if (i == 0) { auto p = point.ToCGAL(); (*seg) = Segment2(p, seg->target()); } else { auto p = point.ToCGAL(); (*seg) = Segment2(seg->source(), p); } } Point2d Segment2_EIK_Min(void* ptr) { auto seg = CastToSegment2(ptr); return Point2d::FromCGAL(seg->min()); } Point2d Segment2_EIK_Max(void* ptr) { auto seg = CastToSegment2(ptr); return Point2d::FromCGAL(seg->max()); } BOOL Segment2_EIK_IsDegenerate(void* ptr) { auto seg = CastToSegment2(ptr); return seg->is_degenerate(); } BOOL Segment2_EIK_IsHorizontal(void* ptr) { auto seg = CastToSegment2(ptr); return seg->is_horizontal(); } BOOL Segment2_EIK_IsVertical(void* ptr) { auto seg = CastToSegment2(ptr); return seg->is_vertical(); } BOOL Segment2_EIK_HasOn(void* segPtr, const Point2d& point) { auto seg = CastToSegment2(segPtr); return seg->has_on(point.ToCGAL()); } Vector2d Segment2_EIK_Vector(void* ptr) { auto seg = CastToSegment2(ptr); auto v = seg->to_vector(); return Vector2d::FromCGAL(v); } void* Segment2_EIK_Line(void* ptr) { auto seg = CastToSegment2(ptr); auto line = new Line2(); (*line) = seg->supporting_line(); return line; } double Segment2_EIK_SqrLength(void* ptr) { auto seg = CastToSegment2(ptr); return CGAL::to_double(seg->squared_length()); } void Segment2_EIK_Transform(void* ptr, const Point2d& translation, double rotation, double scale) { auto seg = CastToSegment2(ptr); Transformation2 T(CGAL::TRANSLATION, translation.ToVector()); Transformation2 R(CGAL::ROTATION, sin(rotation), cos(rotation)); Transformation2 S(CGAL::SCALING, scale); (*seg) = seg->transform(T * R * S); } void* Segment2_EIK_Copy(void* ptr) { auto s = CastToSegment2(ptr); auto s2 = new Segment2(); (*s2) = *s; return s2; } template static void* Convert(Segment2* s) { CGAL::Cartesian_converter convert; auto a = convert(s->source()); auto b = convert(s->target()); return new CGAL::Segment_2(a, b); } void* Segment2_EIK_Convert(void* ptr, CGAL_KERNEL k) { auto s = CastToSegment2(ptr); switch (k) { case CGAL_KERNEL::EXACT_PREDICATES_INEXACT_CONSTRUCTION: return Convert(s); case CGAL_KERNEL::EXACT_PREDICATES_EXACT_CONSTRUCTION: return Convert(s); default: return Convert(s); } } ================================================ FILE: CGALWrapper/Geometry/Segment2_EIK.h ================================================ #pragma once #include "../CGALWrapper.h" #include "../Geometry/Geometry2.h" #include extern "C" { CGALWRAPPER_API void* Segment2_EIK_Create(const Point2d& a, const Point2d& b); CGALWRAPPER_API void Segment2_EIK_Release(void* ptr); CGALWRAPPER_API Point2d Segment2_EIK_GetVertex(void* ptr, int i); CGALWRAPPER_API void Segment2_EIK_SetVertex(void* ptr, int i, const Point2d& point); CGALWRAPPER_API Point2d Segment2_EIK_Min(void* ptr); CGALWRAPPER_API Point2d Segment2_EIK_Max(void* ptr); CGALWRAPPER_API BOOL Segment2_EIK_IsDegenerate(void* ptr); CGALWRAPPER_API BOOL Segment2_EIK_IsHorizontal(void* ptr); CGALWRAPPER_API BOOL Segment2_EIK_IsVertical(void* ptr); CGALWRAPPER_API BOOL Segment2_EIK_HasOn(void* segPtr, const Point2d& point); CGALWRAPPER_API Vector2d Segment2_EIK_Vector(void* ptr); CGALWRAPPER_API void* Segment2_EIK_Line(void* ptr); CGALWRAPPER_API double Segment2_EIK_SqrLength(void* ptr); CGALWRAPPER_API void Segment2_EIK_Transform(void* ptr, const Point2d& translation, double rotation, double scale); CGALWRAPPER_API void* Segment2_EIK_Copy(void* ptr); CGALWRAPPER_API void* Segment2_EIK_Convert(void* ptr, CGAL_KERNEL k); } ================================================ FILE: CGALWrapper/Geometry/Triangle2_EEK.cpp ================================================ #include "Triangle2_EEK.h" #include #include #include typedef CGAL::Triangle_2 Triangle2; typedef CGAL::Point_2 Point2; typedef CGAL::Aff_transformation_2 Transformation2; void* Triangle2_EEK_Create(const Point2d& a, const Point2d& b, const Point2d& c) { auto A = a.ToCGAL(); auto B = b.ToCGAL(); auto C = c.ToCGAL(); return new Triangle2(A, B, C); } void Triangle2_EEK_Release(void* ptr) { auto obj = static_cast(ptr); if (obj != nullptr) { delete obj; obj = nullptr; } } Triangle2* CastToTriangle2(void* ptr) { return static_cast(ptr); } Triangle2* NewTriangle2() { return new Triangle2(); } Point2d Triangle2_EEK_GetVertex(void* ptr, int i) { auto tri = CastToTriangle2(ptr); return Point2d::FromCGAL(tri->vertex(i)); } void Triangle2_EEK_SetVertex(void* ptr, int i, const Point2d& point) { if (i < 0 || i >= 3) return; auto tri = CastToTriangle2(ptr); (*tri)[i] = point.ToCGAL(); } double Triangle2_EEK_Area(void* ptr) { auto tri = CastToTriangle2(ptr); return CGAL::to_double(tri->area()); } CGAL::Bounded_side Triangle2_EEK_BoundedSide(void* ptr, const Point2d& point) { auto tri = CastToTriangle2(ptr); auto p = point.ToCGAL(); return tri->bounded_side(p); } CGAL::Sign Triangle2_EEK_OrientedSide(void* ptr, const Point2d& point) { auto tri = CastToTriangle2(ptr); auto p = point.ToCGAL(); return tri->oriented_side(p); } CGAL::Sign Triangle2_EEK_Orientation(void* ptr) { auto tri = CastToTriangle2(ptr); return tri->orientation(); } BOOL Triangle2_EEK_IsDegenerate(void* ptr) { auto tri = CastToTriangle2(ptr); return tri->is_degenerate(); } void Triangle2_EEK_Transform(void* ptr, const Point2d& translation, double rotation, double scale) { auto tri = CastToTriangle2(ptr); Transformation2 T(CGAL::TRANSLATION, translation.ToVector()); Transformation2 R(CGAL::ROTATION, sin(rotation), cos(rotation)); Transformation2 S(CGAL::SCALING, scale); (*tri) = tri->transform(T * R * S); } void* Triangle2_EEK_Copy(void* ptr) { auto t = CastToTriangle2(ptr); auto t2 = new Triangle2(); (*t2) = *t; return t2; } template static void* Convert(Triangle2* t) { CGAL::Cartesian_converter convert; auto a = convert(t->vertex(0)); auto b = convert(t->vertex(1)); auto c = convert(t->vertex(2)); return new CGAL::Triangle_2(a, b, c); } void* Triangle2_EEK_Convert(void* ptr, CGAL_KERNEL k) { auto t = CastToTriangle2(ptr); switch (k) { case CGAL_KERNEL::EXACT_PREDICATES_INEXACT_CONSTRUCTION: return Convert(t); case CGAL_KERNEL::EXACT_PREDICATES_EXACT_CONSTRUCTION: return Convert(t); default: return Convert(t); } } ================================================ FILE: CGALWrapper/Geometry/Triangle2_EEK.h ================================================ #pragma once #include "../CGALWrapper.h" #include "../Geometry/Geometry2.h" #include extern "C" { CGALWRAPPER_API void* Triangle2_EEK_Create(const Point2d& a, const Point2d& b, const Point2d& c); CGALWRAPPER_API void Triangle2_EEK_Release(void* ptr); CGALWRAPPER_API Point2d Triangle2_EEK_GetVertex(void* ptr, int i); CGALWRAPPER_API void Triangle2_EEK_SetVertex(void* ptr, int i, const Point2d& point); CGALWRAPPER_API double Triangle2_EEK_Area(void* ptr); CGALWRAPPER_API CGAL::Bounded_side Triangle2_EEK_BoundedSide(void* ptr, const Point2d& point); CGALWRAPPER_API CGAL::Sign Triangle2_EEK_OrientedSide(void* ptr, const Point2d& point); CGALWRAPPER_API CGAL::Sign Triangle2_EEK_Orientation(void* ptr); CGALWRAPPER_API BOOL Triangle2_EEK_IsDegenerate(void* ptr); CGALWRAPPER_API void Triangle2_EEK_Transform(void* ptr, const Point2d& translation, double rotation, double scale); CGALWRAPPER_API void* Triangle2_EEK_Copy(void* ptr); CGALWRAPPER_API void* Triangle2_EEK_Convert(void* ptr, CGAL_KERNEL k); } ================================================ FILE: CGALWrapper/Geometry/Triangle2_EIK.cpp ================================================ #include "Triangle2_EIK.h" #include #include #include typedef CGAL::Triangle_2 Triangle2; typedef CGAL::Point_2 Point2; typedef CGAL::Aff_transformation_2 Transformation2; void* Triangle2_EIK_Create(const Point2d& a, const Point2d& b, const Point2d& c) { auto A = a.ToCGAL(); auto B = b.ToCGAL(); auto C = c.ToCGAL(); return new Triangle2(A, B, C); } void Triangle2_EIK_Release(void* ptr) { auto obj = static_cast(ptr); if (obj != nullptr) { delete obj; obj = nullptr; } } Triangle2* CastToTriangle2(void* ptr) { return static_cast(ptr); } Triangle2* NewTriangle2() { return new Triangle2(); } Point2d Triangle2_EIK_GetVertex(void* ptr, int i) { auto tri = CastToTriangle2(ptr); return Point2d::FromCGAL(tri->vertex(i)); } void Triangle2_EIK_SetVertex(void* ptr, int i, const Point2d& point) { auto tri = CastToTriangle2(ptr); if (i == 0) { auto p = point.ToCGAL(); (*tri) = Triangle2(p, tri->vertex(1), tri->vertex(2)); } else if(i == 1) { auto p = point.ToCGAL(); (*tri) = Triangle2(tri->vertex(0), p, tri->vertex(2)); } else { auto p = point.ToCGAL(); (*tri) = Triangle2(tri->vertex(0), tri->vertex(1), p); } } double Triangle2_EIK_Area(void* ptr) { auto tri = CastToTriangle2(ptr); return CGAL::to_double(tri->area()); } CGAL::Bounded_side Triangle2_EIK_BoundedSide(void* ptr, const Point2d& point) { auto tri = CastToTriangle2(ptr); auto p = point.ToCGAL(); return tri->bounded_side(p); } CGAL::Sign Triangle2_EIK_OrientedSide(void* ptr, const Point2d& point) { auto tri = CastToTriangle2(ptr); auto p = point.ToCGAL(); return tri->oriented_side(p); } CGAL::Sign Triangle2_EIK_Orientation(void* ptr) { auto tri = CastToTriangle2(ptr); return tri->orientation(); } BOOL Triangle2_EIK_IsDegenerate(void* ptr) { auto tri = CastToTriangle2(ptr); return tri->is_degenerate(); } void Triangle2_EIK_Transform(void* ptr, const Point2d& translation, double rotation, double scale) { auto tri = CastToTriangle2(ptr); Transformation2 T(CGAL::TRANSLATION, translation.ToVector()); Transformation2 R(CGAL::ROTATION, sin(rotation), cos(rotation)); Transformation2 S(CGAL::SCALING, scale); (*tri) = tri->transform(T * R * S); } void* Triangle2_EIK_Copy(void* ptr) { auto t = CastToTriangle2(ptr); auto t2 = new Triangle2(); (*t2) = *t; return t2; } template static void* Convert(Triangle2* t) { CGAL::Cartesian_converter convert; auto a = convert(t->vertex(0)); auto b = convert(t->vertex(1)); auto c = convert(t->vertex(2)); return new CGAL::Triangle_2(a, b, c); } void* Triangle2_EEK_Convert(void* ptr, CGAL_KERNEL k) { auto t = CastToTriangle2(ptr); switch (k) { case CGAL_KERNEL::EXACT_PREDICATES_INEXACT_CONSTRUCTION: return Convert(t); case CGAL_KERNEL::EXACT_PREDICATES_EXACT_CONSTRUCTION: return Convert(t); default: return Convert(t); } } ================================================ FILE: CGALWrapper/Geometry/Triangle2_EIK.h ================================================ #pragma once #include "../CGALWrapper.h" #include "../Geometry/Geometry2.h" #include extern "C" { CGALWRAPPER_API void* Triangle2_EIK_Create(const Point2d& a, const Point2d& b, const Point2d& c); CGALWRAPPER_API void Triangle2_EIK_Release(void* ptr); CGALWRAPPER_API Point2d Triangle2_EIK_GetVertex(void* ptr, int i); CGALWRAPPER_API void Triangle2_EIK_SetVertex(void* ptr, int i, const Point2d& point); CGALWRAPPER_API double Triangle2_EIK_Area(void* ptr); CGALWRAPPER_API CGAL::Bounded_side Triangle2_EIK_BoundedSide(void* ptr, const Point2d& point); CGALWRAPPER_API CGAL::Sign Triangle2_EIK_OrientedSide(void* ptr, const Point2d& point); CGALWRAPPER_API CGAL::Sign Triangle2_EIK_Orientation(void* ptr); CGALWRAPPER_API BOOL Triangle2_EIK_IsDegenerate(void* ptr); CGALWRAPPER_API void Triangle2_EIK_Transform(void* ptr, const Point2d& translation, double rotation, double scale); CGALWRAPPER_API void* Triangle2_EIK_Copy(void* ptr); CGALWRAPPER_API void* Triangle2_EIK_Convert(void* ptr, CGAL_KERNEL k); } ================================================ FILE: CGALWrapper/Geometry/Vector2_EEK.cpp ================================================ #include "Vector2_EEK.h" #include #include typedef EEK::FT FT; typedef CGAL::Vector_2 Vector2; void* Vector2_EEK_Create() { return new Vector2(); } void* Vector2_EEK_CreateFromVector(const Vector2d& point) { auto p = point.ToCGAL(); return new Vector2(p.x(), p.y()); } void Vector2_EEK_Release(void* ptr) { auto obj = static_cast(ptr); if (obj != nullptr) { delete obj; obj = nullptr; } } Vector2* CastToVector2(void* ptr) { return static_cast(ptr); } double Vector2_EEK_GetX(void* ptr) { auto p = CastToVector2(ptr); return CGAL::to_double(p->x()); } double Vector2_EEK_GetY(void* ptr) { auto p = CastToVector2(ptr); return CGAL::to_double(p->y()); } void Vector2_EEK_SetX(void* ptr, double x) { auto p = CastToVector2(ptr); (*p) = Vector2(x, p->y()); } void Vector2_EEK_SetY(void* ptr, double y) { auto p = CastToVector2(ptr); (*p) = Vector2(p->x(), y); } double Vector2_EEK_SqrLength(void* ptr) { auto p = CastToVector2(ptr); return CGAL::to_double(p->squared_length()); } void* Vector2_EEK_Perpendicular(void* ptr, CGAL::Orientation orientation) { auto p = CastToVector2(ptr); auto v = new Vector2(); (*v) = p->perpendicular(orientation); return v; } void Vector2_EEK_Normalize(void* ptr) { auto p = CastToVector2(ptr); auto sq_len = CGAL::to_double(p->squared_length()); if (sq_len == 0) return; auto len = CGAL::sqrt(sq_len); (*p) = Vector2(p->x() / len, p->y() / len); } double Vector2_EEK_Magnitude(void* ptr) { auto p = CastToVector2(ptr); auto sq_len = CGAL::to_double(p->squared_length()); if (sq_len == 0) return 0; return CGAL::sqrt(sq_len); } void* Vector2_EEK_Copy(void* ptr) { auto v = CastToVector2(ptr); auto v2 = new Vector2(); (*v2) = *v; return v2; } template static void* Convert(Vector2* v) { CGAL::Cartesian_converter convert; auto x = convert((*v)[0]); auto y = convert((*v)[1]); return new CGAL::Vector_2(x, y); } void* Vector2_EEK_Convert(void* ptr, CGAL_KERNEL k) { auto p = CastToVector2(ptr); switch (k) { case CGAL_KERNEL::EXACT_PREDICATES_INEXACT_CONSTRUCTION: return Convert(p); case CGAL_KERNEL::EXACT_PREDICATES_EXACT_CONSTRUCTION: return Convert(p); default: return Convert(p); } } ================================================ FILE: CGALWrapper/Geometry/Vector2_EEK.h ================================================ #pragma once #include "../CGALWrapper.h" #include "../Geometry/Geometry2.h" #include extern "C" { CGALWRAPPER_API void* Vector2_EEK_Create(); CGALWRAPPER_API void* Vector2_EEK_CreateFromVector(const Vector2d& vector); CGALWRAPPER_API void Vector2_EEK_Release(void* ptr); CGALWRAPPER_API double Vector2_EEK_GetX(void* ptr); CGALWRAPPER_API double Vector2_EEK_GetY(void* ptr); CGALWRAPPER_API void Vector2_EEK_SetX(void* ptr, double x); CGALWRAPPER_API void Vector2_EEK_SetY(void* ptr, double y); CGALWRAPPER_API double Vector2_EEK_SqrLength(void* ptr); CGALWRAPPER_API void* Vector2_EEK_Perpendicular(void* ptr, CGAL::Orientation orientation); CGALWRAPPER_API void Vector2_EEK_Normalize(void* ptr); CGALWRAPPER_API double Vector2_EEK_Magnitude(void* ptr); CGALWRAPPER_API void* Vector2_EEK_Copy(void* ptr); CGALWRAPPER_API void* Vector2_EEK_Convert(void* ptr, CGAL_KERNEL k); } ================================================ FILE: CGALWrapper/Geometry/Vector2_EIK.cpp ================================================ #include "Vector2_EIK.h" #include #include typedef EIK::FT FT; typedef CGAL::Vector_2 Vector2; void* Vector2_EIK_Create() { return new Vector2(); } void* Vector2_EIK_CreateFromVector(const Vector2d& point) { auto p = point.ToCGAL(); return new Vector2(p.x(), p.y()); } void Vector2_EIK_Release(void* ptr) { auto obj = static_cast(ptr); if (obj != nullptr) { delete obj; obj = nullptr; } } Vector2* CastToVector2(void* ptr) { return static_cast(ptr); } double Vector2_EIK_GetX(void* ptr) { auto p = CastToVector2(ptr); return CGAL::to_double(p->x()); } double Vector2_EIK_GetY(void* ptr) { auto p = CastToVector2(ptr); return CGAL::to_double(p->y()); } void Vector2_EIK_SetX(void* ptr, double x) { auto p = CastToVector2(ptr); (*p) = Vector2(x, p->y()); } void Vector2_EIK_SetY(void* ptr, double y) { auto p = CastToVector2(ptr); (*p) = Vector2(p->x(), y); } double Vector2_EIK_SqrLength(void* ptr) { auto p = CastToVector2(ptr); return CGAL::to_double(p->squared_length()); } void* Vector2_EIK_Perpendicular(void* ptr, CGAL::Orientation orientation) { auto p = CastToVector2(ptr); auto v = new Vector2(); (*v) = p->perpendicular(orientation); return v; } void Vector2_EIK_Normalize(void* ptr) { auto p = CastToVector2(ptr); auto sq_len = CGAL::to_double(p->squared_length()); if (sq_len == 0) return; auto len = CGAL::sqrt(sq_len); (*p) = Vector2(p->x() / len, p->y() / len); } double Vector2_EIK_Magnitude(void* ptr) { auto p = CastToVector2(ptr); auto sq_len = CGAL::to_double(p->squared_length()); if (sq_len == 0) return 0; return CGAL::sqrt(sq_len); } void* Vector2_EIK_Copy(void* ptr) { auto v = CastToVector2(ptr); auto v2 = new Vector2(); (*v2) = *v; return v2; } template static void* Convert(Vector2* v) { CGAL::Cartesian_converter convert; auto x = convert((*v)[0]); auto y = convert((*v)[1]); return new CGAL::Vector_2(x, y); } void* Vector2_EIK_Convert(void* ptr, CGAL_KERNEL k) { auto p = CastToVector2(ptr); switch (k) { case CGAL_KERNEL::EXACT_PREDICATES_INEXACT_CONSTRUCTION: return Convert(p); case CGAL_KERNEL::EXACT_PREDICATES_EXACT_CONSTRUCTION: return Convert(p); default: return Convert(p); } } ================================================ FILE: CGALWrapper/Geometry/Vector2_EIK.h ================================================ #pragma once #include "../CGALWrapper.h" #include "../Geometry/Geometry2.h" #include extern "C" { CGALWRAPPER_API void* Vector2_EIK_Create(); CGALWRAPPER_API void* Vector2_EIK_CreateFromVector(const Vector2d& vector); CGALWRAPPER_API void Vector2_EIK_Release(void* ptr); CGALWRAPPER_API double Vector2_EIK_GetX(void* ptr); CGALWRAPPER_API double Vector2_EIK_GetY(void* ptr); CGALWRAPPER_API void Vector2_EIK_SetX(void* ptr, double x); CGALWRAPPER_API void Vector2_EIK_SetY(void* ptr, double y); CGALWRAPPER_API double Vector2_EIK_SqrLength(void* ptr); CGALWRAPPER_API void* Vector2_EIK_Perpendicular(void* ptr, CGAL::Orientation orientation); CGALWRAPPER_API void Vector2_EIK_Normalize(void* ptr); CGALWRAPPER_API double Vector2_EIK_Magnitude(void* ptr); CGALWRAPPER_API void* Vector2_EIK_Copy(void* ptr); CGALWRAPPER_API void* Vector2_EIK_Convert(void* ptr, CGAL_KERNEL k); } ================================================ FILE: CGALWrapper/Hull/ConvexHull2.h ================================================ #pragma once #include "../CGALWrapper.h" #include "../Geometry/Geometry2.h" #include "../Polygons/Polygon2.h" #include #include #include #include #include #include template class ConvexHull2 { private: typedef std::vector> PointList; typedef CGAL::Polygon_2 Polygon_2; public: ConvexHull2() { } ~ConvexHull2() { } inline static ConvexHull2* NewConvexHull2() { return new ConvexHull2(); } inline static void DeleteConvexHull2(void* ptr) { auto obj = static_cast(ptr); if (obj != nullptr) { delete obj; obj = nullptr; } } inline static ConvexHull2* CastToConvexHull2(void* ptr) { return static_cast(ptr); } static PointList ConvertPoints(Point2d* points, int count) { PointList list(count); for (auto i = 0; i < count; i++) list[i] = points[i].ToCGAL(); return list; } static void* CreateHull(Point2d* points, int count, HULL_METHOD method) { PointList list = ConvertPoints(points, count); PointList out; switch(method) { case HULL_METHOD::DEFAULT: CGAL::convex_hull_2(list.begin(), list.end(), std::back_inserter(out)); break; case HULL_METHOD::AKL_TOUSSAINT: CGAL::ch_akl_toussaint(list.begin(), list.end(), std::back_inserter(out)); break; case HULL_METHOD::BYKAT: CGAL::ch_bykat(list.begin(), list.end(), std::back_inserter(out)); break; case HULL_METHOD::EDDY: CGAL::ch_eddy(list.begin(), list.end(), std::back_inserter(out)); break; case HULL_METHOD::GRAHAM_ANDREW: CGAL::ch_graham_andrew(list.begin(), list.end(), std::back_inserter(out)); break; case HULL_METHOD::JARVIS: CGAL::ch_jarvis(list.begin(), list.end(), std::back_inserter(out)); break; default: CGAL::convex_hull_2(list.begin(), list.end(), std::back_inserter(out)); break; } return new Polygon_2(out.begin(), out.end()); } static void* LowerHull(Point2d* points, int count) { PointList list = ConvertPoints(points, count); PointList out; CGAL::lower_hull_points_2(list.begin(), list.end(), std::back_inserter(out)); return new Polygon_2(out.begin(), out.end()); } static void* UpperHull(Point2d* points, int count) { PointList list = ConvertPoints(points, count); PointList out; CGAL::upper_hull_points_2(list.begin(), list.end(), std::back_inserter(out)); return new Polygon_2(out.begin(), out.end()); } static BOOL IsStronglyConvexCCW(Point2d* points, int count) { PointList list = ConvertPoints(points, count); return CGAL::is_ccw_strongly_convex_2(list.begin(), list.end()); } static BOOL IsStronglyConvexCW(Point2d* points, int count) { PointList list = ConvertPoints(points, count); return CGAL::is_cw_strongly_convex_2(list.begin(), list.end()); } }; ================================================ FILE: CGALWrapper/Hull/ConvexHull2_EEK.cpp ================================================ #include "ConvexHull2_EEK.h" #include "ConvexHull2.h" void* ConvexHull2_EEK_Create() { return ConvexHull2::NewConvexHull2(); } void ConvexHull2_EEK_Release(void* ptr) { ConvexHull2::DeleteConvexHull2(ptr); } void* ConvexHull2_EEK_CreateHull(Point2d* points, int count, HULL_METHOD method) { return ConvexHull2::CreateHull(points, count, method); } void* ConvexHull2_EEK_UpperHull(Point2d* points, int count) { return ConvexHull2::UpperHull(points, count); } void* ConvexHull2_EEK_LowerHull(Point2d* points, int count) { return ConvexHull2::LowerHull(points, count); } BOOL ConvexHull2_EEK_IsStronglyConvexCCW(Point2d* points, int count) { return ConvexHull2::IsStronglyConvexCCW(points, count); } BOOL ConvexHull2_EEK_IsStronglyConvexCW(Point2d* points, int count) { return ConvexHull2::IsStronglyConvexCW(points, count); } ================================================ FILE: CGALWrapper/Hull/ConvexHull2_EEK.h ================================================ #pragma once #include "../CGALWrapper.h" #include "../Geometry/Geometry2.h" #include enum class HULL_METHOD : int { DEFAULT, AKL_TOUSSAINT, BYKAT, EDDY, GRAHAM_ANDREW, JARVIS }; extern "C" { CGALWRAPPER_API void* ConvexHull2_EEK_Create(); CGALWRAPPER_API void ConvexHull2_EEK_Release(void* ptr); CGALWRAPPER_API void* ConvexHull2_EEK_CreateHull(Point2d* points, int count, HULL_METHOD method); CGALWRAPPER_API void* ConvexHull2_EEK_UpperHull(Point2d* points, int count); CGALWRAPPER_API void* ConvexHull2_EEK_LowerHull(Point2d* points, int count); CGALWRAPPER_API BOOL ConvexHull2_EEK_IsStronglyConvexCCW(Point2d* points, int count); CGALWRAPPER_API BOOL ConvexHull2_EEK_IsStronglyConvexCW(Point2d* points, int count); } ================================================ FILE: CGALWrapper/Hull/ConvexHull2_EIK.cpp ================================================ #include "ConvexHull2_EIK.h" #include "ConvexHull2.h" void* ConvexHull2_EIK_Create() { return ConvexHull2::NewConvexHull2(); } void ConvexHull2_EIK_Release(void* ptr) { ConvexHull2::DeleteConvexHull2(ptr); } void* ConvexHull2_EIK_CreateHull(Point2d* points, int count, HULL_METHOD method) { return ConvexHull2::CreateHull(points, count, method); } void* ConvexHull2_EIK_UpperHull(Point2d* points, int count) { return ConvexHull2::UpperHull(points, count); } void* ConvexHull2_EIK_LowerHull(Point2d* points, int count) { return ConvexHull2::LowerHull(points, count); } BOOL ConvexHull2_EIK_IsStronglyConvexCCW(Point2d* points, int count) { return ConvexHull2::IsStronglyConvexCCW(points, count); } BOOL ConvexHull2_EIK_IsStronglyConvexCW(Point2d* points, int count) { return ConvexHull2::IsStronglyConvexCW(points, count); } ================================================ FILE: CGALWrapper/Hull/ConvexHull2_EIK.h ================================================ #pragma once #include "../CGALWrapper.h" #include "../Geometry/Geometry2.h" #include enum class HULL_METHOD : int { DEFAULT, AKL_TOUSSAINT, BYKAT, EDDY, GRAHAM_ANDREW, JARVIS }; extern "C" { CGALWRAPPER_API void* ConvexHull2_EIK_Create(); CGALWRAPPER_API void ConvexHull2_EIK_Release(void* ptr); CGALWRAPPER_API void* ConvexHull2_EIK_CreateHull(Point2d* points, int count, HULL_METHOD method); CGALWRAPPER_API void* ConvexHull2_EIK_UpperHull(Point2d* points, int count); CGALWRAPPER_API void* ConvexHull2_EIK_LowerHull(Point2d* points, int count); CGALWRAPPER_API BOOL ConvexHull2_EIK_IsStronglyConvexCCW(Point2d* points, int count); CGALWRAPPER_API BOOL ConvexHull2_EIK_IsStronglyConvexCW(Point2d* points, int count); } ================================================ FILE: CGALWrapper/Hull/ConvexHull3.h ================================================ #pragma once #include "../CGALWrapper.h" #include "../Geometry/Geometry3.h" #include "../Polyhedra/Polyhedron3.h" #include "../Polyhedra/SurfaceMesh3.h" #include #include #include template class ConvexHull3 { private: typedef CGAL::Point_3 Point_3; typedef CGAL::Plane_3 Plane_3; typedef std::vector PointList; typedef std::vector PlaneList; public: inline static ConvexHull3* NewConvexHull3() { return new ConvexHull3(); } inline static void DeleteConvexHull3(void* ptr) { auto obj = static_cast(ptr); if (obj != nullptr) { delete obj; obj = nullptr; } } inline static ConvexHull3* CastToConvexHull3(void* ptr) { return static_cast(ptr); } static PointList ConvertPoints(Point3d* points, int count) { PointList list(count); for (auto i = 0; i < count; i++) list[i] = points[i].ToCGAL(); return list; } static PlaneList ConvertPlanes(Plane3d* planes, int count) { PlaneList list(count); for (auto i = 0; i < count; i++) list[i] = planes[i].ToCGAL(); return list; } static void* CreateHullAsPolyhedronFromPoints(Point3d* points, int count) { auto list = ConvertPoints(points, count); auto poly = Polyhedron3::NewPolyhedron(); CGAL::convex_hull_3(list.begin(), list.end(), poly->model); return poly; } static void* CreateHullAsSurfaceMeshFromPoints(Point3d* points, int count) { auto list = ConvertPoints(points, count); auto mesh = SurfaceMesh3::NewSurfaceMesh(); CGAL::convex_hull_3(list.begin(), list.end(), mesh->model); return mesh; } static void* CreateHullAsPolyhedronFromPlanes(Plane3d* planes, int count) { auto list = ConvertPlanes(planes, count); auto poly = Polyhedron3::NewPolyhedron(); CGAL::halfspace_intersection_3(list.begin(), list.end(), poly->model); return poly; } static void* CreateHullAsSurfaceMeshFromPlanes(Plane3d* planes, int count) { auto list = ConvertPlanes(planes, count); auto mesh = SurfaceMesh3::NewSurfaceMesh(); CGAL::halfspace_intersection_3(list.begin(), list.end(), mesh->model); return mesh; } static BOOL IsPolyhedronStronglyConvex(void* ptr) { auto poly = Polyhedron3::CastToPolyhedron(ptr); return CGAL::is_strongly_convex_3(poly->model); } static BOOL IsSurfaceMeshStronglyConvex(void* ptr) { auto mesh = SurfaceMesh3::CastToSurfaceMesh(ptr); return CGAL::is_strongly_convex_3(mesh->model); } }; ================================================ FILE: CGALWrapper/Hull/ConvexHull3_EEK.cpp ================================================ #include "ConvexHull3_EEK.h" #include "ConvexHull3.h" void* ConvexHull3_EEK_Create() { return ConvexHull3::NewConvexHull3(); } void ConvexHull3_EEK_Release(void* ptr) { ConvexHull3::DeleteConvexHull3(ptr); } void* ConvexHull3_EEK_CreateHullAsPolyhedronFromPoints(Point3d* points, int count) { return ConvexHull3::CreateHullAsPolyhedronFromPoints(points, count); } void* ConvexHull3_EEK_CreateHullAsSurfaceMeshFromPoints(Point3d* points, int count) { return ConvexHull3::CreateHullAsSurfaceMeshFromPoints(points, count); } void* ConvexHull3_EEK_CreateHullAsPolyhedronFromPlanes(Plane3d* planes, int count) { return ConvexHull3::CreateHullAsPolyhedronFromPlanes(planes, count); } void* ConvexHull3_EEK_CreateHullAsSurfaceMeshFromPlanes(Plane3d* planes, int count) { return ConvexHull3::CreateHullAsSurfaceMeshFromPlanes(planes, count); } BOOL ConvexHull3_EEK_IsPolyhedronStronglyConvex(void* ptr) { return ConvexHull3::IsPolyhedronStronglyConvex(ptr); } BOOL ConvexHull3_EEK_IsSurfaceMeshStronglyConvex(void* ptr) { return ConvexHull3::IsSurfaceMeshStronglyConvex(ptr); } ================================================ FILE: CGALWrapper/Hull/ConvexHull3_EEK.h ================================================ #pragma once #include "../CGALWrapper.h" #include "../Geometry/Geometry3.h" #include extern "C" { CGALWRAPPER_API void* ConvexHull3_EEK_Create(); CGALWRAPPER_API void ConvexHull3_EEK_Release(void* ptr); CGALWRAPPER_API void* ConvexHull3_EEK_CreateHullAsPolyhedronFromPoints(Point3d* points, int count); CGALWRAPPER_API void* ConvexHull3_EEK_CreateHullAsSurfaceMeshFromPoints(Point3d* points, int count); CGALWRAPPER_API void* ConvexHull3_EEK_CreateHullAsPolyhedronFromPlanes(Plane3d* planes, int count); CGALWRAPPER_API void* ConvexHull3_EEK_CreateHullAsSurfaceMeshFromPlanes(Plane3d* planes, int count); CGALWRAPPER_API BOOL ConvexHull3_EEK_IsPolyhedronStronglyConvex(void* ptr); CGALWRAPPER_API BOOL ConvexHull3_EEK_IsSurfaceMeshStronglyConvex(void* ptr); } ================================================ FILE: CGALWrapper/Hull/ConvexHull3_EIK.cpp ================================================ #include "ConvexHull3_EIK.h" #include "ConvexHull3.h" void* ConvexHull3_EIK_Create() { return ConvexHull3::NewConvexHull3(); } void ConvexHull3_EIK_Release(void* ptr) { ConvexHull3::DeleteConvexHull3(ptr); } void* ConvexHull3_EIK_CreateHullAsPolyhedronFromPoints(Point3d* points, int count) { return ConvexHull3::CreateHullAsPolyhedronFromPoints(points, count); } void* ConvexHull3_EIK_CreateHullAsSurfaceMeshFromPoints(Point3d* points, int count) { return ConvexHull3::CreateHullAsSurfaceMeshFromPoints(points, count); } void* ConvexHull3_EIK_CreateHullAsPolyhedronFromPlanes(Plane3d* planes, int count) { return ConvexHull3::CreateHullAsPolyhedronFromPlanes(planes, count); } void* ConvexHull3_EIK_CreateHullAsSurfaceMeshFromPlanes(Plane3d* planes, int count) { return ConvexHull3::CreateHullAsSurfaceMeshFromPlanes(planes, count); } BOOL ConvexHull3_EIK_IsPolyhedronStronglyConvex(void* ptr) { return ConvexHull3::IsPolyhedronStronglyConvex(ptr); } BOOL ConvexHull3_EIK_IsSurfaceMeshStronglyConvex(void* ptr) { return ConvexHull3::IsSurfaceMeshStronglyConvex(ptr); } ================================================ FILE: CGALWrapper/Hull/ConvexHull3_EIK.h ================================================ #pragma once #include "../CGALWrapper.h" #include "../Geometry/Geometry3.h" #include extern "C" { CGALWRAPPER_API void* ConvexHull3_EIK_Create(); CGALWRAPPER_API void ConvexHull3_EIK_Release(void* ptr); CGALWRAPPER_API void* ConvexHull3_EIK_CreateHullAsPolyhedronFromPoints(Point3d* points, int count); CGALWRAPPER_API void* ConvexHull3_EIK_CreateHullAsSurfaceMeshFromPoints(Point3d* points, int count); CGALWRAPPER_API void* ConvexHull3_EIK_CreateHullAsPolyhedronFromPlanes(Plane3d* planes, int count); CGALWRAPPER_API void* ConvexHull3_EIK_CreateHullAsSurfaceMeshFromPlanes(Plane3d* planes, int count); CGALWRAPPER_API BOOL ConvexHull3_EIK_IsPolyhedronStronglyConvex(void* ptr); CGALWRAPPER_API BOOL ConvexHull3_EIK_IsSurfaceMeshStronglyConvex(void* ptr); } ================================================ FILE: CGALWrapper/Meshing/ConformingTriangulation2.h ================================================ #pragma once #include "../CGALWrapper.h" #include "../Geometry/Geometry2.h" #include "../Polygons/Polygon2.h" #include "../Polygons/PolygonWithHoles2.h" #include #include #include #include #include #include #include #include #include #include #include #include template class ConformingTriangulation2 { public: typedef CGAL::Delaunay_mesh_vertex_base_2 Vb; typedef CGAL::Delaunay_mesh_face_base_2 Fb; typedef CGAL::Triangulation_data_structure_2 Tds; typedef CGAL::Constrained_Delaunay_triangulation_2 CDT; typedef CGAL::Delaunay_mesh_size_criteria_2 Criteria; typedef CGAL::Delaunay_mesher_2 Mesher; typedef typename CDT::Vertex_handle Vertex; typedef typename CDT::Point Point; typedef CGAL::Aff_transformation_2 Transformation_2; CDT model; ConformingTriangulation2() { } ~ConformingTriangulation2() { } inline static ConformingTriangulation2* NewTriangulation2() { return new ConformingTriangulation2(); } inline static void DeleteTriangulation2(void* ptr) { auto obj = static_cast(ptr); if (obj != nullptr) { delete obj; obj = nullptr; } } inline static ConformingTriangulation2* CastToTriangulation2(void* ptr) { return static_cast(ptr); } static void Clear(void* ptr) { auto tri = CastToTriangulation2(ptr); tri->model.clear(); } static void* Copy(void* ptr) { auto tri = CastToTriangulation2(ptr); auto copy = NewTriangulation2(); copy->model = tri->model; return copy; } static int VertexCount(void* ptr) { auto tri = CastToTriangulation2(ptr); return (int)tri->model.number_of_vertices(); } static int FaceCount(void* ptr) { auto tri = CastToTriangulation2(ptr); return (int)tri->model.number_of_faces(); } static void InsertPoint(void* ptr, Point2d point) { auto tri = CastToTriangulation2(ptr); tri->model.insert(point.ToCGAL()); } static void InsertPoints(void* ptr, Point2d* points, int count) { auto tri = CastToTriangulation2(ptr); std::vector list(count); for (int i = 0; i < count; i++) list[i] = points[i].ToCGAL(); tri->model.insert(list.begin(), list.end()); } static void InsertPolygon(void* triPtr, void* polyPtr) { auto tri = CastToTriangulation2(triPtr); auto polygon = Polygon2::CastToPolygon2(polyPtr); tri->model.insert(polygon->vertices_begin(), polygon->vertices_end()); } static void InsertPolygonWithHoles(void* triPtr, void* pwhPtr) { auto tri = CastToTriangulation2(triPtr); auto pwh = PolygonWithHoles2::CastToPolygonWithHoles2(pwhPtr); if (!pwh->is_unbounded()) tri->model.insert(pwh->outer_boundary().vertices_begin(), pwh->outer_boundary().vertices_end()); for (auto& hole : pwh->holes()) tri->model.insert(hole.vertices_begin(), hole.vertices_end()); } static void GetPoints(void* ptr, Point2d* points, int count) { auto tri = CastToTriangulation2(ptr); int i = 0; for (auto vert = tri->model.finite_vertices_begin(); vert != tri->model.finite_vertices_end(); ++vert) { points[i++] = Point2d::FromCGAL(vert->point()); if (i >= count) return; } } static void GetIndices(void* ptr, int* indices, int count) { auto tri = CastToTriangulation2(ptr); int index = 0; std::map map; for (auto vert = tri->model.finite_vertices_begin(); vert != tri->model.finite_vertices_end(); ++vert) { map.insert(std::pair(vert, index++)); } index = 0; for (auto face = tri->model.finite_faces_begin(); face != tri->model.finite_faces_end(); ++face) { auto i0 = map.find(face->vertex(0)); auto i1 = map.find(face->vertex(1)); auto i2 = map.find(face->vertex(2)); if (i0 == map.end() || i1 == map.end() || i2 == map.end()) { indices[index * 3 + 0] = NULL_INDEX; indices[index * 3 + 1] = NULL_INDEX; indices[index * 3 + 2] = NULL_INDEX; } else { indices[index * 3 + 0] = i0->second; indices[index * 3 + 1] = i1->second; indices[index * 3 + 2] = i2->second; } index++; if (index * 3 >= count) return; } } static void Transform(void* ptr, Point2d translation, double rotation, double scale) { auto tri = CastToTriangulation2(ptr); Transformation_2 T(CGAL::TRANSLATION, translation.ToVector()); Transformation_2 R(CGAL::ROTATION, sin(rotation), cos(rotation)); Transformation_2 S(CGAL::SCALING, scale); auto M = T * R * S; for (auto& vert : tri->model.finite_vertex_handles()) vert->point() = M(vert->point()); } static void InsertSegmentConstraint(void* ptr, Point2d a, Point2d b) { if (a == b) return; auto tri = CastToTriangulation2(ptr); tri->model.insert_constraint(a.ToCGAL(), b.ToCGAL()); } static void InsertSegmentConstraints(void* ptr, Segment2d* segments, int count) { auto tri = CastToTriangulation2(ptr); for (int i = 0; i < count; i++) { if (segments[i].a == segments[i].b) continue; auto a = segments[i].a.ToCGAL(); auto b = segments[i].b.ToCGAL(); tri->model.insert_constraint(a, b); } } static void InsertPolygonConstraint(void* triPtr, void* polyPtr) { auto tri = CastToTriangulation2(triPtr); auto polygon = Polygon2::CastToPolygon2(polyPtr); tri->model.insert_constraint(polygon->vertices_begin(), polygon->vertices_end(), true); } static void InsertPolygonWithHolesConstraint(void* triPtr, void* pwhPtr) { auto tri = CastToTriangulation2(triPtr); auto pwh = PolygonWithHoles2::CastToPolygonWithHoles2(pwhPtr); if (!pwh->is_unbounded()) tri->model.insert_constraint(pwh->outer_boundary().vertices_begin(), pwh->outer_boundary().vertices_end(), true); for (auto& hole : pwh->holes()) tri->model.insert_constraint(hole.vertices_begin(), hole.vertices_end(), true); } static void MakeConformingDelaunay(void* ptr) { auto tri = CastToTriangulation2(ptr); CGAL::make_conforming_Delaunay_2(tri->model); } static void MakeConformingGabriel(void* ptr) { auto tri = CastToTriangulation2(ptr); CGAL::make_conforming_Gabriel_2(tri->model); } void RefineAndOptimize(int iterations, double angleBounds, double lengthBounds, std::vector& seeds) { if (angleBounds > 0.125) angleBounds = 0.125; Mesher mesher(model); int numSeeds = (int)seeds.size(); if (numSeeds > 0) mesher.set_seeds(seeds.begin(), seeds.end()); mesher.set_criteria(Criteria(angleBounds, lengthBounds)); mesher.refine_mesh(); //auto code = CGAL::lloyd_optimize_mesh_2(model); } static void RefineAndOptimize(void* ptr, int iterations, double angleBounds, double lengthBounds) { auto tri = CastToTriangulation2(ptr); std::vector points; tri->RefineAndOptimize(iterations, angleBounds, lengthBounds, points); } static void RefineAndOptimize(void* ptr, int iterations, double angleBounds, double lengthBounds, Point2d* seeds, int count) { auto tri = CastToTriangulation2(ptr); std::vector points; for (int i = 0; i < count; i++) points.push_back(seeds[i].ToCGAL()); tri->RefineAndOptimize(iterations, angleBounds, lengthBounds, points); } }; ================================================ FILE: CGALWrapper/Meshing/ConformingTriangulation2_EEK.cpp ================================================ #include "ConformingTriangulation2_EEK.h" void* ConformingTriangulation2_EEK_Create() { return ConformingTriangulation2::NewTriangulation2(); } void ConformingTriangulation2_EEK_Release(void* ptr) { ConformingTriangulation2::DeleteTriangulation2(ptr); } void ConformingTriangulation2_EEK_Clear(void* ptr) { ConformingTriangulation2::Clear(ptr); } void* ConformingTriangulation2_EEK_Copy(void* ptr) { return ConformingTriangulation2::Copy(ptr); } int ConformingTriangulation2_EEK_VertexCount(void* ptr) { return ConformingTriangulation2::VertexCount(ptr); } int ConformingTriangulation2_EEK_FaceCount(void* ptr) { return ConformingTriangulation2::FaceCount(ptr); } void ConformingTriangulation2_EEK_InsertPoint(void* ptr, Point2d point) { ConformingTriangulation2::InsertPoint(ptr, point); } void ConformingTriangulation2_EEK_InsertPoints(void* ptr, Point2d* points, int count) { ConformingTriangulation2::InsertPoints(ptr, points, count); } void ConformingTriangulation2_EEK_InsertPolygon(void* triPtr, void* polyPtr) { ConformingTriangulation2::InsertPolygon(triPtr, polyPtr); } void ConformingTriangulation2_EEK_InsertPolygonWithHoles(void* triPtr, void* pwhPtr) { ConformingTriangulation2::InsertPolygonWithHoles(triPtr, pwhPtr); } void ConformingTriangulation2_EEK_GetPoints(void* ptr, Point2d* points, int count) { ConformingTriangulation2::GetPoints(ptr, points, count); } void ConformingTriangulation2_EEK_GetIndices(void* ptr, int* indices, int count) { ConformingTriangulation2::GetIndices(ptr, indices, count); } void ConformingTriangulation2_EEK_Transform(void* ptr, Point2d translation, double rotation, double scale) { ConformingTriangulation2::Transform(ptr, translation, rotation, scale); } void ConformingTriangulation2_EEK_InsertSegmentConstraint(void* ptr, Point2d a, Point2d b) { ConformingTriangulation2::InsertSegmentConstraint(ptr, a, b); } void ConformingTriangulation2_EEK_InsertSegmentConstraints(void* ptr, Segment2d* segments, int count) { ConformingTriangulation2::InsertSegmentConstraints(ptr, segments, count); } void ConformingTriangulation2_EEK_InsertPolygonConstraint(void* triPtr, void* polyPtr) { ConformingTriangulation2::InsertPolygonConstraint(triPtr, polyPtr); } void ConformingTriangulation2_EEK_InsertPolygonWithHolesConstraint(void* triPtr, void* pwhPtr) { ConformingTriangulation2::InsertPolygonWithHolesConstraint(triPtr, pwhPtr); } void ConformingTriangulation2_EEK_MakeDelaunay(void* ptr) { ConformingTriangulation2::MakeConformingDelaunay(ptr); } void ConformingTriangulation2_EEK_MakeGabriel(void* ptr) { ConformingTriangulation2::MakeConformingGabriel(ptr); } void Conformingriangulation2_EEK_RefineAndOptimize(void* ptr, int iterations, double angleBounds, double lengthBounds) { ConformingTriangulation2::RefineAndOptimize(ptr, iterations, angleBounds, lengthBounds); } void ConformingTriangulation2_EEK_RefineAndOptimizeWithSeeds(void* ptr, int iterations, double angleBounds, double lengthBounds, Point2d* points, int count) { ConformingTriangulation2::RefineAndOptimize(ptr, iterations, angleBounds, lengthBounds, points, count); } ================================================ FILE: CGALWrapper/Meshing/ConformingTriangulation2_EEK.h ================================================ #pragma once #include "../CGALWrapper.h" #include "../Geometry/Geometry2.h" #include "ConformingTriangulation2.h" extern "C" { CGALWRAPPER_API void* ConformingTriangulation2_EEK_Create(); CGALWRAPPER_API void ConformingTriangulation2_EEK_Release(void* ptr); CGALWRAPPER_API void ConformingTriangulation2_EEK_Clear(void* ptr); CGALWRAPPER_API void* ConformingTriangulation2_EEK_Copy(void* ptr); CGALWRAPPER_API int ConformingTriangulation2_EEK_VertexCount(void* ptr); CGALWRAPPER_API int ConformingTriangulation2_EEK_FaceCount(void* ptr); CGALWRAPPER_API void ConformingTriangulation2_EEK_InsertPoint(void* ptr, Point2d point); CGALWRAPPER_API void ConformingTriangulation2_EEK_InsertPoints(void* ptr, Point2d* points, int count); CGALWRAPPER_API void ConformingTriangulation2_EEK_InsertPolygon(void* triPtr, void* polyPtr); CGALWRAPPER_API void ConformingTriangulation2_EEK_InsertPolygonWithHoles(void* triPtr, void* pwhPtr); CGALWRAPPER_API void ConformingTriangulation2_EEK_GetPoints(void* ptr, Point2d* points, int count); CGALWRAPPER_API void ConformingTriangulation2_EEK_GetIndices(void* ptr, int* indices, int count); CGALWRAPPER_API void ConformingTriangulation2_EEK_Transform(void* ptr, Point2d translation, double rotation, double scale); CGALWRAPPER_API void ConformingTriangulation2_EEK_InsertSegmentConstraint(void* ptr, Point2d a, Point2d b); CGALWRAPPER_API void ConformingTriangulation2_EEK_InsertSegmentConstraints(void* ptr, Segment2d* segments, int count); CGALWRAPPER_API void ConformingTriangulation2_EEK_InsertPolygonConstraint(void* triPtr, void* polyPtr); CGALWRAPPER_API void ConformingTriangulation2_EEK_InsertPolygonWithHolesConstraint(void* triPtr, void* pwhPtr); CGALWRAPPER_API void ConformingTriangulation2_EEK_MakeDelaunay(void* ptr); CGALWRAPPER_API void ConformingTriangulation2_EEK_MakeGabriel(void* ptr); CGALWRAPPER_API void Conformingriangulation2_EEK_RefineAndOptimize(void* ptr, int iterations, double angleBounds, double lengthBounds); CGALWRAPPER_API void ConformingTriangulation2_EEK_RefineAndOptimizeWithSeeds(void* ptr, int iterations, double angleBounds, double lengthBounds, Point2d* points, int count); } ================================================ FILE: CGALWrapper/Meshing/ConformingTriangulation2_EIK.cpp ================================================ #include "ConformingTriangulation2_EIK.h" void* ConformingTriangulation2_EIK_Create() { return ConformingTriangulation2::NewTriangulation2(); } void ConformingTriangulation2_EIK_Release(void* ptr) { ConformingTriangulation2::DeleteTriangulation2(ptr); } void ConformingTriangulation2_EIK_Clear(void* ptr) { ConformingTriangulation2::Clear(ptr); } void* ConformingTriangulation2_EIK_Copy(void* ptr) { return ConformingTriangulation2::Copy(ptr); } int ConformingTriangulation2_EIK_VertexCount(void* ptr) { return ConformingTriangulation2::VertexCount(ptr); } int ConformingTriangulation2_EIK_FaceCount(void* ptr) { return ConformingTriangulation2::FaceCount(ptr); } void ConformingTriangulation2_EIK_InsertPoint(void* ptr, Point2d point) { ConformingTriangulation2::InsertPoint(ptr, point); } void ConformingTriangulation2_EIK_InsertPoints(void* ptr, Point2d* points, int count) { ConformingTriangulation2::InsertPoints(ptr, points, count); } void ConformingTriangulation2_EIK_InsertPolygon(void* triPtr, void* polyPtr) { ConformingTriangulation2::InsertPolygon(triPtr, polyPtr); } void ConformingTriangulation2_EIK_InsertPolygonWithHoles(void* triPtr, void* pwhPtr) { ConformingTriangulation2::InsertPolygonWithHoles(triPtr, pwhPtr); } void ConformingTriangulation2_EIK_GetPoints(void* ptr, Point2d* points, int count) { ConformingTriangulation2::GetPoints(ptr, points, count); } void ConformingTriangulation2_EIK_GetIndices(void* ptr, int* indices, int count) { ConformingTriangulation2::GetIndices(ptr, indices, count); } void ConformingTriangulation2_EIK_Transform(void* ptr, Point2d translation, double rotation, double scale) { ConformingTriangulation2::Transform(ptr, translation, rotation, scale); } void ConformingTriangulation2_EIK_InsertSegmentConstraint(void* ptr, Point2d a, Point2d b) { ConformingTriangulation2::InsertSegmentConstraint(ptr, a, b); } void ConformingTriangulation2_EIK_InsertSegmentConstraints(void* ptr, Segment2d* segments, int count) { ConformingTriangulation2::InsertSegmentConstraints(ptr, segments, count); } void ConformingTriangulation2_EIK_InsertPolygonConstraint(void* triPtr, void* polyPtr) { ConformingTriangulation2::InsertPolygonConstraint(triPtr, polyPtr); } void ConformingTriangulation2_EIK_InsertPolygonWithHolesConstraint(void* triPtr, void* pwhPtr) { ConformingTriangulation2::InsertPolygonWithHolesConstraint(triPtr, pwhPtr); } void ConformingTriangulation2_EIK_MakeDelaunay(void* ptr) { ConformingTriangulation2::MakeConformingDelaunay(ptr); } void ConformingTriangulation2_EIK_MakeGabriel(void* ptr) { ConformingTriangulation2::MakeConformingGabriel(ptr); } void Conformingriangulation2_EIK_RefineAndOptimize(void* ptr, int iterations, double angleBounds, double lengthBounds) { ConformingTriangulation2::RefineAndOptimize(ptr, iterations, angleBounds, lengthBounds); } void ConformingTriangulation2_EIK_RefineAndOptimizeWithSeeds(void* ptr, int iterations, double angleBounds, double lengthBounds, Point2d* points, int count) { ConformingTriangulation2::RefineAndOptimize(ptr, iterations, angleBounds, lengthBounds, points, count); } ================================================ FILE: CGALWrapper/Meshing/ConformingTriangulation2_EIK.h ================================================ #pragma once #include "../CGALWrapper.h" #include "../Geometry/Geometry2.h" #include "ConformingTriangulation2.h" extern "C" { CGALWRAPPER_API void* ConformingTriangulation2_EIK_Create(); CGALWRAPPER_API void ConformingTriangulation2_EIK_Release(void* ptr); CGALWRAPPER_API void ConformingTriangulation2_EIK_Clear(void* ptr); CGALWRAPPER_API void* ConformingTriangulation2_EIK_Copy(void* ptr); CGALWRAPPER_API int ConformingTriangulation2_EIK_VertexCount(void* ptr); CGALWRAPPER_API int ConformingTriangulation2_EIK_FaceCount(void* ptr); CGALWRAPPER_API void ConformingTriangulation2_EIK_InsertPoint(void* ptr, Point2d point); CGALWRAPPER_API void ConformingTriangulation2_EIK_InsertPoints(void* ptr, Point2d* points, int count); CGALWRAPPER_API void ConformingTriangulation2_EIK_InsertPolygon(void* triPtr, void* polyPtr); CGALWRAPPER_API void ConformingTriangulation2_EIK_InsertPolygonWithHoles(void* triPtr, void* pwhPtr); CGALWRAPPER_API void ConformingTriangulation2_EIK_GetPoints(void* ptr, Point2d* points, int count); CGALWRAPPER_API void ConformingTriangulation2_EIK_GetIndices(void* ptr, int* indices, int count); CGALWRAPPER_API void ConformingTriangulation2_EIK_Transform(void* ptr, Point2d translation, double rotation, double scale); CGALWRAPPER_API void ConformingTriangulation2_EIK_InsertSegmentConstraint(void* ptr, Point2d a, Point2d b); CGALWRAPPER_API void ConformingTriangulation2_EIK_InsertSegmentConstraints(void* ptr, Segment2d* segments, int count); CGALWRAPPER_API void ConformingTriangulation2_EIK_InsertPolygonConstraint(void* triPtr, void* polyPtr); CGALWRAPPER_API void ConformingTriangulation2_EIK_InsertPolygonWithHolesConstraint(void* triPtr, void* pwhPtr); CGALWRAPPER_API void ConformingTriangulation2_EIK_MakeDelaunay(void* ptr); CGALWRAPPER_API void ConformingTriangulation2_EIK_MakeGabriel(void* ptr); CGALWRAPPER_API void Conformingriangulation2_EIK_RefineAndOptimize(void* ptr, int iterations, double angleBounds, double lengthBounds); CGALWRAPPER_API void ConformingTriangulation2_EIK_RefineAndOptimizeWithSeeds(void* ptr, int iterations, double angleBounds, double lengthBounds, Point2d* points, int count); } ================================================ FILE: CGALWrapper/Meshing/SkinSurfaceMeshing_EEK.cpp ================================================ #include "SkinSurfaceMeshing_EEK.h" #include "SkinSurfaceMesing.h" void* SkinSurfaceMeshing_EEK_Create() { return SkinSurfaceMeshing::NewSkinSurfaceMeshing(); } void SkinSurfaceMeshing_EEK_Release(void* ptr) { SkinSurfaceMeshing::DeleteSkinSurfaceMeshing(ptr); } void* SkinSurfaceMeshing_EEK_MakeSkinSurface_Point3d(double shrinkfactor, BOOL subdivide, Point3d* points, int count) { return SkinSurfaceMeshing::MakeSkinSurface(shrinkfactor, subdivide, points, count); } void* SkinSurfaceMeshing_EEK_MakeSkinSurface_HPoint3d(double shrinkfactor, BOOL subdivide, HPoint3d* points, int count) { return SkinSurfaceMeshing::MakeSkinSurface(shrinkfactor, subdivide, points, count); } ================================================ FILE: CGALWrapper/Meshing/SkinSurfaceMeshing_EEK.h ================================================ #pragma once #include "../CGALWrapper.h" #include "../Geometry/Geometry3.h" extern "C" { CGALWRAPPER_API void* SkinSurfaceMeshing_EEK_Create(); CGALWRAPPER_API void SkinSurfaceMeshing_EEK_Release(void* ptr); CGALWRAPPER_API void* SkinSurfaceMeshing_EEK_MakeSkinSurface_Point3d(double shrinkfactor, BOOL subdivide, Point3d* points, int count); CGALWRAPPER_API void* SkinSurfaceMeshing_EEK_MakeSkinSurface_HPoint3d(double shrinkfactor, BOOL subdivide, HPoint3d* points, int count); } ================================================ FILE: CGALWrapper/Meshing/SkinSurfaceMesing.h ================================================ #pragma once #include "../CGALWrapper.h" #include "../Geometry/Geometry3.h" #include "../Polyhedra//Polyhedron3.h" #include #include #include #include #include #include template class SkinSurfaceMeshing { public: typedef typename K::Point_3 Point; typedef typename K::Weighted_point_3 WPoint; typedef typename CGAL::Polyhedron_3 Polyhedron; typedef typename CGAL::Skin_surface_traits_3 Traits; typedef typename CGAL::Skin_surface_3 Skin_surface_3; inline static SkinSurfaceMeshing* NewSkinSurfaceMeshing() { return new SkinSurfaceMeshing(); } inline static void DeleteSkinSurfaceMeshing(void* ptr) { auto obj = static_cast(ptr); if (obj != nullptr) { delete obj; obj = nullptr; } } inline static SkinSurfaceMeshing* CastToSkinSurfaceMeshing(void* ptr) { return static_cast(ptr); } static std::vector PointList(HPoint3d* points, int count) { std::vector< WPoint> list(count); for (int i = 0; i < count; i++) { list[i] = points[i].ToCGALWeightedPoint(); } return list; } static std::vector PointList(Point3d* points, int count) { std::vector< WPoint> list(count); for (int i = 0; i < count; i++) { list[i] = points[i].ToCGALWeightedPoint(); } return list; } static void* MakeSkinSurface(double shrinkfactor, BOOL subdivide, Point3d* points, int count) { auto list = PointList(points, count); auto poly = Polyhedron3::NewPolyhedron(); Skin_surface_3 skin_surface(list.begin(), list.end(), shrinkfactor); CGAL::mesh_skin_surface_3(skin_surface, poly->model); if (subdivide) CGAL::subdivide_skin_surface_mesh_3(skin_surface, poly->model); poly->OnModelChanged(); return poly; } static void* MakeSkinSurface(double shrinkfactor, BOOL subdivide, HPoint3d* points, int count) { auto list = PointList(points, count); auto poly = Polyhedron3::NewPolyhedron(); Skin_surface_3 skin_surface(list.begin(), list.end(), shrinkfactor); CGAL::mesh_skin_surface_3(skin_surface, poly->model); if(subdivide) CGAL::subdivide_skin_surface_mesh_3(skin_surface, poly->model); poly->OnModelChanged(); return poly; } }; ================================================ FILE: CGALWrapper/Meshing/TetrahedralRemeshing.h ================================================ #pragma once #include "../CGALWrapper.h" #include "../Geometry/Geometry3.h" #include #include #include #include #include #include #include #include template class TetrahedralRemeshing { private: std::vector buffer; public: typedef typename CGAL::Tetrahedral_remeshing::Remeshing_triangulation_3 Remeshing_triangulation; typedef typename Remeshing_triangulation::Point Point; inline static TetrahedralRemeshing* NewTetrahedralRemeshing() { return new TetrahedralRemeshing(); } inline static void DeleteTetrahedralRemeshing(void* ptr) { auto obj = static_cast(ptr); if (obj != nullptr) { delete obj; obj = nullptr; } } inline static TetrahedralRemeshing* CastToTetrahedralRemeshing(void* ptr) { return static_cast(ptr); } static std::vector PointList(Point3d* points, int count) { std::vector list(count); for (int i = 0; i < count; i++) list[i] = points[i].ToCGAL(); return list; } static void GetPoints(void* ptr, Point3d* points, int count) { auto mesher = CastToTetrahedralRemeshing(ptr); for (int i = 0; i < count; i++) { points[i] = mesher->buffer[i]; if (i >= mesher->buffer.size()) break; } mesher->buffer.clear(); } static int Remesh(void* ptr, double targetLength, int iterations, Point3d* points, int count) { auto mesher = CastToTetrahedralRemeshing(ptr); auto list = PointList(points, count); auto tr = Remeshing_triangulation(list.begin(), list.end()); CGAL::tetrahedral_isotropic_remeshing(tr, targetLength, CGAL::parameters::number_of_iterations(iterations)); mesher->buffer.clear(); for (auto v = tr.vertices_begin(); v != tr.vertices_end(); ++v) { auto p = v->point(); mesher->buffer.push_back(Point3d::FromCGAL(p)); } return (int)mesher->buffer.size(); } }; ================================================ FILE: CGALWrapper/Meshing/TetrahedralRemeshing_EEK.cpp ================================================ #include "TetrahedralRemeshing_EEK.h" #include "TetrahedralRemeshing.h" #include #include void* TetrahedralRemeshing_EEK_Create() { return TetrahedralRemeshing::NewTetrahedralRemeshing(); } void TetrahedralRemeshing_EEK_Release(void* ptr) { TetrahedralRemeshing::DeleteTetrahedralRemeshing(ptr); } void TetrahedralRemeshing_EEK_GetPoints(void* ptr, Point3d* points, int count) { TetrahedralRemeshing::GetPoints(ptr, points, count); } int TetrahedralRemeshing_EEK_Remesh(void* ptr, double targetLength, int iterations, Point3d* points, int count) { /* typedef typename CGAL::Tetrahedral_remeshing::Remeshing_triangulation_3 Remeshing_triangulation; typedef typename Remeshing_triangulation::Point Point; std::vector points; points.push_back(Point(1, 0, 0)); points.push_back(Point(0, 1, 0)); points.push_back(Point(0, 0, 1)); points.push_back(Point(0, 0, 0)); Remeshing_triangulation tr = Remeshing_triangulation(points.begin(), points.end()); CGAL::tetrahedral_isotropic_remeshing(tr, target_edge_length, CGAL::parameters::number_of_iterations(iterations)); std::cout << "Number of cells " << tr.number_of_cells() << std::endl; for (auto v = tr.vertices_begin(); v != tr.vertices_end(); ++v) { auto p = v->point(); buffer.push_back(Point3d::FromCGAL(p)); } */ return TetrahedralRemeshing::Remesh(ptr, targetLength, iterations, points, count); } ================================================ FILE: CGALWrapper/Meshing/TetrahedralRemeshing_EEK.h ================================================ #pragma once #include "../CGALWrapper.h" #include "../Geometry/Geometry3.h" extern "C" { CGALWRAPPER_API void* TetrahedralRemeshing_EEK_Create(); CGALWRAPPER_API void TetrahedralRemeshing_EEK_Release(void* ptr); CGALWRAPPER_API void TetrahedralRemeshing_EEK_GetPoints(void* ptr, Point3d* points, int count); CGALWRAPPER_API int TetrahedralRemeshing_EEK_Remesh(void* ptr, double targetLength, int iterations, Point3d* points, int count); } ================================================ FILE: CGALWrapper/Polygons/Polygon2.h ================================================ #pragma once #include "../CGALWrapper.h" #include "../Geometry/Geometry2.h" #include #include #include #include #include #include template class Polygon2 { public: Polygon2() {} typedef CGAL::Point_2 Point_2; typedef CGAL::Segment_2 Segment_2; typedef CGAL::Polygon_2 Polygon_2; typedef CGAL::Aff_transformation_2 Transformation_2; inline static Polygon_2* NewPolygon2() { return new Polygon_2(); } inline static void DeletePolygon2(void* ptr) { auto obj = static_cast(ptr); if (obj != nullptr) { delete obj; obj = nullptr; } } inline static Polygon_2* CastToPolygon2(void* ptr) { return static_cast(ptr); } inline static Polygon_2* CreatePolygon2(const Polygon_2& poly) { return new Polygon_2(poly); } inline static bool OutOfRange(Polygon_2* poly, int index) { if (index < 0 || index >= poly->size()) return true; else return false; } static int Count(void* ptr) { auto polygon = CastToPolygon2(ptr); return (int)polygon->size(); } static Box2d GetBoundingBox(void* ptr) { auto polygon = CastToPolygon2(ptr); auto box = polygon->bbox(); return Box2d::FromCGAL(box); } static void* Copy(void* ptr) { auto polygon = CastToPolygon2(ptr); return new Polygon_2(*polygon); } template static void* Convert(void* ptr) { typedef CGAL::Cartesian_converter Converter; Converter convert; auto polygon = CastToPolygon2(ptr); auto count = polygon->size(); auto poly2 = new CGAL::Polygon_2(); for (auto i = 0; i < count; i++) { auto p = convert(polygon->vertex(i)); poly2->push_back(p); } return poly2; } static void Clear(void* ptr) { auto polygon = CastToPolygon2(ptr); polygon->clear(); } static int Capacity(void* ptr) { auto polygon = CastToPolygon2(ptr); return (int)polygon->container().capacity(); } static void Resize(void* ptr, int count) { auto polygon = CastToPolygon2(ptr); polygon->container().resize(count); } static void ShrinkToFit(void* ptr) { auto polygon = CastToPolygon2(ptr); polygon->container().shrink_to_fit(); } static void Erase(void* ptr, int index) { auto polygon = CastToPolygon2(ptr); if (OutOfRange(polygon, index)) return; polygon->container().erase(polygon->container().begin() + index); } static void Erase(void* ptr, int start, int count) { auto polygon = CastToPolygon2(ptr); if (OutOfRange(polygon, start) || OutOfRange(polygon, start + count)) return; polygon->container().erase(polygon->container().begin() + start, polygon->container().begin() + count); } static void Insert(void* ptr, int index, Point2d point) { auto polygon = CastToPolygon2(ptr); if (OutOfRange(polygon, index)) return; polygon->container().insert(polygon->container().begin() + index, point.ToCGAL()); } static void Insert(void* ptr, int start, int count, Point2d* points) { auto polygon = CastToPolygon2(ptr); if (OutOfRange(polygon, start)) return; std::vector tmp(count); for (int i = 0; i < count; i++) tmp.push_back(points[i].ToCGAL()); polygon->container().insert(polygon->container().begin() + start, tmp.begin(), tmp.end()); } static double SqPerimeter(void* ptr) { auto polygon = CastToPolygon2(ptr); auto count = polygon->container().size(); if (count < 2) return 0; auto sum = CGAL::squared_distance(polygon->vertex(0), polygon->vertex(1)); for (auto i = 1; i < count - 1; i++) sum += CGAL::squared_distance(polygon->vertex(i), polygon->vertex(i + 1)); return CGAL::to_double(sum); } static Point2d GetPoint(void* ptr, int index) { auto polygon = CastToPolygon2(ptr); if (OutOfRange(polygon, index)) return { 0, 0}; auto point = polygon->vertex(index); return Point2d::FromCGAL(point); } static void GetPoints(void* ptr, Point2d* points, int count) { auto polygon = CastToPolygon2(ptr); auto size = polygon->size(); if (size == 0) return; for (auto i = 0; i < count; i++) { auto point = polygon->vertex(i); points[i] = Point2d::FromCGAL(point); if (i >= size) return; } } static void GetPoints(Polygon_2* polygon, std::vector& points) { int count = (int)polygon->size(); for (auto i = 0; i < count; i++) { auto point = polygon->vertex(i); points.push_back(Point2d::FromCGAL(point)); } } inline static int Wrap(int v, int count) { int r = v % count; return r < 0 ? r + count : r; } static void GetSegments(void* ptr, Segment2d* segments, int count) { auto polygon = CastToPolygon2(ptr); auto size = polygon->size(); if (size == 0) return; for (auto i = 0; i < count; i++) { int i0 = Wrap(i + 0, count); int i1 = Wrap(i + 1, count); auto v0 = polygon->vertex(i0); auto v1 = polygon->vertex(i1); segments[i].a = Point2d::FromCGAL(v0); segments[i].b = Point2d::FromCGAL(v1); if (i >= size) return; } } static void SetPoint(void* ptr, int index, const Point2d& point) { auto polygon = CastToPolygon2(ptr); if (OutOfRange(polygon, index)) return; (*polygon)[index] = point.ToCGAL(); } static void SetPoints(void* ptr, Point2d* points, int count) { auto polygon = CastToPolygon2(ptr); auto size = polygon->size(); for (int i = 0; i < count; i++) { if (i < size) (*polygon)[i] = points[i].ToCGAL(); else { //Adding more points than polygon currently contains //so push back instead. polygon->push_back(points[i].ToCGAL()); } } } static void Reverse(void* ptr) { auto polygon = CastToPolygon2(ptr); polygon->reverse_orientation(); } static BOOL IsSimple(void* ptr) { auto polygon = CastToPolygon2(ptr); return polygon->is_simple(); } static BOOL IsConvex(void* ptr) { auto polygon = CastToPolygon2(ptr); return polygon->is_convex(); } static CGAL::Orientation Orientation(void* ptr) { auto polygon = CastToPolygon2(ptr); return polygon->orientation(); } static CGAL::Oriented_side OrientedSide(void* ptr, const Point2d& point) { auto polygon = CastToPolygon2(ptr); return polygon->oriented_side(point.ToCGAL()); } static CGAL::Bounded_side BoundedSide(void* ptr, const Point2d& point) { auto polygon = CastToPolygon2(ptr); return polygon->bounded_side(point.ToCGAL()); } static double SignedArea(void* ptr) { auto polygon = CastToPolygon2(ptr); return CGAL::to_double(polygon->area()); } static void Translate(void* ptr, const Point2d& translation) { auto polygon = CastToPolygon2(ptr); Transformation_2 transformation(CGAL::TRANSLATION, translation.ToVector()); (*polygon) = CGAL::transform(transformation, *polygon); } static void Rotate(void* ptr, double rotation) { auto polygon = CastToPolygon2(ptr); Transformation_2 transformation(CGAL::ROTATION, sin(rotation), cos(rotation)); (*polygon) = CGAL::transform(transformation, *polygon); } static void Scale(void* ptr, double scale) { auto polygon = CastToPolygon2(ptr); Transformation_2 transformation(CGAL::SCALING, scale); (*polygon) = CGAL::transform(transformation, *polygon); } static void Transform(void* ptr, const Point2d& translation, double rotation, double scale) { auto polygon = CastToPolygon2(ptr); Transformation_2 T(CGAL::TRANSLATION, translation.ToVector()); Transformation_2 R(CGAL::ROTATION, sin(rotation), cos(rotation)); Transformation_2 S(CGAL::SCALING, scale); (*polygon) = CGAL::transform(T * R * S, *polygon); } static BOOL ContainsPoint(void* ptr, const Point2d& point, CGAL::Orientation orientation, BOOL inculdeBoundary) { auto polygon = CastToPolygon2(ptr); auto side = polygon->oriented_side(point.ToCGAL()); if (inculdeBoundary && side == CGAL::Oriented_side::ON_ORIENTED_BOUNDARY) return true; return side == orientation; } }; ================================================ FILE: CGALWrapper/Polygons/Polygon2_EEK.cpp ================================================ #include "Polygon2_EEK.h" #include "Polygon2.h" #include void* Polygon2_EEK_Create() { return Polygon2::NewPolygon2(); } void Polygon2_EEK_Release(void* ptr) { Polygon2::DeletePolygon2(ptr); } int Polygon2_EEK_Count(void* ptr) { auto polygon = Polygon2::CastToPolygon2(ptr); return Polygon2::Count(ptr); } Box2d Polygon2_EEK_GetBoundingBox(void* ptr) { return Polygon2::GetBoundingBox(ptr); } void* Polygon2_EEK_Copy(void* ptr) { return Polygon2::Copy(ptr); } void* Polygon2_EEK_Convert(void* ptr, CGAL_KERNEL k) { switch (k) { case CGAL_KERNEL::EXACT_PREDICATES_INEXACT_CONSTRUCTION: return Polygon2::Convert(ptr); case CGAL_KERNEL::EXACT_PREDICATES_EXACT_CONSTRUCTION: return Polygon2::Convert(ptr); default: return Polygon2::Convert(ptr); } } void Polygon2_EEK_Clear(void* ptr) { Polygon2::Clear(ptr); } int Polygon2_EEK_Capacity(void* ptr) { return Polygon2::Capacity(ptr); } void Polygon2_EEK_Resize(void* ptr, int count) { Polygon2::Resize(ptr, count); } void Polygon2_EEK_ShrinkToFit(void* ptr) { Polygon2::ShrinkToFit(ptr); } void Polygon2_EEK_Erase(void* ptr, int index) { Polygon2::Erase(ptr, index); } void Polygon2_EEK_EraseRange(void* ptr, int start, int count) { Polygon2::Erase(ptr, start, count); } void Polygon2_EEK_Insert(void* ptr, int index, Point2d point) { Polygon2::Insert(ptr, index, point); } void Polygon2_EEK_InsertRange(void* ptr, int start, int count, Point2d* points) { Polygon2::Insert(ptr, start, count, points); } double Polygon2_EEK_SqPerimeter(void* ptr) { return Polygon2::SqPerimeter(ptr); } Point2d Polygon2_EEK_GetPoint(void* ptr, int index) { return Polygon2::GetPoint(ptr, index); } void Polygon2_EEK_GetPoints(void* ptr, Point2d* points, int count) { Polygon2::GetPoints(ptr, points, count); } void Polygon2_EEK_GetSegments(void* ptr, Segment2d* segments, int count) { Polygon2::GetSegments(ptr, segments, count); } void Polygon2_EEK_SetPoint(void* ptr, int index, const Point2d& point) { Polygon2::SetPoint(ptr, index, point); } void Polygon2_EEK_SetPoints(void* ptr, Point2d* points, int count) { Polygon2::SetPoints(ptr, points, count); } void Polygon2_EEK_Reverse(void* ptr) { Polygon2::Reverse(ptr); } BOOL Polygon2_EEK_IsSimple(void* ptr) { auto polygon = (CGAL::Polygon_2*)ptr; return polygon->is_simple(); //return Polygon2::IsSimple<(ptr); } BOOL Polygon2_EEK_IsConvex(void* ptr) { return Polygon2::IsConvex(ptr); } CGAL::Orientation Polygon2_EEK_Orientation(void* ptr) { return Polygon2::Orientation(ptr); } CGAL::Oriented_side Polygon2_EEK_OrientedSide(void* ptr, const Point2d& point) { return Polygon2::OrientedSide(ptr, point); } CGAL::Bounded_side Polygon2_EEK_BoundedSide(void* ptr, const Point2d& point) { return Polygon2::BoundedSide(ptr, point); } double Polygon2_EEK_SignedArea(void* ptr) { return Polygon2::SignedArea(ptr); } void Polygon2_EEK_Translate(void* ptr, const Point2d& translation) { Polygon2::Translate(ptr, translation); } void Polygon2_EEK_Rotate(void* ptr, double rotation) { Polygon2::Rotate(ptr, rotation); } void Polygon2_EEK_Scale(void* ptr, double scale) { Polygon2::Scale(ptr, scale); } void Polygon2_EEK_Transform(void* ptr, const Point2d& translation, double rotation, double scale) { Polygon2::Transform(ptr, translation, rotation, scale); } BOOL Polygon2_EEK_ContainsPoint(void* ptr, const Point2d& point, CGAL::Orientation orientation, BOOL inculdeBoundary) { return Polygon2::ContainsPoint(ptr, point, orientation, inculdeBoundary); } ================================================ FILE: CGALWrapper/Polygons/Polygon2_EEK.h ================================================ #pragma once #include "../CGALWrapper.h" #include "../Geometry/Geometry2.h" #include extern "C" { CGALWRAPPER_API void* Polygon2_EEK_Create(); CGALWRAPPER_API void Polygon2_EEK_Release(void* ptr); CGALWRAPPER_API int Polygon2_EEK_Count(void* ptr); CGALWRAPPER_API Box2d Polygon2_EEK_GetBoundingBox(void* ptr); CGALWRAPPER_API void* Polygon2_EEK_Copy(void* ptr); CGALWRAPPER_API void* Polygon2_EEK_Convert(void* ptr, CGAL_KERNEL k); CGALWRAPPER_API void Polygon2_EEK_Clear(void* ptr); CGALWRAPPER_API int Polygon2_EEK_Capacity(void* ptr); CGALWRAPPER_API void Polygon2_EEK_Resize(void* ptr, int count); CGALWRAPPER_API void Polygon2_EEK_ShrinkToFit(void* ptr); CGALWRAPPER_API void Polygon2_EEK_Erase(void* ptr, int index); CGALWRAPPER_API void Polygon2_EEK_EraseRange(void* ptr, int start, int count); CGALWRAPPER_API void Polygon2_EEK_Insert(void* ptr, int index, Point2d point); CGALWRAPPER_API void Polygon2_EEK_InsertRange(void* ptr, int start, int count, Point2d* points); CGALWRAPPER_API double Polygon2_EEK_SqPerimeter(void* ptr); CGALWRAPPER_API Point2d Polygon2_EEK_GetPoint(void* ptr, int index); CGALWRAPPER_API void Polygon2_EEK_GetPoints(void* ptr, Point2d * points, int count); CGALWRAPPER_API void Polygon2_EEK_GetSegments(void* ptr, Segment2d* segments, int count); CGALWRAPPER_API void Polygon2_EEK_SetPoint(void* ptr, int index, const Point2d& point); CGALWRAPPER_API void Polygon2_EEK_SetPoints(void* ptr, Point2d * points, int count); CGALWRAPPER_API void Polygon2_EEK_Reverse(void* ptr); CGALWRAPPER_API BOOL Polygon2_EEK_IsSimple(void* ptr); CGALWRAPPER_API BOOL Polygon2_EEK_IsConvex(void* ptr); CGALWRAPPER_API CGAL::Orientation Polygon2_EEK_Orientation(void* ptr); CGALWRAPPER_API CGAL::Oriented_side Polygon2_EEK_OrientedSide(void* ptr, const Point2d& point); CGALWRAPPER_API CGAL::Bounded_side Polygon2_EEK_BoundedSide(void* ptr, const Point2d& point); CGALWRAPPER_API double Polygon2_EEK_SignedArea(void* ptr); CGALWRAPPER_API void Polygon2_EEK_Translate(void* ptr, const Point2d& translation); CGALWRAPPER_API void Polygon2_EEK_Rotate(void* ptr, double rotation); CGALWRAPPER_API void Polygon2_EEK_Scale(void* ptr, double scale); CGALWRAPPER_API void Polygon2_EEK_Transform(void* ptr, const Point2d& translation, double rotation, double scale); CGALWRAPPER_API BOOL Polygon2_EEK_ContainsPoint(void* ptr, const Point2d& point, CGAL::Orientation orientation, BOOL inculdeBoundary); } ================================================ FILE: CGALWrapper/Polygons/Polygon2_EIK.cpp ================================================ #include "Polygon2_EIK.h" #include "Polygon2.h" #include void* Polygon2_EIK_Create() { return Polygon2::NewPolygon2(); } void Polygon2_EIK_Release(void* ptr) { Polygon2::DeletePolygon2(ptr); } int Polygon2_EIK_Count(void* ptr) { auto polygon = Polygon2::CastToPolygon2(ptr); return Polygon2::Count(ptr); } Box2d Polygon2_EIK_GetBoundingBox(void* ptr) { return Polygon2::GetBoundingBox(ptr); } void* Polygon2_EIK_Copy(void* ptr) { return Polygon2::Copy(ptr); } void* Polygon2_EIK_Convert(void* ptr, CGAL_KERNEL k) { switch (k) { case CGAL_KERNEL::EXACT_PREDICATES_INEXACT_CONSTRUCTION: return Polygon2::Convert(ptr); case CGAL_KERNEL::EXACT_PREDICATES_EXACT_CONSTRUCTION: return Polygon2::Convert(ptr); default: return Polygon2::Convert(ptr); } } void Polygon2_EIK_Clear(void* ptr) { Polygon2::Clear(ptr); } int Polygon2_EIK_Capacity(void* ptr) { return Polygon2::Capacity(ptr); } void Polygon2_EIK_Resize(void* ptr, int count) { Polygon2::Resize(ptr, count); } void Polygon2_EIK_ShrinkToFit(void* ptr) { Polygon2::ShrinkToFit(ptr); } void Polygon2_EIK_Erase(void* ptr, int index) { Polygon2::Erase(ptr, index); } void Polygon2_EIK_EraseRange(void* ptr, int start, int count) { Polygon2::Erase(ptr, start, count); } void Polygon2_EIK_Insert(void* ptr, int index, Point2d point) { Polygon2::Insert(ptr, index, point); } void Polygon2_EIK_InsertRange(void* ptr, int start, int count, Point2d* points) { Polygon2::Insert(ptr, start, count, points); } double Polygon2_EIK_SqPerimeter(void* ptr) { return Polygon2::SqPerimeter(ptr); } Point2d Polygon2_EIK_GetPoint(void* ptr, int index) { return Polygon2::GetPoint(ptr, index); } void Polygon2_EIK_GetPoints(void* ptr, Point2d* points, int count) { Polygon2::GetPoints(ptr, points, count); } void Polygon2_EIK_GetSegments(void* ptr, Segment2d* segments, int count) { Polygon2::GetSegments(ptr, segments, count); } void Polygon2_EIK_SetPoint(void* ptr, int index, const Point2d& point) { Polygon2::SetPoint(ptr, index, point); } void Polygon2_EIK_SetPoints(void* ptr, Point2d* points, int count) { Polygon2::SetPoints(ptr, points, count); } void Polygon2_EIK_Reverse(void* ptr) { Polygon2::Reverse(ptr); } BOOL Polygon2_EIK_IsSimple(void* ptr) { auto polygon = (CGAL::Polygon_2*)ptr; return polygon->is_simple(); //return Polygon2::IsSimple<(ptr); } BOOL Polygon2_EIK_IsConvex(void* ptr) { return Polygon2::IsConvex(ptr); } CGAL::Orientation Polygon2_EIK_Orientation(void* ptr) { return Polygon2::Orientation(ptr); } CGAL::Oriented_side Polygon2_EIK_OrientedSide(void* ptr, const Point2d& point) { return Polygon2::OrientedSide(ptr, point); } CGAL::Bounded_side Polygon2_EIK_BoundedSide(void* ptr, const Point2d& point) { return Polygon2::BoundedSide(ptr, point); } double Polygon2_EIK_SignedArea(void* ptr) { return Polygon2::SignedArea(ptr); } void Polygon2_EIK_Translate(void* ptr, const Point2d& translation) { Polygon2::Translate(ptr, translation); } void Polygon2_EIK_Rotate(void* ptr, double rotation) { Polygon2::Rotate(ptr, rotation); } void Polygon2_EIK_Scale(void* ptr, double scale) { Polygon2::Scale(ptr, scale); } void Polygon2_EIK_Transform(void* ptr, const Point2d& translation, double rotation, double scale) { Polygon2::Transform(ptr, translation, rotation, scale); } BOOL Polygon2_EIK_ContainsPoint(void* ptr, const Point2d& point, CGAL::Orientation orientation, BOOL inculdeBoundary) { return Polygon2::ContainsPoint(ptr, point, orientation, inculdeBoundary); } ================================================ FILE: CGALWrapper/Polygons/Polygon2_EIK.h ================================================ #pragma once #include "../CGALWrapper.h" #include "../Geometry/Geometry2.h" #include extern "C" { CGALWRAPPER_API void* Polygon2_EIK_Create(); CGALWRAPPER_API void Polygon2_EIK_Release(void* ptr); CGALWRAPPER_API int Polygon2_EIK_Count(void* ptr); CGALWRAPPER_API Box2d Polygon2_EIK_GetBoundingBox(void* ptr); CGALWRAPPER_API void* Polygon2_EIK_Copy(void* ptr); CGALWRAPPER_API void* Polygon2_EIK_Convert(void* ptr, CGAL_KERNEL k); CGALWRAPPER_API void Polygon2_EIK_Clear(void* ptr); CGALWRAPPER_API int Polygon2_EIK_Capacity(void* ptr); CGALWRAPPER_API void Polygon2_EIK_Resize(void* ptr, int count); CGALWRAPPER_API void Polygon2_EIK_ShrinkToFit(void* ptr); CGALWRAPPER_API void Polygon2_EIK_Erase(void* ptr, int index); CGALWRAPPER_API void Polygon2_EIK_EraseRange(void* ptr, int start, int count); CGALWRAPPER_API void Polygon2_EIK_Insert(void* ptr, int index, Point2d point); CGALWRAPPER_API void Polygon2_EIK_InsertRange(void* ptr, int start, int count, Point2d* points); CGALWRAPPER_API double Polygon2_EIK_SqPerimeter(void* ptr); CGALWRAPPER_API Point2d Polygon2_EIK_GetPoint(void* ptr, int index); CGALWRAPPER_API void Polygon2_EIK_GetPoints(void* ptr, Point2d* points, int count); CGALWRAPPER_API void Polygon2_EIK_GetSegments(void* ptr, Segment2d* segments, int count); CGALWRAPPER_API void Polygon2_EIK_SetPoint(void* ptr, int index, const Point2d& point); CGALWRAPPER_API void Polygon2_EIK_SetPoints(void* ptr, Point2d* points, int count); CGALWRAPPER_API void Polygon2_EIK_Reverse(void* ptr); CGALWRAPPER_API BOOL Polygon2_EIK_IsSimple(void* ptr); CGALWRAPPER_API BOOL Polygon2_EIK_IsConvex(void* ptr); CGALWRAPPER_API CGAL::Orientation Polygon2_EIK_Orientation(void* ptr); CGALWRAPPER_API CGAL::Oriented_side Polygon2_EIK_OrientedSide(void* ptr, const Point2d& point); CGALWRAPPER_API CGAL::Bounded_side Polygon2_EIK_BoundedSide(void* ptr, const Point2d& point); CGALWRAPPER_API double Polygon2_EIK_SignedArea(void* ptr); CGALWRAPPER_API void Polygon2_EIK_Translate(void* ptr, const Point2d& translation); CGALWRAPPER_API void Polygon2_EIK_Rotate(void* ptr, double rotation); CGALWRAPPER_API void Polygon2_EIK_Scale(void* ptr, double scale); CGALWRAPPER_API void Polygon2_EIK_Transform(void* ptr, const Point2d& translation, double rotation, double scale); CGALWRAPPER_API BOOL Polygon2_EIK_ContainsPoint(void* ptr, const Point2d& point, CGAL::Orientation orientation, BOOL inculdeBoundary); } ================================================ FILE: CGALWrapper/Polygons/PolygonBoolean2.h ================================================ #pragma once #include "../CGALWrapper.h" #include "../Geometry/Geometry2.h" #include #include #include #include #include template class PolygonBoolean2 { public: typedef CGAL::Polygon_2 Polygon_2; typedef CGAL::Polygon_with_holes_2 Pwh_2; private: std::vector buffer; public: PolygonBoolean2() { } ~PolygonBoolean2() { } inline static PolygonBoolean2* NewPolygonBoolean2() { return new PolygonBoolean2(); } inline static void DeletePolygonBoolean2(void* ptr) { auto obj = static_cast(ptr); if (obj != nullptr) { delete obj; obj = nullptr; } } inline static PolygonBoolean2* CastToBoolean2(void* ptr) { return static_cast(ptr); } inline static Polygon_2* CastToPolygon2(void* ptr) { return static_cast(ptr); } inline static Pwh_2* CastToPolygonWithHoles2(void* ptr) { return static_cast(ptr); } static void ClearBuffer(void* ptr) { auto boo = CastToBoolean2(ptr); boo->buffer.clear(); } static void* CopyBufferItem(void* ptr, int index) { auto boo = CastToBoolean2(ptr); return new Pwh_2(boo->buffer[index]); } //Do Intersect template BOOL DoIntersect(P1* polygon1, P2* polygon2) { return CGAL::do_intersect(*polygon1, *polygon2); } static BOOL DoIntersect_P_P(void* ptr0, void* ptr1, void* ptr2) { auto boo = CastToBoolean2(ptr0); auto polygon1 = CastToPolygon2(ptr1); auto polygon2 = CastToPolygon2(ptr2); return boo->DoIntersect(polygon1, polygon2); } static BOOL DoIntersect_P_PWH(void* ptr0, void* ptr1, void* ptr2) { auto boo = CastToBoolean2(ptr0); auto polygon1 = CastToPolygon2(ptr1); auto polygon2 = CastToPolygonWithHoles2(ptr2); return boo->DoIntersect(polygon1, polygon2); } static BOOL DoIntersect_PWH_PWH(void* ptr0, void* ptr1, void* ptr2) { auto boo = CastToBoolean2(ptr0); auto polygon1 = CastToPolygonWithHoles2(ptr1); auto polygon2 = CastToPolygonWithHoles2(ptr2); return boo->DoIntersect(polygon1, polygon2); } //Join template BOOL Join(P1* polygon1, P2* polygon2, void** resultPtr) { auto result = new CGAL::Polygon_with_holes_2(); if (CGAL::join(*polygon1, *polygon2, *result)) { *resultPtr = result; return true; } else { delete result; result = nullptr; return false; } } static BOOL Join_P_P(void* ptr0, void* ptr1, void* ptr2, void** resultPtr) { auto boo = CastToBoolean2(ptr0); auto polygon1 = CastToPolygon2(ptr1); auto polygon2 = CastToPolygon2(ptr2); return boo->Join(polygon1, polygon2, resultPtr); } static BOOL Join_P_PWH(void* ptr0, void* ptr1, void* ptr2, void** resultPtr) { auto boo = CastToBoolean2(ptr0); auto polygon1 = CastToPolygon2(ptr1); auto polygon2 = CastToPolygonWithHoles2(ptr2); return boo->Join(polygon1, polygon2, resultPtr); } static BOOL Join_PWH_PWH(void* ptr0, void* ptr1, void* ptr2, void** resultPtr) { auto boo = CastToBoolean2(ptr0); auto polygon1 = CastToPolygonWithHoles2(ptr1); auto polygon2 = CastToPolygonWithHoles2(ptr2); return boo->Join(polygon1, polygon2, resultPtr); } //Intersect template int Intersect(P1* polygon1, P2* polygon2) { CGAL::intersection(*polygon1, *polygon2, std::back_inserter(buffer)); return (int)buffer.size(); } static int Intersect_P_P(void* ptr0, void* ptr1, void* ptr2) { auto boo = CastToBoolean2(ptr0); auto polygon1 = CastToPolygon2(ptr1); auto polygon2 = CastToPolygon2(ptr2); return boo->Intersect(polygon1, polygon2); } static int Intersect_P_PWH(void* ptr0, void* ptr1, void* ptr2) { auto boo = CastToBoolean2(ptr0); auto polygon1 = CastToPolygon2(ptr1); auto polygon2 = CastToPolygonWithHoles2(ptr2); return boo->Intersect(polygon1, polygon2); } static int Intersect_PWH_PWH(void* ptr0, void* ptr1, void* ptr2) { auto boo = CastToBoolean2(ptr0); auto polygon1 = CastToPolygonWithHoles2(ptr1); auto polygon2 = CastToPolygonWithHoles2(ptr2); return boo->Intersect(polygon1, polygon2); } //Difference template int Difference(P1* polygon1, P2* polygon2) { CGAL::difference(*polygon1, *polygon2, std::back_inserter(buffer)); return (int)buffer.size(); } static int Difference_P_P(void* ptr0, void* ptr1, void* ptr2) { auto boo = CastToBoolean2(ptr0); auto polygon1 = CastToPolygon2(ptr1); auto polygon2 = CastToPolygon2(ptr2); return boo->Difference(polygon1, polygon2); } static int Difference_P_PWH(void* ptr0, void* ptr1, void* ptr2) { auto boo = CastToBoolean2(ptr0); auto polygon1 = CastToPolygon2(ptr1); auto polygon2 = CastToPolygonWithHoles2(ptr2); return boo->Difference(polygon1, polygon2); } static int Difference_PWH_PWH(void* ptr0, void* ptr1, void* ptr2) { auto boo = CastToBoolean2(ptr0); auto polygon1 = CastToPolygonWithHoles2(ptr1); auto polygon2 = CastToPolygonWithHoles2(ptr2); return boo->Difference(polygon1, polygon2); } //Symmetric Difference template int SymmetricDifference(P1* polygon1, P2* polygon2) { CGAL::symmetric_difference(*polygon1, *polygon2, std::back_inserter(buffer)); return (int)buffer.size(); } static int SymmetricDifference_P_P(void* ptr0, void* ptr1, void* ptr2) { auto boo = CastToBoolean2(ptr0); auto polygon1 = CastToPolygon2(ptr1); auto polygon2 = CastToPolygon2(ptr2); return boo->SymmetricDifference(polygon1, polygon2); } static int SymmetricDifference_P_PWH(void* ptr0, void* ptr1, void* ptr2) { auto boo = CastToBoolean2(ptr0); auto polygon1 = CastToPolygon2(ptr1); auto polygon2 = CastToPolygonWithHoles2(ptr2); return boo->SymmetricDifference(polygon1, polygon2); } static int SymmetricDifference_PWH_PWH(void* ptr0, void* ptr1, void* ptr2) { auto boo = CastToBoolean2(ptr0); auto polygon1 = CastToPolygonWithHoles2(ptr1); auto polygon2 = CastToPolygonWithHoles2(ptr2); return boo->SymmetricDifference(polygon1, polygon2); } //Complement template int Complement(P* polygon) { CGAL::complement(*polygon, std::back_inserter(buffer)); return (int)buffer.size(); } static int Complement_PWH(void*ptr0, void* ptr1) { auto boo = CastToBoolean2(ptr0); auto pwh = CastToPolygonWithHoles2(ptr1); return boo->Complement(pwh); } }; ================================================ FILE: CGALWrapper/Polygons/PolygonBoolean2_EEK.cpp ================================================ #include "../pch.h" #include "PolygonBoolean2_EEK.h" #include "PolygonBoolean2.h" #include #include void* PolygonBoolean2_EEK_Create() { return PolygonBoolean2::NewPolygonBoolean2(); } void PolygonBoolean2_EEK_Release(void* ptr) { PolygonBoolean2::DeletePolygonBoolean2(ptr); } void PolygonBoolean2_EEK_ClearBuffer(void* ptr) { PolygonBoolean2::ClearBuffer(ptr); } void* PolygonBoolean2_EEK_CopyBufferItem(void* ptr, int index) { return PolygonBoolean2::CopyBufferItem(ptr, index); } BOOL PolygonBoolean2_EEK_DoIntersect_P_P(void* ptr0, void* ptr1, void* ptr2) { return PolygonBoolean2::DoIntersect_P_P(ptr0, ptr1, ptr2); } BOOL PolygonBoolean2_EEK_DoIntersect_P_PWH(void* ptr0, void* ptr1, void* ptr2) { return PolygonBoolean2::DoIntersect_P_PWH(ptr0, ptr1, ptr2); } BOOL PolygonBoolean2_EEK_DoIntersect_PWH_PWH(void* ptr0, void* ptr1, void* ptr2) { return PolygonBoolean2::DoIntersect_PWH_PWH(ptr0, ptr1, ptr2); } BOOL PolygonBoolean2_EEK_Join_P_P(void* ptr0, void* ptr1, void* ptr2, void** resultPtr) { return PolygonBoolean2::Join_P_P(ptr0, ptr1, ptr2, resultPtr); } BOOL PolygonBoolean2_EEK_Join_P_PWH(void* ptr0, void* ptr1, void* ptr2, void** resultPtr) { return PolygonBoolean2::Join_P_PWH(ptr0, ptr1, ptr2, resultPtr); } BOOL PolygonBoolean2_EEK_Join_PWH_PWH(void* ptr0, void* ptr1, void* ptr2, void** resultPtr) { return PolygonBoolean2::Join_PWH_PWH(ptr0, ptr1, ptr2, resultPtr); } int PolygonBoolean2_EEK_Intersect_P_P(void* ptr0, void* ptr1, void* ptr2) { return PolygonBoolean2::Intersect_P_P(ptr0, ptr1, ptr2); } int PolygonBoolean2_EEK_Intersect_P_PWH(void* ptr0, void* ptr1, void* ptr2) { return PolygonBoolean2::Intersect_P_PWH(ptr0, ptr1, ptr2); } int PolygonBoolean2_EEK_Intersect_PWH_PWH(void* ptr0, void* ptr1, void* ptr2) { return PolygonBoolean2::Intersect_PWH_PWH(ptr0, ptr1, ptr2); } int PolygonBoolean2_EEK_Difference_P_P(void* ptr0, void* ptr1, void* ptr2) { return PolygonBoolean2::Difference_P_P(ptr0, ptr1, ptr2); } int PolygonBoolean2_EEK_Difference_P_PWH(void* ptr0, void* ptr1, void* ptr2) { return PolygonBoolean2::Difference_P_PWH(ptr0, ptr1, ptr2); } int PolygonBoolean2_EEK_Difference_PWH_PWH(void* ptr0, void* ptr1, void* ptr2) { return PolygonBoolean2::Difference_PWH_PWH(ptr0, ptr1, ptr2); } int PolygonBoolean2_EEK_SymmetricDifference_P_P(void* ptr0, void* ptr1, void* ptr2) { return PolygonBoolean2::SymmetricDifference_P_P(ptr0, ptr1, ptr2); } int PolygonBoolean2_EEK_SymmetricDifference_P_PWH(void* ptr0, void* ptr1, void* ptr2) { return PolygonBoolean2::SymmetricDifference_P_PWH(ptr0, ptr1, ptr2); } int PolygonBoolean2_EEK_SymmetricDifference_PWH_PWH(void* ptr0, void* ptr1, void* ptr2) { return PolygonBoolean2::SymmetricDifference_PWH_PWH(ptr0, ptr1, ptr2); } int PolygonBoolean2_EEK_Complement_PWH(void* ptr0, void* ptr1) { return PolygonBoolean2::Complement_PWH(ptr0, ptr1); } ================================================ FILE: CGALWrapper/Polygons/PolygonBoolean2_EEK.h ================================================ #pragma once #include "../CGALWrapper.h" #include "../Geometry/Geometry2.h" #include #include extern "C" { CGALWRAPPER_API void* PolygonBoolean2_EEK_Create(); CGALWRAPPER_API void PolygonBoolean2_EEK_Release(void* ptr); CGALWRAPPER_API void PolygonBoolean2_EEK_ClearBuffer(void* ptr); CGALWRAPPER_API void* PolygonBoolean2_EEK_CopyBufferItem(void* ptr, int index); CGALWRAPPER_API BOOL PolygonBoolean2_EEK_DoIntersect_P_P(void* ptr0, void* ptr1, void* ptr2); CGALWRAPPER_API BOOL PolygonBoolean2_EEK_DoIntersect_P_PWH(void* ptr0, void* ptr1, void* ptr2); CGALWRAPPER_API BOOL PolygonBoolean2_EEK_DoIntersect_PWH_PWH(void* ptr0, void* ptr1, void* ptr2); CGALWRAPPER_API BOOL PolygonBoolean2_EEK_Join_P_P(void* ptr0, void* ptr1, void* ptr2, void** resultPtr); CGALWRAPPER_API BOOL PolygonBoolean2_EEK_Join_P_PWH(void* ptr0, void* ptr1, void* ptr2, void** resultPtr); CGALWRAPPER_API BOOL PolygonBoolean2_EEK_Join_PWH_PWH(void* ptr0, void* ptr1, void* ptr2, void** resultPtr); CGALWRAPPER_API int PolygonBoolean2_EEK_Intersect_P_P(void* ptr0, void* ptr1, void* ptr2); CGALWRAPPER_API int PolygonBoolean2_EEK_Intersect_P_PWH(void* ptr0, void* ptr1, void* ptr2); CGALWRAPPER_API int PolygonBoolean2_EEK_Intersect_PWH_PWH(void* ptr0, void* ptr1, void* ptr2); CGALWRAPPER_API int PolygonBoolean2_EEK_Difference_P_P(void* ptr0, void* ptr1, void* ptr2); CGALWRAPPER_API int PolygonBoolean2_EEK_Difference_P_PWH(void* ptr0, void* ptr1, void* ptr2); CGALWRAPPER_API int PolygonBoolean2_EEK_Difference_PWH_PWH(void* ptr0, void* ptr1, void* ptr2); CGALWRAPPER_API int PolygonBoolean2_EEK_SymmetricDifference_P_P(void* ptr0, void* ptr1, void* ptr2); CGALWRAPPER_API int PolygonBoolean2_EEK_SymmetricDifference_P_PWH(void* ptr0, void* ptr1, void* ptr2); CGALWRAPPER_API int PolygonBoolean2_EEK_SymmetricDifference_PWH_PWH(void* ptr0, void* ptr1, void* ptr2); CGALWRAPPER_API int PolygonBoolean2_EEK_Complement_PWH(void* ptr0, void* ptr1); } ================================================ FILE: CGALWrapper/Polygons/PolygonBoolean2_EIK.cpp ================================================ #include "../pch.h" #include "PolygonBoolean2_EIK.h" #include "PolygonBoolean2.h" #include #include void* PolygonBoolean2_EIK_Create() { return PolygonBoolean2::NewPolygonBoolean2(); } void PolygonBoolean2_EIK_Release(void* ptr) { PolygonBoolean2::DeletePolygonBoolean2(ptr); } void PolygonBoolean2_EIK_ClearBuffer(void* ptr) { PolygonBoolean2::ClearBuffer(ptr); } void* PolygonBoolean2_EIK_CopyBufferItem(void* ptr, int index) { return PolygonBoolean2::CopyBufferItem(ptr, index); } BOOL PolygonBoolean2_EIK_DoIntersect_P_P(void* ptr0, void* ptr1, void* ptr2) { return PolygonBoolean2::DoIntersect_P_P(ptr0, ptr1, ptr2); } BOOL PolygonBoolean2_EIK_DoIntersect_P_PWH(void* ptr0, void* ptr1, void* ptr2) { return PolygonBoolean2::DoIntersect_P_PWH(ptr0, ptr1, ptr2); } BOOL PolygonBoolean2_EIK_DoIntersect_PWH_PWH(void* ptr0, void* ptr1, void* ptr2) { return PolygonBoolean2::DoIntersect_PWH_PWH(ptr0, ptr1, ptr2); } BOOL PolygonBoolean2_EIK_Join_P_P(void* ptr0, void* ptr1, void* ptr2, void** resultPtr) { return PolygonBoolean2::Join_P_P(ptr0, ptr1, ptr2, resultPtr); } BOOL PolygonBoolean2_EIK_Join_P_PWH(void* ptr0, void* ptr1, void* ptr2, void** resultPtr) { return PolygonBoolean2::Join_P_PWH(ptr0, ptr1, ptr2, resultPtr); } BOOL PolygonBoolean2_EIK_Join_PWH_PWH(void* ptr0, void* ptr1, void* ptr2, void** resultPtr) { return PolygonBoolean2::Join_PWH_PWH(ptr0, ptr1, ptr2, resultPtr); } int PolygonBoolean2_EIK_Intersect_P_P(void* ptr0, void* ptr1, void* ptr2) { return PolygonBoolean2::Intersect_P_P(ptr0, ptr1, ptr2); } int PolygonBoolean2_EIK_Intersect_P_PWH(void* ptr0, void* ptr1, void* ptr2) { return PolygonBoolean2::Intersect_P_PWH(ptr0, ptr1, ptr2); } int PolygonBoolean2_EIK_Intersect_PWH_PWH(void* ptr0, void* ptr1, void* ptr2) { return PolygonBoolean2::Intersect_PWH_PWH(ptr0, ptr1, ptr2); } int PolygonBoolean2_EIK_Difference_P_P(void* ptr0, void* ptr1, void* ptr2) { return PolygonBoolean2::Difference_P_P(ptr0, ptr1, ptr2); } int PolygonBoolean2_EIK_Difference_P_PWH(void* ptr0, void* ptr1, void* ptr2) { return PolygonBoolean2::Difference_P_PWH(ptr0, ptr1, ptr2); } int PolygonBoolean2_EIK_Difference_PWH_PWH(void* ptr0, void* ptr1, void* ptr2) { return PolygonBoolean2::Difference_PWH_PWH(ptr0, ptr1, ptr2); } int PolygonBoolean2_EIK_SymmetricDifference_P_P(void* ptr0, void* ptr1, void* ptr2) { return PolygonBoolean2::SymmetricDifference_P_P(ptr0, ptr1, ptr2); } int PolygonBoolean2_EIK_SymmetricDifference_P_PWH(void* ptr0, void* ptr1, void* ptr2) { return PolygonBoolean2::SymmetricDifference_P_PWH(ptr0, ptr1, ptr2); } int PolygonBoolean2_EIK_SymmetricDifference_PWH_PWH(void* ptr0, void* ptr1, void* ptr2) { return PolygonBoolean2::SymmetricDifference_PWH_PWH(ptr0, ptr1, ptr2); } int PolygonBoolean2_EIK_Complement_PWH(void* ptr0, void* ptr1) { return PolygonBoolean2::Complement_PWH(ptr0, ptr1); } ================================================ FILE: CGALWrapper/Polygons/PolygonBoolean2_EIK.h ================================================ #pragma once #include "../CGALWrapper.h" #include "../Geometry/Geometry2.h" #include #include extern "C" { CGALWRAPPER_API void* PolygonBoolean2_EIK_Create(); CGALWRAPPER_API void PolygonBoolean2_EIK_Release(void* ptr); CGALWRAPPER_API void PolygonBoolean2_EIK_ClearBuffer(void* ptr); CGALWRAPPER_API void* PolygonBoolean2_EIK_CopyBufferItem(void* ptr, int index); CGALWRAPPER_API BOOL PolygonBoolean2_EIK_DoIntersect_P_P(void* ptr0, void* ptr1, void* ptr2); CGALWRAPPER_API BOOL PolygonBoolean2_EIK_DoIntersect_P_PWH(void* ptr0, void* ptr1, void* ptr2); CGALWRAPPER_API BOOL PolygonBoolean2_EIK_DoIntersect_PWH_PWH(void* ptr0, void* ptr1, void* ptr2); CGALWRAPPER_API BOOL PolygonBoolean2_EIK_Join_P_P(void* ptr0, void* ptr1, void* ptr2, void** resultPtr); CGALWRAPPER_API BOOL PolygonBoolean2_EIK_Join_P_PWH(void* ptr0, void* ptr1, void* ptr2, void** resultPtr); CGALWRAPPER_API BOOL PolygonBoolean2_EIK_Join_PWH_PWH(void* ptr0, void* ptr1, void* ptr2, void** resultPtr); CGALWRAPPER_API int PolygonBoolean2_EIK_Intersect_P_P(void* ptr0, void* ptr1, void* ptr2); CGALWRAPPER_API int PolygonBoolean2_EIK_Intersect_P_PWH(void* ptr0, void* ptr1, void* ptr2); CGALWRAPPER_API int PolygonBoolean2_EIK_Intersect_PWH_PWH(void* ptr0, void* ptr1, void* ptr2); CGALWRAPPER_API int PolygonBoolean2_EIK_Difference_P_P(void* ptr0, void* ptr1, void* ptr2); CGALWRAPPER_API int PolygonBoolean2_EIK_Difference_P_PWH(void* ptr0, void* ptr1, void* ptr2); CGALWRAPPER_API int PolygonBoolean2_EIK_Difference_PWH_PWH(void* ptr0, void* ptr1, void* ptr2); CGALWRAPPER_API int PolygonBoolean2_EIK_SymmetricDifference_P_P(void* ptr0, void* ptr1, void* ptr2); CGALWRAPPER_API int PolygonBoolean2_EIK_SymmetricDifference_P_PWH(void* ptr0, void* ptr1, void* ptr2); CGALWRAPPER_API int PolygonBoolean2_EIK_SymmetricDifference_PWH_PWH(void* ptr0, void* ptr1, void* ptr2); CGALWRAPPER_API int PolygonBoolean2_EIK_Complement_PWH(void* ptr0, void* ptr1); } ================================================ FILE: CGALWrapper/Polygons/PolygonMinkowski.h ================================================ #pragma once #include "../CGALWrapper.h" #include "../Geometry/Geometry2.h" #include "Polygon2.h" #include "PolygonWithHoles2.h" #include #include #include #include #include #include #include #include #include template class PolygonMinkowski { public: PolygonMinkowski() { } inline static PolygonMinkowski* NewPolygonMinkowski() { return new PolygonMinkowski(); } inline static void DeletePolygonMinkowski(void* ptr) { auto obj = static_cast(ptr); if (obj != nullptr) { delete obj; obj = nullptr; } } inline static PolygonMinkowski* CastToPolygonMinkowski(void* ptr) { return static_cast(ptr); } static void* MinkowskiSum(void* polyPtr1, void* polyPtr2) { auto poly1 = Polygon2::CastToPolygon2(polyPtr1); auto poly2 = Polygon2::CastToPolygon2(polyPtr2); auto sum = CGAL::minkowski_sum_2(*poly1, *poly2); return PolygonWithHoles2::NewPolygonWithHoles2(&sum); } static void* MinkowskiSumPWH(void* pwhPtr1, void* polyPtr2) { auto poly1 = PolygonWithHoles2::CastToPolygonWithHoles2(pwhPtr1); auto poly2 = Polygon2::CastToPolygon2(polyPtr2); auto sum = CGAL::minkowski_sum_2(*poly1, *poly2); return PolygonWithHoles2::NewPolygonWithHoles2(&sum); } static void* MinkowskiSum_SSAB(void* polyPtr1, void* polyPtr2) { auto poly1 = Polygon2::CastToPolygon2(polyPtr1); auto poly2 = Polygon2::CastToPolygon2(polyPtr2); CGAL::Small_side_angle_bisector_decomposition_2 decomp; auto sum = CGAL::minkowski_sum_2(*poly1, *poly2, decomp); return PolygonWithHoles2::NewPolygonWithHoles2(&sum); } static void* MinkowskiSum_OptimalConvex(void* polyPtr1, void* polyPtr2) { auto poly1 = Polygon2::CastToPolygon2(polyPtr1); auto poly2 = Polygon2::CastToPolygon2(polyPtr2); CGAL::Optimal_convex_decomposition_2 decomp; auto sum = CGAL::minkowski_sum_2(*poly1, *poly2, decomp); return PolygonWithHoles2::NewPolygonWithHoles2(&sum); } static void* MinkowskiSum_HertelMehlhorn(void* polyPtr1, void* polyPtr2) { auto poly1 = Polygon2::CastToPolygon2(polyPtr1); auto poly2 = Polygon2::CastToPolygon2(polyPtr2); CGAL::Hertel_Mehlhorn_convex_decomposition_2 decomp; auto sum = CGAL::minkowski_sum_2(*poly1, *poly2, decomp); return PolygonWithHoles2::NewPolygonWithHoles2(&sum); } static void* MinkowskiSum_GreeneConvex(void* polyPtr1, void* polyPtr2) { auto poly1 = Polygon2::CastToPolygon2(polyPtr1); auto poly2 = Polygon2::CastToPolygon2(polyPtr2); CGAL::Greene_convex_decomposition_2 decomp; auto sum = CGAL::minkowski_sum_2(*poly1, *poly2, decomp); return PolygonWithHoles2::NewPolygonWithHoles2(&sum); } static void* MinkowskiSum_Vertical(void* polyPtr1, void* polyPtr2) { auto poly1 = Polygon2::CastToPolygon2(polyPtr1); auto poly2 = Polygon2::CastToPolygon2(polyPtr2); CGAL::Polygon_vertical_decomposition_2 decomp; auto sum = CGAL::minkowski_sum_2(*poly1, *poly2, decomp); return PolygonWithHoles2::NewPolygonWithHoles2(&sum); } static void* MinkowskiSumPWH_Vertical(void* pwhPtr1, void* polyPtr2) { auto poly1 = PolygonWithHoles2::CastToPolygonWithHoles2(pwhPtr1); auto poly2 = Polygon2::CastToPolygon2(polyPtr2); CGAL::Polygon_vertical_decomposition_2 decomp; auto sum = CGAL::minkowski_sum_2(*poly1, *poly2, decomp); return PolygonWithHoles2::NewPolygonWithHoles2(&sum); } static void* MinkowskiSum_Triangle(void* polyPtr1, void* polyPtr2) { auto poly1 = Polygon2::CastToPolygon2(polyPtr1); auto poly2 = Polygon2::CastToPolygon2(polyPtr2); CGAL::Polygon_triangulation_decomposition_2 decomp; auto sum = CGAL::minkowski_sum_2(*poly1, *poly2, decomp); return PolygonWithHoles2::NewPolygonWithHoles2(&sum); } static void* MinkowskiSumPWH_Triangle(void* pwhPtr1, void* polyPtr2) { auto poly1 = PolygonWithHoles2::CastToPolygonWithHoles2(pwhPtr1); auto poly2 = Polygon2::CastToPolygon2(polyPtr2); CGAL::Polygon_triangulation_decomposition_2 decomp; auto sum = CGAL::minkowski_sum_2(*poly1, *poly2, decomp); return PolygonWithHoles2::NewPolygonWithHoles2(&sum); } }; ================================================ FILE: CGALWrapper/Polygons/PolygonMinkowski_EEK.cpp ================================================ #include "PolygonMinkowski_EEK.h" #include "PolygonMinkowski.h" #include "Polygon2.h" #include "PolygonWithHoles2.h" #include #include #include #include #include #include #include #include void* PolygonMinkowski_EEK_Create() { return PolygonMinkowski::NewPolygonMinkowski(); } void PolygonMinkowski_EEK_Release(void* ptr) { PolygonMinkowski::DeletePolygonMinkowski(ptr); } void* PolygonMinkowski_EEK_MinkowskiSum(void* polyPtr1, void* polyPtr2) { return PolygonMinkowski::MinkowskiSum(polyPtr1, polyPtr2); } void* PolygonMinkowski_EEK_MinkowskiSumPWH(void* pwhPtr1, void* polyPtr2) { return PolygonMinkowski::MinkowskiSumPWH(pwhPtr1, polyPtr2); } void* PolygonMinkowski_EEK_MinkowskiSum_SSAB(void* polyPtr1, void* polyPtr2) { return PolygonMinkowski::MinkowskiSum_SSAB(polyPtr1, polyPtr2); } void* PolygonMinkowski_EEK_MinkowskiSum_OptimalConvex(void* polyPtr1, void* polyPtr2) { return PolygonMinkowski::MinkowskiSum_OptimalConvex(polyPtr1, polyPtr2); } void* PolygonMinkowski_EEK_MinkowskiSum_HertelMehlhorn(void* polyPtr1, void* polyPtr2) { return PolygonMinkowski::MinkowskiSum_HertelMehlhorn(polyPtr1, polyPtr2); } void* PolygonMinkowski_EEK_MinkowskiSum_GreeneConvex(void* polyPtr1, void* polyPtr2) { return PolygonMinkowski::MinkowskiSum_GreeneConvex(polyPtr1, polyPtr2); } void* PolygonMinkowski_EEK_MinkowskiSum_Vertical(void* polyPtr1, void* polyPtr2) { return PolygonMinkowski::MinkowskiSum_Vertical(polyPtr1, polyPtr2); } void* PolygonMinkowski_EEK_MinkowskiSumPWH_Vertical(void* pwhPtr1, void* polyPtr2) { return PolygonMinkowski::MinkowskiSumPWH_Vertical(pwhPtr1, polyPtr2); } void* PolygonMinkowski_EEK_MinkowskiSum_Triangle(void* polyPtr1, void* polyPtr2) { return PolygonMinkowski::MinkowskiSum_Triangle(polyPtr1, polyPtr2); } void* PolygonMinkowski_EEK_MinkowskiSumPWH_Triangle(void* pwhPtr1, void* polyPtr2) { return PolygonMinkowski::MinkowskiSumPWH_Triangle(pwhPtr1, polyPtr2); } ================================================ FILE: CGALWrapper/Polygons/PolygonMinkowski_EEK.h ================================================ #pragma once #include "../CGALWrapper.h" #include "../Geometry/Geometry2.h" #include extern "C" { CGALWRAPPER_API void* PolygonMinkowski_EEK_Create(); CGALWRAPPER_API void PolygonMinkowski_EEK_Release(void* ptr); CGALWRAPPER_API void* PolygonMinkowski_EEK_MinkowskiSum(void* polyPtr1, void* polyPtr2); CGALWRAPPER_API void* PolygonMinkowski_EEK_MinkowskiSumPWH(void* pwhPtr1, void* polyPtr2); CGALWRAPPER_API void* PolygonMinkowski_EEK_MinkowskiSum_SSAB(void* polyPtr1, void* polyPtr2); CGALWRAPPER_API void* PolygonMinkowski_EEK_MinkowskiSum_OptimalConvex(void* polyPtr1, void* polyPtr2); CGALWRAPPER_API void* PolygonMinkowski_EEK_MinkowskiSum_HertelMehlhorn(void* polyPtr1, void* polyPtr2); CGALWRAPPER_API void* PolygonMinkowski_EEK_MinkowskiSum_GreeneConvex(void* polyPtr1, void* polyPtr2); CGALWRAPPER_API void* PolygonMinkowski_EEK_MinkowskiSum_Vertical(void* polyPtr1, void* polyPtr2); CGALWRAPPER_API void* PolygonMinkowski_EEK_MinkowskiSumPWH_Vertical(void* pwhPtr1, void* polyPtr2); CGALWRAPPER_API void* PolygonMinkowski_EEK_MinkowskiSum_Triangle(void* polyPtr1, void* polyPtr2); CGALWRAPPER_API void* PolygonMinkowski_EEK_MinkowskiSumPWH_Triangle(void* pwhPtr1, void* polyPtr2); } ================================================ FILE: CGALWrapper/Polygons/PolygonMinkowski_EIK.cpp ================================================ #include "PolygonMinkowski_EIK.h" #include "PolygonMinkowski.h" #include "Polygon2.h" #include "PolygonWithHoles2.h" #include #include #include #include #include #include #include #include void* PolygonMinkowski_EIK_Create() { return PolygonMinkowski::NewPolygonMinkowski(); } void PolygonMinkowski_EIK_Release(void* ptr) { PolygonMinkowski::DeletePolygonMinkowski(ptr); } void* PolygonMinkowski_EIK_MinkowskiSum(void* polyPtr1, void* polyPtr2) { return PolygonMinkowski::MinkowskiSum(polyPtr1, polyPtr2); } void* PolygonMinkowski_EIK_MinkowskiSumPWH(void* pwhPtr1, void* polyPtr2) { return PolygonMinkowski::MinkowskiSumPWH(pwhPtr1, polyPtr2); } void* PolygonMinkowski_EIK_MinkowskiSum_SSAB(void* polyPtr1, void* polyPtr2) { return PolygonMinkowski::MinkowskiSum_SSAB(polyPtr1, polyPtr2); } void* PolygonMinkowski_EIK_MinkowskiSum_OptimalConvex(void* polyPtr1, void* polyPtr2) { return PolygonMinkowski::MinkowskiSum_OptimalConvex(polyPtr1, polyPtr2); } void* PolygonMinkowski_EIK_MinkowskiSum_HertelMehlhorn(void* polyPtr1, void* polyPtr2) { return PolygonMinkowski::MinkowskiSum_HertelMehlhorn(polyPtr1, polyPtr2); } void* PolygonMinkowski_EIK_MinkowskiSum_GreeneConvex(void* polyPtr1, void* polyPtr2) { return PolygonMinkowski::MinkowskiSum_GreeneConvex(polyPtr1, polyPtr2); } void* PolygonMinkowski_EIK_MinkowskiSum_Vertical(void* polyPtr1, void* polyPtr2) { return PolygonMinkowski::MinkowskiSum_Vertical(polyPtr1, polyPtr2); } void* PolygonMinkowski_EIK_MinkowskiSumPWH_Vertical(void* pwhPtr1, void* polyPtr2) { return PolygonMinkowski::MinkowskiSumPWH_Vertical(pwhPtr1, polyPtr2); } void* PolygonMinkowski_EIK_MinkowskiSum_Triangle(void* polyPtr1, void* polyPtr2) { return PolygonMinkowski::MinkowskiSum_Triangle(polyPtr1, polyPtr2); } void* PolygonMinkowski_EIK_MinkowskiSumPWH_Triangle(void* pwhPtr1, void* polyPtr2) { return PolygonMinkowski::MinkowskiSumPWH_Triangle(pwhPtr1, polyPtr2); } ================================================ FILE: CGALWrapper/Polygons/PolygonMinkowski_EIK.h ================================================ #pragma once #include "../CGALWrapper.h" #include "../Geometry/Geometry2.h" #include extern "C" { CGALWRAPPER_API void* PolygonMinkowski_EIK_Create(); CGALWRAPPER_API void PolygonMinkowski_EIK_Release(void* ptr); CGALWRAPPER_API void* PolygonMinkowski_EIK_MinkowskiSum(void* polyPtr1, void* polyPtr2); CGALWRAPPER_API void* PolygonMinkowski_EIK_MinkowskiSumPWH(void* pwhPtr1, void* polyPtr2); CGALWRAPPER_API void* PolygonMinkowski_EIK_MinkowskiSum_SSAB(void* polyPtr1, void* polyPtr2); CGALWRAPPER_API void* PolygonMinkowski_EIK_MinkowskiSum_OptimalConvex(void* polyPtr1, void* polyPtr2); CGALWRAPPER_API void* PolygonMinkowski_EIK_MinkowskiSum_HertelMehlhorn(void* polyPtr1, void* polyPtr2); CGALWRAPPER_API void* PolygonMinkowski_EIK_MinkowskiSum_GreeneConvex(void* polyPtr1, void* polyPtr2); CGALWRAPPER_API void* PolygonMinkowski_EIK_MinkowskiSum_Vertical(void* polyPtr1, void* polyPtr2); CGALWRAPPER_API void* PolygonMinkowski_EIK_MinkowskiSumPWH_Vertical(void* pwhPtr1, void* polyPtr2); CGALWRAPPER_API void* PolygonMinkowski_EIK_MinkowskiSum_Triangle(void* polyPtr1, void* polyPtr2); CGALWRAPPER_API void* PolygonMinkowski_EIK_MinkowskiSumPWH_Triangle(void* pwhPtr1, void* polyPtr2); } ================================================ FILE: CGALWrapper/Polygons/PolygonOffset2.h ================================================ #pragma once #include "../CGALWrapper.h" #include "../Geometry/Geometry2.h" #include "Polygon2.h" #include "PolygonWithHoles2.h" #include #include #include #include #include #include #include template class PolygonOffset2 { private: typedef typename K::Point_2 Point; typedef typename CGAL::Polygon_2 Polygon_2; typedef typename CGAL::Polygon_2 Polygon_2_EIK; typedef CGAL::Polygon_with_holes_2 Polygon_with_holes; typedef CGAL::Straight_skeleton_2 Ss; typedef boost::shared_ptr SsPtr; typedef typename Ss::Vertex_handle Vertex; typedef typename Ss::Halfedge_handle HalfEdge; typedef boost::shared_ptr PolygonPtr; typedef std::vector PolygonPtrVector; std::vector polygonBuffer; std::vector segmentBuffer; public: inline static PolygonOffset2* NewPolygonOffset2() { return new PolygonOffset2(); } inline static void DeletePolygonOffset2(void* ptr) { auto obj = static_cast(ptr); if (obj != nullptr) { delete obj; obj = nullptr; } } inline static PolygonOffset2* CastToPolygonOffset2(void* ptr) { return static_cast(ptr); } static int PolygonBufferSize(void* ptr) { auto offset = CastToPolygonOffset2(ptr); return (int)offset->polygonBuffer.size(); } static int SegmentBufferSize(void* ptr) { auto offset = CastToPolygonOffset2(ptr); return (int)offset->segmentBuffer.size(); } static void ClearPolygonBuffer(void* ptr) { auto offset = CastToPolygonOffset2(ptr); offset->polygonBuffer.clear(); } static void ClearSegmentBuffer(void* ptr) { auto offset = CastToPolygonOffset2(ptr); offset->segmentBuffer.clear(); } static void* GetBufferedPolygon(void* ptr, int index) { auto offset = CastToPolygonOffset2(ptr); return offset->polygonBuffer[index]; } static Segment2d GetSegment(void* ptr, int index) { auto offset = CastToPolygonOffset2(ptr); return offset->segmentBuffer[index]; } static void GetSegments(void* ptr, Segment2d* segments, int count) { auto offset = CastToPolygonOffset2(ptr); for (int i = 0; i < count; i++) segments[i] = offset->segmentBuffer[i]; } static void CreateInteriorOffset(void* ptr, void* polyPtr, double amount) { auto offset = CastToPolygonOffset2(ptr); auto poly = Polygon2::CastToPolygon2(polyPtr); auto polygons = CGAL::create_interior_skeleton_and_offset_polygons_2(amount, *poly); offset->CopyToBuffer(polygons); } static void CreateInteriorOffsetPWH(void* ptr, void* pwhPtr, double amount, BOOL boundaryOnly) { auto offset = CastToPolygonOffset2(ptr); auto pwh = PolygonWithHoles2::CastToPolygonWithHoles2(pwhPtr); if (!pwh->is_unbounded()) { auto boundary = CGAL::create_interior_skeleton_and_offset_polygons_2(amount, pwh->outer_boundary()); offset->CopyToBuffer(boundary); } /* if (!boundaryOnly) { for (auto& hole : pwh->holes()) { auto polygons = CGAL::create_interior_skeleton_and_offset_polygons_2(amount, hole); offset->CopyToBuffer(polygons); } } */ } static void CreateExteriorOffset(void* ptr, void* polyPtr, double maxOffset) { auto offset = CastToPolygonOffset2(ptr); auto poly = Polygon2::CastToPolygon2(polyPtr); auto polygons = CGAL::create_exterior_skeleton_and_offset_polygons_2(maxOffset, *poly); offset->CopyToBuffer(polygons); } static void CreateExteriorOffsetPWH(void* ptr, void* pwhPtr, double amount, BOOL boundaryOnly) { auto offset = CastToPolygonOffset2(ptr); auto pwh = PolygonWithHoles2::CastToPolygonWithHoles2(pwhPtr); if (!pwh->is_unbounded()) { auto boundary = CGAL::create_exterior_skeleton_and_offset_polygons_2(amount, pwh->outer_boundary()); offset->CopyToBuffer(boundary); } } void CopyToBuffer(const PolygonPtrVector& polygons) { for (auto iter = polygons.begin(); iter != polygons.end(); ++iter) { auto p = new Polygon_2(); for (auto v = (*iter)->vertices_begin(); v != (*iter)->vertices_end(); ++v) { Point point(v->x(), v->y()); p->push_back(point); } polygonBuffer.push_back(p); } } void CreateSegments(SsPtr iss, BOOL includeBorder) { std::unordered_set set; segmentBuffer.clear(); for (HalfEdge edge = iss->halfedges_begin(); edge != iss->halfedges_end(); ++edge) { bool isBorder = edge->is_border() || edge->opposite()->is_border(); if ((includeBorder && isBorder) || !isBorder) { if (set.find(edge->id()) == set.end()) { auto a = Point2d::FromCGAL(edge->vertex()->point()); auto b = Point2d::FromCGAL(edge->opposite()->vertex()->point()); segmentBuffer.push_back({ a, b }); set.insert(edge->id()); set.insert(edge->opposite()->id()); } } } } static void CreateInteriorSkeleton(void* ptr, void* polyPtr, BOOL includeBorder) { auto offset = CastToPolygonOffset2(ptr); auto poly = Polygon2::CastToPolygon2(polyPtr); SsPtr iss = CGAL::create_interior_straight_skeleton_2(*poly); offset->CreateSegments(iss, includeBorder); } static void CreateInteriorSkeletonPWH(void* ptr, void* pwhPtr, BOOL includeBorder) { auto offset = CastToPolygonOffset2(ptr); auto pwh = Polygon2::CastToPolygon2(pwhPtr); SsPtr iss = CGAL::create_interior_straight_skeleton_2(*pwh); offset->CreateSegments(iss, includeBorder); } static void CreateExteriorSkeleton(void* ptr, void* polyPtr, double maxOffset, BOOL includeBorder) { auto offset = CastToPolygonOffset2(ptr); auto poly = Polygon2::CastToPolygon2(polyPtr); SsPtr iss = CGAL::create_exterior_straight_skeleton_2(maxOffset, *poly); offset->CreateSegments(iss, includeBorder); } static void CreateExteriorSkeletonPWH(void* ptr, void* pwhPtr, double maxOffset, BOOL includeBorder) { auto offset = CastToPolygonOffset2(ptr); auto pwh = Polygon2::CastToPolygon2(pwhPtr); SsPtr iss = CGAL::create_exterior_straight_skeleton_2(maxOffset, *pwh); offset->CreateSegments(iss, includeBorder); } }; ================================================ FILE: CGALWrapper/Polygons/PolygonOffset2_EEK.cpp ================================================ #include "PolygonOffset2_EEK.h" #include "PolygonOffset2.h" #include #include #include #include #include #include void* PolygonOffset2_EEK_Create() { return PolygonOffset2::NewPolygonOffset2(); } void PolygonOffset2_EEK_Release(void* ptr) { PolygonOffset2::DeletePolygonOffset2(ptr); } int PolygonOffset2_EEK_PolygonBufferSize(void* ptr) { return PolygonOffset2::PolygonBufferSize(ptr); } int PolygonOffset2_EEK_SegmentBufferSize(void* ptr) { return PolygonOffset2::SegmentBufferSize(ptr); } void PolygonOffset2_EEK_ClearPolygonBuffer(void* ptr) { PolygonOffset2::ClearPolygonBuffer(ptr); } void PolygonOffset2_EEK_ClearSegmentBuffer(void* ptr) { PolygonOffset2::ClearSegmentBuffer(ptr); } void* PolygonOffset2_EEK_GetBufferedPolygon(void* ptr, int index) { return PolygonOffset2::GetBufferedPolygon(ptr, index); } Segment2d PolygonOffset2_EEK_GetSegment(void* ptr, int index) { return PolygonOffset2::GetSegment(ptr, index); } void PolygonOffset2_EEK_GetSegments(void* ptr, Segment2d* segments, int count) { PolygonOffset2::GetSegments(ptr, segments, count); } void PolygonOffset2_EEK_CreateInteriorOffset(void* ptr, void* polyPtr, double offset) { PolygonOffset2::CreateInteriorOffset(ptr, polyPtr, offset); } void PolygonOffset2_EEK_CreateInteriorOffsetPWH(void* ptr, void* pwhPtr, double offset, BOOL boundaryOnly) { PolygonOffset2::CreateInteriorOffsetPWH(ptr, pwhPtr, offset, boundaryOnly); } void PolygonOffset2_EEK_CreateExteriorOffset(void* ptr, void* polyPtr, double offset) { PolygonOffset2::CreateExteriorOffset(ptr, polyPtr, offset); } void PolygonOffset2_EEK_CreateExteriorOffsetPWH(void* ptr, void* pwhPtr, double offset, BOOL boundaryOnly) { PolygonOffset2::CreateExteriorOffsetPWH(ptr, pwhPtr, offset, boundaryOnly); } void PolygonOffset2_EEK_CreateInteriorSkeleton(void* ptr, void* polyPtr, BOOL includeBorder) { PolygonOffset2::CreateInteriorSkeleton(ptr, polyPtr, includeBorder); } void PolygonOffset2_EEK_CreateInteriorSkeletonPWH(void* ptr, void* pwhPtr, BOOL includeBorder) { PolygonOffset2::CreateInteriorSkeletonPWH(ptr, pwhPtr, includeBorder); } void PolygonOffset2_EEK_CreateExteriorSkeleton(void* ptr, void* polyPtr, double maxOffset, BOOL includeBorder) { PolygonOffset2::CreateExteriorSkeleton(ptr, polyPtr, maxOffset, includeBorder); } void PolygonOffset2_EEK_CreateExteriorSkeletonPWH(void* ptr, void* pwhPtr, double maxOffset, BOOL includeBorder) { PolygonOffset2::CreateExteriorSkeletonPWH(ptr, pwhPtr, maxOffset, includeBorder); } ================================================ FILE: CGALWrapper/Polygons/PolygonOffset2_EEK.h ================================================ #pragma once #include "../CGALWrapper.h" #include "../Geometry/Geometry2.h" #include extern "C" { CGALWRAPPER_API void* PolygonOffset2_EEK_Create(); CGALWRAPPER_API void PolygonOffset2_EEK_Release(void* ptr); CGALWRAPPER_API int PolygonOffset2_EEK_PolygonBufferSize(void* ptr); CGALWRAPPER_API int PolygonOffset2_EEK_SegmentBufferSize(void* ptr); CGALWRAPPER_API void PolygonOffset2_EEK_ClearPolygonBuffer(void* ptr); CGALWRAPPER_API void PolygonOffset2_EEK_ClearSegmentBuffer(void* ptr); CGALWRAPPER_API void* PolygonOffset2_EEK_GetBufferedPolygon(void* ptr, int index); CGALWRAPPER_API Segment2d PolygonOffset2_EEK_GetSegment(void* ptr, int index); CGALWRAPPER_API void PolygonOffset2_EEK_GetSegments(void* ptr, Segment2d* segments, int count); CGALWRAPPER_API void PolygonOffset2_EEK_CreateInteriorOffset(void* ptr, void* polyPtr, double offset); CGALWRAPPER_API void PolygonOffset2_EEK_CreateInteriorOffsetPWH(void* ptr, void* pwhPtr, double offset, BOOL boundaryOnly); CGALWRAPPER_API void PolygonOffset2_EEK_CreateExteriorOffset(void* ptr, void* polyPtr, double offset); CGALWRAPPER_API void PolygonOffset2_EEK_CreateExteriorOffsetPWH(void* ptr, void* pwhPtr, double offset, BOOL boundaryOnly); CGALWRAPPER_API void PolygonOffset2_EEK_CreateInteriorSkeleton(void* ptr, void* polyPtr, BOOL includeBorder); CGALWRAPPER_API void PolygonOffset2_EEK_CreateInteriorSkeletonPWH(void* ptr, void* pwhPtr, BOOL includeBorder); CGALWRAPPER_API void PolygonOffset2_EEK_CreateExteriorSkeleton(void* ptr, void* polyPtr, double maxOffset, BOOL includeBorder); CGALWRAPPER_API void PolygonOffset2_EEK_CreateExteriorSkeletonPWH(void* ptr, void* pwhPtr, double maxOffset, BOOL includeBorder); } ================================================ FILE: CGALWrapper/Polygons/PolygonOffset2_EIK.cpp ================================================ #include "PolygonOffset2_EIK.h" #include "PolygonOffset2.h" #include #include #include #include #include #include void* PolygonOffset2_EIK_Create() { return PolygonOffset2::NewPolygonOffset2(); } void PolygonOffset2_EIK_Release(void* ptr) { PolygonOffset2::DeletePolygonOffset2(ptr); } int PolygonOffset2_EIK_PolygonBufferSize(void* ptr) { return PolygonOffset2::PolygonBufferSize(ptr); } int PolygonOffset2_EIK_SegmentBufferSize(void* ptr) { return PolygonOffset2::SegmentBufferSize(ptr); } void PolygonOffset2_EIK_ClearPolygonBuffer(void* ptr) { PolygonOffset2::ClearPolygonBuffer(ptr); } void PolygonOffset2_EIK_ClearSegmentBuffer(void* ptr) { PolygonOffset2::ClearSegmentBuffer(ptr); } void* PolygonOffset2_EIK_GetBufferedPolygon(void* ptr, int index) { return PolygonOffset2::GetBufferedPolygon(ptr, index); } Segment2d PolygonOffset2_EIK_GetSegment(void* ptr, int index) { return PolygonOffset2::GetSegment(ptr, index); } void PolygonOffset2_EIK_GetSegments(void* ptr, Segment2d* segments, int count) { PolygonOffset2::GetSegments(ptr, segments, count); } void PolygonOffset2_EIK_CreateInteriorOffset(void* ptr, void* polyPtr, double offset) { PolygonOffset2::CreateInteriorOffset(ptr, polyPtr, offset); } void PolygonOffset2_EIK_CreateInteriorOffsetPWH(void* ptr, void* pwhPtr, double offset, BOOL boundaryOnly) { PolygonOffset2::CreateInteriorOffsetPWH(ptr, pwhPtr, offset, boundaryOnly); } void PolygonOffset2_EIK_CreateExteriorOffset(void* ptr, void* polyPtr, double offset) { PolygonOffset2::CreateExteriorOffset(ptr, polyPtr, offset); } void PolygonOffset2_EIK_CreateExteriorOffsetPWH(void* ptr, void* pwhPtr, double offset, BOOL boundaryOnly) { PolygonOffset2::CreateExteriorOffsetPWH(ptr, pwhPtr, offset, boundaryOnly); } void PolygonOffset2_EIK_CreateInteriorSkeleton(void* ptr, void* polyPtr, BOOL includeBorder) { PolygonOffset2::CreateInteriorSkeleton(ptr, polyPtr, includeBorder); } void PolygonOffset2_EIK_CreateInteriorSkeletonPWH(void* ptr, void* pwhPtr, BOOL includeBorder) { PolygonOffset2::CreateInteriorSkeletonPWH(ptr, pwhPtr, includeBorder); } void PolygonOffset2_EIK_CreateExteriorSkeleton(void* ptr, void* polyPtr, double maxOffset, BOOL includeBorder) { PolygonOffset2::CreateExteriorSkeleton(ptr, polyPtr, maxOffset, includeBorder); } void PolygonOffset2_EIK_CreateExteriorSkeletonPWH(void* ptr, void* pwhPtr, double maxOffset, BOOL includeBorder) { PolygonOffset2::CreateExteriorSkeletonPWH(ptr, pwhPtr, maxOffset, includeBorder); } ================================================ FILE: CGALWrapper/Polygons/PolygonOffset2_EIK.h ================================================ #pragma once #include "../CGALWrapper.h" #include "../Geometry/Geometry2.h" #include extern "C" { CGALWRAPPER_API void* PolygonOffset2_EIK_Create(); CGALWRAPPER_API void PolygonOffset2_EIK_Release(void* ptr); CGALWRAPPER_API int PolygonOffset2_EIK_PolygonBufferSize(void* ptr); CGALWRAPPER_API int PolygonOffset2_EIK_SegmentBufferSize(void* ptr); CGALWRAPPER_API void PolygonOffset2_EIK_ClearPolygonBuffer(void* ptr); CGALWRAPPER_API void PolygonOffset2_EIK_ClearSegmentBuffer(void* ptr); CGALWRAPPER_API void* PolygonOffset2_EIK_GetBufferedPolygon(void* ptr, int index); CGALWRAPPER_API Segment2d PolygonOffset2_EIK_GetSegment(void* ptr, int index); CGALWRAPPER_API void PolygonOffset2_EIK_GetSegments(void* ptr, Segment2d* segments, int count); CGALWRAPPER_API void PolygonOffset2_EIK_CreateInteriorOffset(void* ptr, void* polyPtr, double offset); CGALWRAPPER_API void PolygonOffset2_EIK_CreateInteriorOffsetPWH(void* ptr, void* pwhPtr, double offset, BOOL boundaryOnly); CGALWRAPPER_API void PolygonOffset2_EIK_CreateExteriorOffset(void* ptr, void* polyPtr, double offset); CGALWRAPPER_API void PolygonOffset2_EIK_CreateExteriorOffsetPWH(void* ptr, void* pwhPtr, double offset, BOOL boundaryOnly); CGALWRAPPER_API void PolygonOffset2_EIK_CreateInteriorSkeleton(void* ptr, void* polyPtr, BOOL includeBorder); CGALWRAPPER_API void PolygonOffset2_EIK_CreateInteriorSkeletonPWH(void* ptr, void* pwhPtr, BOOL includeBorder); CGALWRAPPER_API void PolygonOffset2_EIK_CreateExteriorSkeleton(void* ptr, void* polyPtr, double maxOffset, BOOL includeBorder); CGALWRAPPER_API void PolygonOffset2_EIK_CreateExteriorSkeletonPWH(void* ptr, void* pwhPtr, double maxOffset, BOOL includeBorder); } ================================================ FILE: CGALWrapper/Polygons/PolygonPartition2.h ================================================ #pragma once #include "../CGALWrapper.h" #include "../Geometry/Geometry2.h" #include "Polygon2.h" #include "PolygonWithHoles2.h" #include #include #include template class PolygonPartition2 { public: typedef CGAL::Partition_traits_2 Traits; typedef typename Traits::Point_2 Point_2; typedef typename Traits::Polygon_2 Polygon_2; typedef typename std::vector Polygon_List; private: Polygon_List buffer; public: PolygonPartition2() { } ~PolygonPartition2() { } inline static PolygonPartition2* NewPolygonPartition2() { return new PolygonPartition2(); } inline static void DeletePolygonPartition2(void* ptr) { auto obj = static_cast(ptr); if (obj != nullptr) { delete obj; obj = nullptr; } } inline static PolygonPartition2* CastToPolygonPartition2(void* ptr) { return static_cast(ptr); } static void ClearBuffer(void* ptr) { auto par = CastToPolygonPartition2(ptr); par->buffer.clear(); } static int BufferCount(void* ptr) { auto par = CastToPolygonPartition2(ptr); return (int)par->buffer.size(); } static void* CopyBufferItem(void* ptr, int index) { auto par = CastToPolygonPartition2(ptr); auto copy = Polygon2::NewPolygon2(); for (const Point_2& p : par->buffer[index]) copy->push_back(p); return copy; } static BOOL Is_Y_Monotone(void* ptr, void* polyPtr) { auto par = CastToPolygonPartition2(ptr); auto poly = Polygon2::CastToPolygon2(polyPtr); return CGAL::is_y_monotone_2(poly->vertices_begin(), poly->vertices_end()); } static BOOL Is_Y_MonotonePWH(void* ptr, void* polyPtr) { auto par = CastToPolygonPartition2(ptr); auto poly = PolygonWithHoles2::CastToPolygonWithHoles2(polyPtr); return CGAL::is_y_monotone_2(poly->outer_boundary().vertices_begin(), poly->outer_boundary().vertices_end()); } static BOOL PartionIsValid(void* ptr, void* polyPtr) { auto par = CastToPolygonPartition2(ptr); auto poly = Polygon2::CastToPolygon2(polyPtr); return CGAL::partition_is_valid_2(poly->vertices_begin(), poly->vertices_end(), par->buffer.begin(), par->buffer.end()); } static BOOL ConvexPartionIsValid(void* ptr, void* polyPtr) { auto par = CastToPolygonPartition2(ptr); auto poly = Polygon2::CastToPolygon2(polyPtr); return CGAL::convex_partition_is_valid_2(poly->vertices_begin(), poly->vertices_end(), par->buffer.begin(), par->buffer.end()); } static BOOL Y_MonotonePartionIsValid(void* ptr, void* polyPtr) { auto par = CastToPolygonPartition2(ptr); auto poly = Polygon2::CastToPolygon2(polyPtr); return CGAL::y_monotone_partition_is_valid_2(poly->vertices_begin(), poly->vertices_end(), par->buffer.begin(), par->buffer.end()); } static int Y_MonotonePartition(void* ptr, void* polyPtr) { auto par = CastToPolygonPartition2(ptr); auto poly = Polygon2::CastToPolygon2(polyPtr); par->buffer.clear(); CGAL::y_monotone_partition_2(poly->vertices_begin(), poly->vertices_end(), std::back_inserter(par->buffer)); return (int)par->buffer.size(); } static int Y_MonotonePartitionPWH(void* ptr, void* polyPtr) { auto par = CastToPolygonPartition2(ptr); auto poly = PolygonWithHoles2::CastToPolygonWithHoles2(polyPtr); par->buffer.clear(); CGAL::y_monotone_partition_2(poly->outer_boundary().vertices_begin(), poly->outer_boundary().vertices_end(), std::back_inserter(par->buffer)); return (int)par->buffer.size(); } static int ApproxConvexPartition(void* ptr, void* polyPtr) { auto par = CastToPolygonPartition2(ptr); auto poly = Polygon2::CastToPolygon2(polyPtr); par->buffer.clear(); CGAL::approx_convex_partition_2(poly->vertices_begin(), poly->vertices_end(), std::back_inserter(par->buffer)); return (int)par->buffer.size(); } static int ApproxConvexPartitionPWH(void* ptr, void* polyPtr) { auto par = CastToPolygonPartition2(ptr); auto poly = PolygonWithHoles2::CastToPolygonWithHoles2(polyPtr); par->buffer.clear(); CGAL::approx_convex_partition_2(poly->outer_boundary().vertices_begin(), poly->outer_boundary().vertices_end(), std::back_inserter(par->buffer)); return (int)par->buffer.size(); } static int GreeneApproxConvexPartition(void* ptr, void* polyPtr) { auto par = CastToPolygonPartition2(ptr); auto poly = Polygon2::CastToPolygon2(polyPtr); par->buffer.clear(); CGAL::greene_approx_convex_partition_2(poly->vertices_begin(), poly->vertices_end(), std::back_inserter(par->buffer)); return (int)par->buffer.size(); } static int GreeneApproxConvexPartitionPWH(void* ptr, void* polyPtr) { auto par = CastToPolygonPartition2(ptr); auto poly = PolygonWithHoles2::CastToPolygonWithHoles2(polyPtr); par->buffer.clear(); CGAL::greene_approx_convex_partition_2(poly->outer_boundary().vertices_begin(), poly->outer_boundary().vertices_end(), std::back_inserter(par->buffer)); return (int)par->buffer.size(); } static int OptimalConvexPartition(void* ptr, void* polyPtr) { auto par = CastToPolygonPartition2(ptr); auto poly = Polygon2::CastToPolygon2(polyPtr); par->buffer.clear(); CGAL::optimal_convex_partition_2(poly->vertices_begin(), poly->vertices_end(), std::back_inserter(par->buffer)); return (int)par->buffer.size(); } static int OptimalConvexPartitionPWH(void* ptr, void* polyPtr) { auto par = CastToPolygonPartition2(ptr); auto poly = PolygonWithHoles2::CastToPolygonWithHoles2(polyPtr); par->buffer.clear(); CGAL::optimal_convex_partition_2(poly->outer_boundary().vertices_begin(), poly->outer_boundary().vertices_end(), std::back_inserter(par->buffer)); return (int)par->buffer.size(); } }; ================================================ FILE: CGALWrapper/Polygons/PolygonPartition2_EEK.cpp ================================================ #include "PolygonPartition2_EEK.h" #include "PolygonPartition2.h" void* PolygonPartition2_EEK_Create() { return PolygonPartition2::NewPolygonPartition2(); } void PolygonPartition2_EEK_Release(void* ptr) { PolygonPartition2::DeletePolygonPartition2(ptr); } void PolygonPartition2_EEK_ClearBuffer(void* ptr) { PolygonPartition2::ClearBuffer(ptr); } int PolygonPartition2_EEK_BufferCount(void* ptr) { return PolygonPartition2::BufferCount(ptr); } void* PolygonPartition2_EEK_CopyBufferItem(void* ptr, int index) { return PolygonPartition2::CopyBufferItem(ptr, index); } BOOL PolygonPartition2_EEK_Is_Y_Monotone(void* ptr, void* polyPtr) { return PolygonPartition2::Is_Y_Monotone(ptr, polyPtr); } BOOL PolygonPartition2_EEK_Is_Y_MonotonePWH(void* ptr, void* polyPtr) { return PolygonPartition2::Is_Y_MonotonePWH(ptr, polyPtr); } BOOL PolygonPartition2_EEK_PartitionIsValid(void* ptr, void* polyPtr) { return PolygonPartition2::PartionIsValid(ptr, polyPtr); } BOOL PolygonPartition2_EEK_ConvexPartitionIsValid(void* ptr, void* polyPtr) { return PolygonPartition2::ConvexPartionIsValid(ptr, polyPtr); } int PolygonPartition2_EEK_Y_MonotonePartition(void* ptr, void* polyPtr) { return PolygonPartition2::Y_MonotonePartition(ptr, polyPtr); } int PolygonPartition2_EEK_Y_MonotonePartitionPWH(void* ptr, void* polyPtr) { return PolygonPartition2::Y_MonotonePartitionPWH(ptr, polyPtr); } int PolygonPartition2_EEK_ApproxConvexPartition(void* ptr, void* polyPtr) { return PolygonPartition2::ApproxConvexPartition(ptr, polyPtr); } int PolygonPartition2_EEK_ApproxConvexPartitionPWH(void* ptr, void* polyPtr) { return PolygonPartition2::ApproxConvexPartitionPWH(ptr, polyPtr); } int PolygonPartition2_EEK_GreeneApproxConvexPartition(void* ptr, void* polyPtr) { return PolygonPartition2::GreeneApproxConvexPartition(ptr, polyPtr); } int PolygonPartition2_EEK_GreeneApproxConvexPartitionPWH(void* ptr, void* polyPtr) { return PolygonPartition2::GreeneApproxConvexPartitionPWH(ptr, polyPtr); } int PolygonPartition2_EEK_OptimalConvexPartition(void* ptr, void* polyPtr) { return PolygonPartition2::OptimalConvexPartition(ptr, polyPtr); } int PolygonPartition2_EEK_OptimalConvexPartitionPWH(void* ptr, void* polyPtr) { return PolygonPartition2::OptimalConvexPartitionPWH(ptr, polyPtr); } ================================================ FILE: CGALWrapper/Polygons/PolygonPartition2_EEK.h ================================================ #pragma once #include "../CGALWrapper.h" #include "../Geometry/Geometry2.h" extern "C" { CGALWRAPPER_API void* PolygonPartition2_EEK_Create(); CGALWRAPPER_API void PolygonPartition2_EEK_Release(void* ptr); CGALWRAPPER_API void PolygonPartition2_EEK_ClearBuffer(void* ptr); CGALWRAPPER_API int PolygonPartition2_EEK_BufferCount(void* ptr); CGALWRAPPER_API void* PolygonPartition2_EEK_CopyBufferItem(void* ptr, int index); CGALWRAPPER_API BOOL PolygonPartition2_EEK_Is_Y_Monotone(void* ptr, void* polyPtr); CGALWRAPPER_API BOOL PolygonPartition2_EEK_Is_Y_MonotonePWH(void* ptr, void* polyPtr); CGALWRAPPER_API BOOL PolygonPartition2_EEK_PartitionIsValid(void* ptr, void* polyPtr); CGALWRAPPER_API BOOL PolygonPartition2_EEK_ConvexPartitionIsValid(void* ptr, void* polyPtr); CGALWRAPPER_API int PolygonPartition2_EEK_Y_MonotonePartition(void* ptr, void* polyPtr); CGALWRAPPER_API int PolygonPartition2_EEK_Y_MonotonePartitionPWH(void* ptr, void* polyPtr); CGALWRAPPER_API int PolygonPartition2_EEK_ApproxConvexPartition(void* ptr, void* polyPtr); CGALWRAPPER_API int PolygonPartition2_EEK_ApproxConvexPartitionPWH(void* ptr, void* polyPtr); CGALWRAPPER_API int PolygonPartition2_EEK_GreeneApproxConvexPartition(void* ptr, void* polyPtr); CGALWRAPPER_API int PolygonPartition2_EEK_GreeneApproxConvexPartitionPWH(void* ptr, void* polyPtr); CGALWRAPPER_API int PolygonPartition2_EEK_OptimalConvexPartition(void* ptr, void* polyPtr); CGALWRAPPER_API int PolygonPartition2_EEK_OptimalConvexPartitionPWH(void* ptr, void* polyPtr); } ================================================ FILE: CGALWrapper/Polygons/PolygonPartition2_EIK.cpp ================================================ #include "PolygonPartition2_EIK.h" #include "PolygonPartition2.h" void* PolygonPartition2_EIK_Create() { return PolygonPartition2::NewPolygonPartition2(); } void PolygonPartition2_EIK_Release(void* ptr) { PolygonPartition2::DeletePolygonPartition2(ptr); } void PolygonPartition2_EIK_ClearBuffer(void* ptr) { PolygonPartition2::ClearBuffer(ptr); } int PolygonPartition2_EIK_BufferCount(void* ptr) { return PolygonPartition2::BufferCount(ptr); } void* PolygonPartition2_EIK_CopyBufferItem(void* ptr, int index) { return PolygonPartition2::CopyBufferItem(ptr, index); } BOOL PolygonPartition2_EIK_Is_Y_Monotone(void* ptr, void* polyPtr) { return PolygonPartition2::Is_Y_Monotone(ptr, polyPtr); } BOOL PolygonPartition2_EIK_Is_Y_MonotonePWH(void* ptr, void* polyPtr) { return PolygonPartition2::Is_Y_MonotonePWH(ptr, polyPtr); } BOOL PolygonPartition2_EIK_PartitionIsValid(void* ptr, void* polyPtr) { return PolygonPartition2::PartionIsValid(ptr, polyPtr); } BOOL PolygonPartition2_EIK_ConvexPartitionIsValid(void* ptr, void* polyPtr) { return PolygonPartition2::ConvexPartionIsValid(ptr, polyPtr); } int PolygonPartition2_EIK_Y_MonotonePartition(void* ptr, void* polyPtr) { return PolygonPartition2::Y_MonotonePartition(ptr, polyPtr); } int PolygonPartition2_EIK_Y_MonotonePartitionPWH(void* ptr, void* polyPtr) { return PolygonPartition2::Y_MonotonePartitionPWH(ptr, polyPtr); } int PolygonPartition2_EIK_ApproxConvexPartition(void* ptr, void* polyPtr) { return PolygonPartition2::ApproxConvexPartition(ptr, polyPtr); } int PolygonPartition2_EIK_ApproxConvexPartitionPWH(void* ptr, void* polyPtr) { return PolygonPartition2::ApproxConvexPartitionPWH(ptr, polyPtr); } int PolygonPartition2_EIK_GreeneApproxConvexPartition(void* ptr, void* polyPtr) { return PolygonPartition2::GreeneApproxConvexPartition(ptr, polyPtr); } int PolygonPartition2_EIK_GreeneApproxConvexPartitionPWH(void* ptr, void* polyPtr) { return PolygonPartition2::GreeneApproxConvexPartitionPWH(ptr, polyPtr); } int PolygonPartition2_EIK_OptimalConvexPartition(void* ptr, void* polyPtr) { return PolygonPartition2::OptimalConvexPartition(ptr, polyPtr); } int PolygonPartition2_EIK_OptimalConvexPartitionPWH(void* ptr, void* polyPtr) { return PolygonPartition2::OptimalConvexPartitionPWH(ptr, polyPtr); } ================================================ FILE: CGALWrapper/Polygons/PolygonPartition2_EIK.h ================================================ #pragma once #include "../CGALWrapper.h" #include "../Geometry/Geometry2.h" extern "C" { CGALWRAPPER_API void* PolygonPartition2_EIK_Create(); CGALWRAPPER_API void PolygonPartition2_EIK_Release(void* ptr); CGALWRAPPER_API void PolygonPartition2_EIK_ClearBuffer(void* ptr); CGALWRAPPER_API int PolygonPartition2_EIK_BufferCount(void* ptr); CGALWRAPPER_API void* PolygonPartition2_EIK_CopyBufferItem(void* ptr, int index); CGALWRAPPER_API BOOL PolygonPartition2_EIK_Is_Y_Monotone(void* ptr, void* polyPtr); CGALWRAPPER_API BOOL PolygonPartition2_EIK_Is_Y_MonotonePWH(void* ptr, void* polyPtr); CGALWRAPPER_API BOOL PolygonPartition2_EIK_PartitionIsValid(void* ptr, void* polyPtr); CGALWRAPPER_API BOOL PolygonPartition2_EIK_ConvexPartitionIsValid(void* ptr, void* polyPtr); CGALWRAPPER_API int PolygonPartition2_EIK_Y_MonotonePartition(void* ptr, void* polyPtr); CGALWRAPPER_API int PolygonPartition2_EIK_Y_MonotonePartitionPWH(void* ptr, void* polyPtr); CGALWRAPPER_API int PolygonPartition2_EIK_ApproxConvexPartition(void* ptr, void* polyPtr); CGALWRAPPER_API int PolygonPartition2_EIK_ApproxConvexPartitionPWH(void* ptr, void* polyPtr); CGALWRAPPER_API int PolygonPartition2_EIK_GreeneApproxConvexPartition(void* ptr, void* polyPtr); CGALWRAPPER_API int PolygonPartition2_EIK_GreeneApproxConvexPartitionPWH(void* ptr, void* polyPtr); CGALWRAPPER_API int PolygonPartition2_EIK_OptimalConvexPartition(void* ptr, void* polyPtr); CGALWRAPPER_API int PolygonPartition2_EIK_OptimalConvexPartitionPWH(void* ptr, void* polyPtr); } ================================================ FILE: CGALWrapper/Polygons/PolygonSimplification2.h ================================================ #pragma once #include "../CGALWrapper.h" #include "../Geometry/Geometry2.h" #include #include #include #include #include template class PolygonSimplification2 { public: PolygonSimplification2() {} typedef CGAL::Polygon_2 Polygon_2; typedef CGAL::Polygon_with_holes_2 Pwh_2; typedef CGAL::Polyline_simplification_2::Stop_below_count_ratio_threshold stop_below_ratio; typedef CGAL::Polyline_simplification_2::Stop_below_count_threshold stop_below_threshold; typedef CGAL::Polyline_simplification_2::Stop_above_cost_threshold stop_above_threshold; typedef CGAL::Polyline_simplification_2::Squared_distance_cost sq_dist_cost; typedef CGAL::Polyline_simplification_2::Hybrid_squared_distance_cost hsq_dist_cost; typedef CGAL::Polyline_simplification_2::Scaled_squared_distance_cost ssq_dist_cost; inline static PolygonSimplification2* NewPolygonSimplification2() { return new PolygonSimplification2(); } inline static void DeletePolygonSimplification2(void* ptr) { auto obj = static_cast(ptr); if (obj != nullptr) { delete obj; obj = nullptr; } } inline static PolygonSimplification2* CastToPolygonSimplification2(void* ptr) { return static_cast(ptr); } inline static Polygon_2* CastToPolygon2(void* ptr) { return static_cast(ptr); } inline static Pwh_2* CastToPolygonWithHoles2(void* ptr) { return static_cast(ptr); } static void* Simplify(void* polyPtr, COST_FUNC costFunc, STOP_FUNC stopFunc, double theshold) { auto poly = CastToPolygon2(polyPtr); size_t intThreshold = (size_t)std::round(theshold); Polygon_2 result; switch (costFunc) { case COST_FUNC::SQUARE_DIST: switch (stopFunc) { case STOP_FUNC::ABOVE_THRESHOLD: result = CGAL::Polyline_simplification_2::simplify(*poly, sq_dist_cost(), stop_above_threshold(theshold)); break; case STOP_FUNC::BELOW_THRESHOLD: result = CGAL::Polyline_simplification_2::simplify(*poly, sq_dist_cost(), stop_below_threshold(intThreshold)); break; case STOP_FUNC::BELOW_RATIO: result = CGAL::Polyline_simplification_2::simplify(*poly, sq_dist_cost(), stop_below_ratio(theshold)); break; } break; case COST_FUNC::SCALED_SQ_DIST: switch (stopFunc) { case STOP_FUNC::ABOVE_THRESHOLD: result = CGAL::Polyline_simplification_2::simplify(*poly, ssq_dist_cost(), stop_above_threshold(theshold)); break; case STOP_FUNC::BELOW_THRESHOLD: result = CGAL::Polyline_simplification_2::simplify(*poly, ssq_dist_cost(), stop_below_threshold(intThreshold)); break; case STOP_FUNC::BELOW_RATIO: result = CGAL::Polyline_simplification_2::simplify(*poly, ssq_dist_cost(), stop_below_ratio(theshold)); break; } break; } return new Polygon_2(result); } static Polygon_2 Simplify(const Polygon_2& poly, COST_FUNC costFunc, STOP_FUNC stopFunc, double theshold) { size_t intThreshold = (size_t)std::round(theshold); Polygon_2 result; switch (costFunc) { case COST_FUNC::SQUARE_DIST: switch (stopFunc) { case STOP_FUNC::ABOVE_THRESHOLD: result = CGAL::Polyline_simplification_2::simplify(poly, sq_dist_cost(), stop_above_threshold(theshold)); break; case STOP_FUNC::BELOW_THRESHOLD: result = CGAL::Polyline_simplification_2::simplify(poly, sq_dist_cost(), stop_below_threshold(intThreshold)); break; case STOP_FUNC::BELOW_RATIO: result = CGAL::Polyline_simplification_2::simplify(poly, sq_dist_cost(), stop_below_ratio(theshold)); break; } break; case COST_FUNC::SCALED_SQ_DIST: switch (stopFunc) { case STOP_FUNC::ABOVE_THRESHOLD: result = CGAL::Polyline_simplification_2::simplify(poly, ssq_dist_cost(), stop_above_threshold(theshold)); break; case STOP_FUNC::BELOW_THRESHOLD: result = CGAL::Polyline_simplification_2::simplify(poly, ssq_dist_cost(), stop_below_threshold(intThreshold)); break; case STOP_FUNC::BELOW_RATIO: result = CGAL::Polyline_simplification_2::simplify(poly, ssq_dist_cost(), stop_below_ratio(theshold)); break; } break; } return result; } static void* SimplifyPolygonWithHoles_All(void* pwhPtr, COST_FUNC costFunc, STOP_FUNC stopFunc, double threshold) { typedef CGAL::Polygon_with_holes_2 Pwh_2; auto pwh = PolygonSimplification2::CastToPolygonWithHoles2(pwhPtr); Pwh_2* p = nullptr; if (!pwh->is_unbounded()) { auto boundary = Simplify(pwh->outer_boundary(), costFunc, stopFunc, threshold); p = new Pwh_2(boundary); } else p = new Pwh_2(); for (auto hole : pwh->holes()) { auto h = Simplify(hole, costFunc, stopFunc, threshold); p->add_hole(h); } return p; } static void* SimplifyPolygonWithHoles_Boundary(void* pwhPtr, COST_FUNC costFunc, STOP_FUNC stopFunc, double threshold) { typedef CGAL::Polygon_with_holes_2 Pwh_2; auto pwh = PolygonSimplification2::CastToPolygonWithHoles2(pwhPtr); Pwh_2* p = nullptr; if (!pwh->is_unbounded()) { auto boundary = Simplify(pwh->outer_boundary(), costFunc, stopFunc, threshold); p = new Pwh_2(boundary); } else p = new Pwh_2(); for (auto hole : pwh->holes()) p->add_hole(hole); return p; } static void* SimplifyPolygonWithHoles_Holes(void* pwhPtr, COST_FUNC costFunc, STOP_FUNC stopFunc, double threshold) { typedef CGAL::Polygon_with_holes_2 Pwh_2; auto pwh = PolygonSimplification2::CastToPolygonWithHoles2(pwhPtr); Pwh_2* p = nullptr; if (!pwh->is_unbounded()) p = new Pwh_2(pwh->outer_boundary()); else p = new Pwh_2(); for (auto hole : pwh->holes()) p->add_hole(hole); return p; } static void* SimplifyPolygonWithHoles_Hole(void* pwhPtr, COST_FUNC costFunc, STOP_FUNC stopFunc, double threshold, int index) { typedef CGAL::Polygon_with_holes_2 Pwh_2; auto pwh = PolygonSimplification2::CastToPolygonWithHoles2(pwhPtr); Pwh_2* p = nullptr; if (!pwh->is_unbounded()) p = new Pwh_2(pwh->outer_boundary()); else p = new Pwh_2(); int count = 0; for (auto hole : pwh->holes()) { if (count == index) { auto h = Simplify(hole, costFunc, stopFunc, threshold); p->add_hole(h); } else p->add_hole(hole); count++; } return p; } }; ================================================ FILE: CGALWrapper/Polygons/PolygonSimplification2_EEK.cpp ================================================ #include "PolygonSimplification2_EEK.h" #include "PolygonSimplification2.h" #include #include void* PolygonSimplification2_EEK_Create() { return PolygonSimplification2::NewPolygonSimplification2(); } void PolygonSimplification2_EEK_Release(void* ptr) { PolygonSimplification2::DeletePolygonSimplification2(ptr); } void* PolygonSimplification2_EEK_Simplify(void* polyPtr, COST_FUNC costFunc, STOP_FUNC stopFunc, double theshold) { return PolygonSimplification2::Simplify(polyPtr, costFunc, stopFunc, theshold); } void* PolygonSimplification2_EEK_SimplifyPolygonWithHoles_All(void* pwhPtr, COST_FUNC costFunc, STOP_FUNC stopFunc, double theshold) { return PolygonSimplification2::SimplifyPolygonWithHoles_All(pwhPtr, costFunc, stopFunc, theshold); } void* PolygonSimplification2_EEK_SimplifyPolygonWithHoles_Boundary(void* pwhPtr, COST_FUNC costFunc, STOP_FUNC stopFunc, double theshold) { return PolygonSimplification2::SimplifyPolygonWithHoles_Boundary(pwhPtr, costFunc, stopFunc, theshold); } void* PolygonSimplification2_EEK_SimplifyPolygonWithHoles_Holes(void* pwhPtr, COST_FUNC costFunc, STOP_FUNC stopFunc, double theshold) { return PolygonSimplification2::SimplifyPolygonWithHoles_Holes(pwhPtr, costFunc, stopFunc, theshold); } void* PolygonSimplification2_EEK_SimplifyPolygonWithHoles_Hole(void* pwhPtr, COST_FUNC costFunc, STOP_FUNC stopFunc, double theshold, int index) { return PolygonSimplification2::SimplifyPolygonWithHoles_Hole(pwhPtr, costFunc, stopFunc, theshold, index); } ================================================ FILE: CGALWrapper/Polygons/PolygonSimplification2_EEK.h ================================================ #pragma once #include "../CGALWrapper.h" #include "../Geometry/Geometry2.h" #include #include enum COST_FUNC : int { SQUARE_DIST, SCALED_SQ_DIST }; enum STOP_FUNC : int { BELOW_RATIO, BELOW_THRESHOLD, ABOVE_THRESHOLD }; extern "C" { CGALWRAPPER_API void* PolygonSimplification2_EEK_Create(); CGALWRAPPER_API void PolygonSimplification2_EEK_Release(void* ptr); CGALWRAPPER_API void* PolygonSimplification2_EEK_Simplify(void* polyPtr, COST_FUNC costFunc, STOP_FUNC stopFunc, double theshold); CGALWRAPPER_API void* PolygonSimplification2_EEK_SimplifyPolygonWithHoles_All(void* pwhPtr, COST_FUNC costFunc, STOP_FUNC stopFunc, double theshold); CGALWRAPPER_API void* PolygonSimplification2_EEK_SimplifyPolygonWithHoles_Boundary(void* pwhPtr, COST_FUNC costFunc, STOP_FUNC stopFunc, double theshold); CGALWRAPPER_API void* PolygonSimplification2_EEK_SimplifyPolygonWithHoles_Holes(void* pwhPtr, COST_FUNC costFunc, STOP_FUNC stopFunc, double theshold); CGALWRAPPER_API void* PolygonSimplification2_EEK_SimplifyPolygonWithHoles_Hole(void* pwhPtr, COST_FUNC costFunc, STOP_FUNC stopFunc, double theshold, int index); } ================================================ FILE: CGALWrapper/Polygons/PolygonSimplification2_EIK.cpp ================================================ #include "PolygonSimplification2_EIK.h" #include "PolygonSimplification2.h" #include #include void* PolygonSimplification2_EIK_Create() { return PolygonSimplification2::NewPolygonSimplification2(); } void PolygonSimplification2_EIK_Release(void* ptr) { PolygonSimplification2::DeletePolygonSimplification2(ptr); } void* PolygonSimplification2_EIK_Simplify(void* polyPtr, COST_FUNC costFunc, STOP_FUNC stopFunc, double theshold) { return PolygonSimplification2::Simplify(polyPtr, costFunc, stopFunc, theshold); } void* PolygonSimplification2_EIK_SimplifyPolygonWithHoles_All(void* pwhPtr, COST_FUNC costFunc, STOP_FUNC stopFunc, double theshold) { return PolygonSimplification2::SimplifyPolygonWithHoles_All(pwhPtr, costFunc, stopFunc, theshold); } void* PolygonSimplification2_EIK_SimplifyPolygonWithHoles_Boundary(void* pwhPtr, COST_FUNC costFunc, STOP_FUNC stopFunc, double theshold) { return PolygonSimplification2::SimplifyPolygonWithHoles_Boundary(pwhPtr, costFunc, stopFunc, theshold); } void* PolygonSimplification2_EIK_SimplifyPolygonWithHoles_Holes(void* pwhPtr, COST_FUNC costFunc, STOP_FUNC stopFunc, double theshold) { return PolygonSimplification2::SimplifyPolygonWithHoles_Holes(pwhPtr, costFunc, stopFunc, theshold); } void* PolygonSimplification2_EIK_SimplifyPolygonWithHoles_Hole(void* pwhPtr, COST_FUNC costFunc, STOP_FUNC stopFunc, double theshold, int index) { return PolygonSimplification2::SimplifyPolygonWithHoles_Hole(pwhPtr, costFunc, stopFunc, theshold, index); } ================================================ FILE: CGALWrapper/Polygons/PolygonSimplification2_EIK.h ================================================ #pragma once #include "../CGALWrapper.h" #include "../Geometry/Geometry2.h" #include #include enum COST_FUNC : int { SQUARE_DIST, SCALED_SQ_DIST }; enum STOP_FUNC : int { BELOW_RATIO, BELOW_THRESHOLD, ABOVE_THRESHOLD }; extern "C" { CGALWRAPPER_API void* PolygonSimplification2_EIK_Create(); CGALWRAPPER_API void PolygonSimplification2_EIK_Release(void* ptr); CGALWRAPPER_API void* PolygonSimplification2_EIK_Simplify(void* polyPtr, COST_FUNC costFunc, STOP_FUNC stopFunc, double theshold); CGALWRAPPER_API void* PolygonSimplification2_EIK_SimplifyPolygonWithHoles_All(void* pwhPtr, COST_FUNC costFunc, STOP_FUNC stopFunc, double theshold); CGALWRAPPER_API void* PolygonSimplification2_EIK_SimplifyPolygonWithHoles_Boundary(void* pwhPtr, COST_FUNC costFunc, STOP_FUNC stopFunc, double theshold); CGALWRAPPER_API void* PolygonSimplification2_EIK_SimplifyPolygonWithHoles_Holes(void* pwhPtr, COST_FUNC costFunc, STOP_FUNC stopFunc, double theshold); CGALWRAPPER_API void* PolygonSimplification2_EIK_SimplifyPolygonWithHoles_Hole(void* pwhPtr, COST_FUNC costFunc, STOP_FUNC stopFunc, double theshold, int index); } ================================================ FILE: CGALWrapper/Polygons/PolygonVisibility_EEK.cpp ================================================ #include "PolygonVisibility_EEK.h" #include "PolygonVisiblity.h" void* PolygonVisibility_EEK_Create() { return PolygonVisibility::NewPolygonVisibility(); } void PolygonVisibility_EEK_Release(void* ptr) { PolygonVisibility::DeletePolygonVisibility(ptr); } void* PolygonVisibility_EEK_ComputeVisibilitySimple(const Point2d& point, void* polyPtr) { return PolygonVisibility::ComputeVisibilitySimple(point, polyPtr); } void* PolygonVisibility_EEK_ComputeVisibilityTEV(const Point2d& point, void* pwhPtr) { return PolygonVisibility::ComputeVisibilityTEV(point, pwhPtr); } void* PolygonVisibility_EEK_ComputeVisibilityRSV(const Point2d& point, void* pwhPtr) { return PolygonVisibility::ComputeVisibilityRSV(point, pwhPtr); } ================================================ FILE: CGALWrapper/Polygons/PolygonVisibility_EEK.h ================================================ #pragma once #include "../CGALWrapper.h" #include "../Geometry/Geometry2.h" #include extern "C" { CGALWRAPPER_API void* PolygonVisibility_EEK_Create(); CGALWRAPPER_API void PolygonVisibility_EEK_Release(void* ptr); CGALWRAPPER_API void* PolygonVisibility_EEK_ComputeVisibilitySimple(const Point2d& point, void* polyPtr); CGALWRAPPER_API void* PolygonVisibility_EEK_ComputeVisibilityTEV(const Point2d& point, void* pwhPtr); CGALWRAPPER_API void* PolygonVisibility_EEK_ComputeVisibilityRSV(const Point2d& point, void* pwhPtr); } ================================================ FILE: CGALWrapper/Polygons/PolygonVisibility_EIK.cpp ================================================ #include "PolygonVisibility_EIK.h" #include "PolygonVisiblity.h" void* PolygonVisibility_EIK_Create() { return PolygonVisibility::NewPolygonVisibility(); } void PolygonVisibility_EIK_Release(void* ptr) { PolygonVisibility::DeletePolygonVisibility(ptr); } void* PolygonVisibility_EIK_ComputeVisibilitySimple(const Point2d& point, void* polyPtr) { return PolygonVisibility::ComputeVisibilitySimple(point, polyPtr); } void* PolygonVisibility_EIK_ComputeVisibilityTEV(const Point2d& point, void* pwhPtr) { return PolygonVisibility::ComputeVisibilityTEV(point, pwhPtr); } void* PolygonVisibility_EIK_ComputeVisibilityRSV(const Point2d& point, void* pwhPtr) { return PolygonVisibility::ComputeVisibilityRSV(point, pwhPtr); } ================================================ FILE: CGALWrapper/Polygons/PolygonVisibility_EIK.h ================================================ #pragma once #include "../CGALWrapper.h" #include "../Geometry/Geometry2.h" #include extern "C" { CGALWRAPPER_API void* PolygonVisibility_EIK_Create(); CGALWRAPPER_API void PolygonVisibility_EIK_Release(void* ptr); CGALWRAPPER_API void* PolygonVisibility_EIK_ComputeVisibilitySimple(const Point2d& point, void* polyPtr); CGALWRAPPER_API void* PolygonVisibility_EIK_ComputeVisibilityTEV(const Point2d& point, void* pwhPtr); CGALWRAPPER_API void* PolygonVisibility_EIK_ComputeVisibilityRSV(const Point2d& point, void* pwhPtr); } ================================================ FILE: CGALWrapper/Polygons/PolygonVisiblity.h ================================================ #pragma once #include "../CGALWrapper.h" #include "../Geometry/Geometry2.h" #include "Polygon2.h" #include "PolygonWithHoles2.h" #include #include #include #include #include #include #include #include #include template class PolygonVisibility { public: //typedef CGAL::Exact_predicates_exact_constructions_kernel Kernel; typedef CGAL::Polygon_2 Point_2; typedef CGAL::Segment_2 Segment_2; typedef CGAL::Arr_segment_traits_2 Traits_2; typedef CGAL::Arrangement_2 Arrangement_2; typedef CGAL::Triangular_expansion_visibility_2 TEV; typedef CGAL::Rotational_sweep_visibility_2 RSV; typedef CGAL::Arr_walk_along_line_point_location Locator; typedef typename Polygon2::Polygon_2 Polygon; typedef typename PolygonWithHoles2::Pwh_2 Pwh; inline static PolygonVisibility* NewPolygonVisibility() { return new PolygonVisibility(); } inline static void DeletePolygonVisibility(void* ptr) { auto obj = static_cast(ptr); if (obj != nullptr) { delete obj; obj = nullptr; } } inline static PolygonVisibility* CastToPolygonVisibility(void* ptr) { return static_cast(ptr); } static void GetSegments(std::vector& segments, const Polygon& poly) { int count = (int)poly.size(); for (int i = 0; i < count; i++) { if (i != count - 1) { auto p1 = poly.vertex(i); auto p2 = poly.vertex(i + 1); segments.push_back(Segment_2(p1, p2)); } else { auto p1 = poly.vertex(i); auto p2 = poly.vertex(0); segments.push_back(Segment_2(p1, p2)); } } } static void GetSegments(std::vector& segments, const Pwh& pwh) { int count = (int)pwh.outer_boundary().size(); for (int i = 0; i < count; i++) { if (i != count - 1) { auto p1 = pwh.outer_boundary().vertex(i); auto p2 = pwh.outer_boundary().vertex(i + 1); segments.push_back(Segment_2(p1, p2)); } else { auto p1 = pwh.outer_boundary().vertex(i); auto p2 = pwh.outer_boundary().vertex(0); segments.push_back(Segment_2(p1, p2)); } } int holes = (int)pwh.number_of_holes(); for (int j = 0; j < holes; j++) { auto& hole = pwh.holes().at(j); count = (int)hole.size(); for (int i = 0; i < count; i++) { if (i != count - 1) { auto p1 = hole.vertex(i); auto p2 = hole.vertex(i + 1); segments.push_back(Segment_2(p1, p2)); } else { auto p1 = hole.vertex(i); auto p2 = hole.vertex(0); segments.push_back(Segment_2(p1, p2)); } } } } static void* ComputeVisibilitySimple(const Point2d& point, void* polyPtr) { auto poly = Polygon2::CastToPolygon2(polyPtr); std::vector segments; GetSegments(segments, *poly); Arrangement_2 env; CGAL::insert_non_intersecting_curves(env, segments.begin(), segments.end()); Locator pl(env); auto q = point.ToCGAL(); auto obj = pl.locate(q); auto face = boost::get(&obj); typedef CGAL::Simple_polygon_visibility_2 RSPV; Arrangement_2 regular_output; RSPV regular_visibility(env); regular_visibility.compute_visibility(q, *face, regular_output); auto result = Polygon2::NewPolygon2(); auto start = regular_output.edges_begin()->next(); auto eit = start; do { auto p = eit->source()->point(); result->push_back(p); eit = eit->next(); } while (eit != start); return result; } static void* ComputeVisibilityTEV(const Point2d& point, void* pwhPtr) { auto pwh = PolygonWithHoles2::CastToPolygonWithHoles2(pwhPtr); std::vector segments; GetSegments(segments, *pwh); Arrangement_2 env; CGAL::insert_non_intersecting_curves(env, segments.begin(), segments.end()); Locator pl(env); auto q = point.ToCGAL(); auto obj = pl.locate(q); auto face = boost::get(&obj); Arrangement_2 output_arr; TEV tev(env); auto fh = tev.compute_visibility(q, *face, output_arr); auto result = PolygonWithHoles2::NewPolygonWithHoles2(); auto curr = fh->outer_ccb(); result->outer_boundary().push_back(curr->source()->point()); while (++curr != fh->outer_ccb()) { result->outer_boundary().push_back(curr->source()->point()); } return result; } static void* ComputeVisibilityRSV(const Point2d& point, void* pwhPtr) { auto pwh = PolygonWithHoles2::CastToPolygonWithHoles2(pwhPtr); std::vector segments; GetSegments(segments, *pwh); Arrangement_2 env; CGAL::insert_non_intersecting_curves(env, segments.begin(), segments.end()); Locator pl(env); auto q = point.ToCGAL(); auto obj = pl.locate(q); auto face = boost::get(&obj); Arrangement_2 output_arr; RSV rsv(env); auto fh = rsv.compute_visibility(q, *face, output_arr); auto result = PolygonWithHoles2::NewPolygonWithHoles2(); auto curr = fh->outer_ccb(); result->outer_boundary().push_back(curr->source()->point()); while (++curr != fh->outer_ccb()) { result->outer_boundary().push_back(curr->source()->point()); } return result; } }; ================================================ FILE: CGALWrapper/Polygons/PolygonWithHoles2.h ================================================ #pragma once #include "../CGALWrapper.h" #include "../Geometry/Geometry2.h" #include #include #include #include #include #define BOUNDARY_INDEX -1 template class PolygonWithHoles2 { private: PolygonWithHoles2() {} public: typedef CGAL::Polygon_with_holes_2 Pwh_2; typedef CGAL::Polygon_2 Polygon_2; typedef CGAL::Point_2 Point_2; static Pwh_2* NewPolygonWithHoles2() { return new Pwh_2(); } static Pwh_2* NewPolygonWithHoles2(Pwh_2* pwh) { return new Pwh_2(*pwh); } static void DeletePolygonWithHoles2(void* ptr) { auto obj = static_cast(ptr); if (obj != nullptr) { delete obj; obj = nullptr; } } inline static Polygon_2* CastToPolygon2(void* ptr) { return static_cast(ptr); } inline static Pwh_2* CastToPolygonWithHoles2(void* ptr) { return static_cast(ptr); } static Polygon_2* GetBoundaryOrHole(void* ptr, int index) { auto pwh = CastToPolygonWithHoles2(ptr); if (index == BOUNDARY_INDEX) { if (pwh->is_unbounded()) return nullptr; else return &pwh->outer_boundary(); } else { return &pwh->holes().at(index); } } static int HoleCount(void* ptr) { auto pwh = CastToPolygonWithHoles2(ptr); return pwh->number_of_holes(); } static int PointCount(void* ptr, int index) { auto polygon = GetBoundaryOrHole(ptr, index); if (polygon != nullptr) return (int)polygon->size(); else return 0; } static void* Copy(void* ptr) { auto pwh = CastToPolygonWithHoles2(ptr); return new Pwh_2(*pwh); } static Pwh_2* Copy(Pwh_2& pwh) { return new Pwh_2(pwh); } template static void* Convert(void* ptr) { typedef CGAL::Cartesian_converter Converter; Converter convert; auto pwh = CastToPolygonWithHoles2(ptr); auto pwh2 = new CGAL::Polygon_with_holes_2(); if (!pwh->is_unbounded()) { auto count = pwh->outer_boundary().size(); for (auto i = 0; i < count; i++) { auto p = convert(pwh->outer_boundary().vertex(i)); pwh2->outer_boundary().push_back(p); } } for (auto& hole : pwh->holes()) { auto count = hole.size(); auto hole2 = CGAL::Polygon_2(); for (auto i = 0; i < count; i++) { auto p = convert(hole.vertex(i)); hole2.push_back(p); } pwh2->add_hole(hole2); } return pwh2; } static void Clear(void* ptr) { auto pwh = CastToPolygonWithHoles2(ptr); pwh->clear(); } static void ClearBoundary(void* ptr) { auto pwh = CastToPolygonWithHoles2(ptr); pwh->outer_boundary().clear(); } static void ClearHoles(void* ptr) { auto pwh = CastToPolygonWithHoles2(ptr); pwh->holes().clear(); } static void* CreateFromPolygon(void* ptr) { auto polygon = CastToPolygon2(ptr); return new Pwh_2(*polygon); } static void* CreateFromPoints(Point2d* points, int count) { auto polygon = Polygon_2(); for (auto i = 0; i < count; i++) polygon.push_back(points[i].ToCGAL()); return new Pwh_2(polygon); } static Point2d GetPoint(void* ptr, int polyIndex, int pointIndex) { auto polygon = GetBoundaryOrHole(ptr, polyIndex); if (polygon != nullptr) { auto point = polygon->vertex(pointIndex); return Point2d::FromCGAL(point); } else { return { 0, 0 }; } } static void GetPoints(void* ptr, Point2d* points, int polyIndex, int count) { auto polygon = GetBoundaryOrHole(ptr, polyIndex); if (polygon != nullptr) { for (auto i = 0; i < count; i++) { auto point = polygon->vertex(i); points[i] = Point2d::FromCGAL(point); } } } static void SetPoint(void* ptr, int polyIndex, int pointIndex, const Point2d& point) { auto polygon = GetBoundaryOrHole(ptr, polyIndex); if (polygon != nullptr) { auto size = polygon->size(); if (pointIndex < 0 || pointIndex >= size) return; (*polygon)[pointIndex] = Point_2(point.x, point.y); } } static void SetPoints(void* ptr, Point2d* points, int polyIndex, int count) { auto polygon = GetBoundaryOrHole(ptr, polyIndex); if (polygon != nullptr) { auto size = polygon->size(); for (auto i = 0; i < count; i++) { if (i < size) (*polygon)[i] = points[i].ToCGAL(); else { //Adding more points than poygon currently contains //so push back instead. polygon->push_back(points[i].ToCGAL()); } } } } static void AddHoleFromPolygon(void* pwhPtr, void* polygonPtr) { auto pwh = (Pwh_2*)pwhPtr; auto polygon = (Polygon_2*)polygonPtr; pwh->add_hole(*polygon); } static void AddHoleFromPoints(void* ptr, Point2d* points, int count) { auto pwh = (Pwh_2*)ptr; auto polygon = Polygon_2(); for (int i = 0; i < count; i++) polygon.push_back(points[i].ToCGAL()); pwh->add_hole(polygon); } static void RemoveHole(void* ptr, int index) { auto pwh = CastToPolygonWithHoles2(ptr); pwh->erase_hole(pwh->holes_begin() + index); } static void* CopyPolygon(void* ptr, int index) { auto polygon = GetBoundaryOrHole(ptr, index); if (polygon != nullptr) return new Polygon_2(*polygon); else return nullptr; } static void ReversePolygon(void* ptr, int index) { auto polygon = GetBoundaryOrHole(ptr, index); if (polygon != nullptr) return polygon->reverse_orientation(); } static BOOL IsUnbounded(void* ptr) { auto pwh = CastToPolygonWithHoles2(ptr); return pwh->is_unbounded(); } static Box2d GetBoundingBox(void* ptr, int index) { auto polygon = GetBoundaryOrHole(ptr, index); if (polygon != nullptr) { auto box = polygon->bbox(); return Box2d::FromCGAL(box); } else return {}; } static BOOL IsSimple(void* ptr, int index) { auto polygon = GetBoundaryOrHole(ptr, index); if (polygon != nullptr) return polygon->is_simple(); else return false; } static BOOL IsConvex(void* ptr, int index) { auto polygon = GetBoundaryOrHole(ptr, index); if (polygon != nullptr && polygon->is_simple()) return polygon->is_convex(); else return false; } static CGAL::Orientation Orientation(void* ptr, int index) { auto polygon = GetBoundaryOrHole(ptr, index); if (polygon != nullptr && polygon->is_simple()) return polygon->orientation(); else return CGAL::Orientation::DEGENERATE; } static CGAL::Oriented_side OrientedSide(void* ptr, int index, const Point2d& point) { auto polygon = GetBoundaryOrHole(ptr, index); if (polygon != nullptr && polygon->is_simple()) return polygon->oriented_side(point.ToCGAL()); else return CGAL::Oriented_side::DEGENERATE; } static double SignedArea(void* ptr, int index) { auto polygon = GetBoundaryOrHole(ptr, index); if (polygon != nullptr && polygon->is_simple()) return CGAL::to_double(polygon->area()); else return 0; } static void Translate(void* ptr, int index, const Point2d& translation) { auto polygon = GetBoundaryOrHole(ptr, index); if (polygon != nullptr) { CGAL::Aff_transformation_2 transformation(CGAL::TRANSLATION, translation.ToVector()); (*polygon) = CGAL::transform(transformation, *polygon); } } static void Rotate(void* ptr, int index, double rotation) { auto polygon = GetBoundaryOrHole(ptr, index); if (polygon != nullptr) { CGAL::Aff_transformation_2 transformation(CGAL::ROTATION, sin(rotation), cos(rotation)); (*polygon) = CGAL::transform(transformation, *polygon); } } static void Scale(void* ptr, int index, double scale) { auto polygon = GetBoundaryOrHole(ptr, index); if (polygon != nullptr) { CGAL::Aff_transformation_2 transformation(CGAL::SCALING, scale); (*polygon) = CGAL::transform(transformation, *polygon); } } static void Transform(void* ptr, int index, const Point2d& translation, double rotation, double scale) { auto polygon = GetBoundaryOrHole(ptr, index); if (polygon != nullptr) { CGAL::Aff_transformation_2 T(CGAL::TRANSLATION, translation.ToVector()); CGAL::Aff_transformation_2 R(CGAL::ROTATION, sin(rotation), cos(rotation)); CGAL::Aff_transformation_2 S(CGAL::SCALING, scale); (*polygon) = CGAL::transform(T * R * S, *polygon); } } static BOOL ContainsPoint(void* ptr, const Point2d& point, CGAL::Orientation orientation, BOOL inculdeBoundary) { auto pwh = CastToPolygonWithHoles2(ptr); auto& boundary = pwh->outer_boundary(); if (ContainsPoint(boundary, true, point, orientation, inculdeBoundary)) { for (auto& hole : pwh->holes()) { if (ContainsPoint(hole, false, point, orientation, inculdeBoundary)) return FALSE; } return TRUE; } else { return FALSE; } } static BOOL ContainsPoint(Pwh_2& pwh, const Point2d& point, CGAL::Orientation orientation, BOOL inculdeBoundary) { auto& boundary = pwh.outer_boundary(); if (ContainsPoint(boundary, true, point, orientation, inculdeBoundary)) { for (auto& hole : pwh.holes()) { if (ContainsPoint(hole, false, point, orientation, inculdeBoundary)) return FALSE; } return TRUE; } else { return FALSE; } } static void* ConnectHoles(void* ptr) { auto pwh = CastToPolygonWithHoles2(ptr); std::list pts; CGAL::connect_holes(*pwh, std::back_inserter(pts)); return new Polygon_2(pts.begin(), pts.end()); } private: static BOOL ContainsPoint(Polygon_2& polygon, bool isBoundary, const Point2d& point, CGAL::Orientation orientation, BOOL inculdeBoundary) { auto side = polygon.oriented_side(point.ToCGAL()); if (inculdeBoundary && side == CGAL::Oriented_side::ON_ORIENTED_BOUNDARY) return true; if(isBoundary) return side == orientation; else return side == (orientation * -1); } }; ================================================ FILE: CGALWrapper/Polygons/PolygonWithHoles2_EEK.cpp ================================================ #include "../pch.h" #include "PolygonWithHoles2_EEK.h" #include "PolygonWithHoles2.h" #include #include #include void* PolygonWithHoles2_EEK_Create() { return PolygonWithHoles2::NewPolygonWithHoles2(); } void PolygonWithHoles2_EEK_Release(void* ptr) { PolygonWithHoles2::DeletePolygonWithHoles2(ptr); } int PolygonWithHoles2_EEK_HoleCount(void* ptr) { return PolygonWithHoles2::HoleCount(ptr); } int PolygonWithHoles2_EEK_PointCount(void* ptr, int index) { return PolygonWithHoles2::PointCount(ptr, index); } void* PolygonWithHoles2_EEK_Copy(void* ptr) { return PolygonWithHoles2::Copy(ptr); } void* PolygonWithHoles2_EEK_Convert(void* ptr, CGAL_KERNEL k) { switch (k) { case CGAL_KERNEL::EXACT_PREDICATES_INEXACT_CONSTRUCTION: return PolygonWithHoles2::Convert(ptr); case CGAL_KERNEL::EXACT_PREDICATES_EXACT_CONSTRUCTION: return PolygonWithHoles2::Convert(ptr); default: return PolygonWithHoles2::Convert(ptr); } } void PolygonWithHoles2_EEK_Clear(void* ptr) { PolygonWithHoles2::Clear(ptr); } void PolygonWithHoles2_EEK_ClearBoundary(void* ptr) { PolygonWithHoles2::ClearBoundary(ptr); } void PolygonWithHoles2_EEK_ClearHoles(void* ptr) { PolygonWithHoles2::ClearHoles(ptr); } void* PolygonWithHoles2_EEK_CreateFromPolygon(void* ptr) { return PolygonWithHoles2::CreateFromPolygon(ptr); } void* PolygonWithHoles2_EEK_CreateFromPoints(Point2d* points, int count) { return PolygonWithHoles2::CreateFromPoints(points, count); } Point2d PolygonWithHoles2_EEK_GetPoint(void* ptr, int polyIndex, int pointIndex) { return PolygonWithHoles2::GetPoint(ptr, polyIndex, pointIndex); } void PolygonWithHoles2_EEK_GetPoints(void* ptr, Point2d* points, int polyIndex, int count) { PolygonWithHoles2::GetPoints(ptr, points, polyIndex, count); } void PolygonWithHoles2_EEK_SetPoint(void* ptr, int polyIndex, int pointIndex, const Point2d& point) { PolygonWithHoles2::SetPoint(ptr, polyIndex, pointIndex, point); } void PolygonWithHoles2_EEK_SetPoints(void* ptr, Point2d* points, int polyIndex, int count) { PolygonWithHoles2::SetPoints(ptr, points, polyIndex, count); } void PolygonWithHoles2_EEK_AddHoleFromPolygon(void* pwhPtr, void* polygonPtr) { PolygonWithHoles2::AddHoleFromPolygon(pwhPtr, polygonPtr); } void PolygonWithHoles2_EEK_AddHoleFromPoints(void* ptr, Point2d* points, int count) { PolygonWithHoles2::AddHoleFromPoints(ptr, points, count); } void PolygonWithHoles2_EEK_RemoveHole(void* ptr, int index) { PolygonWithHoles2::RemoveHole(ptr, index); } void* PolygonWithHoles2_EEK_CopyPolygon(void* ptr, int index) { return PolygonWithHoles2::CopyPolygon(ptr, index); } void PolygonWithHoles2_EEK_ReversePolygon(void* ptr, int index) { PolygonWithHoles2::ReversePolygon(ptr, index); } BOOL PolygonWithHoles2_EEK_IsUnbounded(void* ptr) { return PolygonWithHoles2::IsUnbounded(ptr); } Box2d PolygonWithHoles2_EEK_GetBoundingBox(void* ptr, int index) { return PolygonWithHoles2::GetBoundingBox(ptr, index); } BOOL PolygonWithHoles2_EEK_IsSimple(void* ptr, int index) { return PolygonWithHoles2::IsSimple(ptr, index); } BOOL PolygonWithHoles2_EEK_IsConvex(void* ptr, int index) { return PolygonWithHoles2::IsConvex(ptr, index); } CGAL::Orientation PolygonWithHoles2_EEK_Orientation(void* ptr, int index) { return PolygonWithHoles2::Orientation(ptr, index); } CGAL::Oriented_side PolygonWithHoles2_EEK_OrientedSide(void* ptr, int index, const Point2d& point) { return PolygonWithHoles2::OrientedSide(ptr, index, point); } double PolygonWithHoles2_EEK_SignedArea(void* ptr, int index) { return PolygonWithHoles2::SignedArea(ptr, index); } void PolygonWithHoles2_EEK_Translate(void* ptr, int index, const Point2d& translation) { PolygonWithHoles2::Translate(ptr, index, translation); } void PolygonWithHoles2_EEK_Rotate(void* ptr, int index, double rotation) { PolygonWithHoles2::Rotate(ptr, index, rotation); } void PolygonWithHoles2_EEK_Scale(void* ptr, int index, double scale) { PolygonWithHoles2::Scale(ptr, index, scale); } void PolygonWithHoles2_EEK_Transform(void* ptr, int index, const Point2d& translation, double rotation, double scale) { PolygonWithHoles2::Transform(ptr, index, translation, rotation, scale); } BOOL PolygonWithHoles2_EEK_ContainsPoint(void* ptr, const Point2d& point, CGAL::Orientation orientation, BOOL inculdeBoundary) { return PolygonWithHoles2::ContainsPoint(ptr, point, orientation, inculdeBoundary); } void* PolygonWithHoles2_EEK_ConnectHoles(void* ptr) { return PolygonWithHoles2::ConnectHoles(ptr); } ================================================ FILE: CGALWrapper/Polygons/PolygonWithHoles2_EEK.h ================================================ #pragma once #include "../CGALWrapper.h" #include "../Geometry/Geometry2.h" #include #include #include extern "C" { CGALWRAPPER_API void* PolygonWithHoles2_EEK_Create(); CGALWRAPPER_API void PolygonWithHoles2_EEK_Release(void* ptr); CGALWRAPPER_API int PolygonWithHoles2_EEK_HoleCount(void* ptr); CGALWRAPPER_API int PolygonWithHoles2_EEK_PointCount(void* ptr, int index); CGALWRAPPER_API void* PolygonWithHoles2_EEK_Copy(void* ptr); CGALWRAPPER_API void* PolygonWithHoles2_EEK_Convert(void* ptr, CGAL_KERNEL k); CGALWRAPPER_API void PolygonWithHoles2_EEK_Clear(void* ptr); CGALWRAPPER_API void PolygonWithHoles2_EEK_ClearBoundary(void* ptr); CGALWRAPPER_API void PolygonWithHoles2_EEK_ClearHoles(void* ptr); CGALWRAPPER_API void* PolygonWithHoles2_EEK_CreateFromPolygon(void* ptr); CGALWRAPPER_API void* PolygonWithHoles2_EEK_CreateFromPoints(Point2d * points, int count); CGALWRAPPER_API Point2d PolygonWithHoles2_EEK_GetPoint(void* ptr, int polyIndex, int pointIndex); CGALWRAPPER_API void PolygonWithHoles2_EEK_GetPoints(void* ptr, Point2d* points, int polyIndex, int count); CGALWRAPPER_API void PolygonWithHoles2_EEK_SetPoint(void* ptr, int polyIndex, int pointIndex, const Point2d& point); CGALWRAPPER_API void PolygonWithHoles2_EEK_SetPoints(void* ptr, Point2d* points, int polyIndex, int count); CGALWRAPPER_API void PolygonWithHoles2_EEK_AddHoleFromPolygon(void* pwhPtr, void* polygonPtr); CGALWRAPPER_API void PolygonWithHoles2_EEK_AddHoleFromPoints(void* ptr, Point2d* points, int count); CGALWRAPPER_API void PolygonWithHoles2_EEK_RemoveHole(void* ptr, int index); CGALWRAPPER_API void* PolygonWithHoles2_EEK_CopyPolygon(void* ptr, int index); CGALWRAPPER_API void PolygonWithHoles2_EEK_ReversePolygon(void* ptr, int index); CGALWRAPPER_API BOOL PolygonWithHoles2_EEK_IsUnbounded(void* ptr); CGALWRAPPER_API Box2d PolygonWithHoles2_EEK_GetBoundingBox(void* ptr, int index); CGALWRAPPER_API BOOL PolygonWithHoles2_EEK_IsSimple(void* ptr, int index); CGALWRAPPER_API BOOL PolygonWithHoles2_EEK_IsConvex(void* ptr, int index); CGALWRAPPER_API CGAL::Orientation PolygonWithHoles2_EEK_Orientation(void* ptr, int index); CGALWRAPPER_API CGAL::Oriented_side PolygonWithHoles2_EEK_OrientedSide(void* ptr, int index, const Point2d& point); CGALWRAPPER_API double PolygonWithHoles2_EEK_SignedArea(void* ptr, int index); CGALWRAPPER_API void PolygonWithHoles2_EEK_Translate(void* ptr, int index, const Point2d& translation); CGALWRAPPER_API void PolygonWithHoles2_EEK_Rotate(void* ptr, int index, double rotation); CGALWRAPPER_API void PolygonWithHoles2_EEK_Scale(void* ptr, int index, double scale); CGALWRAPPER_API void PolygonWithHoles2_EEK_Transform(void* ptr, int index, const Point2d& translation, double rotation, double scale); CGALWRAPPER_API BOOL PolygonWithHoles2_EEK_ContainsPoint(void* ptr, const Point2d& point, CGAL::Orientation orientation, BOOL inculdeBoundary); CGALWRAPPER_API void* PolygonWithHoles2_EEK_ConnectHoles(void* ptr); } ================================================ FILE: CGALWrapper/Polygons/PolygonWithHoles2_EIK.cpp ================================================ #include "../pch.h" #include "PolygonWithHoles2_EIK.h" #include "PolygonWithHoles2.h" #include #include #include void* PolygonWithHoles2_EIK_Create() { return PolygonWithHoles2::NewPolygonWithHoles2(); } void PolygonWithHoles2_EIK_Release(void* ptr) { PolygonWithHoles2::DeletePolygonWithHoles2(ptr); } int PolygonWithHoles2_EIK_HoleCount(void* ptr) { return PolygonWithHoles2::HoleCount(ptr); } int PolygonWithHoles2_EIK_PointCount(void* ptr, int index) { return PolygonWithHoles2::PointCount(ptr, index); } void* PolygonWithHoles2_EIK_Copy(void* ptr) { return PolygonWithHoles2::Copy(ptr); } void PolygonWithHoles2_EIK_Clear(void* ptr) { PolygonWithHoles2::Clear(ptr); } void PolygonWithHoles2_EIK_ClearBoundary(void* ptr) { PolygonWithHoles2::ClearBoundary(ptr); } void PolygonWithHoles2_EIK_ClearHoles(void* ptr) { PolygonWithHoles2::ClearHoles(ptr); } void* PolygonWithHoles2_EIK_CreateFromPolygon(void* ptr) { return PolygonWithHoles2::CreateFromPolygon(ptr); } void* PolygonWithHoles2_EIK_CreateFromPoints(Point2d* points, int count) { return PolygonWithHoles2::CreateFromPoints(points, count); } Point2d PolygonWithHoles2_EIK_GetPoint(void* ptr, int polyIndex, int pointIndex) { return PolygonWithHoles2::GetPoint(ptr, polyIndex, pointIndex); } void PolygonWithHoles2_EIK_GetPoints(void* ptr, Point2d* points, int polyIndex, int count) { PolygonWithHoles2::GetPoints(ptr, points, polyIndex, count); } void PolygonWithHoles2_EIK_SetPoint(void* ptr, int polyIndex, int pointIndex, const Point2d& point) { PolygonWithHoles2::SetPoint(ptr, polyIndex, pointIndex, point); } void PolygonWithHoles2_EIK_SetPoints(void* ptr, Point2d* points, int polyIndex, int count) { PolygonWithHoles2::SetPoints(ptr, points, polyIndex, count); } void PolygonWithHoles2_EIK_AddHoleFromPolygon(void* pwhPtr, void* polygonPtr) { PolygonWithHoles2::AddHoleFromPolygon(pwhPtr, polygonPtr); } void PolygonWithHoles2_EIK_AddHoleFromPoints(void* ptr, Point2d* points, int count) { PolygonWithHoles2::AddHoleFromPoints(ptr, points, count); } void PolygonWithHoles2_EIK_RemoveHole(void* ptr, int index) { PolygonWithHoles2::RemoveHole(ptr, index); } void* PolygonWithHoles2_EIK_CopyPolygon(void* ptr, int index) { return PolygonWithHoles2::CopyPolygon(ptr, index); } void PolygonWithHoles2_EIK_ReversePolygon(void* ptr, int index) { PolygonWithHoles2::ReversePolygon(ptr, index); } BOOL PolygonWithHoles2_EIK_IsUnbounded(void* ptr) { return PolygonWithHoles2::IsUnbounded(ptr); } Box2d PolygonWithHoles2_EIK_GetBoundingBox(void* ptr, int index) { return PolygonWithHoles2::GetBoundingBox(ptr, index); } BOOL PolygonWithHoles2_EIK_IsSimple(void* ptr, int index) { return PolygonWithHoles2::IsSimple(ptr, index); } BOOL PolygonWithHoles2_EIK_IsConvex(void* ptr, int index) { return PolygonWithHoles2::IsConvex(ptr, index); } CGAL::Orientation PolygonWithHoles2_EIK_Orientation(void* ptr, int index) { return PolygonWithHoles2::Orientation(ptr, index); } CGAL::Oriented_side PolygonWithHoles2_EIK_OrientedSide(void* ptr, int index, const Point2d& point) { return PolygonWithHoles2::OrientedSide(ptr, index, point); } double PolygonWithHoles2_EIK_SignedArea(void* ptr, int index) { return PolygonWithHoles2::SignedArea(ptr, index); } void PolygonWithHoles2_EIK_Translate(void* ptr, int index, const Point2d& translation) { PolygonWithHoles2::Translate(ptr, index, translation); } void PolygonWithHoles2_EIK_Rotate(void* ptr, int index, double rotation) { PolygonWithHoles2::Rotate(ptr, index, rotation); } void PolygonWithHoles2_EIK_Scale(void* ptr, int index, double scale) { PolygonWithHoles2::Scale(ptr, index, scale); } void PolygonWithHoles2_EIK_Transform(void* ptr, int index, const Point2d& translation, double rotation, double scale) { PolygonWithHoles2::Transform(ptr, index, translation, rotation, scale); } BOOL PolygonWithHoles2_EIK_ContainsPoint(void* ptr, const Point2d& point, CGAL::Orientation orientation, BOOL inculdeBoundary) { return PolygonWithHoles2::ContainsPoint(ptr, point, orientation, inculdeBoundary); } void* PolygonWithHoles2_EIK_ConnectHoles(void* ptr) { return PolygonWithHoles2::ConnectHoles(ptr); } ================================================ FILE: CGALWrapper/Polygons/PolygonWithHoles2_EIK.h ================================================ #pragma once #include "../CGALWrapper.h" #include "../Geometry/Geometry2.h" #include #include #include extern "C" { CGALWRAPPER_API void* PolygonWithHoles2_EIK_Create(); CGALWRAPPER_API void PolygonWithHoles2_EIK_Release(void* ptr); CGALWRAPPER_API int PolygonWithHoles2_EIK_HoleCount(void* ptr); CGALWRAPPER_API int PolygonWithHoles2_EIK_PointCount(void* ptr, int index); CGALWRAPPER_API void* PolygonWithHoles2_EIK_Copy(void* ptr); CGALWRAPPER_API void PolygonWithHoles2_EIK_Clear(void* ptr); CGALWRAPPER_API void PolygonWithHoles2_EIK_ClearBoundary(void* ptr); CGALWRAPPER_API void PolygonWithHoles2_EIK_ClearHoles(void* ptr); CGALWRAPPER_API void* PolygonWithHoles2_EIK_CreateFromPolygon(void* ptr); CGALWRAPPER_API void* PolygonWithHoles2_EIK_CreateFromPoints(Point2d* points, int count); CGALWRAPPER_API Point2d PolygonWithHoles2_EIK_GetPoint(void* ptr, int polyIndex, int pointIndex); CGALWRAPPER_API void PolygonWithHoles2_EIK_GetPoints(void* ptr, Point2d* points, int polyIndex, int count); CGALWRAPPER_API void PolygonWithHoles2_EIK_SetPoint(void* ptr, int polyIndex, int pointIndex, const Point2d& point); CGALWRAPPER_API void PolygonWithHoles2_EIK_SetPoints(void* ptr, Point2d* points, int polyIndex, int count); CGALWRAPPER_API void PolygonWithHoles2_EIK_AddHoleFromPolygon(void* pwhPtr, void* polygonPtr); CGALWRAPPER_API void PolygonWithHoles2_EIK_AddHoleFromPoints(void* ptr, Point2d* points, int count); CGALWRAPPER_API void PolygonWithHoles2_EIK_RemoveHole(void* ptr, int index); CGALWRAPPER_API void* PolygonWithHoles2_EIK_CopyPolygon(void* ptr, int index); CGALWRAPPER_API void PolygonWithHoles2_EIK_ReversePolygon(void* ptr, int index); CGALWRAPPER_API BOOL PolygonWithHoles2_EIK_IsUnbounded(void* ptr); CGALWRAPPER_API Box2d PolygonWithHoles2_EIK_GetBoundingBox(void* ptr, int index); CGALWRAPPER_API BOOL PolygonWithHoles2_EIK_IsSimple(void* ptr, int index); CGALWRAPPER_API BOOL PolygonWithHoles2_EIK_IsConvex(void* ptr, int index); CGALWRAPPER_API CGAL::Orientation PolygonWithHoles2_EIK_Orientation(void* ptr, int index); CGALWRAPPER_API CGAL::Oriented_side PolygonWithHoles2_EIK_OrientedSide(void* ptr, int index, const Point2d& point); CGALWRAPPER_API double PolygonWithHoles2_EIK_SignedArea(void* ptr, int index); CGALWRAPPER_API void PolygonWithHoles2_EIK_Translate(void* ptr, int index, const Point2d& translation); CGALWRAPPER_API void PolygonWithHoles2_EIK_Rotate(void* ptr, int index, double rotation); CGALWRAPPER_API void PolygonWithHoles2_EIK_Scale(void* ptr, int index, double scale); CGALWRAPPER_API void PolygonWithHoles2_EIK_Transform(void* ptr, int index, const Point2d& translation, double rotation, double scale); CGALWRAPPER_API BOOL PolygonWithHoles2_EIK_ContainsPoint(void* ptr, const Point2d& point, CGAL::Orientation orientation, BOOL inculdeBoundary); CGALWRAPPER_API void* PolygonWithHoles2_EIK_ConnectHoles(void* ptr); } ================================================ FILE: CGALWrapper/Polyhedra/MeshBuilders.h ================================================ #pragma once #include "../CGALWrapper.h" #include "../Geometry/Geometry2.h" #include "../Geometry/Geometry3.h" #include #include template class BuildTriangleMesh : public CGAL::Modifier_base { public: Point3d* vertices; int verticesCount; int* triangles; int triangleCount; void operator()(HDS& hds) { typedef typename HDS::Vertex Vertex; typedef typename Vertex::Point Point; CGAL::Polyhedron_incremental_builder_3 B(hds); //Only a estimate of actual count int numTriangles = triangleCount / 3; int numEdges = numTriangles * 6; B.begin_surface(verticesCount, numTriangles, numEdges, B.ABSOLUTE_INDEXING); for (int i = 0; i < verticesCount; i++) { auto p = vertices[i].ToCGAL(); B.add_vertex(p); } for (int i = 0; i < numTriangles; i++) { B.begin_facet(); B.add_vertex_to_facet(triangles[i * 3 + 0]); B.add_vertex_to_facet(triangles[i * 3 + 1]); B.add_vertex_to_facet(triangles[i * 3 + 2]); B.end_facet(); } B.end_surface(); } }; template class BuildQuadMesh : public CGAL::Modifier_base { public: Point3d* vertices; int verticesCount; int* quads; int quadCount; void operator()(HDS& hds) { typedef typename HDS::Vertex Vertex; typedef typename Vertex::Point Point; CGAL::Polyhedron_incremental_builder_3 B(hds); //Only a estimate of actual count int numQuads = quadCount / 4; int numEdges = numQuads * 8; B.begin_surface(verticesCount, numQuads, numEdges, B.ABSOLUTE_INDEXING); for (int i = 0; i < verticesCount; i++) { auto p = vertices[i].ToCGAL(); B.add_vertex(p); } for (int i = 0; i < numQuads; i++) { B.begin_facet(); B.add_vertex_to_facet(quads[i * 4 + 0]); B.add_vertex_to_facet(quads[i * 4 + 1]); B.add_vertex_to_facet(quads[i * 4 + 2]); B.add_vertex_to_facet(quads[i * 4 + 3]); B.end_facet(); } B.end_surface(); } }; template class BuildTriangleQuadMesh : public CGAL::Modifier_base { public: Point3d* vertices; int verticesCount; int* triangles; int triangleCount; int* quads; int quadCount; void operator()(HDS& hds) { typedef typename HDS::Vertex Vertex; typedef typename Vertex::Point Point; CGAL::Polyhedron_incremental_builder_3 B(hds); //Only a estimate of actual count int numTriangles = triangleCount / 3; int numQuads = quadCount / 4; int numFaces = numTriangles + numQuads; int numEdges = numTriangles * 6 + numQuads * 8; B.begin_surface(verticesCount, numFaces, numEdges, B.ABSOLUTE_INDEXING); for (int i = 0; i < verticesCount; i++) { auto p = vertices[i].ToCGAL(); B.add_vertex(p); } for (int i = 0; i < numTriangles; i++) { B.begin_facet(); B.add_vertex_to_facet(triangles[i * 3 + 0]); B.add_vertex_to_facet(triangles[i * 3 + 1]); B.add_vertex_to_facet(triangles[i * 3 + 2]); B.end_facet(); } for (int i = 0; i < numQuads; i++) { B.begin_facet(); B.add_vertex_to_facet(quads[i * 4 + 0]); B.add_vertex_to_facet(quads[i * 4 + 1]); B.add_vertex_to_facet(quads[i * 4 + 2]); B.add_vertex_to_facet(quads[i * 4 + 3]); B.end_facet(); } B.end_surface(); } }; template class BuildPolygonalMesh : public CGAL::Modifier_base { public: Point3d* vertices; int verticesCount; int* triangles; int triangleCount; int* quads; int quadCount; int* pentagons; int pentagonCount; int* hexagons; int hexagonCount; void operator()(HDS& hds) { typedef typename HDS::Vertex Vertex; typedef typename Vertex::Point Point; CGAL::Polyhedron_incremental_builder_3 B(hds); //Only a estimate of actual count int numTriangles = triangleCount / 3; int numQuads = quadCount / 4; int numPentagons = pentagonCount / 5; int numHexagons = hexagonCount / 6; int numFaces = numTriangles + numQuads + numPentagons + numHexagons; int numEdges = numTriangles * 6 + numQuads * 8 + numPentagons * 10 + numHexagons * 12; B.begin_surface(verticesCount, numFaces, numEdges, B.ABSOLUTE_INDEXING); for (int i = 0; i < verticesCount; i++) { auto p = vertices[i].ToCGAL(); B.add_vertex(p); } for (int i = 0; i < numTriangles; i++) { B.begin_facet(); B.add_vertex_to_facet(triangles[i * 3 + 0]); B.add_vertex_to_facet(triangles[i * 3 + 1]); B.add_vertex_to_facet(triangles[i * 3 + 2]); B.end_facet(); } for (int i = 0; i < numQuads; i++) { B.begin_facet(); B.add_vertex_to_facet(quads[i * 4 + 0]); B.add_vertex_to_facet(quads[i * 4 + 1]); B.add_vertex_to_facet(quads[i * 4 + 2]); B.add_vertex_to_facet(quads[i * 4 + 3]); B.end_facet(); } for (int i = 0; i < numPentagons; i++) { B.begin_facet(); B.add_vertex_to_facet(pentagons[i * 5 + 0]); B.add_vertex_to_facet(pentagons[i * 5 + 1]); B.add_vertex_to_facet(pentagons[i * 5 + 2]); B.add_vertex_to_facet(pentagons[i * 5 + 3]); B.add_vertex_to_facet(pentagons[i * 5 + 4]); B.end_facet(); } for (int i = 0; i < numHexagons; i++) { B.begin_facet(); B.add_vertex_to_facet(hexagons[i * 6 + 0]); B.add_vertex_to_facet(hexagons[i * 6 + 1]); B.add_vertex_to_facet(hexagons[i * 6 + 2]); B.add_vertex_to_facet(hexagons[i * 6 + 3]); B.add_vertex_to_facet(hexagons[i * 6 + 4]); B.add_vertex_to_facet(hexagons[i * 6 + 5]); B.end_facet(); } B.end_surface(); } }; template class BuildPolygonMesh : public CGAL::Modifier_base { public: Point2d* vertices; int verticesCount; BOOL xz; void operator()(HDS& hds) { typedef typename HDS::Vertex Vertex; typedef typename Vertex::Point Point; CGAL::Polyhedron_incremental_builder_3 B(hds); //Only a estimate of actual count int numFaces = 1; int numEdges = numFaces * 2; B.begin_surface(verticesCount, numFaces, numEdges, B.ABSOLUTE_INDEXING); for (int i = 0; i < verticesCount; i++) { if (xz) B.add_vertex(vertices[i].ToCGAL3XZ()); else B.add_vertex(vertices[i].ToCGAL3()); } B.begin_facet(); for (int i = 0; i < verticesCount; i++) B.add_vertex_to_facet(i); B.end_facet(); B.end_surface(); } }; ================================================ FILE: CGALWrapper/Polyhedra/MeshFace3.h ================================================ #pragma once #include "../CGALWrapper.h" #include "../Geometry/Geometry3.h" struct MeshFace3 { int Index; int Halfedge; static MeshFace3 NullFace() { MeshFace3 f; f.Index = NULL_INDEX; f.Halfedge = NULL_INDEX; return f; } }; ================================================ FILE: CGALWrapper/Polyhedra/MeshHalfedge3.h ================================================ #pragma once #include "../CGALWrapper.h" #include "../Geometry/Geometry3.h" struct MeshHalfedge3 { BOOL IsBorder; int Index; int Source; int Target; int Opposite; int Next; int Previous; int Face; static MeshHalfedge3 NullHalfedge() { MeshHalfedge3 e; e.Index = NULL_INDEX; e.Source = NULL_INDEX; e.Target = NULL_INDEX; e.Opposite = NULL_INDEX; e.Next = NULL_INDEX; e.Previous = NULL_INDEX; e.Face = NULL_INDEX; return e; } }; ================================================ FILE: CGALWrapper/Polyhedra/MeshHitResult.h ================================================ #pragma once #include "../CGALWrapper.h" #include "../Geometry/Geometry3.h" struct MeshHitResult { int face; Point3d point; Point3d coord; //BOOL on_face_border; //BOOL on_edge; //BOOL on_mesh_border; //BOOL on_vertex; }; ================================================ FILE: CGALWrapper/Polyhedra/MeshVertex3.h ================================================ #pragma once #include "../CGALWrapper.h" #include "../Geometry/Geometry3.h" struct MeshVertex3 { Point3d Point; int Degree; int Index; int Halfedge; static MeshVertex3 NullVertex() { MeshVertex3 v; v.Point = { 0, 0, 0 }; v.Degree = 0; v.Index = NULL_INDEX; v.Halfedge = NULL_INDEX; return v; } }; ================================================ FILE: CGALWrapper/Polyhedra/NefPolyhedron3.h ================================================ #pragma once #include "../CGALWrapper.h" #include "../Geometry/Geometry2.h" #include "../Geometry/Geometry3.h" #include "Polyhedron3.h" #include "SurfaceMesh3.h" #include #include #include #include #include template class NefPolyhedron3 { public: typedef typename K::Point_3 Point_3; typedef typename K::Plane_3 Plane_3; typedef CGAL::Nef_polyhedron_3 NefPolyhedron; inline static NefPolyhedron* NewNefPolyhedron() { return new NefPolyhedron(NefPolyhedron::EMPTY); } inline static NefPolyhedron* CreateFromSpace(int space) { if(space == NefPolyhedron::EMPTY) return new NefPolyhedron(NefPolyhedron::EMPTY); else return new NefPolyhedron(NefPolyhedron::COMPLETE); } inline static NefPolyhedron* CreateFromPlane(Plane3d plane, int boundary) { auto p = plane.ToCGAL(); if (boundary == NefPolyhedron::EXCLUDED) return new NefPolyhedron(p, NefPolyhedron::EXCLUDED); else return new NefPolyhedron(p, NefPolyhedron::INCLUDED); } inline static NefPolyhedron* CreateFromPolyhedron(void* ptr) { auto p = Polyhedron3::CastToPolyhedron(ptr); return new NefPolyhedron(p->model); } inline static void DeleteNefPolyhedron(void* ptr) { auto obj = static_cast(ptr); if (obj != nullptr) { delete obj; obj = nullptr; } } inline static NefPolyhedron* CastToNefPolyhedron(void* ptr) { return static_cast(ptr); } static void Clear(void* ptr, int space) { auto nef = CastToNefPolyhedron(ptr); if(space == NefPolyhedron::EMPTY) nef->clear(NefPolyhedron::EMPTY); else nef->clear(NefPolyhedron::COMPLETE); } static BOOL IsEmpty(void* ptr) { auto nef = CastToNefPolyhedron(ptr); return nef->is_empty(); } static BOOL IsSimple(void* ptr) { auto nef = CastToNefPolyhedron(ptr); return nef->is_simple(); } static BOOL IsSpace(void* ptr) { auto nef = CastToNefPolyhedron(ptr); return nef->is_space(); } static BOOL IsValid(void* ptr) { auto nef = CastToNefPolyhedron(ptr); return nef->is_valid(); } static int EdgeCount(void* ptr) { auto nef = CastToNefPolyhedron(ptr); return (int)nef->number_of_edges(); } static int FacetCount(void* ptr) { auto nef = CastToNefPolyhedron(ptr); return (int)nef->number_of_facets(); } static int HalfEdgeCount(void* ptr) { auto nef = CastToNefPolyhedron(ptr); return (int)nef->number_of_halfedges(); } static int HalfFacetCount(void* ptr) { auto nef = CastToNefPolyhedron(ptr); return (int)nef->number_of_halffacets(); } static int VertexCount(void* ptr) { auto nef = CastToNefPolyhedron(ptr); return (int)nef->number_of_vertices(); } static int VolumeCount(void* ptr) { auto nef = CastToNefPolyhedron(ptr); return (int)nef->number_of_volumes(); } static void* Intersection(void* ptr1, void* ptr2) { auto nef1 = CastToNefPolyhedron(ptr1); auto nef2 = CastToNefPolyhedron(ptr2); auto result = NewNefPolyhedron(); *result = nef1->intersection(*nef2); return result; } static void* Join(void* ptr1, void* ptr2) { auto nef1 = CastToNefPolyhedron(ptr1); auto nef2 = CastToNefPolyhedron(ptr2); auto result = NewNefPolyhedron(); *result = nef1->join(*nef2); return result; } static void* Difference(void* ptr1, void* ptr2) { auto nef1 = CastToNefPolyhedron(ptr1); auto nef2 = CastToNefPolyhedron(ptr2); auto result = NewNefPolyhedron(); *result = nef1->difference(*nef2); return result; } static void* SymmetricDifference(void* ptr1, void* ptr2) { auto nef1 = CastToNefPolyhedron(ptr1); auto nef2 = CastToNefPolyhedron(ptr2); auto result = NewNefPolyhedron(); *result = nef1->symmetric_difference(*nef2); return result; } static void* Complement(void* ptr) { auto nef = CastToNefPolyhedron(ptr); auto result = NewNefPolyhedron(); *result = nef->complement(); return result; } static void* Interior(void* ptr) { auto nef = CastToNefPolyhedron(ptr); auto result = NewNefPolyhedron(); *result = nef->interior(); return result; } static void* Boundary(void* ptr) { auto nef = CastToNefPolyhedron(ptr); auto result = NewNefPolyhedron(); *result = nef->boundary(); return result; } static void* Closure(void* ptr) { auto nef = CastToNefPolyhedron(ptr); auto result = NewNefPolyhedron(); *result = nef->closure(); return result; } static void* Regularization(void* ptr) { auto nef = CastToNefPolyhedron(ptr); auto result = NewNefPolyhedron(); *result = nef->regularization(); return result; } static void* MinkowskiSum(void* ptr1, void* ptr2) { auto nef1 = CastToNefPolyhedron(ptr1); auto nef2 = CastToNefPolyhedron(ptr2); auto result = NewNefPolyhedron(); *result = CGAL::minkowski_sum_3(*nef1, *nef2); return result; } static void* ConvertToPolyhedron(void* ptr) { auto nef = CastToNefPolyhedron(ptr); auto poly = Polyhedron3::NewPolyhedron(); nef->convert_to_polyhedron(poly->model); return poly; } static void* ConvertToSurfaceMesh(void* ptr) { auto nef = CastToNefPolyhedron(ptr); auto mesh = SurfaceMesh3::NewSurfaceMesh(); CGAL::convert_nef_polyhedron_to_polygon_mesh(*nef, mesh->model); return mesh; } static void ConvexDecomposition(void* ptr) { auto nef = CastToNefPolyhedron(ptr); CGAL::convex_decomposition_3(*nef); } static void GetVolumes(void* ptr, void** volumes, int count) { auto nef = CastToNefPolyhedron(ptr); int index = 0; for (auto ci = nef->volumes_begin(); ci != nef->volumes_end(); ++ci) { auto poly = Polyhedron3::NewPolyhedron(); nef->convert_inner_shell_to_polyhedron(ci->shells_begin(), poly->model); volumes[index++] = poly; if (index >= count) return; } } }; ================================================ FILE: CGALWrapper/Polyhedra/NefPolyhedron3_EEK.cpp ================================================ #include "NefPolyhedron3_EEK.h" #include "NefPolyhedron3.h" #include "Polyhedron3.h" #include void* NefPolyhedron3_EEK_CreateFromSpace(int space) { return NefPolyhedron3::CreateFromSpace(space); } void* NefPolyhedron3_EEK_CreateFromPlane(Plane3d plane, int boundary) { return NefPolyhedron3::CreateFromPlane(plane, boundary); } void* NefPolyhedron3_EEK_CreateFromPolyhedron(void* ptr) { return NefPolyhedron3::CreateFromPolyhedron(ptr); } void NefPolyhedron3_EEK_Release(void* ptr) { NefPolyhedron3::DeleteNefPolyhedron(ptr); } void NefPolyhedron3_EEK_Clear(void* ptr, int space) { NefPolyhedron3::Clear(ptr, space); } BOOL NefPolyhedron3_EEK_IsEmpty(void* ptr) { return NefPolyhedron3::IsEmpty(ptr); } BOOL NefPolyhedron3_EEK_IsSimple(void* ptr) { return NefPolyhedron3::IsSimple(ptr); } BOOL NefPolyhedron3_EEK_IsSpace(void* ptr) { return NefPolyhedron3::IsSpace(ptr); } BOOL NefPolyhedron3_EEK_IsValid(void* ptr) { return NefPolyhedron3::IsValid(ptr); } int NefPolyhedron3_EEK_EdgeCount(void* ptr) { return NefPolyhedron3::EdgeCount(ptr); } int NefPolyhedron3_EEK_FacetCount(void* ptr) { return NefPolyhedron3::FacetCount(ptr); } int NefPolyhedron3_EEK_HalfEdgeCount(void* ptr) { return NefPolyhedron3::HalfEdgeCount(ptr); } int NefPolyhedron3_EEK_HalfFacetCount(void* ptr) { return NefPolyhedron3::HalfFacetCount(ptr); } int NefPolyhedron3_EEK_VertexCount(void* ptr) { return NefPolyhedron3::VertexCount(ptr); } int NefPolyhedron3_EEK_VolumeCount(void* ptr) { return NefPolyhedron3::VolumeCount(ptr); } void* NefPolyhedron3_EEK_Intersection(void* ptr1, void* ptr2) { return NefPolyhedron3::Intersection(ptr1, ptr2); } void* NefPolyhedron3_EEK_Join(void* ptr1, void* ptr2) { return NefPolyhedron3::Join(ptr1, ptr2); } void* NefPolyhedron3_EEK_Difference(void* ptr1, void* ptr2) { return NefPolyhedron3::Difference(ptr1, ptr2); } void* NefPolyhedron3_EEK_SymmetricDifference(void* ptr1, void* ptr2) { return NefPolyhedron3::SymmetricDifference(ptr1, ptr2); } void* NefPolyhedron3_EEK_Complement(void* ptr) { return NefPolyhedron3::Complement(ptr); } void* NefPolyhedron3_EEK_Interior(void* ptr) { return NefPolyhedron3::Interior(ptr); } void* NefPolyhedron3_EEK_Boundary(void* ptr) { return NefPolyhedron3::Boundary(ptr); } void* NefPolyhedron3_EEK_Closure(void* ptr) { return NefPolyhedron3::Closure(ptr); } void* NefPolyhedron3_EEK_Regularization(void* ptr) { return NefPolyhedron3::Regularization(ptr); } void* NefPolyhedron3_EEK_MinkowskiSum(void* ptr1, void* ptr2) { return NefPolyhedron3::MinkowskiSum(ptr1, ptr2); } void* NefPolyhedron3_EEK_ConvertToPolyhedron(void* ptr) { return NefPolyhedron3::ConvertToPolyhedron(ptr); } void* NefPolyhedron3_EEK_ConvertToSurfaceMesh(void* ptr) { return NefPolyhedron3::ConvertToSurfaceMesh(ptr); } void NefPolyhedron3_EEK_ConvexDecomposition(void* ptr) { NefPolyhedron3::ConvexDecomposition(ptr); } void NefPolyhedron3_EEK_GetVolumes(void* ptr, void** volumes, int count) { NefPolyhedron3::GetVolumes(ptr, volumes, count); } ================================================ FILE: CGALWrapper/Polyhedra/NefPolyhedron3_EEK.h ================================================ #pragma once #include "../CGALWrapper.h" #include "../Geometry/Geometry2.h" #include "../Geometry/Geometry3.h" extern "C" { CGALWRAPPER_API void* NefPolyhedron3_EEK_CreateFromSpace(int space); CGALWRAPPER_API void* NefPolyhedron3_EEK_CreateFromPlane(Plane3d plane, int boundary); CGALWRAPPER_API void* NefPolyhedron3_EEK_CreateFromPolyhedron(void* ptr); CGALWRAPPER_API void NefPolyhedron3_EEK_Release(void* ptr); CGALWRAPPER_API void NefPolyhedron3_EEK_Clear(void* ptr, int space); CGALWRAPPER_API BOOL NefPolyhedron3_EEK_IsEmpty(void* ptr); CGALWRAPPER_API BOOL NefPolyhedron3_EEK_IsSimple(void* ptr); CGALWRAPPER_API BOOL NefPolyhedron3_EEK_IsSpace(void* ptr); CGALWRAPPER_API BOOL NefPolyhedron3_EEK_IsValid(void* ptr); CGALWRAPPER_API int NefPolyhedron3_EEK_EdgeCount(void* ptr); CGALWRAPPER_API int NefPolyhedron3_EEK_FacetCount(void* ptr); CGALWRAPPER_API int NefPolyhedron3_EEK_HalfEdgeCount(void* ptr); CGALWRAPPER_API int NefPolyhedron3_EEK_HalfFacetCount(void* ptr); CGALWRAPPER_API int NefPolyhedron3_EEK_VertexCount(void* ptr); CGALWRAPPER_API int NefPolyhedron3_EEK_VolumeCount(void* ptr); CGALWRAPPER_API void* NefPolyhedron3_EEK_Intersection(void* ptr1, void* ptr2); CGALWRAPPER_API void* NefPolyhedron3_EEK_Join(void* ptr1, void* ptr2); CGALWRAPPER_API void* NefPolyhedron3_EEK_Difference(void* ptr1, void* ptr2); CGALWRAPPER_API void* NefPolyhedron3_EEK_SymmetricDifference(void* ptr1, void* ptr2); CGALWRAPPER_API void* NefPolyhedron3_EEK_Complement(void* ptr); CGALWRAPPER_API void* NefPolyhedron3_EEK_Interior(void* ptr); CGALWRAPPER_API void* NefPolyhedron3_EEK_Boundary(void* ptr); CGALWRAPPER_API void* NefPolyhedron3_EEK_Closure(void* ptr); CGALWRAPPER_API void* NefPolyhedron3_EEK_Regularization(void* ptr); CGALWRAPPER_API void* NefPolyhedron3_EEK_MinkowskiSum(void* ptr1, void* ptr2); CGALWRAPPER_API void* NefPolyhedron3_EEK_ConvertToPolyhedron(void* ptr); CGALWRAPPER_API void* NefPolyhedron3_EEK_ConvertToSurfaceMesh(void* ptr); CGALWRAPPER_API void NefPolyhedron3_EEK_ConvexDecomposition(void* ptr); CGALWRAPPER_API void NefPolyhedron3_EEK_GetVolumes(void* ptr, void** volumes, int count); } ================================================ FILE: CGALWrapper/Polyhedra/NefPolyhedron3_EIK.cpp ================================================ #include "NefPolyhedron3_EIK.h" #include "NefPolyhedron3.h" #include "Polyhedron3.h" #include void* NefPolyhedron3_EIK_CreateFromSpace(int space) { return NefPolyhedron3::CreateFromSpace(space); } void* NefPolyhedron3_EIK_CreateFromPlane(Plane3d plane, int boundary) { return NefPolyhedron3::CreateFromPlane(plane, boundary); } void* NefPolyhedron3_EIK_CreateFromPolyhedron(void* ptr) { return NefPolyhedron3::CreateFromPolyhedron(ptr); } void NefPolyhedron3_EIK_Release(void* ptr) { NefPolyhedron3::DeleteNefPolyhedron(ptr); } void NefPolyhedron3_EIK_Clear(void* ptr, int space) { NefPolyhedron3::Clear(ptr, space); } BOOL NefPolyhedron3_EIK_IsEmpty(void* ptr) { return NefPolyhedron3::IsEmpty(ptr); } BOOL NefPolyhedron3_EIK_IsSimple(void* ptr) { return NefPolyhedron3::IsSimple(ptr); } BOOL NefPolyhedron3_EIK_IsSpace(void* ptr) { return NefPolyhedron3::IsSpace(ptr); } BOOL NefPolyhedron3_EIK_IsValid(void* ptr) { return NefPolyhedron3::IsValid(ptr); } int NefPolyhedron3_EIK_EdgeCount(void* ptr) { return NefPolyhedron3::EdgeCount(ptr); } int NefPolyhedron3_EIK_FacetCount(void* ptr) { return NefPolyhedron3::FacetCount(ptr); } int NefPolyhedron3_EIK_HalfEdgeCount(void* ptr) { return NefPolyhedron3::HalfEdgeCount(ptr); } int NefPolyhedron3_EIK_HalfFacetCount(void* ptr) { return NefPolyhedron3::HalfFacetCount(ptr); } int NefPolyhedron3_EIK_VertexCount(void* ptr) { return NefPolyhedron3::VertexCount(ptr); } int NefPolyhedron3_EIK_VolumeCount(void* ptr) { return NefPolyhedron3::VolumeCount(ptr); } void* NefPolyhedron3_EIK_Intersection(void* ptr1, void* ptr2) { return NefPolyhedron3::Intersection(ptr1, ptr2); } void* NefPolyhedron3_EIK_Join(void* ptr1, void* ptr2) { return NefPolyhedron3::Join(ptr1, ptr2); } void* NefPolyhedron3_EIK_Difference(void* ptr1, void* ptr2) { return NefPolyhedron3::Difference(ptr1, ptr2); } void* NefPolyhedron3_EIK_SymmetricDifference(void* ptr1, void* ptr2) { return NefPolyhedron3::SymmetricDifference(ptr1, ptr2); } void* NefPolyhedron3_EIK_Complement(void* ptr) { return NefPolyhedron3::Complement(ptr); } void* NefPolyhedron3_EIK_Interior(void* ptr) { return NefPolyhedron3::Interior(ptr); } void* NefPolyhedron3_EIK_Boundary(void* ptr) { return NefPolyhedron3::Boundary(ptr); } void* NefPolyhedron3_EIK_Closure(void* ptr) { return NefPolyhedron3::Closure(ptr); } void* NefPolyhedron3_EIK_Regularization(void* ptr) { return NefPolyhedron3::Regularization(ptr); } void* NefPolyhedron3_EIK_MinkowskiSum(void* ptr1, void* ptr2) { return NefPolyhedron3::MinkowskiSum(ptr1, ptr2); } void* NefPolyhedron3_EIK_ConvertToPolyhedron(void* ptr) { return NefPolyhedron3::ConvertToPolyhedron(ptr); } void* NefPolyhedron3_EIK_ConvertToSurfaceMesh(void* ptr) { return NefPolyhedron3::ConvertToSurfaceMesh(ptr); } void NefPolyhedron3_EIK_ConvexDecomposition(void* ptr) { NefPolyhedron3::ConvexDecomposition(ptr); } void NefPolyhedron3_EIK_GetVolumes(void* ptr, void** volumes, int count) { NefPolyhedron3::GetVolumes(ptr, volumes, count); } ================================================ FILE: CGALWrapper/Polyhedra/NefPolyhedron3_EIK.h ================================================ #pragma once #include "../CGALWrapper.h" #include "../Geometry/Geometry2.h" #include "../Geometry/Geometry3.h" extern "C" { CGALWRAPPER_API void* NefPolyhedron3_EIK_CreateFromSpace(int space); CGALWRAPPER_API void* NefPolyhedron3_EIK_CreateFromPlane(Plane3d plane, int boundary); CGALWRAPPER_API void* NefPolyhedron3_EIK_CreateFromPolyhedron(void* ptr); CGALWRAPPER_API void NefPolyhedron3_EIK_Release(void* ptr); CGALWRAPPER_API void NefPolyhedron3_EIK_Clear(void* ptr, int space); CGALWRAPPER_API BOOL NefPolyhedron3_EIK_IsEmpty(void* ptr); CGALWRAPPER_API BOOL NefPolyhedron3_EIK_IsSimple(void* ptr); CGALWRAPPER_API BOOL NefPolyhedron3_EIK_IsSpace(void* ptr); CGALWRAPPER_API BOOL NefPolyhedron3_EIK_IsValid(void* ptr); CGALWRAPPER_API int NefPolyhedron3_EIK_EdgeCount(void* ptr); CGALWRAPPER_API int NefPolyhedron3_EIK_FacetCount(void* ptr); CGALWRAPPER_API int NefPolyhedron3_EIK_HalfEdgeCount(void* ptr); CGALWRAPPER_API int NefPolyhedron3_EIK_HalfFacetCount(void* ptr); CGALWRAPPER_API int NefPolyhedron3_EIK_VertexCount(void* ptr); CGALWRAPPER_API int NefPolyhedron3_EIK_VolumeCount(void* ptr); CGALWRAPPER_API void* NefPolyhedron3_EIK_Intersection(void* ptr1, void* ptr2); CGALWRAPPER_API void* NefPolyhedron3_EIK_Join(void* ptr1, void* ptr2); CGALWRAPPER_API void* NefPolyhedron3_EIK_Difference(void* ptr1, void* ptr2); CGALWRAPPER_API void* NefPolyhedron3_EIK_SymmetricDifference(void* ptr1, void* ptr2); CGALWRAPPER_API void* NefPolyhedron3_EIK_Complement(void* ptr); CGALWRAPPER_API void* NefPolyhedron3_EIK_Interior(void* ptr); CGALWRAPPER_API void* NefPolyhedron3_EIK_Boundary(void* ptr); CGALWRAPPER_API void* NefPolyhedron3_EIK_Closure(void* ptr); CGALWRAPPER_API void* NefPolyhedron3_EIK_Regularization(void* ptr); CGALWRAPPER_API void* NefPolyhedron3_EIK_MinkowskiSum(void* ptr1, void* ptr2); CGALWRAPPER_API void* NefPolyhedron3_EIK_ConvertToPolyhedron(void* ptr); CGALWRAPPER_API void* NefPolyhedron3_EIK_ConvertToSurfaceMesh(void* ptr); CGALWRAPPER_API void NefPolyhedron3_EIK_ConvexDecomposition(void* ptr); CGALWRAPPER_API void NefPolyhedron3_EIK_GetVolumes(void* ptr, void** volumes, int count); } ================================================ FILE: CGALWrapper/Polyhedra/PolygonalCount.h ================================================ #pragma once struct PolygonalCount { int degenerate; int three; int four; int five; int six; int greater; }; ================================================ FILE: CGALWrapper/Polyhedra/Polyhedron3.h ================================================ #pragma once #include "../CGALWrapper.h" #include "../Geometry/Geometry2.h" #include "../Geometry/Geometry3.h" #include "../Geometry/Matrices.h" #include "../Geometry/MinMax.h" #include "PolygonalCount.h" #include "MeshBuilders.h" #include "PolyhedronMap.h" #include "MeshVertex3.h" #include "MeshFace3.h" #include "MeshHalfedge3.h" #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include template class Polyhedron3 { public: typedef typename K::FT FT; typedef typename K::Point_3 Point; typedef typename K::Vector_3 Vector; //typedef CGAL::Polyhedron_3 Polyhedron; typedef CGAL::Polyhedron_3 Polyhedron; typedef typename Polyhedron::HalfedgeDS HalfedgeDS; typedef typename HalfedgeDS::Vertex Vertex; typedef typename HalfedgeDS::Face Face; typedef typename HalfedgeDS::Halfedge Halfedge; //typedef typename boost::graph_traits::vertex_descriptor Vertex_Des; //typedef typename boost::graph_traits::face_descriptor Face_Des; //typedef typename boost::graph_traits::edge_descriptor Edge_Des; //typedef typename boost::graph_traits::halfedge_descriptor Halfedge_Des; typedef typename HalfedgeDS::Vertex_iterator Vertex_Iter; typedef typename HalfedgeDS::Face_iterator Face_Iter; typedef typename HalfedgeDS::Halfedge_iterator Halfedge_Iter; typedef typename CGAL::AABB_face_graph_triangle_primitive AABB_face_graph_primitive; typedef typename CGAL::AABB_traits AABB_face_graph_traits; typedef typename CGAL::AABB_tree AABBTree; typedef CGAL::Aff_transformation_3 Transformation_3; public: PolyhedronMap map; std::unordered_map vertexNormalMap; bool rebuildVertexNormalMap = true; std::unordered_map faceNormalMap; bool rebuildFaceNormalMap = true; Polyhedron3() { } ~Polyhedron3() { DeleteTree(); } Polyhedron model; AABBTree* tree = nullptr; inline static Polyhedron3* NewPolyhedron() { return new Polyhedron3(); } inline static void DeletePolyhedron(void* ptr) { auto obj = static_cast(ptr); if (obj != nullptr) { delete obj; obj = nullptr; } } inline static Polyhedron3* CastToPolyhedron(void* ptr) { return static_cast(ptr); } void OnVertexNormalsChanged() { vertexNormalMap.clear(); rebuildVertexNormalMap = true; } void OnFaceNormalsChanged() { faceNormalMap.clear(); rebuildFaceNormalMap = true; } void OnVerticesChanged() { OnVertexNormalsChanged(); map.OnVerticesChanged(); DeleteTree(); } void OnFacesChanged() { OnFaceNormalsChanged(); map.OnFacesChanged(); DeleteTree(); } void OnHalfedgesChanged() { map.OnHalfedgesChanged(); DeleteTree(); } void OnModelChanged() { OnVerticesChanged(); OnFacesChanged(); OnHalfedgesChanged(); } void BuildModel() { map.BuildVertexMaps(); map.BuildFaceMaps(); map.BuildHalfedgeMaps(); } void DeleteTree() { if (tree != nullptr) { delete tree; tree = nullptr; } } void BuildAABBTree() { if (tree == nullptr) { tree = new AABBTree(); CGAL::Polygon_mesh_processing::build_AABB_tree(model, *tree); } } int FindVertexIndex(Vertex_Iter vert) { map.BuildVertexMaps(model); return map.FindVertexIndex(model, vert); } Vertex_Iter* FindVertexIter(int index) { map.BuildVertexMaps(model); return map.FindVertexIter(model, index); } Vertex* FindVertex(int index) { map.BuildVertexMaps(model); return map.FindVertex(model, index); } int FindFaceIndex(Face_Iter face) { map.BuildFaceMaps(model); return map.FindFaceIndex(face); } Face_Iter* FindFaceIter(int index) { map.BuildFaceMaps(model); return map.FindFaceIter(index); } int FindHalfedgeIndex(Halfedge_Iter edge) { map.BuildHalfedgeMaps(model); return map.FindHalfedgeIndex(edge); } Halfedge_Iter* FindHalfedgeIter(int index) { map.BuildHalfedgeMaps(model); return map.FindHalfedgeIter(index); } Halfedge_Iter GetHalfedgeIter(int index) { map.BuildHalfedgeMaps(model); return map.GetHalfedgeIter(index); } Vector FindVertexNormal(Vertex_Iter vert) { auto item = vertexNormalMap.find(vert); if (item != vertexNormalMap.end()) return item->second; else return { 0,0,0 }; } static int GetBuildStamp(void* ptr) { auto poly = CastToPolyhedron(ptr); return poly->map.BuildStamp(); } static void Clear(void* ptr) { auto poly = CastToPolyhedron(ptr); poly->model.clear(); poly->OnModelChanged(); } static void ClearIndexMaps(void* ptr, BOOL vertices, BOOL faces, BOOL edges) { auto poly = CastToPolyhedron(ptr); if (vertices) poly->map.OnVerticesChanged(); if (faces) poly->map.OnFacesChanged(); if (edges) poly->map.OnHalfedgesChanged(); } static void ClearNormalMaps(void* ptr, BOOL vertices, BOOL faces) { auto poly = CastToPolyhedron(ptr); if (vertices) poly->OnVertexNormalsChanged(); if (faces) poly->OnFaceNormalsChanged(); } static void BuildIndices(void* ptr, BOOL vertices, BOOL faces, BOOL edges, BOOL force) { auto poly = CastToPolyhedron(ptr); if (vertices) poly->map.BuildVertexMaps(poly->model, force); if (faces) poly->map.BuildFaceMaps(poly->model, force); if (edges) poly->map.BuildHalfedgeMaps(poly->model, force); } static void* Copy(void* ptr) { auto poly = CastToPolyhedron(ptr); auto copy = NewPolyhedron(); copy->model = poly->model; return copy; } static int VertexCount(void* ptr) { auto poly = CastToPolyhedron(ptr); return (int)poly->model.size_of_vertices(); } static int FaceCount(void* ptr) { auto poly = CastToPolyhedron(ptr); return (int)poly->model.size_of_facets(); } static int HalfEdgeCount(void* ptr) { auto poly = CastToPolyhedron(ptr); return (int)poly->model.size_of_halfedges(); } static int BorderEdgeCount(void* ptr) { auto poly = CastToPolyhedron(ptr); return (int)poly->model.size_of_border_edges(); } static int BorderHalfEdgeCount(void* ptr) { auto poly = CastToPolyhedron(ptr); return (int)poly->model.size_of_border_halfedges(); } static BOOL IsValid(void* ptr, int level) { auto poly = CastToPolyhedron(ptr); return (int)poly->model.is_valid(level); } static BOOL IsClosed(void* ptr) { auto poly = CastToPolyhedron(ptr); return (int)poly->model.is_closed(); } static BOOL IsPureBivalent(void* ptr) { auto poly = CastToPolyhedron(ptr); return (int)poly->model.is_pure_bivalent(); } static BOOL IsPureTrivalent(void* ptr) { auto poly = CastToPolyhedron(ptr); return (int)poly->model.is_pure_trivalent(); } static BOOL IsPureTriangle(void* ptr) { auto poly = CastToPolyhedron(ptr); //return (int)poly->model.is_pure_triangle(); for (auto face = poly->model.facets_begin(); face != poly->model.facets_end(); ++face) { if (face->halfedge() == nullptr) return FALSE; if (!face->is_triangle()) return FALSE; } return TRUE; } static BOOL IsPureQuad(void* ptr) { auto poly = CastToPolyhedron(ptr); //return (int)poly->model.is_pure_quad(); for (auto face = poly->model.facets_begin(); face != poly->model.facets_end(); ++face) { if (face->halfedge() == nullptr) return FALSE; if (!face->is_quad()) return FALSE; } return TRUE; } static Box3d GetBoundingBox(void* ptr) { auto poly = CastToPolyhedron(ptr); if (poly->tree != nullptr) { auto box = poly->tree->root_node()->bbox(); return Box3d::FromCGAL(box); } else { auto box = CGAL::Polygon_mesh_processing::bbox(poly->model); return Box3d::FromCGAL(box); } } static int MakeTetrahedron(void* ptr, Point3d p1, Point3d p2, Point3d p3, Point3d p4) { auto poly = CastToPolyhedron(ptr); auto e = poly->model.make_tetrahedron(p1.ToCGAL(), p2.ToCGAL(), p3.ToCGAL(), p4.ToCGAL()); poly->OnModelChanged(); return poly->FindHalfedgeIndex(e); } static int MakeTriangle(void* ptr, Point3d p1, Point3d p2, Point3d p3) { auto poly = CastToPolyhedron(ptr); auto e = poly->model.make_triangle(p1.ToCGAL(), p2.ToCGAL(), p3.ToCGAL()); poly->OnModelChanged(); return poly->FindHalfedgeIndex(e); } Point3d GetPoint(int index) { auto vertex = FindVertex(index); if (vertex != nullptr) return Point3d::FromCGAL(vertex->point()); else return { 0, 0, 0 }; } static Point3d GetPoint(void* ptr, int index) { auto poly = CastToPolyhedron(ptr); return poly->GetPoint(index); } static void GetPoints(void* ptr, Point3d* points, int count) { auto poly = CastToPolyhedron(ptr); int i = 0; for (int i = 0; i < count; i++) { points[i] = poly->GetPoint(i); } } void SetPoint(int index, const Point3d& point) { auto vertex = FindVertex(index); if (vertex != nullptr) vertex->point() = point.ToCGAL(); } static void SetPoint(void* ptr, int index, const Point3d& point) { auto poly = CastToPolyhedron(ptr); poly->SetPoint(index, point); } static void SetPoints(void* ptr, Point3d* points, int count) { auto poly = CastToPolyhedron(ptr); for (int i = 0; i < count; i++) { poly->SetPoint(i, points[i]); } } static BOOL GetSegment(void* ptr, int index, Segment3d& segment) { auto poly = CastToPolyhedron(ptr); auto edge = poly->FindHalfedgeIter(index); if (edge != nullptr) { auto a = (*edge)->vertex()->point(); auto b = (*edge)->opposite()->vertex()->point(); segment.a = Point3d::FromCGAL(a); segment.b = Point3d::FromCGAL(b); return TRUE; } else { return FALSE; } } static void GetSegments(void* ptr, Segment3d* segments, int count) { auto poly = CastToPolyhedron(ptr); int i = 0; for (auto edge = poly->model.halfedges_begin(); edge != poly->model.halfedges_end(); ++edge) { auto a = edge->vertex()->point(); auto b = edge->opposite()->vertex()->point(); Segment3d seg; seg.a = Point3d::FromCGAL(a); seg.b = Point3d::FromCGAL(b); segments[i++] = seg; if (i >= count) return; } } static BOOL GetTriangle(void* ptr, int index, Triangle3d& tri) { auto poly = CastToPolyhedron(ptr); auto face = poly->FindFaceIter(index); if (face != nullptr) { auto a = (*face)->halfedge()->prev()->vertex()->point(); auto b = (*face)->halfedge()->vertex()->point(); auto c = (*face)->halfedge()->next()->vertex()->point(); tri.a = Point3d::FromCGAL(a); tri.b = Point3d::FromCGAL(b); tri.c = Point3d::FromCGAL(c); return TRUE; } else { return FALSE; } } static void GetTriangles(void* ptr, Triangle3d* triangles, int count) { auto poly = CastToPolyhedron(ptr); int i = 0; for (auto face = poly->model.facets_begin(); face != poly->model.facets_end(); ++face) { if (face->halfedge() == nullptr) continue; auto a = face->halfedge()->prev()->vertex()->point(); auto b = face->halfedge()->vertex()->point(); auto c = face->halfedge()->next()->vertex()->point(); Triangle3d tri; tri.a = Point3d::FromCGAL(a); tri.b = Point3d::FromCGAL(b); tri.c = Point3d::FromCGAL(c); triangles[i++] = tri; if (i >= count) return; } } static BOOL GetVertex(void* ptr, int index, MeshVertex3& vert) { auto poly = CastToPolyhedron(ptr); vert = MeshVertex3::NullVertex(); auto v = poly->FindVertexIter(index); if (v != nullptr) { vert.Index = index; vert.Halfedge = poly->FindHalfedgeIndex((*v)->halfedge()); vert.Point = Point3d::FromCGAL((*v)->point()); vert.Degree = (int)(*v)->degree(); return TRUE; } else { return FALSE; } } static void GetVertices(void* ptr, MeshVertex3* vertices, int count) { auto poly = CastToPolyhedron(ptr); int i = 0; for (auto v = poly->model.vertices_begin(); v != poly->model.vertices_end(); ++v) { MeshVertex3 vert = MeshVertex3::NullVertex(); vert.Index = i; vert.Halfedge = poly->FindHalfedgeIndex(v->halfedge()); vert.Point = Point3d::FromCGAL(v->point()); vert.Degree = (int)v->degree(); vertices[i] = vert; i++; if (i >= count) return; } } static BOOL GetFace(void* ptr, int index, MeshFace3& face) { auto poly = CastToPolyhedron(ptr); face = MeshFace3::NullFace(); auto f = poly->FindFaceIter(index); if (f != nullptr) { face.Index = index; face.Halfedge = poly->FindHalfedgeIndex((*f)->halfedge()); return TRUE; } else { return FALSE; } } static void GetFaces(void* ptr, MeshFace3* faces, int count) { auto poly = CastToPolyhedron(ptr); int i = 0; for (auto f = poly->model.facets_begin(); f != poly->model.facets_end(); ++f) { MeshFace3 face = MeshFace3::NullFace(); face.Index = i; if (f->halfedge() != nullptr) face.Halfedge = poly->FindHalfedgeIndex(f->halfedge()); faces[i] = face; i++; if (i >= count) return; } } static BOOL GetHalfedge(void* ptr, int index, MeshHalfedge3& edge) { auto poly = CastToPolyhedron(ptr); edge = MeshHalfedge3::NullHalfedge(); auto e = poly->FindHalfedgeIter(index); if (e != nullptr) { edge.Index = index; edge.Source = poly->FindVertexIndex((*e)->vertex()); edge.Target = poly->FindVertexIndex((*e)->opposite()->vertex()); edge.Opposite = poly->FindHalfedgeIndex((*e)->opposite()); edge.Next = poly->FindHalfedgeIndex((*e)->next()); edge.Previous = poly->FindHalfedgeIndex((*e)->prev()); edge.Face = poly->FindFaceIndex((*e)->face()); edge.IsBorder = (*e)->is_border(); return TRUE; } else { return FALSE; } } static void GetHalfedges(void* ptr, MeshHalfedge3* edges, int count) { auto poly = CastToPolyhedron(ptr); int i = 0; for (auto e = poly->model.halfedges_begin(); e != poly->model.halfedges_end(); ++e) { MeshHalfedge3 edge = MeshHalfedge3::NullHalfedge(); edge.Index = i; edge.Source = poly->FindVertexIndex(e->vertex()); edge.Target = poly->FindVertexIndex(e->opposite()->vertex()); edge.Opposite = poly->FindHalfedgeIndex(e->opposite()); edge.Next = poly->FindHalfedgeIndex(e->next()); edge.Previous = poly->FindHalfedgeIndex(e->prev()); edge.Face = poly->FindFaceIndex(e->face()); edge.IsBorder = e->is_border(); edges[i] = edge; i++; if (i >= count) return; } } static void Transform(void* ptr, const Matrix4x4d& matrix) { auto poly = CastToPolyhedron(ptr); auto m = matrix.ToCGAL(); std::transform(poly->model.points_begin(), poly->model.points_end(), poly->model.points_begin(), m); poly->OnModelChanged(); } static void InsideOut(void* ptr) { auto poly = CastToPolyhedron(ptr); poly->model.inside_out(); poly->OnModelChanged(); } static void Triangulate(void* ptr) { auto poly = CastToPolyhedron(ptr); CGAL::Polygon_mesh_processing::triangulate_faces(poly->model); poly->OnModelChanged(); } static void NormalizeBorder(void* ptr) { auto poly = CastToPolyhedron(ptr); poly->model.normalize_border(); poly->OnModelChanged(); } static BOOL NormalizedBorderIsValid(void* ptr) { auto poly = CastToPolyhedron(ptr); return poly->model.normalized_border_is_valid(); } static BOOL DoesSelfIntersect(void* ptr) { auto poly = CastToPolyhedron(ptr); return CGAL::Polygon_mesh_processing::does_self_intersect(poly->model); } static double Area(void* ptr) { auto poly = CastToPolyhedron(ptr); return CGAL::to_double(CGAL::Polygon_mesh_processing::area(poly->model)); } static Point3d Centroid(void* ptr) { auto poly = CastToPolyhedron(ptr); auto p = CGAL::Polygon_mesh_processing::centroid(poly->model); return Point3d::FromCGAL(p); } static double Volume(void* ptr) { auto poly = CastToPolyhedron(ptr); return CGAL::to_double(CGAL::Polygon_mesh_processing::volume(poly->model)); } static BOOL DoesBoundAVolume(void* ptr) { auto poly = CastToPolyhedron(ptr); return CGAL::Polygon_mesh_processing::does_bound_a_volume(poly->model); } static void BuildAABBTree(void* ptr) { auto poly = CastToPolyhedron(ptr); poly->BuildAABBTree(); } static void ReleaseAABBTree(void* ptr) { auto poly = CastToPolyhedron(ptr); poly->DeleteTree(); } static CGAL::Bounded_side SideOfTriangleMesh(void* ptr, const Point3d& point) { auto poly = CastToPolyhedron(ptr); poly->BuildAABBTree(); CGAL::Side_of_triangle_mesh inside(*poly->tree); return inside(point.ToCGAL()); } static BOOL DoIntersects(void* ptr, void* otherPtr, BOOL test_bounded_sides) { auto poly = CastToPolyhedron(ptr); auto other = CastToPolyhedron(otherPtr); auto param = CGAL::parameters::do_overlap_test_of_bounded_sides(test_bounded_sides); return CGAL::Polygon_mesh_processing::do_intersect(poly->model, other->model, param, param); } static void ReadOFF(void* ptr, const char* filename) { auto poly = CastToPolyhedron(ptr); std::ifstream i(filename); i >> poly->model; poly->OnModelChanged(); } static void WriteOFF(void* ptr, const char* filename) { auto poly = CastToPolyhedron(ptr); std::ofstream o(filename); o << poly->model; } static void GetCentroids(void* ptr, Point3d* points, int count) { auto poly = CastToPolyhedron(ptr); int numFaces = (int)poly->model.size_of_facets(); int index = 0; for (auto face = poly->model.facets_begin(); face != poly->model.facets_end(); ++face) { if (face->halfedge() == nullptr) continue; auto c = ComputeCentroid(*face); points[index] = Point3d::FromCGAL(c); index++; if (index >= numFaces || index >= count) return; } } static void ComputeVertexNormals(void* ptr) { auto poly = CastToPolyhedron(ptr); if (!poly->rebuildVertexNormalMap) return; poly->rebuildVertexNormalMap = false; ; CGAL::Polygon_mesh_processing::compute_vertex_normals(poly->model, boost::make_assoc_property_map(poly->vertexNormalMap)); } static void ComputeFaceNormals(void* ptr) { auto poly = CastToPolyhedron(ptr); if (!poly->rebuildFaceNormalMap) return; poly->rebuildFaceNormalMap = false; CGAL::Polygon_mesh_processing::compute_face_normals(poly->model, boost::make_assoc_property_map(poly->faceNormalMap)); } static void GetVertexNormals(void* ptr, Vector3d* normals, int count) { auto poly = CastToPolyhedron(ptr); ComputeVertexNormals(ptr); poly->map.BuildVertexMaps(poly->model); for (auto const& pair : poly->vertexNormalMap) { auto vert = pair.first; auto vec = pair.second; int i = poly->FindVertexIndex(vert); if (i >= 0 && i < count) normals[i] = Vector3d::FromCGAL(vec); } } static void GetFaceNormals(void* ptr, Vector3d* normals, int count) { auto poly = CastToPolyhedron(ptr); ComputeFaceNormals(ptr); poly->map.BuildFaceMaps(poly->model); for (auto const& pair : poly->faceNormalMap) { auto face = pair.first; auto vec = pair.second; int i = poly->FindFaceIndex(face); if (i >= 0 && i < count) normals[i] = Vector3d::FromCGAL(vec); } } static Point ComputeCentroid(const Face& face) { int num = 0; FT x = 0; FT y = 0; FT z = 0; auto hedge = face.facet_begin(); do { auto p = hedge->vertex()->point(); x += p.x(); y += p.y(); z += p.z(); num++; } while (++hedge != face.facet_begin()); if (num != 0) { x /= num; y /= num; z /= num; } return { x, y, z }; } static int CountFaceVertices(const Face& face) { int num = 0; auto hedge = face.facet_begin(); do { num++; } while (++hedge != face.facet_begin()); return num; } static void CreatePolygonMesh(void* ptr, Point2d* points, int pointsCount, BOOL xz) { auto poly = CastToPolyhedron(ptr); BuildPolygonMesh builder; builder.vertices = points; builder.verticesCount = pointsCount; builder.xz = xz; poly->model.delegate(builder); poly->OnModelChanged(); } static PolygonalCount GetPolygonalCount(void* ptr) { auto poly = CastToPolyhedron(ptr); int degenerate = 0; int three = 0; int four = 0; int five = 0; int six = 0; int greater = 0; for (auto face = poly->model.facets_begin(); face != poly->model.facets_end(); ++face) { if (face->halfedge() == nullptr) continue; int count = CountFaceVertices(*face); switch (count) { case 0: case 1: case 2: degenerate++; break; case 3: three++; break; case 4: four++; break; case 5: five++; break; case 6: six++; break; default: greater++; break; } } return { degenerate, three, four, five, six, greater }; } static PolygonalCount GetDualPolygonalCount(void* ptr) { auto poly = CastToPolyhedron(ptr); int degenerate = 0; int three = 0; int four = 0; int five = 0; int six = 0; int greater = 0; for (auto vert = poly->model.vertices_begin(); vert != poly->model.vertices_end(); ++vert) { int count = 0; auto start = vert->vertex_begin(), end = start; CGAL_For_all(start, end) { count++; if (count > 6) break; } switch (count) { case 0: case 1: case 2: degenerate++; break; case 3: three++; break; case 4: four++; break; case 5: five++; break; case 6: six++; break; default: greater++; break; } } return { degenerate, three, four, five, six, greater }; } static void CreatePolygonalMesh(void* ptr, Point3d* points, int pointsCount, int* triangles, int triangleCount, int* quads, int quadCount, int* pentagons, int pentagonCount, int* hexagons, int hexagonCount) { auto poly = CastToPolyhedron(ptr); BuildPolygonalMesh builder; builder.vertices = points; builder.verticesCount = pointsCount; builder.triangles = triangles; builder.triangleCount = triangleCount; builder.quads = quads; builder.quadCount = quadCount; builder.pentagons = pentagons; builder.pentagonCount = pentagonCount; builder.hexagons = hexagons; builder.hexagonCount = hexagonCount; poly->model.delegate(builder); poly->OnModelChanged(); } static void GetPolygonalIndices(void* ptr, int* triangles, int triangleCount, int* quads, int quadCount, int* pentagons, int pentagonCount, int* hexagons, int hexagonCount) { auto poly = CastToPolyhedron(ptr); poly->map.BuildVertexMaps(poly->model); int triangleIndex = 0; int quadIndex = 0; int pentagonIndex = 0; int hexagonIndex = 0; for (auto face = poly->model.facets_begin(); face != poly->model.facets_end(); ++face) { if (face->halfedge() == nullptr) continue; int count = CountFaceVertices(*face); if (count == 3 && triangleIndex * 3 < triangleCount) { auto e0 = face->halfedge(); auto e1 = e0->next(); auto e2 = e1->next(); int i0 = poly->FindVertexIndex(e0->vertex()); int i1 = poly->FindVertexIndex(e1->vertex()); int i2 = poly->FindVertexIndex(e2->vertex()); triangles[triangleIndex * 3 + 0] = i0; triangles[triangleIndex * 3 + 1] = i1; triangles[triangleIndex * 3 + 2] = i2; triangleIndex++; } else if (count == 4 && quadIndex * 4 < quadCount) { auto e0 = face->halfedge(); auto e1 = e0->next(); auto e2 = e1->next(); auto e3 = e2->next(); int i0 = poly->FindVertexIndex(e0->vertex()); int i1 = poly->FindVertexIndex(e1->vertex()); int i2 = poly->FindVertexIndex(e2->vertex()); int i3 = poly->FindVertexIndex(e3->vertex()); quads[quadIndex * 4 + 0] = i0; quads[quadIndex * 4 + 1] = i1; quads[quadIndex * 4 + 2] = i2; quads[quadIndex * 4 + 3] = i3; quadIndex++; } else if (count == 5 && pentagonIndex * 5 < pentagonCount) { auto e0 = face->halfedge(); auto e1 = e0->next(); auto e2 = e1->next(); auto e3 = e2->next(); auto e4 = e3->next(); int i0 = poly->FindVertexIndex(e0->vertex()); int i1 = poly->FindVertexIndex(e1->vertex()); int i2 = poly->FindVertexIndex(e2->vertex()); int i3 = poly->FindVertexIndex(e3->vertex()); int i4 = poly->FindVertexIndex(e4->vertex()); pentagons[pentagonIndex * 5 + 0] = i0; pentagons[pentagonIndex * 5 + 1] = i1; pentagons[pentagonIndex * 5 + 2] = i2; pentagons[pentagonIndex * 5 + 3] = i3; pentagons[pentagonIndex * 5 + 4] = i4; pentagonIndex++; } else if (count == 6 && hexagonIndex * 6 < hexagonCount) { auto e0 = face->halfedge(); auto e1 = e0->next(); auto e2 = e1->next(); auto e3 = e2->next(); auto e4 = e3->next(); auto e5 = e4->next(); int i0 = poly->FindVertexIndex(e0->vertex()); int i1 = poly->FindVertexIndex(e1->vertex()); int i2 = poly->FindVertexIndex(e2->vertex()); int i3 = poly->FindVertexIndex(e3->vertex()); int i4 = poly->FindVertexIndex(e4->vertex()); int i5 = poly->FindVertexIndex(e5->vertex()); hexagons[hexagonIndex * 6 + 0] = i0; hexagons[hexagonIndex * 6 + 1] = i1; hexagons[hexagonIndex * 6 + 2] = i2; hexagons[hexagonIndex * 6 + 3] = i3; hexagons[hexagonIndex * 6 + 4] = i4; hexagons[hexagonIndex * 6 + 5] = i5; hexagonIndex++; } } } static void GetDualPolygonalIndices(void* ptr, int* triangles, int triangleCount, int* quads, int quadCount, int* pentagons, int pentagonCount, int* hexagons, int hexagonCount) { auto poly = CastToPolyhedron(ptr); poly->map.BuildFaceMaps(poly->model); int triangleIndex = 0; int quadIndex = 0; int pentagonIndex = 0; int hexagonIndex = 0; int indices[6]; for (auto vert = poly->model.vertices_begin(); vert != poly->model.vertices_end(); ++vert) { int count = 0; auto start = vert->vertex_begin(), end = start; CGAL_For_all(start, end) { auto face = start->face(); indices[count++] = poly->FindFaceIndex(face); if (count >= 6) break; } if (count == 3 && triangleIndex * 3 < triangleCount) { triangles[triangleIndex * 3 + 0] = indices[2]; triangles[triangleIndex * 3 + 1] = indices[1]; triangles[triangleIndex * 3 + 2] = indices[0]; triangleIndex++; } else if (count == 4 && quadIndex * 4 < quadCount) { quads[quadIndex * 4 + 0] = indices[3]; quads[quadIndex * 4 + 1] = indices[2]; quads[quadIndex * 4 + 2] = indices[1]; quads[quadIndex * 4 + 3] = indices[0]; quadIndex++; } else if (count == 5 && pentagonIndex * 5 < pentagonCount) { pentagons[pentagonIndex * 5 + 0] = indices[4]; pentagons[pentagonIndex * 5 + 1] = indices[3]; pentagons[pentagonIndex * 5 + 2] = indices[2]; pentagons[pentagonIndex * 5 + 3] = indices[1]; pentagons[pentagonIndex * 5 + 4] = indices[0]; pentagonIndex++; } else if (count == 6 && hexagonIndex * 6 < hexagonCount) { hexagons[hexagonIndex * 6 + 0] = indices[5]; hexagons[hexagonIndex * 6 + 1] = indices[4]; hexagons[hexagonIndex * 6 + 2] = indices[3]; hexagons[hexagonIndex * 6 + 3] = indices[2]; hexagons[hexagonIndex * 6 + 4] = indices[1]; hexagons[hexagonIndex * 6 + 5] = indices[0]; hexagonIndex++; } } } static int AddFacetToBorder(void* ptr, int h, int g) { auto poly = CastToPolyhedron(ptr); auto eh = poly->FindHalfedgeIter(h); auto eg = poly->FindHalfedgeIter(g); if (eh == nullptr || eg == nullptr) return NULL_INDEX; auto e = poly->model.add_facet_to_border(*eh, *eg); poly->OnModelChanged(); poly->map.BuildHalfedgeMaps(poly->model); return poly->FindHalfedgeIndex(e); } static int AddVertexAndFacetToBorder(void* ptr, int h, int g) { auto poly = CastToPolyhedron(ptr); auto eh = poly->FindHalfedgeIter(h); auto eg = poly->FindHalfedgeIter(g); if (eh == nullptr || eg == nullptr) return NULL_INDEX; auto e = poly->model.add_vertex_and_facet_to_border(*eh, *eg); poly->OnModelChanged(); poly->map.BuildHalfedgeMaps(poly->model); return poly->FindHalfedgeIndex(e); } static int CreateCenterVertex(void* ptr, int h) { auto poly = CastToPolyhedron(ptr); auto eh = poly->FindHalfedgeIter(h); if (eh == nullptr) return NULL_INDEX; auto e = poly->model.create_center_vertex(*eh); poly->OnModelChanged(); poly->map.BuildHalfedgeMaps(poly->model); return poly->FindHalfedgeIndex(e); } static int EraseCenterVertex(void* ptr, int h) { auto poly = CastToPolyhedron(ptr); auto eh = poly->FindHalfedgeIter(h); if (eh == nullptr) return NULL_INDEX; auto e = poly->model.erase_center_vertex(*eh); poly->OnModelChanged(); poly->map.BuildHalfedgeMaps(poly->model); return poly->FindHalfedgeIndex(e); } static BOOL EraseConnectedComponent(void* ptr, int h) { auto poly = CastToPolyhedron(ptr); auto eh = poly->FindHalfedgeIter(h); if (eh == nullptr) return FALSE; poly->model.erase_connected_component(*eh); poly->OnModelChanged(); return TRUE; } static BOOL EraseFacet(void* ptr, int h) { auto poly = CastToPolyhedron(ptr); auto eh = poly->FindHalfedgeIter(h); if (eh == nullptr) return FALSE; poly->model.erase_facet(*eh); poly->OnModelChanged(); return TRUE; } static int FillHole(void* ptr, int h) { auto poly = CastToPolyhedron(ptr); auto eh = poly->FindHalfedgeIter(h); if (eh == nullptr) return NULL_INDEX; auto e = poly->model.fill_hole(*eh); poly->OnModelChanged(); poly->map.BuildHalfedgeMaps(poly->model); return poly->FindHalfedgeIndex(e); } static int FlipEdge(void* ptr, int h) { auto poly = CastToPolyhedron(ptr); auto eh = poly->FindHalfedgeIter(h); if (eh == nullptr) return NULL_INDEX; auto e = poly->model.flip_edge(*eh); poly->OnModelChanged(); poly->map.BuildHalfedgeMaps(poly->model); return poly->FindHalfedgeIndex(e); } static int JoinFacet(void* ptr, int h) { auto poly = CastToPolyhedron(ptr); auto eh = poly->FindHalfedgeIter(h); if (eh == nullptr) return NULL_INDEX; auto e = poly->model.join_facet(*eh); poly->OnModelChanged(); poly->map.BuildHalfedgeMaps(poly->model); return poly->FindHalfedgeIndex(e); } static int JoinLoop(void* ptr, int h, int g) { auto poly = CastToPolyhedron(ptr); auto eh = poly->FindHalfedgeIter(h); auto eg = poly->FindHalfedgeIter(g); if (eh == nullptr || eg == nullptr) return NULL_INDEX; auto e = poly->model.join_loop(*eh, *eg); poly->OnModelChanged(); poly->map.BuildHalfedgeMaps(poly->model); return poly->FindHalfedgeIndex(e); } static int JoinVertex(void* ptr, int h) { auto poly = CastToPolyhedron(ptr); auto eh = poly->FindHalfedgeIter(h); if (eh == nullptr) return NULL_INDEX; auto e = poly->model.join_vertex(*eh); poly->OnModelChanged(); poly->map.BuildHalfedgeMaps(poly->model); return poly->FindHalfedgeIndex(e); } static int MakeHole(void* ptr, int h) { auto poly = CastToPolyhedron(ptr); auto eh = poly->FindHalfedgeIter(h); if (eh == nullptr) return NULL_INDEX; auto e = poly->model.make_hole(*eh); poly->OnModelChanged(); poly->map.BuildHalfedgeMaps(poly->model); return poly->FindHalfedgeIndex(e); } static int SplitEdge(void* ptr, int h) { auto poly = CastToPolyhedron(ptr); auto eh = poly->FindHalfedgeIter(h); if (eh == nullptr) return NULL_INDEX; auto e = poly->model.split_edge(*eh); poly->OnModelChanged(); poly->map.BuildHalfedgeMaps(poly->model); return poly->FindHalfedgeIndex(e); } static int SplitFacet(void* ptr, int h, int g) { auto poly = CastToPolyhedron(ptr); auto eh = poly->FindHalfedgeIter(h); auto eg = poly->FindHalfedgeIter(g); if (eh == nullptr || eg == nullptr) return NULL_INDEX; auto e = poly->model.split_facet(*eh, *eg); poly->OnModelChanged(); poly->map.BuildHalfedgeMaps(poly->model); return poly->FindHalfedgeIndex(e); } static int SplitLoop(void* ptr, int h, int g, int k) { auto poly = CastToPolyhedron(ptr); auto eh = poly->FindHalfedgeIter(h); auto eg = poly->FindHalfedgeIter(g); auto ek = poly->FindHalfedgeIter(k); if (eh == nullptr || eg == nullptr || ek == nullptr) return NULL_INDEX; auto e = poly->model.split_loop(*eh, *eg, *ek); poly->OnModelChanged(); poly->map.BuildHalfedgeMaps(poly->model); return poly->FindHalfedgeIndex(e); } static int SplitVertex(void* ptr, int h, int g) { auto poly = CastToPolyhedron(ptr); auto eh = poly->FindHalfedgeIter(h); auto eg = poly->FindHalfedgeIter(g); if (eh == nullptr || eg == nullptr) return NULL_INDEX; auto e = poly->model.split_vertex(*eh, *eg); poly->OnModelChanged(); poly->map.BuildHalfedgeMaps(poly->model); return poly->FindHalfedgeIndex(e); } }; ================================================ FILE: CGALWrapper/Polyhedra/Polyhedron3_EEK.cpp ================================================ #include "Polyhedron3_EEK.h" #include "Polyhedron3.h" #include #include void* Polyhedron3_EEK_Create() { return Polyhedron3::NewPolyhedron(); } void Polyhedron3_EEK_Release(void* ptr) { Polyhedron3::DeletePolyhedron(ptr); } int Polyhedron3_EEK_GetBuildStamp(void* ptr) { return Polyhedron3::GetBuildStamp(ptr); } void Polyhedron3_EEK_Clear(void* ptr) { Polyhedron3::Clear(ptr); } void Polyhedron3_EEK_ClearIndexMaps(void* ptr, BOOL vertices, BOOL faces, BOOL edges) { Polyhedron3::ClearIndexMaps(ptr, vertices, faces, edges); } void Polyhedron3_EEK_ClearNormalMaps(void* ptr, BOOL vertices, BOOL faces) { Polyhedron3::ClearNormalMaps(ptr, vertices, faces); } void Polyhedron3_EEK_BuildIndices(void* ptr, BOOL vertices, BOOL faces, BOOL edges, BOOL force) { Polyhedron3::BuildIndices(ptr, vertices, faces, edges, force); } void* Polyhedron3_EEK_Copy(void* ptr) { return Polyhedron3::Copy(ptr); } int Polyhedron3_EEK_VertexCount(void* ptr) { return Polyhedron3::VertexCount(ptr); } int Polyhedron3_EEK_FaceCount(void* ptr) { return Polyhedron3::FaceCount(ptr); } int Polyhedron3_EEK_HalfEdgeCount(void* ptr) { return Polyhedron3::HalfEdgeCount(ptr); } int Polyhedron3_EEK_BorderEdgeCount(void* ptr) { return Polyhedron3::BorderEdgeCount(ptr); } int Polyhedron3_EEK_BorderHalfEdgeCount(void* ptr) { return Polyhedron3::BorderHalfEdgeCount(ptr); } BOOL Polyhedron3_EEK_IsValid(void* ptr, int level) { return Polyhedron3::IsValid(ptr, level); } BOOL Polyhedron3_EEK_IsClosed(void* ptr) { return Polyhedron3::IsClosed(ptr); } BOOL Polyhedron3_EEK_IsPureBivalent(void* ptr) { return Polyhedron3::IsPureBivalent(ptr); } BOOL Polyhedron3_EEK_IsPureTrivalent(void* ptr) { return Polyhedron3::IsPureTrivalent(ptr); } BOOL Polyhedron3_EEK_IsPureTriangle(void* ptr) { return Polyhedron3::IsPureTriangle(ptr); } BOOL Polyhedron3_EEK_IsPureQuad(void* ptr) { return Polyhedron3::IsPureQuad(ptr); } Box3d Polyhedron3_EEK_GetBoundingBox(void* ptr) { return Polyhedron3::GetBoundingBox(ptr); } int Polyhedron3_EEK_MakeTetrahedron(void* ptr, Point3d p1, Point3d p2, Point3d p3, Point3d p4) { return Polyhedron3::MakeTetrahedron(ptr, p1, p2, p3, p4); } int Polyhedron3_EEK_MakeTriangle(void* ptr, Point3d p1, Point3d p2, Point3d p3) { return Polyhedron3::MakeTriangle(ptr, p1, p2, p3); } Point3d Polyhedron3_EEK_GetPoint(void* ptr, int index) { return Polyhedron3::GetPoint(ptr, index); } void Polyhedron3_EEK_GetPoints(void* ptr, Point3d* points, int count) { return Polyhedron3::GetPoints(ptr, points, count); } void Polyhedron3_EEK_SetPoint(void* ptr, int index, const Point3d& point) { Polyhedron3::SetPoint(ptr, index, point); } void Polyhedron3_EEK_SetPoints(void* ptr, Point3d* points, int count) { Polyhedron3::SetPoints(ptr, points, count); } BOOL Polyhedron3_EEK_GetSegment(void* ptr, int index, Segment3d& segment) { return Polyhedron3::GetSegment(ptr, index, segment); } BOOL Polyhedron3_EEK_GetTriangle(void* ptr, int index, Triangle3d& tri) { return Polyhedron3::GetTriangle(ptr, index, tri); } BOOL Polyhedron3_EEK_GetVertex(void* ptr, int index, MeshVertex3& vert) { return Polyhedron3::GetVertex(ptr, index, vert); } BOOL Polyhedron3_EEK_GetFace(void* ptr, int index, MeshFace3& face) { return Polyhedron3::GetFace(ptr, index, face); } BOOL Polyhedron3_EEK_GetHalfedge(void* ptr, int index, MeshHalfedge3& edge) { return Polyhedron3::GetHalfedge(ptr, index, edge); } void Polyhedron3_EEK_GetSegments(void* ptr, Segment3d* segments, int count) { Polyhedron3::GetSegments(ptr, segments, count); } void Polyhedron3_EEK_GetTriangles(void* ptr, Triangle3d* triangles, int count) { Polyhedron3::GetTriangles(ptr, triangles, count); } void Polyhedron3_EEK_GetVertices(void* ptr, MeshVertex3* vertices, int count) { Polyhedron3::GetVertices(ptr, vertices, count); } void Polyhedron3_EEK_GetFaces(void* ptr, MeshFace3* faces, int count) { Polyhedron3::GetFaces(ptr, faces, count); } void Polyhedron3_EEK_GetHalfedges(void* ptr, MeshHalfedge3* edges, int count) { Polyhedron3::GetHalfedges(ptr, edges, count); } void Polyhedron3_EEK_Transform(void* ptr, Matrix4x4d matrix) { Polyhedron3::Transform(ptr, matrix); } void Polyhedron3_EEK_InsideOut(void* ptr) { Polyhedron3::InsideOut(ptr); } void Polyhedron3_EEK_Triangulate(void* ptr) { Polyhedron3::Triangulate(ptr); } void Polyhedron3_EEK_NormalizeBorder(void* ptr) { Polyhedron3::NormalizeBorder(ptr); } BOOL Polyhedron3_EEK_NormalizedBorderIsValid(void* ptr) { return Polyhedron3::NormalizedBorderIsValid(ptr); } CGAL::Bounded_side Polyhedron3_EEK_SideOfTriangleMesh(void* ptr, const Point3d& point) { return Polyhedron3::SideOfTriangleMesh(ptr, point); } BOOL Polyhedron3_EEK_DoesSelfIntersect(void* ptr) { return Polyhedron3::DoesSelfIntersect(ptr); } double Polyhedron3_EEK_Area(void* ptr) { return Polyhedron3::Area(ptr); } Point3d Polyhedron3_EEK_Centroid(void* ptr) { return Polyhedron3::Centroid(ptr); } double Polyhedron3_EEK_Volume(void* ptr) { return Polyhedron3::Volume(ptr); } BOOL Polyhedron3_EEK_DoesBoundAVolume(void* ptr) { return Polyhedron3::DoesBoundAVolume(ptr); } void Polyhedron3_EEK_BuildAABBTree(void* ptr) { Polyhedron3::BuildAABBTree(ptr); } void Polyhedron3_EEK_ReleaseAABBTree(void* ptr) { Polyhedron3::ReleaseAABBTree(ptr); } BOOL Polyhedron3_EEK_DoIntersects(void* ptr, void* otherPtr, BOOL test_bounded_sides) { return Polyhedron3::DoIntersects(ptr, otherPtr, test_bounded_sides); } void Polyhedron3_EEK_ReadOFF(void* ptr, const char* filename) { Polyhedron3::ReadOFF(ptr, filename); } void Polyhedron3_EEK_WriteOFF(void* ptr, const char* filename) { Polyhedron3::WriteOFF(ptr, filename); } void Polyhedron3_EEK_GetCentroids(void* ptr, Point3d* points, int count) { Polyhedron3::GetCentroids(ptr, points, count); } void Polyhedron3_EEK_ComputeVertexNormals(void* ptr) { Polyhedron3::ComputeVertexNormals(ptr); } void Polyhedron3_EEK_ComputeFaceNormals(void* ptr) { Polyhedron3::ComputeFaceNormals(ptr); } void Polyhedron3_EEK_GetVertexNormals(void* ptr, Vector3d* normals, int count) { Polyhedron3::GetVertexNormals(ptr, normals, count); } void Polyhedron3_EEK_GetFaceNormals(void* ptr, Vector3d* normals, int count) { Polyhedron3::GetFaceNormals(ptr, normals, count); } void Polyhedron3_EEK_CreatePolygonMesh(void* ptr, Point2d* points, int pointsCount, BOOL xz) { Polyhedron3::CreatePolygonMesh(ptr, points, pointsCount, xz); } PolygonalCount Polyhedron3_EEK_GetPolygonalCount(void* ptr) { return Polyhedron3::GetPolygonalCount(ptr); } PolygonalCount Polyhedron3_EEK_GetDualPolygonalCount(void* ptr) { return Polyhedron3::GetDualPolygonalCount(ptr); } void Polyhedron3_EEK_CreatePolygonalMesh(void* ptr, Point3d* points, int pointsCount, int* triangles, int triangleCount, int* quads, int quadCount, int* pentagons, int pentagonCount, int* hexagons, int hexagonCount) { Polyhedron3::CreatePolygonalMesh(ptr, points, pointsCount, triangles, triangleCount, quads, quadCount, pentagons, pentagonCount, hexagons, hexagonCount); } void Polyhedron3_EEK_GetPolygonalIndices(void* ptr, int* triangles, int triangleCount, int* quads, int quadCount, int* pentagons, int pentagonCount, int* hexagons, int hexagonCount) { Polyhedron3::GetPolygonalIndices(ptr, triangles, triangleCount, quads, quadCount, pentagons, pentagonCount, hexagons, hexagonCount); } void Polyhedron3_EEK_GetDualPolygonalIndices(void* ptr, int* triangles, int triangleCount, int* quads, int quadCount, int* pentagons, int pentagonCount, int* hexagons, int hexagonCount) { Polyhedron3::GetDualPolygonalIndices(ptr, triangles, triangleCount, quads, quadCount, pentagons, pentagonCount, hexagons, hexagonCount); } int Polyhedron3_EEK_AddFacetToBorder(void* ptr, int h, int g) { return Polyhedron3::AddFacetToBorder(ptr, h, g); } int Polyhedron3_EEK_AddVertexAndFacetToBorder(void* ptr, int h, int g) { return Polyhedron3::AddVertexAndFacetToBorder(ptr, h, g); } int Polyhedron3_EEK_CreateCenterVertex(void* ptr, int h) { return Polyhedron3::CreateCenterVertex(ptr, h); } int Polyhedron3_EEK_EraseCenterVertex(void* ptr, int h) { return Polyhedron3::EraseCenterVertex( ptr, h); } BOOL Polyhedron3_EEK_EraseConnectedComponent(void* ptr, int h) { return Polyhedron3::EraseConnectedComponent(ptr, h); } BOOL Polyhedron3_EEK_EraseFacet(void* ptr, int h) { return Polyhedron3::EraseFacet(ptr, h); } int Polyhedron3_EEK_FillHole(void* ptr, int h) { return Polyhedron3::FillHole(ptr, h); } int Polyhedron3_EEK_FlipEdge(void* ptr, int h) { return Polyhedron3::FlipEdge(ptr, h); } int Polyhedron3_EEK_JoinFacet(void* ptr, int h) { return Polyhedron3::JoinFacet(ptr, h); } int Polyhedron3_EEK_JoinLoop(void* ptr, int h, int g) { return Polyhedron3::JoinLoop(ptr, h, g); } int Polyhedron3_EEK_JoinVertex(void* ptr, int h) { return Polyhedron3::JoinVertex(ptr, h); } int Polyhedron3_EEK_MakeHole(void* ptr, int h) { return Polyhedron3::MakeHole(ptr, h); } int Polyhedron3_EEK_SplitEdge(void* ptr, int h) { return Polyhedron3::SplitEdge(ptr, h); } int Polyhedron3_EEK_SplitFacet(void* ptr, int h, int g) { return Polyhedron3::SplitFacet(ptr, h, g); } int Polyhedron3_EEK_SplitLoop(void* ptr, int h, int g, int k) { return Polyhedron3::SplitLoop(ptr, h, g, k); } int Polyhedron3_EEK_SplitVertex(void* ptr, int h, int g) { return Polyhedron3::SplitVertex(ptr, h, g); } /* typedef typename EEK::FT FT; typedef typename EEK::Point_3 Point; typedef typename EEK::Vector_3 Vector; typedef CGAL::Polyhedron_3 Polyhedron; typedef typename Polyhedron::HalfedgeDS HalfedgeDS; typedef typename HalfedgeDS::Vertex Vertex; typedef typename HalfedgeDS::Face Face; typedef typename HalfedgeDS::Halfedge Halfedge; //typedef typename boost::graph_traits::vertex_descriptor Vertex_Des; typedef typename boost::graph_traits::face_descriptor Face_Des; typedef typename boost::graph_traits::edge_descriptor Edge_Des; typedef typename boost::graph_traits::halfedge_descriptor Halfedge_Des; typedef typename HalfedgeDS::Vertex_iterator Vertex_Iter; void Test() { Polyhedron model; } */ ================================================ FILE: CGALWrapper/Polyhedra/Polyhedron3_EEK.h ================================================ #pragma once #include "../CGALWrapper.h" #include "../Geometry/Geometry2.h" #include "../Geometry/Geometry3.h" #include "../Geometry/Matrices.h" #include "../Geometry/MinMax.h" #include "PolygonalCount.h" #include "MeshVertex3.h" #include "MeshFace3.h" #include "MeshHalfedge3.h" #include extern "C" { CGALWRAPPER_API void* Polyhedron3_EEK_Create(); CGALWRAPPER_API void Polyhedron3_EEK_Release(void* ptr); CGALWRAPPER_API void Polyhedron3_EEK_Clear(void* ptr); CGALWRAPPER_API void Polyhedron3_EEK_ClearIndexMaps(void* ptr, BOOL vertices, BOOL faces, BOOL edges); CGALWRAPPER_API void Polyhedron3_EEK_ClearNormalMaps(void* ptr, BOOL vertices, BOOL faces); CGALWRAPPER_API void Polyhedron3_EEK_BuildIndices(void* ptr, BOOL vertices, BOOL faces, BOOL edges, BOOL force); CGALWRAPPER_API int Polyhedron3_EEK_GetBuildStamp(void* ptr); CGALWRAPPER_API void* Polyhedron3_EEK_Copy(void* ptr); CGALWRAPPER_API int Polyhedron3_EEK_VertexCount(void* ptr); CGALWRAPPER_API int Polyhedron3_EEK_FaceCount(void* ptr); CGALWRAPPER_API int Polyhedron3_EEK_HalfEdgeCount(void* ptr); CGALWRAPPER_API int Polyhedron3_EEK_BorderEdgeCount(void* ptr); CGALWRAPPER_API int Polyhedron3_EEK_BorderHalfEdgeCount(void* ptr); CGALWRAPPER_API BOOL Polyhedron3_EEK_IsValid(void* ptr, int level); CGALWRAPPER_API BOOL Polyhedron3_EEK_IsClosed(void* ptr); CGALWRAPPER_API BOOL Polyhedron3_EEK_IsPureBivalent(void* ptr); CGALWRAPPER_API BOOL Polyhedron3_EEK_IsPureTrivalent(void* ptr); CGALWRAPPER_API BOOL Polyhedron3_EEK_IsPureTriangle(void* ptr); CGALWRAPPER_API BOOL Polyhedron3_EEK_IsPureQuad(void* ptr); CGALWRAPPER_API Box3d Polyhedron3_EEK_GetBoundingBox(void* ptr); CGALWRAPPER_API int Polyhedron3_EEK_MakeTetrahedron(void* ptr, Point3d p1, Point3d p2, Point3d p3, Point3d p4); CGALWRAPPER_API int Polyhedron3_EEK_MakeTriangle(void* ptr, Point3d p1, Point3d p2, Point3d p3); CGALWRAPPER_API Point3d Polyhedron3_EEK_GetPoint(void* ptr, int index); CGALWRAPPER_API void Polyhedron3_EEK_GetPoints(void* ptr, Point3d* points, int count); CGALWRAPPER_API void Polyhedron3_EEK_SetPoint(void* ptr, int index, const Point3d& point); CGALWRAPPER_API void Polyhedron3_EEK_SetPoints(void* ptr, Point3d* points, int count); CGALWRAPPER_API BOOL Polyhedron3_EEK_GetSegment(void* ptr, int index, Segment3d& segment); CGALWRAPPER_API BOOL Polyhedron3_EEK_GetTriangle(void* ptr, int index, Triangle3d& tri); CGALWRAPPER_API BOOL Polyhedron3_EEK_GetVertex(void* ptr, int index, MeshVertex3& vert); CGALWRAPPER_API BOOL Polyhedron3_EEK_GetFace(void* ptr, int index, MeshFace3& face); CGALWRAPPER_API BOOL Polyhedron3_EEK_GetHalfedge(void* ptr, int index, MeshHalfedge3& edge); CGALWRAPPER_API void Polyhedron3_EEK_GetSegments(void* ptr, Segment3d* segments, int count); CGALWRAPPER_API BOOL Polyhedron3_EEK_GetTriangle(void* ptr, int index, Triangle3d& tri); CGALWRAPPER_API void Polyhedron3_EEK_GetTriangles(void* ptr, Triangle3d* triangles, int count); CGALWRAPPER_API void Polyhedron3_EEK_GetVertices(void* ptr, MeshVertex3* vertices, int count); CGALWRAPPER_API void Polyhedron3_EEK_GetFaces(void* ptr, MeshFace3* faces, int count); CGALWRAPPER_API void Polyhedron3_EEK_GetHalfedges(void* ptr, MeshHalfedge3* edges, int count); CGALWRAPPER_API void Polyhedron3_EEK_Transform(void* ptr, Matrix4x4d matrix); CGALWRAPPER_API void Polyhedron3_EEK_InsideOut(void* ptr); CGALWRAPPER_API void Polyhedron3_EEK_Triangulate(void* ptr); CGALWRAPPER_API void Polyhedron3_EEK_NormalizeBorder(void* ptr); CGALWRAPPER_API BOOL Polyhedron3_EEK_NormalizedBorderIsValid(void* ptr); CGALWRAPPER_API CGAL::Bounded_side Polyhedron3_EEK_SideOfTriangleMesh(void* ptr, const Point3d& point); CGALWRAPPER_API BOOL Polyhedron3_EEK_DoesSelfIntersect(void* ptr); CGALWRAPPER_API double Polyhedron3_EEK_Area(void* ptr); CGALWRAPPER_API Point3d Polyhedron3_EEK_Centroid(void* ptr); CGALWRAPPER_API double Polyhedron3_EEK_Volume(void* ptr); CGALWRAPPER_API BOOL Polyhedron3_EEK_DoesBoundAVolume(void* ptr); CGALWRAPPER_API void Polyhedron3_EEK_BuildAABBTree(void* ptr); CGALWRAPPER_API void Polyhedron3_EEK_ReleaseAABBTree(void* ptr); CGALWRAPPER_API BOOL Polyhedron3_EEK_DoIntersects(void* ptr, void* otherPtr, BOOL test_bounded_sides); CGALWRAPPER_API void Polyhedron3_EEK_ReadOFF(void* ptr, const char* filename); CGALWRAPPER_API void Polyhedron3_EEK_WriteOFF(void* ptr, const char* filename); CGALWRAPPER_API void Polyhedron3_EEK_GetCentroids(void* ptr, Point3d* points, int count); CGALWRAPPER_API void Polyhedron3_EEK_ComputeVertexNormals(void* ptr); CGALWRAPPER_API void Polyhedron3_EEK_ComputeFaceNormals(void* ptr); CGALWRAPPER_API void Polyhedron3_EEK_GetVertexNormals(void* ptr, Vector3d* normals, int count); CGALWRAPPER_API void Polyhedron3_EEK_GetFaceNormals(void* ptr, Vector3d* normals, int count); CGALWRAPPER_API void Polyhedron3_EEK_CreatePolygonMesh(void* ptr, Point2d* points, int pointsCount, BOOL xz); CGALWRAPPER_API PolygonalCount Polyhedron3_EEK_GetPolygonalCount(void* ptr); CGALWRAPPER_API PolygonalCount Polyhedron3_EEK_GetDualPolygonalCount(void* ptr); CGALWRAPPER_API void Polyhedron3_EEK_CreatePolygonalMesh(void* ptr, Point3d* points, int pointsCount, int* triangles, int triangleCount, int* quads, int quadCount, int* pentagons, int pentagonCount, int* hexagons, int hexagonCount); CGALWRAPPER_API void Polyhedron3_EEK_GetPolygonalIndices(void* ptr, int* triangles, int triangleCount, int* quads, int quadCount, int* pentagons, int pentagonCount, int* hexagons, int hexagonCount); CGALWRAPPER_API void Polyhedron3_EEK_GetDualPolygonalIndices(void* ptr, int* triangles, int triangleCount, int* quads, int quadCount, int* pentagons, int pentagonCount, int* hexagons, int hexagonCount); CGALWRAPPER_API int Polyhedron3_EEK_AddFacetToBorder(void* ptr, int h, int g); CGALWRAPPER_API int Polyhedron3_EEK_AddVertexAndFacetToBorder(void* ptr, int h, int g); CGALWRAPPER_API int Polyhedron3_EEK_CreateCenterVertex(void* ptr, int h); CGALWRAPPER_API int Polyhedron3_EEK_EraseCenterVertex(void* ptr, int h); CGALWRAPPER_API BOOL Polyhedron3_EEK_EraseConnectedComponent(void* ptr, int h); CGALWRAPPER_API BOOL Polyhedron3_EEK_EraseFacet(void* ptr, int h); CGALWRAPPER_API int Polyhedron3_EEK_FillHole(void* ptr, int h); CGALWRAPPER_API int Polyhedron3_EEK_FlipEdge(void* ptr, int h); CGALWRAPPER_API int Polyhedron3_EEK_JoinFacet(void* ptr, int h); CGALWRAPPER_API int Polyhedron3_EEK_JoinLoop(void* ptr, int h, int g); CGALWRAPPER_API int Polyhedron3_EEK_JoinVertex(void* ptr, int h); CGALWRAPPER_API int Polyhedron3_EEK_MakeHole(void* ptr, int h); CGALWRAPPER_API int Polyhedron3_EEK_SplitEdge(void* ptr, int h); CGALWRAPPER_API int Polyhedron3_EEK_SplitFacet(void* ptr, int h, int g); CGALWRAPPER_API int Polyhedron3_EEK_SplitLoop(void* ptr, int h, int g, int k); CGALWRAPPER_API int Polyhedron3_EEK_SplitVertex(void* ptr, int h, int g); } ================================================ FILE: CGALWrapper/Polyhedra/Polyhedron3_EIK.cpp ================================================ #include "Polyhedron3_EIK.h" #include "Polyhedron3.h" void* Polyhedron3_EIK_Create() { return Polyhedron3::NewPolyhedron(); } void Polyhedron3_EIK_Release(void* ptr) { Polyhedron3::DeletePolyhedron(ptr); } int Polyhedron3_EIK_GetBuildStamp(void* ptr) { return Polyhedron3::GetBuildStamp(ptr); } void Polyhedron3_EIK_Clear(void* ptr) { Polyhedron3::Clear(ptr); } void Polyhedron3_EIK_ClearIndexMaps(void* ptr, BOOL vertices, BOOL faces, BOOL edges) { Polyhedron3::ClearIndexMaps(ptr, vertices, faces, edges); } void Polyhedron3_EIK_ClearNormalMaps(void* ptr, BOOL vertices, BOOL faces) { Polyhedron3::ClearNormalMaps(ptr, vertices, faces); } void Polyhedron3_EIK_BuildIndices(void* ptr, BOOL vertices, BOOL faces, BOOL edges, BOOL force) { Polyhedron3::BuildIndices(ptr, vertices, faces, edges, force); } void* Polyhedron3_EIK_Copy(void* ptr) { return Polyhedron3::Copy(ptr); } int Polyhedron3_EIK_VertexCount(void* ptr) { return Polyhedron3::VertexCount(ptr); } int Polyhedron3_EIK_FaceCount(void* ptr) { return Polyhedron3::FaceCount(ptr); } int Polyhedron3_EIK_HalfEdgeCount(void* ptr) { return Polyhedron3::HalfEdgeCount(ptr); } int Polyhedron3_EIK_BorderEdgeCount(void* ptr) { return Polyhedron3::BorderEdgeCount(ptr); } int Polyhedron3_EIK_BorderHalfEdgeCount(void* ptr) { return Polyhedron3::BorderHalfEdgeCount(ptr); } BOOL Polyhedron3_EIK_IsValid(void* ptr, int level) { return Polyhedron3::IsValid(ptr, level); } BOOL Polyhedron3_EIK_IsClosed(void* ptr) { return Polyhedron3::IsClosed(ptr); } BOOL Polyhedron3_EIK_IsPureBivalent(void* ptr) { return Polyhedron3::IsPureBivalent(ptr); } BOOL Polyhedron3_EIK_IsPureTrivalent(void* ptr) { return Polyhedron3::IsPureTrivalent(ptr); } BOOL Polyhedron3_EIK_IsPureTriangle(void* ptr) { return Polyhedron3::IsPureTriangle(ptr); } BOOL Polyhedron3_EIK_IsPureQuad(void* ptr) { return Polyhedron3::IsPureQuad(ptr); } Box3d Polyhedron3_EIK_GetBoundingBox(void* ptr) { return Polyhedron3::GetBoundingBox(ptr); } int Polyhedron3_EIK_MakeTetrahedron(void* ptr, Point3d p1, Point3d p2, Point3d p3, Point3d p4) { return Polyhedron3::MakeTetrahedron(ptr, p1, p2, p3, p4); } int Polyhedron3_EIK_MakeTriangle(void* ptr, Point3d p1, Point3d p2, Point3d p3) { return Polyhedron3::MakeTriangle(ptr, p1, p2, p3); } Point3d Polyhedron3_EIK_GetPoint(void* ptr, int index) { return Polyhedron3::GetPoint(ptr, index); } void Polyhedron3_EIK_GetPoints(void* ptr, Point3d* points, int count) { return Polyhedron3::GetPoints(ptr, points, count); } void Polyhedron3_EIK_SetPoint(void* ptr, int index, const Point3d& point) { Polyhedron3::SetPoint(ptr, index, point); } void Polyhedron3_EIK_SetPoints(void* ptr, Point3d* points, int count) { Polyhedron3::SetPoints(ptr, points, count); } BOOL Polyhedron3_EIK_GetSegment(void* ptr, int index, Segment3d& segment) { return Polyhedron3::GetSegment(ptr, index, segment); } BOOL Polyhedron3_EIK_GetTriangle(void* ptr, int index, Triangle3d& tri) { return Polyhedron3::GetTriangle(ptr, index, tri); } BOOL Polyhedron3_EIK_GetVertex(void* ptr, int index, MeshVertex3& vert) { return Polyhedron3::GetVertex(ptr, index, vert); } BOOL Polyhedron3_EIK_GetFace(void* ptr, int index, MeshFace3& face) { return Polyhedron3::GetFace(ptr, index, face); } BOOL Polyhedron3_EIK_GetHalfedge(void* ptr, int index, MeshHalfedge3& edge) { return Polyhedron3::GetHalfedge(ptr, index, edge); } void Polyhedron3_EIK_GetSegments(void* ptr, Segment3d* segments, int count) { Polyhedron3::GetSegments(ptr, segments, count); } void Polyhedron3_EIK_GetTriangles(void* ptr, Triangle3d* triangles, int count) { Polyhedron3::GetTriangles(ptr, triangles, count); } void Polyhedron3_EIK_GetVertices(void* ptr, MeshVertex3* vertices, int count) { Polyhedron3::GetVertices(ptr, vertices, count); } void Polyhedron3_EIK_GetFaces(void* ptr, MeshFace3* faces, int count) { Polyhedron3::GetFaces(ptr, faces, count); } void Polyhedron3_EIK_GetHalfedges(void* ptr, MeshHalfedge3* edges, int count) { Polyhedron3::GetHalfedges(ptr, edges, count); } void Polyhedron3_EIK_Transform(void* ptr, Matrix4x4d matrix) { Polyhedron3::Transform(ptr, matrix); } void Polyhedron3_EIK_InsideOut(void* ptr) { Polyhedron3::InsideOut(ptr); } void Polyhedron3_EIK_Triangulate(void* ptr) { Polyhedron3::Triangulate(ptr); } void Polyhedron3_EIK_NormalizeBorder(void* ptr) { Polyhedron3::NormalizeBorder(ptr); } BOOL Polyhedron3_EIK_NormalizedBorderIsValid(void* ptr) { return Polyhedron3::NormalizedBorderIsValid(ptr); } CGAL::Bounded_side Polyhedron3_EIK_SideOfTriangleMesh(void* ptr, const Point3d& point) { return Polyhedron3::SideOfTriangleMesh(ptr, point); } BOOL Polyhedron3_EIK_DoesSelfIntersect(void* ptr) { return Polyhedron3::DoesSelfIntersect(ptr); } double Polyhedron3_EIK_Area(void* ptr) { return Polyhedron3::Area(ptr); } Point3d Polyhedron3_EIK_Centroid(void* ptr) { return Polyhedron3::Centroid(ptr); } double Polyhedron3_EIK_Volume(void* ptr) { return Polyhedron3::Volume(ptr); } BOOL Polyhedron3_EIK_DoesBoundAVolume(void* ptr) { return Polyhedron3::DoesBoundAVolume(ptr); } void Polyhedron3_EIK_BuildAABBTree(void* ptr) { Polyhedron3::BuildAABBTree(ptr); } void Polyhedron3_EIK_ReleaseAABBTree(void* ptr) { Polyhedron3::ReleaseAABBTree(ptr); } BOOL Polyhedron3_EIK_DoIntersects(void* ptr, void* otherPtr, BOOL test_bounded_sides) { return Polyhedron3::DoIntersects(ptr, otherPtr, test_bounded_sides); } void Polyhedron3_EIK_ReadOFF(void* ptr, const char* filename) { Polyhedron3::ReadOFF(ptr, filename); } void Polyhedron3_EIK_WriteOFF(void* ptr, const char* filename) { Polyhedron3::WriteOFF(ptr, filename); } void Polyhedron3_EIK_GetCentroids(void* ptr, Point3d* points, int count) { Polyhedron3::GetCentroids(ptr, points, count); } void Polyhedron3_EIK_ComputeVertexNormals(void* ptr) { Polyhedron3::ComputeVertexNormals(ptr); } void Polyhedron3_EIK_ComputeFaceNormals(void* ptr) { Polyhedron3::ComputeFaceNormals(ptr); } void Polyhedron3_EIK_GetVertexNormals(void* ptr, Vector3d* normals, int count) { Polyhedron3::GetVertexNormals(ptr, normals, count); } void Polyhedron3_EIK_GetFaceNormals(void* ptr, Vector3d* normals, int count) { Polyhedron3::GetFaceNormals(ptr, normals, count); } void Polyhedron3_EIK_CreatePolygonMesh(void* ptr, Point2d* points, int pointsCount, BOOL xz) { Polyhedron3::CreatePolygonMesh(ptr, points, pointsCount, xz); } PolygonalCount Polyhedron3_EIK_GetPolygonalCount(void* ptr) { return Polyhedron3::GetPolygonalCount(ptr); } PolygonalCount Polyhedron3_EIK_GetDualPolygonalCount(void* ptr) { return Polyhedron3::GetDualPolygonalCount(ptr); } void Polyhedron3_EIK_CreatePolygonalMesh(void* ptr, Point3d* points, int pointsCount, int* triangles, int triangleCount, int* quads, int quadCount, int* pentagons, int pentagonCount, int* hexagons, int hexagonCount) { Polyhedron3::CreatePolygonalMesh(ptr, points, pointsCount, triangles, triangleCount, quads, quadCount, pentagons, pentagonCount, hexagons, hexagonCount); } void Polyhedron3_EIK_GetPolygonalIndices(void* ptr, int* triangles, int triangleCount, int* quads, int quadCount, int* pentagons, int pentagonCount, int* hexagons, int hexagonCount) { Polyhedron3::GetPolygonalIndices(ptr, triangles, triangleCount, quads, quadCount, pentagons, pentagonCount, hexagons, hexagonCount); } void Polyhedron3_EIK_GetDualPolygonalIndices(void* ptr, int* triangles, int triangleCount, int* quads, int quadCount, int* pentagons, int pentagonCount, int* hexagons, int hexagonCount) { Polyhedron3::GetDualPolygonalIndices(ptr, triangles, triangleCount, quads, quadCount, pentagons, pentagonCount, hexagons, hexagonCount); } int Polyhedron3_EIK_AddFacetToBorder(void* ptr, int h, int g) { return Polyhedron3::AddFacetToBorder(ptr, h, g); } int Polyhedron3_EIK_AddVertexAndFacetToBorder(void* ptr, int h, int g) { return Polyhedron3::AddVertexAndFacetToBorder(ptr, h, g); } int Polyhedron3_EIK_CreateCenterVertex(void* ptr, int h) { return Polyhedron3::CreateCenterVertex(ptr, h); } int Polyhedron3_EIK_EraseCenterVertex(void* ptr, int h) { return Polyhedron3::EraseCenterVertex(ptr, h); } BOOL Polyhedron3_EIK_EraseConnectedComponent(void* ptr, int h) { return Polyhedron3::EraseConnectedComponent(ptr, h); } BOOL Polyhedron3_EIK_EraseFacet(void* ptr, int h) { return Polyhedron3::EraseFacet(ptr, h); } int Polyhedron3_EIK_FillHole(void* ptr, int h) { return Polyhedron3::FillHole(ptr, h); } int Polyhedron3_EIK_FlipEdge(void* ptr, int h) { return Polyhedron3::FlipEdge(ptr, h); } int Polyhedron3_EIK_JoinFacet(void* ptr, int h) { return Polyhedron3::JoinFacet(ptr, h); } int Polyhedron3_EIK_JoinLoop(void* ptr, int h, int g) { return Polyhedron3::JoinLoop(ptr, h, g); } int Polyhedron3_EIK_JoinVertex(void* ptr, int h) { return Polyhedron3::JoinVertex(ptr, h); } int Polyhedron3_EIK_MakeHole(void* ptr, int h) { return Polyhedron3::MakeHole(ptr, h); } int Polyhedron3_EIK_SplitEdge(void* ptr, int h) { return Polyhedron3::SplitEdge(ptr, h); } int Polyhedron3_EIK_SplitFacet(void* ptr, int h, int g) { return Polyhedron3::SplitFacet(ptr, h, g); } int Polyhedron3_EIK_SplitLoop(void* ptr, int h, int g, int k) { return Polyhedron3::SplitLoop(ptr, h, g, k); } int Polyhedron3_EIK_SplitVertex(void* ptr, int h, int g) { return Polyhedron3::SplitVertex(ptr, h, g); } ================================================ FILE: CGALWrapper/Polyhedra/Polyhedron3_EIK.h ================================================ #pragma once #include "../CGALWrapper.h" #include "../Geometry/Geometry2.h" #include "../Geometry/Geometry3.h" #include "../Geometry/Matrices.h" #include "../Geometry/MinMax.h" #include "PolygonalCount.h" #include "MeshVertex3.h" #include "MeshFace3.h" #include "MeshHalfedge3.h" #include extern "C" { CGALWRAPPER_API void* Polyhedron3_EIK_Create(); CGALWRAPPER_API void Polyhedron3_EIK_Release(void* ptr); CGALWRAPPER_API void Polyhedron3_EIK_Clear(void* ptr); CGALWRAPPER_API void Polyhedron3_EIK_ClearIndexMaps(void* ptr, BOOL vertices, BOOL faces, BOOL edges); CGALWRAPPER_API void Polyhedron3_EIK_ClearNormalMaps(void* ptr, BOOL vertices, BOOL faces); CGALWRAPPER_API void Polyhedron3_EIK_BuildIndices(void* ptr, BOOL vertices, BOOL faces, BOOL edges, BOOL force); CGALWRAPPER_API int Polyhedron3_EIK_GetBuildStamp(void* ptr); CGALWRAPPER_API void* Polyhedron3_EIK_Copy(void* ptr); CGALWRAPPER_API int Polyhedron3_EIK_VertexCount(void* ptr); CGALWRAPPER_API int Polyhedron3_EIK_FaceCount(void* ptr); CGALWRAPPER_API int Polyhedron3_EIK_HalfEdgeCount(void* ptr); CGALWRAPPER_API int Polyhedron3_EIK_BorderEdgeCount(void* ptr); CGALWRAPPER_API int Polyhedron3_EIK_BorderHalfEdgeCount(void* ptr); CGALWRAPPER_API BOOL Polyhedron3_EIK_IsValid(void* ptr, int level); CGALWRAPPER_API BOOL Polyhedron3_EIK_IsClosed(void* ptr); CGALWRAPPER_API BOOL Polyhedron3_EIK_IsPureBivalent(void* ptr); CGALWRAPPER_API BOOL Polyhedron3_EIK_IsPureTrivalent(void* ptr); CGALWRAPPER_API BOOL Polyhedron3_EIK_IsPureTriangle(void* ptr); CGALWRAPPER_API BOOL Polyhedron3_EIK_IsPureQuad(void* ptr); CGALWRAPPER_API Box3d Polyhedron3_EIK_GetBoundingBox(void* ptr); CGALWRAPPER_API int Polyhedron3_EIK_MakeTetrahedron(void* ptr, Point3d p1, Point3d p2, Point3d p3, Point3d p4); CGALWRAPPER_API int Polyhedron3_EIK_MakeTriangle(void* ptr, Point3d p1, Point3d p2, Point3d p3); CGALWRAPPER_API Point3d Polyhedron3_EIK_GetPoint(void* ptr, int index); CGALWRAPPER_API void Polyhedron3_EIK_GetPoints(void* ptr, Point3d* points, int count); CGALWRAPPER_API void Polyhedron3_EIK_SetPoint(void* ptr, int index, const Point3d& point); CGALWRAPPER_API void Polyhedron3_EIK_SetPoints(void* ptr, Point3d* points, int count); CGALWRAPPER_API BOOL Polyhedron3_EIK_GetSegment(void* ptr, int index, Segment3d& segment); CGALWRAPPER_API BOOL Polyhedron3_EIK_GetTriangle(void* ptr, int index, Triangle3d& tri); CGALWRAPPER_API BOOL Polyhedron3_EIK_GetVertex(void* ptr, int index, MeshVertex3& vert); CGALWRAPPER_API BOOL Polyhedron3_EIK_GetFace(void* ptr, int index, MeshFace3& face); CGALWRAPPER_API BOOL Polyhedron3_EIK_GetHalfedge(void* ptr, int index, MeshHalfedge3& edge); CGALWRAPPER_API void Polyhedron3_EIK_GetSegments(void* ptr, Segment3d* segments, int count); CGALWRAPPER_API BOOL Polyhedron3_EIK_GetTriangle(void* ptr, int index, Triangle3d& tri); CGALWRAPPER_API void Polyhedron3_EIK_GetTriangles(void* ptr, Triangle3d* triangles, int count); CGALWRAPPER_API void Polyhedron3_EIK_GetVertices(void* ptr, MeshVertex3* vertices, int count); CGALWRAPPER_API void Polyhedron3_EIK_GetFaces(void* ptr, MeshFace3* faces, int count); CGALWRAPPER_API void Polyhedron3_EIK_GetHalfedges(void* ptr, MeshHalfedge3* edges, int count); CGALWRAPPER_API void Polyhedron3_EIK_Transform(void* ptr, Matrix4x4d matrix); CGALWRAPPER_API void Polyhedron3_EIK_InsideOut(void* ptr); CGALWRAPPER_API void Polyhedron3_EIK_Triangulate(void* ptr); CGALWRAPPER_API void Polyhedron3_EIK_NormalizeBorder(void* ptr); CGALWRAPPER_API BOOL Polyhedron3_EIK_NormalizedBorderIsValid(void* ptr); CGALWRAPPER_API CGAL::Bounded_side Polyhedron3_EIK_SideOfTriangleMesh(void* ptr, const Point3d& point); CGALWRAPPER_API BOOL Polyhedron3_EIK_DoesSelfIntersect(void* ptr); CGALWRAPPER_API double Polyhedron3_EIK_Area(void* ptr); CGALWRAPPER_API Point3d Polyhedron3_EIK_Centroid(void* ptr); CGALWRAPPER_API double Polyhedron3_EIK_Volume(void* ptr); CGALWRAPPER_API BOOL Polyhedron3_EIK_DoesBoundAVolume(void* ptr); CGALWRAPPER_API void Polyhedron3_EIK_BuildAABBTree(void* ptr); CGALWRAPPER_API void Polyhedron3_EIK_ReleaseAABBTree(void* ptr); CGALWRAPPER_API BOOL Polyhedron3_EIK_DoIntersects(void* ptr, void* otherPtr, BOOL test_bounded_sides); CGALWRAPPER_API void Polyhedron3_EIK_ReadOFF(void* ptr, const char* filename); CGALWRAPPER_API void Polyhedron3_EIK_WriteOFF(void* ptr, const char* filename); CGALWRAPPER_API void Polyhedron3_EIK_GetCentroids(void* ptr, Point3d* points, int count); CGALWRAPPER_API void Polyhedron3_EIK_ComputeVertexNormals(void* ptr); CGALWRAPPER_API void Polyhedron3_EIK_ComputeFaceNormals(void* ptr); CGALWRAPPER_API void Polyhedron3_EIK_GetVertexNormals(void* ptr, Vector3d* normals, int count); CGALWRAPPER_API void Polyhedron3_EIK_GetFaceNormals(void* ptr, Vector3d* normals, int count); CGALWRAPPER_API void Polyhedron3_EIK_CreatePolygonMesh(void* ptr, Point2d* points, int pointsCount, BOOL xz); CGALWRAPPER_API PolygonalCount Polyhedron3_EIK_GetPolygonalCount(void* ptr); CGALWRAPPER_API PolygonalCount Polyhedron3_EIK_GetDualPolygonalCount(void* ptr); CGALWRAPPER_API void Polyhedron3_EIK_CreatePolygonalMesh(void* ptr, Point3d* points, int pointsCount, int* triangles, int triangleCount, int* quads, int quadCount, int* pentagons, int pentagonCount, int* hexagons, int hexagonCount); CGALWRAPPER_API void Polyhedron3_EIK_GetPolygonalIndices(void* ptr, int* triangles, int triangleCount, int* quads, int quadCount, int* pentagons, int pentagonCount, int* hexagons, int hexagonCount); CGALWRAPPER_API void Polyhedron3_EIK_GetDualPolygonalIndices(void* ptr, int* triangles, int triangleCount, int* quads, int quadCount, int* pentagons, int pentagonCount, int* hexagons, int hexagonCount); CGALWRAPPER_API int Polyhedron3_EIK_AddFacetToBorder(void* ptr, int h, int g); CGALWRAPPER_API int Polyhedron3_EIK_AddVertexAndFacetToBorder(void* ptr, int h, int g); CGALWRAPPER_API int Polyhedron3_EIK_CreateCenterVertex(void* ptr, int h); CGALWRAPPER_API int Polyhedron3_EIK_EraseCenterVertex(void* ptr, int h); CGALWRAPPER_API BOOL Polyhedron3_EIK_EraseConnectedComponent(void* ptr, int h); CGALWRAPPER_API BOOL Polyhedron3_EIK_EraseFacet(void* ptr, int h); CGALWRAPPER_API int Polyhedron3_EIK_FillHole(void* ptr, int h); CGALWRAPPER_API int Polyhedron3_EIK_FlipEdge(void* ptr, int h); CGALWRAPPER_API int Polyhedron3_EIK_JoinFacet(void* ptr, int h); CGALWRAPPER_API int Polyhedron3_EIK_JoinLoop(void* ptr, int h, int g); CGALWRAPPER_API int Polyhedron3_EIK_JoinVertex(void* ptr, int h); CGALWRAPPER_API int Polyhedron3_EIK_MakeHole(void* ptr, int h); CGALWRAPPER_API int Polyhedron3_EIK_SplitEdge(void* ptr, int h); CGALWRAPPER_API int Polyhedron3_EIK_SplitFacet(void* ptr, int h, int g); CGALWRAPPER_API int Polyhedron3_EIK_SplitLoop(void* ptr, int h, int g, int k); CGALWRAPPER_API int Polyhedron3_EIK_SplitVertex(void* ptr, int h, int g); } ================================================ FILE: CGALWrapper/Polyhedra/PolyhedronMap.h ================================================ #pragma once #include "../CGALWrapper.h" #include "Polyhedron3.h" #include #include #include #include template class PolyhedronMap { private: typedef typename K::Point_3 Point; typedef CGAL::Polyhedron_3 Polyhedron; //typedef CGAL::Polyhedron_3 Polyhedron; //typedef typename boost::graph_traits::vertex_descriptor Vertex_Des; //typedef typename boost::graph_traits::face_descriptor Face_Des; //typedef typename boost::graph_traits::edge_descriptor Edge_Des; //typedef typename boost::graph_traits::halfedge_descriptor Halfedge_Des; typedef typename Polyhedron::HalfedgeDS HalfedgeDS; typedef typename HalfedgeDS::Vertex Vertex; typedef typename HalfedgeDS::Face Face; typedef typename HalfedgeDS::Halfedge Halfedge; typedef typename HalfedgeDS::Vertex_iterator Vertex_Iter; typedef typename HalfedgeDS::Face_iterator Face_Iter; typedef typename HalfedgeDS::Halfedge_iterator Halfedge_Iter; int buildStamp = 1; std::unordered_map vertexIndexMap; //std::vector vertexMap; std::vector vertexIterMap; bool rebuildVertexIndexMap = true; std::unordered_map faceIndexMap; std::vector faceIterMap; bool rebuildFaceIndexMap = true; std::unordered_map halfedgeIndexMap; std::vector halfedgeIterMap; bool rebuildHalfedgeIndexMap = true; public: int BuildStamp() { return buildStamp; } void OnVerticesChanged() { vertexIterMap.clear(); vertexIterMap.reserve(0); //vertexIndexMap.clear(); rebuildVertexIndexMap = true; } void OnFacesChanged() { faceIterMap.clear(); faceIterMap.reserve(0); //faceIndexMap.clear(); rebuildFaceIndexMap = true; } void OnHalfedgesChanged() { halfedgeIterMap.clear(); halfedgeIterMap.reserve(0); //halfedgeIndexMap.clear(); rebuildHalfedgeIndexMap = true; } void Clear() { OnVerticesChanged(); OnFacesChanged(); OnHalfedgesChanged(); } void BuildVertexMaps(Polyhedron& model, bool force = false) { if (!force && !rebuildVertexIndexMap) return; rebuildVertexIndexMap = false; auto count = model.size_of_vertices(); //vertexMap.reserve(count); vertexIterMap.reserve(count); vertexIndexMap.clear(); int index = 0; for (auto vert = model.vertices_begin(); vert != model.vertices_end(); ++vert) { //vert->id() = index; //vertexMap.push_back(*vert); vertexIterMap.push_back(vert); vertexIndexMap.insert(std::pair(vert, index)); index++; } } void BuildFaceMaps(Polyhedron& model, bool force = false) { if (!force && !rebuildFaceIndexMap) return; rebuildFaceIndexMap = false; auto count = model.size_of_facets(); faceIterMap.reserve(count); faceIndexMap.clear(); int index = 0; for (Face_Iter face = model.facets_begin(); face != model.facets_end(); ++face) { //face->id() = index; faceIterMap.push_back(face); faceIndexMap.insert(std::pair(face, index)); index++; } } void BuildHalfedgeMaps(Polyhedron& model, bool force = false) { if (!force && !rebuildHalfedgeIndexMap) return; rebuildHalfedgeIndexMap = false; auto count = model.size_of_halfedges(); halfedgeIterMap.reserve(count); halfedgeIndexMap.clear(); int index = 0; for (Halfedge_Iter hedge = model.halfedges_begin(); hedge != model.halfedges_end(); ++hedge) { //hedge->id() = index; halfedgeIterMap.push_back(hedge); halfedgeIndexMap.insert(std::pair(hedge, index)); index++; } } int FindVertexIndex(Polyhedron& model, Vertex_Iter v) { //return v->id(); /* int i = 0; for (Vertex_Iter vert = model.vertices_begin(); vert != model.vertices_end(); ++vert) { if (v == vert) return i; i++; } */ auto item = vertexIndexMap.find(v); if (item != vertexIndexMap.end()) return item->second; else return NULL_INDEX; } Vertex_Iter* FindVertexIter(Polyhedron& model, int index) { /* int i = 0; for (Vertex_Iter vert = model.vertices_begin(); vert != model.vertices_end(); ++vert) { if (i == index) return | i++; } return nullptr; */ int count = (int)vertexIterMap.size(); if (index < 0 || index >= count) return nullptr; return &vertexIterMap[index]; } Vertex* FindVertex(Polyhedron& model, int index) { int count = (int)model.size_of_vertices(); int i = 0; for (Vertex_Iter vert = model.vertices_begin(); vert != model.vertices_end(); ++vert) { if (i == index) return &(*vert); i++; } return nullptr; /* int count = (int)vertexMap.size(); if (index < 0 || index >= count) return nullptr; return &vertexMap[index]; */ } int FindFaceIndex(Face_Iter face) { //return face->id(); auto item = faceIndexMap.find(face); if (item != faceIndexMap.end()) return item->second; else return NULL_INDEX; } Face_Iter* FindFaceIter(int index) { int count = (int)faceIterMap.size(); if (index < 0 || index >= count) return nullptr; return &faceIterMap[index]; } int FindHalfedgeIndex(Halfedge_Iter edge) { //return edge->id(); auto item = halfedgeIndexMap.find(edge); if (item != halfedgeIndexMap.end()) return item->second; else return NULL_INDEX; } Halfedge_Iter* FindHalfedgeIter(int index) { int count = (int)halfedgeIterMap.size(); if (index < 0 || index >= count) return nullptr; return &halfedgeIterMap[index]; } Halfedge_Iter GetHalfedgeIter(int index) { return halfedgeIterMap[index]; } }; ================================================ FILE: CGALWrapper/Polyhedra/SurfaceMesh3.h ================================================ #pragma once #include "../CGALWrapper.h" #include "../Geometry/Geometry2.h" #include "../Geometry/Geometry3.h" #include "../Geometry/Matrices.h" #include "../Geometry/MinMax.h" #include "../Utility/ArrayUtil.h" #include "PolygonalCount.h" #include "SurfaceMeshMap.h" #include "MeshVertex3.h" #include "MeshFace3.h" #include "MeshHalfedge3.h" #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include template class SurfaceMesh3 { public: static constexpr const char* VERTEX_NORMAL_MAP_NAME = "v:normal"; static constexpr const char* FACE_NORMAL_MAP_NAME = "f:normal"; typedef typename K::FT FT; typedef typename K::Point_3 Point_3; typedef typename K::Vector_3 Vector_3; typedef typename CGAL::Surface_mesh SurfaceMesh; typedef typename SurfaceMesh::Edge_index Edge; typedef typename SurfaceMesh::Halfedge_index Halfedge; typedef typename SurfaceMesh::Vertex_index Vertex; typedef typename SurfaceMesh::Face_index Face; typedef typename CGAL::AABB_face_graph_triangle_primitive AABB_face_graph_primitive; typedef typename CGAL::AABB_traits AABB_face_graph_traits; typedef typename CGAL::AABB_tree AABBTree; typedef typename boost::graph_traits::vertex_descriptor VertexDes; typedef typename boost::graph_traits::face_descriptor FaceDes; ~SurfaceMesh3() { DeleteTree(); } SurfaceMesh model; AABBTree* tree = nullptr; SurfaceMeshMap map; private: bool vertexNormalsComputed = false; bool faceNormalsComputed = false; public: inline static SurfaceMesh3* NewSurfaceMesh() { return new SurfaceMesh3(); } inline static void DeleteSurfaceMesh(void* ptr) { auto obj = static_cast(ptr); if (obj != nullptr) { delete obj; obj = nullptr; } } inline static SurfaceMesh3* CastToSurfaceMesh(void* ptr) { return static_cast(ptr); } inline static Point3d NullPoint() { return { 0, 0, 0 }; } inline static Vertex NullVertex() { return SurfaceMesh::null_vertex(); } inline static Face NullFace() { return SurfaceMesh::null_face(); } inline static Edge NullEdge() { return SurfaceMesh::null_edge(); } inline static Halfedge NullHalfedge() { return SurfaceMesh::null_halfedge(); } void OnVertexNormalsChanged() { ClearVertexNormalMap(); vertexNormalsComputed = false; } void OnFaceNormalsChanged() { ClearFaceNormalMap(); faceNormalsComputed = false; } void OnVerticesChanged() { OnVertexNormalsChanged(); map.OnVerticesChanged(); DeleteTree(); } void OnFacesChanged() { OnFaceNormalsChanged(); map.OnFacesChanged(); DeleteTree(); } void OnEdgesChanged() { map.OnEdgesChanged(); DeleteTree(); } void OnHalfedgesChanged() { map.OnHalfedgesChanged(); DeleteTree(); } void OnModelChanged() { OnVerticesChanged(); OnFacesChanged(); OnEdgesChanged(); OnHalfedgesChanged(); DeleteTree(); } void BuildModel() { map.BuildVertexMaps(model); map.BuildFaceMaps(model); map.BuildEdgeMaps(model); map.BuildHalfedgeMaps(model); } void DeleteTree() { if (tree != nullptr) { delete tree; tree = nullptr; } } void BuildAABBTree() { if (tree == nullptr) { tree = new AABBTree(); CGAL::Polygon_mesh_processing::build_AABB_tree(model, *tree); } } void ClearVertexNormalMap() { auto pair = model.property_map(VERTEX_NORMAL_MAP_NAME); model.remove_property_map(pair.first); vertexNormalsComputed = false; } void ClearFaceNormalMap() { auto pair = model.property_map(FACE_NORMAL_MAP_NAME); model.remove_property_map(pair.first); faceNormalsComputed = false; } auto AddScalarPropertyMap(const char* name) { return model.add_property_map(name, 0).first; } void ClearScalarPropertyMap(const char* name) { auto pair = model.property_map(name); model.remove_property_map(pair.first); } int FindVertexIndex(Vertex vertex) { map.BuildVertexMaps(model); return map.FindVertexIndex(vertex); } Vertex FindVertex(int index) { map.BuildVertexMaps(model); return map.FindVertex(index); } int FindFaceIndex(Face face) { map.BuildFaceMaps(model); return map.FindFaceIndex(face); } Face FindFace(int index) { map.BuildFaceMaps(model); return map.FindFace(index); } int FindEdgeIndex(Edge edge) { map.BuildEdgeMaps(model); return map.FindEdgeIndex(edge); } Edge FindEdge(int index) { map.BuildEdgeMaps(model); return map.FindEdge(index); } int FindHalfedgeIndex(Halfedge edge) { map.BuildHalfedgeMaps(model); return map.FindHalfedgeIndex(edge); } Halfedge FindHalfedge(int index) { map.BuildHalfedgeMaps(model); return map.FindHalfedge(index); } static int GetBuildStamp(void* ptr) { auto mesh = CastToSurfaceMesh(ptr); return mesh->map.BuildStamp(); } void Clear() { model.clear(); model.collect_garbage(); OnModelChanged(); } static void Clear(void* ptr) { auto mesh = CastToSurfaceMesh(ptr); mesh->Clear(); } static void ClearIndexMaps(void* ptr, BOOL vertices, BOOL faces, BOOL edges, BOOL halfedges) { auto mesh = CastToSurfaceMesh(ptr); if (vertices) mesh->map.OnVerticesChanged(); if (faces) mesh->map.OnFacesChanged(); if (edges) mesh->map.OnEdgesChanged(); if (halfedges) mesh->map.OnEdgesChanged(); } static void ClearNormalMaps(void* ptr, BOOL vertices, BOOL faces) { auto mesh = CastToSurfaceMesh(ptr); if (vertices) mesh->OnVertexNormalsChanged(); if (faces) mesh->OnFaceNormalsChanged(); } static void ClearProperyMaps(void* ptr) { auto mesh = CastToSurfaceMesh(ptr); mesh->ClearVertexNormalMap(); mesh->ClearFaceNormalMap(); mesh->model.remove_all_property_maps(); } static void BuildIndices(void* ptr, BOOL vertices, BOOL faces, BOOL edges, BOOL halfedges, BOOL force) { auto mesh = CastToSurfaceMesh(ptr); if (vertices) mesh->map.BuildVertexMaps(mesh->model, force); if (faces) mesh->map.BuildFaceMaps(mesh->model, force); if (edges) mesh->map.BuildEdgeMaps(mesh->model, force); if (halfedges) mesh->map.BuildHalfedgeMaps(mesh->model, force); } static void PrintIndices(void* ptr, BOOL vertices, BOOL faces, BOOL edges, BOOL halfedges, BOOL force) { auto mesh = CastToSurfaceMesh(ptr); BuildIndices(ptr, vertices, faces, edges, halfedges, force); if (vertices) mesh->map.PrintVertices(mesh->model); if (faces) mesh->map.PrintFaces(mesh->model); if (edges) mesh->map.PrintEdges(mesh->model); if (halfedges) mesh->map.PrintHalfedges(mesh->model); } static void* Copy(void* ptr) { auto mesh = CastToSurfaceMesh(ptr); auto copy = new SurfaceMesh3(); copy->model = mesh->model; return copy; } static BOOL IsValid(void* ptr) { auto mesh = CastToSurfaceMesh(ptr); return mesh->model.is_valid(false); } static BOOL IsVertexValid(void* ptr, int index) { auto mesh = CastToSurfaceMesh(ptr); auto vertex = mesh->FindVertex(index); if (vertex == NullVertex()) return FALSE; return mesh->model.is_valid(vertex); } static BOOL IsFaceValid(void* ptr, int index) { auto mesh = CastToSurfaceMesh(ptr); auto face = mesh->FindFace(index); if (face == NullFace()) return FALSE; return mesh->model.is_valid(face); } static BOOL IsHalfedgeValid(void* ptr, int index) { auto mesh = CastToSurfaceMesh(ptr); auto hedge = mesh->FindHalfedge(index); if (hedge == NullHalfedge()) return FALSE; return mesh->model.is_valid(hedge); } static BOOL IsEdgeValid(void* ptr, int index) { auto mesh = CastToSurfaceMesh(ptr); auto edge = mesh->FindEdge(index); if (edge == NullEdge()) return FALSE; return mesh->model.is_valid(edge); } static int VertexCount(void* ptr) { auto mesh = CastToSurfaceMesh(ptr); return (int)mesh->model.number_of_vertices(); } static int HalfedgeCount(void* ptr) { auto mesh = CastToSurfaceMesh(ptr); return (int)mesh->model.number_of_halfedges(); } static int EdgeCount(void* ptr) { auto mesh = CastToSurfaceMesh(ptr); return (int)mesh->model.number_of_edges(); } static int FaceCount(void* ptr) { auto mesh = CastToSurfaceMesh(ptr); return (int)mesh->model.number_of_faces(); } static int RemovedVertexCount(void* ptr) { auto mesh = CastToSurfaceMesh(ptr); return (int)mesh->model.number_of_removed_vertices(); } static int RemovedHalfedgeCount(void* ptr) { auto mesh = CastToSurfaceMesh(ptr); return (int)mesh->model.number_of_removed_halfedges(); } static int RemovedEdgeCount(void* ptr) { auto mesh = CastToSurfaceMesh(ptr); return (int)mesh->model.number_of_removed_edges(); } static int RemovedFaceCount(void* ptr) { auto mesh = CastToSurfaceMesh(ptr); return (int)mesh->model.number_of_removed_faces(); } static BOOL IsVertexRemoved(void* ptr, int index) { auto mesh = CastToSurfaceMesh(ptr); auto vertex = mesh->map.FindVertex(index); if (vertex == NullVertex()) return FALSE; return mesh->model.is_removed(vertex); } static BOOL IsFaceRemoved(void* ptr, int index) { auto mesh = CastToSurfaceMesh(ptr); auto face = mesh->FindFace(index); if (face == NullFace()) return FALSE; return mesh->model.is_removed(face); } static BOOL IsHalfedgeRemoved(void* ptr, int index) { auto mesh = CastToSurfaceMesh(ptr); auto hedge = mesh->FindHalfedge(index); if (hedge == NullHalfedge()) return FALSE; return mesh->model.is_removed(hedge); } static BOOL IsEdgeRemoved(void* ptr, int index) { auto mesh = CastToSurfaceMesh(ptr); auto edge = mesh->FindEdge(index); if (edge == NullEdge()) return FALSE; return mesh->model.is_removed(edge); } static int AddVertex(void* ptr, Point3d point) { auto mesh = CastToSurfaceMesh(ptr); mesh->OnModelChanged(); return mesh->model.add_vertex(point.ToCGAL()); } static int AddEdge(void* ptr, int v0, int v1) { auto mesh = CastToSurfaceMesh(ptr); auto vertex0 = mesh->FindVertex(v0); auto vertex1 = mesh->FindVertex(v1); if (vertex0 == NullVertex()) return NULL_INDEX; if (vertex1 == NullVertex()) return NULL_INDEX; mesh->OnModelChanged(); return mesh->model.add_edge(vertex0, vertex1); } static int AddTriangle(void* ptr, int v0, int v1, int v2) { auto mesh = CastToSurfaceMesh(ptr); auto vertex0 = mesh->FindVertex(v0); auto vertex1 = mesh->FindVertex(v1); auto vertex2 = mesh->FindVertex(v2); if (vertex0 == NullVertex()) return NULL_INDEX; if (vertex1 == NullVertex()) return NULL_INDEX; if (vertex2 == NullVertex()) return NULL_INDEX; mesh->OnModelChanged(); return mesh->model.add_face(vertex0, vertex1, vertex2); } static int AddQuad(void* ptr, int v0, int v1, int v2, int v3) { auto mesh = CastToSurfaceMesh(ptr); auto vertex0 = mesh->FindVertex(v0); auto vertex1 = mesh->FindVertex(v1); auto vertex2 = mesh->FindVertex(v2); auto vertex3 = mesh->FindVertex(v3); if (vertex0 == NullVertex()) return NULL_INDEX; if (vertex1 == NullVertex()) return NULL_INDEX; if (vertex2 == NullVertex()) return NULL_INDEX; if (vertex3 == NullVertex()) return NULL_INDEX; mesh->OnModelChanged(); return mesh->model.add_face(vertex0, vertex1, vertex2, vertex3); } static int AddPentagon(void* ptr, int v0, int v1, int v2, int v3, int v4) { auto mesh = CastToSurfaceMesh(ptr); mesh->OnModelChanged(); std::vector face(6); face[0] = mesh->FindVertex(v0); face[1] = mesh->FindVertex(v1); face[2] = mesh->FindVertex(v2); face[3] = mesh->FindVertex(v3); face[4] = mesh->FindVertex(v4); for (auto v : face) if (v == NullVertex()) return NULL_INDEX; return mesh->model.add_face(face); } static int AddHexagon(void* ptr, int v0, int v1, int v2, int v3, int v4, int v5) { auto mesh = CastToSurfaceMesh(ptr); mesh->OnModelChanged(); std::vector face(6); face[0] = mesh->FindVertex(v0); face[1] = mesh->FindVertex(v1); face[2] = mesh->FindVertex(v2); face[3] = mesh->FindVertex(v3); face[4] = mesh->FindVertex(v4); face[5] = mesh->FindVertex(v5); for (auto v : face) if (v == NullVertex()) return NULL_INDEX; return mesh->model.add_face(face); } static int AddFace(void* ptr, int* indices, int count) { auto mesh = CastToSurfaceMesh(ptr); mesh->OnModelChanged(); std::vector face(count); for (int i = 0; i < count; i++) { auto vertex = mesh->FindVertex(indices[i]); if (vertex == NullVertex()) return NULL_INDEX; face[i] = vertex; } return mesh->model.add_face(face); } static BOOL HasGarbage(void* ptr) { auto mesh = CastToSurfaceMesh(ptr); return mesh->model.has_garbage(); } static void CollectGarbage(void* ptr) { auto mesh = CastToSurfaceMesh(ptr); mesh->model.collect_garbage(); mesh->OnModelChanged(); } static void SetRecycleGarbage(void* ptr, BOOL collect) { auto mesh = CastToSurfaceMesh(ptr); mesh->model.set_recycle_garbage(collect); } static BOOL DoesRecycleGarbage(void* ptr) { auto mesh = CastToSurfaceMesh(ptr); return mesh->model.does_recycle_garbage(); } static int VertexDegree(void* ptr, int index) { auto mesh = CastToSurfaceMesh(ptr); auto vertex = mesh->FindVertex(index); if (vertex == NullVertex()) return NULL_INDEX; return mesh->model.degree(vertex); } static int FaceDegree(void* ptr, int index) { auto mesh = CastToSurfaceMesh(ptr); auto face = mesh->FindFace(index); if (face == NullFace()) return FALSE; return mesh->model.degree(face); } static BOOL VertexIsIsolated(void* ptr, int index) { auto mesh = CastToSurfaceMesh(ptr); auto vertex = mesh->FindVertex(index); if (vertex == NullVertex()) return FALSE; return mesh->model.is_isolated(vertex); } static BOOL VertexIsBorder(void* ptr, int index, BOOL check_all_incident_halfedges) { auto mesh = CastToSurfaceMesh(ptr); auto vertex = mesh->FindVertex(index); if (vertex == NullVertex()) return FALSE; return mesh->model.is_border(vertex, check_all_incident_halfedges); } static BOOL EdgeIsBorder(void* ptr, int index) { auto mesh = CastToSurfaceMesh(ptr); auto edge = mesh->FindEdge(index); if (edge == NullEdge()) return FALSE; return mesh->model.is_border(edge); } static int NextHalfedge(void* ptr, int index) { auto mesh = CastToSurfaceMesh(ptr); auto hedge = mesh->FindHalfedge(index); if (hedge == NullHalfedge()) return NULL_INDEX; return mesh->model.next(hedge); } static int PreviousHalfedge(void* ptr, int index) { auto mesh = CastToSurfaceMesh(ptr); auto hedge = mesh->FindHalfedge(index); if (hedge == NullHalfedge()) return NULL_INDEX; return mesh->model.prev(hedge); } static int OppositeHalfedge(void* ptr, int index) { auto mesh = CastToSurfaceMesh(ptr); auto hedge = mesh->FindHalfedge(index); if (hedge == NullHalfedge()) return NULL_INDEX; return mesh->model.opposite(hedge); } static int SourceVertex(void* ptr, int index) { auto mesh = CastToSurfaceMesh(ptr); auto hedge = mesh->FindHalfedge(index); if (hedge == NullHalfedge()) return NULL_INDEX; return mesh->model.source(hedge); } static int TargetVertex(void* ptr, int index) { auto mesh = CastToSurfaceMesh(ptr); auto hedge = mesh->FindHalfedge(index); if (hedge == NullHalfedge()) return NULL_INDEX; return mesh->model.target(hedge); } static int NextAroundSource(void* ptr, int index) { auto mesh = CastToSurfaceMesh(ptr); auto hedge = mesh->FindHalfedge(index); if (hedge == NullHalfedge()) return NULL_INDEX; return mesh->model.next_around_source(hedge); } static int NextAroundTarget(void* ptr, int index) { auto mesh = CastToSurfaceMesh(ptr); auto hedge = mesh->FindHalfedge(index); if (hedge == NullHalfedge()) return NULL_INDEX; return mesh->model.next_around_target(hedge); } static int PreviousAroundSource(void* ptr, int index) { auto mesh = CastToSurfaceMesh(ptr); auto hedge = mesh->FindHalfedge(index); if (hedge == NullHalfedge()) return NULL_INDEX; return mesh->model.prev_around_source(hedge); } static int PreviousAroundTarget(void* ptr, int index) { auto mesh = CastToSurfaceMesh(ptr); auto hedge = mesh->FindHalfedge(index); if (hedge == NullHalfedge()) return NULL_INDEX; return mesh->model.prev_around_target(hedge); } static int EdgesHalfedge(void* ptr, int edgeIndex, int halfedgeIndex) { auto mesh = CastToSurfaceMesh(ptr); if (halfedgeIndex < 0) halfedgeIndex = 0; if (halfedgeIndex > 1) halfedgeIndex = 1; auto edge = mesh->FindEdge(edgeIndex); if (edge == NullEdge()) return FALSE; return mesh->model.halfedge(edge, halfedgeIndex); } static int HalfedgesEdge(void* ptr, int index) { auto mesh = CastToSurfaceMesh(ptr); auto hedge = mesh->FindHalfedge(index); if (hedge == NullHalfedge()) return NULL_INDEX; return mesh->model.edge(hedge); } static BOOL RemoveVertex(void* ptr, int index) { auto mesh = CastToSurfaceMesh(ptr); mesh->map.BuildVertexMaps(mesh->model); Vertex vertex = mesh->FindVertex(index); if (vertex == NullVertex()) return FALSE; mesh->model.remove_vertex(vertex); mesh->OnModelChanged(); return TRUE; } static BOOL RemoveEdge(void* ptr, int index) { auto mesh = CastToSurfaceMesh(ptr); mesh->map.BuildEdgeMaps(mesh->model); Edge edge = mesh->map.FindEdge(index); if (edge == NullEdge()) return FALSE; mesh->model.remove_edge(edge); mesh->OnModelChanged(); return TRUE; } static BOOL RemoveFace(void* ptr, int index) { auto mesh = CastToSurfaceMesh(ptr); mesh->map.BuildFaceMaps(mesh->model); Face face = mesh->map.FindFace(index); if (face == NullFace()) return FALSE; mesh->model.remove_face(face); mesh->OnModelChanged(); return TRUE; } static Point3d GetPoint(void* ptr, int index) { auto mesh = CastToSurfaceMesh(ptr); mesh->map.BuildVertexMaps(mesh->model); if (index < 0 || index >= mesh->map.VertexCount()) return NullPoint(); Vertex v = mesh->map.GetVertex(index); if( v == NullVertex()) return NullPoint(); auto point = mesh->model.point(v); return Point3d::FromCGAL(point); } static void GetPoints(void* ptr, Point3d* points, int count) { auto mesh = SurfaceMesh3::CastToSurfaceMesh(ptr); mesh->map.BuildVertexMaps(mesh->model); int num_vertices = mesh->map.VertexCount(); if (num_vertices == 0) return; if (num_vertices != count) return; for (int i = 0; i < num_vertices; i++) { auto vertex = mesh->map.GetVertex(i); if (vertex == NullVertex()) points[i] = NullPoint(); else { auto p = mesh->model.point(vertex); points[i] = Point3d::FromCGAL(p); } } } static void SetPoint(void* ptr, int index, const Point3d& point) { auto mesh = CastToSurfaceMesh(ptr); mesh->map.BuildVertexMaps(mesh->model); if (index < 0 || index >= mesh->map.VertexCount()) return; auto vertex = mesh->map.GetVertex(index); auto point_map = mesh->model.points(); point_map[vertex] = point.ToCGAL(); mesh->OnModelChanged(); } static void SetPoints(void* ptr, Point3d* points, int count) { auto mesh = CastToSurfaceMesh(ptr); mesh->map.BuildVertexMaps(mesh->model); int num_vertices = mesh->map.VertexCount(); if (num_vertices == 0) return; if (num_vertices != count) return; auto point_map = mesh->model.points(); for (int i = 0; i < num_vertices; i++) { auto vertex = mesh->map.GetVertex(i); if(vertex != NullVertex()) point_map[vertex] = points[i].ToCGAL(); } mesh->OnModelChanged(); } static BOOL GetSegment(void* ptr, int index, Segment3d& segment) { auto mesh = CastToSurfaceMesh(ptr); auto edge = mesh->FindHalfedge(index); if (edge != NullHalfedge()) { auto a = mesh->model.point(mesh->model.source(edge)); auto b = mesh->model.point(mesh->model.target(edge)); segment.a = Point3d::FromCGAL(a); segment.b = Point3d::FromCGAL(b); return TRUE; } else { return FALSE; } } static void GetSegments(void* ptr, Segment3d* segments, int count) { auto mesh = CastToSurfaceMesh(ptr); int i = 0; for (auto edge : halfedges(mesh->model)) { auto a = mesh->model.point(mesh->model.source(edge)); auto b = mesh->model.point(mesh->model.target(edge)); Segment3d seg; seg.a = Point3d::FromCGAL(a); seg.b = Point3d::FromCGAL(b); segments[i++] = seg; if (i >= count) return; } } static BOOL GetTriangle(void* ptr, int index, Triangle3d& tri) { auto mesh = CastToSurfaceMesh(ptr); auto face = mesh->FindFace(index); if (face != NullFace()) { auto edge = mesh->model.halfedge(face); auto prev = mesh->model.prev(edge); auto next = mesh->model.next(edge); auto a = mesh->model.point(mesh->model.source(prev)); auto b = mesh->model.point(mesh->model.source(edge)); auto c = mesh->model.point(mesh->model.source(next)); tri.a = Point3d::FromCGAL(a); tri.b = Point3d::FromCGAL(b); tri.c = Point3d::FromCGAL(c); return TRUE; } else { return FALSE; } } static void GetTriangles(void* ptr, Triangle3d* triangles, int count) { auto mesh = CastToSurfaceMesh(ptr); int i = 0; for (auto face : faces(mesh->model)) { auto edge = mesh->model.halfedge(face); auto prev = mesh->model.prev(edge); auto next = mesh->model.next(edge); auto a = mesh->model.point(mesh->model.source(prev)); auto b = mesh->model.point(mesh->model.source(edge)); auto c = mesh->model.point(mesh->model.source(next)); Triangle3d tri; tri.a = Point3d::FromCGAL(a); tri.b = Point3d::FromCGAL(b); tri.c = Point3d::FromCGAL(c); triangles[i++] = tri; if (i >= count) return; } } static BOOL GetVertex(void* ptr, int index, MeshVertex3& vert) { auto mesh = CastToSurfaceMesh(ptr); vert = MeshVertex3::NullVertex(); auto v = mesh->FindVertex(index); if (v != NullVertex()) { vert.Index = v; vert.Point = Point3d::FromCGAL(mesh->model.point(v)); vert.Halfedge = mesh->FindHalfedgeIndex(mesh->model.halfedge(v)); vert.Degree = mesh->model.degree(v); return TRUE; } else { return FALSE; } } static void GetVertices(void* ptr, MeshVertex3* vertexArray, int count) { auto mesh = CastToSurfaceMesh(ptr); int i = 0; for (auto v : vertices(mesh->model)) { MeshVertex3 vert = MeshVertex3::NullVertex(); vert.Index = v; vert.Point = Point3d::FromCGAL(mesh->model.point(v)); vert.Halfedge = mesh->FindHalfedgeIndex(mesh->model.halfedge(v)); vert.Degree = mesh->model.degree(v); vertexArray[i++] = vert; if (i >= count) return; } } static BOOL GetFace(void* ptr, int index, MeshFace3& face) { auto mesh = CastToSurfaceMesh(ptr); face = MeshFace3::NullFace(); auto f = mesh->FindFace(index); if (f != SurfaceMesh3::NullFace()) { face.Index = index; face.Halfedge = mesh->FindHalfedgeIndex(mesh->model.halfedge(f)); return TRUE; } else { return FALSE; } } static void GetFaces(void* ptr, MeshFace3* faceArray, int count) { auto mesh = CastToSurfaceMesh(ptr); int i = 0; for (auto f : faces(mesh->model)) { MeshFace3 face = MeshFace3::NullFace(); face.Index = i; face.Halfedge = mesh->FindHalfedgeIndex(mesh->model.halfedge(f)); faceArray[i++] = face; if (i >= count) return; } } static BOOL GetHalfedge(void* ptr, int index, MeshHalfedge3& edge) { auto mesh = CastToSurfaceMesh(ptr); edge = MeshHalfedge3::NullHalfedge(); auto e = mesh->FindHalfedge(index); if (e != NullHalfedge()) { edge.Index = index; edge.Source = mesh->FindVertexIndex(mesh->model.source(e)); edge.Target = mesh->FindVertexIndex(mesh->model.target(e)); edge.Opposite = mesh->FindHalfedgeIndex(mesh->model.opposite(e)); edge.Next = mesh->FindHalfedgeIndex(mesh->model.next(e)); edge.Previous = mesh->FindHalfedgeIndex(mesh->model.prev(e)); edge.Face = mesh->FindFaceIndex(mesh->model.face(e)); edge.IsBorder = mesh->model.is_border(e); return TRUE; } else { return FALSE; } } static void GetHalfedges(void* ptr, MeshHalfedge3* edgeArray, int count) { auto mesh = CastToSurfaceMesh(ptr); int i = 0; for (auto e : halfedges(mesh->model)) { MeshHalfedge3 edge = MeshHalfedge3::NullHalfedge(); edge.Index = i; edge.Source = mesh->FindVertexIndex(mesh->model.source(e)); edge.Target = mesh->FindVertexIndex(mesh->model.target(e)); edge.Opposite = mesh->FindHalfedgeIndex(mesh->model.opposite(e)); edge.Next = mesh->FindHalfedgeIndex(mesh->model.next(e)); edge.Previous = mesh->FindHalfedgeIndex(mesh->model.prev(e)); edge.Face = mesh->FindFaceIndex(mesh->model.face(e)); edge.IsBorder = mesh->model.is_border(e); edgeArray[i++] = edge; if (i >= count) return; } } static void Transform(void* ptr, const Matrix4x4d& matrix) { auto mesh = CastToSurfaceMesh(ptr); auto m = matrix.ToCGAL(); mesh->OnModelChanged(); std::transform(mesh->model.points().begin(), mesh->model.points().end(), mesh->model.points().begin(), m); } static BOOL IsVertexBorder(void* ptr, int index, BOOL check_all_incident_halfedges) { auto mesh = CastToSurfaceMesh(ptr); auto vertex = mesh->FindVertex(index); if (vertex == NullVertex()) return FALSE; return mesh->model.is_border(vertex, check_all_incident_halfedges); } static BOOL IsHalfedgeBorder(void* ptr, int index) { auto mesh = CastToSurfaceMesh(ptr); auto hedge = mesh->FindHalfedge(index); if (hedge == NullHalfedge()) return NULL_INDEX; return mesh->model.is_border(hedge); } static BOOL IsEdgeBorder(void* ptr, int index) { auto mesh = CastToSurfaceMesh(ptr); auto edge = mesh->FindEdge(index); if (edge == NullEdge()) return FALSE; return mesh->model.is_border(edge); } static int BorderEdgeCount(void* ptr) { auto mesh = CastToSurfaceMesh(ptr); int count = 0; for (auto edge : mesh->model.edges()) { if (mesh->model.is_border(edge)) count++; } return count; } static BOOL IsClosed(void* ptr) { auto mesh = CastToSurfaceMesh(ptr); for (auto edge : mesh->model.edges()) { if (mesh->model.is_border(edge)) return FALSE; } return TRUE; } static BOOL CheckFaceVertexCount(void* ptr, int count) { auto mesh = CastToSurfaceMesh(ptr); for (auto face : mesh->model.faces()) { int i = mesh->model.degree(face); if (i != count) return FALSE; } return TRUE; } static void Join(void* ptr, void* otherPtr) { auto mesh = CastToSurfaceMesh(ptr); auto other = CastToSurfaceMesh(otherPtr); mesh->model.join(other->model); mesh->OnModelChanged(); } static void BuildAABBTree(void* ptr) { auto mesh = CastToSurfaceMesh(ptr); mesh->BuildAABBTree(); } static void ReleaseAABBTree(void* ptr) { auto mesh = CastToSurfaceMesh(ptr); mesh->DeleteTree(); } static Box3d GetBoundingBox(void* ptr) { auto mesh = CastToSurfaceMesh(ptr); if (mesh->tree != nullptr) { auto box = mesh->tree->root_node()->bbox(); return Box3d::FromCGAL(box); } else { auto box = CGAL::Polygon_mesh_processing::bbox(mesh->model); return Box3d::FromCGAL(box); } } static void ReadOFF(void* ptr, const char* filename) { auto mesh = CastToSurfaceMesh(ptr); std::ifstream i(filename); i >> mesh->model; } static void WriteOFF(void* ptr, const char* filename) { auto mesh = CastToSurfaceMesh(ptr); std::ofstream o(filename); o << mesh->model; } static void Triangulate(void* ptr) { auto mesh = CastToSurfaceMesh(ptr); CGAL::Polygon_mesh_processing::triangulate_faces(mesh->model); mesh->OnModelChanged(); } static BOOL DoesSelfIntersect(void* ptr) { auto mesh = CastToSurfaceMesh(ptr); return CGAL::Polygon_mesh_processing::does_self_intersect(mesh->model); } static double Area(void* ptr) { auto mesh = CastToSurfaceMesh(ptr); return CGAL::to_double(CGAL::Polygon_mesh_processing::area(mesh->model)); } static Point3d Centroid(void* ptr) { auto mesh = CastToSurfaceMesh(ptr); auto p = CGAL::Polygon_mesh_processing::centroid(mesh->model); return Point3d::FromCGAL(p); } static double Volume(void* ptr) { auto mesh = CastToSurfaceMesh(ptr); return CGAL::to_double(CGAL::Polygon_mesh_processing::volume(mesh->model)); } static BOOL DoesBoundAVolume(void* ptr) { auto mesh = CastToSurfaceMesh(ptr); return CGAL::Polygon_mesh_processing::does_bound_a_volume(mesh->model); } static CGAL::Bounded_side SideOfTriangleMesh(void* ptr, const Point3d& point) { auto mesh = CastToSurfaceMesh(ptr); mesh->BuildAABBTree(); CGAL::Side_of_triangle_mesh inside(*mesh->tree); return inside(point.ToCGAL()); } static BOOL DoIntersects(void* ptr, void* otherPtr, BOOL test_bounded_sides) { auto mesh = CastToSurfaceMesh(ptr); auto other = CastToSurfaceMesh(otherPtr); auto param = CGAL::parameters::do_overlap_test_of_bounded_sides(test_bounded_sides); return CGAL::Polygon_mesh_processing::do_intersect(mesh->model, other->model, param, param); } static void GetCentroids(void* ptr, Point3d* points, int count) { auto mesh = CastToSurfaceMesh(ptr); int numFaces = (int)mesh->model.number_of_faces(); int index = 0; for (auto face : mesh->model.faces()) { points[index] = Point3d::FromCGAL(ComputeCentroid(mesh->model, face)); index++; if (index >= numFaces || index >= count) return; } } static int PropertyMapCount(void* ptr) { auto mesh = CastToSurfaceMesh(ptr); return 0; //return (int)mesh->model.properties().size(); } static void ComputeVertexNormals(void* ptr) { typedef K::Vector_3 Vector; typedef boost::graph_traits::SurfaceMesh>::vertex_descriptor VertexDes; auto mesh = CastToSurfaceMesh(ptr); if (mesh->vertexNormalsComputed) return; mesh->vertexNormalsComputed = true; std::string key = VERTEX_NORMAL_MAP_NAME; auto normals = mesh->model.add_property_map(key, CGAL::NULL_VECTOR).first; CGAL::Polygon_mesh_processing::compute_vertex_normals(mesh->model, normals); } static void ComputeFaceNormals(void* ptr) { typedef K::Vector_3 Vector; typedef boost::graph_traits::SurfaceMesh>::face_descriptor FaceDes; auto mesh = CastToSurfaceMesh(ptr); if (mesh->faceNormalsComputed) return; mesh->faceNormalsComputed = true; std::string key = FACE_NORMAL_MAP_NAME; auto normals = mesh->model.add_property_map(key, CGAL::NULL_VECTOR).first; CGAL::Polygon_mesh_processing::compute_face_normals(mesh->model, normals); } static void GetVertexNormals(void* ptr, Vector3d* normals, int count) { typedef K::Vector_3 Vector; typedef boost::graph_traits::SurfaceMesh>::vertex_descriptor VertexDes; auto mesh = CastToSurfaceMesh(ptr); ComputeVertexNormals(ptr); auto pair = mesh->model.property_map(VERTEX_NORMAL_MAP_NAME); if (!pair.second) return; for (auto vd : vertices(mesh->model)) { int index = vd; if (index < count) { auto n = pair.first[vd]; normals[index] = Vector3d::FromCGAL(n); } } } static void GetFaceNormals(void* ptr, Vector3d* normals, int count) { typedef K::Vector_3 Vector; typedef boost::graph_traits::SurfaceMesh>::face_descriptor FaceDes; auto mesh = CastToSurfaceMesh(ptr); ComputeFaceNormals(ptr); auto pair = mesh->model.property_map(FACE_NORMAL_MAP_NAME); if (!pair.second) return; for (auto fd : faces(mesh->model)) { int index = fd; if (index < count) { auto n = pair.first[fd]; normals[index] = Vector3d::FromCGAL(n); } } } static PolygonalCount GetPolygonalCount(void* ptr) { auto mesh = CastToSurfaceMesh(ptr); int degenerate = 0; int three = 0; int four = 0; int five = 0; int six = 0; int greater = 0; for (auto face : mesh->model.faces()) { int count = mesh->model.degree(face); switch (count) { case 0: case 1: case 2: degenerate++; break; case 3: three++; break; case 4: four++; break; case 5: five++; break; case 6: six++; break; default: greater++; break; } } return { degenerate, three, four, five, six, greater }; } static PolygonalCount GetDualPolygonalCount(void* ptr) { auto mesh = CastToSurfaceMesh(ptr); int degenerate = 0; int three = 0; int four = 0; int five = 0; int six = 0; int greater = 0; for (auto vert : mesh->model.vertices()) { int count = mesh->model.degree(vert); switch (count) { case 0: case 1: case 2: degenerate++; break; case 3: three++; break; case 4: four++; break; case 5: five++; break; case 6: six++; break; default: greater++; break; } } return { degenerate, three, four, five, six, greater }; } static void CreatePolygonMesh(void* ptr, Point2d* points, int count, BOOL xz) { auto mesh = CastToSurfaceMesh(ptr); std::vector face(count); for (int i = 0; i < count; i++) { if (xz) { auto p = points[i].ToCGAL3XZ(); face[i] = mesh->model.add_vertex(p); } else { auto p = points[i].ToCGAL3(); face[i] = mesh->model.add_vertex(p); } } mesh->model.add_face(face); } static void CreatePolygonalMesh(void* ptr, Point3d* points, int pointsCount, int* triangles, int trianglesCount, int* quads, int quadsCount, int* pentagons, int pentagonsCount, int* hexagons, int hexagonsCount) { auto mesh = CastToSurfaceMesh(ptr); mesh->Clear(); mesh->OnModelChanged(); ArrayUtil::MakeOutOfBoundsNull(triangles, trianglesCount, pointsCount); ArrayUtil::MakeOutOfBoundsNull(quads, quadsCount, pointsCount); ArrayUtil::MakeOutOfBoundsNull(pentagons, pentagonsCount, pointsCount); ArrayUtil::MakeOutOfBoundsNull(hexagons, hexagonsCount, pointsCount); std::vector list; for (int i = 0; i < pointsCount; i++) mesh->model.add_vertex(points[i].ToCGAL()); if (trianglesCount > 0) { for (int i = 0; i < trianglesCount / 3; i++) { int i0 = triangles[i * 3 + 0]; int i1 = triangles[i * 3 + 1]; int i2 = triangles[i * 3 + 2]; if (i0 == NULL_INDEX || i1 == NULL_INDEX || i2 == NULL_INDEX) continue; list.clear(); list.push_back(Vertex(i0)); list.push_back(Vertex(i1)); list.push_back(Vertex(i2)); mesh->model.add_face(list); } } if (quadsCount > 0) { for (int i = 0; i < quadsCount / 4; i++) { int i0 = quads[i * 4 + 0]; int i1 = quads[i * 4 + 1]; int i2 = quads[i * 4 + 2]; int i3 = quads[i * 4 + 3]; if (i0 == NULL_INDEX || i1 == NULL_INDEX || i2 == NULL_INDEX || i3 == NULL_INDEX) continue; list.clear(); list.push_back(Vertex(i0)); list.push_back(Vertex(i1)); list.push_back(Vertex(i2)); list.push_back(Vertex(i3)); mesh->model.add_face(list); } } if (pentagonsCount > 0) { for (int i = 0; i < pentagonsCount / 5; i++) { int i0 = pentagons[i * 5 + 0]; int i1 = pentagons[i * 5 + 1]; int i2 = pentagons[i * 5 + 2]; int i3 = pentagons[i * 5 + 3]; int i4 = pentagons[i * 5 + 4]; if (i0 == NULL_INDEX || i1 == NULL_INDEX || i2 == NULL_INDEX || i3 == NULL_INDEX || i4 == NULL_INDEX) continue; list.clear(); list.push_back(Vertex(pentagons[i * 5 + 0])); list.push_back(Vertex(pentagons[i * 5 + 1])); list.push_back(Vertex(pentagons[i * 5 + 2])); list.push_back(Vertex(pentagons[i * 5 + 3])); list.push_back(Vertex(pentagons[i * 5 + 4])); mesh->model.add_face(list); } } if (hexagonsCount > 0) { for (int i = 0; i < hexagonsCount / 6; i++) { int i0 = hexagons[i * 6 + 0]; int i1 = hexagons[i * 6 + 1]; int i2 = hexagons[i * 6 + 2]; int i3 = hexagons[i * 6 + 3]; int i4 = hexagons[i * 6 + 4]; int i5 = hexagons[i * 6 + 5]; if (i0 == NULL_INDEX || i1 == NULL_INDEX || i2 == NULL_INDEX || i3 == NULL_INDEX || i4 == NULL_INDEX || i5 == NULL_INDEX) continue; list.clear(); list.push_back(Vertex(hexagons[i * 6 + 0])); list.push_back(Vertex(hexagons[i * 6 + 1])); list.push_back(Vertex(hexagons[i * 6 + 2])); list.push_back(Vertex(hexagons[i * 6 + 3])); list.push_back(Vertex(hexagons[i * 6 + 4])); list.push_back(Vertex(hexagons[i * 6 + 6])); mesh->model.add_face(list); } } } static void GetPolygonalIndices(void* ptr, int* triangles, int triangleCount, int* quads, int quadCount, int* pentagons, int pentagonCount, int* hexagons, int hexagonCount) { auto mesh = CastToSurfaceMesh(ptr); mesh->BuildModel(); int triangleIndex = 0; int quadIndex = 0; int pentagonIndex = 0; int hexagonIndex = 0; int indices[6]; ArrayUtil::FillWithNull(triangles, triangleCount); ArrayUtil::FillWithNull(quads, quadCount); ArrayUtil::FillWithNull(pentagons, pentagonCount); ArrayUtil::FillWithNull(hexagons, hexagonCount); for (auto face : mesh->model.faces()) { int count = mesh->model.degree(face); if (count < 3 || count > 6) continue; auto hedge = mesh->model.halfedge(face); for (int i = 0; i < count; i++) { auto vertex = mesh->model.source(hedge); indices[i] = mesh->FindVertexIndex(vertex); hedge = mesh->model.next(hedge); } if (count == 3 && triangleIndex < triangleCount) { triangles[triangleIndex * 3 + 0] = indices[0]; triangles[triangleIndex * 3 + 1] = indices[1]; triangles[triangleIndex * 3 + 2] = indices[2]; triangleIndex++; } else if (count == 4 && quadIndex < quadCount) { quads[quadIndex * 4 + 0] = indices[0]; quads[quadIndex * 4 + 1] = indices[1]; quads[quadIndex * 4 + 2] = indices[2]; quads[quadIndex * 4 + 3] = indices[3]; quadIndex++; } else if (count == 5 && pentagonIndex < pentagonCount) { pentagons[pentagonIndex * 5 + 0] = indices[0]; pentagons[pentagonIndex * 5 + 1] = indices[1]; pentagons[pentagonIndex * 5 + 2] = indices[2]; pentagons[pentagonIndex * 5 + 3] = indices[3]; pentagons[pentagonIndex * 5 + 4] = indices[4]; pentagonIndex++; } else if (count == 6 && hexagonIndex < hexagonCount) { hexagons[hexagonIndex * 6 + 0] = indices[0]; hexagons[hexagonIndex * 6 + 1] = indices[1]; hexagons[hexagonIndex * 6 + 2] = indices[2]; hexagons[hexagonIndex * 6 + 3] = indices[3]; hexagons[hexagonIndex * 6 + 4] = indices[4]; hexagons[hexagonIndex * 6 + 5] = indices[5]; hexagonIndex++; } } } static void GetDualPolygonalIndices(void* ptr, int* triangles, int triangleCount, int* quads, int quadCount, int* pentagons, int pentagonCount, int* hexagons, int hexagonCount) { auto mesh = CastToSurfaceMesh(ptr); mesh->BuildModel(); int triangleIndex = 0; int quadIndex = 0; int pentagonIndex = 0; int hexagonIndex = 0; int indices[6]; ArrayUtil::FillWithNull(triangles, triangleCount); ArrayUtil::FillWithNull(quads, quadCount); ArrayUtil::FillWithNull(pentagons, pentagonCount); ArrayUtil::FillWithNull(hexagons, hexagonCount); //Not workinng for (auto vert : mesh->model.vertices()) { int count = mesh->model.degree(vert); if (count < 3 || count > 6) continue; auto hedge = mesh->model.halfedge(vert); for (int i = 0; i < count; i++) { auto face = mesh->model.face(hedge); indices[i] = mesh->FindFaceIndex(face); hedge = mesh->model.next_around_source(hedge); } if (count == 3 && triangleIndex < triangleCount) { triangles[triangleIndex * 3 + 0] = indices[0]; triangles[triangleIndex * 3 + 1] = indices[1]; triangles[triangleIndex * 3 + 2] = indices[2]; triangleIndex++; } else if (count == 4 && quadIndex < quadCount) { quads[quadIndex * 4 + 0] = indices[0]; quads[quadIndex * 4 + 1] = indices[1]; quads[quadIndex * 4 + 2] = indices[2]; quads[quadIndex * 4 + 3] = indices[3]; quadIndex++; } else if (count == 5 && pentagonIndex < pentagonCount) { pentagons[pentagonIndex * 5 + 0] = indices[0]; pentagons[pentagonIndex * 5 + 1] = indices[1]; pentagons[pentagonIndex * 5 + 2] = indices[2]; pentagons[pentagonIndex * 5 + 3] = indices[3]; pentagons[pentagonIndex * 5 + 4] = indices[4]; pentagonIndex++; } else if (count == 6 && hexagonIndex < hexagonCount) { hexagons[hexagonIndex * 6 + 0] = indices[0]; hexagons[hexagonIndex * 6 + 1] = indices[1]; hexagons[hexagonIndex * 6 + 2] = indices[2]; hexagons[hexagonIndex * 6 + 3] = indices[3]; hexagons[hexagonIndex * 6 + 4] = indices[4]; hexagons[hexagonIndex * 6 + 5] = indices[5]; hexagonIndex++; } } } private: static Point_3 ComputeCentroid(const SurfaceMesh& mesh, const Face& face) { int num = 0; FT x = 0; FT y = 0; FT z = 0; for (auto vert : mesh.vertices_around_face(mesh.halfedge(face))) { auto p = mesh.point(vert); x += p.x(); y += p.y(); z += p.z(); num++; } if (num != 0) { x /= num; y /= num; z /= num; } return { x, y, z }; } }; ================================================ FILE: CGALWrapper/Polyhedra/SurfaceMesh3_EEK.cpp ================================================ #include "SurfaceMesh3_EEK.h" #include "SurfaceMesh3.h" #include void* SurfaceMesh3_EEK_Create() { return SurfaceMesh3::NewSurfaceMesh(); } void SurfaceMesh3_EEK_Release(void* ptr) { SurfaceMesh3::DeleteSurfaceMesh(ptr); } int SurfaceMesh3_EEK_GetBuildStamp(void* ptr) { return SurfaceMesh3::GetBuildStamp(ptr); } void SurfaceMesh3_EEK_Clear(void* ptr) { SurfaceMesh3::Clear(ptr); } void SurfaceMesh3_EEK_ClearIndexMaps(void* ptr, BOOL vertices, BOOL faces, BOOL edges, BOOL halfedges) { SurfaceMesh3::ClearIndexMaps(ptr, vertices, faces, edges, halfedges); } void SurfaceMesh3_EEK_ClearNormalMaps(void* ptr, BOOL vertices, BOOL faces) { SurfaceMesh3::ClearNormalMaps(ptr, vertices, faces); } void SurfaceMesh3_EEK_ClearProperyMaps(void* ptr) { SurfaceMesh3::ClearProperyMaps(ptr); } void SurfaceMesh3_EEK_BuildIndices(void* ptr, BOOL vertices, BOOL faces, BOOL edges, BOOL halfedges, BOOL force) { SurfaceMesh3::BuildIndices(ptr, vertices, faces, edges, halfedges, force); } void SurfaceMesh3_EEK_PrintIndices(void* ptr, BOOL vertices, BOOL faces, BOOL edges, BOOL halfedges, BOOL force) { SurfaceMesh3::PrintIndices(ptr, vertices, faces, edges, halfedges, force); } void* SurfaceMesh3_EEK_Copy(void* ptr) { return SurfaceMesh3::Copy(ptr); } BOOL SurfaceMesh3_EEK_IsValid(void* ptr) { return SurfaceMesh3::IsValid(ptr); } int SurfaceMesh3_EEK_VertexCount(void* ptr) { return SurfaceMesh3::VertexCount(ptr); } int SurfaceMesh3_EEK_HalfedgeCount(void* ptr) { return SurfaceMesh3::HalfedgeCount(ptr); } int SurfaceMesh3_EEK_EdgeCount(void* ptr) { return SurfaceMesh3::EdgeCount(ptr); } int SurfaceMesh3_EEK_FaceCount(void* ptr) { return SurfaceMesh3::FaceCount(ptr); } int SurfaceMesh3_EEK_RemovedVertexCount(void* ptr) { return SurfaceMesh3::RemovedVertexCount(ptr); } int SurfaceMesh3_EEK_RemovedHalfedgeCount(void* ptr) { return SurfaceMesh3::RemovedHalfedgeCount(ptr); } int SurfaceMesh3_EEK_RemovedEdgeCount(void* ptr) { return SurfaceMesh3::RemovedEdgeCount(ptr); } int SurfaceMesh3_EEK_RemovedFaceCount(void* ptr) { return SurfaceMesh3::RemovedFaceCount(ptr); } BOOL SurfaceMesh3_EEK_IsVertexRemoved(void* ptr, int index) { return SurfaceMesh3::IsVertexRemoved(ptr, index); } BOOL SurfaceMesh3_EEK_IsFaceRemoved(void* ptr, int index) { return SurfaceMesh3::IsFaceRemoved(ptr, index); } BOOL SurfaceMesh3_EEK_IsHalfedgeRemoved(void* ptr, int index) { return SurfaceMesh3::IsHalfedgeRemoved(ptr, index); } BOOL SurfaceMesh3_EEK_IsEdgeRemoved(void* ptr, int index) { return SurfaceMesh3::IsEdgeRemoved(ptr, index); } int SurfaceMesh3_EEK_AddVertex(void* ptr, Point3d point) { return SurfaceMesh3::AddVertex(ptr, point); } int SurfaceMesh3_EEK_AddEdge(void* ptr, int v0, int v1) { return SurfaceMesh3::AddEdge(ptr, v0, v1); } int SurfaceMesh3_EEK_AddTriangle(void* ptr, int v0, int v1, int v2) { return SurfaceMesh3::AddTriangle(ptr, v0, v1, v2); } int SurfaceMesh3_EEK_AddQuad(void* ptr, int v0, int v1, int v2, int v3) { return SurfaceMesh3::AddQuad(ptr, v0, v1, v2, v3); } int SurfaceMesh3_EEK_AddPentagon(void* ptr, int v0, int v1, int v2, int v3, int v4) { return SurfaceMesh3::AddPentagon(ptr, v0, v1, v2, v3, v4); } int SurfaceMesh3_EEK_AddHexagon(void* ptr, int v0, int v1, int v2, int v3, int v4, int v5) { return SurfaceMesh3::AddHexagon(ptr, v0, v1, v2, v3, v4, v5); } int SurfaceMesh3_EEK_AddFace(void* ptr, int* indices, int count) { return SurfaceMesh3::AddFace(ptr, indices, count); } BOOL SurfaceMesh3_EEK_HasGarbage(void* ptr) { return SurfaceMesh3::HasGarbage(ptr); } void SurfaceMesh3_EEK_CollectGarbage(void* ptr) { SurfaceMesh3::CollectGarbage(ptr); } void SurfaceMesh3_EEK_SetRecycleGarbage(void* ptr, BOOL collect) { SurfaceMesh3::SetRecycleGarbage(ptr, collect); } BOOL SurfaceMesh3_EEK_DoesRecycleGarbage(void* ptr) { return SurfaceMesh3::DoesRecycleGarbage(ptr); } int SurfaceMesh3_EEK_VertexDegree(void* ptr, int index) { return SurfaceMesh3::VertexDegree(ptr, index); } int SurfaceMesh3_EEK_FaceDegree(void* ptr, int index) { return SurfaceMesh3::FaceDegree(ptr, index); } BOOL SurfaceMesh3_EEK_VertexIsIsolated(void* ptr, int index) { return SurfaceMesh3::VertexIsIsolated(ptr, index); } BOOL SurfaceMesh3_EEK_VertexIsBorder(void* ptr, int index, BOOL check_all_incident_halfedges) { return SurfaceMesh3::VertexIsBorder(ptr, index, check_all_incident_halfedges); } BOOL SurfaceMesh3_EEK_EdgeIsBorder(void* ptr, int index) { return SurfaceMesh3::EdgeIsBorder(ptr, index); } int SurfaceMesh3_EEK_NextHalfedge(void* ptr, int index) { return SurfaceMesh3::NextHalfedge(ptr, index); } int SurfaceMesh3_EEK_PreviousHalfedge(void* ptr, int index) { return SurfaceMesh3::PreviousHalfedge(ptr, index); } int SurfaceMesh3_EEK_OppositeHalfedge(void* ptr, int index) { return SurfaceMesh3::OppositeHalfedge(ptr, index); } int SurfaceMesh3_EEK_SourceVertex(void* ptr, int index) { return SurfaceMesh3::SourceVertex(ptr, index); } int SurfaceMesh3_EEK_TargetVertex(void* ptr, int index) { return SurfaceMesh3::TargetVertex(ptr, index); } int SurfaceMesh3_EEK_NextAroundSource(void* ptr, int index) { return SurfaceMesh3::NextAroundSource(ptr, index); } int SurfaceMesh3_EEK_NextAroundTarget(void* ptr, int index) { return SurfaceMesh3::NextAroundTarget(ptr, index); } int SurfaceMesh3_EEK_PreviousAroundSource(void* ptr, int index) { return SurfaceMesh3::PreviousAroundSource(ptr, index); } int SurfaceMesh3_EEK_PreviousAroundTarget(void* ptr, int index) { return SurfaceMesh3::PreviousAroundTarget(ptr, index); } int SurfaceMesh3_EEK_EdgesHalfedge(void* ptr, int edgeIndex, int halfedgeIndex) { return SurfaceMesh3::EdgesHalfedge(ptr, edgeIndex, halfedgeIndex); } int SurfaceMesh3_EEK_HalfedgesEdge(void* ptr, int index) { return SurfaceMesh3::HalfedgesEdge(ptr, index); } BOOL SurfaceMesh3_EEK_RemoveVertex(void* ptr, int index) { return SurfaceMesh3::RemoveVertex(ptr, index); } BOOL SurfaceMesh3_EEK_RemoveEdge(void* ptr, int index) { return SurfaceMesh3::RemoveEdge(ptr, index); } BOOL SurfaceMesh3_EEK_RemoveFace(void* ptr, int index) { return SurfaceMesh3::RemoveFace(ptr, index); } BOOL SurfaceMesh3_EEK_IsVertexValid(void* ptr, int index) { return SurfaceMesh3::IsVertexValid(ptr, index); } BOOL SurfaceMesh3_EEK_IsEdgeValid(void* ptr, int index) { return SurfaceMesh3::IsEdgeValid(ptr, index); } BOOL SurfaceMesh3_EEK_IsHalfedgeValid(void* ptr, int index) { return SurfaceMesh3::IsHalfedgeValid(ptr, index); } BOOL SurfaceMesh3_EEK_IsFaceValid(void* ptr, int index) { return SurfaceMesh3::IsFaceValid(ptr, index); } Point3d SurfaceMesh3_EEK_GetPoint(void* ptr, int index) { return SurfaceMesh3::GetPoint(ptr, index); } void SurfaceMesh3_EEK_GetPoints(void* ptr, Point3d* points, int count) { SurfaceMesh3::GetPoints(ptr, points, count); } void SurfaceMesh3_EEK_SetPoint(void* ptr, int index, const Point3d& point) { SurfaceMesh3::SetPoint(ptr, index, point); } void SurfaceMesh3_EEK_SetPoints(void* ptr, Point3d* points, int count) { SurfaceMesh3::SetPoints(ptr, points, count); } BOOL SurfaceMesh3_EEK_GetSegment(void* ptr, int index, Segment3d& segment) { return SurfaceMesh3::GetSegment(ptr,index, segment); } void SurfaceMesh3_EEK_GetSegments(void* ptr, Segment3d* segments, int count) { SurfaceMesh3::GetSegments(ptr, segments, count); } BOOL SurfaceMesh3_EEK_GetTriangle(void* ptr, int index, Triangle3d& tri) { return SurfaceMesh3::GetTriangle(ptr, index, tri); } void SurfaceMesh3_EEK_GetTriangles(void* ptr, Triangle3d* triangles, int count) { SurfaceMesh3::GetTriangles(ptr, triangles, count); } BOOL SurfaceMesh3_EEK_GetVertex(void* ptr, int index, MeshVertex3& vert) { return SurfaceMesh3::GetVertex(ptr, index, vert); } void SurfaceMesh3_EEK_GetVertices(void* ptr, MeshVertex3* vertexArray, int count) { SurfaceMesh3::GetVertices(ptr, vertexArray, count); } BOOL SurfaceMesh3_EEK_GetFace(void* ptr, int index, MeshFace3& face) { return SurfaceMesh3::GetFace(ptr, index, face); } void SurfaceMesh3_EEK_GetFaces(void* ptr, MeshFace3* faceArray, int count) { SurfaceMesh3::GetFaces(ptr, faceArray, count); } BOOL SurfaceMesh3_EEK_GetHalfedge(void* ptr, int index, MeshHalfedge3& edge) { return SurfaceMesh3::GetHalfedge(ptr, index, edge); } void SurfaceMesh3_EEK_GetHalfedges(void* ptr, MeshHalfedge3* edgeArray, int count) { SurfaceMesh3::GetHalfedges(ptr, edgeArray, count); } void SurfaceMesh3_EEK_Transform(void* ptr, const Matrix4x4d& matrix) { SurfaceMesh3::Transform(ptr, matrix); } BOOL SurfaceMesh3_EEK_IsVertexBorder(void* ptr, int index, BOOL check_all_incident_halfedges) { return SurfaceMesh3::IsVertexBorder(ptr, index, check_all_incident_halfedges); } BOOL SurfaceMesh3_EEK_IsHalfedgeBorder(void* ptr, int index) { return SurfaceMesh3::IsHalfedgeBorder(ptr, index); } BOOL SurfaceMesh3_EEK_IsEdgeBorder(void* ptr, int index) { return SurfaceMesh3::IsEdgeBorder(ptr, index); } int SurfaceMesh3_EEK_BorderEdgeCount(void* ptr) { return SurfaceMesh3::BorderEdgeCount(ptr); } BOOL SurfaceMesh3_EEK_IsClosed(void* ptr) { return SurfaceMesh3::IsClosed(ptr); } void SurfaceMesh3_EEK_Join(void* ptr, void* otherPtr) { SurfaceMesh3::Join(ptr, otherPtr); } void SurfaceMesh3_EEK_BuildAABBTree(void* ptr) { SurfaceMesh3::BuildAABBTree(ptr); } void SurfaceMesh3_EEK_ReleaseAABBTree(void* ptr) { SurfaceMesh3::ReleaseAABBTree(ptr); } Box3d SurfaceMesh3_EEK_GetBoundingBox(void* ptr) { return SurfaceMesh3::GetBoundingBox(ptr); } void SurfaceMesh3_EEK_ReadOFF(void* ptr, const char* filename) { SurfaceMesh3::ReadOFF(ptr, filename); } void SurfaceMesh3_EEK_WriteOFF(void* ptr, const char* filename) { SurfaceMesh3::WriteOFF(ptr, filename); } void SurfaceMesh3_EEK_Triangulate(void* ptr) { SurfaceMesh3::Triangulate(ptr); } BOOL SurfaceMesh3_EEK_DoesSelfIntersect(void* ptr) { return SurfaceMesh3::DoesSelfIntersect(ptr); } double SurfaceMesh3_EEK_Area(void* ptr) { return SurfaceMesh3::Area(ptr); } Point3d SurfaceMesh3_EEK_Centroid(void* ptr) { return SurfaceMesh3::Centroid(ptr); } double SurfaceMesh3_EEK_Volume(void* ptr) { return SurfaceMesh3::Volume(ptr); } BOOL SurfaceMesh3_EEK_DoesBoundAVolume(void* ptr) { return SurfaceMesh3::DoesBoundAVolume(ptr); } CGAL::Bounded_side SurfaceMesh3_EEK_SideOfTriangleMesh(void* ptr, const Point3d& point) { return SurfaceMesh3::SideOfTriangleMesh(ptr, point); } BOOL SurfaceMesh3_EEK_DoIntersects(void* ptr, void* otherPtr, BOOL test_bounded_sides) { return SurfaceMesh3::DoIntersects(ptr, otherPtr, test_bounded_sides); } void SurfaceMesh3_EEK_GetCentroids(void* ptr, Point3d* points, int count) { SurfaceMesh3::GetCentroids(ptr, points, count); } int SurfaceMesh3_EEK_PropertyMapCount(void* ptr) { return SurfaceMesh3::PropertyMapCount(ptr); } void SurfaceMesh3_EEK_ComputeVertexNormals(void* ptr) { SurfaceMesh3::ComputeVertexNormals(ptr); } void SurfaceMesh3_EEK_ComputeFaceNormals(void* ptr) { SurfaceMesh3::ComputeFaceNormals(ptr); } void SurfaceMesh3_EEK_GetVertexNormals(void* ptr, Vector3d* normals, int count) { SurfaceMesh3::GetVertexNormals(ptr, normals, count); } void SurfaceMesh3_EEK_GetFaceNormals(void* ptr, Vector3d* normals, int count) { SurfaceMesh3::GetFaceNormals(ptr, normals, count); } BOOL SurfaceMesh3_EEK_CheckFaceVertexCount(void* ptr, int count) { return SurfaceMesh3::CheckFaceVertexCount(ptr, count); } PolygonalCount SurfaceMesh3_EEK_GetPolygonalCount(void* ptr) { return SurfaceMesh3::GetPolygonalCount(ptr); } PolygonalCount SurfaceMesh3_EEK_GetDualPolygonalCount(void* ptr) { return SurfaceMesh3::GetDualPolygonalCount(ptr); } void SurfaceMesh3_EEK_CreatePolygonMesh(void* ptr, Point2d* points, int count, BOOL xz) { SurfaceMesh3::CreatePolygonMesh(ptr, points, count, xz); } void SurfaceMesh3_EEK_CreatePolygonalMesh(void* ptr, Point3d* points, int pointsCount, int* triangles, int triangleCount, int* quads, int quadCount, int* pentagons, int pentagonCount, int* hexagons, int hexagonCount) { SurfaceMesh3::CreatePolygonalMesh(ptr, points, pointsCount, triangles, triangleCount, quads, quadCount, pentagons, pentagonCount, hexagons, hexagonCount); } void SurfaceMesh3_EEK_GetPolygonalIndices(void* ptr, int* triangles, int triangleCount, int* quads, int quadCount, int* pentagons, int pentagonCount, int* hexagons, int hexagonCount) { SurfaceMesh3::GetPolygonalIndices(ptr, triangles, triangleCount, quads, quadCount, pentagons, pentagonCount, hexagons, hexagonCount); } void SurfaceMesh3_EEK_GetDualPolygonalIndices(void* ptr, int* triangles, int triangleCount, int* quads, int quadCount, int* pentagons, int pentagonCount, int* hexagons, int hexagonCount) { SurfaceMesh3::GetDualPolygonalIndices(ptr, triangles, triangleCount, quads, quadCount, pentagons, pentagonCount, hexagons, hexagonCount); } static void GetDualPolygonalIndices(void* ptr, int* triangles, int triangleCount, int* quads, int quadCount, int* pentagons, int pentagonCount, int* hexagons, int hexagonCount) { typedef typename EEK::FT FT; typedef typename EEK::Point_3 Point_3; typedef typename CGAL::Surface_mesh SurfaceMesh; typedef typename SurfaceMesh::Edge_index Edge; typedef typename SurfaceMesh::Halfedge_index Halfedge; typedef typename SurfaceMesh::Vertex_index Vertex; typedef typename SurfaceMesh::Face_index Face; auto mesh = SurfaceMesh3::CastToSurfaceMesh(ptr); mesh->BuildModel(); int triangleIndex = 0; int quadIndex = 0; int pentagonIndex = 0; int hexagonIndex = 0; int indices[6]; ArrayUtil::FillWithNull(triangles, triangleCount); ArrayUtil::FillWithNull(quads, quadCount); ArrayUtil::FillWithNull(pentagons, pentagonCount); ArrayUtil::FillWithNull(hexagons, hexagonCount); for (auto face : mesh->model.faces()) { int count = mesh->model.degree(face); if (count < 3 || count > 6) continue; auto hedge = mesh->model.halfedge(face); for (int i = 0; i < count; i++) { auto face = mesh->model.face(hedge); indices[i] = mesh->FindFaceIndex(face); hedge = mesh->model.next_around_source(hedge); } if (count == 3 && triangleIndex < triangleCount) { triangles[triangleIndex * 3 + 0] = indices[0]; triangles[triangleIndex * 3 + 1] = indices[1]; triangles[triangleIndex * 3 + 2] = indices[2]; triangleIndex++; } else if (count == 4 && quadIndex < quadCount) { quads[quadIndex * 4 + 0] = indices[0]; quads[quadIndex * 4 + 1] = indices[1]; quads[quadIndex * 4 + 2] = indices[2]; quads[quadIndex * 4 + 3] = indices[3]; quadIndex++; } else if (count == 5 && pentagonIndex < pentagonCount) { pentagons[pentagonIndex * 5 + 0] = indices[0]; pentagons[pentagonIndex * 5 + 1] = indices[1]; pentagons[pentagonIndex * 5 + 2] = indices[2]; pentagons[pentagonIndex * 5 + 3] = indices[3]; pentagons[pentagonIndex * 5 + 4] = indices[4]; pentagonIndex++; } else if (count == 6 && hexagonIndex < hexagonCount) { hexagons[hexagonIndex * 6 + 0] = indices[0]; hexagons[hexagonIndex * 6 + 1] = indices[1]; hexagons[hexagonIndex * 6 + 2] = indices[2]; hexagons[hexagonIndex * 6 + 3] = indices[3]; hexagons[hexagonIndex * 6 + 4] = indices[4]; hexagons[hexagonIndex * 6 + 5] = indices[5]; hexagonIndex++; } } } ================================================ FILE: CGALWrapper/Polyhedra/SurfaceMesh3_EEK.h ================================================ #pragma once #include "../CGALWrapper.h" #include "../Geometry/Geometry2.h" #include "../Geometry/Geometry3.h" #include "../Geometry/Matrices.h" #include "../Geometry/MinMax.h" #include "PolygonalCount.h" #include "MeshVertex3.h" #include "MeshFace3.h" #include "MeshHalfedge3.h" extern "C" { CGALWRAPPER_API void* SurfaceMesh3_EEK_Create(); CGALWRAPPER_API void SurfaceMesh3_EEK_Release(void* ptr); CGALWRAPPER_API int SurfaceMesh3_EEK_GetBuildStamp(void* ptr); CGALWRAPPER_API void SurfaceMesh3_EEK_Clear(void* ptr); CGALWRAPPER_API void SurfaceMesh3_EEK_ClearIndexMaps(void* ptr, BOOL vertices, BOOL faces, BOOL edges, BOOL halfedges); CGALWRAPPER_API void SurfaceMesh3_EEK_ClearNormalMaps(void* ptr, BOOL vertices, BOOL faces); CGALWRAPPER_API void SurfaceMesh3_EEK_ClearProperyMaps(void* ptr); CGALWRAPPER_API void SurfaceMesh3_EEK_BuildIndices(void* ptr, BOOL vertices, BOOL faces, BOOL edges, BOOL halfedges, BOOL force); CGALWRAPPER_API void SurfaceMesh3_EEK_PrintIndices(void* ptr, BOOL vertices, BOOL faces, BOOL edges, BOOL halfedges, BOOL force); CGALWRAPPER_API void* SurfaceMesh3_EEK_Copy(void* ptr); CGALWRAPPER_API BOOL SurfaceMesh3_EEK_IsValid(void* ptr); CGALWRAPPER_API BOOL SurfaceMesh3_EEK_IsVertexValid(void* ptr, int index); CGALWRAPPER_API BOOL SurfaceMesh3_EEK_IsFaceValid(void* ptr, int index); CGALWRAPPER_API BOOL SurfaceMesh3_EEK_IsHalfedgeValid(void* ptr, int index); CGALWRAPPER_API BOOL SurfaceMesh3_EEK_IsEdgeValid(void* ptr, int index); CGALWRAPPER_API int SurfaceMesh3_EEK_VertexCount(void* ptr); CGALWRAPPER_API int SurfaceMesh3_EEK_HalfedgeCount(void* ptr); CGALWRAPPER_API int SurfaceMesh3_EEK_EdgeCount(void* ptr); CGALWRAPPER_API int SurfaceMesh3_EEK_FaceCount(void* ptr); CGALWRAPPER_API int SurfaceMesh3_EEK_RemovedVertexCount(void* ptr); CGALWRAPPER_API int SurfaceMesh3_EEK_RemovedHalfedgeCount(void* ptr); CGALWRAPPER_API int SurfaceMesh3_EEK_RemovedEdgeCount(void* ptr); CGALWRAPPER_API int SurfaceMesh3_EEK_RemovedFaceCount(void* ptr); CGALWRAPPER_API BOOL SurfaceMesh3_EEK_IsVertexRemoved(void* ptr, int index); CGALWRAPPER_API BOOL SurfaceMesh3_EEK_IsFaceRemoved(void* ptr, int index); CGALWRAPPER_API BOOL SurfaceMesh3_EEK_IsHalfedgeRemoved(void* ptr, int index); CGALWRAPPER_API BOOL SurfaceMesh3_EEK_IsEdgeRemoved(void* ptr, int index); CGALWRAPPER_API int SurfaceMesh3_EEK_AddVertex(void* ptr, Point3d point); CGALWRAPPER_API int SurfaceMesh3_EEK_AddEdge(void* ptr, int v0, int v1); CGALWRAPPER_API int SurfaceMesh3_EEK_AddTriangle(void* ptr, int v0, int v1, int v2); CGALWRAPPER_API int SurfaceMesh3_EEK_AddQuad(void* ptr, int v0, int v1, int v2, int v3); CGALWRAPPER_API int SurfaceMesh3_EEK_AddPentagon(void* ptr, int v0, int v1, int v2, int v3, int v4); CGALWRAPPER_API int SurfaceMesh3_EEK_AddHexagon(void* ptr, int v0, int v1, int v2, int v3, int v4, int v5); CGALWRAPPER_API int SurfaceMesh3_EEK_AddFace(void* ptr, int* indices, int count); CGALWRAPPER_API BOOL SurfaceMesh3_EEK_HasGarbage(void* ptr); CGALWRAPPER_API void SurfaceMesh3_EEK_CollectGarbage(void* ptr); CGALWRAPPER_API void SurfaceMesh3_EEK_SetRecycleGarbage(void* ptr, BOOL collect); CGALWRAPPER_API BOOL SurfaceMesh3_EEK_DoesRecycleGarbage(void* ptr); CGALWRAPPER_API int SurfaceMesh3_EEK_VertexDegree(void* ptr, int index); CGALWRAPPER_API int SurfaceMesh3_EEK_FaceDegree(void* ptr, int index); CGALWRAPPER_API BOOL SurfaceMesh3_EEK_VertexIsIsolated(void* ptr, int index); CGALWRAPPER_API BOOL SurfaceMesh3_EEK_VertexIsBorder(void* ptr, int index, BOOL check_all_incident_halfedges); CGALWRAPPER_API BOOL SurfaceMesh3_EEK_EdgeIsBorder(void* ptr, int index); CGALWRAPPER_API int SurfaceMesh3_EEK_NextHalfedge(void* ptr, int index); CGALWRAPPER_API int SurfaceMesh3_EEK_PreviousHalfedge(void* ptr, int index); CGALWRAPPER_API int SurfaceMesh3_EEK_OppositeHalfedge(void* ptr, int index); CGALWRAPPER_API int SurfaceMesh3_EEK_SourceVertex(void* ptr, int index); CGALWRAPPER_API int SurfaceMesh3_EEK_TargetVertex(void* ptr, int index); CGALWRAPPER_API int SurfaceMesh3_EEK_NextAroundSource(void* ptr, int index); CGALWRAPPER_API int SurfaceMesh3_EEK_NextAroundTarget(void* ptr, int index); CGALWRAPPER_API int SurfaceMesh3_EEK_PreviousAroundSource(void* ptr, int index); CGALWRAPPER_API int SurfaceMesh3_EEK_PreviousAroundTarget(void* ptr, int index); CGALWRAPPER_API int SurfaceMesh3_EEK_EdgesHalfedge(void* ptr, int edgeIndex, int halfedgeIndex); CGALWRAPPER_API int SurfaceMesh3_EEK_HalfedgesEdge(void* ptr, int index); CGALWRAPPER_API BOOL SurfaceMesh3_EEK_RemoveVertex(void* ptr, int index); CGALWRAPPER_API BOOL SurfaceMesh3_EEK_RemoveEdge(void* ptr, int index); CGALWRAPPER_API BOOL SurfaceMesh3_EEK_RemoveFace(void* ptr, int index); CGALWRAPPER_API Point3d SurfaceMesh3_EEK_GetPoint(void* ptr, int index); CGALWRAPPER_API void SurfaceMesh3_EEK_GetPoints(void* ptr, Point3d* points, int count); CGALWRAPPER_API void SurfaceMesh3_EEK_SetPoint(void* ptr, int index, const Point3d& point); CGALWRAPPER_API void SurfaceMesh3_EEK_SetPoints(void* ptr, Point3d* points, int count); CGALWRAPPER_API BOOL SurfaceMesh3_EEK_GetSegment(void* ptr, int index, Segment3d& segment); CGALWRAPPER_API void SurfaceMesh3_EEK_GetSegments(void* ptr, Segment3d* segments, int count); CGALWRAPPER_API BOOL SurfaceMesh3_EEK_GetTriangle(void* ptr, int index, Triangle3d& tri); CGALWRAPPER_API void SurfaceMesh3_EEK_GetTriangles(void* ptr, Triangle3d* triangles, int count); CGALWRAPPER_API BOOL SurfaceMesh3_EEK_GetVertex(void* ptr, int index, MeshVertex3& vert); CGALWRAPPER_API void SurfaceMesh3_EEK_GetVertices(void* ptr, MeshVertex3* vertexArray, int count); CGALWRAPPER_API BOOL SurfaceMesh3_EEK_GetFace(void* ptr, int index, MeshFace3& face); CGALWRAPPER_API void SurfaceMesh3_EEK_GetFaces(void* ptr, MeshFace3* faceArray, int count); CGALWRAPPER_API BOOL SurfaceMesh3_EEK_GetHalfedge(void* ptr, int index, MeshHalfedge3& edge); CGALWRAPPER_API void SurfaceMesh3_EEK_GetHalfedges(void* ptr, MeshHalfedge3* edgeArray, int count); CGALWRAPPER_API void SurfaceMesh3_EEK_Transform(void* ptr, const Matrix4x4d& matrix); CGALWRAPPER_API BOOL SurfaceMesh3_EEK_IsVertexBorder(void* ptr, int index, BOOL check_all_incident_halfedges); CGALWRAPPER_API BOOL SurfaceMesh3_EEK_IsHalfedgeBorder(void* ptr, int index); CGALWRAPPER_API BOOL SurfaceMesh3_EEK_IsEdgeBorder(void* ptr, int index); CGALWRAPPER_API int SurfaceMesh3_EEK_BorderEdgeCount(void* ptr); CGALWRAPPER_API int SurfaceMesh3_EEK_IsClosed(void* ptr); CGALWRAPPER_API BOOL SurfaceMesh3_EEK_CheckFaceVertexCount(void* ptr, int count); CGALWRAPPER_API void SurfaceMesh3_EEK_Join(void* ptr, void* otherPtr); CGALWRAPPER_API void SurfaceMesh3_EEK_BuildAABBTree(void* ptr); CGALWRAPPER_API void SurfaceMesh3_EEK_ReleaseAABBTree(void* ptr); CGALWRAPPER_API Box3d SurfaceMesh3_EEK_GetBoundingBox(void* ptr); CGALWRAPPER_API void SurfaceMesh3_EEK_ReadOFF(void* ptr, const char* filename); CGALWRAPPER_API void SurfaceMesh3_EEK_WriteOFF(void* ptr, const char* filename); CGALWRAPPER_API void SurfaceMesh3_EEK_Triangulate(void* ptr); CGALWRAPPER_API BOOL SurfaceMesh3_EEK_DoesSelfIntersect(void* ptr); CGALWRAPPER_API double SurfaceMesh3_EEK_Area(void* ptr); CGALWRAPPER_API Point3d SurfaceMesh3_EEK_Centroid(void* ptr); CGALWRAPPER_API double SurfaceMesh3_EEK_Volume(void* ptr); CGALWRAPPER_API BOOL SurfaceMesh3_EEK_DoesBoundAVolume(void* ptr); CGALWRAPPER_API CGAL::Bounded_side SurfaceMesh3_EEK_SideOfTriangleMesh(void* ptr, const Point3d& point); CGALWRAPPER_API BOOL SurfaceMesh3_EEK_DoIntersects(void* ptr, void* otherPtr, BOOL test_bounded_sides); CGALWRAPPER_API void SurfaceMesh3_EEK_GetCentroids(void* ptr, Point3d* points, int count); CGALWRAPPER_API int SurfaceMesh3_EEK_PropertyMapCount(void* ptr); CGALWRAPPER_API void SurfaceMesh3_EEK_ComputeVertexNormals(void* ptr); CGALWRAPPER_API void SurfaceMesh3_EEK_ComputeFaceNormals(void* ptr); CGALWRAPPER_API void SurfaceMesh3_EEK_GetVertexNormals(void* ptr, Vector3d* normals, int count); CGALWRAPPER_API void SurfaceMesh3_EEK_GetFaceNormals(void* ptr, Vector3d* normals, int count); CGALWRAPPER_API PolygonalCount SurfaceMesh3_EEK_GetPolygonalCount(void* ptr); CGALWRAPPER_API PolygonalCount SurfaceMesh3_EEK_GetDualPolygonalCount(void* ptr); CGALWRAPPER_API void SurfaceMesh3_EEK_CreatePolygonMesh(void* ptr, Point2d* points, int count, BOOL xz); CGALWRAPPER_API void SurfaceMesh3_EEK_CreatePolygonalMesh(void* ptr, Point3d* points, int pointsCount, int* triangles, int triangleCount, int* quads, int quadCount, int* pentagons, int pentagonCount, int* hexagons, int hexagonCount); CGALWRAPPER_API void SurfaceMesh3_EEK_GetPolygonalIndices(void* ptr, int* triangles, int triangleCount, int* quads, int quadCount, int* pentagons, int pentagonCount, int* hexagons, int hexagonCount); CGALWRAPPER_API void SurfaceMesh3_EEK_GetDualPolygonalIndices(void* ptr, int* triangles, int triangleCount, int* quads, int quadCount, int* pentagons, int pentagonCount, int* hexagons, int hexagonCount); } ================================================ FILE: CGALWrapper/Polyhedra/SurfaceMesh3_EIK.cpp ================================================ #include "SurfaceMesh3_EIK.h" #include "SurfaceMesh3.h" #include void* SurfaceMesh3_EIK_Create() { return SurfaceMesh3::NewSurfaceMesh(); } void SurfaceMesh3_EIK_Release(void* ptr) { SurfaceMesh3::DeleteSurfaceMesh(ptr); } int SurfaceMesh3_EIK_GetBuildStamp(void* ptr) { return SurfaceMesh3::GetBuildStamp(ptr); } void SurfaceMesh3_EIK_Clear(void* ptr) { SurfaceMesh3::Clear(ptr); } void SurfaceMesh3_EIK_ClearIndexMaps(void* ptr, BOOL vertices, BOOL faces, BOOL edges, BOOL halfedges) { SurfaceMesh3::ClearIndexMaps(ptr, vertices, faces, edges, halfedges); } void SurfaceMesh3_EIK_ClearNormalMaps(void* ptr, BOOL vertices, BOOL faces) { SurfaceMesh3::ClearNormalMaps(ptr, vertices, faces); } void SurfaceMesh3_EIK_ClearProperyMaps(void* ptr) { SurfaceMesh3::ClearProperyMaps(ptr); } void SurfaceMesh3_EIK_BuildIndices(void* ptr, BOOL vertices, BOOL faces, BOOL edges, BOOL halfedges, BOOL force) { SurfaceMesh3::BuildIndices(ptr, vertices, faces, edges, halfedges, force); } void SurfaceMesh3_EIK_PrintIndices(void* ptr, BOOL vertices, BOOL faces, BOOL edges, BOOL halfedges, BOOL force) { SurfaceMesh3::PrintIndices(ptr, vertices, faces, edges, halfedges, force); } void* SurfaceMesh3_EIK_Copy(void* ptr) { return SurfaceMesh3::Copy(ptr); } BOOL SurfaceMesh3_EIK_IsValid(void* ptr) { return SurfaceMesh3::IsValid(ptr); } int SurfaceMesh3_EIK_VertexCount(void* ptr) { return SurfaceMesh3::VertexCount(ptr); } int SurfaceMesh3_EIK_HalfedgeCount(void* ptr) { return SurfaceMesh3::HalfedgeCount(ptr); } int SurfaceMesh3_EIK_EdgeCount(void* ptr) { return SurfaceMesh3::EdgeCount(ptr); } int SurfaceMesh3_EIK_FaceCount(void* ptr) { return SurfaceMesh3::FaceCount(ptr); } int SurfaceMesh3_EIK_RemovedVertexCount(void* ptr) { return SurfaceMesh3::RemovedVertexCount(ptr); } int SurfaceMesh3_EIK_RemovedHalfedgeCount(void* ptr) { return SurfaceMesh3::RemovedHalfedgeCount(ptr); } int SurfaceMesh3_EIK_RemovedEdgeCount(void* ptr) { return SurfaceMesh3::RemovedEdgeCount(ptr); } int SurfaceMesh3_EIK_RemovedFaceCount(void* ptr) { return SurfaceMesh3::RemovedFaceCount(ptr); } BOOL SurfaceMesh3_EIK_IsVertexRemoved(void* ptr, int index) { return SurfaceMesh3::IsVertexRemoved(ptr, index); } BOOL SurfaceMesh3_EIK_IsFaceRemoved(void* ptr, int index) { return SurfaceMesh3::IsFaceRemoved(ptr, index); } BOOL SurfaceMesh3_EIK_IsHalfedgeRemoved(void* ptr, int index) { return SurfaceMesh3::IsHalfedgeRemoved(ptr, index); } BOOL SurfaceMesh3_EIK_IsEdgeRemoved(void* ptr, int index) { return SurfaceMesh3::IsEdgeRemoved(ptr, index); } int SurfaceMesh3_EIK_AddVertex(void* ptr, Point3d point) { return SurfaceMesh3::AddVertex(ptr, point); } int SurfaceMesh3_EIK_AddEdge(void* ptr, int v0, int v1) { return SurfaceMesh3::AddEdge(ptr, v0, v1); } int SurfaceMesh3_EIK_AddTriangle(void* ptr, int v0, int v1, int v2) { return SurfaceMesh3::AddTriangle(ptr, v0, v1, v2); } int SurfaceMesh3_EIK_AddQuad(void* ptr, int v0, int v1, int v2, int v3) { return SurfaceMesh3::AddQuad(ptr, v0, v1, v2, v3); } int SurfaceMesh3_EIK_AddPentagon(void* ptr, int v0, int v1, int v2, int v3, int v4) { return SurfaceMesh3::AddPentagon(ptr, v0, v1, v2, v3, v4); } int SurfaceMesh3_EIK_AddHexagon(void* ptr, int v0, int v1, int v2, int v3, int v4, int v5) { return SurfaceMesh3::AddHexagon(ptr, v0, v1, v2, v3, v4, v5); } int SurfaceMesh3_EIK_AddFace(void* ptr, int* indices, int count) { return SurfaceMesh3::AddFace(ptr, indices, count); } BOOL SurfaceMesh3_EIK_HasGarbage(void* ptr) { return SurfaceMesh3::HasGarbage(ptr); } void SurfaceMesh3_EIK_CollectGarbage(void* ptr) { SurfaceMesh3::CollectGarbage(ptr); } void SurfaceMesh3_EIK_SetRecycleGarbage(void* ptr, BOOL collect) { SurfaceMesh3::SetRecycleGarbage(ptr, collect); } BOOL SurfaceMesh3_EIK_DoesRecycleGarbage(void* ptr) { return SurfaceMesh3::DoesRecycleGarbage(ptr); } int SurfaceMesh3_EIK_VertexDegree(void* ptr, int index) { return SurfaceMesh3::VertexDegree(ptr, index); } int SurfaceMesh3_EIK_FaceDegree(void* ptr, int index) { return SurfaceMesh3::FaceDegree(ptr, index); } BOOL SurfaceMesh3_EIK_VertexIsIsolated(void* ptr, int index) { return SurfaceMesh3::VertexIsIsolated(ptr, index); } BOOL SurfaceMesh3_EIK_VertexIsBorder(void* ptr, int index, BOOL check_all_incident_halfedges) { return SurfaceMesh3::VertexIsBorder(ptr, index, check_all_incident_halfedges); } BOOL SurfaceMesh3_EIK_EdgeIsBorder(void* ptr, int index) { return SurfaceMesh3::EdgeIsBorder(ptr, index); } int SurfaceMesh3_EIK_NextHalfedge(void* ptr, int index) { return SurfaceMesh3::NextHalfedge(ptr, index); } int SurfaceMesh3_EIK_PreviousHalfedge(void* ptr, int index) { return SurfaceMesh3::PreviousHalfedge(ptr, index); } int SurfaceMesh3_EIK_OppositeHalfedge(void* ptr, int index) { return SurfaceMesh3::OppositeHalfedge(ptr, index); } int SurfaceMesh3_EIK_SourceVertex(void* ptr, int index) { return SurfaceMesh3::SourceVertex(ptr, index); } int SurfaceMesh3_EIK_TargetVertex(void* ptr, int index) { return SurfaceMesh3::TargetVertex(ptr, index); } int SurfaceMesh3_EIK_NextAroundSource(void* ptr, int index) { return SurfaceMesh3::NextAroundSource(ptr, index); } int SurfaceMesh3_EIK_NextAroundTarget(void* ptr, int index) { return SurfaceMesh3::NextAroundTarget(ptr, index); } int SurfaceMesh3_EIK_PreviousAroundSource(void* ptr, int index) { return SurfaceMesh3::PreviousAroundSource(ptr, index); } int SurfaceMesh3_EIK_PreviousAroundTarget(void* ptr, int index) { return SurfaceMesh3::PreviousAroundTarget(ptr, index); } int SurfaceMesh3_EIK_EdgesHalfedge(void* ptr, int edgeIndex, int halfedgeIndex) { return SurfaceMesh3::EdgesHalfedge(ptr, edgeIndex, halfedgeIndex); } int SurfaceMesh3_EIK_HalfedgesEdge(void* ptr, int index) { return SurfaceMesh3::HalfedgesEdge(ptr, index); } BOOL SurfaceMesh3_EIK_RemoveVertex(void* ptr, int index) { return SurfaceMesh3::RemoveVertex(ptr, index); } BOOL SurfaceMesh3_EIK_RemoveEdge(void* ptr, int index) { return SurfaceMesh3::RemoveEdge(ptr, index); } BOOL SurfaceMesh3_EIK_RemoveFace(void* ptr, int index) { return SurfaceMesh3::RemoveFace(ptr, index); } BOOL SurfaceMesh3_EIK_IsVertexValid(void* ptr, int index) { return SurfaceMesh3::IsVertexValid(ptr, index); } BOOL SurfaceMesh3_EIK_IsEdgeValid(void* ptr, int index) { return SurfaceMesh3::IsEdgeValid(ptr, index); } BOOL SurfaceMesh3_EIK_IsHalfedgeValid(void* ptr, int index) { return SurfaceMesh3::IsHalfedgeValid(ptr, index); } BOOL SurfaceMesh3_EIK_IsFaceValid(void* ptr, int index) { return SurfaceMesh3::IsFaceValid(ptr, index); } Point3d SurfaceMesh3_EIK_GetPoint(void* ptr, int index) { return SurfaceMesh3::GetPoint(ptr, index); } void SurfaceMesh3_EIK_GetPoints(void* ptr, Point3d* points, int count) { SurfaceMesh3::GetPoints(ptr, points, count); } void SurfaceMesh3_EIK_SetPoint(void* ptr, int index, const Point3d& point) { SurfaceMesh3::SetPoint(ptr, index, point); } void SurfaceMesh3_EIK_SetPoints(void* ptr, Point3d* points, int count) { SurfaceMesh3::SetPoints(ptr, points, count); } BOOL SurfaceMesh3_EIK_GetSegment(void* ptr, int index, Segment3d& segment) { return SurfaceMesh3::GetSegment(ptr, index, segment); } void SurfaceMesh3_EIK_GetSegments(void* ptr, Segment3d* segments, int count) { SurfaceMesh3::GetSegments(ptr, segments, count); } BOOL SurfaceMesh3_EIK_GetTriangle(void* ptr, int index, Triangle3d& tri) { return SurfaceMesh3::GetTriangle(ptr, index, tri); } void SurfaceMesh3_EIK_GetTriangles(void* ptr, Triangle3d* triangles, int count) { SurfaceMesh3::GetTriangles(ptr, triangles, count); } BOOL SurfaceMesh3_EIK_GetVertex(void* ptr, int index, MeshVertex3& vert) { return SurfaceMesh3::GetVertex(ptr, index, vert); } void SurfaceMesh3_EIK_GetVertices(void* ptr, MeshVertex3* vertexArray, int count) { SurfaceMesh3::GetVertices(ptr, vertexArray, count); } BOOL SurfaceMesh3_EIK_GetFace(void* ptr, int index, MeshFace3& face) { return SurfaceMesh3::GetFace(ptr, index, face); } void SurfaceMesh3_EIK_GetFaces(void* ptr, MeshFace3* faceArray, int count) { SurfaceMesh3::GetFaces(ptr, faceArray, count); } BOOL SurfaceMesh3_EIK_GetHalfedge(void* ptr, int index, MeshHalfedge3& edge) { return SurfaceMesh3::GetHalfedge(ptr, index, edge); } void SurfaceMesh3_EIK_GetHalfedges(void* ptr, MeshHalfedge3* edgeArray, int count) { SurfaceMesh3::GetHalfedges(ptr, edgeArray, count); } void SurfaceMesh3_EIK_Transform(void* ptr, const Matrix4x4d& matrix) { SurfaceMesh3::Transform(ptr, matrix); } BOOL SurfaceMesh3_EIK_IsVertexBorder(void* ptr, int index, BOOL check_all_incident_halfedges) { return SurfaceMesh3::IsVertexBorder(ptr, index, check_all_incident_halfedges); } BOOL SurfaceMesh3_EIK_IsHalfedgeBorder(void* ptr, int index) { return SurfaceMesh3::IsHalfedgeBorder(ptr, index); } BOOL SurfaceMesh3_EIK_IsEdgeBorder(void* ptr, int index) { return SurfaceMesh3::IsEdgeBorder(ptr, index); } int SurfaceMesh3_EIK_BorderEdgeCount(void* ptr) { return SurfaceMesh3::BorderEdgeCount(ptr); } BOOL SurfaceMesh3_EIK_IsClosed(void* ptr) { return SurfaceMesh3::IsClosed(ptr); } void SurfaceMesh3_EIK_Join(void* ptr, void* otherPtr) { SurfaceMesh3::Join(ptr, otherPtr); } void SurfaceMesh3_EIK_BuildAABBTree(void* ptr) { SurfaceMesh3::BuildAABBTree(ptr); } void SurfaceMesh3_EIK_ReleaseAABBTree(void* ptr) { SurfaceMesh3::ReleaseAABBTree(ptr); } Box3d SurfaceMesh3_EIK_GetBoundingBox(void* ptr) { return SurfaceMesh3::GetBoundingBox(ptr); } void SurfaceMesh3_EIK_ReadOFF(void* ptr, const char* filename) { SurfaceMesh3::ReadOFF(ptr, filename); } void SurfaceMesh3_EIK_WriteOFF(void* ptr, const char* filename) { SurfaceMesh3::WriteOFF(ptr, filename); } void SurfaceMesh3_EIK_Triangulate(void* ptr) { SurfaceMesh3::Triangulate(ptr); } BOOL SurfaceMesh3_EIK_DoesSelfIntersect(void* ptr) { return SurfaceMesh3::DoesSelfIntersect(ptr); } double SurfaceMesh3_EIK_Area(void* ptr) { return SurfaceMesh3::Area(ptr); } Point3d SurfaceMesh3_EIK_Centroid(void* ptr) { return SurfaceMesh3::Centroid(ptr); } double SurfaceMesh3_EIK_Volume(void* ptr) { return SurfaceMesh3::Volume(ptr); } BOOL SurfaceMesh3_EIK_DoesBoundAVolume(void* ptr) { return SurfaceMesh3::DoesBoundAVolume(ptr); } CGAL::Bounded_side SurfaceMesh3_EIK_SideOfTriangleMesh(void* ptr, const Point3d& point) { return SurfaceMesh3::SideOfTriangleMesh(ptr, point); } BOOL SurfaceMesh3_EIK_DoIntersects(void* ptr, void* otherPtr, BOOL test_bounded_sides) { return SurfaceMesh3::DoIntersects(ptr, otherPtr, test_bounded_sides); } void SurfaceMesh3_EIK_GetCentroids(void* ptr, Point3d* points, int count) { SurfaceMesh3::GetCentroids(ptr, points, count); } int SurfaceMesh3_EIK_PropertyMapCount(void* ptr) { return SurfaceMesh3::PropertyMapCount(ptr); } void SurfaceMesh3_EIK_ComputeVertexNormals(void* ptr) { SurfaceMesh3::ComputeVertexNormals(ptr); } void SurfaceMesh3_EIK_ComputeFaceNormals(void* ptr) { SurfaceMesh3::ComputeFaceNormals(ptr); } void SurfaceMesh3_EIK_GetVertexNormals(void* ptr, Vector3d* normals, int count) { SurfaceMesh3::GetVertexNormals(ptr, normals, count); } void SurfaceMesh3_EIK_GetFaceNormals(void* ptr, Vector3d* normals, int count) { SurfaceMesh3::GetFaceNormals(ptr, normals, count); } BOOL SurfaceMesh3_EIK_CheckFaceVertexCount(void* ptr, int count) { return SurfaceMesh3::CheckFaceVertexCount(ptr, count); } PolygonalCount SurfaceMesh3_EIK_GetPolygonalCount(void* ptr) { return SurfaceMesh3::GetPolygonalCount(ptr); } PolygonalCount SurfaceMesh3_EIK_GetDualPolygonalCount(void* ptr) { return SurfaceMesh3::GetDualPolygonalCount(ptr); } void SurfaceMesh3_EIK_CreatePolygonMesh(void* ptr, Point2d* points, int count, BOOL xz) { SurfaceMesh3::CreatePolygonMesh(ptr, points, count, xz); } void SurfaceMesh3_EIK_CreatePolygonalMesh(void* ptr, Point3d* points, int pointsCount, int* triangles, int triangleCount, int* quads, int quadCount, int* pentagons, int pentagonCount, int* hexagons, int hexagonCount) { SurfaceMesh3::CreatePolygonalMesh(ptr, points, pointsCount, triangles, triangleCount, quads, quadCount, pentagons, pentagonCount, hexagons, hexagonCount); } void SurfaceMesh3_EIK_GetPolygonalIndices(void* ptr, int* triangles, int triangleCount, int* quads, int quadCount, int* pentagons, int pentagonCount, int* hexagons, int hexagonCount) { SurfaceMesh3::GetPolygonalIndices(ptr, triangles, triangleCount, quads, quadCount, pentagons, pentagonCount, hexagons, hexagonCount); } void SurfaceMesh3_EIK_GetDualPolygonalIndices(void* ptr, int* triangles, int triangleCount, int* quads, int quadCount, int* pentagons, int pentagonCount, int* hexagons, int hexagonCount) { SurfaceMesh3::GetDualPolygonalIndices(ptr, triangles, triangleCount, quads, quadCount, pentagons, pentagonCount, hexagons, hexagonCount); } ================================================ FILE: CGALWrapper/Polyhedra/SurfaceMesh3_EIK.h ================================================ #pragma once #include "../CGALWrapper.h" #include "../Geometry/Geometry2.h" #include "../Geometry/Geometry3.h" #include "../Geometry/Matrices.h" #include "../Geometry/MinMax.h" #include "PolygonalCount.h" #include "MeshVertex3.h" #include "MeshFace3.h" #include "MeshHalfedge3.h" extern "C" { CGALWRAPPER_API void* SurfaceMesh3_EIK_Create(); CGALWRAPPER_API void SurfaceMesh3_EIK_Release(void* ptr); CGALWRAPPER_API int SurfaceMesh3_EIK_GetBuildStamp(void* ptr); CGALWRAPPER_API void SurfaceMesh3_EIK_Clear(void* ptr); CGALWRAPPER_API void SurfaceMesh3_EIK_ClearIndexMaps(void* ptr, BOOL vertices, BOOL faces, BOOL edges, BOOL halfedges); CGALWRAPPER_API void SurfaceMesh3_EIK_ClearNormalMaps(void* ptr, BOOL vertices, BOOL faces); CGALWRAPPER_API void SurfaceMesh3_EIK_ClearProperyMaps(void* ptr); CGALWRAPPER_API void SurfaceMesh3_EIK_BuildIndices(void* ptr, BOOL vertices, BOOL faces, BOOL edges, BOOL halfedges, BOOL force); CGALWRAPPER_API void SurfaceMesh3_EIK_PrintIndices(void* ptr, BOOL vertices, BOOL faces, BOOL edges, BOOL halfedges, BOOL force); CGALWRAPPER_API void* SurfaceMesh3_EIK_Copy(void* ptr); CGALWRAPPER_API BOOL SurfaceMesh3_EIK_IsValid(void* ptr); CGALWRAPPER_API BOOL SurfaceMesh3_EIK_IsVertexValid(void* ptr, int index); CGALWRAPPER_API BOOL SurfaceMesh3_EIK_IsFaceValid(void* ptr, int index); CGALWRAPPER_API BOOL SurfaceMesh3_EIK_IsHalfedgeValid(void* ptr, int index); CGALWRAPPER_API BOOL SurfaceMesh3_EIK_IsEdgeValid(void* ptr, int index); CGALWRAPPER_API int SurfaceMesh3_EIK_VertexCount(void* ptr); CGALWRAPPER_API int SurfaceMesh3_EIK_HalfedgeCount(void* ptr); CGALWRAPPER_API int SurfaceMesh3_EIK_EdgeCount(void* ptr); CGALWRAPPER_API int SurfaceMesh3_EIK_FaceCount(void* ptr); CGALWRAPPER_API int SurfaceMesh3_EIK_RemovedVertexCount(void* ptr); CGALWRAPPER_API int SurfaceMesh3_EIK_RemovedHalfedgeCount(void* ptr); CGALWRAPPER_API int SurfaceMesh3_EIK_RemovedEdgeCount(void* ptr); CGALWRAPPER_API int SurfaceMesh3_EIK_RemovedFaceCount(void* ptr); CGALWRAPPER_API BOOL SurfaceMesh3_EIK_IsVertexRemoved(void* ptr, int index); CGALWRAPPER_API BOOL SurfaceMesh3_EIK_IsFaceRemoved(void* ptr, int index); CGALWRAPPER_API BOOL SurfaceMesh3_EIK_IsHalfedgeRemoved(void* ptr, int index); CGALWRAPPER_API BOOL SurfaceMesh3_EIK_IsEdgeRemoved(void* ptr, int index); CGALWRAPPER_API int SurfaceMesh3_EIK_AddVertex(void* ptr, Point3d point); CGALWRAPPER_API int SurfaceMesh3_EIK_AddEdge(void* ptr, int v0, int v1); CGALWRAPPER_API int SurfaceMesh3_EIK_AddTriangle(void* ptr, int v0, int v1, int v2); CGALWRAPPER_API int SurfaceMesh3_EIK_AddQuad(void* ptr, int v0, int v1, int v2, int v3); CGALWRAPPER_API int SurfaceMesh3_EIK_AddPentagon(void* ptr, int v0, int v1, int v2, int v3, int v4); CGALWRAPPER_API int SurfaceMesh3_EIK_AddHexagon(void* ptr, int v0, int v1, int v2, int v3, int v4, int v5); CGALWRAPPER_API int SurfaceMesh3_EIK_AddFace(void* ptr, int* indices, int count); CGALWRAPPER_API BOOL SurfaceMesh3_EIK_HasGarbage(void* ptr); CGALWRAPPER_API void SurfaceMesh3_EIK_CollectGarbage(void* ptr); CGALWRAPPER_API void SurfaceMesh3_EIK_SetRecycleGarbage(void* ptr, BOOL collect); CGALWRAPPER_API BOOL SurfaceMesh3_EIK_DoesRecycleGarbage(void* ptr); CGALWRAPPER_API int SurfaceMesh3_EIK_VertexDegree(void* ptr, int index); CGALWRAPPER_API int SurfaceMesh3_EIK_FaceDegree(void* ptr, int index); CGALWRAPPER_API BOOL SurfaceMesh3_EIK_VertexIsIsolated(void* ptr, int index); CGALWRAPPER_API BOOL SurfaceMesh3_EIK_VertexIsBorder(void* ptr, int index, BOOL check_all_incident_halfedges); CGALWRAPPER_API BOOL SurfaceMesh3_EIK_EdgeIsBorder(void* ptr, int index); CGALWRAPPER_API int SurfaceMesh3_EIK_NextHalfedge(void* ptr, int index); CGALWRAPPER_API int SurfaceMesh3_EIK_PreviousHalfedge(void* ptr, int index); CGALWRAPPER_API int SurfaceMesh3_EIK_OppositeHalfedge(void* ptr, int index); CGALWRAPPER_API int SurfaceMesh3_EIK_SourceVertex(void* ptr, int index); CGALWRAPPER_API int SurfaceMesh3_EIK_TargetVertex(void* ptr, int index); CGALWRAPPER_API int SurfaceMesh3_EIK_NextAroundSource(void* ptr, int index); CGALWRAPPER_API int SurfaceMesh3_EIK_NextAroundTarget(void* ptr, int index); CGALWRAPPER_API int SurfaceMesh3_EIK_PreviousAroundSource(void* ptr, int index); CGALWRAPPER_API int SurfaceMesh3_EIK_PreviousAroundTarget(void* ptr, int index); CGALWRAPPER_API int SurfaceMesh3_EIK_EdgesHalfedge(void* ptr, int edgeIndex, int halfedgeIndex); CGALWRAPPER_API int SurfaceMesh3_EIK_HalfedgesEdge(void* ptr, int index); CGALWRAPPER_API BOOL SurfaceMesh3_EIK_RemoveVertex(void* ptr, int index); CGALWRAPPER_API BOOL SurfaceMesh3_EIK_RemoveEdge(void* ptr, int index); CGALWRAPPER_API BOOL SurfaceMesh3_EIK_RemoveFace(void* ptr, int index); CGALWRAPPER_API Point3d SurfaceMesh3_EIK_GetPoint(void* ptr, int index); CGALWRAPPER_API void SurfaceMesh3_EIK_GetPoints(void* ptr, Point3d* points, int count); CGALWRAPPER_API void SurfaceMesh3_EIK_SetPoint(void* ptr, int index, const Point3d& point); CGALWRAPPER_API void SurfaceMesh3_EIK_SetPoints(void* ptr, Point3d* points, int count); CGALWRAPPER_API BOOL SurfaceMesh3_EIK_GetSegment(void* ptr, int index, Segment3d& segment); CGALWRAPPER_API void SurfaceMesh3_EIK_GetSegments(void* ptr, Segment3d* segments, int count); CGALWRAPPER_API BOOL SurfaceMesh3_EIK_GetTriangle(void* ptr, int index, Triangle3d& tri); CGALWRAPPER_API void SurfaceMesh3_EIK_GetTriangles(void* ptr, Triangle3d* triangles, int count); CGALWRAPPER_API BOOL SurfaceMesh3_EIK_GetVertex(void* ptr, int index, MeshVertex3& vert); CGALWRAPPER_API void SurfaceMesh3_EIK_GetVertices(void* ptr, MeshVertex3* vertexArray, int count); CGALWRAPPER_API BOOL SurfaceMesh3_EIK_GetFace(void* ptr, int index, MeshFace3& face); CGALWRAPPER_API void SurfaceMesh3_EIK_GetFaces(void* ptr, MeshFace3* faceArray, int count); CGALWRAPPER_API BOOL SurfaceMesh3_EIK_GetHalfedge(void* ptr, int index, MeshHalfedge3& edge); CGALWRAPPER_API void SurfaceMesh3_EIK_GetHalfedges(void* ptr, MeshHalfedge3* edgeArray, int count); CGALWRAPPER_API void SurfaceMesh3_EIK_Transform(void* ptr, const Matrix4x4d& matrix); CGALWRAPPER_API BOOL SurfaceMesh3_EIK_IsVertexBorder(void* ptr, int index, BOOL check_all_incident_halfedges); CGALWRAPPER_API BOOL SurfaceMesh3_EIK_IsHalfedgeBorder(void* ptr, int index); CGALWRAPPER_API BOOL SurfaceMesh3_EIK_IsEdgeBorder(void* ptr, int index); CGALWRAPPER_API int SurfaceMesh3_EIK_BorderEdgeCount(void* ptr); CGALWRAPPER_API int SurfaceMesh3_EIK_IsClosed(void* ptr); CGALWRAPPER_API BOOL SurfaceMesh3_EIK_CheckFaceVertexCount(void* ptr, int count); CGALWRAPPER_API void SurfaceMesh3_EIK_Join(void* ptr, void* otherPtr); CGALWRAPPER_API void SurfaceMesh3_EIK_BuildAABBTree(void* ptr); CGALWRAPPER_API void SurfaceMesh3_EIK_ReleaseAABBTree(void* ptr); CGALWRAPPER_API Box3d SurfaceMesh3_EIK_GetBoundingBox(void* ptr); CGALWRAPPER_API void SurfaceMesh3_EIK_ReadOFF(void* ptr, const char* filename); CGALWRAPPER_API void SurfaceMesh3_EIK_WriteOFF(void* ptr, const char* filename); CGALWRAPPER_API void SurfaceMesh3_EIK_Triangulate(void* ptr); CGALWRAPPER_API BOOL SurfaceMesh3_EIK_DoesSelfIntersect(void* ptr); CGALWRAPPER_API double SurfaceMesh3_EIK_Area(void* ptr); CGALWRAPPER_API Point3d SurfaceMesh3_EIK_Centroid(void* ptr); CGALWRAPPER_API double SurfaceMesh3_EIK_Volume(void* ptr); CGALWRAPPER_API BOOL SurfaceMesh3_EIK_DoesBoundAVolume(void* ptr); CGALWRAPPER_API CGAL::Bounded_side SurfaceMesh3_EIK_SideOfTriangleMesh(void* ptr, const Point3d& point); CGALWRAPPER_API BOOL SurfaceMesh3_EIK_DoIntersects(void* ptr, void* otherPtr, BOOL test_bounded_sides); CGALWRAPPER_API void SurfaceMesh3_EIK_GetCentroids(void* ptr, Point3d* points, int count); CGALWRAPPER_API int SurfaceMesh3_EIK_PropertyMapCount(void* ptr); CGALWRAPPER_API void SurfaceMesh3_EIK_ComputeVertexNormals(void* ptr); CGALWRAPPER_API void SurfaceMesh3_EIK_ComputeFaceNormals(void* ptr); CGALWRAPPER_API void SurfaceMesh3_EIK_GetVertexNormals(void* ptr, Vector3d* normals, int count); CGALWRAPPER_API void SurfaceMesh3_EIK_GetFaceNormals(void* ptr, Vector3d* normals, int count); CGALWRAPPER_API PolygonalCount SurfaceMesh3_EIK_GetPolygonalCount(void* ptr); CGALWRAPPER_API PolygonalCount SurfaceMesh3_EIK_GetDualPolygonalCount(void* ptr); CGALWRAPPER_API void SurfaceMesh3_EIK_CreatePolygonMesh(void* ptr, Point2d* points, int count, BOOL xz); CGALWRAPPER_API void SurfaceMesh3_EIK_CreatePolygonalMesh(void* ptr, Point3d* points, int pointsCount, int* triangles, int triangleCount, int* quads, int quadCount, int* pentagons, int pentagonCount, int* hexagons, int hexagonCount); CGALWRAPPER_API void SurfaceMesh3_EIK_GetPolygonalIndices(void* ptr, int* triangles, int triangleCount, int* quads, int quadCount, int* pentagons, int pentagonCount, int* hexagons, int hexagonCount); CGALWRAPPER_API void SurfaceMesh3_EIK_GetDualPolygonalIndices(void* ptr, int* triangles, int triangleCount, int* quads, int quadCount, int* pentagons, int pentagonCount, int* hexagons, int hexagonCount); } ================================================ FILE: CGALWrapper/Polyhedra/SurfaceMeshMap.h ================================================ #pragma once #include "../CGALWrapper.h" #include "SurfaceMesh3.h" #include #include template class SurfaceMeshMap { private: typedef typename K::Point_3 Point_3; typedef typename CGAL::Surface_mesh SurfaceMesh; typedef typename SurfaceMesh::Edge_index Edge; typedef typename SurfaceMesh::Halfedge_index Halfedge; typedef typename SurfaceMesh::Vertex_index Vertex; typedef typename SurfaceMesh::Face_index Face; int buildStamp = 1; std::unordered_map vertexIndexMap; std::vector vertexMap; bool rebuildVertexIndexMap = true; std::unordered_map faceIndexMap; std::vector faceMap; bool rebuildFaceIndexMap = true; std::unordered_map edgeIndexMap; std::vector edgeMap; bool rebuildEdgeIndexMap = true; std::unordered_map halfedgeIndexMap; std::vector halfedgeMap; bool rebuildHalfedgeIndexMap = true; public: int VertexCount() { return (int)vertexMap.size(); } int FaceCount() { return (int)faceMap.size(); } int EdgeCount() { return (int)edgeMap.size(); } int HalfedgeCount() { return (int)halfedgeMap.size(); } int BuildStamp() { return buildStamp; } void OnVerticesChanged() { vertexMap.clear(); vertexMap.reserve(0); vertexIndexMap.clear(); vertexIndexMap.reserve(0); rebuildVertexIndexMap = true; buildStamp++; } void OnFacesChanged() { faceMap.clear(); faceMap.reserve(0); faceIndexMap.clear(); faceIndexMap.reserve(0); rebuildFaceIndexMap = true; buildStamp++; } void OnEdgesChanged() { edgeMap.clear(); edgeMap.reserve(0); edgeIndexMap.clear(); edgeIndexMap.reserve(0); rebuildEdgeIndexMap = true; buildStamp++; } void OnHalfedgesChanged() { halfedgeMap.clear(); halfedgeMap.reserve(0); halfedgeIndexMap.clear(); halfedgeIndexMap.reserve(0); rebuildHalfedgeIndexMap = true; buildStamp++; } void Clear() { OnVerticesChanged(); OnFacesChanged(); OnEdgesChanged(); OnHalfedgesChanged(); } void BuildVertexMaps(const SurfaceMesh& model, bool force = false) { if (!force && !rebuildVertexIndexMap) return; rebuildVertexIndexMap = false; vertexMap.clear(); vertexMap.reserve(model.number_of_vertices()); vertexIndexMap.clear(); int index = 0; for (auto vertex : model.vertices()) { //std::cout << "Vetex = " << vertex<< " Index " << index << std::endl; vertexMap.push_back(vertex); vertexIndexMap.insert(std::pair(vertex, index)); index++; } } void BuildFaceMaps(const SurfaceMesh& model, bool force = false) { if (!force && !rebuildFaceIndexMap) return; rebuildFaceIndexMap = false; faceMap.clear(); faceMap.reserve(model.number_of_faces()); faceIndexMap.clear(); int index = 0; for (auto face : model.faces()) { //std::cout << "Face = " << face << " Index " << index << std::endl; faceMap.push_back(face); faceIndexMap.insert(std::pair(face, index)); index++; } } void BuildEdgeMaps(const SurfaceMesh& model, bool force = false) { if (!force && !rebuildEdgeIndexMap) return; rebuildEdgeIndexMap = false; edgeMap.clear(); edgeMap.reserve(model.number_of_edges()); edgeIndexMap.clear(); int index = 0; for (auto edge : model.edges()) { //std::cout << "Edge = " << edge << " Index " << index << std::endl; edgeMap.push_back(edge); edgeIndexMap.insert(std::pair(edge, index)); index++; } } void BuildHalfedgeMaps(const SurfaceMesh& model, bool force = false) { if (!force && !rebuildHalfedgeIndexMap) return; rebuildHalfedgeIndexMap = false; halfedgeMap.clear(); halfedgeMap.reserve(model.number_of_halfedges()); halfedgeIndexMap.clear(); int index = 0; for (auto edge : model.halfedges()) { //std::cout << "Halfedge = " << edge << " Index " << index << std::endl; halfedgeMap.push_back(edge); halfedgeIndexMap.insert(std::pair(edge, index)); index++; } } int FindVertexIndex(Vertex vertex) { auto item = vertexIndexMap.find(vertex); if (item != vertexIndexMap.end()) return item->second; else return NULL_INDEX; } Vertex FindVertex(int index) { int count = (int)vertexMap.size(); if (index < 0 || index >= count) return SurfaceMesh::null_vertex(); return Vertex(vertexMap[index]); } Vertex GetVertex(int index) { return Vertex(vertexMap[index]); } int FindFaceIndex(Face face) { auto item = faceIndexMap.find(face); if (item != faceIndexMap.end()) return item->second; else return NULL_INDEX; } Face FindFace(int index) { int count = (int)faceMap.size(); if (index < 0 || index >= count) return SurfaceMesh::null_face(); return Face(faceMap[index]); } Face GetFace(int index) { return Face(faceMap[index]); } int FindEdgeIndex(Edge edge) { auto item = edgeIndexMap.find(edge); if (item != edgeIndexMap.end()) return item->second; else return NULL_INDEX; } Edge FindEdge(int index) { int count = (int)edgeMap.size(); if (index < 0 || index >= count) return SurfaceMesh::null_edge(); return Edge(edgeMap[index]); } Edge GetEdge(int index) { return Edge(edgeMap[index]); } int FindHalfedgeIndex(Halfedge edge) { auto item = halfedgeIndexMap.find(edge); if (item != halfedgeIndexMap.end()) return item->second; else return NULL_INDEX; } Halfedge FindHalfedge(int index) { int count = (int)halfedgeMap.size(); if (index < 0 || index >= count) return SurfaceMesh::null_halfedge(); return Halfedge(halfedgeMap[index]); } Halfedge GetHalfedge(int index) { return Halfedge(halfedgeMap[index]); } void PrintVertices(const SurfaceMesh& model) { std::cout << "Vertex indices" << std::endl; for (auto vertex : model.vertices()) { int index = FindVertexIndex(vertex); if (index == NULL_INDEX) { std::cout << "Vertex = " << vertex << ", Index = " << index << std::endl; } else { auto point = model.point(vertex); std::cout << "Vertex = " << vertex << ", Index = " << index << ", Point = " << point << std::endl; } } } void PrintFaces(const SurfaceMesh& model) { std::cout << "Face indices" << std::endl; for (auto face : model.faces()) { std::cout << "Face = " << face << ", Index = " << FindFaceIndex(face) << std::endl; } } void PrintEdges(const SurfaceMesh& model) { std::cout << "Edges indices" << std::endl; for (auto edge : model.edges()) { std::cout << "Edge = " << edge << ", Index = " << FindEdgeIndex(edge) << std::endl; } } void PrintHalfedges(const SurfaceMesh& model) { std::cout << "Halfedges indices" << std::endl; for (auto edge : model.halfedges()) { std::cout << "Halfedge = " << edge << ", Index = " << FindHalfedgeIndex(edge) << std::endl; } } }; ================================================ FILE: CGALWrapper/Polylines/Polyline2.h ================================================ #pragma once #include "../CGALWrapper.h" #include "../Geometry/Geometry2.h" #include #include #include #include #include template class Polyline2 { public: Polyline2() { } Polyline2(int count) { points.resize(count); } typedef CGAL::Point_2 Point_2; typedef CGAL::Segment_2 Segment_2; typedef CGAL::Aff_transformation_2 Transformation_2; std::vector points; inline static Polyline2* NewPolyline2() { return new Polyline2(); } inline static Polyline2* NewPolyline2(int count) { return new Polyline2(count); } inline static void DeletePolyline2(void* ptr) { auto obj = static_cast(ptr); if (obj != nullptr) { delete obj; obj = nullptr; } } inline static Polyline2* CastToPolyline2(void* ptr) { return static_cast(ptr); } inline bool OutOfRange(int index) { if (index < 0 || index >= points.size()) return true; else return false; } static void* Copy(void* ptr) { auto polyline = CastToPolyline2(ptr); auto copy = new Polyline2(); copy->points = polyline->points; return copy; } template static void* Convert(void* ptr) { typedef CGAL::Cartesian_converter Converter; Converter convert; auto polyline = CastToPolyline2(ptr); auto count = polyline->points.size(); auto polyline2 = new Polyline2(); for (auto i = 0; i < count; i++) { auto p = convert(polyline->points[i]); polyline2->points.push_back(p); } return polyline2; } static void Clear(void* ptr) { auto polyline = CastToPolyline2(ptr); polyline->points.clear(); } static int Count(void* ptr) { auto polyline = CastToPolyline2(ptr); return (int)polyline->points.size(); } static int Capacity(void* ptr) { auto polyline = CastToPolyline2(ptr); return (int)polyline->points.capacity(); } static void Resize(void* ptr, int count) { auto polyline = CastToPolyline2(ptr); polyline->points.resize(count); } static void Reverse(void* ptr) { auto polyline = CastToPolyline2(ptr); std::reverse(polyline->points.begin(), polyline->points.end()); } static void ShrinkToFit(void* ptr) { auto polyline = CastToPolyline2(ptr); polyline->points.shrink_to_fit(); } static void Erase(void* ptr, int index) { auto polyline = CastToPolyline2(ptr); if (polyline->OutOfRange(index)) return; polyline->points.erase(polyline->points.begin() + index); } static void Erase(void* ptr, int start, int count) { auto polyline = CastToPolyline2(ptr); if (polyline->OutOfRange(start) || polyline->OutOfRange(start + count)) return; polyline->points.erase(polyline->points.begin() + start, polyline->points.begin() + count); } static void Insert(void* ptr, int index, Point2d point) { auto polyline = CastToPolyline2(ptr); if (polyline->OutOfRange(index)) return; polyline->points.insert(polyline->points.begin() + index, point.ToCGAL()); } static void Insert(void* ptr, int start, int count, Point2d* points) { auto polyline = CastToPolyline2(ptr); if (polyline->OutOfRange(start)) return; std::vector tmp(count); for (int i = 0; i < count; i++) tmp.push_back(points[i].ToCGAL()); polyline->points.insert(polyline->points.begin() + start, tmp.begin(), tmp.end()); } static BOOL IsClosed(void* ptr, double threshold) { auto polyline = CastToPolyline2(ptr); auto size = polyline->points.size(); if (size < 2) return false; auto start = polyline->points[0]; auto end = polyline->points[size - 1]; auto sqdist = CGAL::to_double(CGAL::squared_distance(start, end)); auto sqthreshold = threshold * threshold; return sqdist <= sqthreshold; } static double SqLength(void* ptr) { auto polyline = CastToPolyline2(ptr); auto count = polyline->points.size(); if (count < 2) return 0; auto sum = CGAL::squared_distance(polyline->points[0], polyline->points[1]); for (auto i = 1; i < count - 1; i++) sum += CGAL::squared_distance(polyline->points[i], polyline->points[i + 1]); return CGAL::to_double(sum); } static Point2d GetPoint(void* ptr, int index) { auto polyline = CastToPolyline2(ptr); if (polyline->OutOfRange(index)) return { 0, 0 }; auto point = polyline->points[index]; return Point2d::FromCGAL(point); } static void GetPoints(void* ptr, Point2d* points, int count) { auto polyline = CastToPolyline2(ptr); auto size = polyline->points.size(); if (size == 0) return; for (auto i = 0; i < count; i++) { auto point = polyline->points[i]; points[i] = Point2d::FromCGAL(point); if (i >= size) return; } } static void GetPoints(Polyline2* polyline, std::vector& points) { int count = (int)polyline->points.size(); for (auto i = 0; i < count; i++) { auto point = polyline->points[i]; points.push_back(Point2d::FromCGAL(point)); } } static void GetSegments(void* ptr, Segment2d* segments, int count) { auto polyline = CastToPolyline2(ptr); auto size = polyline->points.size(); if (size == 0) return; for (auto i = 0; i < count-1; i++) { auto v0 = polyline->points[i]; auto v1 = polyline->points[i+1]; segments[i].a = Point2d::FromCGAL(v0); segments[i].b = Point2d::FromCGAL(v1); if (i >= size) return; } } static void SetPoint(void* ptr, int index, const Point2d& point) { auto polyline = CastToPolyline2(ptr); if (polyline->OutOfRange(index)) return; polyline->points[index] = point.ToCGAL(); } static void SetPoints(void* ptr, Point2d* points, int count) { auto polyline = CastToPolyline2(ptr); auto size = polyline->points.size(); for (int i = 0; i < count; i++) { if (i < size) polyline->points[i] = points[i].ToCGAL(); else { //Adding more points than polyline currently contains //so push back instead. polyline->points.push_back(points[i].ToCGAL()); } } } static void Translate(void* ptr, const Point2d& translation) { auto polyline = CastToPolyline2(ptr); Transformation_2 transformation(CGAL::TRANSLATION, translation.ToVector()); for(int i = 0; i < polyline->points.size(); i++) polyline->points[i] = transformation(polyline->points[i]); } static void Rotate(void* ptr, double rotation) { auto polyline = CastToPolyline2(ptr); Transformation_2 transformation(CGAL::ROTATION, sin(rotation), cos(rotation)); for (int i = 0; i < polyline->points.size(); i++) polyline->points[i] = transformation(polyline->points[i]); } static void Scale(void* ptr, double scale) { auto polyline = CastToPolyline2(ptr); Transformation_2 transformation(CGAL::SCALING, scale); for (int i = 0; i < polyline->points.size(); i++) polyline->points[i] = transformation(polyline->points[i]); } static void Transform(void* ptr, const Point2d& translation, double rotation, double scale) { auto polyline = CastToPolyline2(ptr); Transformation_2 T(CGAL::TRANSLATION, translation.ToVector()); Transformation_2 R(CGAL::ROTATION, sin(rotation), cos(rotation)); Transformation_2 S(CGAL::SCALING, scale); Transformation_2 transformation = T * R * S; for (int i = 0; i < polyline->points.size(); i++) polyline->points[i] = transformation(polyline->points[i]); } }; ================================================ FILE: CGALWrapper/Polylines/Polyline2_EEK.cpp ================================================ #include "Polyline2_EEK.h" #include "Polyline2.h" void* Polyline2_EEK_Create() { return Polyline2::NewPolyline2(); } void* Polyline2_EEK_CreateWithCount(int count) { return Polyline2::NewPolyline2(count); } void Polyline2_EEK_Release(void* ptr) { Polyline2::DeletePolyline2(ptr); } int Polyline2_EEK_Count(void* ptr) { return Polyline2::Count(ptr); } void* Polyline2_EEK_Copy(void* ptr) { return Polyline2::Copy(ptr); } void* Polyline2_EEK_Convert(void* ptr, CGAL_KERNEL k) { switch (k) { case CGAL_KERNEL::EXACT_PREDICATES_INEXACT_CONSTRUCTION: return Polyline2::Convert(ptr); case CGAL_KERNEL::EXACT_PREDICATES_EXACT_CONSTRUCTION: return Polyline2::Convert(ptr); default: return Polyline2::Convert(ptr); } } void Polyline2_EEK_Clear(void* ptr) { Polyline2::Clear(ptr); } int Polyline2_EEK_Capacity(void* ptr) { return Polyline2::Capacity(ptr); } void Polyline2_EEK_Resize(void* ptr, int count) { Polyline2::Resize(ptr, count); } void Polyline2_EEK_Reverse(void* ptr) { Polyline2::Reverse(ptr); } void Polyline2_EEK_ShrinkToFit(void* ptr) { Polyline2::ShrinkToFit(ptr); } void Polyline2_EEK_Erase(void* ptr, int index) { Polyline2::Erase(ptr, index); } void Polyline2_EEK_EraseRange(void* ptr, int start, int count) { Polyline2::Erase(ptr, start, count); } void Polyline2_EEK_Insert(void* ptr, int index, Point2d point) { Polyline2::Insert(ptr, index, point); } void Polyline2_EEK_InsertRange(void* ptr, int start, int count, Point2d* points) { Polyline2::Insert(ptr, start, count, points); } BOOL Polyline2_EEK_IsClosed(void* ptr, double threshold) { return Polyline2::IsClosed(ptr, threshold); } double Polyline2_EEK_SqLength(void* ptr) { return Polyline2::SqLength(ptr); } Point2d Polyline2_EEK_GetPoint(void* ptr, int index) { return Polyline2::GetPoint(ptr, index); } void Polyline2_EEK_GetPoints(void* ptr, Point2d* points, int count) { Polyline2::GetPoints(ptr, points, count); } void Polyline2_EEK_GetSegments(void* ptr, Segment2d* segments, int count) { Polyline2::GetSegments(ptr, segments, count); } void Polyline2_EEK_SetPoint(void* ptr, int index, const Point2d& point) { Polyline2::SetPoint(ptr, index, point); } void Polyline2_EEK_SetPoints(void* ptr, Point2d* points, int count) { Polyline2::SetPoints(ptr, points, count); } void Polyline2_EEK_Translate(void* ptr, const Point2d& translation) { Polyline2::Translate(ptr, translation); } void Polyline2_EEK_Rotate(void* ptr, double rotation) { Polyline2::Rotate(ptr, rotation); } void Polyline2_EEK_Scale(void* ptr, double scale) { Polyline2::Scale(ptr, scale); } void Polyline2_EEK_Transform(void* ptr, const Point2d& translation, double rotation, double scale) { Polyline2::Transform(ptr, translation, rotation, scale); } ================================================ FILE: CGALWrapper/Polylines/Polyline2_EEK.h ================================================ #pragma once #include "../CGALWrapper.h" #include "../Geometry/Geometry2.h" #include extern "C" { CGALWRAPPER_API void* Polyline2_EEK_Create(); CGALWRAPPER_API void* Polyline2_EEK_CreateWithCount(int count); CGALWRAPPER_API void Polyline2_EEK_Release(void* ptr); CGALWRAPPER_API int Polyline2_EEK_Count(void* ptr); CGALWRAPPER_API void* Polyline2_EEK_Copy(void* ptr); CGALWRAPPER_API void* Polyline2_EEK_Convert(void* ptr, CGAL_KERNEL k); CGALWRAPPER_API void Polyline2_EEK_Clear(void* ptr); CGALWRAPPER_API int Polyline2_EEK_Capacity(void* ptr); CGALWRAPPER_API void Polyline2_EEK_Resize(void* ptr, int count); CGALWRAPPER_API void Polyline2_EEK_Reverse(void* ptr); CGALWRAPPER_API void Polyline2_EEK_ShrinkToFit(void* ptr); CGALWRAPPER_API void Polyline2_EEK_Erase(void* ptr, int index); CGALWRAPPER_API void Polyline2_EEK_EraseRange(void* ptr, int start, int count); CGALWRAPPER_API void Polyline2_EEK_Insert(void* ptr, int index, Point2d point); CGALWRAPPER_API void Polyline2_EEK_InsertRange(void* ptr, int start, int count, Point2d* points); CGALWRAPPER_API BOOL Polyline2_EEK_IsClosed(void* ptr, double threshold); CGALWRAPPER_API double Polyline2_EEK_SqLength(void* ptr); CGALWRAPPER_API Point2d Polyline2_EEK_GetPoint(void* ptr, int index); CGALWRAPPER_API void Polyline2_EEK_GetPoints(void* ptr, Point2d* points, int count); CGALWRAPPER_API void Polyline2_EEK_GetSegments(void* ptr, Segment2d* segments, int count); CGALWRAPPER_API void Polyline2_EEK_SetPoint(void* ptr, int index, const Point2d& point); CGALWRAPPER_API void Polyline2_EEK_SetPoints(void* ptr, Point2d* points, int count); CGALWRAPPER_API void Polyline2_EEK_Translate(void* ptr, const Point2d& translation); CGALWRAPPER_API void Polyline2_EEK_Rotate(void* ptr, double rotation); CGALWRAPPER_API void Polyline2_EEK_Scale(void* ptr, double scale); CGALWRAPPER_API void Polyline2_EEK_Transform(void* ptr, const Point2d& translation, double rotation, double scale); } ================================================ FILE: CGALWrapper/Polylines/Polyline2_EIK.cpp ================================================ #include "Polyline2_EIK.h" #include "Polyline2.h" void* Polyline2_EIK_Create() { return Polyline2::NewPolyline2(); } void* Polyline2_EIK_CreateWithCount(int count) { return Polyline2::NewPolyline2(count); } void Polyline2_EIK_Release(void* ptr) { Polyline2::DeletePolyline2(ptr); } int Polyline2_EIK_Count(void* ptr) { return Polyline2::Count(ptr); } void* Polyline2_EIK_Copy(void* ptr) { return Polyline2::Copy(ptr); } void* Polyline2_EIK_Convert(void* ptr, CGAL_KERNEL k) { switch (k) { case CGAL_KERNEL::EXACT_PREDICATES_INEXACT_CONSTRUCTION: return Polyline2::Convert(ptr); case CGAL_KERNEL::EXACT_PREDICATES_EXACT_CONSTRUCTION: return Polyline2::Convert(ptr); default: return Polyline2::Convert(ptr); } } void Polyline2_EIK_Clear(void* ptr) { Polyline2::Clear(ptr); } int Polyline2_EIK_Capacity(void* ptr) { return Polyline2::Capacity(ptr); } void Polyline2_EIK_Resize(void* ptr, int count) { Polyline2::Resize(ptr, count); } void Polyline2_EIK_Reverse(void* ptr) { Polyline2::Reverse(ptr); } void Polyline2_EIK_ShrinkToFit(void* ptr) { Polyline2::ShrinkToFit(ptr); } void Polyline2_EIK_Erase(void* ptr, int index) { Polyline2::Erase(ptr, index); } void Polyline2_EIK_EraseRange(void* ptr, int start, int count) { Polyline2::Erase(ptr, start, count); } void Polyline2_EIK_Insert(void* ptr, int index, Point2d point) { Polyline2::Insert(ptr, index, point); } void Polyline2_EIK_InsertRange(void* ptr, int start, int count, Point2d* points) { Polyline2::Insert(ptr, start, count, points); } BOOL Polyline2_EIK_IsClosed(void* ptr, double threshold) { return Polyline2::IsClosed(ptr, threshold); } double Polyline2_EIK_SqLength(void* ptr) { return Polyline2::SqLength(ptr); } Point2d Polyline2_EIK_GetPoint(void* ptr, int index) { return Polyline2::GetPoint(ptr, index); } void Polyline2_EIK_GetPoints(void* ptr, Point2d* points, int count) { Polyline2::GetPoints(ptr, points, count); } void Polyline2_EIK_GetSegments(void* ptr, Segment2d* segments, int count) { Polyline2::GetSegments(ptr, segments, count); } void Polyline2_EIK_SetPoint(void* ptr, int index, const Point2d& point) { Polyline2::SetPoint(ptr, index, point); } void Polyline2_EIK_SetPoints(void* ptr, Point2d* points, int count) { Polyline2::SetPoints(ptr, points, count); } void Polyline2_EIK_Translate(void* ptr, const Point2d& translation) { Polyline2::Translate(ptr, translation); } void Polyline2_EIK_Rotate(void* ptr, double rotation) { Polyline2::Rotate(ptr, rotation); } void Polyline2_EIK_Scale(void* ptr, double scale) { Polyline2::Scale(ptr, scale); } void Polyline2_EIK_Transform(void* ptr, const Point2d& translation, double rotation, double scale) { Polyline2::Transform(ptr, translation, rotation, scale); } ================================================ FILE: CGALWrapper/Polylines/Polyline2_EIK.h ================================================ #pragma once #include "../CGALWrapper.h" #include "../Geometry/Geometry2.h" #include extern "C" { CGALWRAPPER_API void* Polyline2_EIK_Create(); CGALWRAPPER_API void* Polyline2_EIK_CreateWithCount(int count); CGALWRAPPER_API void Polyline2_EIK_Release(void* ptr); CGALWRAPPER_API int Polyline2_EIK_Count(void* ptr); CGALWRAPPER_API void* Polyline2_EIK_Copy(void* ptr); CGALWRAPPER_API void* Polyline2_EIK_Convert(void* ptr, CGAL_KERNEL k); CGALWRAPPER_API void Polyline2_EIK_Clear(void* ptr); CGALWRAPPER_API int Polyline2_EIK_Capacity(void* ptr); CGALWRAPPER_API void Polyline2_EIK_Resize(void* ptr, int count); CGALWRAPPER_API void Polyline2_EIK_Reverse(void* ptr); CGALWRAPPER_API void Polyline2_EIK_ShrinkToFit(void* ptr); CGALWRAPPER_API void Polyline2_EIK_Erase(void* ptr, int index); CGALWRAPPER_API void Polyline2_EIK_EraseRange(void* ptr, int start, int count); CGALWRAPPER_API void Polyline2_EIK_Insert(void* ptr, int index, Point2d point); CGALWRAPPER_API void Polyline2_EIK_InsertRange(void* ptr, int start, int count, Point2d* points); CGALWRAPPER_API BOOL Polyline2_EIK_IsClosed(void* ptr, double threshold); CGALWRAPPER_API double Polyline2_EIK_SqLength(void* ptr); CGALWRAPPER_API Point2d Polyline2_EIK_GetPoint(void* ptr, int index); CGALWRAPPER_API void Polyline2_EIK_GetPoints(void* ptr, Point2d* points, int count); CGALWRAPPER_API void Polyline2_EIK_GetSegments(void* ptr, Segment2d* segments, int count); CGALWRAPPER_API void Polyline2_EIK_SetPoint(void* ptr, int index, const Point2d& point); CGALWRAPPER_API void Polyline2_EIK_SetPoints(void* ptr, Point2d* points, int count); CGALWRAPPER_API void Polyline2_EIK_Translate(void* ptr, const Point2d& translation); CGALWRAPPER_API void Polyline2_EIK_Rotate(void* ptr, double rotation); CGALWRAPPER_API void Polyline2_EIK_Scale(void* ptr, double scale); CGALWRAPPER_API void Polyline2_EIK_Transform(void* ptr, const Point2d& translation, double rotation, double scale); } ================================================ FILE: CGALWrapper/Polylines/Polyline3.h ================================================ #pragma once #include "../CGALWrapper.h" #include "../Geometry/Geometry3.h" #include "../Geometry/Matrices.h" #include #include #include #include #include template class Polyline3 { public: typedef CGAL::Point_3 Point_3; typedef CGAL::Segment_3 Segment_3; Polyline3() { } Polyline3(int count) { points.resize(count); } Polyline3(const std::vector& points) { this->points = points; } std::vector points; inline static Polyline3* NewPolyline3() { return new Polyline3(); } inline static Polyline3* NewPolyline3(int count) { return new Polyline3(count); } inline static Polyline3* NewPolyline3(const std::vector& points) { return new Polyline3(points); } inline static void DeletePolyline3(void* ptr) { auto obj = static_cast(ptr); if (obj != nullptr) { delete obj; obj = nullptr; } } inline static Polyline3* CastToPolyline3(void* ptr) { return static_cast(ptr); } inline bool OutOfRange(int index) { if (index < 0 || index >= points.size()) return true; else return false; } static void* Copy(void* ptr) { auto polyline = CastToPolyline3(ptr); auto copy = new Polyline3(); copy->points = polyline->points; return copy; } template static void* Convert(void* ptr) { typedef CGAL::Cartesian_converter Converter; Converter convert; auto polyline = CastToPolyline3(ptr); auto count = polyline->points.size(); auto polyline2 = new Polyline3(); for (auto i = 0; i < count; i++) { auto p = convert(polyline->points[i]); polyline2->points.push_back(p); } return polyline2; } static void Clear(void* ptr) { auto polyline = CastToPolyline3(ptr); polyline->points.clear(); } static int Count(void* ptr) { auto polyline = CastToPolyline3(ptr); return (int)polyline->points.size(); } static int Capacity(void* ptr) { auto polyline = CastToPolyline3(ptr); return (int)polyline->points.capacity(); } static void Resize(void* ptr, int count) { auto polyline = CastToPolyline3(ptr); polyline->points.resize(count); } static void Reverse(void* ptr) { auto polyline = CastToPolyline3(ptr); std::reverse(polyline->points.begin(), polyline->points.end()); } static void ShrinkToFit(void* ptr) { auto polyline = CastToPolyline3(ptr); polyline->points.shrink_to_fit(); } static void Erase(void* ptr, int index) { auto polyline = CastToPolyline3(ptr); if (polyline->OutOfRange(index)) return; polyline->points.erase(polyline->points.begin() + index); } static void Erase(void* ptr, int start, int count) { auto polyline = CastToPolyline3(ptr); if (polyline->OutOfRange(start) || polyline->OutOfRange(start + count)) return; polyline->points.erase(polyline->points.begin() + start, polyline->points.begin() + count); } static void Insert(void* ptr, int index, Point3d point) { auto polyline = CastToPolyline3(ptr); if (polyline->OutOfRange(index)) return; polyline->points.insert(polyline->points.begin() + index, point.ToCGAL()); } static void Insert(void* ptr, int start, int count, Point3d* points) { auto polyline = CastToPolyline3(ptr); if (polyline->OutOfRange(start)) return; std::vector tmp(count); for (int i = 0; i < count; i++) tmp.push_back(points[i].ToCGAL()); polyline->points.insert(polyline->points.begin() + start, tmp.begin(), tmp.end()); } static BOOL IsClosed(void* ptr, double threshold) { auto polyline = CastToPolyline3(ptr); auto size = polyline->points.size(); if (size < 2) return false; auto start = polyline->points[0]; auto end = polyline->points[size - 1]; auto sqdist = CGAL::to_double(CGAL::squared_distance(start, end)); auto sqthreshold = threshold * threshold; return sqdist <= sqthreshold; } static double SqLength(void* ptr) { auto polyline = CastToPolyline3(ptr); auto count = polyline->points.size(); if (count < 2) return 0; auto sum = CGAL::squared_distance(polyline->points[0], polyline->points[1]); for (auto i = 1; i < count - 1; i++) sum += CGAL::squared_distance(polyline->points[i], polyline->points[i + 1]); return CGAL::to_double(sum); } static Point3d GetPoint(void* ptr, int index) { auto polyline = CastToPolyline3(ptr); if (polyline->OutOfRange(index)) return { 0, 0 }; auto point = polyline->points[index]; return Point3d::FromCGAL(point); } static void GetPoints(void* ptr, Point3d* points, int count) { auto polyline = CastToPolyline3(ptr); auto size = polyline->points.size(); if (size == 0) return; for (auto i = 0; i < count; i++) { auto point = polyline->points[i]; points[i] = Point3d::FromCGAL(point); if (i >= size) return; } } static void GetPoints(Polyline3* polyline, std::vector& points) { int count = (int)polyline->points.size(); for (auto i = 0; i < count; i++) { auto point = polyline->points[i]; points.push_back(Point3d::FromCGAL(point)); } } static void GetSegments(void* ptr, Segment3d* segments, int count) { auto polyline = CastToPolyline3(ptr); auto size = polyline->points.size(); if (size == 0) return; for (auto i = 0; i < count - 1; i++) { auto v0 = polyline->points[i]; auto v1 = polyline->points[i + 1]; segments[i].a = Point3d::FromCGAL(v0); segments[i].b = Point3d::FromCGAL(v1); if (i >= size) return; } } static void SetPoint(void* ptr, int index, const Point3d& point) { auto polyline = CastToPolyline3(ptr); if (polyline->OutOfRange(index)) return; polyline->points[index] = point.ToCGAL(); } static void SetPoints(void* ptr, Point3d* points, int count) { auto polyline = CastToPolyline3(ptr); auto size = polyline->points.size(); for (int i = 0; i < count; i++) { if (i < size) polyline->points[i] = points[i].ToCGAL(); else { //Adding more points than polyline currently contains //so push back instead. polyline->points.push_back(points[i].ToCGAL()); } } } static void Transform(void* ptr, const Matrix4x4d& matrix) { auto polyline = CastToPolyline3(ptr); auto m = matrix.ToCGAL(); std::transform(polyline->points.begin(), polyline->points.end(), polyline->points.begin(), m); } }; ================================================ FILE: CGALWrapper/Polylines/Polyline3_EEK.cpp ================================================ #include "Polyline3_EEK.h" #include "Polyline3.h" void* Polyline3_EEK_Create() { return Polyline3::NewPolyline3(); } void* Polyline3_EEK_CreateWithCount(int count) { return Polyline3::NewPolyline3(count); } void Polyline3_EEK_Release(void* ptr) { Polyline3::DeletePolyline3(ptr); } int Polyline3_EEK_Count(void* ptr) { return Polyline3::Count(ptr); } void* Polyline3_EEK_Copy(void* ptr) { return Polyline3::Copy(ptr); } void* Polyline3_EEK_Convert(void* ptr, CGAL_KERNEL k) { switch (k) { case CGAL_KERNEL::EXACT_PREDICATES_INEXACT_CONSTRUCTION: return Polyline3::Convert(ptr); case CGAL_KERNEL::EXACT_PREDICATES_EXACT_CONSTRUCTION: return Polyline3::Convert(ptr); default: return Polyline3::Convert(ptr); } } void Polyline3_EEK_Clear(void* ptr) { Polyline3::Clear(ptr); } int Polyline3_EEK_Capacity(void* ptr) { return Polyline3::Capacity(ptr); } void Polyline3_EEK_Resize(void* ptr, int count) { Polyline3::Resize(ptr, count); } void Polyline3_EEK_Reverse(void* ptr) { Polyline3::Reverse(ptr); } void Polyline3_EEK_ShrinkToFit(void* ptr) { Polyline3::ShrinkToFit(ptr); } void Polyline3_EEK_Erase(void* ptr, int index) { Polyline3::Erase(ptr, index); } void Polyline3_EEK_EraseRange(void* ptr, int start, int count) { Polyline3::Erase(ptr, start, count); } void Polyline3_EEK_Insert(void* ptr, int index, Point3d point) { Polyline3::Insert(ptr, index, point); } void Polyline3_EEK_InsertRange(void* ptr, int start, int count, Point3d* points) { Polyline3::Insert(ptr, start, count, points); } BOOL Polyline3_EEK_IsClosed(void* ptr, double threshold) { return Polyline3::IsClosed(ptr, threshold); } double Polyline3_EEK_SqLength(void* ptr) { return Polyline3::SqLength(ptr); } Point3d Polyline3_EEK_GetPoint(void* ptr, int index) { return Polyline3::GetPoint(ptr, index); } void Polyline3_EEK_GetPoints(void* ptr, Point3d* points, int count) { Polyline3::GetPoints(ptr, points, count); } void Polyline3_EEK_GetSegments(void* ptr, Segment3d* segments, int count) { Polyline3::GetSegments(ptr, segments, count); } void Polyline3_EEK_SetPoint(void* ptr, int index, const Point3d& point) { Polyline3::SetPoint(ptr, index, point); } void Polyline3_EEK_SetPoints(void* ptr, Point3d* points, int count) { Polyline3::SetPoints(ptr, points, count); } void Polyline3_EEK_Transform(void* ptr, const Matrix4x4d& matrix) { Polyline3::Transform(ptr, matrix); } ================================================ FILE: CGALWrapper/Polylines/Polyline3_EEK.h ================================================ #pragma once #include "../CGALWrapper.h" #include "../Geometry/Geometry3.h" #include "../Geometry/Matrices.h" #include extern "C" { CGALWRAPPER_API void* Polyline3_EEK_Create(); CGALWRAPPER_API void* Polyline3_EEK_CreateWithCount(int count); CGALWRAPPER_API void Polyline3_EEK_Release(void* ptr); CGALWRAPPER_API int Polyline3_EEK_Count(void* ptr); CGALWRAPPER_API void* Polyline3_EEK_Copy(void* ptr); CGALWRAPPER_API void* Polyline3_EEK_Convert(void* ptr, CGAL_KERNEL k); CGALWRAPPER_API void Polyline3_EEK_Clear(void* ptr); CGALWRAPPER_API int Polyline3_EEK_Capacity(void* ptr); CGALWRAPPER_API void Polyline3_EEK_Resize(void* ptr, int count); CGALWRAPPER_API void Polyline3_EEK_Reverse(void* ptr); CGALWRAPPER_API void Polyline3_EEK_ShrinkToFit(void* ptr); CGALWRAPPER_API void Polyline3_EEK_Erase(void* ptr, int index); CGALWRAPPER_API void Polyline3_EEK_EraseRange(void* ptr, int start, int count); CGALWRAPPER_API void Polyline3_EEK_Insert(void* ptr, int index, Point3d point); CGALWRAPPER_API void Polyline3_EEK_InsertRange(void* ptr, int start, int count, Point3d* points); CGALWRAPPER_API BOOL Polyline3_EEK_IsClosed(void* ptr, double threshold); CGALWRAPPER_API double Polyline3_EEK_SqLength(void* ptr); CGALWRAPPER_API Point3d Polyline3_EEK_GetPoint(void* ptr, int index); CGALWRAPPER_API void Polyline3_EEK_GetPoints(void* ptr, Point3d* points, int count); CGALWRAPPER_API void Polyline3_EEK_GetSegments(void* ptr, Segment3d* segments, int count); CGALWRAPPER_API void Polyline3_EEK_SetPoint(void* ptr, int index, const Point3d& point); CGALWRAPPER_API void Polyline3_EEK_SetPoints(void* ptr, Point3d* points, int count); CGALWRAPPER_API void Polyline3_EEK_Transform(void* ptr, const Matrix4x4d& matrix); } ================================================ FILE: CGALWrapper/Polylines/Polyline3_EIK.cpp ================================================ #include "Polyline3_EIK.h" #include "Polyline3.h" void* Polyline3_EIK_Create() { return Polyline3::NewPolyline3(); } void* Polyline3_EIK_CreateWithCount(int count) { return Polyline3::NewPolyline3(count); } void Polyline3_EIK_Release(void* ptr) { Polyline3::DeletePolyline3(ptr); } int Polyline3_EIK_Count(void* ptr) { return Polyline3::Count(ptr); } void* Polyline3_EIK_Copy(void* ptr) { return Polyline3::Copy(ptr); } void* Polyline3_EIK_Convert(void* ptr, CGAL_KERNEL k) { switch (k) { case CGAL_KERNEL::EXACT_PREDICATES_INEXACT_CONSTRUCTION: return Polyline3::Convert(ptr); case CGAL_KERNEL::EXACT_PREDICATES_EXACT_CONSTRUCTION: return Polyline3::Convert(ptr); default: return Polyline3::Convert(ptr); } } void Polyline3_EIK_Clear(void* ptr) { Polyline3::Clear(ptr); } int Polyline3_EIK_Capacity(void* ptr) { return Polyline3::Capacity(ptr); } void Polyline3_EIK_Resize(void* ptr, int count) { Polyline3::Resize(ptr, count); } void Polyline3_EIK_Reverse(void* ptr) { Polyline3::Reverse(ptr); } void Polyline3_EIK_ShrinkToFit(void* ptr) { Polyline3::ShrinkToFit(ptr); } void Polyline3_EIK_Erase(void* ptr, int index) { Polyline3::Erase(ptr, index); } void Polyline3_EIK_EraseRange(void* ptr, int start, int count) { Polyline3::Erase(ptr, start, count); } void Polyline3_EIK_Insert(void* ptr, int index, Point3d point) { Polyline3::Insert(ptr, index, point); } void Polyline3_EIK_InsertRange(void* ptr, int start, int count, Point3d* points) { Polyline3::Insert(ptr, start, count, points); } BOOL Polyline3_EIK_IsClosed(void* ptr, double threshold) { return Polyline3::IsClosed(ptr, threshold); } double Polyline3_EIK_SqLength(void* ptr) { return Polyline3::SqLength(ptr); } Point3d Polyline3_EIK_GetPoint(void* ptr, int index) { return Polyline3::GetPoint(ptr, index); } void Polyline3_EIK_GetPoints(void* ptr, Point3d* points, int count) { Polyline3::GetPoints(ptr, points, count); } void Polyline3_EIK_GetSegments(void* ptr, Segment3d* segments, int count) { Polyline3::GetSegments(ptr, segments, count); } void Polyline3_EIK_SetPoint(void* ptr, int index, const Point3d& point) { Polyline3::SetPoint(ptr, index, point); } void Polyline3_EIK_SetPoints(void* ptr, Point3d* points, int count) { Polyline3::SetPoints(ptr, points, count); } void Polyline3_EIK_Transform(void* ptr, const Matrix4x4d& matrix) { Polyline3::Transform(ptr, matrix); } ================================================ FILE: CGALWrapper/Polylines/Polyline3_EIK.h ================================================ #pragma once #include "../CGALWrapper.h" #include "../Geometry/Geometry3.h" #include "../Geometry/Matrices.h" #include extern "C" { CGALWRAPPER_API void* Polyline3_EIK_Create(); CGALWRAPPER_API void* Polyline3_EIK_CreateWithCount(int count); CGALWRAPPER_API void Polyline3_EIK_Release(void* ptr); CGALWRAPPER_API int Polyline3_EIK_Count(void* ptr); CGALWRAPPER_API void* Polyline3_EIK_Copy(void* ptr); CGALWRAPPER_API void* Polyline3_EIK_Convert(void* ptr, CGAL_KERNEL k); CGALWRAPPER_API void Polyline3_EIK_Clear(void* ptr); CGALWRAPPER_API int Polyline3_EIK_Capacity(void* ptr); CGALWRAPPER_API void Polyline3_EIK_Resize(void* ptr, int count); CGALWRAPPER_API void Polyline3_EIK_Reverse(void* ptr); CGALWRAPPER_API void Polyline3_EIK_ShrinkToFit(void* ptr); CGALWRAPPER_API void Polyline3_EIK_Erase(void* ptr, int index); CGALWRAPPER_API void Polyline3_EIK_EraseRange(void* ptr, int start, int count); CGALWRAPPER_API void Polyline3_EIK_Insert(void* ptr, int index, Point3d point); CGALWRAPPER_API void Polyline3_EIK_InsertRange(void* ptr, int start, int count, Point3d* points); CGALWRAPPER_API BOOL Polyline3_EIK_IsClosed(void* ptr, double threshold); CGALWRAPPER_API double Polyline3_EIK_SqLength(void* ptr); CGALWRAPPER_API Point3d Polyline3_EIK_GetPoint(void* ptr, int index); CGALWRAPPER_API void Polyline3_EIK_GetPoints(void* ptr, Point3d* points, int count); CGALWRAPPER_API void Polyline3_EIK_GetSegments(void* ptr, Segment3d* segments, int count); CGALWRAPPER_API void Polyline3_EIK_SetPoint(void* ptr, int index, const Point3d& point); CGALWRAPPER_API void Polyline3_EIK_SetPoints(void* ptr, Point3d* points, int count); CGALWRAPPER_API void Polyline3_EIK_Transform(void* ptr, const Matrix4x4d& matrix); } ================================================ FILE: CGALWrapper/Processing/HeatMethod.h ================================================ #pragma once #include "../CGALWrapper.h" #include "../Geometry/Geometry3.h" #include "../Polyhedra/Polyhedron3.h" #include "../Polyhedra/SurfaceMesh3.h" #include #include template class HeatMethod { public: typedef typename K::Point_3 Point3; typedef typename CGAL::Surface_mesh SurfaceMesh; typedef typename boost::graph_traits::vertex_descriptor SVertexDes; typedef typename CGAL::Heat_method_3::Surface_mesh_geodesic_distances_3 SHeat_method_idt; typedef typename CGAL::Heat_method_3::Surface_mesh_geodesic_distances_3 SHeat_method; typedef typename CGAL::Polyhedron_3 Polyhedron; typedef typename boost::graph_traits::vertex_descriptor PVertexDes; typedef typename CGAL::Heat_method_3::Surface_mesh_geodesic_distances_3 PHeat_method_idt; typedef typename CGAL::Heat_method_3::Surface_mesh_geodesic_distances_3 PHeat_method; std::vector distances; inline static HeatMethod* NewHeatMethod() { return new HeatMethod(); } inline static void DeleteHeatMethod(void* ptr) { auto obj = static_cast(ptr); if (obj != nullptr) { delete obj; obj = nullptr; } } inline static HeatMethod* CastToHeatMethod(void* ptr) { return static_cast(ptr); } static double GetDistance(void* ptr, int index) { auto method = CastToHeatMethod(ptr); return method->distances[index]; } static void ClearDistances(void* ptr) { auto method = CastToHeatMethod(ptr); method->distances.clear(); } static int EstimateGeodesicDistances_SM(void* ptr, void* meshPtr, int vertexIndex, BOOL useIDT) { auto method = CastToHeatMethod(ptr); auto mesh = SurfaceMesh3::CastToSurfaceMesh(meshPtr); auto distMap = mesh->AddScalarPropertyMap("v:distance"); auto source = mesh->FindVertex(vertexIndex); if (useIDT) { SHeat_method_idt hm(mesh->model); hm.add_source(source); hm.estimate_geodesic_distances(distMap); } else { SHeat_method hm(mesh->model); hm.add_source(source); hm.estimate_geodesic_distances(distMap); } method->distances.clear(); for (auto vd : vertices(mesh->model)) { double dist = get(distMap, vd); method->distances.push_back(dist); } mesh->ClearScalarPropertyMap("v:distance"); return (int)method->distances.size(); } static int EstimateGeodesicDistances_PH(void* ptr, void* meshPtr, int vertexIndex, BOOL useIDT) { auto method = CastToHeatMethod(ptr); auto mesh = Polyhedron3::CastToPolyhedron(meshPtr); boost::unordered_map distMap; auto source = mesh->FindVertex(vertexIndex); //if (useIDT) //{ CGAL::Heat_method_3::estimate_geodesic_distances(mesh->model, boost::make_assoc_property_map(distMap), source); //} //else //{ // CGAL::Heat_method_3::estimate_geodesic_distances(mesh->model, // boost::make_assoc_property_map(distMap), // source); //} method->distances.clear(); for (auto vd : vertices(mesh->model)) { double dist = distMap[vd]; method->distances.push_back(dist); } return (int)method->distances.size(); } }; ================================================ FILE: CGALWrapper/Processing/HeatMethod_EEK.cpp ================================================ #include "HeatMethod_EEK.h" #include "HeatMethod.h" void* HeatMethod_EEK_Create() { return HeatMethod::NewHeatMethod(); } void HeatMethod_EEK_Release(void* ptr) { HeatMethod::DeleteHeatMethod(ptr); } double HeatMethod_EEK_GetDistance(void* ptr, int index) { return HeatMethod::GetDistance(ptr, index); } void HeatMethod_EEK_ClearDistances(void* ptr) { HeatMethod::ClearDistances(ptr); } int HeatMethod_EEK_EstimateGeodesicDistances_SM(void* ptr, void* meshPtr, int vertexIndex, BOOL useIDT) { return HeatMethod::EstimateGeodesicDistances_SM(ptr, meshPtr, vertexIndex, useIDT); } int HeatMethod_EEK_EstimateGeodesicDistances_PH(void* ptr, void* meshPtr, int vertexIndex, BOOL useIDT) { return HeatMethod::EstimateGeodesicDistances_PH(ptr, meshPtr, vertexIndex, useIDT); } ================================================ FILE: CGALWrapper/Processing/HeatMethod_EEK.h ================================================ #pragma once #include "../CGALWrapper.h" #include "../Geometry/Geometry3.h" extern "C" { CGALWRAPPER_API void* HeatMethod_EEK_Create(); CGALWRAPPER_API void HeatMethod_EEK_Release(void* ptr); CGALWRAPPER_API double HeatMethod_EEK_GetDistance(void* ptr, int index); CGALWRAPPER_API void HeatMethod_EEK_ClearDistances(void* ptr); CGALWRAPPER_API int HeatMethod_EEK_EstimateGeodesicDistances_SM(void* ptr, void* meshPtr, int vertexIndex, BOOL useIDT); CGALWRAPPER_API int HeatMethod_EEK_EstimateGeodesicDistances_PH(void* ptr, void* meshPtr, int vertexIndex, BOOL useIDT); } ================================================ FILE: CGALWrapper/Processing/HeatMethod_EIK.cpp ================================================ #include "HeatMethod_EIK.h" #include "HeatMethod.h" void* HeatMethod_EIK_Create() { return HeatMethod::NewHeatMethod(); } void HeatMethod_EIK_Release(void* ptr) { HeatMethod::DeleteHeatMethod(ptr); } double HeatMethod_EIK_GetDistance(void* ptr, int index) { return HeatMethod::GetDistance(ptr, index); } void HeatMethod_EIK_ClearDistances(void* ptr) { HeatMethod::ClearDistances(ptr); } int HeatMethod_EIK_EstimateGeodesicDistances_SM(void* ptr, void* meshPtr, int vertexIndex, BOOL useIDT) { return HeatMethod::EstimateGeodesicDistances_SM(ptr, meshPtr, vertexIndex, useIDT); } int HeatMethod_EIK_EstimateGeodesicDistances_PH(void* ptr, void* meshPtr, int vertexIndex, BOOL useIDT) { return HeatMethod::EstimateGeodesicDistances_PH(ptr, meshPtr, vertexIndex, useIDT); } ================================================ FILE: CGALWrapper/Processing/HeatMethod_EIK.h ================================================ #pragma once #include "../CGALWrapper.h" #include "../Geometry/Geometry3.h" extern "C" { CGALWRAPPER_API void* HeatMethod_EIK_Create(); CGALWRAPPER_API void HeatMethod_EIK_Release(void* ptr); CGALWRAPPER_API double HeatMethod_EIK_GetDistance(void* ptr, int index); CGALWRAPPER_API void HeatMethod_EIK_ClearDistances(void* ptr); CGALWRAPPER_API int HeatMethod_EIK_EstimateGeodesicDistances_SM(void* ptr, void* meshPtr, int vertexIndex, BOOL useIDT); CGALWRAPPER_API int HeatMethod_EIK_EstimateGeodesicDistances_PH(void* ptr, void* meshPtr, int vertexIndex, BOOL useIDT); } ================================================ FILE: CGALWrapper/Processing/MeshProcessingBoolean.h ================================================ #pragma once #include "../CGALWrapper.h" #include "../Geometry/Geometry3.h" #include "../Polyhedra/Polyhedron3.h" #include "../Polyhedra/SurfaceMesh3.h" #include #include #include #include #include #include template class MeshProcessingBoolean { public: typedef typename K::Point_3 Point; typedef typename CGAL::Iso_cuboid_3 IsoCube3; typedef typename CGAL::Plane_3 Plane3; typedef typename std::vector Polyline; inline static MeshProcessingBoolean* NewMeshProcessingBoolean() { return new MeshProcessingBoolean(); } inline static void DeleteMeshProcessingBoolean(void* ptr) { auto obj = static_cast(ptr); if (obj != nullptr) { delete obj; obj = nullptr; } } inline static MeshProcessingBoolean* CastToMeshProcessingBoolean(void* ptr) { return static_cast(ptr); } //Polyhedron static BOOL Union_PH(void* meshPtr1, void* meshPtr2, void** resultPtr) { auto mesh1 = Polyhedron3::CastToPolyhedron(meshPtr1); auto mesh2 = Polyhedron3::CastToPolyhedron(meshPtr2); auto result = Polyhedron3::NewPolyhedron(); if (CGAL::Polygon_mesh_processing::corefine_and_compute_union(mesh1->model, mesh2->model, result->model)) { *resultPtr = result; return TRUE; } else { delete result; return FALSE; } } static BOOL Difference_PH(void* meshPtr1, void* meshPtr2, void** resultPtr) { auto mesh1 = Polyhedron3::CastToPolyhedron(meshPtr1); auto mesh2 = Polyhedron3::CastToPolyhedron(meshPtr2); auto result = Polyhedron3::NewPolyhedron(); if (CGAL::Polygon_mesh_processing::corefine_and_compute_difference(mesh1->model, mesh2->model, result->model)) { *resultPtr = result; return TRUE; } else { delete result; return FALSE; } } static BOOL Intersection_PH(void* meshPtr1, void* meshPtr2, void** resultPtr) { auto mesh1 = Polyhedron3::CastToPolyhedron(meshPtr1); auto mesh2 = Polyhedron3::CastToPolyhedron(meshPtr2); auto result = Polyhedron3::NewPolyhedron(); if (CGAL::Polygon_mesh_processing::corefine_and_compute_intersection(mesh1->model, mesh2->model, result->model)) { *resultPtr = result; return TRUE; } else { delete result; return FALSE; } } static BOOL Clip_PH(void* meshPtr1, void* meshPtr2, void** resultPtr) { return FALSE; /* auto mesh1 = Polyhedron3::CastToPolyhedron(meshPtr1); auto mesh2 = Polyhedron3::CastToPolyhedron(meshPtr2); auto result = Polyhedron3::NewPolyhedron(); if (CGAL::Polygon_mesh_processing::clip(mesh1->model, mesh2->model, result->model)) { *resultPtr = result; return TRUE; } else { delete result; return FALSE; } */ } static BOOL PlaneClip_PH(void* meshPtr1, Plane3d plane, void** resultPtr) { return FALSE; /* auto mesh1 = Polyhedron3::CastToPolyhedron(meshPtr1); auto result = Polyhedron3::NewPolyhedron(); if (CGAL::Polygon_mesh_processing::clip(mesh1->model, plane.ToCGAL(), result->model)) { *resultPtr = result; return TRUE; } else { delete result; return FALSE; } */ } static BOOL BoxClip_PH(void* meshPtr1, Box3d box, void** resultPtr) { return FALSE; /* auto mesh1 = Polyhedron3::CastToPolyhedron(meshPtr1); auto result = Polyhedron3::NewPolyhedron(); if (CGAL::Polygon_mesh_processing::clip(mesh1->model, box.ToCGAL(), result->model)) { *resultPtr = result; return true; } else { delete result; return FALSE; } */ } static BOOL SurfaceIntersection_PH(void* meshPtr1, void* meshPtr2) { return FALSE; /* auto mesh1 = Polyhedron3::CastToPolyhedron(meshPtr1); auto mesh2 = Polyhedron3::CastToPolyhedron(meshPtr2); std::vector lines; if (CGAL::Polygon_mesh_processing::surface_intersection(mesh1->model, mesh2->model, std::back_inserter(lines))) { return TRUE; } else { return FALSE; } */ } //Surface Mesh static BOOL Union_SM(void* meshPtr1, void* meshPtr2, void** resultPtr) { auto mesh1 = SurfaceMesh3::CastToSurfaceMesh(meshPtr1); auto mesh2 = SurfaceMesh3::CastToSurfaceMesh(meshPtr2); auto result = SurfaceMesh3::NewSurfaceMesh(); if (CGAL::Polygon_mesh_processing::corefine_and_compute_union(mesh1->model, mesh2->model, result->model)) { *resultPtr = result; return TRUE; } else { delete result; return FALSE; } } static BOOL Difference_SM(void* meshPtr1, void* meshPtr2, void** resultPtr) { auto mesh1 = SurfaceMesh3::CastToSurfaceMesh(meshPtr1); auto mesh2 = SurfaceMesh3::CastToSurfaceMesh(meshPtr2); auto result = SurfaceMesh3::NewSurfaceMesh(); if (CGAL::Polygon_mesh_processing::corefine_and_compute_difference(mesh1->model, mesh2->model, result->model)) { *resultPtr = result; return TRUE; } else { delete result; return FALSE; } } static BOOL Intersection_SM(void* meshPtr1, void* meshPtr2, void** resultPtr) { auto mesh1 = SurfaceMesh3::CastToSurfaceMesh(meshPtr1); auto mesh2 = SurfaceMesh3::CastToSurfaceMesh(meshPtr2); auto result = SurfaceMesh3::NewSurfaceMesh(); if (CGAL::Polygon_mesh_processing::corefine_and_compute_intersection(mesh1->model, mesh2->model, result->model)) { *resultPtr = result; return TRUE; } else { delete result; return FALSE; } } static BOOL Clip_SM(void* meshPtr1, void* meshPtr2, void** resultPtr) { return FALSE; /* auto mesh1 = SurfaceMesh3::CastToSurfaceMesh(meshPtr1); auto mesh2 = SurfaceMesh3::CastToSurfaceMesh(meshPtr2); auto result = SurfaceMesh3::NewSurfaceMesh(); if (CGAL::Polygon_mesh_processing::clip(mesh1->model, mesh2->model, result->model)) { *resultPtr = result; return TRUE; } else { delete result; return FALSE; } */ } static BOOL PlaneClip_SM(void* meshPtr1, Plane3d plane, void** resultPtr) { return FALSE; /* auto mesh1 = SurfaceMesh3::CastToSurfaceMesh(meshPtr1); auto result = SurfaceMesh3::NewSurfaceMesh(); if (CGAL::Polygon_mesh_processing::clip(mesh1->model, plane.ToCGAL(), result->model)) { *resultPtr = result; return TRUE; } else { delete result; return FALSE; } */ } static BOOL BoxClip_SM(void* meshPtr1, Box3d box, void** resultPtr) { return FALSE; /* auto mesh1 = SurfaceMesh3::CastToSurfaceMesh(meshPtr1); auto result = SurfaceMesh3::NewSurfaceMesh(); if (CGAL::Polygon_mesh_processing::clip(mesh1->model, box.ToCGAL(), result->model)) { *resultPtr = result; return true; } else { delete result; return FALSE; } */ } static BOOL SurfaceIntersection_SM(void* meshPtr1, void* meshPtr2) { return FALSE; /* auto mesh1 = Polyhedron3::CastToPolyhedron(meshPtr1); auto mesh2 = Polyhedron3::CastToPolyhedron(meshPtr2); std::vector lines; if (CGAL::Polygon_mesh_processing::surface_intersection(mesh1->model, mesh2->model, std::back_inserter(lines))) { return TRUE; } else { return FALSE; } */ } }; ================================================ FILE: CGALWrapper/Processing/MeshProcessingBoolean_EEK.cpp ================================================ #include "MeshProcessingBoolean_EEK.h" #include "MeshProcessingBoolean.h" void* MeshProcessingBoolean_EEK_Create() { return MeshProcessingBoolean::NewMeshProcessingBoolean(); } void MeshProcessingBoolean_EEK_Release(void* ptr) { MeshProcessingBoolean::DeleteMeshProcessingBoolean(ptr); } //Polyhedron BOOL MeshProcessingBoolean_EEK_Union_PH(void* meshPtr1, void* meshPtr2, void** resultPtr) { return MeshProcessingBoolean::Union_PH(meshPtr1, meshPtr2, resultPtr); } BOOL MeshProcessingBoolean_EEK_Difference_PH(void* meshPtr1, void* meshPtr2, void** resultPtr) { return MeshProcessingBoolean::Difference_PH(meshPtr1, meshPtr2, resultPtr); } BOOL MeshProcessingBoolean_EEK_Intersection_PH(void* meshPtr1, void* meshPtr2, void** resultPtr) { return MeshProcessingBoolean::Intersection_PH(meshPtr1, meshPtr2, resultPtr); } BOOL MeshProcessingBoolean_EEK_Clip_PH(void* meshPtr1, void* meshPtr2, void** resultPtr) { return MeshProcessingBoolean::Clip_PH(meshPtr1, meshPtr2, resultPtr); } BOOL MeshProcessingBoolean_EEK_PlaneClip_PH(void* meshPtr1, Plane3d plane, void** resultPtr) { return MeshProcessingBoolean::PlaneClip_PH(meshPtr1, plane, resultPtr); } BOOL MeshProcessingBoolean_EEK_BoxClip_PH(void* meshPtr1, Box3d box, void** resultPtr) { return MeshProcessingBoolean::BoxClip_PH(meshPtr1, box, resultPtr); } BOOL MeshProcessingBoolean_EEK_SurfaceIntersection_PH(void* meshPtr1, void* meshPtr2) { return MeshProcessingBoolean::SurfaceIntersection_PH(meshPtr1, meshPtr2); } //Surface Mesh BOOL MeshProcessingBoolean_EEK_Union_SM(void* meshPtr1, void* meshPtr2, void** resultPtr) { return MeshProcessingBoolean::Union_SM(meshPtr1, meshPtr2, resultPtr); } BOOL MeshProcessingBoolean_EEK_Difference_SM(void* meshPtr1, void* meshPtr2, void** resultPtr) { return MeshProcessingBoolean::Difference_SM(meshPtr1, meshPtr2, resultPtr); } BOOL MeshProcessingBoolean_EEK_Intersection_SM(void* meshPtr1, void* meshPtr2, void** resultPtr) { return MeshProcessingBoolean::Intersection_SM(meshPtr1, meshPtr2, resultPtr); } BOOL MeshProcessingBoolean_EEK_Clip_SM(void* meshPtr1, void* meshPtr2, void** resultPtr) { return MeshProcessingBoolean::Clip_SM(meshPtr1, meshPtr2, resultPtr); } BOOL MeshProcessingBoolean_EEK_PlaneClip_SM(void* meshPtr1, Plane3d plane, void** resultPtr) { return MeshProcessingBoolean::PlaneClip_SM(meshPtr1, plane, resultPtr); } BOOL MeshProcessingBoolean_EEK_BoxClip_SM(void* meshPtr1, Box3d box, void** resultPtr) { return MeshProcessingBoolean::BoxClip_SM(meshPtr1, box, resultPtr); } BOOL MeshProcessingBoolean_EEK_SurfaceIntersection_SM(void* meshPtr1, void* meshPtr2) { return MeshProcessingBoolean::SurfaceIntersection_SM(meshPtr1, meshPtr2); } ================================================ FILE: CGALWrapper/Processing/MeshProcessingBoolean_EEK.h ================================================ #pragma once #include "../CGALWrapper.h" #include "../Geometry/Geometry3.h" extern "C" { CGALWRAPPER_API void* MeshProcessingBoolean_EEK_Create(); CGALWRAPPER_API void MeshProcessingBoolean_EEK_Release(void* ptr); //Polyhedron CGALWRAPPER_API BOOL MeshProcessingBoolean_EEK_Union_PH(void* meshPtr1, void* meshPtr2, void** resultPtr); CGALWRAPPER_API BOOL MeshProcessingBoolean_EEK_Difference_PH(void* meshPtr1, void* meshPtr2, void** resultPtr); CGALWRAPPER_API BOOL MeshProcessingBoolean_EEK_Intersection_PH(void* meshPtr1, void* meshPtr2, void** resultPtr); CGALWRAPPER_API BOOL MeshProcessingBoolean_EEK_Clip_PH(void* meshPtr1, void* meshPtr2, void** resultPtr); CGALWRAPPER_API BOOL MeshProcessingBoolean_EEK_PlaneClip_PH(void* meshPtr1, Plane3d plane, void** resultPtr); CGALWRAPPER_API BOOL MeshProcessingBoolean_EEK_BoxClip_PH(void* meshPtr1, Box3d box, void** resultPtr); CGALWRAPPER_API BOOL MeshProcessingBoolean_EEK_SurfaceIntersection_PH(void* meshPtr1, void* meshPtr2); //Surface Mesh CGALWRAPPER_API BOOL MeshProcessingBoolean_EEK_Union_SM(void* meshPtr1, void* meshPtr2, void** resultPtr); CGALWRAPPER_API BOOL MeshProcessingBoolean_EEK_Difference_SM(void* meshPtr1, void* meshPtr2, void** resultPtr); CGALWRAPPER_API BOOL MeshProcessingBoolean_EEK_Intersection_SM(void* meshPtr1, void* meshPtr2, void** resultPtr); CGALWRAPPER_API BOOL MeshProcessingBoolean_EEK_Clip_SM(void* meshPtr1, void* meshPtr2, void** resultPtr); CGALWRAPPER_API BOOL MeshProcessingBoolean_EEK_PlaneClip_SM(void* meshPtr1, Plane3d plane, void** resultPtr); CGALWRAPPER_API BOOL MeshProcessingBoolean_EEK_BoxClip_SM(void* meshPtr1, Box3d box, void** resultPtr); CGALWRAPPER_API BOOL MeshProcessingBoolean_EEK_SurfaceIntersection_SM(void* meshPtr1, void* meshPtr2); } ================================================ FILE: CGALWrapper/Processing/MeshProcessingBoolean_EIK.cpp ================================================ #include "MeshProcessingBoolean_EIK.h" #include "MeshProcessingBoolean.h" void* MeshProcessingBoolean_EIK_Create() { return MeshProcessingBoolean::NewMeshProcessingBoolean(); } void MeshProcessingBoolean_EIK_Release(void* ptr) { MeshProcessingBoolean::DeleteMeshProcessingBoolean(ptr); } //Polyhedron BOOL MeshProcessingBoolean_EIK_Union_PH(void* meshPtr1, void* meshPtr2, void** resultPtr) { return MeshProcessingBoolean::Union_PH(meshPtr1, meshPtr2, resultPtr); } BOOL MeshProcessingBoolean_EIK_Difference_PH(void* meshPtr1, void* meshPtr2, void** resultPtr) { return MeshProcessingBoolean::Difference_PH(meshPtr1, meshPtr2, resultPtr); } BOOL MeshProcessingBoolean_EIK_Intersection_PH(void* meshPtr1, void* meshPtr2, void** resultPtr) { return MeshProcessingBoolean::Intersection_PH(meshPtr1, meshPtr2, resultPtr); } BOOL MeshProcessingBoolean_EIK_Clip_PH(void* meshPtr1, void* meshPtr2, void** resultPtr) { return MeshProcessingBoolean::Clip_PH(meshPtr1, meshPtr2, resultPtr); } BOOL MeshProcessingBoolean_EIK_PlaneClip_PH(void* meshPtr1, Plane3d plane, void** resultPtr) { return MeshProcessingBoolean::PlaneClip_PH(meshPtr1, plane, resultPtr); } BOOL MeshProcessingBoolean_EIK_BoxClip_PH(void* meshPtr1, Box3d box, void** resultPtr) { return MeshProcessingBoolean::BoxClip_PH(meshPtr1, box, resultPtr); } BOOL MeshProcessingBoolean_EIK_SurfaceIntersection_PH(void* meshPtr1, void* meshPtr2) { return MeshProcessingBoolean::SurfaceIntersection_PH(meshPtr1, meshPtr2); } //Surface Mesh BOOL MeshProcessingBoolean_EIK_Union_SM(void* meshPtr1, void* meshPtr2, void** resultPtr) { return MeshProcessingBoolean::Union_SM(meshPtr1, meshPtr2, resultPtr); } BOOL MeshProcessingBoolean_EIK_Difference_SM(void* meshPtr1, void* meshPtr2, void** resultPtr) { return MeshProcessingBoolean::Difference_SM(meshPtr1, meshPtr2, resultPtr); } BOOL MeshProcessingBoolean_EIK_Intersection_SM(void* meshPtr1, void* meshPtr2, void** resultPtr) { return MeshProcessingBoolean::Intersection_SM(meshPtr1, meshPtr2, resultPtr); } BOOL MeshProcessingBoolean_EIK_Clip_SM(void* meshPtr1, void* meshPtr2, void** resultPtr) { return MeshProcessingBoolean::Clip_SM(meshPtr1, meshPtr2, resultPtr); } BOOL MeshProcessingBoolean_EIK_PlaneClip_SM(void* meshPtr1, Plane3d plane, void** resultPtr) { return MeshProcessingBoolean::PlaneClip_SM(meshPtr1, plane, resultPtr); } BOOL MeshProcessingBoolean_EIK_BoxClip_SM(void* meshPtr1, Box3d box, void** resultPtr) { return MeshProcessingBoolean::BoxClip_SM(meshPtr1, box, resultPtr); } BOOL MeshProcessingBoolean_EIK_SurfaceIntersection_SM(void* meshPtr1, void* meshPtr2) { return MeshProcessingBoolean::SurfaceIntersection_SM(meshPtr1, meshPtr2); } ================================================ FILE: CGALWrapper/Processing/MeshProcessingBoolean_EIK.h ================================================ #pragma once #include "../CGALWrapper.h" #include "../Geometry/Geometry3.h" extern "C" { CGALWRAPPER_API void* MeshProcessingBoolean_EIK_Create(); CGALWRAPPER_API void MeshProcessingBoolean_EIK_Release(void* ptr); //Polyhedron CGALWRAPPER_API BOOL MeshProcessingBoolean_EIK_Union_PH(void* meshPtr1, void* meshPtr2, void** resultPtr); CGALWRAPPER_API BOOL MeshProcessingBoolean_EIK_Difference_PH(void* meshPtr1, void* meshPtr2, void** resultPtr); CGALWRAPPER_API BOOL MeshProcessingBoolean_EIK_Intersection_PH(void* meshPtr1, void* meshPtr2, void** resultPtr); CGALWRAPPER_API BOOL MeshProcessingBoolean_EIK_Clip_PH(void* meshPtr1, void* meshPtr2, void** resultPtr); CGALWRAPPER_API BOOL MeshProcessingBoolean_EIK_PlaneClip_PH(void* meshPtr1, Plane3d plane, void** resultPtr); CGALWRAPPER_API BOOL MeshProcessingBoolean_EIK_BoxClip_PH(void* meshPtr1, Box3d box, void** resultPtr); CGALWRAPPER_API BOOL MeshProcessingBoolean_EIK_SurfaceIntersection_PH(void* meshPtr1, void* meshPtr2); //Surface Mesh CGALWRAPPER_API BOOL MeshProcessingBoolean_EIK_Union_SM(void* meshPtr1, void* meshPtr2, void** resultPtr); CGALWRAPPER_API BOOL MeshProcessingBoolean_EIK_Difference_SM(void* meshPtr1, void* meshPtr2, void** resultPtr); CGALWRAPPER_API BOOL MeshProcessingBoolean_EIK_Intersection_SM(void* meshPtr1, void* meshPtr2, void** resultPtr); CGALWRAPPER_API BOOL MeshProcessingBoolean_EIK_Clip_SM(void* meshPtr1, void* meshPtr2, void** resultPtr); CGALWRAPPER_API BOOL MeshProcessingBoolean_EIK_PlaneClip_SM(void* meshPtr1, Plane3d plane, void** resultPtr); CGALWRAPPER_API BOOL MeshProcessingBoolean_EIK_BoxClip_SM(void* meshPtr1, Box3d box, void** resultPtr); CGALWRAPPER_API BOOL MeshProcessingBoolean_EIK_SurfaceIntersection_SM(void* meshPtr1, void* meshPtr2); } ================================================ FILE: CGALWrapper/Processing/MeshProcessingConnections.h ================================================ #pragma once #include "../CGALWrapper.h" #include "../Polyhedra/Polyhedron3.h" #include "../Polyhedra/SurfaceMesh3.h" #include #include #include #include #include #include #include #include template class MeshProcessingConnections { public: typedef typename K::Point_3 Point_3; typedef CGAL::Polyhedron_3 Polyhedron; typedef typename boost::graph_traits::face_descriptor PFace_Des; typedef typename boost::graph_traits::faces_size_type PFaces_Size; typedef typename CGAL::Surface_mesh SurfaceMesh; typedef typename SurfaceMesh::Face_index SFace; typedef typename boost::graph_traits::face_descriptor SFace_Des; typedef typename boost::graph_traits::faces_size_type SFaces_Size; //CGAL::Polygon_mesh_processing::parameters::all_default() std::vector polyhedron_buffer; std::vector surface_mesh_buffer; std::vector polyhedron_face_buffer; std::vector surface_face_buffer; public: inline static MeshProcessingConnections* NewMeshProcessingConnections() { return new MeshProcessingConnections(); } inline static void DeleteMeshProcessingConnections(void* ptr) { auto obj = static_cast(ptr); if (obj != nullptr) { delete obj; obj = nullptr; } } inline static MeshProcessingConnections* CastToMeshProcessingConnections(void* ptr) { return static_cast(ptr); } //Polyhedron static int ConnectedComponents_PH(void* meshPtr) { auto mesh = Polyhedron3::CastToPolyhedron(meshPtr); //auto fccmap = mesh->model.add_property_map("f:CC").first; //std::size_t num = CGAL::Polygon_mesh_processing::connected_components(mesh->model, fccmap); return 0; } static int ConnectedComponent_PH(void* ptr, void* meshPtr, int index) { auto con = CastToMeshProcessingConnections(ptr); auto mesh = Polyhedron3::CastToPolyhedron(meshPtr); auto face = mesh->FindFaceIter(index); if (face != nullptr) { con->polyhedron_face_buffer.clear(); auto ins = std::back_inserter(con->polyhedron_face_buffer); CGAL::Polygon_mesh_processing::connected_component(*face, mesh->model, ins); return (int)con->polyhedron_face_buffer.size(); } else return 0; } static void GetConnectedComponentFaceIndex_PH(void* ptr, void* meshPtr, int* indices, int count) { auto con = CastToMeshProcessingConnections(ptr); auto mesh = Polyhedron3::CastToPolyhedron(meshPtr); int size = (int)con->polyhedron_face_buffer.size(); for (int i = 0; i < count; i++) { auto face = con->polyhedron_face_buffer[i]; int index = mesh->FindFaceIndex(face); indices[i] = index; if (i >= size) break; } con->polyhedron_face_buffer.clear(); } static int SplitConnectedComponents_PH(void* ptr, void* meshPtr) { auto con = CastToMeshProcessingConnections(ptr); auto mesh = Polyhedron3::CastToPolyhedron(meshPtr); con->polyhedron_buffer.clear(); CGAL::Polygon_mesh_processing::split_connected_components(mesh->model, con->polyhedron_buffer); return (int)con->polyhedron_buffer.size(); } static void GetSplitConnectedComponents_PH(void* ptr, void** meshPtrs, int count) { auto con = CastToMeshProcessingConnections(ptr); int size = (int)con->polyhedron_buffer.size(); for (int i = 0; i < count; i++) { auto mesh = Polyhedron3::NewPolyhedron(); mesh->model = con->polyhedron_buffer[i]; meshPtrs[i] = mesh; if (i >= size) break; } con->polyhedron_buffer.clear(); } static int KeepLargeConnectedComponents_PH(void* meshPtr, int threshold_value) { auto mesh = Polyhedron3::CastToPolyhedron(meshPtr); return (int)CGAL::Polygon_mesh_processing::keep_large_connected_components(mesh->model, threshold_value); } static int KeepLargestConnectedComponents_PH(void* meshPtr, int nb_components_to_keep) { auto mesh = Polyhedron3::CastToPolyhedron(meshPtr); return (int)CGAL::Polygon_mesh_processing::keep_largest_connected_components(mesh->model, nb_components_to_keep);; } //Surface Mesh static int ConnectedComponents_SM(void* meshPtr) { auto mesh = SurfaceMesh3::CastToSurfaceMesh(meshPtr); //auto pair = mesh->model.property_map("f:CC"); //auto map = pair.first; auto map = mesh->model.add_property_map("f:CC").first; auto num = CGAL::Polygon_mesh_processing::connected_components(mesh->model, map); mesh->model.remove_property_map(map); return (int)num; } static int ConnectedComponent_SM(void* ptr, void* meshPtr, int index) { auto con = CastToMeshProcessingConnections(ptr); auto mesh = SurfaceMesh3::CastToSurfaceMesh(meshPtr); auto face = mesh->FindFace(index); if (face != SurfaceMesh3::NullFace()) { con->surface_face_buffer.clear(); auto ins = std::back_inserter(con->surface_face_buffer); CGAL::Polygon_mesh_processing::connected_component(face, mesh->model, ins); return (int)con->surface_face_buffer.size(); } else return 0; } static void GetConnectedComponentFaceIndex_SM(void* ptr, void* meshPtr, int* indices, int count) { auto con = CastToMeshProcessingConnections(ptr); auto mesh = SurfaceMesh3::CastToSurfaceMesh(meshPtr); int size = (int)con->surface_face_buffer.size(); for (int i = 0; i < count; i++) { auto face = con->surface_face_buffer[i]; indices[i] = face; if (i >= size) break; } con->surface_face_buffer.clear(); } static int SplitConnectedComponents_SM(void* ptr, void* meshPtr) { auto con = CastToMeshProcessingConnections(ptr); auto mesh = SurfaceMesh3::CastToSurfaceMesh(meshPtr); con->surface_mesh_buffer.clear(); CGAL::Polygon_mesh_processing::split_connected_components(mesh->model, con->surface_mesh_buffer); return (int)con->surface_mesh_buffer.size(); } static void GetSplitConnectedComponents_SM(void* ptr, void** meshPtrs, int count) { auto con = CastToMeshProcessingConnections(ptr); int size = (int)con->surface_mesh_buffer.size(); for (int i = 0; i < count; i++) { auto mesh = SurfaceMesh3::NewSurfaceMesh(); mesh->model = con->surface_mesh_buffer[i]; meshPtrs[i] = mesh; if (i >= size) break; } con->surface_mesh_buffer.clear(); } static int KeepLargeConnectedComponents_SM(void* meshPtr, int threshold_value) { auto mesh = SurfaceMesh3::CastToSurfaceMesh(meshPtr); mesh->OnModelChanged(); return (int)CGAL::Polygon_mesh_processing::keep_large_connected_components(mesh->model, threshold_value); } static int KeepLargestConnectedComponents_SM(void* meshPtr, int nb_components_to_keep) { auto mesh = SurfaceMesh3::CastToSurfaceMesh(meshPtr); mesh->OnModelChanged(); return (int)CGAL::Polygon_mesh_processing::keep_largest_connected_components(mesh->model, nb_components_to_keep); } }; ================================================ FILE: CGALWrapper/Processing/MeshProcessingConnections_EEK.cpp ================================================ #include "MeshProcessingConnections_EEK.h" #include "MeshProcessingConnections.h" #include #include #include #include #include #include void* MeshProcessingConnections_EEK_Create() { return MeshProcessingConnections::NewMeshProcessingConnections(); } void MeshProcessingConnections_EEK_Release(void* ptr) { MeshProcessingConnections::DeleteMeshProcessingConnections(ptr); } //Polyhedron int MeshProcessingConnections_EEK_ConnectedComponents_PH(void* meshPtr) { return MeshProcessingConnections::ConnectedComponents_PH(meshPtr); } int MeshProcessingConnections_EEK_ConnectedComponent_PH(void* ptr, void* meshPtr, int index) { return MeshProcessingConnections::ConnectedComponent_PH(ptr, meshPtr, index); } void MeshProcessingConnections_EEK_GetConnectedComponentsFaceIndex_PH(void* ptr, void* meshPtr, int* indices, int count) { MeshProcessingConnections::GetConnectedComponentFaceIndex_PH(ptr, meshPtr, indices, count); } int MeshProcessingConnections_EEK_SplitConnectedComponents_PH(void* ptr, void* meshPtr) { return MeshProcessingConnections::SplitConnectedComponents_PH(ptr, meshPtr); } void MeshProcessingConnections_EEK_GetSplitConnectedComponents_PH(void* ptr, void** meshPtrs, int count) { MeshProcessingConnections::GetSplitConnectedComponents_PH(ptr, meshPtrs, count); } int MeshProcessingConnections_EEK_KeepLargeConnectedComponents_PH(void* meshPtr, int threshold_value) { return MeshProcessingConnections::KeepLargeConnectedComponents_PH(meshPtr, threshold_value); } int MeshProcessingConnections_EEK_KeepLargestConnectedComponents_PH(void* meshPtr, int nb_components_to_keep) { return MeshProcessingConnections::KeepLargestConnectedComponents_PH(meshPtr, nb_components_to_keep); } //Surface Mesh int MeshProcessingConnections_EEK_ConnectedComponents_SM(void* meshPtr) { return MeshProcessingConnections::ConnectedComponents_SM(meshPtr); } int MeshProcessingConnections_EEK_ConnectedComponent_SM(void* ptr, void* meshPtr, int index) { return MeshProcessingConnections::ConnectedComponent_SM(ptr, meshPtr, index); } void MeshProcessingConnections_EEK_GetConnectedComponentsFaceIndex_SM(void* ptr, void* meshPtr, int* indices, int count) { MeshProcessingConnections::GetConnectedComponentFaceIndex_SM(ptr, meshPtr, indices, count); } int MeshProcessingConnections_EEK_SplitConnectedComponents_SM(void* ptr, void* meshPtr) { return MeshProcessingConnections::SplitConnectedComponents_SM(ptr, meshPtr); } void MeshProcessingConnections_EEK_GetSplitConnectedComponents_SM(void* ptr, void** meshPtrs, int count) { MeshProcessingConnections::GetSplitConnectedComponents_SM(ptr, meshPtrs, count); } int MeshProcessingConnections_EEK_KeepLargeConnectedComponents_SM(void* meshPtr, int threshold_value) { return MeshProcessingConnections::KeepLargeConnectedComponents_SM(meshPtr, threshold_value); } int MeshProcessingConnections_EEK_KeepLargestConnectedComponents_SM(void* meshPtr, int nb_components_to_keep) { return MeshProcessingConnections::KeepLargestConnectedComponents_SM(meshPtr, nb_components_to_keep); } ================================================ FILE: CGALWrapper/Processing/MeshProcessingConnections_EEK.h ================================================ #pragma once #include "../CGALWrapper.h" #include "../Geometry/Geometry3.h" extern "C" { CGALWRAPPER_API void* MeshProcessingConnections_EEK_Create(); CGALWRAPPER_API void MeshProcessingConnections_EEK_Release(void* ptr); //Polyhedron CGALWRAPPER_API int MeshProcessingConnections_EEK_ConnectedComponents_PH(void* meshPtr); CGALWRAPPER_API int MeshProcessingConnections_EEK_ConnectedComponent_PH(void* ptr, void* meshPtr, int index); CGALWRAPPER_API void MeshProcessingConnections_EEK_GetConnectedComponentsFaceIndex_PH(void* ptr, void* meshPtr, int* indices, int count); CGALWRAPPER_API int MeshProcessingConnections_EEK_SplitConnectedComponents_PH(void* ptr, void* meshPtr); CGALWRAPPER_API void MeshProcessingConnections_EEK_GetSplitConnectedComponents_PH(void* ptr, void** meshPtrs, int count); CGALWRAPPER_API int MeshProcessingConnections_EEK_KeepLargeConnectedComponents_PH(void* meshPtr, int threshold_value); CGALWRAPPER_API int MeshProcessingConnections_EEK_KeepLargestConnectedComponents_PH(void* meshPtr, int nb_components_to_keep); //Surface Mesh CGALWRAPPER_API int MeshProcessingConnections_EEK_ConnectedComponents_SM(void* meshPtr); CGALWRAPPER_API int MeshProcessingConnections_EEK_ConnectedComponent_SM(void* ptr, void* meshPtr, int index); CGALWRAPPER_API void MeshProcessingConnections_EEK_GetConnectedComponentsFaceIndex_SM(void* ptr, void* meshPtr, int* indices, int count); CGALWRAPPER_API int MeshProcessingConnections_EEK_SplitConnectedComponents_SM(void* ptr, void* meshPtr); CGALWRAPPER_API void MeshProcessingConnections_EEK_GetSplitConnectedComponents_SM(void* ptr, void** meshPtrs, int count); CGALWRAPPER_API int MeshProcessingConnections_EEK_KeepLargeConnectedComponents_SM(void* meshPtr, int threshold_value); CGALWRAPPER_API int MeshProcessingConnections_EEK_KeepLargestConnectedComponents_SM(void* meshPtr, int nb_components_to_keep); } ================================================ FILE: CGALWrapper/Processing/MeshProcessingConnections_EIK.cpp ================================================ #include "MeshProcessingConnections_EIK.h" #include "MeshProcessingConnections.h" #include #include #include #include #include #include void* MeshProcessingConnections_EIK_Create() { return MeshProcessingConnections::NewMeshProcessingConnections(); } void MeshProcessingConnections_EIK_Release(void* ptr) { MeshProcessingConnections::DeleteMeshProcessingConnections(ptr); } //Polyhedron int MeshProcessingConnections_EIK_ConnectedComponents_PH(void* meshPtr) { return MeshProcessingConnections::ConnectedComponents_PH(meshPtr); } int MeshProcessingConnections_EIK_ConnectedComponent_PH(void* ptr, void* meshPtr, int index) { return MeshProcessingConnections::ConnectedComponent_PH(ptr, meshPtr, index); } void MeshProcessingConnections_EIK_GetConnectedComponentsFaceIndex_PH(void* ptr, void* meshPtr, int* indices, int count) { MeshProcessingConnections::GetConnectedComponentFaceIndex_PH(ptr, meshPtr, indices, count); } int MeshProcessingConnections_EIK_SplitConnectedComponents_PH(void* ptr, void* meshPtr) { return MeshProcessingConnections::SplitConnectedComponents_PH(ptr, meshPtr); } void MeshProcessingConnections_EIK_GetSplitConnectedComponents_PH(void* ptr, void** meshPtrs, int count) { MeshProcessingConnections::GetSplitConnectedComponents_PH(ptr, meshPtrs, count); } int MeshProcessingConnections_EIK_KeepLargeConnectedComponents_PH(void* meshPtr, int threshold_value) { return MeshProcessingConnections::KeepLargeConnectedComponents_PH(meshPtr, threshold_value); } int MeshProcessingConnections_EIK_KeepLargestConnectedComponents_PH(void* meshPtr, int nb_components_to_keep) { return MeshProcessingConnections::KeepLargestConnectedComponents_PH(meshPtr, nb_components_to_keep); } //Surface Mesh int MeshProcessingConnections_EIK_ConnectedComponents_SM(void* meshPtr) { return MeshProcessingConnections::ConnectedComponents_SM(meshPtr); } int MeshProcessingConnections_EIK_ConnectedComponent_SM(void* ptr, void* meshPtr, int index) { return MeshProcessingConnections::ConnectedComponent_SM(ptr, meshPtr, index); } void MeshProcessingConnections_EIK_GetConnectedComponentsFaceIndex_SM(void* ptr, void* meshPtr, int* indices, int count) { MeshProcessingConnections::GetConnectedComponentFaceIndex_SM(ptr, meshPtr, indices, count); } int MeshProcessingConnections_EIK_SplitConnectedComponents_SM(void* ptr, void* meshPtr) { return MeshProcessingConnections::SplitConnectedComponents_SM(ptr, meshPtr); } void MeshProcessingConnections_EIK_GetSplitConnectedComponents_SM(void* ptr, void** meshPtrs, int count) { MeshProcessingConnections::GetSplitConnectedComponents_SM(ptr, meshPtrs, count); } int MeshProcessingConnections_EIK_KeepLargeConnectedComponents_SM(void* meshPtr, int threshold_value) { return MeshProcessingConnections::KeepLargeConnectedComponents_SM(meshPtr, threshold_value); } int MeshProcessingConnections_EIK_KeepLargestConnectedComponents_SM(void* meshPtr, int nb_components_to_keep) { return MeshProcessingConnections::KeepLargestConnectedComponents_SM(meshPtr, nb_components_to_keep); } ================================================ FILE: CGALWrapper/Processing/MeshProcessingConnections_EIK.h ================================================ #pragma once #include "../CGALWrapper.h" #include "../Geometry/Geometry3.h" extern "C" { CGALWRAPPER_API void* MeshProcessingConnections_EIK_Create(); CGALWRAPPER_API void MeshProcessingConnections_EIK_Release(void* ptr); //Polyhedron CGALWRAPPER_API int MeshProcessingConnections_EIK_ConnectedComponents_PH(void* meshPtr); CGALWRAPPER_API int MeshProcessingConnections_EIK_ConnectedComponent_PH(void* ptr, void* meshPtr, int index); CGALWRAPPER_API void MeshProcessingConnections_EIK_GetConnectedComponentsFaceIndex_PH(void* ptr, void* meshPtr, int* indices, int count); CGALWRAPPER_API int MeshProcessingConnections_EIK_SplitConnectedComponents_PH(void* ptr, void* meshPtr); CGALWRAPPER_API void MeshProcessingConnections_EIK_GetSplitConnectedComponents_PH(void* ptr, void** meshPtrs, int count); CGALWRAPPER_API int MeshProcessingConnections_EIK_KeepLargeConnectedComponents_PH(void* meshPtr, int threshold_value); CGALWRAPPER_API int MeshProcessingConnections_EIK_KeepLargestConnectedComponents_PH(void* meshPtr, int nb_components_to_keep); //Surface Mesh CGALWRAPPER_API int MeshProcessingConnections_EIK_ConnectedComponents_SM(void* meshPtr); CGALWRAPPER_API int MeshProcessingConnections_EIK_ConnectedComponent_SM(void* ptr, void* meshPtr, int index); CGALWRAPPER_API void MeshProcessingConnections_EIK_GetConnectedComponentsFaceIndex_SM(void* ptr, void* meshPtr, int* indices, int count); CGALWRAPPER_API int MeshProcessingConnections_EIK_SplitConnectedComponents_SM(void* ptr, void* meshPtr); CGALWRAPPER_API void MeshProcessingConnections_EIK_GetSplitConnectedComponents_SM(void* ptr, void** meshPtrs, int count); CGALWRAPPER_API int MeshProcessingConnections_EIK_KeepLargeConnectedComponents_SM(void* meshPtr, int threshold_value); CGALWRAPPER_API int MeshProcessingConnections_EIK_KeepLargestConnectedComponents_SM(void* meshPtr, int nb_components_to_keep); } ================================================ FILE: CGALWrapper/Processing/MeshProcessingFeatures.h ================================================ #pragma once #include "../CGALWrapper.h" #include "../Geometry/Index.h" #include "../Polyhedra/Polyhedron3.h" #include "../Polyhedra/SurfaceMesh3.h" #include "../Geometry/MinMax.h" #include #include template class MeshProcessingFeatures { public: typedef typename K::FT FT; typedef typename K::Point_3 Point_3; typedef CGAL::Polyhedron_3 Polyhedron; typedef typename boost::graph_traits::edge_descriptor PEdge_Des; typedef typename boost::graph_traits::face_descriptor PFace_Des; typedef typename CGAL::Surface_mesh SurfaceMesh; typedef typename SurfaceMesh::Face_index SFace; typedef typename boost::graph_traits::edge_descriptor SEdge_Des; typedef typename boost::graph_traits::face_descriptor SFace_Des; std::vector polyhedron_edge_buffer; std::vector surface_edge_buffer; std::unordered_map> polyhedron_patch_buffer; std::unordered_map> surface_patch_buffer; inline static MeshProcessingFeatures* NewMeshProcessingFeatures() { return new MeshProcessingFeatures(); } inline static void DeleteMeshProcessingFeatures(void* ptr) { auto obj = static_cast(ptr); if (obj != nullptr) { delete obj; obj = nullptr; } } inline static MeshProcessingFeatures* CastToMeshProcessingFeatures(void* ptr) { return static_cast(ptr); } void AddSurfaceFaceToPatchBuffer(SFace face, int patch) { auto list = surface_patch_buffer.find(patch); if (list != surface_patch_buffer.end()) { list->second.push_back(face); } else { std::pair> pair; pair.first = patch; pair.second.push_back(face); surface_patch_buffer.insert(pair); } } //Polyhedron static int DetectSharpEdges_PH(void* feaPtr, void* meshPtr, double feature_angle) { auto fea = CastToMeshProcessingFeatures(feaPtr); auto mesh = Polyhedron3::CastToPolyhedron(meshPtr); std::unordered_map map; CGAL::Polygon_mesh_processing::detect_sharp_edges(mesh->model, feature_angle, boost::make_assoc_property_map(map)); fea->polyhedron_edge_buffer.clear(); for(auto& pair : map) { if (pair.second) fea->polyhedron_edge_buffer.push_back(pair.first); } return (int)fea->polyhedron_edge_buffer.size(); } static void GetSharpEdges_PH(void* feaPtr, void* meshPtr, int* indices, int count) { auto fea = CastToMeshProcessingFeatures(feaPtr); auto mesh = Polyhedron3::CastToPolyhedron(meshPtr); int index = 0; for (auto edge : fea->polyhedron_edge_buffer) { auto hedge = edge.halfedge(); indices[index++] = mesh->FindHalfedgeIndex(hedge); if (index >= count) break; } fea->polyhedron_edge_buffer.clear(); } static Index2 SharpEdgesSegmentation_PH(void* feaPtr, void* meshPtr, double feature_angle) { return { 0, 0 }; } static void ClearPatchBuffer_PH(void* feaPtr) { auto fea = CastToMeshProcessingFeatures(feaPtr); fea->polyhedron_patch_buffer.clear(); } static int GetPatchBufferFaceCount_PH(void* feaPtr, int patchIndex) { auto fea = CastToMeshProcessingFeatures(feaPtr); auto list = fea->polyhedron_patch_buffer.find(patchIndex); if (list != fea->polyhedron_patch_buffer.end()) { return (int)list->second.size(); } else return 0; } static int GetPatchBufferFaceIndex_PH(void* feaPtr, int patchIndex, int faceIndex) { auto fea = CastToMeshProcessingFeatures(feaPtr); auto list = fea->polyhedron_patch_buffer.find(patchIndex); if (list != fea->polyhedron_patch_buffer.end()) { if (faceIndex < 0 || faceIndex >= (int)list->second.size()) return NULL_INDEX; return list->second[faceIndex]; } else return 0; } static MinMaxAvg EdgeLengthMinMaxAvg_PH(void* ptr) { auto mesh = Polyhedron3::CastToPolyhedron(ptr); constexpr double MAX = std::numeric_limits::max(); FT min = MAX; FT max = 0; FT avg = 0; int count = 0; for (auto halfedge = mesh->model.halfedges_begin(); halfedge != mesh->model.halfedges_end(); ++halfedge) { auto len = CGAL::Polygon_mesh_processing::edge_length(halfedge, mesh->model); count++; avg += len; if (len < min) min = len; if (len > max) max = len; } if (min == MAX) min = 0; if (count != 0) avg /= count; MinMaxAvg m; m.min = CGAL::to_double(min); m.max = CGAL::to_double(max); m.avg = CGAL::to_double(avg); return m; } static MinMaxAvg FaceAreaMinMaxAvg_PH(void* ptr) { auto mesh = Polyhedron3::CastToPolyhedron(ptr); constexpr double MAX = std::numeric_limits::max(); FT min = MAX; FT max = 0; FT avg = 0; int count = 0; for (auto face = mesh->model.facets_begin(); face != mesh->model.facets_end(); ++face) { auto area = CGAL::Polygon_mesh_processing::face_area(face, mesh->model); count++; avg += area; if (area < min) min = area; if (area > max) max = area; } if (min == MAX) min = 0; if (count != 0) avg /= count; MinMaxAvg m; m.min = CGAL::to_double(min); m.max = CGAL::to_double(max); m.avg = CGAL::to_double(avg); return m; } //SurfaceMesh static int DetectSharpEdges_SM(void* feaPtr, void* meshPtr, double feature_angle) { auto fea = CastToMeshProcessingFeatures(feaPtr); auto mesh = SurfaceMesh3::CastToSurfaceMesh(meshPtr); std::unordered_map map; CGAL::Polygon_mesh_processing::detect_sharp_edges(mesh->model, feature_angle, boost::make_assoc_property_map(map)); fea->surface_edge_buffer.clear(); for (auto& pair : map) { if (pair.second) fea->surface_edge_buffer.push_back(pair.first); } return (int)fea->surface_edge_buffer.size(); } static void GetSharpEdges_SM(void* feaPtr, void* meshPtr, int* indices, int count) { auto fea = CastToMeshProcessingFeatures(feaPtr); auto mesh = SurfaceMesh3::CastToSurfaceMesh(meshPtr); int index = 0; for (auto edge : fea->surface_edge_buffer) { auto hedge = edge.halfedge(); indices[index++] = mesh->FindHalfedgeIndex(hedge); if (index >= count) break; } fea->surface_edge_buffer.clear(); } static Index2 SharpEdgesSegmentation_SM(void* feaPtr, void* meshPtr, double feature_angle) { auto fea = CastToMeshProcessingFeatures(feaPtr); auto mesh = SurfaceMesh3::CastToSurfaceMesh(meshPtr); typedef boost::property_map::type EIFMap; typedef boost::property_map >::type PIMap; typedef boost::property_map >::type VIMap; namespace PMP = CGAL::Polygon_mesh_processing; EIFMap eif = get(CGAL::edge_is_feature, mesh->model); PIMap pid = get(CGAL::face_patch_id_t(), mesh->model); VIMap vip = get(CGAL::vertex_incident_patches_t(), mesh->model); auto param = PMP::parameters::vertex_incident_patches_map(vip); auto number_of_patches = PMP::sharp_edges_segmentation(mesh->model, feature_angle, eif, pid, param); fea->surface_edge_buffer.clear(); fea->surface_patch_buffer.clear(); int index = 0; for (auto edge : edges(mesh->model)) { if (get(eif, edge)) { fea->surface_edge_buffer.push_back(edge); } } for (auto face : faces(mesh->model)) { if (get(pid, face)) { int patch = pid[face]; fea->AddSurfaceFaceToPatchBuffer(face, patch); } } return { (int)fea->surface_edge_buffer.size(), (int)number_of_patches }; } static void ClearPatchBuffer_SM(void* feaPtr) { auto fea = CastToMeshProcessingFeatures(feaPtr); fea->surface_patch_buffer.clear(); } static int GetPatchBufferFaceCount_SM(void* feaPtr, int patchIndex) { auto fea = CastToMeshProcessingFeatures(feaPtr); auto list = fea->surface_patch_buffer.find(patchIndex); if (list != fea->surface_patch_buffer.end()) { return (int)list->second.size(); } else return 0; } static int GetPatchBufferFaceIndex_SM(void* feaPtr, int patchIndex, int faceIndex) { auto fea = CastToMeshProcessingFeatures(feaPtr); auto list = fea->surface_patch_buffer.find(patchIndex); if (list != fea->surface_patch_buffer.end()) { if (faceIndex < 0 || faceIndex >= (int)list->second.size()) return NULL_INDEX; return list->second[faceIndex]; } else return 0; } static MinMaxAvg EdgeLengthMinMaxAvg_SM(void* ptr) { auto mesh = SurfaceMesh3::CastToSurfaceMesh(ptr); constexpr double MAX = std::numeric_limits::max(); FT min = MAX; FT max = 0; FT avg = 0; int count = 0; for (auto halfedge : mesh->model.halfedges()) { auto len = CGAL::Polygon_mesh_processing::edge_length(halfedge, mesh->model); count++; avg += len; if (len < min) min = len; if (len > max) max = len; } if (min == MAX) min = 0; if (count != 0) avg /= count; MinMaxAvg m; m.min = CGAL::to_double(min); m.max = CGAL::to_double(max); m.avg = CGAL::to_double(avg); return m; } static MinMaxAvg FaceAreaMinMaxAvg_SM(void* ptr) { auto mesh = SurfaceMesh3::CastToSurfaceMesh(ptr); constexpr double MAX = std::numeric_limits::max(); FT min = MAX; FT max = 0; FT avg = 0; int count = 0; for (auto face : mesh->model.faces()) { auto area = CGAL::Polygon_mesh_processing::face_area(face, mesh->model); count++; avg += area; if (area < min) min = area; if (area > max) max = area; } if (min == MAX) min = 0; if (count != 0) avg /= count; MinMaxAvg m; m.min = CGAL::to_double(min); m.max = CGAL::to_double(max); m.avg = CGAL::to_double(avg); return m; } }; ================================================ FILE: CGALWrapper/Processing/MeshProcessingFeatures_EEK.cpp ================================================ #include "MeshProcessingFeatures_EEK.h" #include "MeshProcessingFeatures.h" void* MeshProcessingFeatures_EEK_Create() { return MeshProcessingFeatures::NewMeshProcessingFeatures(); } void MeshProcessingFeatures_EEK_Release(void* ptr) { MeshProcessingFeatures::DeleteMeshProcessingFeatures(ptr); } //Polyhedron int MeshProcessingFeatures_EEK_DetectSharpEdges_PH(void* feaPtr, void* meshPtr, double feature_angle) { return MeshProcessingFeatures::DetectSharpEdges_PH(feaPtr, meshPtr, feature_angle); } void MeshProcessingFeatures_EEK_GetSharpEdges_PH(void* feaPtr, void* meshPtr, int* indices, int count) { MeshProcessingFeatures::GetSharpEdges_PH(feaPtr, meshPtr, indices, count); } Index2 MeshProcessingFeatures_EEK_SharpEdgesSegmentation_PH(void* feaPtr, void* meshPtr, double feature_angle) { return MeshProcessingFeatures::SharpEdgesSegmentation_PH(feaPtr, meshPtr, feature_angle); } void MeshProcessingFeatures_EEK_ClearPatchBuffer_PH(void* feaPtr) { MeshProcessingFeatures::ClearPatchBuffer_PH(feaPtr); } int MeshProcessingFeatures_EEK_GetPatchBufferFaceCount_PH(void* feaPtr, int patchIndex) { return MeshProcessingFeatures::GetPatchBufferFaceCount_PH(feaPtr, patchIndex); } int MeshProcessingFeatures_EEK_GetPatchBufferFaceIndex_PH(void* feaPtr, int patchIndex, int faceIndex) { return MeshProcessingFeatures::GetPatchBufferFaceIndex_PH(feaPtr, patchIndex, faceIndex); } MinMaxAvg MeshProcessingFeatures_EEK_EdgeLengthMinMaxAvg_PH(void* ptr) { return MeshProcessingFeatures::EdgeLengthMinMaxAvg_PH(ptr); } MinMaxAvg MeshProcessingFeatures_EEK_FaceAreaMinMaxAvg_PH(void* ptr) { return MeshProcessingFeatures::FaceAreaMinMaxAvg_PH(ptr); } //Surface Mesh int MeshProcessingFeatures_EEK_DetectSharpEdges_SM(void* feaPtr, void* meshPtr, double feature_angle) { return MeshProcessingFeatures::DetectSharpEdges_SM(feaPtr, meshPtr, feature_angle); } void MeshProcessingFeatures_EEK_GetSharpEdges_SM(void* feaPtr, void* meshPtr, int* indices, int count) { MeshProcessingFeatures::GetSharpEdges_SM(feaPtr, meshPtr, indices, count); } Index2 MeshProcessingFeatures_EEK_SharpEdgesSegmentation_SM(void* feaPtr, void* meshPtr, double feature_angle) { return MeshProcessingFeatures::SharpEdgesSegmentation_SM(feaPtr, meshPtr, feature_angle); } void MeshProcessingFeatures_EEK_ClearPatchBuffer_SM(void* feaPtr) { MeshProcessingFeatures::ClearPatchBuffer_SM(feaPtr); } int MeshProcessingFeatures_EEK_GetPatchBufferFaceCount_SM(void* feaPtr, int patchIndex) { return MeshProcessingFeatures::GetPatchBufferFaceCount_SM(feaPtr, patchIndex); } int MeshProcessingFeatures_EEK_GetPatchBufferFaceIndex_SM(void* feaPtr, int patchIndex, int faceIndex) { return MeshProcessingFeatures::GetPatchBufferFaceIndex_SM(feaPtr, patchIndex, faceIndex); } MinMaxAvg MeshProcessingFeatures_EEK_EdgeLengthMinMaxAvg_SM(void* ptr) { return MeshProcessingFeatures::EdgeLengthMinMaxAvg_SM(ptr); } MinMaxAvg MeshProcessingFeatures_EEK_FaceAreaMinMaxAvg_SM(void* ptr) { return MeshProcessingFeatures::FaceAreaMinMaxAvg_SM(ptr); } ================================================ FILE: CGALWrapper/Processing/MeshProcessingFeatures_EEK.h ================================================ #pragma once #include "../CGALWrapper.h" #include "../Geometry/Geometry3.h" #include "../Geometry/Index.h" #include "../Geometry/MinMax.h" extern "C" { CGALWRAPPER_API void* MeshProcessingFeatures_EEK_Create(); CGALWRAPPER_API void MeshProcessingFeatures_EEK_Release(void* ptr); //Polyhedron CGALWRAPPER_API int MeshProcessingFeatures_EEK_DetectSharpEdges_PH(void* feaPtr, void* meshPtr, double feature_angle); CGALWRAPPER_API void MeshProcessingFeatures_EEK_GetSharpEdges_PH(void* feaPtr, void* meshPtr, int* indices, int count); CGALWRAPPER_API Index2 MeshProcessingFeatures_EEK_SharpEdgesSegmentation_PH(void* feaPtr, void* meshPtr, double feature_angle); CGALWRAPPER_API void MeshProcessingFeatures_EEK_ClearPatchBuffer_PH(void* feaPtr); CGALWRAPPER_API int MeshProcessingFeatures_EEK_GetPatchBufferFaceCount_PH(void* feaPtr, int patchIndex); CGALWRAPPER_API int MeshProcessingFeatures_EEK_GetPatchBufferFaceIndex_PH(void* feaPtr, int patchIndex, int faceIndex); CGALWRAPPER_API MinMaxAvg MeshProcessingFeatures_EEK_EdgeLengthMinMaxAvg_PH(void* ptr); CGALWRAPPER_API MinMaxAvg MeshProcessingFeatures_EEK_FaceAreaMinMaxAvg_PH(void* ptr); //Surface Mesh CGALWRAPPER_API int MeshProcessingFeatures_EEK_DetectSharpEdges_SM(void* feaPtr, void* meshPtr, double feature_angle); CGALWRAPPER_API void MeshProcessingFeatures_EEK_GetSharpEdges_SM(void* feaPtr, void* meshPtr, int* indices, int count); CGALWRAPPER_API Index2 MeshProcessingFeatures_EEK_SharpEdgesSegmentation_SM(void* feaPtr, void* meshPtr, double feature_angle); CGALWRAPPER_API void MeshProcessingFeatures_EEK_ClearPatchBuffer_SM(void* feaPtr); CGALWRAPPER_API int MeshProcessingFeatures_EEK_GetPatchBufferFaceCount_SM(void* feaPtr, int patchIndex); CGALWRAPPER_API int MeshProcessingFeatures_EEK_GetPatchBufferFaceIndex_SM(void* feaPtr, int patchIndex, int faceIndex); CGALWRAPPER_API MinMaxAvg MeshProcessingFeatures_EEK_EdgeLengthMinMaxAvg_SM(void* ptr); CGALWRAPPER_API MinMaxAvg MeshProcessingFeatures_EEK_FaceAreaMinMaxAvg_SM(void* ptr); } ================================================ FILE: CGALWrapper/Processing/MeshProcessingFeatures_EIK.cpp ================================================ #include "MeshProcessingFeatures_EIK.h" #include "MeshProcessingFeatures.h" void* MeshProcessingFeatures_EIK_Create() { return MeshProcessingFeatures::NewMeshProcessingFeatures(); } void MeshProcessingFeatures_EIK_Release(void* ptr) { MeshProcessingFeatures::DeleteMeshProcessingFeatures(ptr); } //Polyhedron int MeshProcessingFeatures_EIK_DetectSharpEdges_PH(void* feaPtr, void* meshPtr, double feature_angle) { return MeshProcessingFeatures::DetectSharpEdges_PH(feaPtr, meshPtr, feature_angle); } void MeshProcessingFeatures_EIK_GetSharpEdges_PH(void* feaPtr, void* meshPtr, int* indices, int count) { MeshProcessingFeatures::GetSharpEdges_PH(feaPtr, meshPtr, indices, count); } Index2 MeshProcessingFeatures_EIK_SharpEdgesSegmentation_PH(void* feaPtr, void* meshPtr, double feature_angle) { return MeshProcessingFeatures::SharpEdgesSegmentation_PH(feaPtr, meshPtr, feature_angle); } void MeshProcessingFeatures_EIK_ClearPatchBuffer_PH(void* feaPtr) { MeshProcessingFeatures::ClearPatchBuffer_PH(feaPtr); } int MeshProcessingFeatures_EIK_GetPatchBufferFaceCount_PH(void* feaPtr, int patchIndex) { return MeshProcessingFeatures::GetPatchBufferFaceCount_PH(feaPtr, patchIndex); } int MeshProcessingFeatures_EIK_GetPatchBufferFaceIndex_PH(void* feaPtr, int patchIndex, int faceIndex) { return MeshProcessingFeatures::GetPatchBufferFaceIndex_PH(feaPtr, patchIndex, faceIndex); } MinMaxAvg MeshProcessingFeatures_EIK_EdgeLengthMinMaxAvg_PH(void* ptr) { return MeshProcessingFeatures::EdgeLengthMinMaxAvg_PH(ptr); } MinMaxAvg MeshProcessingFeatures_EIK_FaceAreaMinMaxAvg_PH(void* ptr) { return MeshProcessingFeatures::FaceAreaMinMaxAvg_PH(ptr); } //Surface Mesh int MeshProcessingFeatures_EIK_DetectSharpEdges_SM(void* feaPtr, void* meshPtr, double feature_angle) { return MeshProcessingFeatures::DetectSharpEdges_SM(feaPtr, meshPtr, feature_angle); } void MeshProcessingFeatures_EIK_GetSharpEdges_SM(void* feaPtr, void* meshPtr, int* indices, int count) { MeshProcessingFeatures::GetSharpEdges_SM(feaPtr, meshPtr, indices, count); } Index2 MeshProcessingFeatures_EIK_SharpEdgesSegmentation_SM(void* feaPtr, void* meshPtr, double feature_angle) { return MeshProcessingFeatures::SharpEdgesSegmentation_SM(feaPtr, meshPtr, feature_angle); } void MeshProcessingFeatures_EIK_ClearPatchBuffer_SM(void* feaPtr) { MeshProcessingFeatures::ClearPatchBuffer_SM(feaPtr); } int MeshProcessingFeatures_EIK_GetPatchBufferFaceCount_SM(void* feaPtr, int patchIndex) { return MeshProcessingFeatures::GetPatchBufferFaceCount_SM(feaPtr, patchIndex); } int MeshProcessingFeatures_EIK_GetPatchBufferFaceIndex_SM(void* feaPtr, int patchIndex, int faceIndex) { return MeshProcessingFeatures::GetPatchBufferFaceIndex_SM(feaPtr, patchIndex, faceIndex); } MinMaxAvg MeshProcessingFeatures_EIK_EdgeLengthMinMaxAvg_SM(void* ptr) { return MeshProcessingFeatures::EdgeLengthMinMaxAvg_SM(ptr); } MinMaxAvg MeshProcessingFeatures_EIK_FaceAreaMinMaxAvg_SM(void* ptr) { return MeshProcessingFeatures::FaceAreaMinMaxAvg_SM(ptr); } ================================================ FILE: CGALWrapper/Processing/MeshProcessingFeatures_EIK.h ================================================ #pragma once #include "../CGALWrapper.h" #include "../Geometry/Geometry3.h" #include "../Geometry/Index.h" #include "../Geometry/MinMax.h" extern "C" { CGALWRAPPER_API void* MeshProcessingFeatures_EIK_Create(); CGALWRAPPER_API void MeshProcessingFeatures_EIK_Release(void* ptr); //Polyhedron CGALWRAPPER_API int MeshProcessingFeatures_EIK_DetectSharpEdges_PH(void* feaPtr, void* meshPtr, double feature_angle); CGALWRAPPER_API void MeshProcessingFeatures_EIK_GetSharpEdges_PH(void* feaPtr, void* meshPtr, int* indices, int count); CGALWRAPPER_API Index2 MeshProcessingFeatures_EIK_SharpEdgesSegmentation_PH(void* feaPtr, void* meshPtr, double feature_angle); CGALWRAPPER_API void MeshProcessingFeatures_EIK_ClearPatchBuffer_PH(void* feaPtr); CGALWRAPPER_API int MeshProcessingFeatures_EIK_GetPatchBufferFaceCount_PH(void* feaPtr, int patchIndex); CGALWRAPPER_API int MeshProcessingFeatures_EIK_GetPatchBufferFaceIndex_PH(void* feaPtr, int patchIndex, int faceIndex); CGALWRAPPER_API MinMaxAvg MeshProcessingFeatures_EIK_EdgeLengthMinMaxAvg_PH(void* ptr); CGALWRAPPER_API MinMaxAvg MeshProcessingFeatures_EIK_FaceAreaMinMaxAvg_PH(void* ptr); //Surface Mesh CGALWRAPPER_API int MeshProcessingFeatures_EIK_DetectSharpEdges_SM(void* feaPtr, void* meshPtr, double feature_angle); CGALWRAPPER_API void MeshProcessingFeatures_EIK_GetSharpEdges_SM(void* feaPtr, void* meshPtr, int* indices, int count); CGALWRAPPER_API Index2 MeshProcessingFeatures_EIK_SharpEdgesSegmentation_SM(void* feaPtr, void* meshPtr, double feature_angle); CGALWRAPPER_API void MeshProcessingFeatures_EIK_ClearPatchBuffer_SM(void* feaPtr); CGALWRAPPER_API int MeshProcessingFeatures_EIK_GetPatchBufferFaceCount_SM(void* feaPtr, int patchIndex); CGALWRAPPER_API int MeshProcessingFeatures_EIK_GetPatchBufferFaceIndex_SM(void* feaPtr, int patchIndex, int faceIndex); CGALWRAPPER_API MinMaxAvg MeshProcessingFeatures_EIK_EdgeLengthMinMaxAvg_SM(void* ptr); CGALWRAPPER_API MinMaxAvg MeshProcessingFeatures_EIK_FaceAreaMinMaxAvg_SM(void* ptr); } ================================================ FILE: CGALWrapper/Processing/MeshProcessingLocate.h ================================================ #pragma once #include "../CGALWrapper.h" #include "../Geometry/Index.h" #include "../Polyhedra/Polyhedron3.h" #include "../Polyhedra/SurfaceMesh3.h" #include "../Polyhedra/MeshHitResult.h" #include #include #include #include #include #include #include namespace CP = CGAL::parameters; namespace PMP = CGAL::Polygon_mesh_processing; template class MeshProcessingLocate { public: typedef typename K::FT FT; typedef typename K::Point_2 Point_2; typedef typename K::Ray_2 Ray_2; typedef typename K::Point_3 Point_3; typedef typename K::Ray_3 Ray_3; typedef CGAL::Polyhedron_3 Polyhedron; typedef typename boost::graph_traits::edge_descriptor PEdge_Des; typedef typename boost::graph_traits::face_descriptor PFace_Des; typedef typename CGAL::Surface_mesh SurfaceMesh; typedef typename SurfaceMesh::Face_index SFace; typedef typename boost::graph_traits::edge_descriptor SEdge_Des; typedef typename boost::graph_traits::face_descriptor SFace_Des; typedef PMP::Barycentric_coordinates Barycentric_coordinates; typedef PMP::Face_location PFace_location; typedef PMP::Face_location SFace_location; inline static MeshProcessingLocate* NewMeshProcessingLocate() { return new MeshProcessingLocate(); } inline static void DeleteMeshProcessingLocate(void* ptr) { auto obj = static_cast(ptr); if (obj != nullptr) { delete obj; obj = nullptr; } } inline static MeshProcessingLocate* CastToMeshProcessingLocate(void* ptr) { return static_cast(ptr); } static Point3d ToPoint3d(const Barycentric_coordinates& coord) { double x = CGAL::to_double(coord[0]); double y = CGAL::to_double(coord[1]); double z = CGAL::to_double(coord[2]); return { x, y, z }; } //Polyhedron static Point3d RandomLocationOnMesh_PH(void* ptr) { auto mesh = Polyhedron3::CastToPolyhedron(ptr); auto location = PMP::random_location_on_mesh(mesh->model); //auto face = location.first; //auto coordinates = location.second; auto point = PMP::construct_point(location, mesh->model); return Point3d::FromCGAL(point); } static MeshHitResult LocateFace_PH(void* ptr, const Ray3d& ray) { auto mesh = Polyhedron3::CastToPolyhedron(ptr); mesh->BuildAABBTree(); auto pos = ray.position.ToCGAL(); auto dir = ray.direction.ToCGAL(); Ray_3 r(pos, dir); auto location = PMP::locate_with_AABB_tree(r, *mesh->tree, mesh->model); auto face = location.first; auto coord = location.second; MeshHitResult result; result.face = mesh->FindFaceIndex(face); if (result.face != NULL_INDEX) { result.point = Point3d::FromCGAL(PMP::construct_point(location, mesh->model)); result.coord = ToPoint3d(coord); } else { result.point = { 0,0,0 }; result.coord = { 0,0,0 }; } return result; } static MeshHitResult LocateFace_PH(void* ptr, const Point3d& point) { auto mesh = Polyhedron3::CastToPolyhedron(ptr); mesh->BuildAABBTree(); auto location = PMP::locate_with_AABB_tree(point.ToCGAL(), *mesh->tree, mesh->model); auto face = location.first; auto coord = location.second; MeshHitResult result; result.face = mesh->FindFaceIndex(face); if (result.face != NULL_INDEX) { result.point = Point3d::FromCGAL(PMP::construct_point(location, mesh->model)); result.coord = ToPoint3d(coord); } else { result.point = { 0,0,0 }; result.coord = { 0,0,0 }; } return result; } //SurfaceMesh static Point3d RandomLocationOnMesh_SM(void* ptr) { auto mesh = SurfaceMesh3::CastToSurfaceMesh(ptr); auto location = PMP::random_location_on_mesh(mesh->model); //auto face = location.first; //auto coordinates = location.second; auto point = PMP::construct_point(location, mesh->model); return Point3d::FromCGAL(point); } static MeshHitResult LocateFace_SM(void* ptr, const Ray3d& ray) { auto mesh = SurfaceMesh3::CastToSurfaceMesh(ptr); mesh->BuildAABBTree(); auto pos = ray.position.ToCGAL(); auto dir = ray.direction.ToCGAL(); Ray_3 r(pos, dir); auto location = PMP::locate_with_AABB_tree(r, *mesh->tree, mesh->model); auto face = location.first; auto coord = location.second; MeshHitResult result; result.face = mesh->FindFaceIndex(face); if (result.face != NULL_INDEX) { result.point = Point3d::FromCGAL(PMP::construct_point(location, mesh->model)); result.coord = ToPoint3d(coord); } else { result.point = { 0,0,0 }; result.coord = { 0,0,0 }; } return result; } static MeshHitResult LocateFace_SM(void* ptr, const Point3d& point) { auto mesh = SurfaceMesh3::CastToSurfaceMesh(ptr); mesh->BuildAABBTree(); auto location = PMP::locate_with_AABB_tree(point.ToCGAL(), *mesh->tree, mesh->model); auto face = location.first; auto coord = location.second; MeshHitResult result; result.face = mesh->FindFaceIndex(face); if (result.face != NULL_INDEX) { result.point = Point3d::FromCGAL(PMP::construct_point(location, mesh->model)); result.coord = ToPoint3d(coord); } else { result.point = { 0,0,0 }; result.coord = { 0,0,0 }; } return result; } }; ================================================ FILE: CGALWrapper/Processing/MeshProcessingLocate_EEK.cpp ================================================ #include "MeshProcessingLocate_EEK.h" #include "MeshProcessingLocate.h" void* MeshProcessingLocate_EEK_Create() { return MeshProcessingLocate::NewMeshProcessingLocate(); } void MeshProcessingLocate_EEK_Release(void* ptr) { MeshProcessingLocate::DeleteMeshProcessingLocate(ptr); } //Polyhedron Point3d MeshProcessingLocate_EEK_RandomLocationOnMesh_PH(void* ptr) { return MeshProcessingLocate::RandomLocationOnMesh_PH(ptr); } MeshHitResult MeshProcessingLocate_EEK_LocateFaceRay_PH(void* ptr, const Ray3d& ray) { return MeshProcessingLocate::LocateFace_PH(ptr, ray); } MeshHitResult MeshProcessingLocate_EEK_LocateFacePoint_PH(void* ptr, const Point3d& point) { return MeshProcessingLocate::LocateFace_PH(ptr, point); } //SurfaceMesh Point3d MeshProcessingLocate_EEK_RandomLocationOnMesh_SM(void* ptr) { return MeshProcessingLocate::RandomLocationOnMesh_SM(ptr); } MeshHitResult MeshProcessingLocate_EEK_LocateFaceRay_SM(void* ptr, const Ray3d& ray) { return MeshProcessingLocate::LocateFace_SM(ptr, ray); } MeshHitResult MeshProcessingLocate_EEK_LocateFacePoint_SM(void* ptr, const Point3d& point) { return MeshProcessingLocate::LocateFace_SM(ptr, point); } ================================================ FILE: CGALWrapper/Processing/MeshProcessingLocate_EEK.h ================================================ #pragma once #include "../CGALWrapper.h" #include "../Geometry/Geometry3.h" #include "../Polyhedra/MeshHitResult.h" extern "C" { CGALWRAPPER_API void* MeshProcessingLocate_EEK_Create(); CGALWRAPPER_API void MeshProcessingLocate_EEK_Release(void* ptr); //Polyhedron CGALWRAPPER_API Point3d MeshProcessingLocate_EEK_RandomLocationOnMesh_PH(void* ptr); CGALWRAPPER_API MeshHitResult MeshProcessingLocate_EEK_LocateFaceRay_PH(void* ptr, const Ray3d& ray); CGALWRAPPER_API MeshHitResult MeshProcessingLocate_EEK_LocateFacePoint_PH(void* ptr, const Point3d& point); //SurfaceMesh CGALWRAPPER_API Point3d MeshProcessingLocate_EEK_RandomLocationOnMesh_SM(void* ptr); CGALWRAPPER_API MeshHitResult MeshProcessingLocate_EEK_LocateFaceRay_SM(void* ptr, const Ray3d& ray); CGALWRAPPER_API MeshHitResult MeshProcessingLocate_EEK_LocateFacePoint_SM(void* ptr, const Point3d& point); } ================================================ FILE: CGALWrapper/Processing/MeshProcessingLocate_EIK.cpp ================================================ #include "MeshProcessingLocate_EIK.h" #include "MeshProcessingLocate.h" void* MeshProcessingLocate_EIK_Create() { return MeshProcessingLocate::NewMeshProcessingLocate(); } void MeshProcessingLocate_EIK_Release(void* ptr) { MeshProcessingLocate::DeleteMeshProcessingLocate(ptr); } //Polyhedron Point3d MeshProcessingLocate_EIK_RandomLocationOnMesh_PH(void* ptr) { return MeshProcessingLocate::RandomLocationOnMesh_PH(ptr); } MeshHitResult MeshProcessingLocate_EIK_LocateFaceRay_PH(void* ptr, const Ray3d& ray) { return MeshProcessingLocate::LocateFace_PH(ptr, ray); } MeshHitResult MeshProcessingLocate_EIK_LocateFacePoint_PH(void* ptr, const Point3d& point) { return MeshProcessingLocate::LocateFace_PH(ptr, point); } //SurfaceMesh Point3d MeshProcessingLocate_EIK_RandomLocationOnMesh_SM(void* ptr) { return MeshProcessingLocate::RandomLocationOnMesh_SM(ptr); } MeshHitResult MeshProcessingLocate_EIK_LocateFaceRay_SM(void* ptr, const Ray3d& ray) { return MeshProcessingLocate::LocateFace_SM(ptr, ray); } MeshHitResult MeshProcessingLocate_EIK_LocateFacePoint_SM(void* ptr, const Point3d& point) { return MeshProcessingLocate::LocateFace_SM(ptr, point); } ================================================ FILE: CGALWrapper/Processing/MeshProcessingLocate_EIK.h ================================================ #pragma once #include "../CGALWrapper.h" #include "../Geometry/Geometry3.h" #include "../Polyhedra/MeshHitResult.h" extern "C" { CGALWRAPPER_API void* MeshProcessingLocate_EIK_Create(); CGALWRAPPER_API void MeshProcessingLocate_EIK_Release(void* ptr); //Polyhedron CGALWRAPPER_API Point3d MeshProcessingLocate_EIK_RandomLocationOnMesh_PH(void* ptr); CGALWRAPPER_API MeshHitResult MeshProcessingLocate_EIK_LocateFaceRay_PH(void* ptr, const Ray3d& ray); CGALWRAPPER_API MeshHitResult MeshProcessingLocate_EIK_LocateFacePoint_PH(void* ptr, const Point3d& point); //SurfaceMesh CGALWRAPPER_API Point3d MeshProcessingLocate_EIK_RandomLocationOnMesh_SM(void* ptr); CGALWRAPPER_API MeshHitResult MeshProcessingLocate_EIK_LocateFaceRay_SM(void* ptr, const Ray3d& ray); CGALWRAPPER_API MeshHitResult MeshProcessingLocate_EIK_LocateFacePoint_SM(void* ptr, const Point3d& point); } ================================================ FILE: CGALWrapper/Processing/MeshProcessingMeshing.h ================================================ #pragma once #include "../CGALWrapper.h" #include "../Polyhedra/Polyhedron3.h" #include "../Polyhedra/SurfaceMesh3.h" #include "../Geometry/Index.h" #include "../Geometry/Geometry3.h" #include #include #include #include #include #include #include #include #include #include #include template class MeshProcessingMeshing { public: typedef typename K::Point_3 Point_3; typedef typename K::Vector_3 Vector_3; typedef CGAL::Polyhedron_3 Polyhedron; typedef typename boost::graph_traits::edge_descriptor PEdge_Des; typedef typename boost::graph_traits::halfedge_descriptor PHalfedge_Des; typedef typename boost::graph_traits::face_descriptor PFace_Des; typedef typename Polyhedron::Vertex_handle PVertex_Handle; typedef typename CGAL::Surface_mesh SurfaceMesh; typedef typename SurfaceMesh::Face_index SFace; typedef typename boost::graph_traits::edge_descriptor SEdge_Des; typedef typename boost::graph_traits::halfedge_descriptor SHalfedge_Des; typedef typename boost::graph_traits::face_descriptor SFace_Des; typedef typename SurfaceMesh::Vertex_index SVertex_Index; inline static MeshProcessingMeshing* NewMeshProcessingMeshing() { return new MeshProcessingMeshing(); } inline static void DeleteMeshProcessingMeshing(void* ptr) { auto obj = static_cast(ptr); if (obj != nullptr) { delete obj; obj = nullptr; } } inline static MeshProcessingMeshing* CastToMeshProcessingMeshing(void* ptr) { return static_cast(ptr); } //Polyhedron struct HalfedgeToEdge_PM { HalfedgeToEdge_PM(const Polyhedron& m, std::vector& edges) : m_mesh(m), m_edges(edges) {} void operator()(const PHalfedge_Des& h) const { m_edges.push_back(edge(h, m_mesh)); } const Polyhedron& m_mesh; std::vector& m_edges; }; // extract vertices which are at most k (inclusive) // far from vertex v in the graph of edges static void ExtractKRing_PH(PVertex_Handle v, int k, std::vector& qv) { std::map D; qv.push_back(v); D[v] = 0; std::size_t current_index = 0; int dist_v; while (current_index < qv.size() && (dist_v = D[qv[current_index]]) < k) { v = qv[current_index++]; auto e(v->vertex_begin()), e_end(e); do { PVertex_Handle new_v = e->opposite()->vertex(); if (D.insert(std::make_pair(new_v, dist_v + 1)).second) qv.push_back(new_v); } while (++e != e_end); } } static void* Extrude_PH(void* meshPtr, Vector3d dir) { auto mesh = Polyhedron3::CastToPolyhedron(meshPtr); auto extruded = Polyhedron3::NewPolyhedron(); CGAL::Polygon_mesh_processing::extrude_mesh(mesh->model, extruded->model, dir.ToCGAL()); return extruded; } static Index2 Fair_PH(void* meshPtr, int index, int k_ring) { auto mesh = Polyhedron3::CastToPolyhedron(meshPtr); int count = (int)mesh->model.size_of_facets(); if (k_ring <= 0 || index < 0 || index >= count) return { FALSE, 0 }; auto v = mesh->model.vertices_begin(); std::advance(v, index); std::vector region; ExtractKRing_PH(v, k_ring, region); //If whole mesh is select result will be degenerate. //All vertices will collapse to origin. if(region.size() >= (int)mesh->model.size_of_vertices()) return { FALSE, (int)region.size() }; BOOL successful = CGAL::Polygon_mesh_processing::fair(mesh->model, region); if(successful) mesh->OnModelChanged(); return { successful, (int)region.size() }; } static Index2 Refine_PH(void* meshPtr, double density_control_factor) { auto mesh = Polyhedron3::CastToPolyhedron(meshPtr); std::vector new_facets; std::vector new_vertices; auto param = CGAL::parameters::density_control_factor(density_control_factor); CGAL::Polygon_mesh_processing::refine(mesh->model, faces(mesh->model), std::back_inserter(new_facets), std::back_inserter(new_vertices), param); mesh->OnModelChanged(); return { (int)new_vertices.size(), (int)new_facets.size() }; } static int IsotropicRemeshing_PH(void* meshPtr, int iterations, double target_edge_length) { auto mesh = Polyhedron3::CastToPolyhedron(meshPtr); int count_before = (int)mesh->model.size_of_vertices(); std::vector border; auto it = boost::make_function_output_iterator(HalfedgeToEdge_PM(mesh->model, border)); CGAL::Polygon_mesh_processing::border_halfedges(faces(mesh->model), mesh->model, it); CGAL::Polygon_mesh_processing::split_long_edges(border, target_edge_length, mesh->model); auto param = CGAL::Polygon_mesh_processing::parameters:: number_of_iterations(iterations) .protect_constraints(true); CGAL::Polygon_mesh_processing::isotropic_remeshing(faces(mesh->model), target_edge_length, mesh->model, param); mesh->OnModelChanged(); return (int)mesh->model.size_of_vertices() - count_before; } static void RandomPerturbation_PH(void* meshPtr, double perturbation_max_size) { auto mesh = Polyhedron3::CastToPolyhedron(meshPtr); CGAL::Polygon_mesh_processing::random_perturbation(vertices(mesh->model), mesh->model, perturbation_max_size); mesh->OnModelChanged(); } static void SmoothMesh_PH(void* meshPtr, double featureAngle, int iterations) { /* auto mesh = Polyhedron3::CastToPolyhedron(meshPtr); typedef boost::property_map::type FeatureMap; FeatureMap map = get(CGAL::edge_is_feature, mesh->model); CGAL::Polygon_mesh_processing::detect_sharp_edges(mesh->model, featureAngle, map); auto param = CGAL::Polygon_mesh_processing::parameters::number_of_iterations(iterations). use_safety_constraints(false). edge_is_constrained_map(map); CGAL::Polygon_mesh_processing::smooth_mesh(faces(mesh->model), mesh->model, param); mesh->OnModelChanged(); */ } static void SmoothShape_PH(void* meshPtr, double timeStep, int iterations) { /* auto mesh = Polyhedron3::CastToPolyhedron(meshPtr); std::set constrained_vertices; for (auto v : vertices(mesh->model)) { if (is_border(v, mesh->model)) constrained_vertices.insert(v); } CGAL::Boolean_property_map > map(constrained_vertices); auto param = CGAL::Polygon_mesh_processing::parameters:: number_of_iterations(iterations) .vertex_is_constrained_map(map); CGAL::Polygon_mesh_processing::smooth_shape(mesh->model, timeStep, param); mesh->OnModelChanged(); */ } static int SplitLongEdges_PH(void* meshPtr, double target_edge_length) { auto mesh = Polyhedron3::CastToPolyhedron(meshPtr); int count_before = (int)mesh->model.size_of_halfedges(); //std::vector border; //CGAL::Polygon_mesh_processing::border_halfedges(faces(mesh->model), mesh->model, // boost::make_function_output_iterator(HalfedgeToEdge_PM(mesh->model, border))); //CGAL::Polygon_mesh_processing::split_long_edges(border, target_edge_length, mesh->model); CGAL::Polygon_mesh_processing::split_long_edges(edges(mesh->model), target_edge_length, mesh->model); return (int)mesh->model.size_of_halfedges() - count_before; } static BOOL TriangulateFace_PH(void* meshPtr, int index) { auto mesh = Polyhedron3::CastToPolyhedron(meshPtr); auto face = mesh->FindFaceIter(index); if (face != nullptr) { std::vector faces; faces.push_back(*face); return CGAL::Polygon_mesh_processing::triangulate_faces(faces, mesh->model); } else { return FALSE; } } static BOOL TriangulateFaces_PH(void* meshPtr, int* faces, int count) { auto mesh = Polyhedron3::CastToPolyhedron(meshPtr); std::vector _faces; for (int i = 0; i < count; i++) { auto face = mesh->FindFaceIter(faces[i]); if (face != nullptr) _faces.push_back(*face); } if (_faces.size() == 0) return FALSE; return CGAL::Polygon_mesh_processing::triangulate_faces(_faces, mesh->model); } //Surface Mesh struct HalfedgeToEdge_SM { HalfedgeToEdge_SM(const SurfaceMesh& m, std::vector& edges) : m_mesh(m), m_edges(edges) {} void operator()(const SHalfedge_Des& h) const { m_edges.push_back(edge(h, m_mesh)); } const SurfaceMesh& m_mesh; std::vector& m_edges; }; // extract vertices which are at most k (inclusive) // far from vertex v in the graph of edges static void ExtractKRing_SM(SVertex_Index v, int k, std::vector& qv) { std::map D; qv.push_back(v); /* D[v] = 0; std::size_t current_index = 0; int dist_v; while (current_index < qv.size() && (dist_v = D[qv[current_index]]) < k) { v = qv[current_index++]; auto e(v->vertex_begin()), e_end(e); do { PVertex_Handle new_v = e->opposite()->vertex(); if (D.insert(std::make_pair(new_v, dist_v + 1)).second) qv.push_back(new_v); } while (++e != e_end); } */ } static void* Extrude_SM(void* meshPtr, Vector3d dir) { auto mesh = SurfaceMesh3::CastToSurfaceMesh(meshPtr); auto extruded = SurfaceMesh3::NewSurfaceMesh(); CGAL::Polygon_mesh_processing::extrude_mesh(mesh->model, extruded->model, dir.ToCGAL()); return extruded; } static Index2 Fair_SM(void* meshPtr, int index, int k_ring) { auto mesh = SurfaceMesh3::CastToSurfaceMesh(meshPtr); int count = (int)mesh->model.number_of_faces(); if (k_ring <= 0 || index < 0 || index >= count) return { FALSE, 0 }; std::vector region; ExtractKRing_SM(SVertex_Index(index), k_ring, region); //If whole mesh is select result will be degenerate. //All vertices will collapse to origin. if (region.size() >= (int)mesh->model.number_of_vertices()) return { FALSE, (int)region.size() }; BOOL successful = CGAL::Polygon_mesh_processing::fair(mesh->model, region); if (successful) mesh->OnModelChanged(); return { successful, (int)region.size() }; } static Index2 Refine_SM(void* meshPtr, double density_control_factor) { auto mesh = SurfaceMesh3::CastToSurfaceMesh(meshPtr); std::vector new_facets; std::vector new_vertices; auto param = CGAL::parameters::density_control_factor(density_control_factor); CGAL::Polygon_mesh_processing::refine(mesh->model, faces(mesh->model), std::back_inserter(new_facets), std::back_inserter(new_vertices), param); mesh->OnModelChanged(); return { (int)new_vertices.size(), (int)new_facets.size() }; } static int IsotropicRemeshing_SM(void* meshPtr, int iterations, double target_edge_length) { auto mesh = SurfaceMesh3::CastToSurfaceMesh(meshPtr); int count_before = (int)mesh->model.number_of_vertices(); std::vector border; auto it = boost::make_function_output_iterator(HalfedgeToEdge_SM(mesh->model, border)); CGAL::Polygon_mesh_processing::border_halfedges(faces(mesh->model), mesh->model, it); CGAL::Polygon_mesh_processing::split_long_edges(border, target_edge_length, mesh->model); auto param = CGAL::Polygon_mesh_processing::parameters:: number_of_iterations(iterations) .protect_constraints(true); CGAL::Polygon_mesh_processing::isotropic_remeshing(faces(mesh->model), target_edge_length, mesh->model, param); mesh->OnModelChanged(); return (int)mesh->model.number_of_vertices() - count_before; } static void RandomPerturbation_SM(void* meshPtr, double perturbation_max_size) { auto mesh = SurfaceMesh3::CastToSurfaceMesh(meshPtr); CGAL::Polygon_mesh_processing::random_perturbation(vertices(mesh->model), mesh->model, perturbation_max_size); mesh->OnModelChanged(); } static void SmoothMesh_SM(void* meshPtr, double featureAngle, int iterations) { auto mesh = SurfaceMesh3::CastToSurfaceMesh(meshPtr); typedef boost::property_map::type FeatureMap; FeatureMap map = get(CGAL::edge_is_feature, mesh->model); CGAL::Polygon_mesh_processing::detect_sharp_edges(mesh->model, featureAngle, map); auto param = CGAL::Polygon_mesh_processing::parameters:: number_of_iterations(iterations). use_safety_constraints(false). edge_is_constrained_map(map); CGAL::Polygon_mesh_processing::smooth_mesh(faces(mesh->model), mesh->model, param); mesh->OnModelChanged(); } static void SmoothShape_SM(void* meshPtr, double timeStep, int iterations) { /* auto mesh = SurfaceMesh3::CastToSurfaceMesh(meshPtr); std::set constrained_vertices; for (auto v : vertices(mesh->model)) { if (is_border(v, mesh->model)) constrained_vertices.insert(v); } CGAL::Boolean_property_map> map(constrained_vertices); auto param = CGAL::Polygon_mesh_processing::parameters:: number_of_iterations(iterations) .vertex_is_constrained_map(map); CGAL::Polygon_mesh_processing::smooth_shape(mesh->model, timeStep, param); mesh->OnModelChanged(); */ } static int SplitLongEdges_SM(void* meshPtr, double target_edge_length) { auto mesh = SurfaceMesh3::CastToSurfaceMesh(meshPtr); int count_before = (int)mesh->model.number_of_halfedges(); //std::vector border; //auto it = boost::make_function_output_iterator(HalfedgeToEdge_SM(mesh->model, border)); //CGAL::Polygon_mesh_processing::border_halfedges(faces(mesh->model), mesh->model, it); //CGAL::Polygon_mesh_processing::split_long_edges(border, target_edge_length, mesh->model); CGAL::Polygon_mesh_processing::split_long_edges(edges(mesh->model), target_edge_length, mesh->model); return (int)mesh->model.number_of_halfedges() - count_before; } static BOOL TriangulateFace_SM(void* meshPtr, int index) { auto mesh = SurfaceMesh3::CastToSurfaceMesh(meshPtr); auto face = mesh->FindFace(index); if (face != SurfaceMesh3::NullFace()) { std::vector faces; faces.push_back(face); return CGAL::Polygon_mesh_processing::triangulate_faces(faces, mesh->model); } else { return FALSE; } } static BOOL TriangulateFaces_SM(void* meshPtr, int* faces, int count) { auto mesh = SurfaceMesh3::CastToSurfaceMesh(meshPtr); std::vector _faces; for (int i = 0; i < count; i++) { auto face = mesh->FindFace(faces[i]); if (face != SurfaceMesh3::NullFace()) _faces.push_back(face); } if (_faces.size() == 0) return FALSE; return CGAL::Polygon_mesh_processing::triangulate_faces(_faces, mesh->model); } }; ================================================ FILE: CGALWrapper/Processing/MeshProcessingMeshing_EEK.cpp ================================================ #include "MeshProcessingMeshing_EEK.h" #include "MeshProcessingMeshing.h" void* MeshProcessingMeshing_EEK_Create() { return MeshProcessingMeshing::NewMeshProcessingMeshing(); } void MeshProcessingMeshing_EEK_Release(void* ptr) { MeshProcessingMeshing::DeleteMeshProcessingMeshing(ptr); } //Polyhedron void* MeshProcessingMeshing_EEK_Extrude_PH(void* meshPtr, Vector3d dir) { return MeshProcessingMeshing::Extrude_PH(meshPtr, dir); } Index2 MeshProcessingMeshing_EEK_Fair_PH(void* meshPtr, int index, int k_ring) { return MeshProcessingMeshing::Fair_PH(meshPtr, index, k_ring); } Index2 MeshProcessingMeshing_EEK_Refine_PH(void* meshPtr, double density_control_factor) { return MeshProcessingMeshing::Refine_PH(meshPtr, density_control_factor); } int MeshProcessingMeshing_EEK_IsotropicRemeshing_PH(void* meshPtr, int iterations, double target_edge_length) { return MeshProcessingMeshing::IsotropicRemeshing_PH(meshPtr, iterations, target_edge_length); } void MeshProcessingMeshing_EEK_RandomPerturbation_PH(void* meshPtr, double perturbation_max_size) { MeshProcessingMeshing::RandomPerturbation_PH(meshPtr, perturbation_max_size); } void MeshProcessingMeshing_EEK_SmoothMesh_PH(void* meshPtr, double featureAngle, int iterations) { MeshProcessingMeshing::SmoothMesh_PH(meshPtr, featureAngle, iterations); } void MeshProcessingMeshing_EEK_SmoothShape_PH(void* meshPtr, double timeStep, int iterations) { MeshProcessingMeshing::SmoothShape_PH(meshPtr, timeStep, iterations); } int MeshProcessingMeshing_EEK_SplitLongEdges_PH(void* meshPtr, double target_edge_length) { return MeshProcessingMeshing::SplitLongEdges_PH(meshPtr, target_edge_length); } BOOL MeshProcessingMeshing_EEK_TriangulateFace_PH(void* meshPtr, int index) { return MeshProcessingMeshing::TriangulateFace_PH(meshPtr, index); } BOOL MeshProcessingMeshing_EEK_TriangulateFaces_PH(void* meshPtr, int* faces, int count) { return MeshProcessingMeshing::TriangulateFaces_PH(meshPtr, faces, count); } //Surface Mesh void* MeshProcessingMeshing_EEK_Extrude_SM(void* meshPtr, Vector3d dir) { return MeshProcessingMeshing::Extrude_SM(meshPtr, dir); } Index2 MeshProcessingMeshing_EEK_Fair_SM(void* meshPtr, int index, int k_ring) { return MeshProcessingMeshing::Fair_SM(meshPtr, index, k_ring); } Index2 MeshProcessingMeshing_EEK_Refine_SM(void* meshPtr, double density_control_factor) { return MeshProcessingMeshing::Refine_SM(meshPtr, density_control_factor); } int MeshProcessingMeshing_EEK_IsotropicRemeshing_SM(void* meshPtr, int iterations, double target_edge_length) { return MeshProcessingMeshing::IsotropicRemeshing_SM(meshPtr, iterations, target_edge_length); } void MeshProcessingMeshing_EEK_RandomPerturbation_SM(void* meshPtr, double perturbation_max_size) { MeshProcessingMeshing::RandomPerturbation_SM(meshPtr, perturbation_max_size); } void MeshProcessingMeshing_EEK_SmoothMesh_SM(void* meshPtr, double featureAngle, int iterations) { MeshProcessingMeshing::SmoothMesh_SM(meshPtr, featureAngle, iterations); } void MeshProcessingMeshing_EEK_SmoothShape_SM(void* meshPtr, double timeStep, int iterations) { MeshProcessingMeshing::SmoothShape_SM(meshPtr, timeStep, iterations); } int MeshProcessingMeshing_EEK_SplitLongEdges_SM(void* meshPtr, double target_edge_length) { return MeshProcessingMeshing::SplitLongEdges_SM(meshPtr, target_edge_length); } BOOL MeshProcessingMeshing_EEK_TriangulateFace_SM(void* meshPtr, int index) { return MeshProcessingMeshing::TriangulateFace_SM(meshPtr, index); } BOOL MeshProcessingMeshing_EEK_TriangulateFaces_SM(void* meshPtr, int* faces, int count) { return MeshProcessingMeshing::TriangulateFaces_SM(meshPtr, faces, count); } ================================================ FILE: CGALWrapper/Processing/MeshProcessingMeshing_EEK.h ================================================ #pragma once #include "../CGALWrapper.h" #include "../Geometry/Geometry3.h" #include "../Geometry/Index.h" extern "C" { CGALWRAPPER_API void* MeshProcessingMeshing_EEK_Create(); CGALWRAPPER_API void MeshProcessingMeshing_EEK_Release(void* ptr); //Polyhedron CGALWRAPPER_API void* MeshProcessingMeshing_EEK_Extrude_PH(void* meshPtr, Vector3d dir); CGALWRAPPER_API Index2 MeshProcessingMeshing_EEK_Fair_PH(void* meshPtr, int index, int k_ring); CGALWRAPPER_API Index2 MeshProcessingMeshing_EEK_Refine_PH(void* meshPtr, double density_control_factor); CGALWRAPPER_API int MeshProcessingMeshing_EEK_IsotropicRemeshing_PH(void* meshPtr, int iterations, double target_edge_length); CGALWRAPPER_API void MeshProcessingMeshing_EEK_RandomPerturbation_PH(void* meshPtr, double perturbation_max_size); CGALWRAPPER_API void MeshProcessingMeshing_EEK_SmoothMesh_PH(void* meshPtr, double featureAngle, int iterations); CGALWRAPPER_API void MeshProcessingMeshing_EEK_SmoothShape_PH(void* meshPtr, double timeStep, int iterations); CGALWRAPPER_API int MeshProcessingMeshing_EEK_SplitLongEdges_PH(void* meshPtr, double target_edge_length); CGALWRAPPER_API BOOL MeshProcessingMeshing_EEK_TriangulateFace_PH(void* meshPtr, int index); CGALWRAPPER_API BOOL MeshProcessingMeshing_EEK_TriangulateFaces_PH(void* meshPtr, int* faces, int count); //Surface Mesh CGALWRAPPER_API void* MeshProcessingMeshing_EEK_Extrude_SM(void* meshPtr, Vector3d dir); CGALWRAPPER_API Index2 MeshProcessingMeshing_EEK_Fair_SM(void* meshPtr, int index, int k_ring); CGALWRAPPER_API Index2 MeshProcessingMeshing_EEK_Refine_SM(void* meshPtr, double density_control_factor); CGALWRAPPER_API int MeshProcessingMeshing_EEK_IsotropicRemeshing_SM(void* meshPtr, int iterations, double target_edge_length); CGALWRAPPER_API void MeshProcessingMeshing_EEK_RandomPerturbation_SM(void* meshPtr, double perturbation_max_size); CGALWRAPPER_API void MeshProcessingMeshing_EEK_SmoothMesh_SM(void* meshPtr, double featureAngle, int iterations); CGALWRAPPER_API void MeshProcessingMeshing_EEK_SmoothShape_SM(void* meshPtr, double timeStep, int iterations); CGALWRAPPER_API int MeshProcessingMeshing_EEK_SplitLongEdges_SM(void* meshPtr, double target_edge_length); CGALWRAPPER_API BOOL MeshProcessingMeshing_EEK_TriangulateFace_SM(void* meshPtr, int index); CGALWRAPPER_API BOOL MeshProcessingMeshing_EEK_TriangulateFaces_SM(void* meshPtr, int* faces, int count); } ================================================ FILE: CGALWrapper/Processing/MeshProcessingMeshing_EIK.cpp ================================================ #include "MeshProcessingMeshing_EIK.h" #include "MeshProcessingMeshing.h" void* MeshProcessingMeshing_EIK_Create() { return MeshProcessingMeshing::NewMeshProcessingMeshing(); } void MeshProcessingMeshing_EIK_Release(void* ptr) { MeshProcessingMeshing::DeleteMeshProcessingMeshing(ptr); } //Polyhedron void* MeshProcessingMeshing_EIK_Extrude_PH(void* meshPtr, Vector3d dir) { return MeshProcessingMeshing::Extrude_PH(meshPtr, dir); } Index2 MeshProcessingMeshing_EIK_Fair_PH(void* meshPtr, int index, int k_ring) { return MeshProcessingMeshing::Fair_PH(meshPtr, index, k_ring); } Index2 MeshProcessingMeshing_EIK_Refine_PH(void* meshPtr, double density_control_factor) { return MeshProcessingMeshing::Refine_PH(meshPtr, density_control_factor); } int MeshProcessingMeshing_EIK_IsotropicRemeshing_PH(void* meshPtr, int iterations, double target_edge_length) { return MeshProcessingMeshing::IsotropicRemeshing_PH(meshPtr, iterations, target_edge_length); } void MeshProcessingMeshing_EIK_RandomPerturbation_PH(void* meshPtr, double perturbation_max_size) { MeshProcessingMeshing::RandomPerturbation_PH(meshPtr, perturbation_max_size); } void MeshProcessingMeshing_EIK_SmoothMesh_PH(void* meshPtr, double featureAngle, int iterations) { MeshProcessingMeshing::SmoothMesh_PH(meshPtr, featureAngle, iterations); } void MeshProcessingMeshing_EIK_SmoothShape_PH(void* meshPtr, double timeStep, int iterations) { MeshProcessingMeshing::SmoothShape_PH(meshPtr, timeStep, iterations); } int MeshProcessingMeshing_EIK_SplitLongEdges_PH(void* meshPtr, double target_edge_length) { return MeshProcessingMeshing::SplitLongEdges_PH(meshPtr, target_edge_length); } BOOL MeshProcessingMeshing_EIK_TriangulateFace_PH(void* meshPtr, int index) { return MeshProcessingMeshing::TriangulateFace_PH(meshPtr, index); } BOOL MeshProcessingMeshing_EIK_TriangulateFaces_PH(void* meshPtr, int* faces, int count) { return MeshProcessingMeshing::TriangulateFaces_PH(meshPtr, faces, count); } //Surface Mesh void* MeshProcessingMeshing_EIK_Extrude_SM(void* meshPtr, Vector3d dir) { return MeshProcessingMeshing::Extrude_SM(meshPtr, dir); } Index2 MeshProcessingMeshing_EIK_Fair_SM(void* meshPtr, int index, int k_ring) { return MeshProcessingMeshing::Fair_SM(meshPtr, index, k_ring); } Index2 MeshProcessingMeshing_EIK_Refine_SM(void* meshPtr, double density_control_factor) { return MeshProcessingMeshing::Refine_SM(meshPtr, density_control_factor); } int MeshProcessingMeshing_EIK_IsotropicRemeshing_SM(void* meshPtr, int iterations, double target_edge_length) { return MeshProcessingMeshing::IsotropicRemeshing_SM(meshPtr, iterations, target_edge_length); } void MeshProcessingMeshing_EIK_RandomPerturbation_SM(void* meshPtr, double perturbation_max_size) { MeshProcessingMeshing::RandomPerturbation_SM(meshPtr, perturbation_max_size); } void MeshProcessingMeshing_EIK_SmoothMesh_SM(void* meshPtr, double featureAngle, int iterations) { MeshProcessingMeshing::SmoothMesh_SM(meshPtr, featureAngle, iterations); } void MeshProcessingMeshing_EIK_SmoothShape_SM(void* meshPtr, double timeStep, int iterations) { MeshProcessingMeshing::SmoothShape_SM(meshPtr, timeStep, iterations); } int MeshProcessingMeshing_EIK_SplitLongEdges_SM(void* meshPtr, double target_edge_length) { return MeshProcessingMeshing::SplitLongEdges_SM(meshPtr, target_edge_length); } BOOL MeshProcessingMeshing_EIK_TriangulateFace_SM(void* meshPtr, int index) { return MeshProcessingMeshing::TriangulateFace_SM(meshPtr, index); } BOOL MeshProcessingMeshing_EIK_TriangulateFaces_SM(void* meshPtr, int* faces, int count) { return MeshProcessingMeshing::TriangulateFaces_SM(meshPtr, faces, count); } ================================================ FILE: CGALWrapper/Processing/MeshProcessingMeshing_EIK.h ================================================ #pragma once #include "../CGALWrapper.h" #include "../Geometry/Geometry3.h" #include "../Geometry/Index.h" extern "C" { CGALWRAPPER_API void* MeshProcessingMeshing_EIK_Create(); CGALWRAPPER_API void MeshProcessingMeshing_EIK_Release(void* ptr); //Polyhedron CGALWRAPPER_API void* MeshProcessingMeshing_EIK_Extrude_PH(void* meshPtr, Vector3d dir); CGALWRAPPER_API Index2 MeshProcessingMeshing_EIK_Fair_PH(void* meshPtr, int index, int k_ring); CGALWRAPPER_API Index2 MeshProcessingMeshing_EIK_Refine_PH(void* meshPtr, double density_control_factor); CGALWRAPPER_API int MeshProcessingMeshing_EIK_IsotropicRemeshing_PH(void* meshPtr, int iterations, double target_edge_length); CGALWRAPPER_API void MeshProcessingMeshing_EIK_RandomPerturbation_PH(void* meshPtr, double perturbation_max_size); CGALWRAPPER_API void MeshProcessingMeshing_EIK_SmoothMesh_PH(void* meshPtr, double featureAngle, int iterations); CGALWRAPPER_API void MeshProcessingMeshing_EIK_SmoothShape_PH(void* meshPtr, double timeStep, int iterations); CGALWRAPPER_API int MeshProcessingMeshing_EIK_SplitLongEdges_PH(void* meshPtr, double target_edge_length); CGALWRAPPER_API BOOL MeshProcessingMeshing_EIK_TriangulateFace_PH(void* meshPtr, int index); CGALWRAPPER_API BOOL MeshProcessingMeshing_EIK_TriangulateFaces_PH(void* meshPtr, int* faces, int count); //Surface Mesh CGALWRAPPER_API void* MeshProcessingMeshing_EIK_Extrude_SM(void* meshPtr, Vector3d dir); CGALWRAPPER_API Index2 MeshProcessingMeshing_EIK_Fair_SM(void* meshPtr, int index, int k_ring); CGALWRAPPER_API Index2 MeshProcessingMeshing_EIK_Refine_SM(void* meshPtr, double density_control_factor); CGALWRAPPER_API int MeshProcessingMeshing_EIK_IsotropicRemeshing_SM(void* meshPtr, int iterations, double target_edge_length); CGALWRAPPER_API void MeshProcessingMeshing_EIK_RandomPerturbation_SM(void* meshPtr, double perturbation_max_size); CGALWRAPPER_API void MeshProcessingMeshing_EIK_SmoothMesh_SM(void* meshPtr, double featureAngle, int iterations); CGALWRAPPER_API void MeshProcessingMeshing_EIK_SmoothShape_SM(void* meshPtr, double timeStep, int iterations); CGALWRAPPER_API int MeshProcessingMeshing_EIK_SplitLongEdges_SM(void* meshPtr, double target_edge_length); CGALWRAPPER_API BOOL MeshProcessingMeshing_EIK_TriangulateFace_SM(void* meshPtr, int index); CGALWRAPPER_API BOOL MeshProcessingMeshing_EIK_TriangulateFaces_SM(void* meshPtr, int* faces, int count); } ================================================ FILE: CGALWrapper/Processing/MeshProcessingOrientation.h ================================================ #pragma once #include "../CGALWrapper.h" #include "../Polyhedra/Polyhedron3.h" #include "../Polyhedra/SurfaceMesh3.h" #include template class MeshProcessingOrientation { public: inline static MeshProcessingOrientation* NewMeshProcessingOrientation() { return new MeshProcessingOrientation(); } inline static void DeleteMeshProcessingOrientation(void* ptr) { auto obj = static_cast(ptr); if (obj != nullptr) { delete obj; obj = nullptr; } } inline static MeshProcessingOrientation* CastToMeshProcessingOrientation(void* ptr) { return static_cast(ptr); } //Polyhedron static BOOL DoesBoundAVolume_PH(void* meshPtr) { auto mesh = Polyhedron3::CastToPolyhedron(meshPtr); return CGAL::Polygon_mesh_processing::does_bound_a_volume(mesh->model); } static BOOL IsOutwardOriented_PH(void* meshPtr) { auto mesh = Polyhedron3::CastToPolyhedron(meshPtr);; return CGAL::Polygon_mesh_processing::is_outward_oriented(mesh->model); } static void Orient_PH(void* meshPtr) { auto mesh = Polyhedron3::CastToPolyhedron(meshPtr); mesh->OnFaceNormalsChanged(); return CGAL::Polygon_mesh_processing::orient(mesh->model); } static void OrientToBoundAVolume_PH(void* meshPtr) { auto mesh = Polyhedron3::CastToPolyhedron(meshPtr); mesh->OnFaceNormalsChanged(); return CGAL::Polygon_mesh_processing::orient_to_bound_a_volume(mesh->model); } static void ReverseFaceOrientations_PH(void* meshPtr) { auto mesh = Polyhedron3::CastToPolyhedron(meshPtr); mesh->OnFaceNormalsChanged(); return CGAL::Polygon_mesh_processing::reverse_face_orientations(mesh->model); } //Surface Mesh static BOOL DoesBoundAVolume_SM(void* meshPtr) { auto mesh = SurfaceMesh3::CastToSurfaceMesh(meshPtr); return CGAL::Polygon_mesh_processing::does_bound_a_volume(mesh->model); } static BOOL IsOutwardOriented_SM(void* meshPtr) { auto mesh = SurfaceMesh3::CastToSurfaceMesh(meshPtr); return CGAL::Polygon_mesh_processing::is_outward_oriented(mesh->model); } static void Orient_SM(void* meshPtr) { auto mesh = SurfaceMesh3::CastToSurfaceMesh(meshPtr); mesh->OnFaceNormalsChanged(); return CGAL::Polygon_mesh_processing::orient(mesh->model); } static void OrientToBoundAVolume_SM(void* meshPtr) { auto mesh = SurfaceMesh3::CastToSurfaceMesh(meshPtr); mesh->OnFaceNormalsChanged(); return CGAL::Polygon_mesh_processing::orient_to_bound_a_volume(mesh->model); } static void ReverseFaceOrientations_SM(void* meshPtr) { auto mesh = SurfaceMesh3::CastToSurfaceMesh(meshPtr); mesh->OnFaceNormalsChanged(); return CGAL::Polygon_mesh_processing::reverse_face_orientations(mesh->model); } }; ================================================ FILE: CGALWrapper/Processing/MeshProcessingOrientation_EEK.cpp ================================================ #include "MeshProcessingOrientation_EEK.h" #include "MeshProcessingOrientation.h" void* MeshProcessingOrientation_EEK_Create() { return MeshProcessingOrientation::NewMeshProcessingOrientation(); } void MeshProcessingOrientation_EEK_Release(void* ptr) { MeshProcessingOrientation::DeleteMeshProcessingOrientation(ptr); } //Polyhedron BOOL MeshProcessingOrientation_EEK_DoesBoundAVolume_PH(void* meshPtr) { return MeshProcessingOrientation::DoesBoundAVolume_PH(meshPtr); } BOOL MeshProcessingOrientation_EEK_IsOutwardOriented_PH(void* meshPtr) { return MeshProcessingOrientation::IsOutwardOriented_PH(meshPtr); } void MeshProcessingOrientation_EEK_Orient_PH(void* meshPtr) { MeshProcessingOrientation::Orient_PH(meshPtr); } void MeshProcessingOrientation_EEK_OrientToBoundAVolume_PH(void* meshPtr) { MeshProcessingOrientation::OrientToBoundAVolume_PH(meshPtr); } void MeshProcessingOrientation_EEK_ReverseFaceOrientations_PH(void* meshPtr) { MeshProcessingOrientation::ReverseFaceOrientations_PH(meshPtr); } //Surface Mesh BOOL MeshProcessingOrientation_EEK_DoesBoundAVolume_SM(void* meshPtr) { return MeshProcessingOrientation::DoesBoundAVolume_SM(meshPtr); } BOOL MeshProcessingOrientation_EEK_IsOutwardOriented_SM(void* meshPtr) { return MeshProcessingOrientation::IsOutwardOriented_SM(meshPtr); } void MeshProcessingOrientation_EEK_Orient_SM(void* meshPtr) { MeshProcessingOrientation::Orient_SM(meshPtr); } void MeshProcessingOrientation_EEK_OrientToBoundAVolume_SM(void* meshPtr) { MeshProcessingOrientation::OrientToBoundAVolume_SM(meshPtr); } void MeshProcessingOrientation_EEK_ReverseFaceOrientations_SM(void* meshPtr) { MeshProcessingOrientation::ReverseFaceOrientations_SM(meshPtr); } ================================================ FILE: CGALWrapper/Processing/MeshProcessingOrientation_EEK.h ================================================ #pragma once #include "../CGALWrapper.h" extern "C" { CGALWRAPPER_API void* MeshProcessingOrientation_EEK_Create(); CGALWRAPPER_API void MeshProcessingOrientation_EEK_Release(void* ptr); //Polyhedron CGALWRAPPER_API BOOL MeshProcessingOrientation_EEK_DoesBoundAVolume_PH(void* meshPtr); CGALWRAPPER_API BOOL MeshProcessingOrientation_EEK_IsOutwardOriented_PH(void* meshPtr); CGALWRAPPER_API void MeshProcessingOrientation_EEK_Orient_PH(void* meshPtr); CGALWRAPPER_API void MeshProcessingOrientation_EEK_OrientToBoundAVolume_PH(void* meshPtr); CGALWRAPPER_API void MeshProcessingOrientation_EEK_ReverseFaceOrientations_PH(void* meshPtr); //Surface Mesh CGALWRAPPER_API BOOL MeshProcessingOrientation_EEK_DoesBoundAVolume_SM(void* meshPtr); CGALWRAPPER_API BOOL MeshProcessingOrientation_EEK_IsOutwardOriented_SM(void* meshPtr); CGALWRAPPER_API void MeshProcessingOrientation_EEK_Orient_SM(void* meshPtr); CGALWRAPPER_API void MeshProcessingOrientation_EEK_OrientToBoundAVolume_SM(void* meshPtr); CGALWRAPPER_API void MeshProcessingOrientation_EEK_ReverseFaceOrientations_SM(void* meshPtr); } ================================================ FILE: CGALWrapper/Processing/MeshProcessingOrientation_EIK.cpp ================================================ #include "MeshProcessingOrientation_EIK.h" #include "MeshProcessingOrientation.h" void* MeshProcessingOrientation_EIK_Create() { return MeshProcessingOrientation::NewMeshProcessingOrientation(); } void MeshProcessingOrientation_EIK_Release(void* ptr) { MeshProcessingOrientation::DeleteMeshProcessingOrientation(ptr); } //Polyhedron BOOL MeshProcessingOrientation_EIK_DoesBoundAVolume_PH(void* meshPtr) { return MeshProcessingOrientation::DoesBoundAVolume_PH(meshPtr); } BOOL MeshProcessingOrientation_EIK_IsOutwardOriented_PH(void* meshPtr) { return MeshProcessingOrientation::IsOutwardOriented_PH(meshPtr); } void MeshProcessingOrientation_EIK_Orient_PH(void* meshPtr) { MeshProcessingOrientation::Orient_PH(meshPtr); } void MeshProcessingOrientation_EIK_OrientToBoundAVolume_PH(void* meshPtr) { MeshProcessingOrientation::OrientToBoundAVolume_PH(meshPtr); } void MeshProcessingOrientation_EIK_ReverseFaceOrientations_PH(void* meshPtr) { MeshProcessingOrientation::ReverseFaceOrientations_PH(meshPtr); } //Surface Mesh BOOL MeshProcessingOrientation_EIK_DoesBoundAVolume_SM(void* meshPtr) { return MeshProcessingOrientation::DoesBoundAVolume_SM(meshPtr); } BOOL MeshProcessingOrientation_EIK_IsOutwardOriented_SM(void* meshPtr) { return MeshProcessingOrientation::IsOutwardOriented_SM(meshPtr); } void MeshProcessingOrientation_EIK_Orient_SM(void* meshPtr) { MeshProcessingOrientation::Orient_SM(meshPtr); } void MeshProcessingOrientation_EIK_OrientToBoundAVolume_SM(void* meshPtr) { MeshProcessingOrientation::OrientToBoundAVolume_SM(meshPtr); } void MeshProcessingOrientation_EIK_ReverseFaceOrientations_SM(void* meshPtr) { MeshProcessingOrientation::ReverseFaceOrientations_SM(meshPtr); } ================================================ FILE: CGALWrapper/Processing/MeshProcessingOrientation_EIK.h ================================================ #pragma once #include "../CGALWrapper.h" extern "C" { CGALWRAPPER_API void* MeshProcessingOrientation_EIK_Create(); CGALWRAPPER_API void MeshProcessingOrientation_EIK_Release(void* ptr); //Polyhedron CGALWRAPPER_API BOOL MeshProcessingOrientation_EIK_DoesBoundAVolume_PH(void* meshPtr); CGALWRAPPER_API BOOL MeshProcessingOrientation_EIK_IsOutwardOriented_PH(void* meshPtr); CGALWRAPPER_API void MeshProcessingOrientation_EIK_Orient_PH(void* meshPtr); CGALWRAPPER_API void MeshProcessingOrientation_EIK_OrientToBoundAVolume_PH(void* meshPtr); CGALWRAPPER_API void MeshProcessingOrientation_EIK_ReverseFaceOrientations_PH(void* meshPtr); //Surface Mesh CGALWRAPPER_API BOOL MeshProcessingOrientation_EIK_DoesBoundAVolume_SM(void* meshPtr); CGALWRAPPER_API BOOL MeshProcessingOrientation_EIK_IsOutwardOriented_SM(void* meshPtr); CGALWRAPPER_API void MeshProcessingOrientation_EIK_Orient_SM(void* meshPtr); CGALWRAPPER_API void MeshProcessingOrientation_EIK_OrientToBoundAVolume_SM(void* meshPtr); CGALWRAPPER_API void MeshProcessingOrientation_EIK_ReverseFaceOrientations_SM(void* meshPtr); } ================================================ FILE: CGALWrapper/Processing/MeshProcessingRepair.h ================================================ #pragma once #include "../CGALWrapper.h" #include "../Polyhedra/Polyhedron3.h" #include "../Polyhedra/SurfaceMesh3.h" #include #include #include #include #include #include #include #include #include #include #include namespace PMP = CGAL::Polygon_mesh_processing; namespace NP = CGAL::parameters; template class MeshProcessingRepair { public: typedef typename K::FT FT; typedef typename K::Point_3 Point; typedef CGAL::Polyhedron_3 Polyhedron; typedef typename boost::graph_traits::face_descriptor PFace_Des; typedef typename CGAL::Surface_mesh SurfaceMesh; typedef typename boost::graph_traits::face_descriptor SFace_Des; typedef typename std::vector PolygonIndex; inline static MeshProcessingRepair* NewMeshProcessingRepair() { return new MeshProcessingRepair(); } inline static void DeleteMeshProcessingRepair(void* ptr) { auto obj = static_cast(ptr); if (obj != nullptr) { delete obj; obj = nullptr; } } inline static MeshProcessingRepair* CastToMeshProcessingRepair(void* ptr) { return static_cast(ptr); } //Polyhedron static int DegenerateEdgeCount_PH(void* ptr) { auto mesh = Polyhedron3::CastToPolyhedron(ptr); //int count = 0; //for (auto edge = mesh->model.edges_begin(); edge != mesh->model.edges_end(); ++edge) //{ // if (PMP::is_degenerate_edge(edge, mesh->model)) // count++; //} return 0; } static int DegenerateTriangleCount_PH(void* ptr) { auto mesh = Polyhedron3::CastToPolyhedron(ptr); int count = 0; for (auto face = mesh->model.facets_begin(); face != mesh->model.facets_end(); ++face) { if (PMP::is_degenerate_triangle_face(face, mesh->model)) count++; } return count; } static int NeedleTriangleCount_PH(void* ptr, double threshold) { auto mesh = Polyhedron3::CastToPolyhedron(ptr); int count = 0; for (auto face = mesh->model.facets_begin(); face != mesh->model.facets_end(); ++face) { if (PMP::is_needle_triangle_face(face, mesh->model, threshold) != nullptr) count++; } return count; } static int NonManifoldVertexCount_PH(void* ptr) { auto mesh = Polyhedron3::CastToPolyhedron(ptr); int count = 0; for (auto vert = mesh->model.vertices_begin(); vert != mesh->model.vertices_end(); ++vert) { if (PMP::is_non_manifold_vertex(vert, mesh->model)) count++; } return count; } static void RepairPolygonSoup_PH(void* ptr) { auto mesh = Polyhedron3::CastToPolyhedron(ptr); std::vector points; std::vector polygons; PMP::polygon_mesh_to_polygon_soup(mesh->model, points, polygons); PMP::repair_polygon_soup(points, polygons); mesh->model.clear(); mesh->OnModelChanged(); PMP::polygon_soup_to_polygon_mesh(points, polygons, mesh->model); } static int StitchBoundaryCycles_PH(void* ptr) { auto mesh = Polyhedron3::CastToPolyhedron(ptr); mesh->OnModelChanged(); return (int)PMP::stitch_boundary_cycles(mesh->model); } static int StitchBorders_PH(void* ptr) { auto mesh = Polyhedron3::CastToPolyhedron(ptr); mesh->OnModelChanged(); return (int)PMP::stitch_borders(mesh->model); } static int MergeDuplicatedVerticesInBoundaryCycle_PH(void* ptr, int index) { auto mesh = Polyhedron3::CastToPolyhedron(ptr); mesh->OnModelChanged(); int before = (int)mesh->model.size_of_halfedges(); auto hedge = mesh->FindHalfedgeIter(index); if(hedge != nullptr) PMP::merge_duplicated_vertices_in_boundary_cycle(*hedge, mesh->model); return before - (int)mesh->model.size_of_halfedges(); } static int MergeDuplicatedVerticesInBoundaryCycles_PH(void* ptr) { auto mesh = Polyhedron3::CastToPolyhedron(ptr); mesh->OnModelChanged(); int before = (int)mesh->model.size_of_halfedges(); PMP::merge_duplicated_vertices_in_boundary_cycles(mesh->model); return before - (int)mesh->model.size_of_halfedges(); } static int RemoveIsolatedVertices_PH(void* ptr) { auto mesh = Polyhedron3::CastToPolyhedron(ptr); mesh->OnModelChanged(); return (int)PMP::remove_isolated_vertices(mesh->model); } //Surface Mesh static int DegenerateEdgeCount_SM(void* ptr) { auto mesh = SurfaceMesh3::CastToSurfaceMesh(ptr); int count = 0; for (const auto edge : mesh->model.edges()) { if (PMP::is_degenerate_edge(edge, mesh->model)) count++; } return count; } static int DegenerateTriangleCount_SM(void* ptr) { auto mesh = SurfaceMesh3::CastToSurfaceMesh(ptr); int count = 0; for (const auto& face : mesh->model.faces()) { if (PMP::is_degenerate_triangle_face(face, mesh->model)) count++; } return count; } static int NeedleTriangleCount_SM(void* ptr, double threshold) { auto mesh = SurfaceMesh3::CastToSurfaceMesh(ptr); auto null_edge = SurfaceMesh3::NullHalfedge(); int count = 0; for (const auto& face : mesh->model.faces()) { if (PMP::is_needle_triangle_face(face, mesh->model, threshold) != null_edge) count++; } return count; } static int NonManifoldVertexCount_SM(void* ptr) { auto mesh = SurfaceMesh3::CastToSurfaceMesh(ptr); int count = 0; for (const auto& vert : mesh->model.vertices()) { if (PMP::is_non_manifold_vertex(vert, mesh->model)) count++; } return count; } static void RepairPolygonSoup_SM(void* ptr) { auto mesh = SurfaceMesh3::CastToSurfaceMesh(ptr); std::vector points; std::vector polygons; PMP::polygon_mesh_to_polygon_soup(mesh->model, points, polygons); PMP::repair_polygon_soup(points, polygons); mesh->model.clear(); mesh->OnModelChanged(); PMP::polygon_soup_to_polygon_mesh(points, polygons, mesh->model); } static int StitchBoundaryCycles_SM(void* ptr) { auto mesh = SurfaceMesh3::CastToSurfaceMesh(ptr); mesh->OnModelChanged(); return (int)PMP::stitch_boundary_cycles(mesh->model); } static int StitchBorders_SM(void* ptr) { auto mesh = SurfaceMesh3::CastToSurfaceMesh(ptr); mesh->OnModelChanged(); return (int)PMP::stitch_borders(mesh->model); } static int MergeDuplicatedVerticesInBoundaryCycle_SM(void* ptr, int index) { auto mesh = SurfaceMesh3::CastToSurfaceMesh(ptr); mesh->OnModelChanged(); int before = (int)mesh->model.number_of_halfedges(); auto hedge = mesh->FindHalfedge(index); if (hedge != SurfaceMesh3::NullHalfedge()) PMP::merge_duplicated_vertices_in_boundary_cycle(hedge, mesh->model); return before - (int)mesh->model.number_of_halfedges(); } static int MergeDuplicatedVerticesInBoundaryCycles_SM(void* ptr) { auto mesh = SurfaceMesh3::CastToSurfaceMesh(ptr); mesh->OnModelChanged(); int before = (int)mesh->model.number_of_halfedges(); PMP::merge_duplicated_vertices_in_boundary_cycles(mesh->model); return before - (int)mesh->model.number_of_halfedges(); } static int RemoveIsolatedVertices_SM(void* ptr) { auto mesh = SurfaceMesh3::CastToSurfaceMesh(ptr); mesh->OnModelChanged(); return (int)PMP::remove_isolated_vertices(mesh->model); } }; ================================================ FILE: CGALWrapper/Processing/MeshProcessingRepair_EEK.cpp ================================================ #include "MeshProcessingRepair_EEK.h" #include "MeshProcessingRepair.h" void* MeshProcessingRepair_EEK_Create() { return MeshProcessingRepair::NewMeshProcessingRepair(); } void MeshProcessingRepair_EEK_Release(void* ptr) { MeshProcessingRepair::DeleteMeshProcessingRepair(ptr); } //Polyhedron int MeshProcessingRepair_EEK_DegenerateEdgeCount_PH(void* ptr) { return MeshProcessingRepair::DegenerateEdgeCount_PH(ptr); } int MeshProcessingRepair_EEK_DegenerateTriangleCount_PH(void* ptr) { return MeshProcessingRepair::DegenerateTriangleCount_PH(ptr); } int MeshProcessingRepair_EEK_NeedleTriangleCount_PH(void* ptr, double threshold) { return MeshProcessingRepair::NeedleTriangleCount_PH(ptr, threshold); } int MeshProcessingRepair_EEK_NonManifoldVertexCount_PH(void* ptr) { return MeshProcessingRepair::NonManifoldVertexCount_PH(ptr); } void MeshProcessingRepair_EEK_RepairPolygonSoup_PH(void* ptr) { MeshProcessingRepair::RepairPolygonSoup_PH(ptr); } int MeshProcessingRepair_EEK_StitchBoundaryCycles_PH(void* ptr) { return MeshProcessingRepair::StitchBoundaryCycles_PH(ptr); } int MeshProcessingRepair_EEK_StitchBorders_PH(void* ptr) { return MeshProcessingRepair::StitchBorders_PH(ptr); } int MeshProcessingRepair_EEK_MergeDuplicatedVerticesInBoundaryCycle_PH(void* ptr, int index) { return MeshProcessingRepair::MergeDuplicatedVerticesInBoundaryCycle_PH(ptr, index); } int MeshProcessingRepair_EEK_MergeDuplicatedVerticesInBoundaryCycles_PH(void* ptr) { return MeshProcessingRepair::MergeDuplicatedVerticesInBoundaryCycles_PH(ptr); } int MeshProcessingRepair_EEK_RemoveIsolatedVertices_PH(void* ptr) { return MeshProcessingRepair::RemoveIsolatedVertices_PH(ptr); } //SurfaceMesh int MeshProcessingRepair_EEK_DegenerateEdgeCount_SM(void* ptr) { return MeshProcessingRepair::DegenerateEdgeCount_SM(ptr); } int MeshProcessingRepair_EEK_DegenerateTriangleCount_SM(void* ptr) { return MeshProcessingRepair::DegenerateTriangleCount_SM(ptr); } int MeshProcessingRepair_EEK_NeedleTriangleCount_SM(void* ptr, double threshold) { return MeshProcessingRepair::NeedleTriangleCount_SM(ptr, threshold); } int MeshProcessingRepair_EEK_NonManifoldVertexCount_SM(void* ptr) { return MeshProcessingRepair::NonManifoldVertexCount_SM(ptr); } void MeshProcessingRepair_EEK_RepairPolygonSoup_SM(void* ptr) { MeshProcessingRepair::RepairPolygonSoup_SM(ptr); } int MeshProcessingRepair_EEK_StitchBoundaryCycles_SM(void* ptr) { return MeshProcessingRepair::StitchBoundaryCycles_SM(ptr); } int MeshProcessingRepair_EEK_StitchBorders_SM(void* ptr) { return MeshProcessingRepair::StitchBorders_SM(ptr); } int MeshProcessingRepair_EEK_MergeDuplicatedVerticesInBoundaryCycle_SM(void* ptr, int index) { return MeshProcessingRepair::MergeDuplicatedVerticesInBoundaryCycle_SM(ptr, index); } int MeshProcessingRepair_EEK_MergeDuplicatedVerticesInBoundaryCycles_SM(void* ptr) { return MeshProcessingRepair::MergeDuplicatedVerticesInBoundaryCycles_SM(ptr); } int MeshProcessingRepair_EEK_RemoveIsolatedVertices_SM(void* ptr) { return MeshProcessingRepair::RemoveIsolatedVertices_SM(ptr); } ================================================ FILE: CGALWrapper/Processing/MeshProcessingRepair_EEK.h ================================================ #pragma once #include "../CGALWrapper.h" extern "C" { CGALWRAPPER_API void* MeshProcessingRepair_EEK_Create(); CGALWRAPPER_API void MeshProcessingRepair_EEK_Release(void* ptr); //Polyhedron CGALWRAPPER_API int MeshProcessingRepair_EEK_DegenerateEdgeCount_PH(void* ptr); CGALWRAPPER_API int MeshProcessingRepair_EEK_DegenerateTriangleCount_PH(void* ptr); CGALWRAPPER_API int MeshProcessingRepair_EEK_NeedleTriangleCount_PH(void* ptr, double threshold); CGALWRAPPER_API int MeshProcessingRepair_EEK_NonManifoldVertexCount_PH(void* ptr); CGALWRAPPER_API void MeshProcessingRepair_EEK_RepairPolygonSoup_PH(void* ptr); CGALWRAPPER_API int MeshProcessingRepair_EEK_StitchBoundaryCycles_PH(void* ptr); CGALWRAPPER_API int MeshProcessingRepair_EEK_StitchBorders_PH(void* ptr); CGALWRAPPER_API int MeshProcessingRepair_EEK_MergeDuplicatedVerticesInBoundaryCycle_PH(void* ptr, int index); CGALWRAPPER_API int MeshProcessingRepair_EEK_MergeDuplicatedVerticesInBoundaryCycles_PH(void* ptr); CGALWRAPPER_API int MeshProcessingRepair_EEK_RemoveIsolatedVertices_PH(void* ptr); //SurfaceMesh CGALWRAPPER_API int MeshProcessingRepair_EEK_DegenerateEdgeCount_SM(void* ptr); CGALWRAPPER_API int MeshProcessingRepair_EEK_DegenerateTriangleCount_SM(void* ptr); CGALWRAPPER_API int MeshProcessingRepair_EEK_NeedleTriangleCount_SM(void* ptr, double threshold); CGALWRAPPER_API int MeshProcessingRepair_EEK_NonManifoldVertexCount_SM(void* ptr); CGALWRAPPER_API void MeshProcessingRepair_EEK_RepairPolygonSoup_SM(void* ptr); CGALWRAPPER_API int MeshProcessingRepair_EEK_StitchBoundaryCycles_SM(void* ptr); CGALWRAPPER_API int MeshProcessingRepair_EEK_StitchBorders_SM(void* ptr); CGALWRAPPER_API int MeshProcessingRepair_EEK_MergeDuplicatedVerticesInBoundaryCycle_SM(void* ptr, int index); CGALWRAPPER_API int MeshProcessingRepair_EEK_MergeDuplicatedVerticesInBoundaryCycles_SM(void* ptr); CGALWRAPPER_API int MeshProcessingRepair_EEK_RemoveIsolatedVertices_SM(void* ptr); } ================================================ FILE: CGALWrapper/Processing/MeshProcessingRepair_EIK.cpp ================================================ #include "MeshProcessingRepair_EIK.h" #include "MeshProcessingRepair.h" void* MeshProcessingRepair_EIK_Create() { return MeshProcessingRepair::NewMeshProcessingRepair(); } void MeshProcessingRepair_EIK_Release(void* ptr) { MeshProcessingRepair::DeleteMeshProcessingRepair(ptr); } //Polyhedron int MeshProcessingRepair_EIK_DegenerateEdgeCount_PH(void* ptr) { return MeshProcessingRepair::DegenerateEdgeCount_PH(ptr); } int MeshProcessingRepair_EIK_DegenerateTriangleCount_PH(void* ptr) { return MeshProcessingRepair::DegenerateTriangleCount_PH(ptr); } int MeshProcessingRepair_EIK_NeedleTriangleCount_PH(void* ptr, double threshold) { return MeshProcessingRepair::NeedleTriangleCount_PH(ptr, threshold); } int MeshProcessingRepair_EIK_NonManifoldVertexCount_PH(void* ptr) { return MeshProcessingRepair::NonManifoldVertexCount_PH(ptr); } void MeshProcessingRepair_EIK_RepairPolygonSoup_PH(void* ptr) { MeshProcessingRepair::RepairPolygonSoup_PH(ptr); } int MeshProcessingRepair_EIK_StitchBoundaryCycles_PH(void* ptr) { return MeshProcessingRepair::StitchBoundaryCycles_PH(ptr); } int MeshProcessingRepair_EIK_StitchBorders_PH(void* ptr) { return MeshProcessingRepair::StitchBorders_PH(ptr); } int MeshProcessingRepair_EIK_MergeDuplicatedVerticesInBoundaryCycle_PH(void* ptr, int index) { return MeshProcessingRepair::MergeDuplicatedVerticesInBoundaryCycle_PH(ptr, index); } int MeshProcessingRepair_EIK_MergeDuplicatedVerticesInBoundaryCycles_PH(void* ptr) { return MeshProcessingRepair::MergeDuplicatedVerticesInBoundaryCycles_PH(ptr); } int MeshProcessingRepair_EIK_RemoveIsolatedVertices_PH(void* ptr) { return MeshProcessingRepair::RemoveIsolatedVertices_PH(ptr); } //SurfaceMesh int MeshProcessingRepair_EIK_DegenerateEdgeCount_SM(void* ptr) { return MeshProcessingRepair::DegenerateEdgeCount_SM(ptr); } int MeshProcessingRepair_EIK_DegenerateTriangleCount_SM(void* ptr) { return MeshProcessingRepair::DegenerateTriangleCount_SM(ptr); } int MeshProcessingRepair_EIK_NeedleTriangleCount_SM(void* ptr, double threshold) { return MeshProcessingRepair::NeedleTriangleCount_SM(ptr, threshold); } int MeshProcessingRepair_EIK_NonManifoldVertexCount_SM(void* ptr) { return MeshProcessingRepair::NonManifoldVertexCount_SM(ptr); } void MeshProcessingRepair_EIK_RepairPolygonSoup_SM(void* ptr) { MeshProcessingRepair::RepairPolygonSoup_SM(ptr); } int MeshProcessingRepair_EIK_StitchBoundaryCycles_SM(void* ptr) { return MeshProcessingRepair::StitchBoundaryCycles_SM(ptr); } int MeshProcessingRepair_EIK_StitchBorders_SM(void* ptr) { return MeshProcessingRepair::StitchBorders_SM(ptr); } int MeshProcessingRepair_EIK_MergeDuplicatedVerticesInBoundaryCycle_SM(void* ptr, int index) { return MeshProcessingRepair::MergeDuplicatedVerticesInBoundaryCycle_SM(ptr, index); } int MeshProcessingRepair_EIK_MergeDuplicatedVerticesInBoundaryCycles_SM(void* ptr) { return MeshProcessingRepair::MergeDuplicatedVerticesInBoundaryCycles_SM(ptr); } int MeshProcessingRepair_EIK_RemoveIsolatedVertices_SM(void* ptr) { return MeshProcessingRepair::RemoveIsolatedVertices_SM(ptr); } ================================================ FILE: CGALWrapper/Processing/MeshProcessingRepair_EIK.h ================================================ #pragma once #include "../CGALWrapper.h" extern "C" { CGALWRAPPER_API void* MeshProcessingRepair_EIK_Create(); CGALWRAPPER_API void MeshProcessingRepair_EIK_Release(void* ptr); //Polyhedron CGALWRAPPER_API int MeshProcessingRepair_EIK_DegenerateEdgeCount_PH(void* ptr); CGALWRAPPER_API int MeshProcessingRepair_EIK_DegenerateTriangleCount_PH(void* ptr); CGALWRAPPER_API int MeshProcessingRepair_EIK_NeedleTriangleCount_PH(void* ptr, double threshold); CGALWRAPPER_API int MeshProcessingRepair_EIK_NonManifoldVertexCount_PH(void* ptr); CGALWRAPPER_API void MeshProcessingRepair_EIK_RepairPolygonSoup_PH(void* ptr); CGALWRAPPER_API int MeshProcessingRepair_EIK_StitchBoundaryCycles_PH(void* ptr); CGALWRAPPER_API int MeshProcessingRepair_EIK_StitchBorders_PH(void* ptr); CGALWRAPPER_API int MeshProcessingRepair_EIK_MergeDuplicatedVerticesInBoundaryCycle_PH(void* ptr, int index); CGALWRAPPER_API int MeshProcessingRepair_EIK_MergeDuplicatedVerticesInBoundaryCycles_PH(void* ptr); CGALWRAPPER_API int MeshProcessingRepair_EIK_RemoveIsolatedVertices_PH(void* ptr); //SurfaceMesh CGALWRAPPER_API int MeshProcessingRepair_EIK_DegenerateEdgeCount_SM(void* ptr); CGALWRAPPER_API int MeshProcessingRepair_EIK_DegenerateTriangleCount_SM(void* ptr); CGALWRAPPER_API int MeshProcessingRepair_EIK_NeedleTriangleCount_SM(void* ptr, double threshold); CGALWRAPPER_API int MeshProcessingRepair_EIK_NonManifoldVertexCount_SM(void* ptr); CGALWRAPPER_API void MeshProcessingRepair_EIK_RepairPolygonSoup_SM(void* ptr); CGALWRAPPER_API int MeshProcessingRepair_EIK_StitchBoundaryCycles_SM(void* ptr); CGALWRAPPER_API int MeshProcessingRepair_EIK_StitchBorders_SM(void* ptr); CGALWRAPPER_API int MeshProcessingRepair_EIK_MergeDuplicatedVerticesInBoundaryCycle_SM(void* ptr, int index); CGALWRAPPER_API int MeshProcessingRepair_EIK_MergeDuplicatedVerticesInBoundaryCycles_SM(void* ptr); CGALWRAPPER_API int MeshProcessingRepair_EIK_RemoveIsolatedVertices_SM(void* ptr); } ================================================ FILE: CGALWrapper/Processing/MeshProcessingSlicer.h ================================================ #pragma once #include "../CGALWrapper.h" #include "../Polyhedra/Polyhedron3.h" #include "../Polyhedra/SurfaceMesh3.h" #include "../Polylines/Polyline3.h" #include #include #include #include #include #include #include #include template class MeshProcessingSlicer { public: typedef typename K::FT FT; typedef typename K::Point_3 Point; typedef typename K::Vector_3 Vector; typedef typename K::Plane_3 Plane; typedef typename std::vector PointList; typedef typename std::vector PolylineList; typedef CGAL::Polyhedron_3 Polyhedron; typedef CGAL::AABB_halfedge_graph_segment_primitive PHGSP; typedef CGAL::AABB_traits PAABB_traits; typedef CGAL::AABB_tree PAABB_tree; typedef typename CGAL::Surface_mesh SurfaceMesh; typedef CGAL::AABB_halfedge_graph_segment_primitive SHGSP; typedef CGAL::AABB_traits SAABB_traits; typedef CGAL::AABB_tree SAABB_tree; private: PolylineList lines; public: inline static MeshProcessingSlicer* NewMeshProcessingSlicer() { return new MeshProcessingSlicer(); } inline static void DeleteMeshProcessingSlicer(void* ptr) { auto obj = static_cast(ptr); if (obj != nullptr) { delete obj; obj = nullptr; } } inline static MeshProcessingSlicer* CastToMeshProcessingSlicer(void* ptr) { return static_cast(ptr); } static void GetLines(void* slicerPtr, void** lines, int count) { auto slicer = CastToMeshProcessingSlicer(slicerPtr); auto size = slicer->lines.size(); if (size == 0) return; for (int i = 0; i < count; i++) { lines[i] = Polyline3::NewPolyline3(slicer->lines[i]); if (i >= size) break; } slicer->lines.clear(); } //Polyhedron static int Polyhedron_Slice_PH(void* slicerPtr, void* meshPtr, const Plane3d& plane, BOOL useTree) { auto scr = CastToMeshProcessingSlicer(slicerPtr); auto mesh = Polyhedron3::CastToPolyhedron(meshPtr); scr->lines.clear(); if (useTree) { PAABB_tree tree(edges(mesh->model).first, edges(mesh->model).second, mesh->model); CGAL::Polygon_mesh_slicer slicer_aabb(mesh->model, tree); slicer_aabb(plane.ToCGAL(), std::back_inserter(scr->lines)); } else { CGAL::Polygon_mesh_slicer slicer(mesh->model); slicer(plane.ToCGAL(), std::back_inserter(scr->lines)); } return (int)scr->lines.size(); } static int Polyhedron_Slice_PH(void* slicerPtr, void* meshPtr, const Point3d& start, const Point3d& end, double increment) { if (increment <= 0) return 0; auto scr = CastToMeshProcessingSlicer(slicerPtr); auto mesh = Polyhedron3::CastToPolyhedron(meshPtr); scr->lines.clear(); auto s = start.ToCGAL(); auto e = end.ToCGAL(); auto sq = CGAL::squared_distance(s, e); if (sq == FT(0)) return 0; auto len = CGAL::approximate_sqrt(sq); auto inc = FT(increment); auto dir = (e - s) / len; auto current = FT(0); PAABB_tree tree(edges(mesh->model).first, edges(mesh->model).second, mesh->model); CGAL::Polygon_mesh_slicer slicer_aabb(mesh->model, tree); while (current < len) { Point p = s + dir * current; auto plane = Plane(p, dir); slicer_aabb(plane, std::back_inserter(scr->lines)); current += inc; } return (int)scr->lines.size(); } //SurfaceMesh static int Polyhedron_Slice_SM(void* slicerPtr, void* meshPtr, const Plane3d& plane, BOOL useTree) { auto scr = CastToMeshProcessingSlicer(slicerPtr); auto mesh = SurfaceMesh3::CastToSurfaceMesh(meshPtr); scr->lines.clear(); if (useTree) { SAABB_tree tree(edges(mesh->model).first, edges(mesh->model).second, mesh->model); CGAL::Polygon_mesh_slicer slicer_aabb(mesh->model, tree); slicer_aabb(plane.ToCGAL(), std::back_inserter(scr->lines)); } else { CGAL::Polygon_mesh_slicer slicer(mesh->model); slicer(plane.ToCGAL(), std::back_inserter(scr->lines)); } return (int)scr->lines.size(); } static int Polyhedron_Slice_SM(void* slicerPtr, void* meshPtr, const Point3d& start, const Point3d& end, double increment) { if (increment <= 0) return 0; auto scr = CastToMeshProcessingSlicer(slicerPtr); auto mesh = SurfaceMesh3::CastToSurfaceMesh(meshPtr); scr->lines.clear(); auto s = start.ToCGAL(); auto e = end.ToCGAL(); auto sq = CGAL::squared_distance(s, e); if (sq == FT(0)) return 0; auto len = CGAL::approximate_sqrt(sq); auto inc = FT(increment); auto dir = (e - s) / len; auto current = FT(0); SAABB_tree tree(edges(mesh->model).first, edges(mesh->model).second, mesh->model); CGAL::Polygon_mesh_slicer slicer_aabb(mesh->model, tree); while (current < len) { Point p = s + dir * current; auto plane = Plane(p, dir); slicer_aabb(plane, std::back_inserter(scr->lines)); current += inc; } return (int)scr->lines.size(); } }; ================================================ FILE: CGALWrapper/Processing/MeshProcessingSlicer_EEK.cpp ================================================ #include "MeshProcessingSlicer_EEK.h" #include "MeshProcessingSlicer.h" void* MeshProcessingSlicer_EEK_Create() { return MeshProcessingSlicer::NewMeshProcessingSlicer(); } void MeshProcessingSlicer_EEK_Release(void* ptr) { MeshProcessingSlicer::DeleteMeshProcessingSlicer(ptr); } void MeshProcessingSlicer_EEK_GetLines(void* slicerPtr, void** lines, int count) { MeshProcessingSlicer::GetLines(slicerPtr, lines, count); } //Polyhedron int MeshProcessingSlicer_EEK_Slice_PH(void* slicerPtr, void* meshPtr, const Plane3d& plane, BOOL useTree) { return MeshProcessingSlicer::Polyhedron_Slice_PH(slicerPtr, meshPtr, plane, useTree); } int MeshProcessingSlicer_EEK_IncrementalSlice_PH(void* slicerPtr, void* meshPtr, const Point3d& start, const Point3d& end, double increment) { return MeshProcessingSlicer::Polyhedron_Slice_PH(slicerPtr, meshPtr, start, end, increment); } //SUrfaceMesh int MeshProcessingSlicer_EEK_Slice_SM(void* slicerPtr, void* meshPtr, const Plane3d& plane, BOOL useTree) { return MeshProcessingSlicer::Polyhedron_Slice_SM(slicerPtr, meshPtr, plane, useTree); } int MeshProcessingSlicer_EEK_IncrementalSlice_SM(void* slicerPtr, void* meshPtr, const Point3d& start, const Point3d& end, double increment) { return MeshProcessingSlicer::Polyhedron_Slice_SM(slicerPtr, meshPtr, start, end, increment); } ================================================ FILE: CGALWrapper/Processing/MeshProcessingSlicer_EEK.h ================================================ #pragma once #include "../CGALWrapper.h" #include "../Geometry/Geometry3.h" extern "C" { CGALWRAPPER_API void* MeshProcessingSlicer_EEK_Create(); CGALWRAPPER_API void MeshProcessingSlicer_EEK_Release(void* ptr); CGALWRAPPER_API void MeshProcessingSlicer_EEK_GetLines(void* slicerPtr, void** lines, int count); //Polyhedron CGALWRAPPER_API int MeshProcessingSlicer_EEK_Slice_PH(void* slicerPtr, void* meshPtr, const Plane3d& plane, BOOL useTree); CGALWRAPPER_API int MeshProcessingSlicer_EEK_IncrementalSlice_PH(void* slicerPtr, void* meshPtr, const Point3d& start, const Point3d& end, double increment); //Surface Mesh CGALWRAPPER_API int MeshProcessingSlicer_EEK_Slice_SM(void* slicerPtr, void* meshPtr, const Plane3d& plane, BOOL useTree); CGALWRAPPER_API int MeshProcessingSlicer_EEK_IncrementalSlice_SM(void* slicerPtr, void* meshPtr, const Point3d& start, const Point3d& end, double increment); } ================================================ FILE: CGALWrapper/Processing/MeshProcessingSlicer_EIK.cpp ================================================ #include "MeshProcessingSlicer_EIK.h" #include "MeshProcessingSlicer.h" void* MeshProcessingSlicer_EIK_Create() { return MeshProcessingSlicer::NewMeshProcessingSlicer(); } void MeshProcessingSlicer_EIK_Release(void* ptr) { MeshProcessingSlicer::DeleteMeshProcessingSlicer(ptr); } void MeshProcessingSlicer_EIK_GetLines(void* slicerPtr, void** lines, int count) { MeshProcessingSlicer::GetLines(slicerPtr, lines, count); } //Polyhedron int MeshProcessingSlicer_EIK_Slice_PH(void* slicerPtr, void* meshPtr, const Plane3d& plane, BOOL useTree) { return MeshProcessingSlicer::Polyhedron_Slice_PH(slicerPtr, meshPtr, plane, useTree); } int MeshProcessingSlicer_EIK_IncrementalSlice_PH(void* slicerPtr, void* meshPtr, const Point3d& start, const Point3d& end, double increment) { return MeshProcessingSlicer::Polyhedron_Slice_PH(slicerPtr, meshPtr, start, end, increment); } //SUrfaceMesh int MeshProcessingSlicer_EIK_Slice_SM(void* slicerPtr, void* meshPtr, const Plane3d& plane, BOOL useTree) { return MeshProcessingSlicer::Polyhedron_Slice_SM(slicerPtr, meshPtr, plane, useTree); } int MeshProcessingSlicer_EIK_IncrementalSlice_SM(void* slicerPtr, void* meshPtr, const Point3d& start, const Point3d& end, double increment) { return MeshProcessingSlicer::Polyhedron_Slice_SM(slicerPtr, meshPtr, start, end, increment); } ================================================ FILE: CGALWrapper/Processing/MeshProcessingSlicer_EIK.h ================================================ #pragma once #include "../CGALWrapper.h" #include "../Geometry/Geometry3.h" extern "C" { CGALWRAPPER_API void* MeshProcessingSlicer_EIK_Create(); CGALWRAPPER_API void MeshProcessingSlicer_EIK_Release(void* ptr); CGALWRAPPER_API void MeshProcessingSlicer_EIK_GetLines(void* slicerPtr, void** lines, int count); //Polyhedron CGALWRAPPER_API int MeshProcessingSlicer_EIK_Slice_PH(void* slicerPtr, void* meshPtr, const Plane3d& plane, BOOL useTree); CGALWRAPPER_API int MeshProcessingSlicer_EIK_IncrementalSlice_PH(void* slicerPtr, void* meshPtr, const Point3d& start, const Point3d& end, double increment); //Surface Mesh CGALWRAPPER_API int MeshProcessingSlicer_EIK_Slice_SM(void* slicerPtr, void* meshPtr, const Plane3d& plane, BOOL useTree); CGALWRAPPER_API int MeshProcessingSlicer_EIK_IncrementalSlice_SM(void* slicerPtr, void* meshPtr, const Point3d& start, const Point3d& end, double increment); } ================================================ FILE: CGALWrapper/Processing/SurfaceSimplification.h ================================================ #pragma once #include "../CGALWrapper.h" #include "../Polyhedra/Polyhedron3.h" #include "../Polyhedra/SurfaceMesh3.h" #include #include #include #include template class SurfaceSimplification { public: typedef typename K::Point_3 Point; typedef CGAL::Polyhedron_3 Polyhedron; typedef typename CGAL::Surface_mesh SurfaceMesh; inline static SurfaceSimplification* NewSimplification() { return new SurfaceSimplification(); } inline static void DeleteSurfaceSimplification(void* ptr) { auto obj = static_cast(ptr); if (obj != nullptr) { delete obj; obj = nullptr; } } inline static SurfaceSimplification* CastToSimplification(void* ptr) { return static_cast(ptr); } static void Simplify_PH(void* polyPtr, double stop_ratio) { auto mesh = Polyhedron3::CastToPolyhedron(polyPtr); CGAL::Surface_mesh_simplification::Count_ratio_stop_predicate stop(stop_ratio); CGAL::Surface_mesh_simplification::edge_collapse(mesh->model, stop); mesh->OnModelChanged(); } static void Simplify_SM(void* polyPtr, double stop_ratio) { auto mesh = SurfaceMesh3::CastToSurfaceMesh(polyPtr); CGAL::Surface_mesh_simplification::Count_ratio_stop_predicate stop(stop_ratio); CGAL::Surface_mesh_simplification::edge_collapse(mesh->model, stop); mesh->OnModelChanged(); } }; ================================================ FILE: CGALWrapper/Processing/SurfaceSimplification_EIK.cpp ================================================ #include "SurfaceSimplification_EIK.h" #include "SurfaceSimplification.h" void* SurfaceSimplification_EIK_Create() { return SurfaceSimplification::NewSimplification(); } void SurfaceSimplification_EIK_Release(void* ptr) { SurfaceSimplification::DeleteSurfaceSimplification(ptr); } void SurfaceSimplification_EIK_Simplify_PH(void* meshPtr, double stop_ratio) { SurfaceSimplification::Simplify_PH(meshPtr, stop_ratio); } void SurfaceSimplification_EIK_Simplify_SM(void* meshPtr, double stop_ratio) { SurfaceSimplification::Simplify_SM(meshPtr, stop_ratio); } ================================================ FILE: CGALWrapper/Processing/SurfaceSimplification_EIK.h ================================================ #pragma once #include "../CGALWrapper.h" extern "C" { CGALWRAPPER_API void* SurfaceSimplification_EIK_Create(); CGALWRAPPER_API void SurfaceSimplification_EIK_Release(void* ptr); CGALWRAPPER_API void SurfaceSimplification_EIK_Simplify_PH(void* meshPtr, double stop_ratio); CGALWRAPPER_API void SurfaceSimplification_EIK_Simplify_SM(void* meshPtr, double stop_ratio); } ================================================ FILE: CGALWrapper/Processing/SurfaceSubdivision.h ================================================ #pragma once #include "../CGALWrapper.h" #include "../Polyhedra/Polyhedron3.h" #include "../Polyhedra/SurfaceMesh3.h" #include #include #include template class SurfaceSubdivision { public: inline static SurfaceSubdivision* NewSurfaceSubdivision() { return new SurfaceSubdivision(); } inline static void DeleteSurfaceSubdivision(void* ptr) { auto obj = static_cast(ptr); if (obj != nullptr) { delete obj; obj = nullptr; } } inline static SurfaceSubdivision* CastToSurfaceSubdivision(void* ptr) { return static_cast(ptr); } //Polyhedron static void Subdive_CatmullClark_PH(void* meshPtr, int iterations) { auto mesh = Polyhedron3::CastToPolyhedron(meshPtr); auto param = CGAL::parameters::number_of_iterations(iterations); CGAL::Subdivision_method_3::CatmullClark_subdivision(mesh->model, param); mesh->OnModelChanged(); } static void Subdive_DooSabin_PH(void* meshPtr, int iterations) { //auto mesh = Polyhedron3::CastToPolyhedron(meshPtr); //auto param = CGAL::parameters::number_of_iterations(iterations); //CGAL::Subdivision_method_3::DooSabin_subdivision(mesh->model, param); //mesh->OnModelChanged(); } static void Subdive_Loop_PH(void* meshPtr, int iterations) { auto mesh = Polyhedron3::CastToPolyhedron(meshPtr); auto param = CGAL::parameters::number_of_iterations(iterations); CGAL::Subdivision_method_3::Loop_subdivision(mesh->model, param); mesh->OnModelChanged(); } static void Subdive_Sqrt3_PH(void* meshPtr, int iterations) { auto mesh = Polyhedron3::CastToPolyhedron(meshPtr); auto param = CGAL::parameters::number_of_iterations(iterations); CGAL::Subdivision_method_3::Sqrt3_subdivision(mesh->model, param); mesh->OnModelChanged(); } //Surface mesh static void Subdive_CatmullClark_SM(void* meshPtr, int iterations) { auto mesh = SurfaceMesh3::CastToSurfaceMesh(meshPtr); auto param = CGAL::parameters::number_of_iterations(iterations); CGAL::Subdivision_method_3::CatmullClark_subdivision(mesh->model, param); mesh->OnModelChanged(); } static void Subdive_DooSabin_SM(void* meshPtr, int iterations) { auto mesh = SurfaceMesh3::CastToSurfaceMesh(meshPtr); auto param = CGAL::parameters::number_of_iterations(iterations); CGAL::Subdivision_method_3::DooSabin_subdivision(mesh->model, param); mesh->OnModelChanged(); } static void Subdive_Loop_SM(void* meshPtr, int iterations) { auto mesh = SurfaceMesh3::CastToSurfaceMesh(meshPtr); auto param = CGAL::parameters::number_of_iterations(iterations); CGAL::Subdivision_method_3::Loop_subdivision(mesh->model, param); mesh->OnModelChanged(); } static void Subdive_Sqrt3_SM(void* meshPtr, int iterations) { auto mesh = SurfaceMesh3::CastToSurfaceMesh(meshPtr); auto param = CGAL::parameters::number_of_iterations(iterations); CGAL::Subdivision_method_3::Sqrt3_subdivision(mesh->model, param); mesh->OnModelChanged(); } }; ================================================ FILE: CGALWrapper/Processing/SurfaceSubdivision_EEK.cpp ================================================ #include "SurfaceSubdivision_EEK.h" #include "SurfaceSubdivision.h" void* SurfaceSubdivision_EEK_Create() { return SurfaceSubdivision::NewSurfaceSubdivision(); } void SurfaceSubdivision_EEK_Release(void* ptr) { SurfaceSubdivision::DeleteSurfaceSubdivision(ptr); } //Polyhedron void SurfaceSubdivision_EEK_Subdive_CatmullClark_PH(void* meshPtr, int iterations) { SurfaceSubdivision::Subdive_CatmullClark_PH(meshPtr, iterations); } void SurfaceSubdivision_EEK_Subdive_Loop_PH(void* meshPtr, int iterations) { SurfaceSubdivision::Subdive_Loop_PH(meshPtr, iterations); } void SurfaceSubdivision_EEK_Subdive_Sqrt3_PH(void* meshPtr, int iterations) { SurfaceSubdivision::Subdive_Sqrt3_PH(meshPtr, iterations); } void SurfaceSubdivision_EEK_Subdive_DooSabin_PH(void* meshPtr, int iterations) { SurfaceSubdivision::Subdive_DooSabin_PH(meshPtr, iterations); } //Surface Mesh void SurfaceSubdivision_EEK_Subdive_CatmullClark_SM(void* meshPtr, int iterations) { SurfaceSubdivision::Subdive_CatmullClark_SM(meshPtr, iterations); } void SurfaceSubdivision_EEK_Subdive_Loop_SM(void* meshPtr, int iterations) { SurfaceSubdivision::Subdive_Loop_SM(meshPtr, iterations); } void SurfaceSubdivision_EEK_Subdive_Sqrt3_SM(void* meshPtr, int iterations) { SurfaceSubdivision::Subdive_Loop_SM(meshPtr, iterations); } void SurfaceSubdivision_EEK_Subdive_DooSabin_SM(void* meshPtr, int iterations) { SurfaceSubdivision::Subdive_Loop_SM(meshPtr, iterations); } ================================================ FILE: CGALWrapper/Processing/SurfaceSubdivision_EEK.h ================================================ #pragma once #include "../CGALWrapper.h" extern "C" { CGALWRAPPER_API void* SurfaceSubdivision_EEK_Create(); CGALWRAPPER_API void SurfaceSubdivision_EEK_Release(void* ptr); // Polyhedron CGALWRAPPER_API void SurfaceSubdivision_EEK_Subdive_CatmullClark_PH(void* meshPtr, int iterations); CGALWRAPPER_API void SurfaceSubdivision_EEK_Subdive_DooSabin_PH(void* meshPtr, int iterations); CGALWRAPPER_API void SurfaceSubdivision_EEK_Subdive_Loop_PH(void* meshPtr, int iterations); CGALWRAPPER_API void SurfaceSubdivision_EEK_Subdive_Sqrt3_PH(void* meshPtr, int iterations); //Surface Mesh CGALWRAPPER_API void SurfaceSubdivision_EEK_Subdive_CatmullClark_SM(void* meshPtr, int iterations); CGALWRAPPER_API void SurfaceSubdivision_EEK_Subdive_DooSabin_SM(void* meshPtr, int iterations); CGALWRAPPER_API void SurfaceSubdivision_EEK_Subdive_Loop_SM(void* meshPtr, int iterations); CGALWRAPPER_API void SurfaceSubdivision_EEK_Subdive_Sqrt3_SM(void* meshPtr, int iterations); } ================================================ FILE: CGALWrapper/Processing/SurfaceSubdivision_EIK.cpp ================================================ #include "SurfaceSubdivision_EIK.h" #include "SurfaceSubdivision.h" void* SurfaceSubdivision_EIK_Create() { return SurfaceSubdivision::NewSurfaceSubdivision(); } void SurfaceSubdivision_EIK_Release(void* ptr) { SurfaceSubdivision::DeleteSurfaceSubdivision(ptr); } //Polyhedron void SurfaceSubdivision_EIK_Subdive_CatmullClark_PH(void* meshPtr, int iterations) { SurfaceSubdivision::Subdive_CatmullClark_PH(meshPtr, iterations); } void SurfaceSubdivision_EIK_Subdive_Loop_PH(void* meshPtr, int iterations) { SurfaceSubdivision::Subdive_Loop_PH(meshPtr, iterations); } void SurfaceSubdivision_EIK_Subdive_Sqrt3_PH(void* meshPtr, int iterations) { SurfaceSubdivision::Subdive_Sqrt3_PH(meshPtr, iterations); } void SurfaceSubdivision_EIK_Subdive_DooSabin_PH(void* meshPtr, int iterations) { SurfaceSubdivision::Subdive_DooSabin_PH(meshPtr, iterations); } //Surface Mesh void SurfaceSubdivision_EIK_Subdive_CatmullClark_SM(void* meshPtr, int iterations) { SurfaceSubdivision::Subdive_CatmullClark_SM(meshPtr, iterations); } void SurfaceSubdivision_EIK_Subdive_Loop_SM(void* meshPtr, int iterations) { SurfaceSubdivision::Subdive_Loop_SM(meshPtr, iterations); } void SurfaceSubdivision_EIK_Subdive_Sqrt3_SM(void* meshPtr, int iterations) { SurfaceSubdivision::Subdive_Loop_SM(meshPtr, iterations); } void SurfaceSubdivision_EIK_Subdive_DooSabin_SM(void* meshPtr, int iterations) { SurfaceSubdivision::Subdive_Loop_SM(meshPtr, iterations); } ================================================ FILE: CGALWrapper/Processing/SurfaceSubdivision_EIK.h ================================================ #pragma once #include "../CGALWrapper.h" extern "C" { CGALWRAPPER_API void* SurfaceSubdivision_EIK_Create(); CGALWRAPPER_API void SurfaceSubdivision_EIK_Release(void* ptr); // Polyhedron CGALWRAPPER_API void SurfaceSubdivision_EIK_Subdive_CatmullClark_PH(void* meshPtr, int iterations); CGALWRAPPER_API void SurfaceSubdivision_EIK_Subdive_DooSabin_PH(void* meshPtr, int iterations); CGALWRAPPER_API void SurfaceSubdivision_EIK_Subdive_Loop_PH(void* meshPtr, int iterations); CGALWRAPPER_API void SurfaceSubdivision_EIK_Subdive_Sqrt3_PH(void* meshPtr, int iterations); //Surface Mesh CGALWRAPPER_API void SurfaceSubdivision_EIK_Subdive_CatmullClark_SM(void* meshPtr, int iterations); CGALWRAPPER_API void SurfaceSubdivision_EIK_Subdive_DooSabin_SM(void* meshPtr, int iterations); CGALWRAPPER_API void SurfaceSubdivision_EIK_Subdive_Loop_SM(void* meshPtr, int iterations); CGALWRAPPER_API void SurfaceSubdivision_EIK_Subdive_Sqrt3_SM(void* meshPtr, int iterations); } ================================================ FILE: CGALWrapper/Triangulations/BaseTriangulation2.h ================================================ #pragma once #include "../CGALWrapper.h" #include "../Geometry/Geometry2.h" #include "../Polygons/Polygon2.h" #include "../Polygons/PolygonWithHoles2.h" #include "TriUtil.h" #include "TriVertex2.h" #include "TriFace2.h" #include "TriEdge2.h" #include "TriangulationMap2.h" #include #include "CGAL/Point_2.h" #include #include template class BaseTriangulation2 { public: typedef typename K::Point_2 Point_2; typedef CGAL::Aff_transformation_2 Transformation_2; TRI model; TriangulationMap2 map; void Clear() { model.clear(); map.ClearMaps(); map.OnModelChanged(); } void SetIndices() { map.OnModelChanged(); map.SetIndices(model); } int BuildStamp() { return map.BuildStamp(); } BOOL IsValid(int level) { return model.is_valid(level); } int VertexCount() { return (int)model.number_of_vertices(); } int FaceCount() { return (int)model.number_of_faces(); } void InsertPoint(Point2d point) { model.insert(point.ToCGAL()); map.OnModelChanged(); } void InsertPoints(Point2d* points, int count) { std::vector list(count); for (int i = 0; i < count; i++) list[i] = points[i].ToCGAL(); model.insert(list.begin(), list.end()); map.OnModelChanged(); } void InsertPolygon(void* polyPtr) { auto polygon = Polygon2::CastToPolygon2(polyPtr); model.insert(polygon->vertices_begin(), polygon->vertices_end()); map.OnModelChanged(); } void InsertPolygonWithHoles(void* pwhPtr) { auto pwh = PolygonWithHoles2::CastToPolygonWithHoles2(pwhPtr); if (!pwh->is_unbounded()) model.insert(pwh->outer_boundary().vertices_begin(), pwh->outer_boundary().vertices_end()); for (auto& hole : pwh->holes()) model.insert(hole.vertices_begin(), hole.vertices_end()); map.OnModelChanged(); } void InsertPoints(std::vector& points) { for (auto iter = points.begin(); iter != points.end(); ++iter) model.insert(*iter); map.OnModelChanged(); } void GetPoints(std::vector& points) { for (const auto& vert : model.finite_vertex_handles()) points.push_back(vert->point()); } void GetPoints(Point2d* points, int count) { int i = 0; for (const auto& vert : model.finite_vertex_handles()) points[i++] = Point2d::FromCGAL(vert->point()); } void GetIndices(int* indices, int count) { int index = 0; map.SetVertexIndices(model); for (auto& face : model.finite_face_handles()) { indices[index * 3 + 0] = face->vertex(0)->info(); indices[index * 3 + 1] = face->vertex(1)->info(); indices[index * 3 + 2] = face->vertex(2)->info(); index++; } } BOOL GetVertex(int index, TriVertex2& triVert) { map.SetIndices(model); auto vert = map.FindVertex(model, index); if (vert != nullptr) { int degree = TriUtil::Degree2(model, *vert); triVert = TriVertex2::FromVertex(model, *vert, degree); return TRUE; } else { triVert = TriVertex2::NullVertex(); return FALSE; } } void GetVertices(TriVertex2* vertices, int count) { int i = 0; map.SetIndices(model); for (const auto& vert : model.finite_vertex_handles()) { int degree = TriUtil::Degree2(model, vert); vertices[i++] = TriVertex2::FromVertex(model, vert, degree); } } BOOL GetFace(int index, TriFace2& triFace) { map.SetIndices(model); auto face = map.FindFace(model, index); if (face != nullptr) { triFace = TriFace2::FromFace(model, *face); return TRUE; } else { triFace = TriFace2::NullFace(); return FALSE; } } void GetFaces(TriFace2* faces, int count) { int i = 0; map.SetIndices(model); for (const auto& face : model.finite_face_handles()) faces[i++] = TriFace2::FromFace(model, face); } BOOL GetSegment(int faceIndex, int neighbourIndex, Segment2d& segment) { if (neighbourIndex < 0 || neighbourIndex > 2) return FALSE; auto face = map.FindFace(model, faceIndex); if (face != nullptr) { if (model.is_infinite(*face)) return FALSE; auto seg = model.segment(*face, neighbourIndex); segment = Segment2d::FromCGAL(seg[0], seg[1]); return TRUE; } else { segment = {}; return FALSE; } } BOOL GetTriangle(int faceIndex, Triangle2d& triangle) { auto face = map.FindFace(model, faceIndex); if (face != nullptr) { if (model.is_infinite(*face)) return FALSE; auto t = model.triangle(*face); triangle = Triangle2d::FromCGAL(t[0], t[1], t[2]); return TRUE; } else { triangle = {}; return FALSE; } } void GetTriangles(Triangle2d* triangles, int count) { int i = 0; for (const auto& face : model.finite_face_handles()) { auto t = model.triangle(face); triangles[i++] = Triangle2d::FromCGAL(t[0], t[1], t[2]); } } BOOL GetCircumcenter(int faceIndex, Point2d& circumcenter) { auto face = map.FindFace(model, faceIndex); if (face != nullptr) { if (model.is_infinite(*face)) return FALSE; auto c = model.circumcenter(*face); circumcenter = Point2d::FromCGAL(c); return TRUE; } else { circumcenter = { 0, 0 }; return FALSE; } } void GetCircumcenters(Point2d* circumcenters, int count) { int i = 0; for (const auto& face : model.finite_face_handles()) { auto c = model.circumcenter(face); circumcenters[i++] = Point2d::FromCGAL(c); } } int NeighbourIndex(int faceIndex, int index) { if (index < 0 || index > 2) return -1; map.SetFaceIndices( model); auto face = map.FindFace( model, faceIndex); if (face != nullptr) { auto neighbour = (*face)->neighbor(index); if (neighbour != nullptr) return neighbour->info(); else return -1; } else { return -1; } } BOOL LocateFace(Point2d point, TriFace2& triFace) { map.SetIndices( model); auto face = model.locate(point.ToCGAL()); if (face != nullptr) { triFace = TriFace2::FromFace( model, face); return TRUE; } else { triFace = TriFace2::NullFace(); return FALSE; } } BOOL MoveVertex(int index, Point2d point, BOOL ifNoCollision, TriVertex2& triVert) { auto vert = map.FindVertex( model, index); if (vert != nullptr) { VERT v; if (ifNoCollision) v = model.move(*vert, point.ToCGAL()); else v = model.move_if_no_collision(*vert, point.ToCGAL()); if (v != *vert) map.OnModelChanged(); int degree = TriUtil::Degree2( model, v); triVert = TriVertex2::FromVertex( model, v, degree); return TRUE; } else { triVert = TriVertex2::NullVertex(); return FALSE; } } BOOL RemoveVertex(int index) { auto vert = map.FindVertex( model, index); if (vert != nullptr) { model.remove(*vert); map.OnModelChanged(); return TRUE; } else { return FALSE; } } BOOL FlipEdge(int faceIndex, int neighbourIndex) { if (neighbourIndex < 0 || neighbourIndex > 2) return FALSE; auto face = map.FindFace( model, faceIndex); if (face != nullptr) { if ( model.is_infinite(*face)) return FALSE; model.flip(*face, neighbourIndex); map.OnModelChanged(); return TRUE; } else { return FALSE; } } void Transform(Point2d translation, double rotation, double scale) { Transformation_2 T(CGAL::TRANSLATION, translation.ToVector()); Transformation_2 R(CGAL::ROTATION, sin(rotation), cos(rotation)); Transformation_2 S(CGAL::SCALING, scale); auto M = T * R * S; for (auto& vert : model.finite_vertex_handles()) vert->point() = M(vert->point()); } }; ================================================ FILE: CGALWrapper/Triangulations/BaseTriangulation3.h ================================================ #pragma once #include "../CGALWrapper.h" #include "../Geometry/Geometry3.h" #include "TriUtil.h" #include "TriVertex3.h" #include "TriCell3.h" #include #include #include "CGAL/Point_3.h" #include #include #include #include #include template class BaseTriangulation3 { public: typedef CGAL::Triangulation_vertex_base_with_info_3 Vb; typedef CGAL::Triangulation_cell_base_with_info_3 Cb; typedef CGAL::Triangulation_data_structure_3 Tds; typedef CGAL::Triangulation_3 Triangulation_3; typedef typename Triangulation_3::Point Point_3; typedef typename Triangulation_3::Cell_handle Cell; typedef typename Triangulation_3::Vertex_handle Vertex; typedef typename Triangulation_3::Edge Edge; typedef typename K::Point_3 Point_3; typedef CGAL::Aff_transformation_3 Transformation_3; TRI model; std::unordered_map cellIndexMap; std::unordered_map cellMap; bool cellIndexMapBuilt = false; std::unordered_map vertexMap; bool vertexIndexMapBuilt = false; int buildStamp = 1; void Clear() { model.clear(); cellIndexMap.clear(); vertexMap.clear(); cellMap.clear(); } int BuildStamp() { return buildStamp; } void OnModelChanged() { cellIndexMapBuilt = false; vertexIndexMapBuilt = false; } void BuildVertexIndices() { if (vertexIndexMapBuilt) return; vertexMap.clear(); int index = 0; for (auto& vert : model.all_vertex_handles()) { //if (model.is_infinite(vert)) //{ // vert->info() = NULL_INDEX; //} //else //{ vert->info() = index; vertexMap.insert(std::pair(index, vert)); index++; //} } buildStamp++; vertexIndexMapBuilt = true; } void BuildCellIndices() { if (cellIndexMapBuilt) return; cellIndexMap.clear(); cellMap.clear(); int index = 0; for (auto cell = model.all_cells_begin(); cell != model.all_cells_end(); ++cell) { //if (model.is_infinite(cell)) //{ // cellIndexMap.insert(std::pair(cell, NULL_INDEX)); //} //else //{ cellMap.insert(std::pair(index, cell)); cellIndexMap.insert(std::pair(cell, index)); index++; //} } buildStamp++; cellIndexMapBuilt = true; } int GetCellIndex(CELL c) { BuildCellIndices(); auto item = cellIndexMap.find(c); if (item != cellIndexMap.end()) return item->second; else return NULL_INDEX; } CELL GetCell(int i) { BuildCellIndices(); auto item = cellMap.find(i); if (item != cellMap.end()) return item->second; else return nullptr; } VERT GetVertex(int i) { BuildVertexIndices(); auto item = vertexMap.find(i); if (item != vertexMap.end()) return item->second; else return nullptr; } BOOL IsValid(BOOL verbose) { return model.is_valid(verbose); } int Dimension() { return model.dimension(); } int VertexCount() { int count = 0; for (const auto& vert : model.all_vertex_handles()) count++; return count; //return (int)model.number_of_vertices(); } int FiniteVertexCount() { int count = 0; for (const auto& vert : model.all_vertex_handles()) if (!model.is_infinite(vert)) count++; return count; } int CellCount() { int count = 0; for (const auto& cell : model.all_cell_handles()) count++; return count; //return (int)model.number_of_cells(); } int FiniteCellCount() { int count = 0; for (const auto& cell : model.all_cell_handles()) if (!model.is_infinite(cell)) count++; return count; //return (int)model.number_of_finite_cells(); } int EdgeCount() { int count = 0; for (auto edge = model.all_edges_begin(); edge != model.all_edges_end(); ++edge) count++; return count; //return (int)model.number_of_edges(); } int FiniteEdgeCount() { //int count = 0; //for (auto edge = model.all_edges_begin(); edge != model.all_edges_end(); ++edge) // if (!model.is_infinite(edge)) // count++; //return count; return (int)model.number_of_finite_edges(); } int FacetCount() { int count = 0; for (auto face = model.all_facets_begin(); face != model.all_facets_end(); ++face) count++; return count; //return (int)model.number_of_facets(); } int FiniteFacetCount() { //int count = 0; //for (auto face = model.all_facets_begin(); face != model.all_facets_end(); ++face) // if (!model.is_infinite(face)) // count++; //return count; return (int)model.number_of_finite_facets(); } void InsertPoint(const Point3d& point) { model.insert(point.ToCGAL()); OnModelChanged(); } void InsertPoints(Point3d* points, int count) { std::vector list(count); for (int i = 0; i < count; i++) list[i] = points[i].ToCGAL(); model.insert(list.begin(), list.end()); OnModelChanged(); } void InsertInCell(int index, const Point3d& point) { auto c = GetCell(index); if (c != nullptr) { model.insert_in_cell(point.ToCGAL(), c); OnModelChanged(); } } int Locate(const Point3d& point) { auto cell = model.locate(point.ToCGAL()); return GetCellIndex(cell); } void GetCircumcenters(Point3d* Circumcenters, int count) { int num = (int)model.number_of_cells(); int i = 0; for (auto cell = model.all_cells_begin(); cell != model.all_cells_end(); ++cell) { Point3d c = { 0,0,0 }; for (int j = 0; j < 4; j++) { c = c + Point3d::FromCGAL(cell->vertex(j)->point()); } Circumcenters[i] = c / 4; i++; if (i >= count) return; } } void GetPoints(Point3d* points, int count) { constexpr double inf = std::numeric_limits::infinity(); int i = 0; for (const auto& vert : model.all_vertex_handles()) { if (model.is_infinite(vert)) points[i] = { inf, inf, inf }; else points[i] = Point3d::FromCGAL(vert->point()); i++; if (i >= count) return; } } void GetVertices(TriVertex3* vertices, int count) { BuildVertexIndices(); constexpr double inf = std::numeric_limits::infinity(); int i = 0; for (auto& vert : model.all_vertex_handles()) { TriVertex3 v; if (model.is_infinite(vert)) { v.Point = { inf, inf, inf }; v.IsInfinite = TRUE; } else { v.Point = Point3d::FromCGAL(vert->point()); v.IsInfinite = FALSE; } if (model.is_infinite(vert->cell())) ResetCell(vert); v.Degree = Degree(vert); v.Index = vert->info(); v.CellIndex = GetCellIndex(vert->cell()); vertices[i++] = v; if (i >= count) return; } } BOOL GetVertex(int index, TriVertex3& v) { BuildVertexIndices(); constexpr double inf = std::numeric_limits::infinity(); auto vert = GetVertex(index); if(vert != nullptr) { if (model.is_infinite(vert)) { v.Point = { inf, inf, inf }; v.IsInfinite = TRUE; } else { v.Point = Point3d::FromCGAL(vert->point()); v.IsInfinite = FALSE; } if (model.is_infinite(vert->cell())) ResetCell(vert); v.Degree = Degree(vert); v.Index = vert->info(); v.CellIndex = GetCellIndex(vert->cell()); return TRUE; } else { v = TriVertex3::NullVertex(); return FALSE; } } void GetCells(TriCell3* cells, int count) { BuildVertexIndices(); int i = 0; for (auto cell = model.all_cells_begin(); cell != model.all_cells_end(); ++cell) { TriCell3 c; c.IsInfinite = model.is_infinite(cell); c.Index = GetCellIndex(cell); c.VertexIndices[0] = cell->vertex(0)->info(); c.VertexIndices[1] = cell->vertex(1)->info(); c.VertexIndices[2] = cell->vertex(2)->info(); c.VertexIndices[3] = cell->vertex(3)->info(); c.NeighborIndices[0] = GetCellIndex(cell->neighbor(0)); c.NeighborIndices[1] = GetCellIndex(cell->neighbor(1)); c.NeighborIndices[2] = GetCellIndex(cell->neighbor(2)); c.NeighborIndices[3] = GetCellIndex(cell->neighbor(3)); cells[i++] = c; if (i >= count) return; } } BOOL GetCell(int index, TriCell3& cell) { BuildVertexIndices(); auto c = GetCell(index); if (c != nullptr) { cell.IsInfinite = model.is_infinite(c); cell.Index = GetCellIndex(c); cell.VertexIndices[0] = c->vertex(0)->info(); cell.VertexIndices[1] = c->vertex(1)->info(); cell.VertexIndices[2] = c->vertex(2)->info(); cell.VertexIndices[3] = c->vertex(3)->info(); cell.NeighborIndices[0] = GetCellIndex(c->neighbor(0)); cell.NeighborIndices[1] = GetCellIndex(c->neighbor(1)); cell.NeighborIndices[2] = GetCellIndex(c->neighbor(2)); cell.NeighborIndices[3] = GetCellIndex(c->neighbor(3)); return TRUE; } else { cell = TriCell3::NullCell(); return FALSE; } } void GetSegmentIndices(int* indices, int count) { BuildVertexIndices(); int index = 0; for (auto edge = model.all_edges_begin(); edge != model.all_edges_end(); ++edge) { indices[index * 2 + 0] = edge->first->vertex(0)->info(); indices[index * 2 + 1] = edge->first->vertex(1)->info(); index++; if (index * 2 >= count) return; } } void GetTriangleIndices(int* indices, int count) { BuildVertexIndices(); int index = 0; for (auto face = model.all_facets_begin(); face != model.all_facets_end(); ++face) { indices[index * 3 + 0] = face->first->vertex(0)->info(); indices[index * 3 + 1] = face->first->vertex(1)->info(); indices[index * 3 + 2] = face->first->vertex(2)->info(); index++; if (index * 3 >= count) return; } } void GetTetrahedraIndices(int* indices, int count) { BuildVertexIndices(); int index = 0; for (auto cell = model.all_cells_begin(); cell != model.all_cells_end(); ++cell) { indices[index * 4 + 0] = cell->vertex(0)->info(); indices[index * 4 + 1] = cell->vertex(1)->info(); indices[index * 4 + 2] = cell->vertex(2)->info(); indices[index * 4 + 3] = cell->vertex(3)->info(); index++; if (index * 4 >= count) return; } } void GetSegments(Segment3d* segments, int count) { BuildVertexIndices(); int index = 0; for (auto edge = model.all_edges_begin(); edge != model.all_edges_end(); ++edge) { auto a = edge->first->vertex(0)->point(); auto b = edge->first->vertex(1)->point(); segments[index].a = Point3d::FromCGAL(a); segments[index].b = Point3d::FromCGAL(b); index++; if (index >= count) return; } } void GetTriangles(Triangle3d* triangles, int count) { BuildVertexIndices(); int index = 0; for (auto face = model.all_facets_begin(); face != model.all_facets_end(); ++face) { auto a = face->first->vertex(0)->point(); auto b = face->first->vertex(1)->point(); auto c = face->first->vertex(2)->point(); triangles[index].a = Point3d::FromCGAL(a); triangles[index].b = Point3d::FromCGAL(b); triangles[index].c = Point3d::FromCGAL(c); index++; if (index >= count) return; } } void GetTetahedrons(Tetahedron3d* tetahedrons, int count) { BuildVertexIndices(); int index = 0; for (auto cell = model.all_cells_begin(); cell != model.all_cells_end(); ++cell) { auto a = cell->vertex(0)->point(); auto b = cell->vertex(1)->point(); auto c = cell->vertex(2)->point(); auto d = cell->vertex(3)->point(); tetahedrons[index].a = Point3d::FromCGAL(a); tetahedrons[index].b = Point3d::FromCGAL(b); tetahedrons[index].c = Point3d::FromCGAL(c); tetahedrons[index].d = Point3d::FromCGAL(d); index++; if (index >= count) return; } } void Transform(const Matrix4x4d& matrix) { auto m = matrix.ToCGAL(); for (auto vert = model.finite_vertices_begin(); vert != model.finite_vertices_end(); ++vert) { auto p = vert->point(); vert->set_point(m.transform(p)); } } void ResetCell(VERT& vert) { std::vector cells; model.incident_cells(vert, std::back_inserter(cells)); for (auto cell : cells) { if (!model.is_infinite(cell)) { vert->set_cell(cell); return; } } } int Degree(VERT& vert) { std::vector cells; model.incident_cells(vert, std::back_inserter(cells)); int count = 0; for (auto cell : cells) { if (!model.is_infinite(cell)) { count++; } } return count; } }; ================================================ FILE: CGALWrapper/Triangulations/ConstrainedDelaunayTriangulation2.h ================================================ #pragma once #include "../CGALWrapper.h" #include "../Geometry/Geometry2.h" #include "../Polygons/Polygon2.h" #include "../Polygons/PolygonWithHoles2.h" #include "BaseTriangulation2.h" #include "CGAL/Segment_2.h" #include "CGAL/Point_2.h" #include #include #include #include #include template class ConstrainedDelaunayTriangulation2 : public BaseTriangulation2 { public: typedef typename K::Point_2 Point_2; typedef CGAL::No_constraint_intersection_tag Tag1; typedef CGAL::No_constraint_intersection_requiring_constructions_tag Tag2; typedef CGAL::Exact_predicates_tag Tag3; typedef CGAL::Exact_intersections_tag Tag4; typedef CGAL::Triangulation_vertex_base_with_info_2 Vb; typedef CGAL::Constrained_Delaunay_triangulation_face_base_2 CFb; typedef CGAL::Triangulation_face_base_with_info_2 Fb; typedef CGAL::Triangulation_data_structure_2 Tds; typedef CGAL::Constrained_Delaunay_triangulation_2 Triangulation_2; typedef typename Triangulation_2::Face_handle Face; typedef typename Triangulation_2::Vertex_handle Vertex; typedef typename Triangulation_2::Edge Edge; public: inline static ConstrainedDelaunayTriangulation2* NewTriangulation2() { return new ConstrainedDelaunayTriangulation2(); } inline static void DeleteTriangulation2(void* ptr) { auto obj = static_cast(ptr); if (obj != nullptr) { delete obj; obj = nullptr; } } inline static ConstrainedDelaunayTriangulation2* CastToTriangulation2(void* ptr) { return static_cast(ptr); } void* Copy() { auto copy = NewTriangulation2(); copy->model = this->model; return copy; } template static void* Convert(void* ptr) { typedef CGAL::Cartesian_converter Converter; Converter convert; auto tri = NewTriangulation2(); auto tri2 = new ConstrainedDelaunayTriangulation2(); for (const auto& vert : tri->model.finite_vertex_handles()) { auto p = convert(vert->point()); //tri2->model.insert(p); } return tri2; } BOOL MoveVertex(int index, Point2d point, BOOL ifNoCollision, TriVertex2& triVert) { auto vert = this->map.FindVertex(this->model, index); if (vert != nullptr) { Vertex v; //if (ifNoCollision) // v = this->model.move(*vert, point.ToCGAL()); //else v = this->model.move_if_no_collision(*vert, point.ToCGAL()); if (v != *vert) this->map.OnModelChanged(); int degree = TriUtil::Degree2(this->model, v); triVert = TriVertex2::FromVertex(this->model, v, degree); return TRUE; } else { triVert = TriVertex2::NullVertex(); return FALSE; } } //Constrained only int ConstrainedEdgesCount() { int count = 0; for (auto edge = this->model.constrained_edges_begin(); edge != this->model.constrained_edges_end(); ++edge) ++count; return count; } BOOL HasIncidentConstraints(int index) { auto vert = this->map.FindVertex(this->model, index); if (vert != nullptr) return this->model.are_there_incident_constraints(*vert); else return FALSE; } int IncidentConstraintCount(int index) { int count = 0; auto vert = this->map.FindVertex(this->model, index); if (vert != nullptr) { auto edge = (*vert)->incident_edges(), end(edge); if (edge != nullptr) { do { if (this->model.is_constrained(*edge)) ++count; } while (++edge != end); } } return count; } void InsertSegmentConstraint(Point2d a, Point2d b) { if (a == b) return; this->model.insert_constraint(a.ToCGAL(), b.ToCGAL()); this->map.OnModelChanged(); } void InsertSegmentConstraint(int vertIndex1, int vertIndex2) { auto vert1 = this->map.FindVertex(this->model, vertIndex1); auto vert2 = this->map.FindVertex(this->model, vertIndex2); if (vert1 != nullptr && vert2 != nullptr) { this->model.insert_constraint(*vert1, *vert2); this->map.OnModelChanged(); } } void InsertSegmentConstraints(Segment2d* segments, int count) { for (int i = 0; i < count; i++) { if (segments[i].a == segments[i].b) continue; auto a = segments[i].a.ToCGAL(); auto b = segments[i].b.ToCGAL(); this->model.insert_constraint(a, b); } this->map.OnModelChanged(); } void InsertPolygonConstraint(void* polyPtr) { auto polygon = Polygon2::CastToPolygon2(polyPtr); this->model.insert_constraint(polygon->vertices_begin(), polygon->vertices_end(), true); this->map.OnModelChanged(); } void InsertPolygonWithHolesConstraint(void* pwhPtr) { auto pwh = PolygonWithHoles2::CastToPolygonWithHoles2(pwhPtr); if (!pwh->is_unbounded()) this->model.insert_constraint(pwh->outer_boundary().vertices_begin(), pwh->outer_boundary().vertices_end(), true); for (auto& hole : pwh->holes()) this->model.insert_constraint(hole.vertices_begin(), hole.vertices_end(), true); this->map.OnModelChanged(); } void GetConstraints(TriEdge2* constraints, int count) { this->map.SetIndices(this->model); int i = 0; for (auto edge = this->model.constrained_edges_begin(); edge != this->model.constrained_edges_end(); ++edge) { if (!this->model.is_infinite(edge->first)) { constraints[i].FaceIndex = edge->first->info(); constraints[i].NeighbourIndex = edge->second; } else { auto neighbour = edge->first->neighbor(edge->second); auto n = neighbour->index(edge->first); if (!this->model.is_infinite(neighbour)) constraints[i].FaceIndex = neighbour->info(); else constraints[i].FaceIndex = NULL_INDEX; constraints[i].NeighbourIndex = n; } if (i++ >= count) return; } } void GetConstraints(Segment2d* constraints, int count) { this->map.SetIndices(this->model); int i = 0; for (auto edge = this->model.constrained_edges_begin(); edge != this->model.constrained_edges_end(); ++edge) { auto seg = this->model.segment(edge->first, edge->second); constraints[i] = Segment2d::FromCGAL(seg[0], seg[1]); if (i++ >= count) return; } } void GetIncidentConstraints(int vertexIndex, TriEdge2* constraints, int count) { int i = 0; auto vert = this->map.FindVertex(this->model, vertexIndex); if (vert != nullptr) { this->map.SetVertexIndices(this->model); this->map.SetFaceIndices(this->model); auto edge = (*vert)->incident_edges(), end(edge); if (edge != nullptr) { do { if (this->model.is_constrained(*edge)) { if (!this->model.is_infinite(edge->first)) { constraints[i].FaceIndex = edge->first->info(); constraints[i].NeighbourIndex = edge->second; } else { auto neighbour = edge->first->neighbor(edge->second); auto n = neighbour->index(edge->first); if (!this->model.is_infinite(neighbour)) constraints[i].FaceIndex = neighbour->info(); else constraints[i].FaceIndex = NULL_INDEX; constraints[i].NeighbourIndex = n; } if (i++ >= count) return; } } while (++edge != end); } } } void RemoveConstraint(int faceIndex, int neighbourIndex) { if (neighbourIndex < 0 || neighbourIndex > 2) return; auto face = this->map.FindFace(this->model, faceIndex); if (face != nullptr) { this->model.remove_constraint(*face, neighbourIndex); } } void RemoveIncidentConstraints(int vertexIndex) { auto vert = this->map.FindVertex(this->model, vertexIndex); if (vert != nullptr) { this->model.remove_incident_constraints(*vert); } } int MarkDomains(int* indices, int count) { this->map.SetVertexIndices(this->model); //Need each face to store its nesting level. //Use the faces info value and then reset after. this->map.ForceSetFaceIndices(this->model, 0); this->MarkDomains(this->model); int num = 0; int index = 0; for (Face face : this->model.finite_face_handles()) { if (face->info() % 2 == 1) { indices[index * 3 + 0] = face->vertex(0)->info(); indices[index * 3 + 1] = face->vertex(1)->info(); indices[index * 3 + 2] = face->vertex(2)->info(); index++; num++; } } //Restore faces index value. //Face indices may have changed so //increment buildd stamp as well. this->map.SetFaceIndices(this->model); this->map.IncrementBuildStamp(); return num * 3; } private: void MarkDomains(Triangulation_2& ct, Face start, int index, std::list& border) { if (start->info() != -1) return; std::list queue; queue.push_back(start); while (!queue.empty()) { Face fh = queue.front(); queue.pop_front(); if (fh->info() == -1) { fh->info() = index; for (int i = 0; i < 3; i++) { Edge e(fh, i); Face n = fh->neighbor(i); if (n->info() == -1) { if (ct.is_constrained(e)) border.push_back(e); else queue.push_back(n); } } } } } /// /// explore set of facets connected with non constrained edges, /// and attribute to each such set a nesting level. /// We start from facets incident to the infinite vertex, with a nesting /// level of 0. Then we recursively consider the non-explored facets incident /// to constrained edges bounding the former set and increase the nesting level by 1. /// Facets in the domain are those with an odd nesting level. /// /// void MarkDomains(Triangulation_2& cdt) { for (Face f : cdt.all_face_handles()) f->info() = -1; std::list border; MarkDomains(cdt, cdt.infinite_face(), 0, border); while (!border.empty()) { Edge e = border.front(); border.pop_front(); Face n = e.first->neighbor(e.second); if (n->info() == -1) { MarkDomains(cdt, n, e.first->info() + 1, border); } } } }; ================================================ FILE: CGALWrapper/Triangulations/ConstrainedDelaunayTriangulation2_EEK.cpp ================================================ #pragma once #include "ConstrainedDelaunayTriangulation2_EEK.h" #include "ConstrainedDelaunayTriangulation2.h" #include "TriVertex2.h" #include "TriFace2.h" #include "TriEDge2.h" #include #include #include #include #include typedef typename EEK::Point_2 Point_2; typedef CGAL::No_constraint_intersection_tag Tag1; typedef CGAL::No_constraint_intersection_requiring_constructions_tag Tag2; typedef CGAL::Exact_predicates_tag Tag3; typedef CGAL::Exact_intersections_tag Tag4; typedef CGAL::Triangulation_vertex_base_with_info_2 Vb; typedef CGAL::Constrained_Delaunay_triangulation_face_base_2 CFb; typedef CGAL::Triangulation_face_base_with_info_2 Fb; typedef CGAL::Triangulation_data_structure_2 Tds; typedef CGAL::Constrained_Delaunay_triangulation_2 Triangulation_2; typedef typename Triangulation_2::Face_handle Face; typedef typename Triangulation_2::Vertex_handle Vertex; typedef typename Triangulation_2::Edge Edge; typedef ConstrainedDelaunayTriangulation2 Tri2; void* ConstrainedDelaunayTriangulation2_EEK_Create() { return Tri2::NewTriangulation2(); } void ConstrainedDelaunayTriangulation2_EEK_Release(void* ptr) { Tri2::DeleteTriangulation2(ptr); } void ConstrainedDelaunayTriangulation2_EEK_Clear(void* ptr) { auto tri = Tri2::CastToTriangulation2(ptr); tri->Clear(); } void* ConstrainedDelaunayTriangulation2_EEK_Copy(void* ptr) { auto tri = Tri2::CastToTriangulation2(ptr); return tri->Copy(); } void* ConstrainedDelaunayTriangulation2_EEK_Convert(void* ptr, CGAL_KERNEL k) { switch (k) { case CGAL_KERNEL::EXACT_PREDICATES_INEXACT_CONSTRUCTION: return Tri2::Convert(ptr); case CGAL_KERNEL::EXACT_PREDICATES_EXACT_CONSTRUCTION: return Tri2::Convert(ptr); default: return Tri2::Convert(ptr); } } void ConstrainedDelaunayTriangulation2_EEK_SetIndices(void* ptr) { auto tri = Tri2::CastToTriangulation2(ptr); tri->SetIndices(); } int ConstrainedDelaunayTriangulation2_EEK_BuildStamp(void* ptr) { auto tri = Tri2::CastToTriangulation2(ptr); return tri->BuildStamp(); } BOOL ConstrainedDelaunayTriangulation2_EEK_IsValid(void* ptr, int level) { auto tri = Tri2::CastToTriangulation2(ptr); return tri->IsValid(level); } int ConstrainedDelaunayTriangulation2_EEK_VertexCount(void* ptr) { auto tri = Tri2::CastToTriangulation2(ptr); return tri->VertexCount(); } int ConstrainedDelaunayTriangulation2_EEK_FaceCount(void* ptr) { auto tri = Tri2::CastToTriangulation2(ptr); return tri->FaceCount(); } void ConstrainedDelaunayTriangulation2_EEK_InsertPoint(void* ptr, Point2d point) { auto tri = Tri2::CastToTriangulation2(ptr); tri->InsertPoint(point); } void ConstrainedDelaunayTriangulation2_EEK_InsertPoints(void* ptr, Point2d* points, int count) { auto tri = Tri2::CastToTriangulation2(ptr); tri->InsertPoints(points, count); } void ConstrainedDelaunayTriangulation2_EEK_InsertPolygon(void* triPtr, void* polyPtr) { auto tri = Tri2::CastToTriangulation2(triPtr); tri->InsertPolygon(polyPtr); } void ConstrainedDelaunayTriangulation2_EEK_InsertPolygonWithHoles(void* triPtr, void* pwhPtr) { auto tri = Tri2::CastToTriangulation2(triPtr); tri->InsertPolygonWithHoles(pwhPtr); } void ConstrainedDelaunayTriangulation2_EEK_GetPoints(void* ptr, Point2d* points, int count) { auto tri = Tri2::CastToTriangulation2(ptr); tri->GetPoints(points, count); } void ConstrainedDelaunayTriangulation2_EEK_GetIndices(void* ptr, int* indices, int count) { auto tri = Tri2::CastToTriangulation2(ptr); tri->GetIndices(indices, count); } BOOL ConstrainedDelaunayTriangulation2_EEK_GetVertex(void* ptr, int index, TriVertex2& vertex) { auto tri = Tri2::CastToTriangulation2(ptr); return tri->GetVertex(index, vertex); } void ConstrainedDelaunayTriangulation2_EEK_GetVertices(void* ptr, TriVertex2* vertices, int count) { auto tri = Tri2::CastToTriangulation2(ptr); tri->GetVertices(vertices, count); } bool ConstrainedDelaunayTriangulation2_EEK_GetFace(void* ptr, int index, TriFace2& face) { auto tri = Tri2::CastToTriangulation2(ptr); return tri->GetFace(index, face); } void ConstrainedDelaunayTriangulation2_EEK_GetFaces(void* ptr, TriFace2* faces, int count) { auto tri = Tri2::CastToTriangulation2(ptr); tri->GetFaces(faces, count); } BOOL ConstrainedDelaunayTriangulation2_EEK_GetSegment(void* ptr, int faceIndex, int neighbourIndex, Segment2d& segment) { auto tri = Tri2::CastToTriangulation2(ptr); return tri->GetSegment(faceIndex, neighbourIndex, segment); } BOOL ConstrainedDelaunayTriangulation2_EEK_GetTriangle(void* ptr, int faceIndex, Triangle2d& triangle) { auto tri = Tri2::CastToTriangulation2(ptr); return tri->GetTriangle(faceIndex, triangle); } void ConstrainedDelaunayTriangulation2_EEK_GetTriangles(void* ptr, Triangle2d* triangles, int count) { auto tri = Tri2::CastToTriangulation2(ptr); tri->GetTriangles(triangles, count); } BOOL ConstrainedDelaunayTriangulation2_EEK_GetCircumcenter(void* ptr, int faceIndex, Point2d& circumcenter) { auto tri = Tri2::CastToTriangulation2(ptr); return tri->GetCircumcenter(faceIndex, circumcenter); } void ConstrainedDelaunayTriangulation2_EEK_GetCircumcenters(void* ptr, Point2d* circumcenters, int count) { auto tri = Tri2::CastToTriangulation2(ptr); tri->GetCircumcenters(circumcenters, count); } int ConstrainedDelaunayTriangulation2_EEK_NeighbourIndex(void* ptr, int faceIndex, int index) { auto tri = Tri2::CastToTriangulation2(ptr); return tri->NeighbourIndex(faceIndex, index); } BOOL ConstrainedDelaunayTriangulation2_EEK_LocateFace(void* ptr, Point2d point, TriFace2& face) { auto tri = Tri2::CastToTriangulation2(ptr); return tri->LocateFace(point, face); } BOOL ConstrainedDelaunayTriangulation2_EEK_MoveVertex(void* ptr, int index, Point2d point, BOOL ifNoCollision, TriVertex2& vertex) { auto tri = Tri2::CastToTriangulation2(ptr); return tri->MoveVertex(index, point, ifNoCollision, vertex); } BOOL ConstrainedDelaunayTriangulation2_EEK_RemoveVertex(void* ptr, int index) { auto tri = Tri2::CastToTriangulation2(ptr); return tri->RemoveVertex(index); } BOOL ConstrainedDelaunayTriangulation2_EEK_FlipEdge(void* ptr, int faceIndex, int neighbour) { auto tri = Tri2::CastToTriangulation2(ptr); return tri->FlipEdge(faceIndex, neighbour); } void ConstrainedDelaunayTriangulation2_EEK_Transform(void* ptr, Point2d translation, double rotation, double scale) { auto tri = Tri2::CastToTriangulation2(ptr); tri->Transform(translation, rotation, scale); } //Constrained only int ConstrainedDelaunayTriangulation2_EEK_ConstrainedEdgesCount(void* ptr) { auto tri = Tri2::CastToTriangulation2(ptr); return tri->ConstrainedEdgesCount(); } BOOL ConstrainedDelaunayTriangulation2_EEK_HasIncidentConstraints(void* ptr, int index) { auto tri = Tri2::CastToTriangulation2(ptr); return tri->HasIncidentConstraints(index); } int ConstrainedDelaunayTriangulation2_EEK_IncidentConstraintCount(void* ptr, int index) { auto tri = Tri2::CastToTriangulation2(ptr); return tri->IncidentConstraintCount(index); } void ConstrainedDelaunayTriangulation2_EEK_InsertSegmentConstraintFromPoints(void* ptr, Point2d a, Point2d b) { auto tri = Tri2::CastToTriangulation2(ptr); tri->InsertSegmentConstraint(a, b); } void ConstrainedDelaunayTriangulation2_EEK_InsertSegmentConstraintFromVertices(void* ptr, int vertIndex1, int vertIndex2) { auto tri = Tri2::CastToTriangulation2(ptr); tri->InsertSegmentConstraint(vertIndex1, vertIndex2); } void ConstrainedDelaunayTriangulation2_EEK_InsertSegmentConstraints(void* ptr, Segment2d* segments, int count) { auto tri = Tri2::CastToTriangulation2(ptr); tri->InsertSegmentConstraints(segments, count); } void ConstrainedDelaunayTriangulation2_EEK_InsertPolygonConstraint(void* triPtr, void* polyPtr) { auto tri = Tri2::CastToTriangulation2(triPtr); tri->InsertPolygonConstraint(polyPtr); } void ConstrainedDelaunayTriangulation2_EEK_InsertPolygonWithHolesConstraint(void* triPtr, void* pwhPtr) { auto tri = Tri2::CastToTriangulation2(triPtr); tri->InsertPolygonWithHolesConstraint(pwhPtr); } void ConstrainedDelaunayTriangulation2_EEK_GetEdgeConstraints(void* ptr, TriEdge2* constraints, int count) { auto tri = Tri2::CastToTriangulation2(ptr); tri->GetConstraints(constraints, count); } void ConstrainedDelaunayTriangulation2_EEK_GetSegmentConstraints(void* ptr, Segment2d* constraints, int count) { auto tri = Tri2::CastToTriangulation2(ptr); tri->GetConstraints(constraints, count); } void ConstrainedDelaunayTriangulation2_EEK_GetIncidentConstraints(void* ptr, int vertexIndex, TriEdge2* constraints, int count) { auto tri = Tri2::CastToTriangulation2(ptr); tri->GetIncidentConstraints(vertexIndex, constraints, count); } void ConstrainedDelaunayTriangulation2_EEK_RemoveConstraint(void* ptr, int faceIndex, int neighbourIndex) { auto tri = Tri2::CastToTriangulation2(ptr); tri->RemoveConstraint(faceIndex, neighbourIndex); } void ConstrainedDelaunayTriangulation2_EEK_RemoveIncidentConstraints(void* ptr, int vertexIndex) { auto tri = Tri2::CastToTriangulation2(ptr); tri->RemoveIncidentConstraints(vertexIndex); } int ConstrainedDelaunayTriangulation2_EEK_MarkDomains(void* ptr, int* indices, int count) { auto tri = Tri2::CastToTriangulation2(ptr); return tri->MarkDomains(indices, count); } ================================================ FILE: CGALWrapper/Triangulations/ConstrainedDelaunayTriangulation2_EEK.h ================================================ #pragma once #include "../CGALWrapper.h" #include "../Geometry/Geometry2.h" #include "ConstrainedDelaunayTriangulation2.h" extern "C" { CGALWRAPPER_API void* ConstrainedDelaunayTriangulation2_EEK_Create(); CGALWRAPPER_API void ConstrainedDelaunayTriangulation2_EEK_Release(void* ptr); CGALWRAPPER_API void ConstrainedDelaunayTriangulation2_EEK_Clear(void* ptr); CGALWRAPPER_API void* ConstrainedDelaunayTriangulation2_EEK_Copy(void* ptr); CGALWRAPPER_API void* ConstrainedDelaunayTriangulation2_EEK_Convert(void* ptr, CGAL_KERNEL k); CGALWRAPPER_API void ConstrainedDelaunayTriangulation2_EEK_SetIndices(void* ptr); CGALWRAPPER_API int ConstrainedDelaunayTriangulation2_EEK_BuildStamp(void* ptr); CGALWRAPPER_API BOOL ConstrainedDelaunayTriangulation2_EEK_IsValid(void* ptr, int level); CGALWRAPPER_API int ConstrainedDelaunayTriangulation2_EEK_VertexCount(void* ptr); CGALWRAPPER_API int ConstrainedDelaunayTriangulation2_EEK_FaceCount(void* ptr); CGALWRAPPER_API void ConstrainedDelaunayTriangulation2_EEK_InsertPoint(void* ptr, Point2d point); CGALWRAPPER_API void ConstrainedDelaunayTriangulation2_EEK_InsertPoints(void* ptr, Point2d* points, int count); CGALWRAPPER_API void ConstrainedDelaunayTriangulation2_EEK_InsertPolygon(void* triPtr, void* polyPtr); CGALWRAPPER_API void ConstrainedDelaunayTriangulation2_EEK_InsertPolygonWithHoles(void* triPtr, void* pwhPtr); CGALWRAPPER_API void ConstrainedDelaunayTriangulation2_EEK_GetPoints(void* ptr, Point2d* points, int count); CGALWRAPPER_API void ConstrainedDelaunayTriangulation2_EEK_GetIndices(void* ptr, int* indices, int count); CGALWRAPPER_API BOOL ConstrainedDelaunayTriangulation2_EEK_GetVertex(void* ptr, int index, TriVertex2& vertex); CGALWRAPPER_API void ConstrainedDelaunayTriangulation2_EEK_GetVertices(void* ptr, TriVertex2* vertices, int count); CGALWRAPPER_API bool ConstrainedDelaunayTriangulation2_EEK_GetFace(void* ptr, int index, TriFace2& face); CGALWRAPPER_API void ConstrainedDelaunayTriangulation2_EEK_GetFaces(void* ptr, TriFace2* faces, int count); CGALWRAPPER_API BOOL ConstrainedDelaunayTriangulation2_EEK_GetSegment(void* ptr, int faceIndex, int neighbourIndex, Segment2d& segment); CGALWRAPPER_API BOOL ConstrainedDelaunayTriangulation2_EEK_GetTriangle(void* ptr, int faceIndex, Triangle2d& triangle); CGALWRAPPER_API void ConstrainedDelaunayTriangulation2_EEK_GetTriangles(void* ptr, Triangle2d* triangles, int count); CGALWRAPPER_API BOOL ConstrainedDelaunayTriangulation2_EEK_GetCircumcenter(void* ptr, int faceIndex, Point2d& circumcenter); CGALWRAPPER_API void ConstrainedDelaunayTriangulation2_EEK_GetCircumcenters(void* ptr, Point2d* circumcenters, int count); CGALWRAPPER_API int ConstrainedDelaunayTriangulation2_EEK_NeighbourIndex(void* ptr, int faceIndex, int index); CGALWRAPPER_API BOOL ConstrainedDelaunayTriangulation2_EEK_LocateFace(void* ptr, Point2d point, TriFace2& face); CGALWRAPPER_API BOOL ConstrainedDelaunayTriangulation2_EEK_MoveVertex(void* ptr, int index, Point2d point, BOOL ifNoCollision, TriVertex2& vertex); CGALWRAPPER_API BOOL ConstrainedDelaunayTriangulation2_EEK_RemoveVertex(void* ptr, int index); CGALWRAPPER_API BOOL ConstrainedDelaunayTriangulation2_EEK_FlipEdge(void* ptr, int faceIndex, int neighbour); CGALWRAPPER_API void ConstrainedDelaunayTriangulation2_EEK_Transform(void* ptr, Point2d translation, double rotation, double scale); //Constrained only CGALWRAPPER_API int ConstrainedDelaunayTriangulation2_EEK_ConstrainedEdgesCount(void* ptr); CGALWRAPPER_API BOOL ConstrainedDelaunayTriangulation2_EEK_HasIncidentConstraints(void* ptr, int index); CGALWRAPPER_API int ConstrainedDelaunayTriangulation2_EEK_IncidentConstraintCount(void* ptr, int index); CGALWRAPPER_API void ConstrainedDelaunayTriangulation2_EEK_InsertSegmentConstraintFromPoints(void* ptr, Point2d a, Point2d b); CGALWRAPPER_API void ConstrainedDelaunayTriangulation2_EEK_InsertSegmentConstraintFromVertices(void* ptr, int vertIndex1, int vertIndex2); CGALWRAPPER_API void ConstrainedDelaunayTriangulation2_EEK_InsertSegmentConstraints(void* ptr, Segment2d* segments, int count); CGALWRAPPER_API void ConstrainedDelaunayTriangulation2_EEK_InsertPolygonConstraint(void* triPtr, void* polyPtr); CGALWRAPPER_API void ConstrainedDelaunayTriangulation2_EEK_InsertPolygonWithHolesConstraint(void* triPtr, void* pwhPtr); CGALWRAPPER_API void ConstrainedDelaunayTriangulation2_EEK_GetEdgeConstraints(void* ptr, TriEdge2* constraints, int count); CGALWRAPPER_API void ConstrainedDelaunayTriangulation2_EEK_GetSegmentConstraints(void* ptr, Segment2d* constraints, int count); CGALWRAPPER_API void ConstrainedDelaunayTriangulation2_EEK_GetIncidentConstraints(void* ptr, int vertexIndex, TriEdge2* constraints, int count); CGALWRAPPER_API void ConstrainedDelaunayTriangulation2_EEK_RemoveConstraint(void* ptr, int faceIndex, int neighbourIndex); CGALWRAPPER_API void ConstrainedDelaunayTriangulation2_EEK_RemoveIncidentConstraints(void* ptr, int vertexIndex); CGALWRAPPER_API int ConstrainedDelaunayTriangulation2_EEK_MarkDomains(void* ptr, int* indices, int count); } ================================================ FILE: CGALWrapper/Triangulations/ConstrainedDelaunayTriangulation2_EIK.cpp ================================================ #pragma once #include "ConstrainedDelaunayTriangulation2_EIK.h" #include "ConstrainedDelaunayTriangulation2.h" #include "TriVertex2.h" #include "TriFace2.h" #include "TriEDge2.h" #include #include #include #include #include typedef typename EIK::Point_2 Point_2; typedef CGAL::No_constraint_intersection_tag Tag1; typedef CGAL::No_constraint_intersection_requiring_constructions_tag Tag2; typedef CGAL::Exact_predicates_tag Tag3; typedef CGAL::Exact_intersections_tag Tag4; typedef CGAL::Triangulation_vertex_base_with_info_2 Vb; typedef CGAL::Constrained_Delaunay_triangulation_face_base_2 CFb; typedef CGAL::Triangulation_face_base_with_info_2 Fb; typedef CGAL::Triangulation_data_structure_2 Tds; typedef CGAL::Constrained_Delaunay_triangulation_2 Triangulation_2; typedef typename Triangulation_2::Face_handle Face; typedef typename Triangulation_2::Vertex_handle Vertex; typedef typename Triangulation_2::Edge Edge; typedef ConstrainedDelaunayTriangulation2 Tri2; void* ConstrainedDelaunayTriangulation2_EIK_Create() { return Tri2::NewTriangulation2(); } void ConstrainedDelaunayTriangulation2_EIK_Release(void* ptr) { Tri2::DeleteTriangulation2(ptr); } void ConstrainedDelaunayTriangulation2_EIK_Clear(void* ptr) { auto tri = Tri2::CastToTriangulation2(ptr); tri->Clear(); } void* ConstrainedDelaunayTriangulation2_EIK_Copy(void* ptr) { auto tri = Tri2::CastToTriangulation2(ptr); return tri->Copy(); } void* ConstrainedDelaunayTriangulation2_EIK_Convert(void* ptr, CGAL_KERNEL k) { switch (k) { case CGAL_KERNEL::EXACT_PREDICATES_INEXACT_CONSTRUCTION: return Tri2::Convert(ptr); case CGAL_KERNEL::EXACT_PREDICATES_EXACT_CONSTRUCTION: return Tri2::Convert(ptr); default: return Tri2::Convert(ptr); } } void ConstrainedDelaunayTriangulation2_EIK_SetIndices(void* ptr) { auto tri = Tri2::CastToTriangulation2(ptr); tri->SetIndices(); } int ConstrainedDelaunayTriangulation2_EIK_BuildStamp(void* ptr) { auto tri = Tri2::CastToTriangulation2(ptr); return tri->BuildStamp(); } BOOL ConstrainedDelaunayTriangulation2_EIK_IsValid(void* ptr, int level) { auto tri = Tri2::CastToTriangulation2(ptr); return tri->IsValid(level); } int ConstrainedDelaunayTriangulation2_EIK_VertexCount(void* ptr) { auto tri = Tri2::CastToTriangulation2(ptr); return tri->VertexCount(); } int ConstrainedDelaunayTriangulation2_EIK_FaceCount(void* ptr) { auto tri = Tri2::CastToTriangulation2(ptr); return tri->FaceCount(); } void ConstrainedDelaunayTriangulation2_EIK_InsertPoint(void* ptr, Point2d point) { auto tri = Tri2::CastToTriangulation2(ptr); tri->InsertPoint(point); } void ConstrainedDelaunayTriangulation2_EIK_InsertPoints(void* ptr, Point2d* points, int count) { auto tri = Tri2::CastToTriangulation2(ptr); tri->InsertPoints(points, count); } void ConstrainedDelaunayTriangulation2_EIK_InsertPolygon(void* triPtr, void* polyPtr) { auto tri = Tri2::CastToTriangulation2(triPtr); tri->InsertPolygon(polyPtr); } void ConstrainedDelaunayTriangulation2_EIK_InsertPolygonWithHoles(void* triPtr, void* pwhPtr) { auto tri = Tri2::CastToTriangulation2(triPtr); tri->InsertPolygonWithHoles(pwhPtr); } void ConstrainedDelaunayTriangulation2_EIK_GetPoints(void* ptr, Point2d* points, int count) { auto tri = Tri2::CastToTriangulation2(ptr); tri->GetPoints(points, count); } void ConstrainedDelaunayTriangulation2_EIK_GetIndices(void* ptr, int* indices, int count) { auto tri = Tri2::CastToTriangulation2(ptr); tri->GetIndices(indices, count); } BOOL ConstrainedDelaunayTriangulation2_EIK_GetVertex(void* ptr, int index, TriVertex2& vertex) { auto tri = Tri2::CastToTriangulation2(ptr); return tri->GetVertex(index, vertex); } void ConstrainedDelaunayTriangulation2_EIK_GetVertices(void* ptr, TriVertex2* vertices, int count) { auto tri = Tri2::CastToTriangulation2(ptr); tri->GetVertices(vertices, count); } bool ConstrainedDelaunayTriangulation2_EIK_GetFace(void* ptr, int index, TriFace2& face) { auto tri = Tri2::CastToTriangulation2(ptr); return tri->GetFace(index, face); } void ConstrainedDelaunayTriangulation2_EIK_GetFaces(void* ptr, TriFace2* faces, int count) { auto tri = Tri2::CastToTriangulation2(ptr); tri->GetFaces(faces, count); } BOOL ConstrainedDelaunayTriangulation2_EIK_GetSegment(void* ptr, int faceIndex, int neighbourIndex, Segment2d& segment) { auto tri = Tri2::CastToTriangulation2(ptr); return tri->GetSegment(faceIndex, neighbourIndex, segment); } BOOL ConstrainedDelaunayTriangulation2_EIK_GetTriangle(void* ptr, int faceIndex, Triangle2d& triangle) { auto tri = Tri2::CastToTriangulation2(ptr); return tri->GetTriangle(faceIndex, triangle); } void ConstrainedDelaunayTriangulation2_EIK_GetTriangles(void* ptr, Triangle2d* triangles, int count) { auto tri = Tri2::CastToTriangulation2(ptr); tri->GetTriangles(triangles, count); } BOOL ConstrainedDelaunayTriangulation2_EIK_GetCircumcenter(void* ptr, int faceIndex, Point2d& circumcenter) { auto tri = Tri2::CastToTriangulation2(ptr); return tri->GetCircumcenter(faceIndex, circumcenter); } void ConstrainedDelaunayTriangulation2_EIK_GetCircumcenters(void* ptr, Point2d* circumcenters, int count) { auto tri = Tri2::CastToTriangulation2(ptr); tri->GetCircumcenters(circumcenters, count); } int ConstrainedDelaunayTriangulation2_EIK_NeighbourIndex(void* ptr, int faceIndex, int index) { auto tri = Tri2::CastToTriangulation2(ptr); return tri->NeighbourIndex(faceIndex, index); } BOOL ConstrainedDelaunayTriangulation2_EIK_LocateFace(void* ptr, Point2d point, TriFace2& face) { auto tri = Tri2::CastToTriangulation2(ptr); return tri->LocateFace(point, face); } BOOL ConstrainedDelaunayTriangulation2_EIK_MoveVertex(void* ptr, int index, Point2d point, BOOL ifNoCollision, TriVertex2& vertex) { auto tri = Tri2::CastToTriangulation2(ptr); return tri->MoveVertex(index, point, ifNoCollision, vertex); } BOOL ConstrainedDelaunayTriangulation2_EIK_RemoveVertex(void* ptr, int index) { auto tri = Tri2::CastToTriangulation2(ptr); return tri->RemoveVertex(index); } BOOL ConstrainedDelaunayTriangulation2_EIK_FlipEdge(void* ptr, int faceIndex, int neighbour) { auto tri = Tri2::CastToTriangulation2(ptr); return tri->FlipEdge(faceIndex, neighbour); } void ConstrainedDelaunayTriangulation2_EIK_Transform(void* ptr, Point2d translation, double rotation, double scale) { auto tri = Tri2::CastToTriangulation2(ptr); tri->Transform(translation, rotation, scale); } //Constrained only int ConstrainedDelaunayTriangulation2_EIK_ConstrainedEdgesCount(void* ptr) { auto tri = Tri2::CastToTriangulation2(ptr); return tri->ConstrainedEdgesCount(); } BOOL ConstrainedDelaunayTriangulation2_EIK_HasIncidentConstraints(void* ptr, int index) { auto tri = Tri2::CastToTriangulation2(ptr); return tri->HasIncidentConstraints(index); } int ConstrainedDelaunayTriangulation2_EIK_IncidentConstraintCount(void* ptr, int index) { auto tri = Tri2::CastToTriangulation2(ptr); return tri->IncidentConstraintCount(index); } void ConstrainedDelaunayTriangulation2_EIK_InsertSegmentConstraintFromPoints(void* ptr, Point2d a, Point2d b) { auto tri = Tri2::CastToTriangulation2(ptr); tri->InsertSegmentConstraint(a, b); } void ConstrainedDelaunayTriangulation2_EIK_InsertSegmentConstraintFromVertices(void* ptr, int vertIndex1, int vertIndex2) { auto tri = Tri2::CastToTriangulation2(ptr); tri->InsertSegmentConstraint(vertIndex1, vertIndex2); } void ConstrainedDelaunayTriangulation2_EIK_InsertSegmentConstraints(void* ptr, Segment2d* segments, int count) { auto tri = Tri2::CastToTriangulation2(ptr); tri->InsertSegmentConstraints(segments, count); } void ConstrainedDelaunayTriangulation2_EIK_InsertPolygonConstraint(void* triPtr, void* polyPtr) { auto tri = Tri2::CastToTriangulation2(triPtr); tri->InsertPolygonConstraint(polyPtr); } void ConstrainedDelaunayTriangulation2_EIK_InsertPolygonWithHolesConstraint(void* triPtr, void* pwhPtr) { auto tri = Tri2::CastToTriangulation2(triPtr); tri->InsertPolygonWithHolesConstraint(pwhPtr); } void ConstrainedDelaunayTriangulation2_EIK_GetEdgeConstraints(void* ptr, TriEdge2* constraints, int count) { auto tri = Tri2::CastToTriangulation2(ptr); tri->GetConstraints(constraints, count); } void ConstrainedDelaunayTriangulation2_EIK_GetSegmentConstraints(void* ptr, Segment2d* constraints, int count) { auto tri = Tri2::CastToTriangulation2(ptr); tri->GetConstraints(constraints, count); } void ConstrainedDelaunayTriangulation2_EIK_GetIncidentConstraints(void* ptr, int vertexIndex, TriEdge2* constraints, int count) { auto tri = Tri2::CastToTriangulation2(ptr); tri->GetIncidentConstraints(vertexIndex, constraints, count); } void ConstrainedDelaunayTriangulation2_EIK_RemoveConstraint(void* ptr, int faceIndex, int neighbourIndex) { auto tri = Tri2::CastToTriangulation2(ptr); tri->RemoveConstraint(faceIndex, neighbourIndex); } void ConstrainedDelaunayTriangulation2_EIK_RemoveIncidentConstraints(void* ptr, int vertexIndex) { auto tri = Tri2::CastToTriangulation2(ptr); tri->RemoveIncidentConstraints(vertexIndex); } int ConstrainedDelaunayTriangulation2_EIK_MarkDomains(void* ptr, int* indices, int count) { auto tri = Tri2::CastToTriangulation2(ptr); return tri->MarkDomains(indices, count); } ================================================ FILE: CGALWrapper/Triangulations/ConstrainedDelaunayTriangulation2_EIK.h ================================================ #pragma once #include "../CGALWrapper.h" #include "../Geometry/Geometry2.h" #include "ConstrainedDelaunayTriangulation2.h" extern "C" { CGALWRAPPER_API void* ConstrainedDelaunayTriangulation2_EIK_Create(); CGALWRAPPER_API void ConstrainedDelaunayTriangulation2_EIK_Release(void* ptr); CGALWRAPPER_API void ConstrainedDelaunayTriangulation2_EIK_Clear(void* ptr); CGALWRAPPER_API void* ConstrainedDelaunayTriangulation2_EIK_Copy(void* ptr); CGALWRAPPER_API void* ConstrainedDelaunayTriangulation2_EIK_Convert(void* ptr, CGAL_KERNEL k); CGALWRAPPER_API void ConstrainedDelaunayTriangulation2_EIK_SetIndices(void* ptr); CGALWRAPPER_API int ConstrainedDelaunayTriangulation2_EIK_BuildStamp(void* ptr); CGALWRAPPER_API BOOL ConstrainedDelaunayTriangulation2_EIK_IsValid(void* ptr, int level); CGALWRAPPER_API int ConstrainedDelaunayTriangulation2_EIK_VertexCount(void* ptr); CGALWRAPPER_API int ConstrainedDelaunayTriangulation2_EIK_FaceCount(void* ptr); CGALWRAPPER_API void ConstrainedDelaunayTriangulation2_EIK_InsertPoint(void* ptr, Point2d point); CGALWRAPPER_API void ConstrainedDelaunayTriangulation2_EIK_InsertPoints(void* ptr, Point2d* points, int count); CGALWRAPPER_API void ConstrainedDelaunayTriangulation2_EIK_InsertPolygon(void* triPtr, void* polyPtr); CGALWRAPPER_API void ConstrainedDelaunayTriangulation2_EIK_InsertPolygonWithHoles(void* triPtr, void* pwhPtr); CGALWRAPPER_API void ConstrainedDelaunayTriangulation2_EIK_GetPoints(void* ptr, Point2d* points, int count); CGALWRAPPER_API void ConstrainedDelaunayTriangulation2_EIK_GetIndices(void* ptr, int* indices, int count); CGALWRAPPER_API BOOL ConstrainedDelaunayTriangulation2_EIK_GetVertex(void* ptr, int index, TriVertex2& vertex); CGALWRAPPER_API void ConstrainedDelaunayTriangulation2_EIK_GetVertices(void* ptr, TriVertex2* vertices, int count); CGALWRAPPER_API bool ConstrainedDelaunayTriangulation2_EIK_GetFace(void* ptr, int index, TriFace2& face); CGALWRAPPER_API void ConstrainedDelaunayTriangulation2_EIK_GetFaces(void* ptr, TriFace2* faces, int count); CGALWRAPPER_API BOOL ConstrainedDelaunayTriangulation2_EIK_GetSegment(void* ptr, int faceIndex, int neighbourIndex, Segment2d& segment); CGALWRAPPER_API BOOL ConstrainedDelaunayTriangulation2_EIK_GetTriangle(void* ptr, int faceIndex, Triangle2d& triangle); CGALWRAPPER_API void ConstrainedDelaunayTriangulation2_EIK_GetTriangles(void* ptr, Triangle2d* triangles, int count); CGALWRAPPER_API BOOL ConstrainedDelaunayTriangulation2_EIK_GetCircumcenter(void* ptr, int faceIndex, Point2d& circumcenter); CGALWRAPPER_API void ConstrainedDelaunayTriangulation2_EIK_GetCircumcenters(void* ptr, Point2d* circumcenters, int count); CGALWRAPPER_API int ConstrainedDelaunayTriangulation2_EIK_NeighbourIndex(void* ptr, int faceIndex, int index); CGALWRAPPER_API BOOL ConstrainedDelaunayTriangulation2_EIK_LocateFace(void* ptr, Point2d point, TriFace2& face); CGALWRAPPER_API BOOL ConstrainedDelaunayTriangulation2_EIK_MoveVertex(void* ptr, int index, Point2d point, BOOL ifNoCollision, TriVertex2& vertex); CGALWRAPPER_API BOOL ConstrainedDelaunayTriangulation2_EIK_RemoveVertex(void* ptr, int index); CGALWRAPPER_API BOOL ConstrainedDelaunayTriangulation2_EIK_FlipEdge(void* ptr, int faceIndex, int neighbour); CGALWRAPPER_API void ConstrainedDelaunayTriangulation2_EIK_Transform(void* ptr, Point2d translation, double rotation, double scale); //Constrained only CGALWRAPPER_API int ConstrainedDelaunayTriangulation2_EIK_ConstrainedEdgesCount(void* ptr); CGALWRAPPER_API BOOL ConstrainedDelaunayTriangulation2_EIK_HasIncidentConstraints(void* ptr, int index); CGALWRAPPER_API int ConstrainedDelaunayTriangulation2_EIK_IncidentConstraintCount(void* ptr, int index); CGALWRAPPER_API void ConstrainedDelaunayTriangulation2_EIK_InsertSegmentConstraintFromPoints(void* ptr, Point2d a, Point2d b); CGALWRAPPER_API void ConstrainedDelaunayTriangulation2_EIK_InsertSegmentConstraintFromVertices(void* ptr, int vertIndex1, int vertIndex2); CGALWRAPPER_API void ConstrainedDelaunayTriangulation2_EIK_InsertSegmentConstraints(void* ptr, Segment2d* segments, int count); CGALWRAPPER_API void ConstrainedDelaunayTriangulation2_EIK_InsertPolygonConstraint(void* triPtr, void* polyPtr); CGALWRAPPER_API void ConstrainedDelaunayTriangulation2_EIK_InsertPolygonWithHolesConstraint(void* triPtr, void* pwhPtr); CGALWRAPPER_API void ConstrainedDelaunayTriangulation2_EIK_GetEdgeConstraints(void* ptr, TriEdge2* constraints, int count); CGALWRAPPER_API void ConstrainedDelaunayTriangulation2_EIK_GetSegmentConstraints(void* ptr, Segment2d* constraints, int count); CGALWRAPPER_API void ConstrainedDelaunayTriangulation2_EIK_GetIncidentConstraints(void* ptr, int vertexIndex, TriEdge2* constraints, int count); CGALWRAPPER_API void ConstrainedDelaunayTriangulation2_EIK_RemoveConstraint(void* ptr, int faceIndex, int neighbourIndex); CGALWRAPPER_API void ConstrainedDelaunayTriangulation2_EIK_RemoveIncidentConstraints(void* ptr, int vertexIndex); CGALWRAPPER_API int ConstrainedDelaunayTriangulation2_EIK_MarkDomains(void* ptr, int* indices, int count); } ================================================ FILE: CGALWrapper/Triangulations/ConstrainedTriangulation2.h ================================================ #pragma once #include "../CGALWrapper.h" #include "../Geometry/Geometry2.h" #include "../Polygons/Polygon2.h" #include "../Polygons/PolygonWithHoles2.h" #include "BaseTriangulation2.h" #include "CGAL/Segment_2.h" #include "CGAL/Point_2.h" #include #include #include #include #include template class ConstrainedTriangulation2 : public BaseTriangulation2 { public: typedef typename K::Point_2 Point_2; typedef CGAL::No_constraint_intersection_tag Tag1; typedef CGAL::No_constraint_intersection_requiring_constructions_tag Tag2; typedef CGAL::Exact_predicates_tag Tag3; typedef CGAL::Exact_intersections_tag Tag4; typedef CGAL::Triangulation_vertex_base_with_info_2 Vb; typedef CGAL::Constrained_triangulation_face_base_2 CFb; typedef CGAL::Triangulation_face_base_with_info_2 Fb; typedef CGAL::Triangulation_data_structure_2 Tds; typedef CGAL::Constrained_triangulation_2 Triangulation_2; typedef typename Triangulation_2::Face_handle Face; typedef typename Triangulation_2::Vertex_handle Vertex; typedef typename Triangulation_2::Edge Edge; public: inline static ConstrainedTriangulation2* NewTriangulation2() { return new ConstrainedTriangulation2(); } inline static void DeleteTriangulation2(void* ptr) { auto obj = static_cast(ptr); if (obj != nullptr) { delete obj; obj = nullptr; } } inline static ConstrainedTriangulation2* CastToTriangulation2(void* ptr) { return static_cast(ptr); } void* Copy() { auto copy = NewTriangulation2(); copy->model = this->model; return copy; } template static void* Convert(void* ptr) { typedef CGAL::Cartesian_converter Converter; Converter convert; auto tri = NewTriangulation2(); auto tri2 = new ConstrainedTriangulation2(); for (const auto& vert : tri->model.finite_vertex_handles()) { auto p = convert(vert->point()); //tri2->model.insert(p); } return tri2; } BOOL MoveVertex(int index, Point2d point, BOOL ifNoCollision, TriVertex2& triVert) { auto vert = this->map.FindVertex(this->model, index); if (vert != nullptr) { Vertex v; //if (ifNoCollision) // v = this->model.move(*vert, point.ToCGAL()); //else v = this->model.move_if_no_collision(*vert, point.ToCGAL()); if (v != *vert) this->map.OnModelChanged(); int degree = TriUtil::Degree2(this->model, v); triVert = TriVertex2::FromVertex(this->model, v, degree); return TRUE; } else { triVert = TriVertex2::NullVertex(); return FALSE; } } //Constrained only int ConstrainedEdgesCount() { int count = 0; for (auto edge = this->model.constrained_edges_begin(); edge != this->model.constrained_edges_end(); ++edge) ++count; return count; } BOOL HasIncidentConstraints(int index) { auto vert = this->map.FindVertex(this->model, index); if (vert != nullptr) return this->model.are_there_incident_constraints(*vert); else return FALSE; } int IncidentConstraintCount(int index) { int count = 0; auto vert = this->map.FindVertex(this->model, index); if (vert != nullptr) { auto edge = (*vert)->incident_edges(), end(edge); if (edge != nullptr) { do { if (this->model.is_constrained(*edge)) ++count; } while (++edge != end); } } return count; } void InsertSegmentConstraint(Point2d a, Point2d b) { if (a == b) return; this->model.insert_constraint(a.ToCGAL(), b.ToCGAL()); this->map.OnModelChanged(); } void InsertSegmentConstraint(int vertIndex1, int vertIndex2) { auto vert1 = this->map.FindVertex(this->model, vertIndex1); auto vert2 = this->map.FindVertex(this->model, vertIndex2); if (vert1 != nullptr && vert2 != nullptr) { this->model.insert_constraint(*vert1, *vert2); this->map.OnModelChanged(); } } void InsertSegmentConstraints(Segment2d* segments, int count) { for (int i = 0; i < count; i++) { if (segments[i].a == segments[i].b) continue; auto a = segments[i].a.ToCGAL(); auto b = segments[i].b.ToCGAL(); this->model.insert_constraint(a, b); } this->map.OnModelChanged(); } void InsertPolygonConstraint(void* polyPtr) { auto polygon = Polygon2::CastToPolygon2(polyPtr); this->model.insert_constraint(polygon->vertices_begin(), polygon->vertices_end(), true); this->map.OnModelChanged(); } void InsertPolygonWithHolesConstraint(void* pwhPtr) { auto pwh = PolygonWithHoles2::CastToPolygonWithHoles2(pwhPtr); if (!pwh->is_unbounded()) this->model.insert_constraint(pwh->outer_boundary().vertices_begin(), pwh->outer_boundary().vertices_end(), true); for (auto& hole : pwh->holes()) this->model.insert_constraint(hole.vertices_begin(), hole.vertices_end(), true); this->map.OnModelChanged(); } void GetConstraints(TriEdge2* constraints, int count) { this->map.SetIndices(this->model); int i = 0; for (auto edge = this->model.constrained_edges_begin(); edge != this->model.constrained_edges_end(); ++edge) { if (!this->model.is_infinite(edge->first)) { constraints[i].FaceIndex = edge->first->info(); constraints[i].NeighbourIndex = edge->second; } else { auto neighbour = edge->first->neighbor(edge->second); auto n = neighbour->index(edge->first); if (!this->model.is_infinite(neighbour)) constraints[i].FaceIndex = neighbour->info(); else constraints[i].FaceIndex = NULL_INDEX; constraints[i].NeighbourIndex = n; } if (i++ >= count) return; } } void GetConstraints(Segment2d* constraints, int count) { this->map.SetIndices(this->model); int i = 0; for (auto edge = this->model.constrained_edges_begin(); edge != this->model.constrained_edges_end(); ++edge) { auto seg = this->model.segment(edge->first, edge->second); constraints[i] = Segment2d::FromCGAL(seg[0], seg[1]); if (i++ >= count) return; } } void GetIncidentConstraints(int vertexIndex, TriEdge2* constraints, int count) { int i = 0; auto vert = this->map.FindVertex(this->model, vertexIndex); if (vert != nullptr) { this->map.SetVertexIndices(this->model); this->map.SetFaceIndices(this->model); auto edge = (*vert)->incident_edges(), end(edge); if (edge != nullptr) { do { if (this->model.is_constrained(*edge)) { if (!this->model.is_infinite(edge->first)) { constraints[i].FaceIndex = edge->first->info(); constraints[i].NeighbourIndex = edge->second; } else { auto neighbour = edge->first->neighbor(edge->second); auto n = neighbour->index(edge->first); if (!this->model.is_infinite(neighbour)) constraints[i].FaceIndex = neighbour->info(); else constraints[i].FaceIndex = NULL_INDEX; constraints[i].NeighbourIndex = n; } if (i++ >= count) return; } } while (++edge != end); } } } void RemoveConstraint(int faceIndex, int neighbourIndex) { if (neighbourIndex < 0 || neighbourIndex > 2) return; auto face = this->map.FindFace(this->model, faceIndex); if (face != nullptr) { this->model.remove_constraint(*face, neighbourIndex); } } void RemoveIncidentConstraints(int vertexIndex) { auto vert = this->map.FindVertex(this->model, vertexIndex); if (vert != nullptr) { this->model.remove_incident_constraints(*vert); } } int MarkDomains(int* indices, int count) { this->map.SetVertexIndices(this->model); //Need each face to store its nesting level. //Use the faces info value and then reset after. this->map.ForceSetFaceIndices(this->model, 0); this->MarkDomains(this->model); int num = 0; int index = 0; for (Face face : this->model.finite_face_handles()) { if (face->info() % 2 == 1) { indices[index * 3 + 0] = face->vertex(0)->info(); indices[index * 3 + 1] = face->vertex(1)->info(); indices[index * 3 + 2] = face->vertex(2)->info(); index++; num++; } } //Restore faces index value. //Face indices may have changed so //increment buildd stamp as well. this->map.SetFaceIndices(this->model); this->map.IncrementBuildStamp(); return num * 3; } private: void MarkDomains(Triangulation_2& ct, Face start, int index, std::list& border) { if (start->info() != -1) return; std::list queue; queue.push_back(start); while (!queue.empty()) { Face fh = queue.front(); queue.pop_front(); if (fh->info() == -1) { fh->info() = index; for (int i = 0; i < 3; i++) { Edge e(fh, i); Face n = fh->neighbor(i); if (n->info() == -1) { if (ct.is_constrained(e)) border.push_back(e); else queue.push_back(n); } } } } } /// /// explore set of facets connected with non constrained edges, /// and attribute to each such set a nesting level. /// We start from facets incident to the infinite vertex, with a nesting /// level of 0. Then we recursively consider the non-explored facets incident /// to constrained edges bounding the former set and increase the nesting level by 1. /// Facets in the domain are those with an odd nesting level. /// /// void MarkDomains(Triangulation_2& cdt) { for (Face f : cdt.all_face_handles()) f->info() = -1; std::list border; MarkDomains(cdt, cdt.infinite_face(), 0, border); while (!border.empty()) { Edge e = border.front(); border.pop_front(); Face n = e.first->neighbor(e.second); if (n->info() == -1) { MarkDomains(cdt, n, e.first->info() + 1, border); } } } }; ================================================ FILE: CGALWrapper/Triangulations/ConstrainedTriangulation2_EEK.cpp ================================================ #pragma once #include "ConstrainedTriangulation2_EEK.h" #include "ConstrainedTriangulation2.h" #include "TriVertex2.h" #include "TriFace2.h" #include "TriEDge2.h" typedef typename EEK::Point_2 Point_2; typedef CGAL::No_constraint_intersection_tag Tag1; typedef CGAL::No_constraint_intersection_requiring_constructions_tag Tag2; typedef CGAL::Exact_predicates_tag Tag3; typedef CGAL::Exact_intersections_tag Tag4; typedef CGAL::Triangulation_vertex_base_with_info_2 Vb; typedef CGAL::Constrained_triangulation_face_base_2 CFb; typedef CGAL::Triangulation_face_base_with_info_2 Fb; typedef CGAL::Triangulation_data_structure_2 Tds; typedef CGAL::Constrained_triangulation_2 Triangulation_2; typedef typename Triangulation_2::Face_handle Face; typedef typename Triangulation_2::Vertex_handle Vertex; typedef typename Triangulation_2::Edge Edge; typedef ConstrainedTriangulation2 Tri2; void* ConstrainedTriangulation2_EEK_Create() { return Tri2::NewTriangulation2(); } void ConstrainedTriangulation2_EEK_Release(void* ptr) { Tri2::DeleteTriangulation2(ptr); } void ConstrainedTriangulation2_EEK_Clear(void* ptr) { auto tri = Tri2::CastToTriangulation2(ptr); tri->Clear(); } void* ConstrainedTriangulation2_EEK_Copy(void* ptr) { auto tri = Tri2::CastToTriangulation2(ptr); return tri->Copy(); } void* ConstrainedTriangulation2_EEK_Convert(void* ptr, CGAL_KERNEL k) { switch (k) { case CGAL_KERNEL::EXACT_PREDICATES_INEXACT_CONSTRUCTION: return Tri2::Convert(ptr); case CGAL_KERNEL::EXACT_PREDICATES_EXACT_CONSTRUCTION: return Tri2::Convert(ptr); default: return Tri2::Convert(ptr); } } void ConstrainedTriangulation2_EEK_SetIndices(void* ptr) { auto tri = Tri2::CastToTriangulation2(ptr); tri->SetIndices(); } int ConstrainedTriangulation2_EEK_BuildStamp(void* ptr) { auto tri = Tri2::CastToTriangulation2(ptr); return tri->BuildStamp(); } BOOL ConstrainedTriangulation2_EEK_IsValid(void* ptr, int level) { auto tri = Tri2::CastToTriangulation2(ptr); return tri->IsValid(level); } int ConstrainedTriangulation2_EEK_VertexCount(void* ptr) { auto tri = Tri2::CastToTriangulation2(ptr); return tri->VertexCount(); } int ConstrainedTriangulation2_EEK_FaceCount(void* ptr) { auto tri = Tri2::CastToTriangulation2(ptr); return tri->FaceCount(); } void ConstrainedTriangulation2_EEK_InsertPoint(void* ptr, Point2d point) { auto tri = Tri2::CastToTriangulation2(ptr); tri->InsertPoint(point); } void ConstrainedTriangulation2_EEK_InsertPoints(void* ptr, Point2d* points, int count) { auto tri = Tri2::CastToTriangulation2(ptr); tri->InsertPoints(points, count); } void ConstrainedTriangulation2_EEK_InsertPolygon(void* triPtr, void* polyPtr) { auto tri = Tri2::CastToTriangulation2(triPtr); tri->InsertPolygon(polyPtr); } void ConstrainedTriangulation2_EEK_InsertPolygonWithHoles(void* triPtr, void* pwhPtr) { auto tri = Tri2::CastToTriangulation2(triPtr); tri->InsertPolygonWithHoles(pwhPtr); } void ConstrainedTriangulation2_EEK_GetPoints(void* ptr, Point2d* points, int count) { auto tri = Tri2::CastToTriangulation2(ptr); tri->GetPoints(points, count); } void ConstrainedTriangulation2_EEK_GetIndices(void* ptr, int* indices, int count) { auto tri = Tri2::CastToTriangulation2(ptr); tri->GetIndices(indices, count); } BOOL ConstrainedTriangulation2_EEK_GetVertex(void* ptr, int index, TriVertex2& vertex) { auto tri = Tri2::CastToTriangulation2(ptr); return tri->GetVertex(index, vertex); } void ConstrainedTriangulation2_EEK_GetVertices(void* ptr, TriVertex2* vertices, int count) { auto tri = Tri2::CastToTriangulation2(ptr); tri->GetVertices(vertices, count); } bool ConstrainedTriangulation2_EEK_GetFace(void* ptr, int index, TriFace2& face) { auto tri = Tri2::CastToTriangulation2(ptr); return tri->GetFace(index, face); } void ConstrainedTriangulation2_EEK_GetFaces(void* ptr, TriFace2* faces, int count) { auto tri = Tri2::CastToTriangulation2(ptr); tri->GetFaces(faces, count); } BOOL ConstrainedTriangulation2_EEK_GetSegment(void* ptr, int faceIndex, int neighbourIndex, Segment2d& segment) { auto tri = Tri2::CastToTriangulation2(ptr); return tri->GetSegment(faceIndex, neighbourIndex, segment); } BOOL ConstrainedTriangulation2_EEK_GetTriangle(void* ptr, int faceIndex, Triangle2d& triangle) { auto tri = Tri2::CastToTriangulation2(ptr); return tri->GetTriangle(faceIndex, triangle); } void ConstrainedTriangulation2_EEK_GetTriangles(void* ptr, Triangle2d* triangles, int count) { auto tri = Tri2::CastToTriangulation2(ptr); tri->GetTriangles(triangles, count); } BOOL ConstrainedTriangulation2_EEK_GetCircumcenter(void* ptr, int faceIndex, Point2d& circumcenter) { auto tri = Tri2::CastToTriangulation2(ptr); return tri->GetCircumcenter(faceIndex, circumcenter); } void ConstrainedTriangulation2_EEK_GetCircumcenters(void* ptr, Point2d* circumcenters, int count) { auto tri = Tri2::CastToTriangulation2(ptr); tri->GetCircumcenters(circumcenters, count); } int ConstrainedTriangulation2_EEK_NeighbourIndex(void* ptr, int faceIndex, int index) { auto tri = Tri2::CastToTriangulation2(ptr); return tri->NeighbourIndex(faceIndex, index); } BOOL ConstrainedTriangulation2_EEK_LocateFace(void* ptr, Point2d point, TriFace2& face) { auto tri = Tri2::CastToTriangulation2(ptr); return tri->LocateFace(point, face); } BOOL ConstrainedTriangulation2_EEK_MoveVertex(void* ptr, int index, Point2d point, BOOL ifNoCollision, TriVertex2& vertex) { auto tri = Tri2::CastToTriangulation2(ptr); return tri->MoveVertex(index, point, ifNoCollision, vertex); } BOOL ConstrainedTriangulation2_EEK_RemoveVertex(void* ptr, int index) { auto tri = Tri2::CastToTriangulation2(ptr); return tri->RemoveVertex(index); } BOOL ConstrainedTriangulation2_EEK_FlipEdge(void* ptr, int faceIndex, int neighbour) { auto tri = Tri2::CastToTriangulation2(ptr); return tri->FlipEdge(faceIndex, neighbour); } void ConstrainedTriangulation2_EEK_Transform(void* ptr, Point2d translation, double rotation, double scale) { auto tri = Tri2::CastToTriangulation2(ptr); tri->Transform(translation, rotation, scale); } //Constrained only int ConstrainedTriangulation2_EEK_ConstrainedEdgesCount(void* ptr) { auto tri = Tri2::CastToTriangulation2(ptr); return tri->ConstrainedEdgesCount(); } BOOL ConstrainedTriangulation2_EEK_HasIncidentConstraints(void* ptr, int index) { auto tri = Tri2::CastToTriangulation2(ptr); return tri->HasIncidentConstraints(index); } int ConstrainedTriangulation2_EEK_IncidentConstraintCount(void* ptr, int index) { auto tri = Tri2::CastToTriangulation2(ptr); return tri->IncidentConstraintCount(index); } void ConstrainedTriangulation2_EEK_InsertSegmentConstraintFromPoints(void* ptr, Point2d a, Point2d b) { auto tri = Tri2::CastToTriangulation2(ptr); tri->InsertSegmentConstraint(a, b); } void ConstrainedTriangulation2_EEK_InsertSegmentConstraintFromVertices(void* ptr, int vertIndex1, int vertIndex2) { auto tri = Tri2::CastToTriangulation2(ptr); tri->InsertSegmentConstraint(vertIndex1, vertIndex2); } void ConstrainedTriangulation2_EEK_InsertSegmentConstraints(void* ptr, Segment2d* segments, int count) { auto tri = Tri2::CastToTriangulation2(ptr); tri->InsertSegmentConstraints(segments, count); } void ConstrainedTriangulation2_EEK_InsertPolygonConstraint(void* triPtr, void* polyPtr) { auto tri = Tri2::CastToTriangulation2(triPtr); tri->InsertPolygonConstraint(polyPtr); } void ConstrainedTriangulation2_EEK_InsertPolygonWithHolesConstraint(void* triPtr, void* pwhPtr) { auto tri = Tri2::CastToTriangulation2(triPtr); tri->InsertPolygonWithHolesConstraint(pwhPtr); } void ConstrainedTriangulation2_EEK_GetEdgeConstraints(void* ptr, TriEdge2* constraints, int count) { auto tri = Tri2::CastToTriangulation2(ptr); tri->GetConstraints(constraints, count); } void ConstrainedTriangulation2_EEK_GetSegmentConstraints(void* ptr, Segment2d* constraints, int count) { auto tri = Tri2::CastToTriangulation2(ptr); tri->GetConstraints(constraints, count); } void ConstrainedTriangulation2_EEK_GetIncidentConstraints(void* ptr, int vertexIndex, TriEdge2* constraints, int count) { auto tri = Tri2::CastToTriangulation2(ptr); tri->GetIncidentConstraints(vertexIndex, constraints, count); } void ConstrainedTriangulation2_EEK_RemoveConstraint(void* ptr, int faceIndex, int neighbourIndex) { auto tri = Tri2::CastToTriangulation2(ptr); tri->RemoveConstraint(faceIndex, neighbourIndex); } void ConstrainedTriangulation2_EEK_RemoveIncidentConstraints(void* ptr, int vertexIndex) { auto tri = Tri2::CastToTriangulation2(ptr); tri->RemoveIncidentConstraints(vertexIndex); } int ConstrainedTriangulation2_EEK_MarkDomains(void* ptr, int* indices, int count) { auto tri = Tri2::CastToTriangulation2(ptr); return tri->MarkDomains(indices, count); } ================================================ FILE: CGALWrapper/Triangulations/ConstrainedTriangulation2_EEK.h ================================================ #pragma once #include "../CGALWrapper.h" #include "../Geometry/Geometry2.h" #include "ConstrainedTriangulation2.h" extern "C" { CGALWRAPPER_API void* ConstrainedTriangulation2_EEK_Create(); CGALWRAPPER_API void ConstrainedTriangulation2_EEK_Release(void* ptr); CGALWRAPPER_API void ConstrainedTriangulation2_EEK_Clear(void* ptr); CGALWRAPPER_API void* ConstrainedTriangulation2_EEK_Copy(void* ptr); CGALWRAPPER_API void* ConstrainedTriangulation2_EEK_Convert(void* ptr, CGAL_KERNEL k); CGALWRAPPER_API void ConstrainedTriangulation2_EEK_SetIndices(void* ptr); CGALWRAPPER_API int ConstrainedTriangulation2_EEK_BuildStamp(void* ptr); CGALWRAPPER_API BOOL ConstrainedTriangulation2_EEK_IsValid(void* ptr, int level); CGALWRAPPER_API int ConstrainedTriangulation2_EEK_VertexCount(void* ptr); CGALWRAPPER_API int ConstrainedTriangulation2_EEK_FaceCount(void* ptr); CGALWRAPPER_API void ConstrainedTriangulation2_EEK_InsertPoint(void* ptr, Point2d point); CGALWRAPPER_API void ConstrainedTriangulation2_EEK_InsertPoints(void* ptr, Point2d* points, int count); CGALWRAPPER_API void ConstrainedTriangulation2_EEK_InsertPolygon(void* triPtr, void* polyPtr); CGALWRAPPER_API void ConstrainedTriangulation2_EEK_InsertPolygonWithHoles(void* triPtr, void* pwhPtr); CGALWRAPPER_API void ConstrainedTriangulation2_EEK_GetPoints(void* ptr, Point2d* points, int count); CGALWRAPPER_API void ConstrainedTriangulation2_EEK_GetIndices(void* ptr, int* indices, int count); CGALWRAPPER_API BOOL ConstrainedTriangulation2_EEK_GetVertex(void* ptr, int index, TriVertex2& vertex); CGALWRAPPER_API void ConstrainedTriangulation2_EEK_GetVertices(void* ptr, TriVertex2* vertices, int count); CGALWRAPPER_API bool ConstrainedTriangulation2_EEK_GetFace(void* ptr, int index, TriFace2& face); CGALWRAPPER_API void ConstrainedTriangulation2_EEK_GetFaces(void* ptr, TriFace2* faces, int count); CGALWRAPPER_API BOOL ConstrainedTriangulation2_EEK_GetSegment(void* ptr, int faceIndex, int neighbourIndex, Segment2d& segment); CGALWRAPPER_API BOOL ConstrainedTriangulation2_EEK_GetTriangle(void* ptr, int faceIndex, Triangle2d& triangle); CGALWRAPPER_API void ConstrainedTriangulation2_EEK_GetTriangles(void* ptr, Triangle2d* triangles, int count); CGALWRAPPER_API BOOL ConstrainedTriangulation2_EEK_GetCircumcenter(void* ptr, int faceIndex, Point2d& circumcenter); CGALWRAPPER_API void ConstrainedTriangulation2_EEK_GetCircumcenters(void* ptr, Point2d* circumcenters, int count); CGALWRAPPER_API int ConstrainedTriangulation2_EEK_NeighbourIndex(void* ptr, int faceIndex, int index); CGALWRAPPER_API BOOL ConstrainedTriangulation2_EEK_LocateFace(void* ptr, Point2d point, TriFace2& face); CGALWRAPPER_API BOOL ConstrainedTriangulation2_EEK_MoveVertex(void* ptr, int index, Point2d point, BOOL ifNoCollision, TriVertex2& vertex); CGALWRAPPER_API BOOL ConstrainedTriangulation2_EEK_RemoveVertex(void* ptr, int index); CGALWRAPPER_API BOOL ConstrainedTriangulation2_EEK_FlipEdge(void* ptr, int faceIndex, int neighbour); CGALWRAPPER_API void ConstrainedTriangulation2_EEK_Transform(void* ptr, Point2d translation, double rotation, double scale); //Constrained only CGALWRAPPER_API int ConstrainedTriangulation2_EEK_ConstrainedEdgesCount(void* ptr); CGALWRAPPER_API BOOL ConstrainedTriangulation2_EEK_HasIncidentConstraints(void* ptr, int index); CGALWRAPPER_API int ConstrainedTriangulation2_EEK_IncidentConstraintCount(void* ptr, int index); CGALWRAPPER_API void ConstrainedTriangulation2_EEK_InsertSegmentConstraintFromPoints(void* ptr, Point2d a, Point2d b); CGALWRAPPER_API void ConstrainedTriangulation2_EEK_InsertSegmentConstraintFromVertices(void* ptr, int vertIndex1, int vertIndex2); CGALWRAPPER_API void ConstrainedTriangulation2_EEK_InsertSegmentConstraints(void* ptr, Segment2d* segments, int count); CGALWRAPPER_API void ConstrainedTriangulation2_EEK_InsertPolygonConstraint(void* triPtr, void* polyPtr); CGALWRAPPER_API void ConstrainedTriangulation2_EEK_InsertPolygonWithHolesConstraint(void* triPtr, void* pwhPtr); CGALWRAPPER_API void ConstrainedTriangulation2_EEK_GetEdgeConstraints(void* ptr, TriEdge2* constraints, int count); CGALWRAPPER_API void ConstrainedTriangulation2_EEK_GetSegmentConstraints(void* ptr, Segment2d* constraints, int count); CGALWRAPPER_API void ConstrainedTriangulation2_EEK_GetIncidentConstraints(void* ptr, int vertexIndex, TriEdge2* constraints, int count); CGALWRAPPER_API void ConstrainedTriangulation2_EEK_RemoveConstraint(void* ptr, int faceIndex, int neighbourIndex); CGALWRAPPER_API void ConstrainedTriangulation2_EEK_RemoveIncidentConstraints(void* ptr, int vertexIndex); CGALWRAPPER_API int ConstrainedTriangulation2_EEK_MarkDomains(void* ptr, int* indices, int count); } ================================================ FILE: CGALWrapper/Triangulations/ConstrainedTriangulation2_EIK.cpp ================================================ #pragma once #include "ConstrainedTriangulation2_EIK.h" #include "ConstrainedTriangulation2.h" #include "TriVertex2.h" #include "TriFace2.h" #include "TriEDge2.h" typedef typename EIK::Point_2 Point_2; typedef CGAL::No_constraint_intersection_tag Tag1; typedef CGAL::No_constraint_intersection_requiring_constructions_tag Tag2; typedef CGAL::Exact_predicates_tag Tag3; typedef CGAL::Exact_intersections_tag Tag4; typedef CGAL::Triangulation_vertex_base_with_info_2 Vb; typedef CGAL::Constrained_triangulation_face_base_2 CFb; typedef CGAL::Triangulation_face_base_with_info_2 Fb; typedef CGAL::Triangulation_data_structure_2 Tds; typedef CGAL::Constrained_triangulation_2 Triangulation_2; typedef typename Triangulation_2::Face_handle Face; typedef typename Triangulation_2::Vertex_handle Vertex; typedef typename Triangulation_2::Edge Edge; typedef ConstrainedTriangulation2 Tri2; void* ConstrainedTriangulation2_EIK_Create() { return Tri2::NewTriangulation2(); } void ConstrainedTriangulation2_EIK_Release(void* ptr) { Tri2::DeleteTriangulation2(ptr); } void ConstrainedTriangulation2_EIK_Clear(void* ptr) { auto tri = Tri2::CastToTriangulation2(ptr); tri->Clear(); } void* ConstrainedTriangulation2_EIK_Copy(void* ptr) { auto tri = Tri2::CastToTriangulation2(ptr); return tri->Copy(); } void* ConstrainedTriangulation2_EIK_Convert(void* ptr, CGAL_KERNEL k) { switch (k) { case CGAL_KERNEL::EXACT_PREDICATES_INEXACT_CONSTRUCTION: return Tri2::Convert(ptr); case CGAL_KERNEL::EXACT_PREDICATES_EXACT_CONSTRUCTION: return Tri2::Convert(ptr); default: return Tri2::Convert(ptr); } } void ConstrainedTriangulation2_EIK_SetIndices(void* ptr) { auto tri = Tri2::CastToTriangulation2(ptr); tri->SetIndices(); } int ConstrainedTriangulation2_EIK_BuildStamp(void* ptr) { auto tri = Tri2::CastToTriangulation2(ptr); return tri->BuildStamp(); } BOOL ConstrainedTriangulation2_EIK_IsValid(void* ptr, int level) { auto tri = Tri2::CastToTriangulation2(ptr); return tri->IsValid(level); } int ConstrainedTriangulation2_EIK_VertexCount(void* ptr) { auto tri = Tri2::CastToTriangulation2(ptr); return tri->VertexCount(); } int ConstrainedTriangulation2_EIK_FaceCount(void* ptr) { auto tri = Tri2::CastToTriangulation2(ptr); return tri->FaceCount(); } void ConstrainedTriangulation2_EIK_InsertPoint(void* ptr, Point2d point) { auto tri = Tri2::CastToTriangulation2(ptr); tri->InsertPoint(point); } void ConstrainedTriangulation2_EIK_InsertPoints(void* ptr, Point2d* points, int count) { auto tri = Tri2::CastToTriangulation2(ptr); tri->InsertPoints(points, count); } void ConstrainedTriangulation2_EIK_InsertPolygon(void* triPtr, void* polyPtr) { auto tri = Tri2::CastToTriangulation2(triPtr); tri->InsertPolygon(polyPtr); } void ConstrainedTriangulation2_EIK_InsertPolygonWithHoles(void* triPtr, void* pwhPtr) { auto tri = Tri2::CastToTriangulation2(triPtr); tri->InsertPolygonWithHoles(pwhPtr); } void ConstrainedTriangulation2_EIK_GetPoints(void* ptr, Point2d* points, int count) { auto tri = Tri2::CastToTriangulation2(ptr); tri->GetPoints(points, count); } void ConstrainedTriangulation2_EIK_GetIndices(void* ptr, int* indices, int count) { auto tri = Tri2::CastToTriangulation2(ptr); tri->GetIndices(indices, count); } BOOL ConstrainedTriangulation2_EIK_GetVertex(void* ptr, int index, TriVertex2& vertex) { auto tri = Tri2::CastToTriangulation2(ptr); return tri->GetVertex(index, vertex); } void ConstrainedTriangulation2_EIK_GetVertices(void* ptr, TriVertex2* vertices, int count) { auto tri = Tri2::CastToTriangulation2(ptr); tri->GetVertices(vertices, count); } bool ConstrainedTriangulation2_EIK_GetFace(void* ptr, int index, TriFace2& face) { auto tri = Tri2::CastToTriangulation2(ptr); return tri->GetFace(index, face); } void ConstrainedTriangulation2_EIK_GetFaces(void* ptr, TriFace2* faces, int count) { auto tri = Tri2::CastToTriangulation2(ptr); tri->GetFaces(faces, count); } BOOL ConstrainedTriangulation2_EIK_GetSegment(void* ptr, int faceIndex, int neighbourIndex, Segment2d& segment) { auto tri = Tri2::CastToTriangulation2(ptr); return tri->GetSegment(faceIndex, neighbourIndex, segment); } BOOL ConstrainedTriangulation2_EIK_GetTriangle(void* ptr, int faceIndex, Triangle2d& triangle) { auto tri = Tri2::CastToTriangulation2(ptr); return tri->GetTriangle(faceIndex, triangle); } void ConstrainedTriangulation2_EIK_GetTriangles(void* ptr, Triangle2d* triangles, int count) { auto tri = Tri2::CastToTriangulation2(ptr); tri->GetTriangles(triangles, count); } BOOL ConstrainedTriangulation2_EIK_GetCircumcenter(void* ptr, int faceIndex, Point2d& circumcenter) { auto tri = Tri2::CastToTriangulation2(ptr); return tri->GetCircumcenter(faceIndex, circumcenter); } void ConstrainedTriangulation2_EIK_GetCircumcenters(void* ptr, Point2d* circumcenters, int count) { auto tri = Tri2::CastToTriangulation2(ptr); tri->GetCircumcenters(circumcenters, count); } int ConstrainedTriangulation2_EIK_NeighbourIndex(void* ptr, int faceIndex, int index) { auto tri = Tri2::CastToTriangulation2(ptr); return tri->NeighbourIndex(faceIndex, index); } BOOL ConstrainedTriangulation2_EIK_LocateFace(void* ptr, Point2d point, TriFace2& face) { auto tri = Tri2::CastToTriangulation2(ptr); return tri->LocateFace(point, face); } BOOL ConstrainedTriangulation2_EIK_MoveVertex(void* ptr, int index, Point2d point, BOOL ifNoCollision, TriVertex2& vertex) { auto tri = Tri2::CastToTriangulation2(ptr); return tri->MoveVertex(index, point, ifNoCollision, vertex); } BOOL ConstrainedTriangulation2_EIK_RemoveVertex(void* ptr, int index) { auto tri = Tri2::CastToTriangulation2(ptr); return tri->RemoveVertex(index); } BOOL ConstrainedTriangulation2_EIK_FlipEdge(void* ptr, int faceIndex, int neighbour) { auto tri = Tri2::CastToTriangulation2(ptr); return tri->FlipEdge(faceIndex, neighbour); } void ConstrainedTriangulation2_EIK_Transform(void* ptr, Point2d translation, double rotation, double scale) { auto tri = Tri2::CastToTriangulation2(ptr); tri->Transform(translation, rotation, scale); } //Constrained only int ConstrainedTriangulation2_EIK_ConstrainedEdgesCount(void* ptr) { auto tri = Tri2::CastToTriangulation2(ptr); return tri->ConstrainedEdgesCount(); } BOOL ConstrainedTriangulation2_EIK_HasIncidentConstraints(void* ptr, int index) { auto tri = Tri2::CastToTriangulation2(ptr); return tri->HasIncidentConstraints(index); } int ConstrainedTriangulation2_EIK_IncidentConstraintCount(void* ptr, int index) { auto tri = Tri2::CastToTriangulation2(ptr); return tri->IncidentConstraintCount(index); } void ConstrainedTriangulation2_EIK_InsertSegmentConstraintFromPoints(void* ptr, Point2d a, Point2d b) { auto tri = Tri2::CastToTriangulation2(ptr); tri->InsertSegmentConstraint(a, b); } void ConstrainedTriangulation2_EIK_InsertSegmentConstraintFromVertices(void* ptr, int vertIndex1, int vertIndex2) { auto tri = Tri2::CastToTriangulation2(ptr); tri->InsertSegmentConstraint(vertIndex1, vertIndex2); } void ConstrainedTriangulation2_EIK_InsertSegmentConstraints(void* ptr, Segment2d* segments, int count) { auto tri = Tri2::CastToTriangulation2(ptr); tri->InsertSegmentConstraints(segments, count); } void ConstrainedTriangulation2_EIK_InsertPolygonConstraint(void* triPtr, void* polyPtr) { auto tri = Tri2::CastToTriangulation2(triPtr); tri->InsertPolygonConstraint(polyPtr); } void ConstrainedTriangulation2_EIK_InsertPolygonWithHolesConstraint(void* triPtr, void* pwhPtr) { auto tri = Tri2::CastToTriangulation2(triPtr); tri->InsertPolygonWithHolesConstraint(pwhPtr); } void ConstrainedTriangulation2_EIK_GetEdgeConstraints(void* ptr, TriEdge2* constraints, int count) { auto tri = Tri2::CastToTriangulation2(ptr); tri->GetConstraints(constraints, count); } void ConstrainedTriangulation2_EIK_GetSegmentConstraints(void* ptr, Segment2d* constraints, int count) { auto tri = Tri2::CastToTriangulation2(ptr); tri->GetConstraints(constraints, count); } void ConstrainedTriangulation2_EIK_GetIncidentConstraints(void* ptr, int vertexIndex, TriEdge2* constraints, int count) { auto tri = Tri2::CastToTriangulation2(ptr); tri->GetIncidentConstraints(vertexIndex, constraints, count); } void ConstrainedTriangulation2_EIK_RemoveConstraint(void* ptr, int faceIndex, int neighbourIndex) { auto tri = Tri2::CastToTriangulation2(ptr); tri->RemoveConstraint(faceIndex, neighbourIndex); } void ConstrainedTriangulation2_EIK_RemoveIncidentConstraints(void* ptr, int vertexIndex) { auto tri = Tri2::CastToTriangulation2(ptr); tri->RemoveIncidentConstraints(vertexIndex); } int ConstrainedTriangulation2_EIK_MarkDomains(void* ptr, int* indices, int count) { auto tri = Tri2::CastToTriangulation2(ptr); return tri->MarkDomains(indices, count); } ================================================ FILE: CGALWrapper/Triangulations/ConstrainedTriangulation2_EIK.h ================================================ #pragma once #include "../CGALWrapper.h" #include "../Geometry/Geometry2.h" #include "ConstrainedTriangulation2.h" extern "C" { CGALWRAPPER_API void* ConstrainedTriangulation2_EIK_Create(); CGALWRAPPER_API void ConstrainedTriangulation2_EIK_Release(void* ptr); CGALWRAPPER_API void ConstrainedTriangulation2_EIK_Clear(void* ptr); CGALWRAPPER_API void* ConstrainedTriangulation2_EIK_Copy(void* ptr); CGALWRAPPER_API void* ConstrainedTriangulation2_EIK_Convert(void* ptr, CGAL_KERNEL k); CGALWRAPPER_API void ConstrainedTriangulation2_EIK_SetIndices(void* ptr); CGALWRAPPER_API int ConstrainedTriangulation2_EIK_BuildStamp(void* ptr); CGALWRAPPER_API BOOL ConstrainedTriangulation2_EIK_IsValid(void* ptr, int level); CGALWRAPPER_API int ConstrainedTriangulation2_EIK_VertexCount(void* ptr); CGALWRAPPER_API int ConstrainedTriangulation2_EIK_FaceCount(void* ptr); CGALWRAPPER_API void ConstrainedTriangulation2_EIK_InsertPoint(void* ptr, Point2d point); CGALWRAPPER_API void ConstrainedTriangulation2_EIK_InsertPoints(void* ptr, Point2d* points, int count); CGALWRAPPER_API void ConstrainedTriangulation2_EIK_InsertPolygon(void* triPtr, void* polyPtr); CGALWRAPPER_API void ConstrainedTriangulation2_EIK_InsertPolygonWithHoles(void* triPtr, void* pwhPtr); CGALWRAPPER_API void ConstrainedTriangulation2_EIK_GetPoints(void* ptr, Point2d* points, int count); CGALWRAPPER_API void ConstrainedTriangulation2_EIK_GetIndices(void* ptr, int* indices, int count); CGALWRAPPER_API BOOL ConstrainedTriangulation2_EIK_GetVertex(void* ptr, int index, TriVertex2& vertex); CGALWRAPPER_API void ConstrainedTriangulation2_EIK_GetVertices(void* ptr, TriVertex2* vertices, int count); CGALWRAPPER_API bool ConstrainedTriangulation2_EIK_GetFace(void* ptr, int index, TriFace2& face); CGALWRAPPER_API void ConstrainedTriangulation2_EIK_GetFaces(void* ptr, TriFace2* faces, int count); CGALWRAPPER_API BOOL ConstrainedTriangulation2_EIK_GetSegment(void* ptr, int faceIndex, int neighbourIndex, Segment2d& segment); CGALWRAPPER_API BOOL ConstrainedTriangulation2_EIK_GetTriangle(void* ptr, int faceIndex, Triangle2d& triangle); CGALWRAPPER_API void ConstrainedTriangulation2_EIK_GetTriangles(void* ptr, Triangle2d* triangles, int count); CGALWRAPPER_API BOOL ConstrainedTriangulation2_EIK_GetCircumcenter(void* ptr, int faceIndex, Point2d& circumcenter); CGALWRAPPER_API void ConstrainedTriangulation2_EIK_GetCircumcenters(void* ptr, Point2d* circumcenters, int count); CGALWRAPPER_API int ConstrainedTriangulation2_EIK_NeighbourIndex(void* ptr, int faceIndex, int index); CGALWRAPPER_API BOOL ConstrainedTriangulation2_EIK_LocateFace(void* ptr, Point2d point, TriFace2& face); CGALWRAPPER_API BOOL ConstrainedTriangulation2_EIK_MoveVertex(void* ptr, int index, Point2d point, BOOL ifNoCollision, TriVertex2& vertex); CGALWRAPPER_API BOOL ConstrainedTriangulation2_EIK_RemoveVertex(void* ptr, int index); CGALWRAPPER_API BOOL ConstrainedTriangulation2_EIK_FlipEdge(void* ptr, int faceIndex, int neighbour); CGALWRAPPER_API void ConstrainedTriangulation2_EIK_Transform(void* ptr, Point2d translation, double rotation, double scale); //Constrained only CGALWRAPPER_API int ConstrainedTriangulation2_EIK_ConstrainedEdgesCount(void* ptr); CGALWRAPPER_API BOOL ConstrainedTriangulation2_EIK_HasIncidentConstraints(void* ptr, int index); CGALWRAPPER_API int ConstrainedTriangulation2_EIK_IncidentConstraintCount(void* ptr, int index); CGALWRAPPER_API void ConstrainedTriangulation2_EIK_InsertSegmentConstraintFromPoints(void* ptr, Point2d a, Point2d b); CGALWRAPPER_API void ConstrainedTriangulation2_EIK_InsertSegmentConstraintFromVertices(void* ptr, int vertIndex1, int vertIndex2); CGALWRAPPER_API void ConstrainedTriangulation2_EIK_InsertSegmentConstraints(void* ptr, Segment2d* segments, int count); CGALWRAPPER_API void ConstrainedTriangulation2_EIK_InsertPolygonConstraint(void* triPtr, void* polyPtr); CGALWRAPPER_API void ConstrainedTriangulation2_EIK_InsertPolygonWithHolesConstraint(void* triPtr, void* pwhPtr); CGALWRAPPER_API void ConstrainedTriangulation2_EIK_GetEdgeConstraints(void* ptr, TriEdge2* constraints, int count); CGALWRAPPER_API void ConstrainedTriangulation2_EIK_GetSegmentConstraints(void* ptr, Segment2d* constraints, int count); CGALWRAPPER_API void ConstrainedTriangulation2_EIK_GetIncidentConstraints(void* ptr, int vertexIndex, TriEdge2* constraints, int count); CGALWRAPPER_API void ConstrainedTriangulation2_EIK_RemoveConstraint(void* ptr, int faceIndex, int neighbourIndex); CGALWRAPPER_API void ConstrainedTriangulation2_EIK_RemoveIncidentConstraints(void* ptr, int vertexIndex); CGALWRAPPER_API int ConstrainedTriangulation2_EIK_MarkDomains(void* ptr, int* indices, int count); } ================================================ FILE: CGALWrapper/Triangulations/DelaunayTriangulation2.h ================================================ #pragma once #include "../CGALWrapper.h" #include "../Geometry/Geometry2.h" #include "../Polygons/Polygon2.h" #include "../Polygons/PolygonWithHoles2.h" #include "TriUtil.h" #include "TriVertex2.h" #include "TriFace2.h" #include "TriangulationMap2.h" #include "BaseTriangulation2.h" #include #include "CGAL/Point_2.h" #include #include #include #include #include template class DelaunayTriangulation2 : public BaseTriangulation2 { public: typedef typename K::Point_2 Point_2; typedef CGAL::Triangulation_vertex_base_with_info_2 Vb; typedef CGAL::Triangulation_face_base_with_info_2 Fb; typedef CGAL::Triangulation_data_structure_2 Tds; typedef CGAL::Delaunay_triangulation_2 Triangulation_2; typedef typename Triangulation_2::Face_handle Face; typedef typename Triangulation_2::Vertex_handle Vertex; private: public: inline static DelaunayTriangulation2* NewTriangulation2() { return new DelaunayTriangulation2(); } inline static void DeleteTriangulation2(void* ptr) { auto obj = static_cast(ptr); if (obj != nullptr) { delete obj; obj = nullptr; } } inline static DelaunayTriangulation2* CastToTriangulation2(void* ptr) { return static_cast(ptr); } void* Copy() { auto copy = NewTriangulation2(); copy->model = this->model; return copy; } template static void* Convert(void* ptr) { typedef CGAL::Cartesian_converter Converter; Converter convert; auto tri = NewTriangulation2(); auto tri2 = new DelaunayTriangulation2(); for (const auto& vert : tri->model.finite_vertex_handles()) { auto p = convert(vert->point()); //tri2->model.insert(p); } return tri2; } //Delauny only void VoronoiCount(int& numSegments, int& numRays) { numSegments = 0; numRays = 0; for (auto eit = this->model.edges_begin(); eit != this->model.edges_end(); ++eit) { CGAL::Object o = this->model.dual(eit); if (CGAL::object_cast(&o)) numSegments++; else if (CGAL::object_cast(&o)) numRays++; } } int VoronoiSegmentCount() { int count = 0; for (auto eit = this->model.edges_begin(); eit != this->model.edges_end(); ++eit) { CGAL::Object o = this->model.dual(eit); if (CGAL::object_cast(&o)) ++count; } return count; } int VoronoiRayCount() { int count = 0; for (auto eit = this->model.edges_begin(); eit != this->model.edges_end(); ++eit) { CGAL::Object o = this->model.dual(eit); if (CGAL::object_cast(&o)) ++count; } return count; } void GetVoronoiSegments(Segment2d* segments, int count) { int i = 0; for (auto eit = this->model.edges_begin(); eit != this->model.edges_end(); ++eit) { if (i >= count) return; CGAL::Object o = this->model.dual(eit); if (auto seg = CGAL::object_cast(&o)) segments[i++] = Segment2d::FromCGAL(seg->source(), seg->target()); } } void GetVoronoiRays(Ray2d* rays, int count) { int i = 0; for (auto eit = this->model.edges_begin(); eit != this->model.edges_end(); ++eit) { if (i >= count) return; CGAL::Object o = this->model.dual(eit); if (auto ray = CGAL::object_cast(&o)) rays[i++] = Ray2d::FromCGAL(ray->source(), ray->to_vector()); } } }; ================================================ FILE: CGALWrapper/Triangulations/DelaunayTriangulation2_EEK.cpp ================================================ #pragma once #include "DelaunayTriangulation2_EEK.h" #include "DelaunayTriangulation2.h" typedef CGAL::Triangulation_vertex_base_with_info_2 Vb; typedef CGAL::Triangulation_face_base_with_info_2 Fb; typedef CGAL::Triangulation_data_structure_2 Tds; typedef CGAL::Delaunay_triangulation_2 Triangulation_2; typedef typename Triangulation_2::Face_handle Face; typedef typename Triangulation_2::Vertex_handle Vertex; typedef DelaunayTriangulation2 Tri2; void* DelaunayTriangulation2_EEK_Create() { return Tri2::NewTriangulation2(); } void DelaunayTriangulation2_EEK_Release(void* ptr) { Tri2::DeleteTriangulation2(ptr); } void DelaunayTriangulation2_EEK_Clear(void* ptr) { auto tri = Tri2::CastToTriangulation2(ptr); tri->Clear(); } void* DelaunayTriangulation2_EEK_Copy(void* ptr) { auto tri = Tri2::CastToTriangulation2(ptr); return tri->Copy(); } void* DelaunayTriangulation2_EEK_Convert(void* ptr, CGAL_KERNEL k) { switch (k) { case CGAL_KERNEL::EXACT_PREDICATES_INEXACT_CONSTRUCTION: return Tri2::Convert(ptr); case CGAL_KERNEL::EXACT_PREDICATES_EXACT_CONSTRUCTION: return Tri2::Convert(ptr); default: return Tri2::Convert(ptr); } } void DelaunayTriangulation2_EEK_SetIndices(void* ptr) { auto tri = Tri2::CastToTriangulation2(ptr); tri->SetIndices(); } int DelaunayTriangulation2_EEK_BuildStamp(void* ptr) { auto tri = Tri2::CastToTriangulation2(ptr); return tri->BuildStamp(); } BOOL DelaunayTriangulation2_EEK_IsValid(void* ptr, int level) { auto tri = Tri2::CastToTriangulation2(ptr); return tri->IsValid(level); } int DelaunayTriangulation2_EEK_VertexCount(void* ptr) { auto tri = Tri2::CastToTriangulation2(ptr); return tri->VertexCount(); } int DelaunayTriangulation2_EEK_FaceCount(void* ptr) { auto tri = Tri2::CastToTriangulation2(ptr); return tri->FaceCount(); } void DelaunayTriangulation2_EEK_InsertPoint(void* ptr, Point2d point) { auto tri = Tri2::CastToTriangulation2(ptr); tri->InsertPoint(point); } void DelaunayTriangulation2_EEK_InsertPoints(void* ptr, Point2d* points, int count) { auto tri = Tri2::CastToTriangulation2(ptr); tri->InsertPoints(points, count); } void DelaunayTriangulation2_EEK_InsertPolygon(void* triPtr, void* polyPtr) { auto tri = Tri2::CastToTriangulation2(triPtr); tri->InsertPolygon(polyPtr); } void DelaunayTriangulation2_EEK_InsertPolygonWithHoles(void* triPtr, void* pwhPtr) { auto tri = Tri2::CastToTriangulation2(triPtr); tri->InsertPolygonWithHoles(pwhPtr); } void DelaunayTriangulation2_EEK_GetPoints(void* ptr, Point2d* points, int count) { auto tri = Tri2::CastToTriangulation2(ptr); tri->GetPoints(points, count); } void DelaunayTriangulation2_EEK_GetIndices(void* ptr, int* indices, int count) { auto tri = Tri2::CastToTriangulation2(ptr); tri->GetIndices(indices, count); } BOOL DelaunayTriangulation2_EEK_GetVertex(void* ptr, int index, TriVertex2& vertex) { auto tri = Tri2::CastToTriangulation2(ptr); return tri->GetVertex(index, vertex); } void DelaunayTriangulation2_EEK_GetVertices(void* ptr, TriVertex2* vertices, int count) { auto tri = Tri2::CastToTriangulation2(ptr); tri->GetVertices(vertices, count); } bool DelaunayTriangulation2_EEK_GetFace(void* ptr, int index, TriFace2& face) { auto tri = Tri2::CastToTriangulation2(ptr); return tri->GetFace(index, face); } void DelaunayTriangulation2_EEK_GetFaces(void* ptr, TriFace2* faces, int count) { auto tri = Tri2::CastToTriangulation2(ptr); tri->GetFaces(faces, count); } BOOL DelaunayTriangulation2_EEK_GetSegment(void* ptr, int faceIndex, int neighbourIndex, Segment2d& segment) { auto tri = Tri2::CastToTriangulation2(ptr); return tri->GetSegment(faceIndex, neighbourIndex, segment); } BOOL DelaunayTriangulation2_EEK_GetTriangle(void* ptr, int faceIndex, Triangle2d& triangle) { auto tri = Tri2::CastToTriangulation2(ptr); return tri->GetTriangle(faceIndex, triangle); } void DelaunayTriangulation2_EEK_GetTriangles(void* ptr, Triangle2d* triangles, int count) { auto tri = Tri2::CastToTriangulation2(ptr); tri->GetTriangles(triangles, count); } BOOL DelaunayTriangulation2_EEK_GetCircumcenter(void* ptr, int faceIndex, Point2d& circumcenter) { auto tri = Tri2::CastToTriangulation2(ptr); return tri->GetCircumcenter(faceIndex, circumcenter); } void DelaunayTriangulation2_EEK_GetCircumcenters(void* ptr, Point2d* circumcenters, int count) { auto tri = Tri2::CastToTriangulation2(ptr); tri->GetCircumcenters(circumcenters, count); } int DelaunayTriangulation2_EEK_NeighbourIndex(void* ptr, int faceIndex, int index) { auto tri = Tri2::CastToTriangulation2(ptr); return tri->NeighbourIndex(faceIndex, index); } BOOL DelaunayTriangulation2_EEK_LocateFace(void* ptr, Point2d point, TriFace2& face) { auto tri = Tri2::CastToTriangulation2(ptr); return tri->LocateFace(point, face); } BOOL DelaunayTriangulation2_EEK_MoveVertex(void* ptr, int index, Point2d point, BOOL ifNoCollision, TriVertex2& vertex) { auto tri = Tri2::CastToTriangulation2(ptr); return tri->MoveVertex(index, point, ifNoCollision, vertex); } BOOL DelaunayTriangulation2_EEK_RemoveVertex(void* ptr, int index) { auto tri = Tri2::CastToTriangulation2(ptr); return tri->RemoveVertex(index); } BOOL DelaunayTriangulation2_EEK_FlipEdge(void* ptr, int faceIndex, int neighbour) { auto tri = Tri2::CastToTriangulation2(ptr); return tri->FlipEdge(faceIndex, neighbour); } void DelaunayTriangulation2_EEK_Transform(void* ptr, Point2d translation, double rotation, double scale) { auto tri = Tri2::CastToTriangulation2(ptr); tri->Transform(translation, rotation, scale); } //Delaunay only int DelaunayTriangulation2_EEK_VoronoiSegmentCount(void* ptr) { auto tri = Tri2::CastToTriangulation2(ptr); return tri->VoronoiSegmentCount(); } int DelaunayTriangulation2_EEK_VoronoiRayCount(void* ptr) { auto tri = Tri2::CastToTriangulation2(ptr); return tri->VoronoiRayCount(); } void DelaunayTriangulation2_EEK_VoronoiCount(void* ptr, int& numSegments, int& numRays) { auto tri = Tri2::CastToTriangulation2(ptr); tri->VoronoiCount(numSegments, numRays); } void DelaunayTriangulation2_EEK_GetVoronoiSegments(void* ptr, Segment2d* segments, int count) { auto tri = Tri2::CastToTriangulation2(ptr); tri->GetVoronoiSegments(segments, count); } void DelaunayTriangulation2_EEK_GetVoronoiRays(void* ptr, Ray2d* rays, int count) { auto tri = Tri2::CastToTriangulation2(ptr); tri->GetVoronoiRays(rays, count); } ================================================ FILE: CGALWrapper/Triangulations/DelaunayTriangulation2_EEK.h ================================================ #pragma once #include "../CGALWrapper.h" #include "../Geometry/Geometry2.h" #include "DelaunayTriangulation2.h" extern "C" { CGALWRAPPER_API void* DelaunayTriangulation2_EEK_Create(); CGALWRAPPER_API void DelaunayTriangulation2_EEK_Release(void* ptr); CGALWRAPPER_API void DelaunayTriangulation2_EEK_Clear(void* ptr); CGALWRAPPER_API void DelaunayTriangulation2_EEK_Clear(void* ptr); CGALWRAPPER_API void* DelaunayTriangulation2_EEK_Copy(void* ptr); CGALWRAPPER_API void* DelaunayTriangulation2_EEK_Convert(void* ptr, CGAL_KERNEL k); CGALWRAPPER_API void DelaunayTriangulation2_EEK_SetIndices(void* ptr); CGALWRAPPER_API int DelaunayTriangulation2_EEK_BuildStamp(void* ptr); CGALWRAPPER_API BOOL DelaunayTriangulation2_EEK_IsValid(void* ptr, int level); CGALWRAPPER_API int DelaunayTriangulation2_EEK_VertexCount(void* ptr); CGALWRAPPER_API int DelaunayTriangulation2_EEK_FaceCount(void* ptr); CGALWRAPPER_API void DelaunayTriangulation2_EEK_InsertPoint(void* ptr, Point2d point); CGALWRAPPER_API void DelaunayTriangulation2_EEK_InsertPoints(void* ptr, Point2d* points, int count); CGALWRAPPER_API void DelaunayTriangulation2_EEK_InsertPolygon(void* triPtr, void* polyPtr); CGALWRAPPER_API void DelaunayTriangulation2_EEK_InsertPolygonWithHoles(void* triPtr, void* pwhPtr); CGALWRAPPER_API void DelaunayTriangulation2_EEK_GetPoints(void* ptr, Point2d* points, int count); CGALWRAPPER_API void DelaunayTriangulation2_EEK_GetIndices(void* ptr, int* indices, int count); CGALWRAPPER_API BOOL DelaunayTriangulation2_EEK_GetVertex(void* ptr, int index, TriVertex2& vertex); CGALWRAPPER_API void DelaunayTriangulation2_EEK_GetVertices(void* ptr, TriVertex2* vertices, int count); CGALWRAPPER_API bool DelaunayTriangulation2_EEK_GetFace(void* ptr, int index, TriFace2& face); CGALWRAPPER_API void DelaunayTriangulation2_EEK_GetFaces(void* ptr, TriFace2* faces, int count); CGALWRAPPER_API BOOL DelaunayTriangulation2_EEK_GetSegment(void* ptr, int faceIndex, int neighbourIndex, Segment2d& segment); CGALWRAPPER_API BOOL DelaunayTriangulation2_EEK_GetTriangle(void* ptr, int faceIndex, Triangle2d& triangle); CGALWRAPPER_API void DelaunayTriangulation2_EEK_GetTriangles(void* ptr, Triangle2d* triangles, int count); CGALWRAPPER_API BOOL DelaunayTriangulation2_EEK_GetCircumcenter(void* ptr, int faceIndex, Point2d& circumcenter); CGALWRAPPER_API void DelaunayTriangulation2_EEK_GetCircumcenters(void* ptr, Point2d* circumcenters, int count); CGALWRAPPER_API int DelaunayTriangulation2_EEK_NeighbourIndex(void* ptr, int faceIndex, int index); CGALWRAPPER_API BOOL DelaunayTriangulation2_EEK_LocateFace(void* ptr, Point2d point, TriFace2& face); CGALWRAPPER_API BOOL DelaunayTriangulation2_EEK_MoveVertex(void* ptr, int index, Point2d point, BOOL ifNoCollision, TriVertex2& vertex); CGALWRAPPER_API BOOL DelaunayTriangulation2_EEK_RemoveVertex(void* ptr, int index); CGALWRAPPER_API BOOL DelaunayTriangulation2_EEK_FlipEdge(void* ptr, int faceIndex, int neighbour); CGALWRAPPER_API void DelaunayTriangulation2_EEK_Transform(void* ptr, Point2d translation, double rotation, double scale); //Delaunay only CGALWRAPPER_API int DelaunayTriangulation2_EEK_VoronoiSegmentCount(void* ptr); CGALWRAPPER_API int DelaunayTriangulation2_EEK_VoronoiRayCount(void* ptr); CGALWRAPPER_API void DelaunayTriangulation2_EEK_VoronoiCount(void* ptr, int& numSegments, int& numRays); CGALWRAPPER_API void DelaunayTriangulation2_EEK_GetVoronoiSegments(void* ptr, Segment2d* segments, int count); CGALWRAPPER_API void DelaunayTriangulation2_EEK_GetVoronoiRays(void* ptr, Ray2d* rays, int count); } ================================================ FILE: CGALWrapper/Triangulations/DelaunayTriangulation2_EIK.cpp ================================================ #pragma once #include "DelaunayTriangulation2_EIK.h" #include "DelaunayTriangulation2.h" typedef CGAL::Triangulation_vertex_base_with_info_2 Vb; typedef CGAL::Triangulation_face_base_with_info_2 Fb; typedef CGAL::Triangulation_data_structure_2 Tds; typedef CGAL::Delaunay_triangulation_2 Triangulation_2; typedef typename Triangulation_2::Face_handle Face; typedef typename Triangulation_2::Vertex_handle Vertex; typedef DelaunayTriangulation2 Tri2; void* DelaunayTriangulation2_EIK_Create() { return Tri2::NewTriangulation2(); } void DelaunayTriangulation2_EIK_Release(void* ptr) { Tri2::DeleteTriangulation2(ptr); } void DelaunayTriangulation2_EIK_Clear(void* ptr) { auto tri = Tri2::CastToTriangulation2(ptr); tri->Clear(); } void* DelaunayTriangulation2_EIK_Copy(void* ptr) { auto tri = Tri2::CastToTriangulation2(ptr); return tri->Copy(); } void* DelaunayTriangulation2_EIK_Convert(void* ptr, CGAL_KERNEL k) { switch (k) { case CGAL_KERNEL::EXACT_PREDICATES_INEXACT_CONSTRUCTION: return Tri2::Convert(ptr); case CGAL_KERNEL::EXACT_PREDICATES_EXACT_CONSTRUCTION: return Tri2::Convert(ptr); default: return Tri2::Convert(ptr); } } void DelaunayTriangulation2_EIK_SetIndices(void* ptr) { auto tri = Tri2::CastToTriangulation2(ptr); tri->SetIndices(); } int DelaunayTriangulation2_EIK_BuildStamp(void* ptr) { auto tri = Tri2::CastToTriangulation2(ptr); return tri->BuildStamp(); } BOOL DelaunayTriangulation2_EIK_IsValid(void* ptr, int level) { auto tri = Tri2::CastToTriangulation2(ptr); return tri->IsValid(level); } int DelaunayTriangulation2_EIK_VertexCount(void* ptr) { auto tri = Tri2::CastToTriangulation2(ptr); return tri->VertexCount(); } int DelaunayTriangulation2_EIK_FaceCount(void* ptr) { auto tri = Tri2::CastToTriangulation2(ptr); return tri->FaceCount(); } void DelaunayTriangulation2_EIK_InsertPoint(void* ptr, Point2d point) { auto tri = Tri2::CastToTriangulation2(ptr); tri->InsertPoint(point); } void DelaunayTriangulation2_EIK_InsertPoints(void* ptr, Point2d* points, int count) { auto tri = Tri2::CastToTriangulation2(ptr); tri->InsertPoints(points, count); } void DelaunayTriangulation2_EIK_InsertPolygon(void* triPtr, void* polyPtr) { auto tri = Tri2::CastToTriangulation2(triPtr); tri->InsertPolygon(polyPtr); } void DelaunayTriangulation2_EIK_InsertPolygonWithHoles(void* triPtr, void* pwhPtr) { auto tri = Tri2::CastToTriangulation2(triPtr); tri->InsertPolygonWithHoles(pwhPtr); } void DelaunayTriangulation2_EIK_GetPoints(void* ptr, Point2d* points, int count) { auto tri = Tri2::CastToTriangulation2(ptr); tri->GetPoints(points, count); } void DelaunayTriangulation2_EIK_GetIndices(void* ptr, int* indices, int count) { auto tri = Tri2::CastToTriangulation2(ptr); tri->GetIndices(indices, count); } BOOL DelaunayTriangulation2_EIK_GetVertex(void* ptr, int index, TriVertex2& vertex) { auto tri = Tri2::CastToTriangulation2(ptr); return tri->GetVertex(index, vertex); } void DelaunayTriangulation2_EIK_GetVertices(void* ptr, TriVertex2* vertices, int count) { auto tri = Tri2::CastToTriangulation2(ptr); tri->GetVertices(vertices, count); } bool DelaunayTriangulation2_EIK_GetFace(void* ptr, int index, TriFace2& face) { auto tri = Tri2::CastToTriangulation2(ptr); return tri->GetFace(index, face); } void DelaunayTriangulation2_EIK_GetFaces(void* ptr, TriFace2* faces, int count) { auto tri = Tri2::CastToTriangulation2(ptr); tri->GetFaces(faces, count); } BOOL DelaunayTriangulation2_EIK_GetSegment(void* ptr, int faceIndex, int neighbourIndex, Segment2d& segment) { auto tri = Tri2::CastToTriangulation2(ptr); return tri->GetSegment(faceIndex, neighbourIndex, segment); } BOOL DelaunayTriangulation2_EIK_GetTriangle(void* ptr, int faceIndex, Triangle2d& triangle) { auto tri = Tri2::CastToTriangulation2(ptr); return tri->GetTriangle(faceIndex, triangle); } void DelaunayTriangulation2_EIK_GetTriangles(void* ptr, Triangle2d* triangles, int count) { auto tri = Tri2::CastToTriangulation2(ptr); tri->GetTriangles(triangles, count); } BOOL DelaunayTriangulation2_EIK_GetCircumcenter(void* ptr, int faceIndex, Point2d& circumcenter) { auto tri = Tri2::CastToTriangulation2(ptr); return tri->GetCircumcenter(faceIndex, circumcenter); } void DelaunayTriangulation2_EIK_GetCircumcenters(void* ptr, Point2d* circumcenters, int count) { auto tri = Tri2::CastToTriangulation2(ptr); tri->GetCircumcenters(circumcenters, count); } int DelaunayTriangulation2_EIK_NeighbourIndex(void* ptr, int faceIndex, int index) { auto tri = Tri2::CastToTriangulation2(ptr); return tri->NeighbourIndex(faceIndex, index); } BOOL DelaunayTriangulation2_EIK_LocateFace(void* ptr, Point2d point, TriFace2& face) { auto tri = Tri2::CastToTriangulation2(ptr); return tri->LocateFace(point, face); } BOOL DelaunayTriangulation2_EIK_MoveVertex(void* ptr, int index, Point2d point, BOOL ifNoCollision, TriVertex2& vertex) { auto tri = Tri2::CastToTriangulation2(ptr); return tri->MoveVertex(index, point, ifNoCollision, vertex); } BOOL DelaunayTriangulation2_EIK_RemoveVertex(void* ptr, int index) { auto tri = Tri2::CastToTriangulation2(ptr); return tri->RemoveVertex(index); } BOOL DelaunayTriangulation2_EIK_FlipEdge(void* ptr, int faceIndex, int neighbour) { auto tri = Tri2::CastToTriangulation2(ptr); return tri->FlipEdge(faceIndex, neighbour); } void DelaunayTriangulation2_EIK_Transform(void* ptr, Point2d translation, double rotation, double scale) { auto tri = Tri2::CastToTriangulation2(ptr); tri->Transform(translation, rotation, scale); } //Delaunay only int DelaunayTriangulation2_EIK_VoronoiSegmentCount(void* ptr) { auto tri = Tri2::CastToTriangulation2(ptr); return tri->VoronoiSegmentCount(); } int DelaunayTriangulation2_EIK_VoronoiRayCount(void* ptr) { auto tri = Tri2::CastToTriangulation2(ptr); return tri->VoronoiRayCount(); } void DelaunayTriangulation2_EIK_VoronoiCount(void* ptr, int& numSegments, int& numRays) { auto tri = Tri2::CastToTriangulation2(ptr); tri->VoronoiCount(numSegments, numRays); } void DelaunayTriangulation2_EIK_GetVoronoiSegments(void* ptr, Segment2d* segments, int count) { auto tri = Tri2::CastToTriangulation2(ptr); tri->GetVoronoiSegments(segments, count); } void DelaunayTriangulation2_EIK_GetVoronoiRays(void* ptr, Ray2d* rays, int count) { auto tri = Tri2::CastToTriangulation2(ptr); tri->GetVoronoiRays(rays, count); } ================================================ FILE: CGALWrapper/Triangulations/DelaunayTriangulation2_EIK.h ================================================ #pragma once #include "../CGALWrapper.h" #include "../Geometry/Geometry2.h" #include "DelaunayTriangulation2.h" extern "C" { CGALWRAPPER_API void* DelaunayTriangulation2_EIK_Create(); CGALWRAPPER_API void DelaunayTriangulation2_EIK_Release(void* ptr); CGALWRAPPER_API void DelaunayTriangulation2_EIK_Clear(void* ptr); CGALWRAPPER_API void DelaunayTriangulation2_EIK_Clear(void* ptr); CGALWRAPPER_API void* DelaunayTriangulation2_EIK_Copy(void* ptr); CGALWRAPPER_API void* DelaunayTriangulation2_EIK_Convert(void* ptr, CGAL_KERNEL k); CGALWRAPPER_API void DelaunayTriangulation2_EIK_SetIndices(void* ptr); CGALWRAPPER_API int DelaunayTriangulation2_EIK_BuildStamp(void* ptr); CGALWRAPPER_API BOOL DelaunayTriangulation2_EIK_IsValid(void* ptr, int level); CGALWRAPPER_API int DelaunayTriangulation2_EIK_VertexCount(void* ptr); CGALWRAPPER_API int DelaunayTriangulation2_EIK_FaceCount(void* ptr); CGALWRAPPER_API void DelaunayTriangulation2_EIK_InsertPoint(void* ptr, Point2d point); CGALWRAPPER_API void DelaunayTriangulation2_EIK_InsertPoints(void* ptr, Point2d* points, int count); CGALWRAPPER_API void DelaunayTriangulation2_EIK_InsertPolygon(void* triPtr, void* polyPtr); CGALWRAPPER_API void DelaunayTriangulation2_EIK_InsertPolygonWithHoles(void* triPtr, void* pwhPtr); CGALWRAPPER_API void DelaunayTriangulation2_EIK_GetPoints(void* ptr, Point2d* points, int count); CGALWRAPPER_API void DelaunayTriangulation2_EIK_GetIndices(void* ptr, int* indices, int count); CGALWRAPPER_API BOOL DelaunayTriangulation2_EIK_GetVertex(void* ptr, int index, TriVertex2& vertex); CGALWRAPPER_API void DelaunayTriangulation2_EIK_GetVertices(void* ptr, TriVertex2* vertices, int count); CGALWRAPPER_API bool DelaunayTriangulation2_EIK_GetFace(void* ptr, int index, TriFace2& face); CGALWRAPPER_API void DelaunayTriangulation2_EIK_GetFaces(void* ptr, TriFace2* faces, int count); CGALWRAPPER_API BOOL DelaunayTriangulation2_EIK_GetSegment(void* ptr, int faceIndex, int neighbourIndex, Segment2d& segment); CGALWRAPPER_API BOOL DelaunayTriangulation2_EIK_GetTriangle(void* ptr, int faceIndex, Triangle2d& triangle); CGALWRAPPER_API void DelaunayTriangulation2_EIK_GetTriangles(void* ptr, Triangle2d* triangles, int count); CGALWRAPPER_API BOOL DelaunayTriangulation2_EIK_GetCircumcenter(void* ptr, int faceIndex, Point2d& circumcenter); CGALWRAPPER_API void DelaunayTriangulation2_EIK_GetCircumcenters(void* ptr, Point2d* circumcenters, int count); CGALWRAPPER_API int DelaunayTriangulation2_EIK_NeighbourIndex(void* ptr, int faceIndex, int index); CGALWRAPPER_API BOOL DelaunayTriangulation2_EIK_LocateFace(void* ptr, Point2d point, TriFace2& face); CGALWRAPPER_API BOOL DelaunayTriangulation2_EIK_MoveVertex(void* ptr, int index, Point2d point, BOOL ifNoCollision, TriVertex2& vertex); CGALWRAPPER_API BOOL DelaunayTriangulation2_EIK_RemoveVertex(void* ptr, int index); CGALWRAPPER_API BOOL DelaunayTriangulation2_EIK_FlipEdge(void* ptr, int faceIndex, int neighbour); CGALWRAPPER_API void DelaunayTriangulation2_EIK_Transform(void* ptr, Point2d translation, double rotation, double scale); //Delaunay only CGALWRAPPER_API int DelaunayTriangulation2_EIK_VoronoiSegmentCount(void* ptr); CGALWRAPPER_API int DelaunayTriangulation2_EIK_VoronoiRayCount(void* ptr); CGALWRAPPER_API void DelaunayTriangulation2_EIK_VoronoiCount(void* ptr, int& numSegments, int& numRays); CGALWRAPPER_API void DelaunayTriangulation2_EIK_GetVoronoiSegments(void* ptr, Segment2d* segments, int count); CGALWRAPPER_API void DelaunayTriangulation2_EIK_GetVoronoiRays(void* ptr, Ray2d* rays, int count); } ================================================ FILE: CGALWrapper/Triangulations/DelaunayTriangulation3.h ================================================ #pragma once #include "../CGALWrapper.h" #include "../Geometry/Geometry3.h" #include "TriUtil.h" #include #include "CGAL/Point_3.h" #include #include #include #include #include #include #include template class DelaunayTriangulation3 : public BaseTriangulation3 { public: typedef typename CGAL::Triangulation_vertex_base_with_info_3 Vb; typedef typename CGAL::Delaunay_triangulation_cell_base_3 Cb; typedef typename CGAL::Triangulation_data_structure_3 Tds; typedef CGAL::Delaunay_triangulation_3 DelaunayTriangulation_3; typedef typename DelaunayTriangulation_3::Point Point_3; typedef typename DelaunayTriangulation_3::Cell_handle Cell; typedef typename DelaunayTriangulation_3::Vertex_handle Vertex; typedef CGAL::Aff_transformation_3 Transformation_3; public: DelaunayTriangulation3() { } ~DelaunayTriangulation3() { } inline static DelaunayTriangulation3* NewTriangulation3() { return new DelaunayTriangulation3(); } inline static void DeleteTriangulation3(void* ptr) { auto obj = static_cast(ptr); if (obj != nullptr) { delete obj; obj = nullptr; } } inline static DelaunayTriangulation3* CastToTriangulation3(void* ptr) { return static_cast(ptr); } void* Copy() { auto copy = NewTriangulation3(); copy->model = this->model; return copy; } BOOL Move(int index, const Point3d& point, BOOL ifNoCollision) { auto vert = this->GetVertex(index); if (vert != nullptr) { if (ifNoCollision) this->model.move_if_no_collision(vert, point.ToCGAL()); else this->model.move(vert, point.ToCGAL()); return TRUE; } else { return FALSE; } } int NearestVertex(const Point3d& point) { this->BuildVertexIndices(); auto vert = this->model.nearest_vertex(point.ToCGAL()); return vert->info(); } int NearestVertexInCell(int index, const Point3d& point) { auto cell = this->GetCell(index); if (cell != nullptr) { this->BuildVertexIndices(); auto vert = this->model.nearest_vertex_in_cell(point.ToCGAL(), cell); return vert->info(); } else { return NULL_INDEX; } } BOOL RemoveVertex(int index) { auto vert = this->GetVertex(index); if (vert != nullptr) { this->model.remove(vert); return TRUE; } else { return FALSE; } } }; ================================================ FILE: CGALWrapper/Triangulations/DelaunayTriangulation3_EEK.cpp ================================================ #pragma once #include "DelaunayTriangulation3_EEK.h" #include "BaseTriangulation3.h" #include "DelaunayTriangulation3.h" typedef typename CGAL::Triangulation_vertex_base_with_info_3 Vb; typedef typename CGAL::Delaunay_triangulation_cell_base_3 Cb; typedef typename CGAL::Triangulation_data_structure_3 Tds; typedef CGAL::Delaunay_triangulation_3 DelaunayTriangulation_3; typedef typename DelaunayTriangulation_3::Point Point_3; typedef typename DelaunayTriangulation_3::Cell_handle Cell; typedef typename DelaunayTriangulation_3::Vertex_handle Vertex; typedef DelaunayTriangulation3 Tri3; void* DelaunayTriangulation3_EEK_Create() { return Tri3::NewTriangulation3(); } void DelaunayTriangulation3_EEK_Release(void* ptr) { Tri3::DeleteTriangulation3(ptr); } void* DelaunayTriangulation3_EEK_Copy(void* ptr) { auto tri = Tri3::CastToTriangulation3(ptr); return tri->Copy(); } void DelaunayTriangulation3_EEK_Clear(void* ptr) { auto tri = Tri3::CastToTriangulation3(ptr); tri->Clear(); } int DelaunayTriangulation3_EEK_BuildStamp(void* ptr) { auto tri = Tri3::CastToTriangulation3(ptr); return tri->buildStamp; } int DelaunayTriangulation3_EEK_Dimension(void* ptr) { auto tri = Tri3::CastToTriangulation3(ptr); return tri->Dimension(); } BOOL DelaunayTriangulation3_EEK_IsValid(void* ptr, BOOL verbose) { auto tri = Tri3::CastToTriangulation3(ptr); return tri->IsValid(verbose); } int DelaunayTriangulation3_EEK_FiniteVertexCount(void* ptr) { auto tri = Tri3::CastToTriangulation3(ptr); return tri->FiniteVertexCount(); } int DelaunayTriangulation3_EEK_VertexCount(void* ptr) { auto tri = Tri3::CastToTriangulation3(ptr); return tri->VertexCount(); } int DelaunayTriangulation3_EEK_CellCount(void* ptr) { auto tri = Tri3::CastToTriangulation3(ptr); return tri->CellCount(); } int DelaunayTriangulation3_EEK_FiniteCellCount(void* ptr) { auto tri = Tri3::CastToTriangulation3(ptr); return tri->FiniteCellCount(); } int DelaunayTriangulation3_EEK_EdgeCount(void* ptr) { auto tri = Tri3::CastToTriangulation3(ptr); return tri->EdgeCount(); } int DelaunayTriangulation3_EEK_FiniteEdgeCount(void* ptr) { auto tri = Tri3::CastToTriangulation3(ptr); return tri->FiniteEdgeCount(); } int DelaunayTriangulation3_EEK_FacetCount(void* ptr) { auto tri = Tri3::CastToTriangulation3(ptr); return tri->FacetCount(); } int DelaunayTriangulation3_EEK_FiniteFacetCount(void* ptr) { auto tri = Tri3::CastToTriangulation3(ptr); return tri->FiniteFacetCount(); } void DelaunayTriangulation3_EEK_InsertPoint(void* ptr, const Point3d& point) { auto tri = Tri3::CastToTriangulation3(ptr); tri->InsertPoint(point); } void DelaunayTriangulation3_EEK_InsertPoints(void* ptr, Point3d* points, int count) { auto tri = Tri3::CastToTriangulation3(ptr); tri->InsertPoints(points, count); } void DelaunayTriangulation3_EEK_InsertInCell(void* ptr, int index, const Point3d& point) { auto tri = Tri3::CastToTriangulation3(ptr); tri->InsertInCell(index, point); } int DelaunayTriangulation3_EEK_Locate(void* ptr, const Point3d& point) { auto tri = Tri3::CastToTriangulation3(ptr); return tri->Locate(point); } void DelaunayTriangulation3_EEK_GetCircumcenters(void* ptr, Point3d* Circumcenters, int count) { auto tri = Tri3::CastToTriangulation3(ptr); tri->GetCircumcenters(Circumcenters, count); } void DelaunayTriangulation3_EEK_GetPoints(void* ptr, Point3d* points, int count) { auto tri = Tri3::CastToTriangulation3(ptr); tri->GetPoints(points, count); } void DelaunayTriangulation3_EEK_GetVertices(void* ptr, TriVertex3* vertices, int count) { auto tri = Tri3::CastToTriangulation3(ptr); tri->GetVertices(vertices, count); } BOOL DelaunayTriangulation3_EEK_GetVertex(void* ptr, int index, TriVertex3& vertex) { auto tri = Tri3::CastToTriangulation3(ptr); return tri->GetVertex(index, vertex); } void DelaunayTriangulation3_EEK_GetCells(void* ptr, TriCell3* cells, int count) { auto tri = Tri3::CastToTriangulation3(ptr); tri->GetCells(cells, count); } BOOL DelaunayTriangulation3_EEK_GetCell(void* ptr, int index, TriCell3& cell) { auto tri = Tri3::CastToTriangulation3(ptr); return tri->GetCell(index, cell); } void DelaunayTriangulation3_EEK_GetSegmentIndices(void* ptr, int* indices, int count) { auto tri = Tri3::CastToTriangulation3(ptr); tri->GetSegmentIndices(indices, count); } void DelaunayTriangulation3_EEK_GetTriangleIndices(void* ptr, int* indices, int count) { auto tri = Tri3::CastToTriangulation3(ptr); tri->GetTriangleIndices(indices, count); } void DelaunayTriangulation3_EEK_GetTetrahedraIndices(void* ptr, int* indices, int count) { auto tri = Tri3::CastToTriangulation3(ptr); tri->GetTetrahedraIndices(indices, count); } void DelaunayTriangulation3_EEK_GetSegments(void* ptr, Segment3d* segments, int count) { auto tri = Tri3::CastToTriangulation3(ptr); tri->GetSegments(segments, count); } void DelaunayTriangulation3_EEK_GetTriangles(void* ptr, Triangle3d* triangles, int count) { auto tri = Tri3::CastToTriangulation3(ptr); tri->GetTriangles(triangles, count); } void DelaunayTriangulation3_EEK_GetTetahedrons(void* ptr, Tetahedron3d* tetahedrons, int count) { auto tri = Tri3::CastToTriangulation3(ptr); tri->GetTetahedrons(tetahedrons, count); } void DelaunayTriangulation3_EEK_Transform(void* ptr, const Matrix4x4d& matrix) { auto tri = Tri3::CastToTriangulation3(ptr); tri->Transform(matrix); } BOOL DelaunayTriangulation3_EEK_Move(void* ptr, int index, const Point3d& point, BOOL ifNoCollision) { auto tri = Tri3::CastToTriangulation3(ptr); return tri->Move(index, point, ifNoCollision); } int DelaunayTriangulation3_EEK_NearestVertex(void* ptr, const Point3d& point) { auto tri = Tri3::CastToTriangulation3(ptr); return tri->NearestVertex(point); } int DelaunayTriangulation3_EEK_NearestVertexInCell(void* ptr, int index, const Point3d& point) { auto tri = Tri3::CastToTriangulation3(ptr); return tri->NearestVertexInCell(index, point); } BOOL DelaunayTriangulation3_EEK_RemoveVertex(void* ptr, int index) { auto tri = Tri3::CastToTriangulation3(ptr); return tri->RemoveVertex(index); } ================================================ FILE: CGALWrapper/Triangulations/DelaunayTriangulation3_EEK.h ================================================ #pragma once #include "../CGALWrapper.h" #include "../Geometry/Geometry3.h" #include "../Geometry/Matrices.h" #include "TriVertex3.h" #include "TriCell3.h" extern "C" { CGALWRAPPER_API void* DelaunayTriangulation3_EEK_Create(); CGALWRAPPER_API void DelaunayTriangulation3_EEK_Release(void* ptr); CGALWRAPPER_API void DelaunayTriangulation3_EEK_Clear(void* ptr); CGALWRAPPER_API void* DelaunayTriangulation3_EEK_Copy(void* ptr); CGALWRAPPER_API int DelaunayTriangulation3_EEK_BuildStamp(void* ptr); CGALWRAPPER_API int DelaunayTriangulation3_EEK_Dimension(void* ptr); CGALWRAPPER_API BOOL DelaunayTriangulation3_EEK_IsValid(void* ptr, BOOL verbose); CGALWRAPPER_API int DelaunayTriangulation3_EEK_FiniteVertexCount(void* ptr); CGALWRAPPER_API int DelaunayTriangulation3_EEK_VertexCount(void* ptr); CGALWRAPPER_API int DelaunayTriangulation3_EEK_CellCount(void* ptr); CGALWRAPPER_API int DelaunayTriangulation3_EEK_FiniteCellCount(void* ptr); CGALWRAPPER_API int DelaunayTriangulation3_EEK_EdgeCount(void* ptr); CGALWRAPPER_API int DelaunayTriangulation3_EEK_FiniteEdgeCount(void* ptr); CGALWRAPPER_API int DelaunayTriangulation3_EEK_FacetCount(void* ptr); CGALWRAPPER_API int DelaunayTriangulation3_EEK_FiniteFacetCount(void* ptr); CGALWRAPPER_API void DelaunayTriangulation3_EEK_InsertPoint(void* ptr, const Point3d& point); CGALWRAPPER_API void DelaunayTriangulation3_EEK_InsertPoints(void* ptr, Point3d* points, int count); CGALWRAPPER_API void DelaunayTriangulation3_EEK_InsertInCell(void* ptr, int index, const Point3d& point); CGALWRAPPER_API int DelaunayTriangulation3_EEK_Locate(void* ptr, const Point3d& point); CGALWRAPPER_API void DelaunayTriangulation3_EEK_GetCircumcenters(void* ptr, Point3d* Circumcenters, int count); CGALWRAPPER_API void DelaunayTriangulation3_EEK_GetPoints(void* ptr, Point3d* points, int count); CGALWRAPPER_API void DelaunayTriangulation3_EEK_GetVertices(void* ptr, TriVertex3* vertices, int count); CGALWRAPPER_API BOOL DelaunayTriangulation3_EEK_GetVertex(void* ptr, int index, TriVertex3& vertex); CGALWRAPPER_API void DelaunayTriangulation3_EEK_GetCells(void* ptr, TriCell3* cells, int count); CGALWRAPPER_API BOOL DelaunayTriangulation3_EEK_GetCell(void* ptr, int index, TriCell3& cell); CGALWRAPPER_API void DelaunayTriangulation3_EEK_GetSegmentIndices(void* ptr, int* indices, int count); CGALWRAPPER_API void DelaunayTriangulation3_EEK_GetTriangleIndices(void* ptr, int* indices, int count); CGALWRAPPER_API void DelaunayTriangulation3_EEK_GetTetrahedraIndices(void* ptr, int* indices, int count); CGALWRAPPER_API void DelaunayTriangulation3_EEK_GetSegments(void* ptr, Segment3d* segments, int count); CGALWRAPPER_API void DelaunayTriangulation3_EEK_GetTriangles(void* ptr, Triangle3d* triangles, int count); CGALWRAPPER_API void DelaunayTriangulation3_EEK_GetTetahedrons(void* ptr, Tetahedron3d* tetahedrons, int count); CGALWRAPPER_API void DelaunayTriangulation3_EEK_Transform(void* ptr, const Matrix4x4d& matrix); CGALWRAPPER_API BOOL DelaunayTriangulation3_EEK_Move(void* ptr, int index, const Point3d& point, BOOL ifNoCollision); CGALWRAPPER_API int DelaunayTriangulation3_EEK_NearestVertex(void* ptr, const Point3d& point); CGALWRAPPER_API int DelaunayTriangulation3_EEK_NearestVertexInCell(void* ptr, int index, const Point3d& point); CGALWRAPPER_API BOOL DelaunayTriangulation3_EEK_RemoveVertex(void* ptr, int index); } ================================================ FILE: CGALWrapper/Triangulations/TriCell3.h ================================================ #pragma once #include "../CGALWrapper.h" #include "../Geometry/Geometry2.h" #include "../Geometry/Geometry3.h" #include "CGAL/Point_3.h" struct TriCell3 { BOOL IsInfinite; int Index; int VertexIndices[4]; int NeighborIndices[4]; static TriCell3 NullCell() { TriCell3 c; c.IsInfinite = false; c.Index = NULL_INDEX; c.VertexIndices[0] = NULL_INDEX; c.VertexIndices[1] = NULL_INDEX; c.VertexIndices[2] = NULL_INDEX; c.VertexIndices[3] = NULL_INDEX; c.NeighborIndices[0] = NULL_INDEX; c.NeighborIndices[1] = NULL_INDEX; c.NeighborIndices[2] = NULL_INDEX; c.NeighborIndices[3] = NULL_INDEX; return c; } }; ================================================ FILE: CGALWrapper/Triangulations/TriEdge2.h ================================================ #pragma once #include "../CGALWrapper.h" #include "../Geometry/Geometry2.h" #include "CGAL/Point_2.h" struct TriEdge2 { int FaceIndex; int NeighbourIndex; }; ================================================ FILE: CGALWrapper/Triangulations/TriFace2.h ================================================ #pragma once #include "../CGALWrapper.h" #include "../Geometry/Geometry2.h" #include "CGAL/Point_2.h" struct TriFace2 { BOOL IsInfinite; int Index; int VertexIndices[3]; static TriFace2 NullFace() { TriFace2 f; f.IsInfinite = false; f.Index = NULL_INDEX; f.VertexIndices[0] = NULL_INDEX; f.VertexIndices[1] = NULL_INDEX; f.VertexIndices[2] = NULL_INDEX; return f; } template static TriFace2 FromFace(const TRI& tri, FACE face) { TriFace2 triFace; triFace.IsInfinite = tri.is_infinite(face); if(triFace.IsInfinite) triFace.Index = NULL_INDEX; else triFace.Index = face->info(); for (int j = 0; j < 3; j++) { auto vert = face->vertex(j); if (tri.is_infinite(vert)) triFace.VertexIndices[j] = NULL_INDEX; else triFace.VertexIndices[j] = vert->info(); } return triFace; } }; ================================================ FILE: CGALWrapper/Triangulations/TriUtil.h ================================================ #pragma once #include "../CGALWrapper.h" #include "../Geometry/Geometry2.h" #include "TriFace2.h" #include "TriVertex2.h" #include "CGAL/Point_2.h" #include #include #include #include namespace TriUtil { template int NeighbourIndex(FACE face, FACE neighbour) { for (int i = 0; i < 3; i++) { if (face->neighbor(i) == neighbour) return i; } return NULL_INDEX; } template int Degree2(TRI& tri, VERT vert) { auto face = vert->face(); auto start = vert->incident_faces(face), end(start); int count = 0; if (!start.is_empty()) { do { if (!tri.is_infinite(start)) ++count; } while (++start != end); } return count; } //template //int Degree3(TRI& tri, VERT vert) //{ // std::vector cells; // tri.finite_incident_cells(vert, std::back_inserter(cells)); // return cells.size(); //} template POINT CenterPoint(FACE face) { POINT p0 = face->vertex(0)->point(); POINT p1 = face->vertex(1)->point(); POINT p2 = face->vertex(2)->point(); auto x = (p0.x() + p1.x() + p2.x()) / 3; auto y = (p0.y() + p1.y() + p2.y()) / 3; return POINT(x, y); } } ================================================ FILE: CGALWrapper/Triangulations/TriVertex2.h ================================================ #pragma once #include "../CGALWrapper.h" #include "../Geometry/Geometry2.h" #include "../Geometry/Geometry3.h" #include "CGAL/Point_2.h" struct TriVertex2 { Point2d Point; BOOL IsInfinite; int Degree; int Index; int FaceIndex; static TriVertex2 NullVertex() { TriVertex2 v; v.Point = { 0, 0}; v.IsInfinite = false; v.Degree = 0; v.Index = NULL_INDEX; v.FaceIndex = NULL_INDEX; return v; } template static TriVertex2 FromVertex(const TRI& tri, VERT vert, int degree) { TriVertex2 triVertex; triVertex.Point = Point2d::FromCGAL(vert->point()); triVertex.IsInfinite = tri.is_infinite(vert); triVertex.Degree = degree; triVertex.Index = vert->info(); auto face = vert->face(); if (tri.is_infinite(face) || tri.number_of_faces() == 0) triVertex.FaceIndex = NULL_INDEX; else triVertex.FaceIndex = face->info(); return triVertex; } }; ================================================ FILE: CGALWrapper/Triangulations/TriVertex3.h ================================================ #pragma once #include "../CGALWrapper.h" #include "../Geometry/Geometry2.h" #include "../Geometry/Geometry3.h" #include "CGAL/Point_3.h" struct TriVertex3 { Point3d Point; BOOL IsInfinite; int Degree; int Index; int CellIndex; static TriVertex3 NullVertex() { TriVertex3 v; v.Point = { 0, 0 }; v.IsInfinite = false; v.Degree = 0; v.Index = NULL_INDEX; v.CellIndex = NULL_INDEX; return v; } }; ================================================ FILE: CGALWrapper/Triangulations/Triangulation2.h ================================================ #pragma once #include "../CGALWrapper.h" #include "../Geometry/Geometry2.h" #include "../Polygons/Polygon2.h" #include "../Polygons/PolygonWithHoles2.h" #include "BaseTriangulation2.h" #include "CGAL/Point_2.h" #include #include #include template class Triangulation2 : public BaseTriangulation2 { public: typedef CGAL::Triangulation_vertex_base_with_info_2 Vb; typedef CGAL::Triangulation_face_base_with_info_2 Fb; typedef CGAL::Triangulation_data_structure_2 Tds; typedef CGAL::Triangulation_2 Triangulation_2; typedef typename Triangulation_2::Face_handle Face; typedef typename Triangulation_2::Vertex_handle Vertex; public: inline static Triangulation2* NewTriangulation2() { return new Triangulation2(); } inline static void DeleteTriangulation2(void* ptr) { auto obj = static_cast(ptr); if (obj != nullptr) { delete obj; obj = nullptr; } } inline static Triangulation2* CastToTriangulation2(void* ptr) { return static_cast(ptr); } void* Copy() { auto copy = NewTriangulation2(); copy->model = this->model; return copy; } template static void* Convert(void* ptr) { typedef CGAL::Cartesian_converter Converter; Converter convert; auto tri = NewTriangulation2(); auto tri2 = new Triangulation2(); for (const auto& vert : tri->model.finite_vertex_handles()) { auto p = convert(vert->point()); //tri2->model.insert(p); } return tri2; } }; ================================================ FILE: CGALWrapper/Triangulations/Triangulation2_EEK.cpp ================================================ #pragma once #include "Triangulation2_EEK.h" #include "Triangulation2.h" typedef CGAL::Triangulation_vertex_base_with_info_2 Vb; typedef CGAL::Triangulation_face_base_with_info_2 Fb; typedef CGAL::Triangulation_data_structure_2 Tds; typedef CGAL::Triangulation_2 Triangulation_2; typedef typename Triangulation_2::Face_handle Face; typedef typename Triangulation_2::Vertex_handle Vertex; typedef Triangulation2 Tri2; void* Triangulation2_EEK_Create() { return Tri2::NewTriangulation2(); } void Triangulation2_EEK_Release(void* ptr) { Tri2::DeleteTriangulation2(ptr); } void Triangulation2_EEK_Clear(void* ptr) { auto tri = Tri2::CastToTriangulation2(ptr); tri->Clear(); } void* Triangulation2_EEK_Copy(void* ptr) { auto tri = Tri2::CastToTriangulation2(ptr); return tri->Copy(); } void* Triangulation2_EEK_Convert(void* ptr, CGAL_KERNEL k) { switch (k) { case CGAL_KERNEL::EXACT_PREDICATES_INEXACT_CONSTRUCTION: return Tri2::Convert(ptr); case CGAL_KERNEL::EXACT_PREDICATES_EXACT_CONSTRUCTION: return Tri2::Convert(ptr); default: return Tri2::Convert(ptr); } } void Triangulation2_EEK_SetIndices(void* ptr) { auto tri = Tri2::CastToTriangulation2(ptr); tri->SetIndices(); } int Triangulation2_EEK_BuildStamp(void* ptr) { auto tri = Tri2::CastToTriangulation2(ptr); return tri->BuildStamp(); } BOOL Triangulation2_EEK_IsValid(void* ptr, int level) { auto tri = Tri2::CastToTriangulation2(ptr); return tri->IsValid(level); } int Triangulation2_EEK_VertexCount(void* ptr) { auto tri = Tri2::CastToTriangulation2(ptr); return tri->VertexCount(); } int Triangulation2_EEK_FaceCount(void* ptr) { auto tri = Tri2::CastToTriangulation2(ptr); return tri->FaceCount(); } void Triangulation2_EEK_InsertPoint(void* ptr, Point2d point) { auto tri = Tri2::CastToTriangulation2(ptr); tri->InsertPoint(point); } void Triangulation2_EEK_InsertPoints(void* ptr, Point2d* points, int count) { auto tri = Tri2::CastToTriangulation2(ptr); tri->InsertPoints(points, count); } void Triangulation2_EEK_InsertPolygon(void* triPtr, void* polyPtr) { auto tri = Tri2::CastToTriangulation2(triPtr); tri->InsertPolygon(polyPtr); } void Triangulation2_EEK_InsertPolygonWithHoles(void* triPtr, void* pwhPtr) { auto tri = Tri2::CastToTriangulation2(triPtr); tri->InsertPolygonWithHoles(pwhPtr); } void Triangulation2_EEK_GetPoints(void* ptr, Point2d* points, int count) { auto tri = Tri2::CastToTriangulation2(ptr); tri->GetPoints(points, count); } void Triangulation2_EEK_GetIndices(void* ptr, int* indices, int count) { auto tri = Tri2::CastToTriangulation2(ptr); tri->GetIndices(indices, count); } BOOL Triangulation2_EEK_GetVertex(void* ptr, int index, TriVertex2& vertex) { auto tri = Tri2::CastToTriangulation2(ptr); return tri->GetVertex(index, vertex); } void Triangulation2_EEK_GetVertices(void* ptr, TriVertex2* vertices, int count) { auto tri = Tri2::CastToTriangulation2(ptr); tri->GetVertices(vertices, count); } bool Triangulation2_EEK_GetFace(void* ptr, int index, TriFace2& face) { auto tri = Tri2::CastToTriangulation2(ptr); return tri->GetFace(index, face); } void Triangulation2_EEK_GetFaces(void* ptr, TriFace2* faces, int count) { auto tri = Tri2::CastToTriangulation2(ptr); tri->GetFaces(faces, count); } BOOL Triangulation2_EEK_GetSegment(void* ptr, int faceIndex, int neighbourIndex, Segment2d& segment) { auto tri = Tri2::CastToTriangulation2(ptr); return tri->GetSegment(faceIndex, neighbourIndex, segment); } BOOL Triangulation2_EEK_GetTriangle(void* ptr, int faceIndex, Triangle2d& triangle) { auto tri = Tri2::CastToTriangulation2(ptr); return tri->GetTriangle(faceIndex, triangle); } void Triangulation2_EEK_GetTriangles(void* ptr, Triangle2d* triangles, int count) { auto tri = Tri2::CastToTriangulation2(ptr); tri->GetTriangles(triangles, count); } BOOL Triangulation2_EEK_GetCircumcenter(void* ptr, int faceIndex, Point2d& circumcenter) { auto tri = Tri2::CastToTriangulation2(ptr); return tri->GetCircumcenter(faceIndex, circumcenter); } void Triangulation2_EEK_GetCircumcenters(void* ptr, Point2d* circumcenters, int count) { auto tri = Tri2::CastToTriangulation2(ptr); tri->GetCircumcenters(circumcenters, count); } int Triangulation2_EEK_NeighbourIndex(void* ptr, int faceIndex, int index) { auto tri = Tri2::CastToTriangulation2(ptr); return tri->NeighbourIndex(faceIndex, index); } BOOL Triangulation2_EEK_LocateFace(void* ptr, Point2d point, TriFace2& face) { auto tri = Tri2::CastToTriangulation2(ptr); return tri->LocateFace(point, face); } BOOL Triangulation2_EEK_MoveVertex(void* ptr, int index, Point2d point, BOOL ifNoCollision, TriVertex2& vertex) { auto tri = Tri2::CastToTriangulation2(ptr); return tri->MoveVertex(index, point, ifNoCollision, vertex); } BOOL Triangulation2_EEK_RemoveVertex(void* ptr, int index) { auto tri = Tri2::CastToTriangulation2(ptr); return tri->RemoveVertex(index); } BOOL Triangulation2_EEK_FlipEdge(void* ptr, int faceIndex, int neighbour) { auto tri = Tri2::CastToTriangulation2(ptr); return tri->FlipEdge(faceIndex, neighbour); } void Triangulation2_EEK_Transform(void* ptr, Point2d translation, double rotation, double scale) { auto tri = Tri2::CastToTriangulation2(ptr); tri->Transform(translation, rotation, scale); } ================================================ FILE: CGALWrapper/Triangulations/Triangulation2_EEK.h ================================================ #pragma once #include "../CGALWrapper.h" #include "../Geometry/Geometry2.h" #include "Triangulation2.h" extern "C" { CGALWRAPPER_API void* Triangulation2_EEK_Create(); CGALWRAPPER_API void Triangulation2_EEK_Release(void* ptr); CGALWRAPPER_API void Triangulation2_EEK_Clear(void* ptr); CGALWRAPPER_API void* Triangulation2_EEK_Copy(void* ptr); CGALWRAPPER_API void* Triangulation2_EEK_Convert(void* ptr, CGAL_KERNEL k); CGALWRAPPER_API void Triangulation2_EEK_SetIndices(void* ptr); CGALWRAPPER_API int Triangulation2_EEK_BuildStamp(void* ptr); CGALWRAPPER_API BOOL Triangulation2_EEK_IsValid(void* ptr, int level); CGALWRAPPER_API int Triangulation2_EEK_VertexCount(void* ptr); CGALWRAPPER_API int Triangulation2_EEK_FaceCount(void* ptr); CGALWRAPPER_API void Triangulation2_EEK_InsertPoint(void* ptr, Point2d point); CGALWRAPPER_API void Triangulation2_EEK_InsertPoints(void* ptr, Point2d* points, int count); CGALWRAPPER_API void Triangulation2_EEK_InsertPolygon(void* triPtr, void* polyPtr); CGALWRAPPER_API void Triangulation2_EEK_InsertPolygonWithHoles(void* triPtr, void* pwhPtr); CGALWRAPPER_API void Triangulation2_EEK_GetPoints(void* ptr, Point2d* points, int count); CGALWRAPPER_API void Triangulation2_EEK_GetIndices(void* ptr, int* indices, int count); CGALWRAPPER_API BOOL Triangulation2_EEK_GetVertex(void* ptr, int index, TriVertex2& vertex); CGALWRAPPER_API void Triangulation2_EEK_GetVertices(void* ptr, TriVertex2* vertices, int count); CGALWRAPPER_API bool Triangulation2_EEK_GetFace(void* ptr, int index, TriFace2& face); CGALWRAPPER_API void Triangulation2_EEK_GetFaces(void* ptr, TriFace2* faces, int count); CGALWRAPPER_API BOOL Triangulation2_EEK_GetSegment(void* ptr, int faceIndex, int neighbourIndex, Segment2d& segment); CGALWRAPPER_API BOOL Triangulation2_EEK_GetTriangle(void* ptr, int faceIndex, Triangle2d& triangle); CGALWRAPPER_API void Triangulation2_EEK_GetTriangles(void* ptr, Triangle2d* triangles, int count); CGALWRAPPER_API BOOL Triangulation2_EEK_GetCircumcenter(void* ptr, int faceIndex, Point2d& circumcenter); CGALWRAPPER_API void Triangulation2_EEK_GetCircumcenters(void* ptr, Point2d* circumcenters, int count); CGALWRAPPER_API int Triangulation2_EEK_NeighbourIndex(void* ptr, int faceIndex, int index); CGALWRAPPER_API BOOL Triangulation2_EEK_LocateFace(void* ptr, Point2d point, TriFace2& face); CGALWRAPPER_API BOOL Triangulation2_EEK_MoveVertex(void* ptr, int index, Point2d point, BOOL ifNoCollision, TriVertex2& vertex); CGALWRAPPER_API BOOL Triangulation2_EEK_RemoveVertex(void* ptr, int index); CGALWRAPPER_API BOOL Triangulation2_EEK_FlipEdge(void* ptr, int faceIndex, int neighbour); CGALWRAPPER_API void Triangulation2_EEK_Transform(void* ptr, Point2d translation, double rotation, double scale); } ================================================ FILE: CGALWrapper/Triangulations/Triangulation2_EIK.cpp ================================================ #pragma once #include "Triangulation2_EIK.h" #include "Triangulation2.h" typedef CGAL::Triangulation_vertex_base_with_info_2 Vb; typedef CGAL::Triangulation_face_base_with_info_2 Fb; typedef CGAL::Triangulation_data_structure_2 Tds; typedef CGAL::Triangulation_2 Triangulation_2; typedef typename Triangulation_2::Face_handle Face; typedef typename Triangulation_2::Vertex_handle Vertex; typedef Triangulation2 Tri2; void* Triangulation2_EIK_Create() { return Tri2::NewTriangulation2(); } void Triangulation2_EIK_Release(void* ptr) { Tri2::DeleteTriangulation2(ptr); } void Triangulation2_EIK_Clear(void* ptr) { auto tri = Tri2::CastToTriangulation2(ptr); tri->Clear(); } void* Triangulation2_EIK_Copy(void* ptr) { auto tri = Tri2::CastToTriangulation2(ptr); return tri->Copy(); } void* Triangulation2_EIK_Convert(void* ptr, CGAL_KERNEL k) { switch (k) { case CGAL_KERNEL::EXACT_PREDICATES_INEXACT_CONSTRUCTION: return Tri2::Convert(ptr); case CGAL_KERNEL::EXACT_PREDICATES_EXACT_CONSTRUCTION: return Tri2::Convert(ptr); default: return Tri2::Convert(ptr); } } void Triangulation2_EIK_SetIndices(void* ptr) { auto tri = Tri2::CastToTriangulation2(ptr); tri->SetIndices(); } int Triangulation2_EIK_BuildStamp(void* ptr) { auto tri = Tri2::CastToTriangulation2(ptr); return tri->BuildStamp(); } BOOL Triangulation2_EIK_IsValid(void* ptr, int level) { auto tri = Tri2::CastToTriangulation2(ptr); return tri->IsValid(level); } int Triangulation2_EIK_VertexCount(void* ptr) { auto tri = Tri2::CastToTriangulation2(ptr); return tri->VertexCount(); } int Triangulation2_EIK_FaceCount(void* ptr) { auto tri = Tri2::CastToTriangulation2(ptr); return tri->FaceCount(); } void Triangulation2_EIK_InsertPoint(void* ptr, Point2d point) { auto tri = Tri2::CastToTriangulation2(ptr); tri->InsertPoint(point); } void Triangulation2_EIK_InsertPoints(void* ptr, Point2d* points, int count) { auto tri = Tri2::CastToTriangulation2(ptr); tri->InsertPoints(points, count); } void Triangulation2_EIK_InsertPolygon(void* triPtr, void* polyPtr) { auto tri = Tri2::CastToTriangulation2(triPtr); tri->InsertPolygon(polyPtr); } void Triangulation2_EIK_InsertPolygonWithHoles(void* triPtr, void* pwhPtr) { auto tri = Tri2::CastToTriangulation2(triPtr); tri->InsertPolygonWithHoles(pwhPtr); } void Triangulation2_EIK_GetPoints(void* ptr, Point2d* points, int count) { auto tri = Tri2::CastToTriangulation2(ptr); tri->GetPoints(points, count); } void Triangulation2_EIK_GetIndices(void* ptr, int* indices, int count) { auto tri = Tri2::CastToTriangulation2(ptr); tri->GetIndices(indices, count); } BOOL Triangulation2_EIK_GetVertex(void* ptr, int index, TriVertex2& vertex) { auto tri = Tri2::CastToTriangulation2(ptr); return tri->GetVertex(index, vertex); } void Triangulation2_EIK_GetVertices(void* ptr, TriVertex2* vertices, int count) { auto tri = Tri2::CastToTriangulation2(ptr); tri->GetVertices(vertices, count); } bool Triangulation2_EIK_GetFace(void* ptr, int index, TriFace2& face) { auto tri = Tri2::CastToTriangulation2(ptr); return tri->GetFace(index, face); } void Triangulation2_EIK_GetFaces(void* ptr, TriFace2* faces, int count) { auto tri = Tri2::CastToTriangulation2(ptr); tri->GetFaces(faces, count); } BOOL Triangulation2_EIK_GetSegment(void* ptr, int faceIndex, int neighbourIndex, Segment2d& segment) { auto tri = Tri2::CastToTriangulation2(ptr); return tri->GetSegment(faceIndex, neighbourIndex, segment); } BOOL Triangulation2_EIK_GetTriangle(void* ptr, int faceIndex, Triangle2d& triangle) { auto tri = Tri2::CastToTriangulation2(ptr); return tri->GetTriangle(faceIndex, triangle); } void Triangulation2_EIK_GetTriangles(void* ptr, Triangle2d* triangles, int count) { auto tri = Tri2::CastToTriangulation2(ptr); tri->GetTriangles(triangles, count); } BOOL Triangulation2_EIK_GetCircumcenter(void* ptr, int faceIndex, Point2d& circumcenter) { auto tri = Tri2::CastToTriangulation2(ptr); return tri->GetCircumcenter(faceIndex, circumcenter); } void Triangulation2_EIK_GetCircumcenters(void* ptr, Point2d* circumcenters, int count) { auto tri = Tri2::CastToTriangulation2(ptr); tri->GetCircumcenters(circumcenters, count); } int Triangulation2_EIK_NeighbourIndex(void* ptr, int faceIndex, int index) { auto tri = Tri2::CastToTriangulation2(ptr); return tri->NeighbourIndex(faceIndex, index); } BOOL Triangulation2_EIK_LocateFace(void* ptr, Point2d point, TriFace2& face) { auto tri = Tri2::CastToTriangulation2(ptr); return tri->LocateFace(point, face); } BOOL Triangulation2_EIK_MoveVertex(void* ptr, int index, Point2d point, BOOL ifNoCollision, TriVertex2& vertex) { auto tri = Tri2::CastToTriangulation2(ptr); return tri->MoveVertex(index, point, ifNoCollision, vertex); } BOOL Triangulation2_EIK_RemoveVertex(void* ptr, int index) { auto tri = Tri2::CastToTriangulation2(ptr); return tri->RemoveVertex(index); } BOOL Triangulation2_EIK_FlipEdge(void* ptr, int faceIndex, int neighbour) { auto tri = Tri2::CastToTriangulation2(ptr); return tri->FlipEdge(faceIndex, neighbour); } void Triangulation2_EIK_Transform(void* ptr, Point2d translation, double rotation, double scale) { auto tri = Tri2::CastToTriangulation2(ptr); tri->Transform(translation, rotation, scale); } ================================================ FILE: CGALWrapper/Triangulations/Triangulation2_EIK.h ================================================ #pragma once #include "../CGALWrapper.h" #include "../Geometry/Geometry2.h" #include "Triangulation2.h" extern "C" { CGALWRAPPER_API void* Triangulation2_EIK_Create(); CGALWRAPPER_API void Triangulation2_EIK_Release(void* ptr); CGALWRAPPER_API void Triangulation2_EIK_Clear(void* ptr); CGALWRAPPER_API void* Triangulation2_EIK_Copy(void* ptr); CGALWRAPPER_API void* Triangulation2_EIK_Convert(void* ptr, CGAL_KERNEL k); CGALWRAPPER_API void Triangulation2_EIK_SetIndices(void* ptr); CGALWRAPPER_API int Triangulation2_EIK_BuildStamp(void* ptr); CGALWRAPPER_API BOOL Triangulation2_EIK_IsValid(void* ptr, int level); CGALWRAPPER_API int Triangulation2_EIK_VertexCount(void* ptr); CGALWRAPPER_API int Triangulation2_EIK_FaceCount(void* ptr); CGALWRAPPER_API void Triangulation2_EIK_InsertPoint(void* ptr, Point2d point); CGALWRAPPER_API void Triangulation2_EIK_InsertPoints(void* ptr, Point2d* points, int count); CGALWRAPPER_API void Triangulation2_EIK_InsertPolygon(void* triPtr, void* polyPtr); CGALWRAPPER_API void Triangulation2_EIK_InsertPolygonWithHoles(void* triPtr, void* pwhPtr); CGALWRAPPER_API void Triangulation2_EIK_GetPoints(void* ptr, Point2d* points, int count); CGALWRAPPER_API void Triangulation2_EIK_GetIndices(void* ptr, int* indices, int count); CGALWRAPPER_API BOOL Triangulation2_EIK_GetVertex(void* ptr, int index, TriVertex2& vertex); CGALWRAPPER_API void Triangulation2_EIK_GetVertices(void* ptr, TriVertex2* vertices, int count); CGALWRAPPER_API bool Triangulation2_EIK_GetFace(void* ptr, int index, TriFace2& face); CGALWRAPPER_API void Triangulation2_EIK_GetFaces(void* ptr, TriFace2* faces, int count); CGALWRAPPER_API BOOL Triangulation2_EIK_GetSegment(void* ptr, int faceIndex, int neighbourIndex, Segment2d& segment); CGALWRAPPER_API BOOL Triangulation2_EIK_GetTriangle(void* ptr, int faceIndex, Triangle2d& triangle); CGALWRAPPER_API void Triangulation2_EIK_GetTriangles(void* ptr, Triangle2d* triangles, int count); CGALWRAPPER_API BOOL Triangulation2_EIK_GetCircumcenter(void* ptr, int faceIndex, Point2d& circumcenter); CGALWRAPPER_API void Triangulation2_EIK_GetCircumcenters(void* ptr, Point2d* circumcenters, int count); CGALWRAPPER_API int Triangulation2_EIK_NeighbourIndex(void* ptr, int faceIndex, int index); CGALWRAPPER_API BOOL Triangulation2_EIK_LocateFace(void* ptr, Point2d point, TriFace2& face); CGALWRAPPER_API BOOL Triangulation2_EIK_MoveVertex(void* ptr, int index, Point2d point, BOOL ifNoCollision, TriVertex2& vertex); CGALWRAPPER_API BOOL Triangulation2_EIK_RemoveVertex(void* ptr, int index); CGALWRAPPER_API BOOL Triangulation2_EIK_FlipEdge(void* ptr, int faceIndex, int neighbour); CGALWRAPPER_API void Triangulation2_EIK_Transform(void* ptr, Point2d translation, double rotation, double scale); } ================================================ FILE: CGALWrapper/Triangulations/Triangulation3.h ================================================ #pragma once #include "../CGALWrapper.h" #include "../Geometry/Geometry3.h" #include "TriUtil.h" #include "../Geometry/Matrices.h" #include "BaseTriangulation3.h" #include #include "CGAL/Point_3.h" #include #include #include #include template class Triangulation3 : public BaseTriangulation3 { public: typedef CGAL::Triangulation_vertex_base_with_info_3 Vb; typedef CGAL::Triangulation_cell_base_with_info_3 Cb; typedef CGAL::Triangulation_data_structure_3 Tds; typedef CGAL::Triangulation_3 Triangulation_3; typedef typename Triangulation_3::Point Point_3; typedef typename Triangulation_3::Cell_handle Cell; typedef typename Triangulation_3::Vertex_handle Vertex; public: Triangulation3() { } ~Triangulation3() { } inline static Triangulation3* NewTriangulation3() { return new Triangulation3(); } inline static void DeleteTriangulation3(void* ptr) { auto obj = static_cast(ptr); if (obj != nullptr) { delete obj; obj = nullptr; } } inline static Triangulation3* CastToTriangulation3(void* ptr) { return static_cast(ptr); } void* Copy() { auto copy = NewTriangulation3(); copy->model = this->model; return copy; } }; ================================================ FILE: CGALWrapper/Triangulations/Triangulation3_EEK.cpp ================================================ #pragma once #include "Triangulation3_EEK.h" #include "Triangulation3.h" #include "BaseTriangulation3.h" typedef CGAL::Triangulation_vertex_base_with_info_3 Vb; typedef CGAL::Triangulation_cell_base_with_info_3 Cb; typedef CGAL::Triangulation_data_structure_3 Tds; typedef CGAL::Triangulation_3 Triangulation_3; typedef typename Triangulation_3::Point Point_3; typedef typename Triangulation_3::Cell_handle Cell; typedef typename Triangulation_3::Vertex_handle Vertex; typedef typename Triangulation_3::Edge Edge; typedef Triangulation3 Tri3; void* Triangulation3_EEK_Create() { return Tri3::NewTriangulation3(); } void Triangulation3_EEK_Release(void* ptr) { Tri3::DeleteTriangulation3(ptr); } void Triangulation3_EEK_Clear(void* ptr) { auto tri = Tri3::CastToTriangulation3(ptr); tri->Clear(); } void* Triangulation3_EEK_Copy(void* ptr) { auto tri = Tri3::CastToTriangulation3(ptr); return tri->Copy(); } int Triangulation3_EEK_BuildStamp(void* ptr) { auto tri = Tri3::CastToTriangulation3(ptr); return tri->buildStamp; } int Triangulation3_EEK_Dimension(void* ptr) { auto tri = Tri3::CastToTriangulation3(ptr); return tri->Dimension(); } BOOL Triangulation3_EEK_IsValid(void* ptr, BOOL verbose) { auto tri = Tri3::CastToTriangulation3(ptr); return tri->IsValid(verbose); } int Triangulation3_EEK_FiniteVertexCount(void* ptr) { auto tri = Tri3::CastToTriangulation3(ptr); return tri->FiniteVertexCount(); } int Triangulation3_EEK_VertexCount(void* ptr) { auto tri = Tri3::CastToTriangulation3(ptr); return tri->VertexCount(); } int Triangulation3_EEK_CellCount(void* ptr) { auto tri = Tri3::CastToTriangulation3(ptr); return tri->CellCount(); } int Triangulation3_EEK_FiniteCellCount(void* ptr) { auto tri = Tri3::CastToTriangulation3(ptr); return tri->FiniteCellCount(); } int Triangulation3_EEK_EdgeCount(void* ptr) { auto tri = Tri3::CastToTriangulation3(ptr); return tri->EdgeCount(); } int Triangulation3_EEK_FiniteEdgeCount(void* ptr) { auto tri = Tri3::CastToTriangulation3(ptr); return tri->FiniteEdgeCount(); } int Triangulation3_EEK_FacetCount(void* ptr) { auto tri = Tri3::CastToTriangulation3(ptr); return tri->FacetCount(); } int Triangulation3_EEK_FiniteFacetCount(void* ptr) { auto tri = Tri3::CastToTriangulation3(ptr); return tri->FiniteFacetCount(); } void Triangulation3_EEK_InsertPoint(void* ptr, const Point3d& point) { auto tri = Tri3::CastToTriangulation3(ptr); tri->InsertPoint(point); } void Triangulation3_EEK_InsertPoints(void* ptr, Point3d* points, int count) { auto tri = Tri3::CastToTriangulation3(ptr); tri->InsertPoints(points, count); } void Triangulation3_EEK_InsertInCell(void* ptr, int index, const Point3d& point) { auto tri = Tri3::CastToTriangulation3(ptr); tri->InsertInCell(index, point); } int Triangulation3_EEK_Locate(void* ptr, const Point3d& point) { auto tri = Tri3::CastToTriangulation3(ptr); return tri->Locate(point); } void Triangulation3_EEK_GetCircumcenters(void* ptr, Point3d* Circumcenters, int count) { auto tri = Tri3::CastToTriangulation3(ptr); tri->GetCircumcenters(Circumcenters, count); } void Triangulation3_EEK_GetPoints(void* ptr, Point3d* points, int count) { auto tri = Tri3::CastToTriangulation3(ptr); tri->GetPoints(points, count); } void Triangulation3_EEK_GetVertices(void* ptr, TriVertex3* vertices, int count) { auto tri = Tri3::CastToTriangulation3(ptr); tri->GetVertices(vertices, count); } BOOL Triangulation3_EEK_GetVertex(void* ptr, int index, TriVertex3& vertex) { auto tri = Tri3::CastToTriangulation3(ptr); return tri->GetVertex(index, vertex); } void Triangulation3_EEK_GetCells(void* ptr, TriCell3* cells, int count) { auto tri = Tri3::CastToTriangulation3(ptr); tri->GetCells(cells, count); } BOOL Triangulation3_EEK_GetCell(void* ptr, int index, TriCell3& cell) { auto tri = Tri3::CastToTriangulation3(ptr); return tri->GetCell(index, cell); } void Triangulation3_EEK_GetSegmentIndices(void* ptr, int* indices, int count) { auto tri = Tri3::CastToTriangulation3(ptr); tri->GetSegmentIndices(indices, count); } void Triangulation3_EEK_GetTriangleIndices(void* ptr, int* indices, int count) { auto tri = Tri3::CastToTriangulation3(ptr); tri->GetTriangleIndices(indices, count); } void Triangulation3_EEK_GetTetrahedraIndices(void* ptr, int* indices, int count) { auto tri = Tri3::CastToTriangulation3(ptr); tri->GetTetrahedraIndices(indices, count); } void Triangulation3_EEK_GetSegments(void* ptr, Segment3d* segments, int count) { auto tri = Tri3::CastToTriangulation3(ptr); tri->GetSegments(segments, count); } void Triangulation3_EEK_GetTriangles(void* ptr, Triangle3d* triangles, int count) { auto tri = Tri3::CastToTriangulation3(ptr); tri->GetTriangles(triangles, count); } void Triangulation3_EEK_GetTetahedrons(void* ptr, Tetahedron3d* tetahedrons, int count) { auto tri = Tri3::CastToTriangulation3(ptr); tri->GetTetahedrons(tetahedrons, count); } void Triangulation3_EEK_Transform(void* ptr, const Matrix4x4d& matrix) { auto tri = Tri3::CastToTriangulation3(ptr); tri->Transform(matrix); } ================================================ FILE: CGALWrapper/Triangulations/Triangulation3_EEK.h ================================================ #pragma once #include "../CGALWrapper.h" #include "../Geometry/Geometry3.h" #include "../Geometry/Matrices.h" #include "TriVertex3.h" #include "TriCell3.h" extern "C" { CGALWRAPPER_API void* Triangulation3_EEK_Create(); CGALWRAPPER_API void Triangulation3_EEK_Release(void* ptr); CGALWRAPPER_API void Triangulation3_EEK_Clear(void* ptr); CGALWRAPPER_API void* Triangulation3_EEK_Copy(void* ptr); CGALWRAPPER_API int Triangulation3_EEK_BuildStamp(void* ptr); CGALWRAPPER_API int Triangulation3_EEK_Dimension(void* ptr); CGALWRAPPER_API BOOL Triangulation3_EEK_IsValid(void* ptr, BOOL verbose); CGALWRAPPER_API int Triangulation3_EEK_FiniteVertexCount(void* ptr); CGALWRAPPER_API int Triangulation3_EEK_VertexCount(void* ptr); CGALWRAPPER_API int Triangulation3_EEK_CellCount(void* ptr); CGALWRAPPER_API int Triangulation3_EEK_FiniteCellCount(void* ptr); CGALWRAPPER_API int Triangulation3_EEK_EdgeCount(void* ptr); CGALWRAPPER_API int Triangulation3_EEK_FiniteEdgeCount(void* ptr); CGALWRAPPER_API int Triangulation3_EEK_FacetCount(void* ptr); CGALWRAPPER_API int Triangulation3_EEK_FiniteFacetCount(void* ptr); CGALWRAPPER_API void Triangulation3_EEK_InsertPoint(void* ptr, const Point3d& point); CGALWRAPPER_API void Triangulation3_EEK_InsertPoints(void* ptr, Point3d* points, int count); CGALWRAPPER_API void Triangulation3_EEK_InsertInCell(void* ptr, int index, const Point3d& point); CGALWRAPPER_API int Triangulation3_EEK_Locate(void* ptr, const Point3d& point); CGALWRAPPER_API void Triangulation3_EEK_GetCircumcenters(void* ptr, Point3d* Circumcenters, int count); CGALWRAPPER_API void Triangulation3_EEK_GetPoints(void* ptr, Point3d* points, int count); CGALWRAPPER_API void Triangulation3_EEK_GetVertices(void* ptr, TriVertex3* vertices, int count); CGALWRAPPER_API BOOL Triangulation3_EEK_GetVertex(void* ptr, int index, TriVertex3& vertex); CGALWRAPPER_API void Triangulation3_EEK_GetCells(void* ptr, TriCell3* cells, int count); CGALWRAPPER_API BOOL Triangulation3_EEK_GetCell(void* ptr, int index, TriCell3& cell); CGALWRAPPER_API void Triangulation3_EEK_GetSegmentIndices(void* ptr, int* indices, int count); CGALWRAPPER_API void Triangulation3_EEK_GetTriangleIndices(void* ptr, int* indices, int count); CGALWRAPPER_API void Triangulation3_EEK_GetTetrahedraIndices(void* ptr, int* indices, int count); CGALWRAPPER_API void Triangulation3_EEK_GetSegments(void* ptr, Segment3d* segments, int count); CGALWRAPPER_API void Triangulation3_EEK_GetTriangles(void* ptr, Triangle3d* triangles, int count); CGALWRAPPER_API void Triangulation3_EEK_GetTetahedrons(void* ptr, Tetahedron3d* tetahedrons, int count); CGALWRAPPER_API void Triangulation3_EEK_Transform(void* ptr, const Matrix4x4d& matrix); } ================================================ FILE: CGALWrapper/Triangulations/TriangulationMap2.h ================================================ #pragma once #include "../CGALWrapper.h" #include "../Geometry/Geometry2.h" #include "../Collections/IndexMap.h" #include "CGAL/Point_2.h" #include #include #include #include #include /// /// A helper class to hold a triangulations faces and vertices /// by a int key value that represents their index in the triangulation. /// Infinite faces/vertices will have a index of -1 set and not be /// inculded in the map. /// /// The triangulations kernel type. /// The vertex type /// The face type. template class TriangulationMap2 { private: /// /// The map that holds the vertices. /// IndexMap vertexMap; /// /// The mape that holds the faces. /// IndexMap faceMap; /// /// A build stamp that is increment anytime the map changes. /// int buildStamp; public: TriangulationMap2() { } /// /// Get the current build stamp. /// /// int BuildStamp() { return buildStamp; } /// /// Increment the build stamp. /// void IncrementBuildStamp() { ++buildStamp; } /// /// Build the face and vertex maps /// if not already built. /// /// The triangulations type /// The triangulation. template void BuildMaps(TRI& model) { BuildVertexMap(model); BuildFaceMap(model); } /// /// Clear the maps to a empty state. /// void ClearMaps() { vertexMap.Clear(); faceMap.Clear(); } /// /// Call when the triangulation model has changed. /// Will mark the faces and vertex maps as needing /// to be updated. /// void OnModelChanged() { OnVerticesChanged(); OnFacesChanged(); } /// /// Call when the triangulation vertices have changed. /// void OnVerticesChanged() { buildStamp++; vertexMap.Clear(); } /// /// Call when th triangulation faces have changed. /// void OnFacesChanged() { buildStamp++; faceMap.Clear(); } /// /// Find the vertex by its key. /// /// The triangulation type. /// The triangulation. /// The vertices index key value. /// The vertex or null. template VERTEX* FindVertex(TRI& model, int index) { if (index == NULL_INDEX) return nullptr; SetVertexIndices(model); BuildVertexMap(model); return vertexMap.Find(index); } /// /// Find the face by its key. /// /// The triangulation type. /// The triangulation. /// The face index key value. /// The face or null. template FACE* FindFace(TRI& model, int index) { if (index == NULL_INDEX) return nullptr; SetFaceIndices(model); BuildFaceMap(model); return faceMap.Find(index); } /// /// Sets the indices of the vertices and faces. /// Infinite faces/vertices will have a index of /// -1 set and not be inculded in the map. /// /// The triangulation type. /// The triangulation model. template void SetIndices(TRI& model) { SetVertexIndices(model); SetFaceIndices(model); } /// /// Sets the indices of the vertices if they have not already been set. /// Infinite vertices will have a index of /// -1 set and not be inculded in the map. /// /// The triangulation type. /// The triangulation model. template void SetVertexIndices(TRI& model) { if (vertexMap.indicesSet) return; vertexMap.Clear(); model.infinite_vertex()->info() = NULL_INDEX; for (auto& vert : model.finite_vertex_handles()) { //If the vertices face is infinite then try and //find one of its other surrounding faces that is //finite and set that as the face. if (model.is_infinite(vert->face())) ResetFace(model, vert); vert->info() = vertexMap.NextIndex(); } vertexMap.indicesSet = true; } /// /// Build the vertex map by adding each vertex to the map /// using its index as the key. /// /// The triangulation type. /// The triangulation model. template void BuildVertexMap(TRI& model) { if (vertexMap.mapBuilt) return; vertexMap.ClearMap(); for (auto& vert : model.finite_vertex_handles()) vertexMap.Insert(vert->info(), vert); vertexMap.mapBuilt = true; } /// /// Sets the indices of the faces if they have not already been set. /// Infinite faces will have a index of /// -1 set and not be inculded in the map. /// /// The triangulation type. /// The triangulation model. template void SetFaceIndices(TRI& model) { if (faceMap.indicesSet) return; faceMap.Clear(); model.infinite_face()->info() = NULL_INDEX; for (auto& face : model.finite_face_handles()) face->info() = faceMap.NextIndex(); faceMap.indicesSet = true; } /// /// Set all the faces indices to the value. /// /// The triangulation type. /// The triangulation model. /// The faces index value to uses. template void ForceSetFaceIndices(TRI& model, int value) { faceMap.mapBuilt = false; for (auto& face : model.finite_face_handles()) face->info() = value; } /// /// Build the face map by adding each face to the map /// using its index as the key. /// /// The triangulation type. /// The triangulation model. template void BuildFaceMap(TRI& model) { if (faceMap.mapBuilt) return; faceMap.ClearMap(); for (auto& face : model.finite_face_handles()) faceMap.Insert(face->info(), face); faceMap.mapBuilt = true; } private: /// /// If the vertices face is infinite then try and /// find one of its other surrounding faces that is /// finite and set that as the face. /// /// The triangulation type. /// The triangulation model. /// The vertex to reset. template void ResetFace(const TRI& tri, VERTEX vert) { auto face = vert->face(); auto start = vert->incident_faces(face), end(start); if (start != nullptr) { do { if (!tri.is_infinite(start)) { vert->set_face(start); return; } } while (++start != end); } } }; ================================================ FILE: CGALWrapper/Utility/ArrayUtil.h ================================================ #pragma once #include "../CGALWrapper.h" namespace ArrayUtil { static void FillWithNull(int* indices, int count) { if (count <= 0) return; if (indices == nullptr) return; for (int i = 0; i < count; i++) indices[i] = NULL_INDEX; } static void MakeOutOfBoundsNull(int* indices, int count, int len) { if (count <= 0) return; if (indices == nullptr) return; for (int i = 0; i < count; i++) { if(indices[i] < NULL_INDEX || indices[i] >= len) indices[i] = NULL_INDEX; } } } ================================================ FILE: CGALWrapper/Utility/CGALGlobal.h ================================================ #pragma once #include "../Geometry/Geometry2.h" #include "../Geometry/Geometry3.h" template class CGALGlobal { private: typedef CGAL::Point_2 Point2; typedef CGAL::Vector_2 Vector2; typedef CGAL::Line_2 Line2; typedef CGAL::Line_3 Line3; typedef CGAL::Ray_2 Ray2; typedef CGAL::Segment_2 Segment2; typedef CGAL::Triangle_2 Triangle2; typedef CGAL::Iso_rectangle_2 Box2; typedef std::vector Polygon2; inline static CGAL::Vector_2* CastToVector2_EIK(void* ptr) { return static_cast*>(ptr); } inline static CGAL::Vector_2* CastToVector2_EEK(void* ptr) { return static_cast*>(ptr); } inline static CGAL::Vector_3* CastToVector3_EIK(void* ptr) { return static_cast*>(ptr); } inline static CGAL::Vector_3* CastToVector3_EEK(void* ptr) { return static_cast*>(ptr); } inline static CGAL::Point_2* CastToPoint2_EIK(void* ptr) { return static_cast*>(ptr); } inline static CGAL::Point_2* CastToPoint2_EEK(void* ptr) { return static_cast*>(ptr); } inline static CGAL::Point_3* CastToPoint3_EIK(void* ptr) { return static_cast*>(ptr); } inline static CGAL::Point_3* CastToPoint3_EEK(void* ptr) { return static_cast*>(ptr); } inline static CGAL::Line_2* CastToLine2_EIK(void* ptr) { return static_cast*>(ptr); } inline static CGAL::Line_2* CastToLine2_EEK(void* ptr) { return static_cast*>(ptr); } inline static CGAL::Ray_2* CastToRay2_EIK(void* ptr) { return static_cast*>(ptr); } inline static CGAL::Ray_2* CastToRay2_EEK(void* ptr) { return static_cast*>(ptr); } inline static CGAL::Segment_2* CastToSegment2_EIK(void* ptr) { return static_cast*>(ptr); } inline static CGAL::Segment_2* CastToSegment2_EEK(void* ptr) { return static_cast*>(ptr); } public: //---------------------------------------------------------------------------// // Angle // //---------------------------------------------------------------------------// static CGAL::Angle Angle_Vector2(Vector2d u, Vector2d v) { return CGAL::angle(u.ToCGAL(), v.ToCGAL()); } static CGAL::Angle Angle_EIK_Vector2(void* u, void* v) { auto U = CastToVector2_EIK(u); auto V = CastToVector2_EIK(v); return CGAL::angle(*U, *V); } static CGAL::Angle Angle_EEK_Vector2(void* u, void* v) { auto U = CastToVector2_EEK(u); auto V = CastToVector2_EEK(v); return CGAL::angle(*U, *V); } static CGAL::Angle Angle_Vector3(Vector3d u, Vector3d v) { return CGAL::angle(u.ToCGAL(), v.ToCGAL()); } //---------------------------------------------------------------------------// // ApproxAngle // //---------------------------------------------------------------------------// static double ApproxAngle_Vector3d(Vector3d u, Vector3d v) { auto d = CGAL::approximate_angle(u.ToCGAL(), v.ToCGAL()); return CGAL::to_double(d); } //---------------------------------------------------------------------------// // ApproxApproxAngle // //---------------------------------------------------------------------------// static double ApproxDihedralAngle(Point3d p, Point3d q, Point3d r, Point3d s) { auto d = CGAL::approximate_dihedral_angle(p.ToCGAL(), q.ToCGAL(), r.ToCGAL(), s.ToCGAL()); return CGAL::to_double(d); } //---------------------------------------------------------------------------// // AreOrderedAlongLine // //---------------------------------------------------------------------------// static BOOL AreOrderedAlongLine_Point2d(Point2d p, Point2d q, Point2d r) { return CGAL::are_ordered_along_line(p.ToCGAL(), q.ToCGAL(), r.ToCGAL()); } static BOOL AreOrderedAlongLine_EIK_Point2(void* p, void* q, void* r) { auto P = CastToPoint2_EIK(p); auto Q = CastToPoint2_EIK(q); auto R = CastToPoint2_EIK(r); return CGAL::are_ordered_along_line(*P, *Q, *R); } static BOOL AreOrderedAlongLine_EEK_Point2(void* p, void* q, void* r) { auto P = CastToPoint2_EEK(p); auto Q = CastToPoint2_EEK(q); auto R = CastToPoint2_EEK(r); return CGAL::are_ordered_along_line(*P, *Q, *R); } static BOOL AreOrderedAlongLine_Point3d(Point3d p, Point3d q, Point3d r) { return CGAL::are_ordered_along_line(p.ToCGAL(), q.ToCGAL(), r.ToCGAL()); } //---------------------------------------------------------------------------// // AreStrictlyOrderedAlongLine // //---------------------------------------------------------------------------// static BOOL AreStrictlyOrderedAlongLine_Point2d(Point2d p, Point2d q, Point2d r) { return CGAL::are_strictly_ordered_along_line(p.ToCGAL(), q.ToCGAL(), r.ToCGAL()); } static BOOL AreStrictlyOrderedAlongLine_EIK_Point2(void* p, void* q, void* r) { auto P = CastToPoint2_EIK(p); auto Q = CastToPoint2_EIK(q); auto R = CastToPoint2_EIK(r); return CGAL::are_strictly_ordered_along_line(*P, *Q, *R); } static BOOL AreStrictlyOrderedAlongLine_EEK_Point2(void* p, void* q, void* r) { auto P = CastToPoint2_EEK(p); auto Q = CastToPoint2_EEK(q); auto R = CastToPoint2_EEK(r); return CGAL::are_strictly_ordered_along_line(*P, *Q, *R); } static BOOL AreStrictlyOrderedAlongLine_Point3d(Point3d p, Point3d q, Point3d r) { return CGAL::are_strictly_ordered_along_line(p.ToCGAL(), q.ToCGAL(), r.ToCGAL()); } //---------------------------------------------------------------------------// // Collinear // //---------------------------------------------------------------------------// static BOOL Collinear_Point2d(Point2d p, Point2d q, Point2d r) { return CGAL::collinear(p.ToCGAL(), q.ToCGAL(), r.ToCGAL()); } static BOOL Collinear_EIK_Point2(void* p, void* q, void* r) { auto P = CastToPoint2_EIK(p); auto Q = CastToPoint2_EIK(q); auto R = CastToPoint2_EIK(r); return CGAL::collinear(*P, *Q, *R); } static BOOL Collinear_EEK_Point2(void* p, void* q, void* r) { auto P = CastToPoint2_EEK(p); auto Q = CastToPoint2_EEK(q); auto R = CastToPoint2_EEK(r); return CGAL::collinear(*P, *Q, *R); } static BOOL Collinear_Point3d(Point3d p, Point3d q, Point3d r) { return CGAL::collinear(p.ToCGAL(), q.ToCGAL(), r.ToCGAL()); } //---------------------------------------------------------------------------// // Barycenter // //---------------------------------------------------------------------------// static Point2d Barycenter_Point2d(Point2d p, Point2d q, Point2d r) { auto bc = CGAL::barycenter(p.ToCGAL(), 1, q.ToCGAL(), 1, r.ToCGAL(), 1); double x = CGAL::to_double(bc.x()); double y = CGAL::to_double(bc.y()); return { x, y }; } static void* Barycenter_EIK_Point2(void* p, void* q, void* r) { auto P = CastToPoint2_EIK(p); auto Q = CastToPoint2_EIK(q); auto R = CastToPoint2_EIK(r); auto bc = CGAL::barycenter(*P, 1, *Q, 1, *R, 1); return new CGAL::Point_2(bc.x(), bc.y()); } static void* Barycenter_EEK_Point2(void* p, void* q, void* r) { auto P = CastToPoint2_EEK(p); auto Q = CastToPoint2_EEK(q); auto R = CastToPoint2_EEK(r); auto bc = CGAL::barycenter(*P, 1, *Q, 1, *R, 1); return new CGAL::Point_2(bc.x(), bc.y()); } static Point3d Barycenter_Point3d(Point3d p, Point3d q, Point3d r) { auto bc = CGAL::barycenter(p.ToCGAL(), 1, q.ToCGAL(), 1, r.ToCGAL(), 1); double x = CGAL::to_double(bc.x()); double y = CGAL::to_double(bc.y()); double z = CGAL::to_double(bc.z()); return { x, y, z}; } //---------------------------------------------------------------------------// // Bisector // //---------------------------------------------------------------------------// static Line2d Bisector_Point3d(Point3d p, Point3d q) { auto l = CGAL::bisector(p.ToCGAL(), q.ToCGAL()); auto a = CGAL::to_double(l.a()); auto b = CGAL::to_double(l.b()); auto c = CGAL::to_double(l.c()); return { a, b, c }; } static Line2d Bisector_Line2d(Line2d p, Line2d q) { auto l = CGAL::bisector(p.ToCGAL(), q.ToCGAL()); auto a = CGAL::to_double(l.a()); auto b = CGAL::to_double(l.b()); auto c = CGAL::to_double(l.c()); return { a, b, c }; } static void* Bisector_EIK_Line2(void* p, void* q) { auto P = CastToLine2_EIK(p); auto Q = CastToLine2_EIK(q); auto l = CGAL::bisector(*P, *Q); return new CGAL::Line_2(l.a(), l.b(), l.c()); } static void* Bisector_EEK_Line2(void* p, void* q) { auto P = CastToLine2_EEK(p); auto Q = CastToLine2_EEK(q); auto l = CGAL::bisector(*P, *Q); return new CGAL::Line_2(l.a(), l.b(), l.c()); } //---------------------------------------------------------------------------// // Coplanar // //---------------------------------------------------------------------------// static BOOL Coplanar_Point3d(Point3d p, Point3d q, Point3d r, Point3d s) { return CGAL::coplanar(p.ToCGAL(), q.ToCGAL(), r.ToCGAL(), s.ToCGAL()); } //---------------------------------------------------------------------------// // CoplanarOrientation // //---------------------------------------------------------------------------// static CGAL::Orientation CoplanarOrientation_Point3d(Point3d p, Point3d q, Point3d r) { return CGAL::coplanar_orientation(p.ToCGAL(), q.ToCGAL(), r.ToCGAL()); } static CGAL::Orientation CoplanarOrientation_Point3d(Point3d p, Point3d q, Point3d r, Point3d s) { return CGAL::coplanar_orientation(p.ToCGAL(), q.ToCGAL(), r.ToCGAL(), s.ToCGAL()); } //---------------------------------------------------------------------------// // EquidistantLine // //---------------------------------------------------------------------------// static Line3d EquidistantLine_Point3d(Point3d p, Point3d q, Point3d r) { auto l = CGAL::equidistant_line(p.ToCGAL(), q.ToCGAL(), r.ToCGAL()); return Line3d::FromCGAL(l.point(), l.to_vector()); } //---------------------------------------------------------------------------// // LeftTurn // //---------------------------------------------------------------------------// static BOOL LeftTurn_Point2d(Point2d p, Point2d q, Point2d r) { return CGAL::left_turn(p.ToCGAL(), q.ToCGAL(), r.ToCGAL()); } static BOOL LeftTurn_EIK_Point2(void* p, void* q, void* r) { auto P = CastToPoint2_EIK(p); auto Q = CastToPoint2_EIK(q); auto R = CastToPoint2_EIK(r); return CGAL::left_turn(*P, *Q, *R); } static BOOL LeftTurn_EEK_Point2(void* p, void* q, void* r) { auto P = CastToPoint2_EEK(p); auto Q = CastToPoint2_EEK(q); auto R = CastToPoint2_EEK(r); return CGAL::left_turn(*P, *Q, *R); } //---------------------------------------------------------------------------// // RightTurn // //---------------------------------------------------------------------------// static BOOL RightTurn_Point2d(Point2d p, Point2d q, Point2d r) { return CGAL::right_turn(p.ToCGAL(), q.ToCGAL(), r.ToCGAL()); } static BOOL RightTurn_EIK_Point2(void* p, void* q, void* r) { auto P = CastToPoint2_EIK(p); auto Q = CastToPoint2_EIK(q); auto R = CastToPoint2_EIK(r); return CGAL::right_turn(*P, *Q, *R); } static BOOL RightTurn_EEK_Point2(void* p, void* q, void* r) { auto P = CastToPoint2_EEK(p); auto Q = CastToPoint2_EEK(q); auto R = CastToPoint2_EEK(r); return CGAL::right_turn(*P, *Q, *R); } //---------------------------------------------------------------------------// // Orientation // //---------------------------------------------------------------------------// static CGAL::Orientation Orientation_Point2d(Point2d p, Point2d q, Point2d r) { return CGAL::orientation(p.ToCGAL(), q.ToCGAL(), r.ToCGAL()); } static CGAL::Orientation Orientation_EIK_Point2(void* p, void* q, void* r) { auto P = CastToPoint2_EIK(p); auto Q = CastToPoint2_EIK(q); auto R = CastToPoint2_EIK(r); return CGAL::orientation(*P, *Q, *R); } static CGAL::Orientation Orientation_EEK_Point2(void* p, void* q, void* r) { auto P = CastToPoint2_EEK(p); auto Q = CastToPoint2_EEK(q); auto R = CastToPoint2_EEK(r); return CGAL::orientation(*P, *Q, *R); } static CGAL::Orientation Orientation_Vector2d(Vector2d u, Vector2d v) { return CGAL::orientation(u.ToCGAL(), v.ToCGAL()); } static CGAL::Orientation Orientation_EIK_Vector2(void* p, void* q) { auto P = CastToVector2_EIK(p); auto Q = CastToVector2_EIK(q); return CGAL::orientation(*P, *Q); } static CGAL::Orientation Orientation_EEK_Vector2(void* p, void* q) { auto P = CastToVector2_EEK(p); auto Q = CastToVector2_EEK(q); return CGAL::orientation(*P, *Q); } static CGAL::Orientation Orientation_Point3d(Point3d p, Point3d q, Point3d r, Point3d s) { return CGAL::orientation(p.ToCGAL(), q.ToCGAL(), r.ToCGAL(), s.ToCGAL()); } static CGAL::Orientation Orientation_Vector3d(Vector3d u, Vector3d v, Vector3d w) { return CGAL::orientation(u.ToCGAL(), v.ToCGAL(), w.ToCGAL()); } //---------------------------------------------------------------------------// // OrthogonalVector // //---------------------------------------------------------------------------// static Vector3d OrthogonalVector_Point3d(Point3d p, Point3d q, Point3d r) { auto v = CGAL::orthogonal_vector(p.ToCGAL(), q.ToCGAL(), r.ToCGAL()); return Vector3d::FromCGAL(v); } static void* OrthogonalVector_EIK_Point3(void* p, void* q, void* r) { auto P = CastToPoint3_EIK(p); auto Q = CastToPoint3_EIK(q); auto R = CastToPoint3_EIK(r); auto v = CGAL::orthogonal_vector(*P, *Q, *R); return new CGAL::Vector_3(v.x(), v.y(), v.z()); } static void* OrthogonalVector_EEK_Point3(void* p, void* q, void* r) { auto P = CastToPoint3_EEK(p); auto Q = CastToPoint3_EEK(q); auto R = CastToPoint3_EEK(r); auto v = CGAL::orthogonal_vector(*P, *Q, *R); return new CGAL::Vector_3(v.x(), v.y(), v.z()); } //---------------------------------------------------------------------------// // Parallel // //---------------------------------------------------------------------------// static BOOL Parallel_Line2d(Line2d l1, Line2d l2) { auto L1 = l1.ToCGAL(); auto L2 = l2.ToCGAL(); return CGAL::parallel(L1, L2); } static BOOL Parallel_EIK_Line2d(void* l1, void* l2) { auto L1 = CastToLine2_EIK(l1); auto L2 = CastToLine2_EIK(l2); return CGAL::parallel(*L1, *L2); } static BOOL Parallel_EEK_Line2d(void* l1, void* l2) { auto L1 = CastToLine2_EEK(l1); auto L2 = CastToLine2_EEK(l2); return CGAL::parallel(*L1, *L2); } static BOOL Parallel_Ray2d(Ray2d r1, Ray2d r2) { auto R1 = r1.ToCGAL(); auto R2 = r2.ToCGAL(); return CGAL::parallel(R1, R2); } static BOOL Parallel_EIK_Ray2d(void* r1, void* r2) { auto R1 = CastToRay2_EIK(r1); auto R2 = CastToRay2_EIK(r2); return CGAL::parallel(*R1, *R2); } static BOOL Parallel_EEK_Ray2d(void* r1, void* r2) { auto R1 = CastToRay2_EEK(r1); auto R2 = CastToRay2_EEK(r2); return CGAL::parallel(*R1, *R2); } static BOOL Parallel_Segment2d(Segment2d s1, Segment2d s2) { auto S1 = s1.ToCGAL(); auto S2 = s2.ToCGAL(); return CGAL::parallel(S1, S2); } static BOOL Parallel_EIK_Segment2d(void* s1, void* s2) { auto S1 = CastToSegment2_EIK(s1); auto S2 = CastToSegment2_EIK(s2); return CGAL::parallel(*S1, *S2); } static BOOL Parallel_EEK_Segment2d(void* s1, void* s2) { auto S1 = CastToSegment2_EEK(s1); auto S2 = CastToSegment2_EEK(s2); return CGAL::parallel(*S1, *S2); } }; ================================================ FILE: CGALWrapper/Utility/CGALGlobal_EIK_EEK.cpp ================================================ #include "../pch.h" #include "CGALGlobal_EIK_EEK.h" #include "CGALGlobal.h" #include "../Geometry/Geometry2.h" #include "../Geometry/Geometry3.h" //---------------------------------------------------------------------------// // Angle // //---------------------------------------------------------------------------// CGAL::Angle CGALGlobal_EIK_Angle_Vector2d(Vector2d u, Vector2d v) { return CGALGlobal::Angle_Vector2(u, v); } CGAL::Angle CGALGlobal_EIK_Angle_Vector2(void* u, void* v) { return CGALGlobal::Angle_EIK_Vector2(u, v); } CGAL::Angle CGALGlobal_EEK_Angle_Vector2(void* u, void* v) { return CGALGlobal::Angle_EEK_Vector2(u, v); } CGAL::Angle CGALGlobal_EIK_Angle_Vector3d(Vector3d u, Vector3d v) { return CGALGlobal::Angle_Vector3(u, v); } //---------------------------------------------------------------------------// // ApproxAngle // //---------------------------------------------------------------------------// double CGALGlobal_EIK_ApproxAngle_Vector3d(Vector3d u, Vector3d v) { return CGALGlobal::ApproxAngle_Vector3d(u, v); } //---------------------------------------------------------------------------// // ApproxDihedralAngle // //---------------------------------------------------------------------------// double CGALGlobal_EIK_ApproxDihedralAngle_Point3(Point3d p, Point3d q, Point3d r, Point3d s) { return CGALGlobal::ApproxDihedralAngle(p, q, r, s); } //---------------------------------------------------------------------------// // AreOrderedAlongLine // //---------------------------------------------------------------------------// BOOL CGALGlobal_EIK_AreOrderedAlongLine_Point2d(Point2d p, Point2d q, Point2d r) { return CGALGlobal::AreOrderedAlongLine_Point2d(p, q, r); } BOOL CGALGlobal_EIK_AreOrderedAlongLine_Point2(void* p, void* q, void* r) { return CGALGlobal::AreOrderedAlongLine_EIK_Point2(p, q, r); } BOOL CGALGlobal_EEK_AreOrderedAlongLine_Point2(void* p, void* q, void* r) { return CGALGlobal::AreOrderedAlongLine_EEK_Point2(p, q, r); } BOOL CGALGlobal_EIK_AreOrderedAlongLine_Point3d(Point3d p, Point3d q, Point3d r) { return CGALGlobal::AreOrderedAlongLine_Point3d(p, q, r); } //---------------------------------------------------------------------------// // AreStrictlyOrderedAlongLine // //---------------------------------------------------------------------------// BOOL CGALGlobal_EIK_AreStrictlyOrderedAlongLine_Point2d(Point2d p, Point2d q, Point2d r) { return CGALGlobal::AreStrictlyOrderedAlongLine_Point2d(p, q, r); } BOOL CGALGlobal_EIK_AreStrictlyOrderedAlongLine_Point2(void* p, void* q, void* r) { return CGALGlobal::AreStrictlyOrderedAlongLine_EIK_Point2(p, q, r); } BOOL CGALGlobal_EEK_AreStrictlyOrderedAlongLine_Point2(void* p, void* q, void* r) { return CGALGlobal::AreStrictlyOrderedAlongLine_EEK_Point2(p, q, r); } BOOL CGALGlobal_EIK_AreStrictlyOrderedAlongLine_Point3d(Point3d p, Point3d q, Point3d r) { return CGALGlobal::AreStrictlyOrderedAlongLine_Point3d(p, q, r); } //---------------------------------------------------------------------------// // Collinear // //---------------------------------------------------------------------------// BOOL CGALGlobal_EIK_Collinear_Point2d(Point2d p, Point2d q, Point2d r) { return CGALGlobal::Collinear_Point2d(p, q, r); } BOOL CGALGlobal_EIK_Collinear_Point2(void* p, void* q, void* r) { return CGALGlobal::Collinear_EIK_Point2(p, q, r); } BOOL CGALGlobal_EEK_Collinear_Point2(void* p, void* q, void* r) { return CGALGlobal::Collinear_EEK_Point2(p, q, r); } BOOL CGALGlobal_EIK_Collinear_Point3d(Point3d p, Point3d q, Point3d r) { return CGALGlobal::Collinear_Point3d(p, q, r); } //---------------------------------------------------------------------------// // Barycenter // //---------------------------------------------------------------------------// Point2d CGALGlobal_EIK_Barycenter_Point2d(Point2d p, Point2d q, Point2d r) { return CGALGlobal::Barycenter_Point2d(p, q, r); } void* CGALGlobal_EIK_Barycenter_Point2(void* p, void* q, void* r) { return CGALGlobal::Barycenter_EIK_Point2(p, q, r); } void* CGALGlobal_EEK_Barycenter_Point2(void* p, void* q, void* r) { return CGALGlobal::Barycenter_EEK_Point2(p, q, r); } Point3d CGALGlobal_EIK_Barycenter_Point3d(Point3d p, Point3d q, Point3d r) { return CGALGlobal::Barycenter_Point3d(p, q, r); } //---------------------------------------------------------------------------// // Bisector // //---------------------------------------------------------------------------// Line2d CGALGlobal_EIK_Bisector_Point3d(Point3d p, Point3d q) { return CGALGlobal::Bisector_Point3d(p, q); } Line2d CGALGlobal_EIK_Bisector_Line2d(Line2d p, Line2d q) { return CGALGlobal::Bisector_Line2d(p, q); } void* CGALGlobal_EIK_Bisector_Line2(void* p, void* q) { return CGALGlobal::Bisector_EIK_Line2(p, q); } void* CGALGlobal_EEK_Bisector_Line2(void* p, void* q) { return CGALGlobal::Bisector_EEK_Line2(p, q); } //---------------------------------------------------------------------------// // Coplanar // //---------------------------------------------------------------------------// BOOL CGALGlobal_EIK_Coplanar_Point3d(Point3d p, Point3d q, Point3d r, Point3d s) { return CGALGlobal::Coplanar_Point3d(p, q, r, s); } //---------------------------------------------------------------------------// // CoplanarOrientation // //---------------------------------------------------------------------------// CGAL::Orientation CGALGlobal_EIK_CoplanarOrientation_3Point3d(Point3d p, Point3d q, Point3d r) { return CGALGlobal::CoplanarOrientation_Point3d(p, q, r); } CGAL::Orientation CGALGlobal_EIK_CoplanarOrientation_4Point3d(Point3d p, Point3d q, Point3d r, Point3d s) { return CGALGlobal::CoplanarOrientation_Point3d(p, q, r, s); } //---------------------------------------------------------------------------// // EquidistantLine // //---------------------------------------------------------------------------// Line3d CGALGlobal_EIK_EquidistantLine_Line3d(Point3d p, Point3d q, Point3d r) { return CGALGlobal::EquidistantLine_Point3d(p, q, r); } //---------------------------------------------------------------------------// // LeftTurn // //---------------------------------------------------------------------------// BOOL CGALGlobal_EIK_LeftTurn_Point2d(Point2d p, Point2d q, Point2d r) { return CGALGlobal::LeftTurn_Point2d(p, q, r); } BOOL CGALGlobal_EIK_LeftTurn_Point2(void* p, void* q, void* r) { return CGALGlobal::LeftTurn_EIK_Point2(p, q, r); } BOOL CGALGlobal_EEK_LeftTurn_Point2(void* p, void* q, void* r) { return CGALGlobal::LeftTurn_EEK_Point2(p, q, r); } //---------------------------------------------------------------------------// // RightTurn // //---------------------------------------------------------------------------// BOOL CGALGlobal_EIK_RightTurn_Point2d(Point2d p, Point2d q, Point2d r) { return CGALGlobal::RightTurn_Point2d(p, q, r); } BOOL CGALGlobal_EIK_RightTurn_Point2(void* p, void* q, void* r) { return CGALGlobal::RightTurn_EIK_Point2(p, q, r); } BOOL CGALGlobal_EEK_RightTurn_Point2(void* p, void* q, void* r) { return CGALGlobal::RightTurn_EEK_Point2(p, q, r); } //---------------------------------------------------------------------------// // Orientation // //---------------------------------------------------------------------------// CGAL::Orientation CGALGlobal_EIK_Orientation_Point2d(Point2d p, Point2d q, Point2d r) { return CGALGlobal::Orientation_Point2d(p, q, r); } CGAL::Orientation CGALGlobal_EIK_Orientation_Point2(void* p, void* q, void* r) { return CGALGlobal::Orientation_EIK_Point2(p, q, r); } CGAL::Orientation CGALGlobal_EEK_Orientation_Point2(void* p, void* q, void* r) { return CGALGlobal::Orientation_EEK_Point2(p, q, r); } CGAL::Orientation CGALGlobal_EIK_Orientation_Vector2d(Vector2d u, Vector2d v) { return CGALGlobal::Orientation_Vector2d(u, v); } CGAL::Orientation CGALGlobal_EIK_Orientation_Vector2(void* p, void* q) { return CGALGlobal::Orientation_EIK_Vector2(p, q); } CGAL::Orientation CGALGlobal_EEK_Orientation_Vector2(void* p, void* q) { return CGALGlobal::Orientation_EEK_Vector2(p, q); } CGAL::Orientation CGALGlobal_EIK_Orientation_Point3d(Point3d p, Point3d q, Point3d r, Point3d s) { return CGALGlobal::Orientation_Point3d(p, q, r, s); } CGAL::Orientation CGALGlobal_EIK_Orientation_Vector3d(Vector3d u, Vector3d v, Vector3d w) { return CGALGlobal::Orientation_Vector3d(u, v, w); } //---------------------------------------------------------------------------// // OrthogonalVector // //---------------------------------------------------------------------------// Vector3d CGALGlobal_EIK_OrthogonalVector_Point3d(Point3d p, Point3d q, Point3d r) { return CGALGlobal::OrthogonalVector_Point3d(p, q, r); } void* CGALGlobal_EIK_OrthogonalVector_Point3(void* p, void* q, void* r) { return CGALGlobal::OrthogonalVector_EIK_Point3(p, q, r); } void* CGALGlobal_EEK_OrthogonalVector_Point3(void* p, void* q, void* r) { return CGALGlobal::OrthogonalVector_EEK_Point3(p, q, r); } //---------------------------------------------------------------------------// // Parallel // //---------------------------------------------------------------------------// BOOL CGALGlobal_EIK_Parallel_Line2d(Line2d l1, Line2d l2) { return CGALGlobal::Parallel_Line2d(l1, l2); } BOOL CGALGlobal_EIK_Parallel_Line2(void* l1, void* l2) { return CGALGlobal::Parallel_EIK_Line2d(l1, l2); } BOOL CGALGlobal_EEK_Parallel_Line2(void* l1, void* l2) { return CGALGlobal::Parallel_EEK_Line2d(l1, l2); } BOOL CGALGlobal_EIK_Parallel_Ray2d(Ray2d r1, Ray2d r2) { return CGALGlobal::Parallel_Ray2d(r1, r2); } BOOL CGALGlobal_EIK_Parallel_Ray2(void* r1, void* r2) { return CGALGlobal::Parallel_EIK_Ray2d(r1, r2); } BOOL CGALGlobal_EEK_Parallel_Ray2(void* r1, void* r2) { return CGALGlobal::Parallel_EEK_Ray2d(r1, r2); } BOOL CGALGlobal_EIK_Parallel_Segment2d(Segment2d s1, Segment2d s2) { return CGALGlobal::Parallel_Segment2d(s1, s2); } BOOL CGALGlobal_EIK_Parallel_Segment2(void* s1, void* s2) { return CGALGlobal::Parallel_EIK_Segment2d(s1, s2); } BOOL CGALGlobal_EEK_Parallel_Segment2(void* s1, void* s2) { return CGALGlobal::Parallel_EEK_Segment2d(s1, s2); } ================================================ FILE: CGALWrapper/Utility/CGALGlobal_EIK_EEK.h ================================================ #pragma once #include "../CGALWrapper.h" #include "../Geometry/Geometry2.h" #include "../Geometry/Geometry3.h" #include "CGALGlobal.h" #include extern "C" { //---------------------------------------------------------------------------// // Angle // //---------------------------------------------------------------------------// CGALWRAPPER_API CGAL::Angle CGALGlobal_EIK_Angle_Vector2d(Vector2d u, Vector2d v); CGALWRAPPER_API CGAL::Angle CGALGlobal_EIK_Angle_Vector2(void* u, void* v); CGALWRAPPER_API CGAL::Angle CGALGlobal_EEK_Angle_Vector2(void* u, void* v); CGALWRAPPER_API CGAL::Angle CGALGlobal_EIK_Angle_Vector3d(Vector3d u, Vector3d v); //---------------------------------------------------------------------------// // ApproxAngle // //---------------------------------------------------------------------------// CGALWRAPPER_API double CGALGlobal_EIK_ApproxAngle_Vector3d(Vector3d u, Vector3d v); //---------------------------------------------------------------------------// // ApproxDihedralAngle // //---------------------------------------------------------------------------// CGALWRAPPER_API double CGALGlobal_EIK_ApproxDihedralAngle_Point3(Point3d p, Point3d q, Point3d r, Point3d s); //---------------------------------------------------------------------------// // AreOrderedAlongLine // //---------------------------------------------------------------------------// CGALWRAPPER_API BOOL CGALGlobal_EIK_AreOrderedAlongLine_Point2d(Point2d p, Point2d q, Point2d r); CGALWRAPPER_API BOOL CGALGlobal_EIK_AreOrderedAlongLine_Point2(void* p, void* q, void* r); CGALWRAPPER_API BOOL CGALGlobal_EEK_AreOrderedAlongLine_Point2(void* p, void* q, void* r); CGALWRAPPER_API BOOL CGALGlobal_EIK_AreOrderedAlongLine_Point3d(Point3d p, Point3d q, Point3d r); //---------------------------------------------------------------------------// // AreStrictlyOrderedAlongLine // //---------------------------------------------------------------------------// CGALWRAPPER_API BOOL CGALGlobal_EIK_AreStrictlyOrderedAlongLine_Point2d(Point2d p, Point2d q, Point2d r); CGALWRAPPER_API BOOL CGALGlobal_EIK_AreStrictlyOrderedAlongLine_Point2(void* p, void* q, void* r); CGALWRAPPER_API BOOL CGALGlobal_EEK_AreStrictlyOrderedAlongLine_Point2(void* p, void* q, void* r); CGALWRAPPER_API BOOL CGALGlobal_EIK_AreStrictlyOrderedAlongLine_Point3d(Point3d p, Point3d q, Point3d r); //---------------------------------------------------------------------------// // Collinear // //---------------------------------------------------------------------------// CGALWRAPPER_API BOOL CGALGlobal_EIK_Collinear_Point2d(Point2d p, Point2d q, Point2d r); CGALWRAPPER_API BOOL CGALGlobal_EIK_Collinear_Point2(void* p, void* q, void* r); CGALWRAPPER_API BOOL CGALGlobal_EEK_Collinear_Point2(void* p, void* q, void* r); CGALWRAPPER_API BOOL CGALGlobal_EIK_Collinear_Point3d(Point3d p, Point3d q, Point3d r); //---------------------------------------------------------------------------// // Barycenter // //---------------------------------------------------------------------------// CGALWRAPPER_API Point2d CGALGlobal_EIK_Barycenter_Point2d(Point2d p, Point2d q, Point2d r); CGALWRAPPER_API void* CGALGlobal_EIK_Barycenter_Point2(void* p, void* q, void* r); CGALWRAPPER_API void* CGALGlobal_EEK_Barycenter_Point2(void* p, void* q, void* r); CGALWRAPPER_API Point3d CGALGlobal_EIK_Barycenter_Point3d(Point3d p, Point3d q, Point3d r); //---------------------------------------------------------------------------// // Bisector // //---------------------------------------------------------------------------// CGALWRAPPER_API Line2d CGALGlobal_EIK_Bisector_Point3d(Point3d p, Point3d q); CGALWRAPPER_API Line2d CGALGlobal_EIK_Bisector_Line2d(Line2d p, Line2d q); CGALWRAPPER_API void* CGALGlobal_EIK_Bisector_Line2(void* p, void* q); CGALWRAPPER_API void* CGALGlobal_EEK_Bisector_Line2(void* p, void* q); //---------------------------------------------------------------------------// // Coplanar // //---------------------------------------------------------------------------// CGALWRAPPER_API BOOL CGALGlobal_EIK_Coplanar_Point3d(Point3d p, Point3d q, Point3d r, Point3d s); //---------------------------------------------------------------------------// // CoplanarOrientation // //---------------------------------------------------------------------------// CGALWRAPPER_API CGAL::Orientation CGALGlobal_EIK_CoplanarOrientation_3Point3d(Point3d p, Point3d q, Point3d r); CGALWRAPPER_API CGAL::Orientation CGALGlobal_EIK_CoplanarOrientation_4Point3d(Point3d p, Point3d q, Point3d r, Point3d s); //---------------------------------------------------------------------------// // EquidistantLine // //---------------------------------------------------------------------------// CGALWRAPPER_API Line3d CGALGlobal_EIK_EquidistantLine_Line3d(Point3d p, Point3d q, Point3d r); //---------------------------------------------------------------------------// // LeftTurn // //---------------------------------------------------------------------------// CGALWRAPPER_API BOOL CGALGlobal_EIK_LeftTurn_Point2d(Point2d p, Point2d q, Point2d r); CGALWRAPPER_API BOOL CGALGlobal_EIK_LeftTurn_Point2(void* p, void* q, void* r); CGALWRAPPER_API BOOL CGALGlobal_EEK_LeftTurn_Point2(void* p, void* q, void* r); //---------------------------------------------------------------------------// // RightTurn // //---------------------------------------------------------------------------// CGALWRAPPER_API BOOL CGALGlobal_EIK_RightTurn_Point2d(Point2d p, Point2d q, Point2d r); CGALWRAPPER_API BOOL CGALGlobal_EIK_RightTurn_Point2(void* p, void* q, void* r); CGALWRAPPER_API BOOL CGALGlobal_EEK_RightTurn_Point2(void* p, void* q, void* r); //---------------------------------------------------------------------------// // Orientation // //---------------------------------------------------------------------------// CGALWRAPPER_API CGAL::Orientation CGALGlobal_EIK_Orientation_Point2d(Point2d p, Point2d q, Point2d r); CGALWRAPPER_API CGAL::Orientation CGALGlobal_EIK_Orientation_Point2(void* p, void* q, void* r); CGALWRAPPER_API CGAL::Orientation CGALGlobal_EEK_Orientation_Point2(void* p, void* q, void* r); CGALWRAPPER_API CGAL::Orientation CGALGlobal_EIK_Orientation_Vector2d(Vector2d u, Vector2d v); CGALWRAPPER_API CGAL::Orientation CGALGlobal_EIK_Orientation_Vector2(void* p, void* q); CGALWRAPPER_API CGAL::Orientation CGALGlobal_EEK_Orientation_Vector2(void* p, void* q); CGALWRAPPER_API CGAL::Orientation CGALGlobal_EIK_Orientation_Point3d(Point3d p, Point3d q, Point3d r, Point3d s); CGALWRAPPER_API CGAL::Orientation CGALGlobal_EIK_Orientation_Vector3d(Vector3d u, Vector3d v, Vector3d w); //---------------------------------------------------------------------------// // OrthogonalVector // //---------------------------------------------------------------------------// CGALWRAPPER_API Vector3d CGALGlobal_EIK_OrthogonalVector_Point3d(Point3d p, Point3d q, Point3d r); CGALWRAPPER_API void* CGALGlobal_EIK_OrthogonalVector_Point3(void* p, void* q, void* r); CGALWRAPPER_API void* CGALGlobal_EEK_OrthogonalVector_Point3(void* p, void* q, void* r); //---------------------------------------------------------------------------// // Parallel // //---------------------------------------------------------------------------// CGALWRAPPER_API BOOL CGALGlobal_EIK_Parallel_Line2d(Line2d l1, Line2d l2); CGALWRAPPER_API BOOL CGALGlobal_EIK_Parallel_Line2(void* l1, void* l2); CGALWRAPPER_API BOOL CGALGlobal_EEK_Parallel_Line2(void* l1, void* l2); CGALWRAPPER_API BOOL CGALGlobal_EIK_Parallel_Ray2d(Ray2d r1, Ray2d r2); CGALWRAPPER_API BOOL CGALGlobal_EIK_Parallel_Ray2(void* r1, void* r2); CGALWRAPPER_API BOOL CGALGlobal_EEK_Parallel_Ray2(void* r1, void* r2); CGALWRAPPER_API BOOL CGALGlobal_EIK_Parallel_Segment2d(Segment2d s1, Segment2d s2); CGALWRAPPER_API BOOL CGALGlobal_EIK_Parallel_Segment2(void* s1, void* s2); CGALWRAPPER_API BOOL CGALGlobal_EEK_Parallel_Segment2(void* s1, void* s2); } ================================================ FILE: CGALWrapper/Utility/VersionNumber.cpp ================================================ #include "VersionNumber.h" #include "Eigen\src\Core\util\Macros.h" int CGALGlobal_VersionNumber() { return CGAL_VERSION_NR; //CGAL_VERSION_MAJOR (CGAL_VERSION_NR/10000000%100) //CGAL_VERSION_MINOR (CGAL_VERSION_NR/100000%100) //CGAL_VERSION_PATCH (CGAL_VERSION_NR/10000%10) // CGAL_VERSION_BUILD (CGAL_VERSION_NR%10000) //CGAL_VERSION_NUMBER(M, m, b) //CGAL_VERSION_NUMBER(x, y, z) (1000001 + 10000 * x + 100 * y + 10 * z) * 1000 } Index3 CGALGlobal_EigenVersionNumber() { return { EIGEN_WORLD_VERSION, EIGEN_MAJOR_VERSION , EIGEN_MINOR_VERSION }; } ================================================ FILE: CGALWrapper/Utility/VersionNumber.h ================================================ #pragma once #include "../CGALWrapper.h" #include "../Geometry/Index.h" extern "C" { CGALWRAPPER_API int CGALGlobal_VersionNumber(); CGALWRAPPER_API Index3 CGALGlobal_EigenVersionNumber(); } ================================================ FILE: CGALWrapper/framework.h ================================================ #pragma once #define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers // Windows Header Files #include #undef max #undef min ================================================ FILE: CGALWrapper/pch.cpp ================================================ // pch.cpp: source file corresponding to the pre-compiled header #include "pch.h" // When you are using pre-compiled headers, this source file is necessary for compilation to succeed. ================================================ FILE: CGALWrapper/pch.h ================================================ // pch.h: This is a precompiled header file. // Files listed below are compiled only once, improving build performance for future builds. // This also affects IntelliSense performance, including code completion and many code browsing features. // However, files listed here are ALL re-compiled if any one of them is updated between builds. // Do not add files here that you will be updating frequently as this negates the performance advantage. #ifndef PCH_H #define PCH_H // add headers that you want to pre-compile here #include "framework.h" #endif //PCH_H ================================================ FILE: CGALWrapper/resource.h ================================================ //{{NO_DEPENDENCIES}} // Microsoft Visual C++ generated include file. // Used by CGALWrapper.rc // Next default values for new objects // #ifdef APSTUDIO_INVOKED #ifndef APSTUDIO_READONLY_SYMBOLS #define _APS_NEXT_RESOURCE_VALUE 101 #define _APS_NEXT_COMMAND_VALUE 40001 #define _APS_NEXT_CONTROL_VALUE 1001 #define _APS_NEXT_SYMED_VALUE 101 #endif #endif ================================================ FILE: LICENSE ================================================ GNU GENERAL PUBLIC LICENSE Version 3, 29 June 2007 Copyright (C) 2007 Free Software Foundation, Inc. Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The GNU General Public License is a free, copyleft license for software and other kinds of works. The licenses for most software and other practical works are designed to take away your freedom to share and change the works. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change all versions of a program--to make sure it remains free software for all its users. We, the Free Software Foundation, use the GNU General Public License for most of our software; it applies also to any other work released this way by its authors. You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for them if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs, and that you know you can do these things. To protect your rights, we need to prevent others from denying you these rights or asking you to surrender the rights. Therefore, you have certain responsibilities if you distribute copies of the software, or if you modify it: responsibilities to respect the freedom of others. For example, if you distribute copies of such a program, whether gratis or for a fee, you must pass on to the recipients the same freedoms that you received. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. Developers that use the GNU GPL protect your rights with two steps: (1) assert copyright on the software, and (2) offer you this License giving you legal permission to copy, distribute and/or modify it. For the developers' and authors' protection, the GPL clearly explains that there is no warranty for this free software. For both users' and authors' sake, the GPL requires that modified versions be marked as changed, so that their problems will not be attributed erroneously to authors of previous versions. Some devices are designed to deny users access to install or run modified versions of the software inside them, although the manufacturer can do so. This is fundamentally incompatible with the aim of protecting users' freedom to change the software. The systematic pattern of such abuse occurs in the area of products for individuals to use, which is precisely where it is most unacceptable. Therefore, we have designed this version of the GPL to prohibit the practice for those products. If such problems arise substantially in other domains, we stand ready to extend this provision to those domains in future versions of the GPL, as needed to protect the freedom of users. Finally, every program is threatened constantly by software patents. States should not allow patents to restrict development and use of software on general-purpose computers, but in those that do, we wish to avoid the special danger that patents applied to a free program could make it effectively proprietary. To prevent this, the GPL assures that patents cannot be used to render the program non-free. The precise terms and conditions for copying, distribution and modification follow. TERMS AND CONDITIONS 0. Definitions. "This License" refers to version 3 of the GNU General Public License. "Copyright" also means copyright-like laws that apply to other kinds of works, such as semiconductor masks. "The Program" refers to any copyrightable work licensed under this License. Each licensee is addressed as "you". "Licensees" and "recipients" may be individuals or organizations. To "modify" a work means to copy from or adapt all or part of the work in a fashion requiring copyright permission, other than the making of an exact copy. The resulting work is called a "modified version" of the earlier work or a work "based on" the earlier work. A "covered work" means either the unmodified Program or a work based on the Program. To "propagate" a work means to do anything with it that, without permission, would make you directly or secondarily liable for infringement under applicable copyright law, except executing it on a computer or modifying a private copy. Propagation includes copying, distribution (with or without modification), making available to the public, and in some countries other activities as well. To "convey" a work means any kind of propagation that enables other parties to make or receive copies. Mere interaction with a user through a computer network, with no transfer of a copy, is not conveying. An interactive user interface displays "Appropriate Legal Notices" to the extent that it includes a convenient and prominently visible feature that (1) displays an appropriate copyright notice, and (2) tells the user that there is no warranty for the work (except to the extent that warranties are provided), that licensees may convey the work under this License, and how to view a copy of this License. If the interface presents a list of user commands or options, such as a menu, a prominent item in the list meets this criterion. 1. Source Code. The "source code" for a work means the preferred form of the work for making modifications to it. "Object code" means any non-source form of a work. A "Standard Interface" means an interface that either is an official standard defined by a recognized standards body, or, in the case of interfaces specified for a particular programming language, one that is widely used among developers working in that language. The "System Libraries" of an executable work include anything, other than the work as a whole, that (a) is included in the normal form of packaging a Major Component, but which is not part of that Major Component, and (b) serves only to enable use of the work with that Major Component, or to implement a Standard Interface for which an implementation is available to the public in source code form. A "Major Component", in this context, means a major essential component (kernel, window system, and so on) of the specific operating system (if any) on which the executable work runs, or a compiler used to produce the work, or an object code interpreter used to run it. The "Corresponding Source" for a work in object code form means all the source code needed to generate, install, and (for an executable work) run the object code and to modify the work, including scripts to control those activities. However, it does not include the work's System Libraries, or general-purpose tools or generally available free programs which are used unmodified in performing those activities but which are not part of the work. For example, Corresponding Source includes interface definition files associated with source files for the work, and the source code for shared libraries and dynamically linked subprograms that the work is specifically designed to require, such as by intimate data communication or control flow between those subprograms and other parts of the work. The Corresponding Source need not include anything that users can regenerate automatically from other parts of the Corresponding Source. The Corresponding Source for a work in source code form is that same work. 2. Basic Permissions. All rights granted under this License are granted for the term of copyright on the Program, and are irrevocable provided the stated conditions are met. This License explicitly affirms your unlimited permission to run the unmodified Program. The output from running a covered work is covered by this License only if the output, given its content, constitutes a covered work. This License acknowledges your rights of fair use or other equivalent, as provided by copyright law. You may make, run and propagate covered works that you do not convey, without conditions so long as your license otherwise remains in force. You may convey covered works to others for the sole purpose of having them make modifications exclusively for you, or provide you with facilities for running those works, provided that you comply with the terms of this License in conveying all material for which you do not control copyright. Those thus making or running the covered works for you must do so exclusively on your behalf, under your direction and control, on terms that prohibit them from making any copies of your copyrighted material outside their relationship with you. Conveying under any other circumstances is permitted solely under the conditions stated below. Sublicensing is not allowed; section 10 makes it unnecessary. 3. Protecting Users' Legal Rights From Anti-Circumvention Law. No covered work shall be deemed part of an effective technological measure under any applicable law fulfilling obligations under article 11 of the WIPO copyright treaty adopted on 20 December 1996, or similar laws prohibiting or restricting circumvention of such measures. When you convey a covered work, you waive any legal power to forbid circumvention of technological measures to the extent such circumvention is effected by exercising rights under this License with respect to the covered work, and you disclaim any intention to limit operation or modification of the work as a means of enforcing, against the work's users, your or third parties' legal rights to forbid circumvention of technological measures. 4. Conveying Verbatim Copies. You may convey verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice; keep intact all notices stating that this License and any non-permissive terms added in accord with section 7 apply to the code; keep intact all notices of the absence of any warranty; and give all recipients a copy of this License along with the Program. You may charge any price or no price for each copy that you convey, and you may offer support or warranty protection for a fee. 5. Conveying Modified Source Versions. You may convey a work based on the Program, or the modifications to produce it from the Program, in the form of source code under the terms of section 4, provided that you also meet all of these conditions: a) The work must carry prominent notices stating that you modified it, and giving a relevant date. b) The work must carry prominent notices stating that it is released under this License and any conditions added under section 7. This requirement modifies the requirement in section 4 to "keep intact all notices". c) You must license the entire work, as a whole, under this License to anyone who comes into possession of a copy. This License will therefore apply, along with any applicable section 7 additional terms, to the whole of the work, and all its parts, regardless of how they are packaged. This License gives no permission to license the work in any other way, but it does not invalidate such permission if you have separately received it. d) If the work has interactive user interfaces, each must display Appropriate Legal Notices; however, if the Program has interactive interfaces that do not display Appropriate Legal Notices, your work need not make them do so. A compilation of a covered work with other separate and independent works, which are not by their nature extensions of the covered work, and which are not combined with it such as to form a larger program, in or on a volume of a storage or distribution medium, is called an "aggregate" if the compilation and its resulting copyright are not used to limit the access or legal rights of the compilation's users beyond what the individual works permit. Inclusion of a covered work in an aggregate does not cause this License to apply to the other parts of the aggregate. 6. Conveying Non-Source Forms. You may convey a covered work in object code form under the terms of sections 4 and 5, provided that you also convey the machine-readable Corresponding Source under the terms of this License, in one of these ways: a) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by the Corresponding Source fixed on a durable physical medium customarily used for software interchange. b) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by a written offer, valid for at least three years and valid for as long as you offer spare parts or customer support for that product model, to give anyone who possesses the object code either (1) a copy of the Corresponding Source for all the software in the product that is covered by this License, on a durable physical medium customarily used for software interchange, for a price no more than your reasonable cost of physically performing this conveying of source, or (2) access to copy the Corresponding Source from a network server at no charge. c) Convey individual copies of the object code with a copy of the written offer to provide the Corresponding Source. This alternative is allowed only occasionally and noncommercially, and only if you received the object code with such an offer, in accord with subsection 6b. d) Convey the object code by offering access from a designated place (gratis or for a charge), and offer equivalent access to the Corresponding Source in the same way through the same place at no further charge. You need not require recipients to copy the Corresponding Source along with the object code. If the place to copy the object code is a network server, the Corresponding Source may be on a different server (operated by you or a third party) that supports equivalent copying facilities, provided you maintain clear directions next to the object code saying where to find the Corresponding Source. Regardless of what server hosts the Corresponding Source, you remain obligated to ensure that it is available for as long as needed to satisfy these requirements. e) Convey the object code using peer-to-peer transmission, provided you inform other peers where the object code and Corresponding Source of the work are being offered to the general public at no charge under subsection 6d. A separable portion of the object code, whose source code is excluded from the Corresponding Source as a System Library, need not be included in conveying the object code work. A "User Product" is either (1) a "consumer product", which means any tangible personal property which is normally used for personal, family, or household purposes, or (2) anything designed or sold for incorporation into a dwelling. In determining whether a product is a consumer product, doubtful cases shall be resolved in favor of coverage. For a particular product received by a particular user, "normally used" refers to a typical or common use of that class of product, regardless of the status of the particular user or of the way in which the particular user actually uses, or expects or is expected to use, the product. A product is a consumer product regardless of whether the product has substantial commercial, industrial or non-consumer uses, unless such uses represent the only significant mode of use of the product. "Installation Information" for a User Product means any methods, procedures, authorization keys, or other information required to install and execute modified versions of a covered work in that User Product from a modified version of its Corresponding Source. The information must suffice to ensure that the continued functioning of the modified object code is in no case prevented or interfered with solely because modification has been made. If you convey an object code work under this section in, or with, or specifically for use in, a User Product, and the conveying occurs as part of a transaction in which the right of possession and use of the User Product is transferred to the recipient in perpetuity or for a fixed term (regardless of how the transaction is characterized), the Corresponding Source conveyed under this section must be accompanied by the Installation Information. But this requirement does not apply if neither you nor any third party retains the ability to install modified object code on the User Product (for example, the work has been installed in ROM). The requirement to provide Installation Information does not include a requirement to continue to provide support service, warranty, or updates for a work that has been modified or installed by the recipient, or for the User Product in which it has been modified or installed. Access to a network may be denied when the modification itself materially and adversely affects the operation of the network or violates the rules and protocols for communication across the network. Corresponding Source conveyed, and Installation Information provided, in accord with this section must be in a format that is publicly documented (and with an implementation available to the public in source code form), and must require no special password or key for unpacking, reading or copying. 7. Additional Terms. "Additional permissions" are terms that supplement the terms of this License by making exceptions from one or more of its conditions. Additional permissions that are applicable to the entire Program shall be treated as though they were included in this License, to the extent that they are valid under applicable law. If additional permissions apply only to part of the Program, that part may be used separately under those permissions, but the entire Program remains governed by this License without regard to the additional permissions. When you convey a copy of a covered work, you may at your option remove any additional permissions from that copy, or from any part of it. (Additional permissions may be written to require their own removal in certain cases when you modify the work.) You may place additional permissions on material, added by you to a covered work, for which you have or can give appropriate copyright permission. Notwithstanding any other provision of this License, for material you add to a covered work, you may (if authorized by the copyright holders of that material) supplement the terms of this License with terms: a) Disclaiming warranty or limiting liability differently from the terms of sections 15 and 16 of this License; or b) Requiring preservation of specified reasonable legal notices or author attributions in that material or in the Appropriate Legal Notices displayed by works containing it; or c) Prohibiting misrepresentation of the origin of that material, or requiring that modified versions of such material be marked in reasonable ways as different from the original version; or d) Limiting the use for publicity purposes of names of licensors or authors of the material; or e) Declining to grant rights under trademark law for use of some trade names, trademarks, or service marks; or f) Requiring indemnification of licensors and authors of that material by anyone who conveys the material (or modified versions of it) with contractual assumptions of liability to the recipient, for any liability that these contractual assumptions directly impose on those licensors and authors. All other non-permissive additional terms are considered "further restrictions" within the meaning of section 10. If the Program as you received it, or any part of it, contains a notice stating that it is governed by this License along with a term that is a further restriction, you may remove that term. If a license document contains a further restriction but permits relicensing or conveying under this License, you may add to a covered work material governed by the terms of that license document, provided that the further restriction does not survive such relicensing or conveying. If you add terms to a covered work in accord with this section, you must place, in the relevant source files, a statement of the additional terms that apply to those files, or a notice indicating where to find the applicable terms. Additional terms, permissive or non-permissive, may be stated in the form of a separately written license, or stated as exceptions; the above requirements apply either way. 8. Termination. You may not propagate or modify a covered work except as expressly provided under this License. Any attempt otherwise to propagate or modify it is void, and will automatically terminate your rights under this License (including any patent licenses granted under the third paragraph of section 11). However, if you cease all violation of this License, then your license from a particular copyright holder is reinstated (a) provisionally, unless and until the copyright holder explicitly and finally terminates your license, and (b) permanently, if the copyright holder fails to notify you of the violation by some reasonable means prior to 60 days after the cessation. Moreover, your license from a particular copyright holder is reinstated permanently if the copyright holder notifies you of the violation by some reasonable means, this is the first time you have received notice of violation of this License (for any work) from that copyright holder, and you cure the violation prior to 30 days after your receipt of the notice. Termination of your rights under this section does not terminate the licenses of parties who have received copies or rights from you under this License. If your rights have been terminated and not permanently reinstated, you do not qualify to receive new licenses for the same material under section 10. 9. Acceptance Not Required for Having Copies. You are not required to accept this License in order to receive or run a copy of the Program. Ancillary propagation of a covered work occurring solely as a consequence of using peer-to-peer transmission to receive a copy likewise does not require acceptance. However, nothing other than this License grants you permission to propagate or modify any covered work. These actions infringe copyright if you do not accept this License. Therefore, by modifying or propagating a covered work, you indicate your acceptance of this License to do so. 10. Automatic Licensing of Downstream Recipients. Each time you convey a covered work, the recipient automatically receives a license from the original licensors, to run, modify and propagate that work, subject to this License. You are not responsible for enforcing compliance by third parties with this License. An "entity transaction" is a transaction transferring control of an organization, or substantially all assets of one, or subdividing an organization, or merging organizations. If propagation of a covered work results from an entity transaction, each party to that transaction who receives a copy of the work also receives whatever licenses to the work the party's predecessor in interest had or could give under the previous paragraph, plus a right to possession of the Corresponding Source of the work from the predecessor in interest, if the predecessor has it or can get it with reasonable efforts. You may not impose any further restrictions on the exercise of the rights granted or affirmed under this License. For example, you may not impose a license fee, royalty, or other charge for exercise of rights granted under this License, and you may not initiate litigation (including a cross-claim or counterclaim in a lawsuit) alleging that any patent claim is infringed by making, using, selling, offering for sale, or importing the Program or any portion of it. 11. Patents. A "contributor" is a copyright holder who authorizes use under this License of the Program or a work on which the Program is based. The work thus licensed is called the contributor's "contributor version". A contributor's "essential patent claims" are all patent claims owned or controlled by the contributor, whether already acquired or hereafter acquired, that would be infringed by some manner, permitted by this License, of making, using, or selling its contributor version, but do not include claims that would be infringed only as a consequence of further modification of the contributor version. For purposes of this definition, "control" includes the right to grant patent sublicenses in a manner consistent with the requirements of this License. Each contributor grants you a non-exclusive, worldwide, royalty-free patent license under the contributor's essential patent claims, to make, use, sell, offer for sale, import and otherwise run, modify and propagate the contents of its contributor version. In the following three paragraphs, a "patent license" is any express agreement or commitment, however denominated, not to enforce a patent (such as an express permission to practice a patent or covenant not to sue for patent infringement). To "grant" such a patent license to a party means to make such an agreement or commitment not to enforce a patent against the party. If you convey a covered work, knowingly relying on a patent license, and the Corresponding Source of the work is not available for anyone to copy, free of charge and under the terms of this License, through a publicly available network server or other readily accessible means, then you must either (1) cause the Corresponding Source to be so available, or (2) arrange to deprive yourself of the benefit of the patent license for this particular work, or (3) arrange, in a manner consistent with the requirements of this License, to extend the patent license to downstream recipients. "Knowingly relying" means you have actual knowledge that, but for the patent license, your conveying the covered work in a country, or your recipient's use of the covered work in a country, would infringe one or more identifiable patents in that country that you have reason to believe are valid. If, pursuant to or in connection with a single transaction or arrangement, you convey, or propagate by procuring conveyance of, a covered work, and grant a patent license to some of the parties receiving the covered work authorizing them to use, propagate, modify or convey a specific copy of the covered work, then the patent license you grant is automatically extended to all recipients of the covered work and works based on it. A patent license is "discriminatory" if it does not include within the scope of its coverage, prohibits the exercise of, or is conditioned on the non-exercise of one or more of the rights that are specifically granted under this License. You may not convey a covered work if you are a party to an arrangement with a third party that is in the business of distributing software, under which you make payment to the third party based on the extent of your activity of conveying the work, and under which the third party grants, to any of the parties who would receive the covered work from you, a discriminatory patent license (a) in connection with copies of the covered work conveyed by you (or copies made from those copies), or (b) primarily for and in connection with specific products or compilations that contain the covered work, unless you entered into that arrangement, or that patent license was granted, prior to 28 March 2007. Nothing in this License shall be construed as excluding or limiting any implied license or other defenses to infringement that may otherwise be available to you under applicable patent law. 12. No Surrender of Others' Freedom. If conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot convey a covered work so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not convey it at all. For example, if you agree to terms that obligate you to collect a royalty for further conveying from those to whom you convey the Program, the only way you could satisfy both those terms and this License would be to refrain entirely from conveying the Program. 13. Use with the GNU Affero General Public License. Notwithstanding any other provision of this License, you have permission to link or combine any covered work with a work licensed under version 3 of the GNU Affero General Public License into a single combined work, and to convey the resulting work. The terms of this License will continue to apply to the part which is the covered work, but the special requirements of the GNU Affero General Public License, section 13, concerning interaction through a network will apply to the combination as such. 14. Revised Versions of this License. The Free Software Foundation may publish revised and/or new versions of the GNU General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies that a certain numbered version of the GNU General Public License "or any later version" applies to it, you have the option of following the terms and conditions either of that numbered version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of the GNU General Public License, you may choose any version ever published by the Free Software Foundation. If the Program specifies that a proxy can decide which future versions of the GNU General Public License can be used, that proxy's public statement of acceptance of a version permanently authorizes you to choose that version for the Program. Later license versions may give you additional or different permissions. However, no additional obligations are imposed on any author or copyright holder as a result of your choosing to follow a later version. 15. Disclaimer of Warranty. THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 16. Limitation of Liability. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. 17. Interpretation of Sections 15 and 16. If the disclaimer of warranty and limitation of liability provided above cannot be given local legal effect according to their terms, reviewing courts shall apply local law that most closely approximates an absolute waiver of all civil liability in connection with the Program, unless a warranty or assumption of liability accompanies a copy of the Program in return for a fee. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively state the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . Also add information on how to contact you by electronic and paper mail. If the program does terminal interaction, make it output a short notice like this when it starts in an interactive mode: Copyright (C) This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, your program's commands might be different; for a GUI interface, you would use an "about box". You should also get your employer (if you work as a programmer) or school, if any, to sign a "copyright disclaimer" for the program, if necessary. For more information on this, and how to apply and follow the GNU GPL, see . The GNU General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Lesser General Public License instead of this License. But first, please read . ================================================ FILE: README.md ================================================ # Welcome to CGALDotNet. - [Introduction.](https://github.com/Scrawk/CGALDotNet/wiki/Introduction) - [The CGAL Numbers types.](https://github.com/Scrawk/CGALDotNet/wiki/The-Number-Types) - [Eigen](https://github.com/Scrawk/CGALDotNet/wiki/Eigen) - [The CGAL Object.](https://github.com/Scrawk/CGALDotNet/wiki/The-CGALObject) - [The CGAL Global Functions.](https://github.com/Scrawk/CGALDotNet/wiki/The-CGALGlobal-Functions) - [Unity Extensions](https://github.com/Scrawk/CGALDotNet/wiki/Unity-Extensions) # The Geometry Kernel. - [The Geometry Numerics.](https://github.com/Scrawk/CGALDotNet/wiki/The-Geometry-Numerics) - [The Geometry Shapes.](https://github.com/Scrawk/CGALDotNet/wiki/The-Geometry-Shapes) - [The Geometry Objects.](https://github.com/Scrawk/CGALDotNet/wiki/The-Geometry-Objects) - [The Geometry Intersections.](https://github.com/Scrawk/CGALDotNet/wiki/The-Geometry-Intersections) # The Polygon Kernel. - [The Polygon Object.](https://github.com/Scrawk/CGALDotNet/wiki/The-Polygon-Object) - [The Polygon With Holes Object.](https://github.com/Scrawk/CGALDotNet/wiki/The-Polygon-With-Holes-Object) - [Polygon Boolean.](https://github.com/Scrawk/CGALDotNet/wiki/Polygon-Boolean) - [Polygon Minkowski.](https://github.com/Scrawk/CGALDotNet/wiki/Polygon-Minkowski) - [Polygon Offset.](https://github.com/Scrawk/CGALDotNet/wiki/Polygon-Offset) - [Polygon Simplification.](https://github.com/Scrawk/CGALDotNet/wiki/Polygon-Simplification) - [Polygon Visibility.](https://github.com/Scrawk/CGALDotNet/wiki/Polygon-Visibility) - [Polygon Partition.](https://github.com/Scrawk/CGALDotNet/wiki/Polygon-Partition) # The Triangulation Kernel - [Triangulation 2D](https://github.com/Scrawk/CGALDotNet/wiki/Triangulations-2D) - [Triangulation 3D](https://github.com/Scrawk/CGALDotNet/wiki/Triangulations-3D) # The Arrangements Kernel - [Arrangements 2D](https://github.com/Scrawk/CGALDotNet/wiki/Arrangements-2D) - [Sweep Line 2D](https://github.com/Scrawk/CGALDotNet/wiki/Sweep-Line-2D) # The Polyhedra Kernel - [Polyhedra3 Mesh](https://github.com/Scrawk/CGALDotNet/wiki/Polyhedron3-Mesh) - [Mesh Processing](https://github.com/Scrawk/CGALDotNet/wiki/Mesh-Processing) Some common geomerty objects are referrenced in a [seperate project](https://github.com/Scrawk/CGALDotNetGeometry) so they can come under a different license. Work in progress. Only 64 bit windows binarys provided. Examples in Unity can be found in [this](https://github.com/Scrawk/CGALDotNetUnity) repository. A page on the Unity forums can be found [here](https://forum.unity.com/threads/cgaldotnet-a-c-computational-library-built-around-cgal.1250314/).