Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mac build support #568

Open
wants to merge 9 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,9 @@ target_include_directories(PotreeConverter PRIVATE "./Converter/include")
target_include_directories(PotreeConverter PRIVATE "./Converter/modules")
target_include_directories(PotreeConverter PRIVATE "./Converter/libs")


if (UNIX)
if(APPLE)
## Do nothing. Just skip the Unix check
elseif (UNIX)
find_package(Threads REQUIRED)
find_package(TBB REQUIRED)

Expand All @@ -62,7 +63,7 @@ if (UNIX)


#SET(CMAKE_CXX_FLAGS "-pthread -ltbb")
endif (UNIX)
endif ()

###############################################
# COPY PAGE TEMPLATE TO BINARY DIRECTORY
Expand Down
8 changes: 6 additions & 2 deletions Converter/include/PotreeConverter.h
Original file line number Diff line number Diff line change
Expand Up @@ -207,9 +207,13 @@ inline Attributes computeOutputAttributes(vector<Source>& sources, vector<string
// compute scale and offset from all sources
{
mutex mtx;
auto parallel = std::execution::par;
for_each(parallel, sources.begin(), sources.end(), [&mtx, &sources, &scaleMin, &min, &max, requestedAttributes, &fullAttributeList, &acceptedAttributeNames](Source source) {

#if defined(__APPLE__)
for_each(sources.begin(), sources.end(), [&mtx, &sources, &scaleMin, &min, &max, requestedAttributes, &fullAttributeList, &acceptedAttributeNames](Source source) {
#else
auto parallel = std::execution::par;
for_each(parallel, sources.begin(), sources.end(), [&mtx, &sources, &scaleMin, &min, &max, requestedAttributes, &fullAttributeList, &acceptedAttributeNames](Source source) {
#endif
auto header = loadLasHeader(source.path);

vector<Attribute> attributes = computeOutputAttributes(header);
Expand Down
14 changes: 13 additions & 1 deletion Converter/include/sampler_poisson.h
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,15 @@ struct SamplerPoisson : public Sampler {
double y = (xyz[1] * scale.y) + offset.y;
double z = (xyz[2] * scale.z) + offset.z;

Point point = { x, y, z, i, childIndex };
#if defined(__APPLE__)
// convert int64_t to int32_t for apple to be happy
int32_t apple_i = i;
int32_t apple_childIndex = childIndex;

Point point = { x, y, z, apple_i, apple_childIndex };
#else
Point point = { x, y, z, i, childIndex };
#endif

points.push_back(point);
}
Expand Down Expand Up @@ -179,8 +187,12 @@ struct SamplerPoisson : public Sampler {

};

#if defined(__APPLE__)
std::sort(points.begin(), points.end(), [center](Point a, Point b) -> bool {
#else
auto parallel = std::execution::par_unseq;
std::sort(parallel, points.begin(), points.end(), [center](Point a, Point b) -> bool {
#endif

auto ax = a.x - center.x;
auto ay = a.y - center.y;
Expand Down
7 changes: 6 additions & 1 deletion Converter/include/sampler_poisson_average.h
Original file line number Diff line number Diff line change
Expand Up @@ -280,9 +280,14 @@ struct SamplerPoissonAverage : public Sampler {

};


#if defined(__APPLE__)
std::sort(points.begin(), points.end(), [center](Point a, Point b) -> bool {
#else
auto parallel = std::execution::par_unseq;
std::sort(parallel, points.begin(), points.end(), [center](Point a, Point b) -> bool {

#endif

auto ax = a.x - center.x;
auto ay = a.y - center.y;
auto az = a.z - center.z;
Expand Down
63 changes: 63 additions & 0 deletions Converter/modules/unsuck/cpu.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
/* vim: tabstop=2 shiftwidth=2 expandtab textwidth=80 linebreak wrap
*
* Copyright 2012 Matthew McCormick
* Copyright 2015 Pawel 'l0ner' Soltys
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

#ifndef CPU_H_
#define CPU_H_

#include <sys/types.h>

#if defined(__APPLE__) && defined(__MACH__)
#define CP_USER 0
#define CP_SYS 1
#define CP_IDLE 2
#define CP_NICE 3
#define CP_STATES 4
#else
#define CP_USER 0
#define CP_NICE 1
#define CP_SYS 2

#if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__)
// *BSD or OSX
#define CP_INTR 3
#define CP_IDLE 4
#define CP_STATES 5
#else
//linux
#define CP_IDLE 3
#define CP_STATES 4
#endif
#endif

float cpu_percentage( unsigned );
uint32_t get_cpu_count();

/** CPU percentage output mode.
*
* Examples:
*
* CPU_MODE_DEFAULT: 100%
* CPU_MODE_THREADS: 800% (8 cores, fully loaded)
*/
enum CPU_MODE
{
CPU_MODE_DEFAULT,
CPU_MODE_THREADS
};

#endif
56 changes: 56 additions & 0 deletions Converter/modules/unsuck/memory.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
/* vim: tabstop=2 shiftwidth=2 expandtab textwidth=80 linebreak wrap
*
* Copyright 2012 Matthew McCormick
* Copyright 2015 Pawel 'l0ner' Soltys
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

#ifndef MEMORY_H_
#define MEMORY_H_

#include <string>

/** Memory status in megabytes */
struct MemoryStatus
{
float used_mem;
float total_mem;
};

/** Get the current memory status */
void mem_status( MemoryStatus & status );


/** Memory status string output mode.
*
* Examples:
*
* MEMORY_MODE_DEFAULT: 11156/16003MB
* MEMORY_MODE_FREE_MEMORY:
* MEMORY_MODE_USAGE_PERCENTAGE:
*/
enum MEMORY_MODE
{
MEMORY_MODE_DEFAULT,
MEMORY_MODE_FREE_MEMORY,
MEMORY_MODE_USAGE_PERCENTAGE
};

std::string mem_string( const MemoryStatus & mem_status,
MEMORY_MODE mode = MEMORY_MODE_DEFAULT,
bool use_colors = false,
bool use_powerline_left = false,
bool use_powerline_right = false );

#endif
6 changes: 5 additions & 1 deletion Converter/modules/unsuck/unsuck.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
#include <cstdint>
#include <cstring>

#include "cpu.h"
#include "memory.h"

using std::cout;
using std::endl;
using std::to_string;
Expand Down Expand Up @@ -43,6 +46,8 @@ static double Infinity = std::numeric_limits<double>::infinity();
constexpr auto fseek_64_all_platforms = fseeko64;
#elif defined(WIN32)
constexpr auto fseek_64_all_platforms = _fseeki64;
#elif defined(__APPLE__)
constexpr auto fseek_64_all_platforms = fseeko;
#endif


Expand Down Expand Up @@ -586,4 +591,3 @@ inline string rightPad(string in, int64_t length, const char character = ' ') {

#define GENERATE_ERROR_MESSAGE cout << "ERROR(" << __FILE__ << ":" << __LINE__ << "): "
#define GENERATE_WARN_MESSAGE cout << "WARNING: "

Loading