Skip to content

Commit

Permalink
update test files
Browse files Browse the repository at this point in the history
  • Loading branch information
chitalu committed Jan 19, 2024
1 parent 46f10a3 commit ad7a723
Show file tree
Hide file tree
Showing 19 changed files with 948 additions and 856 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ if(${MCUT_BUILD_TESTS} OR ${MCUT_BUILD_TUTORIALS})
# tests
#
if(MCUT_BUILD_TESTS)
#add_subdirectory(tests)
add_subdirectory(tests)
endif()

#
Expand Down
File renamed without changes.
10 changes: 5 additions & 5 deletions include/mcut/internal/tpool.h
Original file line number Diff line number Diff line change
Expand Up @@ -503,7 +503,7 @@ void parallel_for(
min_per_thread);

std::vector<std::future<void>> futures;
futures.resize(num_threads - 1);
futures.resize((std::size_t)num_threads - 1);
InputStorageIteratorType block_start = first;

for (uint32_t i = 0; i < (num_threads - 1); ++i) {
Expand Down Expand Up @@ -612,7 +612,7 @@ void parallel_partial_sum(thread_pool& pool, Iterator first, Iterator last)
std::vector<std::future<value_type>> previous_end_values;
previous_end_values.reserve(num_threads - 1);
std::vector<std::future<void>> futures;
futures.resize(num_threads - 1);
futures.resize((std::size_t)num_threads - 1);

Iterator block_start = first;

Expand Down Expand Up @@ -689,7 +689,7 @@ Iterator parallel_find(thread_pool& pool, Iterator first, Iterator last, MatchTy
std::promise<Iterator> result;
std::atomic<bool> done_flag(false);
std::vector<std::future<void>> futures;
futures.resize(num_threads - 1);
futures.resize((std::size_t)num_threads - 1);

{
Iterator block_start = first;
Expand Down Expand Up @@ -767,7 +767,7 @@ Iterator parallel_find_in_map_by_key(thread_pool& pool, Iterator first, Iterator

{
std::vector<std::future<void>> futures;
futures.resize(num_threads - 1);
futures.resize((std::size_t)num_threads - 1);

Iterator block_start = first;
for (unsigned long i = 0; i < (num_threads - 1); ++i) {
Expand Down Expand Up @@ -846,7 +846,7 @@ Iterator parallel_find_if(thread_pool& pool, Iterator first, Iterator last, Unar
std::promise<Iterator> result;
std::atomic<bool> done_flag(false);
std::vector<std::future<void>> futures;
futures.resize(num_threads - 1);
futures.resize((std::size_t)num_threads - 1);

Iterator block_start = first;
for (uint32_t i = 0; i < (num_threads - 1); ++i) {
Expand Down
76 changes: 54 additions & 22 deletions source/kernel.cpp
Original file line number Diff line number Diff line change
@@ -1,24 +1,38 @@
/**
* Copyright (c) 2021-2022 Floyd M. Chitalu.
* All rights reserved.
/***************************************************************************
* This file is part of the MCUT project, which is comprised of a library
* for surface mesh cutting, example programs and test programs.
*
* Copyright (C) 2024 CutDigital Enterprise Ltd
*
* MCUT is dual-licensed software that is available under an Open Source
* license as well as a commercial license. The Open Source license is the
* GNU Lesser General Public License v3+ (LGPL). The commercial license
* option is for users that wish to use MCUT in their products for commercial
* purposes but do not wish to release their software under the LGPL.
* Email <contact@cut-digital.com> for further information.
*
* NOTE: This file is licensed under GPL-3.0-or-later (default).
* A commercial license can be purchased from Floyd M. Chitalu.
* You may not use this file except in compliance with the License. A copy of
* the Open Source license can be obtained from
*
* License details:
* https://www.gnu.org/licenses/lgpl-3.0.en.html.
*
* (A) GNU General Public License ("GPL"); a copy of which you should have
* recieved with this file.
* - see also: <http://www.gnu.org/licenses/>
* (B) Commercial license.
* - email: floyd.m.chitalu@gmail.com
* For your convenience, a copy of this License has been included in this
* repository.
*
* The commercial license options is for users that wish to use MCUT in
* their products for comercial purposes but do not wish to release their
* software products under the GPL license.
* MCUT is distributed in the hope that it will be useful, but THE SOFTWARE IS
* PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR
* A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
* OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
* Author(s) : Floyd M. Chitalu
*/
* Author(s):
*
* Floyd M. Chitalu CutDigital Enterprise Ltd.
*
**************************************************************************/

#include <algorithm>
#include <functional>
#include <iterator>
Expand All @@ -36,11 +50,7 @@
#include "mcut/internal/timer.h"
#include "mcut/internal/utils.h"

#ifndef LICENSE_PURCHASED
#define lmsg() printf("NOTE: MCUT is copyrighted and may not be sold or included in commercial products without a license.\n")
#else
#define lmsg()
#endif // #ifndef LICENSE_PURCHASED


namespace std {
// need to declare partial and explicit specializations in every translation unit
Expand Down Expand Up @@ -1527,7 +1537,29 @@ std::vector<vd_t> linear_projection_sort(const std::vector<std::pair<vd_t, vec3>
//
void dispatch(output_t& output, const input_t& input)
{
lmsg();

#ifndef LICENSE_NOTICE_ACKNOWLEDGED
const char* notice_str = R"delimiter(
***************************************************************************
* *
* The program you are running is dependent on the MCUT library. *
* *
* Copyright (C) 2024 CutDigital Enterprise Ltd *
* *
* MCUT is dual-licensed software that is available under an Open Source *
* license as well as a Commercial license. The Open Source license is *
* the GNU Lesser General Public License v3+ (LGPL). The Commercial *
* license is for users that wish to use MCUT in their products for *
* commercial purposes but do not wish to release their software under *
* LGPL. *
* *
* Email <contact@cut-digital.com> for further information. *
* *
***************************************************************************
)delimiter";

printf("%s", notice_str);
#endif // #ifndef LICENSE_NOTICE_ACKNOWLEDGED

TIMESTACK_PUSH(__FUNCTION__);

Expand Down
40 changes: 3 additions & 37 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,27 +1,3 @@
#
# Copyright (c) 2021-2022 Floyd M. Chitalu.
# All rights reserved.
#
# NOTE: This file is licensed under GPL-3.0-or-later (default).
# A commercial license can be purchased from Floyd M. Chitalu.
#
# License details:
#
# (A) GNU General Public License ("GPL"); a copy of which you should have
# recieved with this file.
# - see also: <http://www.gnu.org/licenses/>
# (B) Commercial license.
# - email: floyd.m.chitalu@gmail.com
#
# The commercial license options is for users that wish to use MCUT in
# their products for comercial purposes but do not wish to release their
# software products under the GPL license.
#
# Author(s) : Floyd M. Chitalu
#

cmake_minimum_required(VERSION 3.10)

project(mcut_tests VERSION 1.0)

find_package(Threads REQUIRED) # multi-context tests
Expand All @@ -38,16 +14,11 @@ enable_testing()
#
# Download and unpack utest at configure time
#
#download_project(PROJ utest
# GIT_REPOSITORY https://github.com/sheredom/utest.h.git
# GIT_TAG master
# ${UPDATE_DISCONNECTED_IF_AVAILABLE}
#)
FetchContent_Populate(
utest
GIT_REPOSITORY https://github.com/sheredom/utest.h.git
GIT_TAG master
GIT_PROGRESS TRUE
GIT_PROGRESS FALSE
)

set(utest_include_dir ${utest_SOURCE_DIR})
Expand All @@ -67,21 +38,16 @@ add_executable(
${CMAKE_CURRENT_SOURCE_DIR}/source/getDataMaps.cpp
${CMAKE_CURRENT_SOURCE_DIR}/source/polygonWithHoles.cpp
${CMAKE_CURRENT_SOURCE_DIR}/source/triangulation.cpp
${CMAKE_CURRENT_SOURCE_DIR}/source/off.cpp
${CMAKE_CURRENT_SOURCE_DIR}/source/getEventInfo.cpp
${CMAKE_CURRENT_SOURCE_DIR}/source/concurrentSynchronizedContexts.cpp
${CMAKE_CURRENT_SOURCE_DIR}/source/userEvents.cpp
${CMAKE_CURRENT_SOURCE_DIR}/source/perturbationState.cpp
${CMAKE_CURRENT_SOURCE_DIR}/source/intersectionType.cpp)

target_include_directories(mcut_tests PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include ${MCUT_INCLUDE_DIR} ${utest_include_dir} ${libigl_include_dir} ${eigen_include_dir})
target_link_libraries(mcut_tests PRIVATE mcut Threads::Threads)
target_include_directories(mcut_tests PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include ${MCUT_INCLUDE_DIR} ${utest_include_dir} ${mio_include_dir})
target_link_libraries(mcut_tests PRIVATE mcut mio Threads::Threads)
target_compile_definitions(mcut_tests PRIVATE -DMESHES_DIR="${CMAKE_CURRENT_SOURCE_DIR}/meshes" )
target_compile_options(mcut_tests PRIVATE ${compilation_flags})
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
target_compile_options(mcut_tests PRIVATE -Wno-class-memaccess) # utest: warning: ‘void* memset(void*, int, size_t)’ clearing an object of non-trivial type
endif()

if(MCUT_BUILD_AS_SHARED_LIB)
target_compile_definitions(mcut_tests PRIVATE -DMCUT_WITH_ARBITRARY_PRECISION_NUMBERS=1 )
endif()
7 changes: 5 additions & 2 deletions tests/source/benchmark.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,9 @@ UTEST_I_TEARDOWN(Benchmark)
if (utest_index < NUMBER_OF_BENCHMARKS) {
EXPECT_EQ(mcReleaseContext(utest_fixture->myContext), MC_NO_ERROR);
}

mioFreeMesh(&utest_fixture->srcMesh);
mioFreeMesh(&utest_fixture->cutMesh);
}

UTEST_I(Benchmark, inputID, NUMBER_OF_BENCHMARKS)
Expand Down Expand Up @@ -158,8 +161,8 @@ UTEST_I(Benchmark, inputID, NUMBER_OF_BENCHMARKS)
//
// We no longer need the mem of input meshes, so we can free it!
//
mioFreeMesh(&srcMesh);
mioFreeMesh(&cutMesh);
mioFreeMesh(&utest_fixture->srcMesh);
mioFreeMesh(&utest_fixture->cutMesh);

McUint32 connectedComponentCount = 0;

Expand Down

0 comments on commit ad7a723

Please sign in to comment.