From bae84b675383655ee10f2afd8dec6c1fa59a3479 Mon Sep 17 00:00:00 2001 From: Ken Arroyo Ohori Date: Tue, 7 Feb 2017 19:50:51 -0600 Subject: [PATCH] Directions as CGAL Vector_3, more robust points --- .../kernels/cgal/CgalConversionFunctions.cpp | 15 ++++++++++++++- src/ifcgeom/kernels/cgal/CgalEntityMapping.h | 1 + src/ifcgeom/kernels/cgal/CgalKernel.h | 1 + 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/src/ifcgeom/kernels/cgal/CgalConversionFunctions.cpp b/src/ifcgeom/kernels/cgal/CgalConversionFunctions.cpp index 93947879ea..9e66c5def6 100644 --- a/src/ifcgeom/kernels/cgal/CgalConversionFunctions.cpp +++ b/src/ifcgeom/kernels/cgal/CgalConversionFunctions.cpp @@ -30,9 +30,22 @@ bool IfcGeom::CgalKernel::convert(const IfcSchema::IfcExtrudedAreaSolid*, cgal_s bool IfcGeom::CgalKernel::convert(const IfcSchema::IfcCartesianPoint* l, cgal_point_t& point) { std::vector xyz = l->Coordinates(); if (xyz.size() == 3) { - point = new Kernel::Point_3(xyz[0], xyz[1], xyz[2]); + point = new Kernel::Point_3(xyz.size() ? (xyz[0]*getValue(GV_LENGTH_UNIT)) : 0.0f, + xyz.size() > 1 ? (xyz[1]*getValue(GV_LENGTH_UNIT)) : 0.0f, + xyz.size() > 2 ? (xyz[2]*getValue(GV_LENGTH_UNIT)) : 0.0f); return true; } else { throw std::runtime_error("Point without 3 coordinates"); } } + +bool IfcGeom::CgalKernel::convert(const IfcSchema::IfcDirection* l, cgal_direction_t& dir) { +// IN_CACHE(IfcDirection,l,cgal_direction_t,dir) + std::vector xyz = l->DirectionRatios(); + dir = new Kernel::Vector_3(xyz.size() ? xyz[0] : 0.0f, + xyz.size() > 1 ? xyz[1] : 0.0f, + xyz.size() > 2 ? xyz[2] : 0.0f); +// CACHE(IfcDirection,l,dir) + return true; +} + diff --git a/src/ifcgeom/kernels/cgal/CgalEntityMapping.h b/src/ifcgeom/kernels/cgal/CgalEntityMapping.h index e720796002..d8e39626d2 100644 --- a/src/ifcgeom/kernels/cgal/CgalEntityMapping.h +++ b/src/ifcgeom/kernels/cgal/CgalEntityMapping.h @@ -43,3 +43,4 @@ FACE(IfcFace); WIRE(IfcPolyLoop); CLASS(IfcCartesianPoint,cgal_point_t); +CLASS(IfcDirection,cgal_direction_t); diff --git a/src/ifcgeom/kernels/cgal/CgalKernel.h b/src/ifcgeom/kernels/cgal/CgalKernel.h index b6a042770d..638344c7d8 100644 --- a/src/ifcgeom/kernels/cgal/CgalKernel.h +++ b/src/ifcgeom/kernels/cgal/CgalKernel.h @@ -46,6 +46,7 @@ typedef CGAL::Exact_predicates_exact_constructions_kernel Kernel; typedef Kernel::Aff_transformation_3 *cgal_placement_t; typedef Kernel::Point_3 *cgal_point_t; +typedef Kernel::Vector_3 *cgal_direction_t; typedef std::vector *cgal_curve_t; typedef std::vector *cgal_wire_t;