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

An Xcode project that creates MacOS libraries from CGALWrapper #21

Open
wants to merge 6 commits into
base: master
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
Binary file added MacOS/.DS_Store
Binary file not shown.
Binary file added MacOS/CgalForCgalDotnet/.DS_Store
Binary file not shown.
Binary file added MacOS/CgalForCgalDotnet/CGALWrapper/.DS_Store
Binary file not shown.
48 changes: 48 additions & 0 deletions MacOS/CgalForCgalDotnet/CGALWrapper/Arrangments/ArrFace2.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#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<class FACE>
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;
}
};
45 changes: 45 additions & 0 deletions MacOS/CgalForCgalDotnet/CGALWrapper/Arrangments/ArrHalfEdge2.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#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<class EDGE>
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;
}
};
273 changes: 273 additions & 0 deletions MacOS/CgalForCgalDotnet/CGALWrapper/Arrangments/ArrMultiLocator.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,273 @@
#pragma once

#include "../CGALWrapper.h"
#include "../Geometry/Geometry2.h"

#include "CGAL/Point_2.h"
#include <CGAL/Arr_point_location_result.h>
#include <CGAL/Arr_batched_point_location.h>
#include <CGAL/Arr_naive_point_location.h>
#include <CGAL/Arr_walk_along_line_point_location.h>
#include <CGAL/Arr_landmarks_point_location.h>
#include <CGAL/Arr_trapezoid_ric_point_location.h>

enum class ARR_LOCATOR : int
{
NONE,
NAIVE,
WALK,
LANDMARKS,
TRAPEZOID
};

template<class K, class Arrangement>
class ArrMultiLocator
{

public:

typedef CGAL::Arr_point_location_result<Arrangement> Locator_Result;
typedef typename Locator_Result::Type Locator_Result_Type;

typedef CGAL::Arr_naive_point_location<Arrangement> Naive_Locator;
typedef CGAL::Arr_walk_along_line_point_location<Arrangement> Walk_Locator;
typedef CGAL::Arr_landmarks_point_location<Arrangement> Landmarks_Locator;
typedef CGAL::Arr_trapezoid_ric_point_location<Arrangement> 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<K>());

case ARR_LOCATOR::WALK:
return walk_locator->locate(point.ToCGAL<K>());

case ARR_LOCATOR::LANDMARKS:
return landmark_locator->locate(point.ToCGAL<K>());

case ARR_LOCATOR::TRAPEZOID:
return trapezoid_locator->locate(point.ToCGAL<K>());

default:
Walk_Locator locator;
locator.attach(arr);
return locator.locate(point.ToCGAL<K>());
}
}

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<K>());

case ARR_LOCATOR::TRAPEZOID:
return trapezoid_locator->ray_shoot_up(point.ToCGAL<K>());

default:
Walk_Locator locator;
locator.attach(arr);
return locator.ray_shoot_up(point.ToCGAL<K>());
}
}

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<K>());

case ARR_LOCATOR::TRAPEZOID:
return trapezoid_locator->ray_shoot_down(point.ToCGAL<K>());

default:
Walk_Locator locator;
locator.attach(arr);
return locator.ray_shoot_down(point.ToCGAL<K>());
}
}

template<class SEGMENT>
BOOL Intersects(Arrangement& arr, Segment2d segment)
{
auto seg = segment.ToCGAL<K, SEGMENT>();

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<K>(), *walk_locator);
break;

case ARR_LOCATOR::TRAPEZOID:
insert_point(arr, point.ToCGAL<K>(), *trapezoid_locator);
break;

default:
Walk_Locator locator;
locator.attach(arr);
insert_point(arr, point.ToCGAL<K>(), locator);
break;
}
}

template<class SEGMENT>
void InsertSegment(Arrangement& arr, Segment2d segment)
{
auto seg = segment.ToCGAL<K, SEGMENT>();

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<class SEGMENT>
void InsertNonIntersectingSegment(Arrangement& arr, Segment2d segment)
{
auto seg = segment.ToCGAL<K, SEGMENT>();

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;
}
}

};

Loading