From c0732f5197fdb08d55adfeb23a05dfb7b1d93b3a Mon Sep 17 00:00:00 2001 From: Ken Arroyo Ohori Date: Tue, 21 Feb 2017 15:37:38 -0600 Subject: [PATCH] =?UTF-8?q?Trying=20to=20find=20out=20why=20placements=20d?= =?UTF-8?q?on=E2=80=99t=20arrive=20at=20Triangulate()?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/ifcgeom/IfcGeomIterator.h | 7 ++++ .../kernels/cgal/CgalConversionFunctions.cpp | 34 +++++++++++++++++++ .../kernels/cgal/CgalConversionResult.h | 5 +-- src/ifcgeom/kernels/cgal/CgalKernel.cpp | 7 ++++ 4 files changed, 51 insertions(+), 2 deletions(-) diff --git a/src/ifcgeom/IfcGeomIterator.h b/src/ifcgeom/IfcGeomIterator.h index 2d2c8fe312..8a1de806e5 100644 --- a/src/ifcgeom/IfcGeomIterator.h +++ b/src/ifcgeom/IfcGeomIterator.h @@ -702,6 +702,13 @@ namespace IfcGeom { try { next_shape_model = create_shape_model_for_next_entity(); + +// std::cout << "trsf" << std::endl; +// for (int i = 0; i < 3; ++i) { +// for (int j = 0; j < 4; ++j) { +// std::cout << next_shape_model->transformation().matrix().data() << " "; +// } std::cout << std::endl; +// } } catch (...) {} if (next_shape_model) { diff --git a/src/ifcgeom/kernels/cgal/CgalConversionFunctions.cpp b/src/ifcgeom/kernels/cgal/CgalConversionFunctions.cpp index 4121a7c783..80f7457811 100644 --- a/src/ifcgeom/kernels/cgal/CgalConversionFunctions.cpp +++ b/src/ifcgeom/kernels/cgal/CgalConversionFunctions.cpp @@ -139,12 +139,22 @@ bool IfcGeom::CgalKernel::convert(const IfcSchema::IfcAxis2Placement3D* l, cgal_ if ( l->hasAxis() ) IfcGeom::CgalKernel::convert(l->Axis(),axis); if ( hasRef ) IfcGeom::CgalKernel::convert(l->RefDirection(),refDirection); +// std::cout << "Ref direction: " << refDirection << std::endl; +// std::cout << "Axis: " << axis << std::endl; +// std::cout << "Origin: " << o << std::endl; + // TODO: From Thomas' email. Should be checked. Kernel::Vector_3 y = CGAL::cross_product(axis, refDirection); trsf = Kernel::Aff_transformation_3(refDirection.cartesian(0), y.cartesian(0), axis.cartesian(0), o.cartesian(0), refDirection.cartesian(1), y.cartesian(1), axis.cartesian(1), o.cartesian(1), refDirection.cartesian(2), y.cartesian(2), axis.cartesian(2), o.cartesian(2)); +// for (int i = 0; i < 3; ++i) { +// for (int j = 0; j < 4; ++j) { +// std::cout << trsf.cartesian(i, j) << " "; +// } std::cout << std::endl; +// } + // CACHE(IfcAxis2Placement3D,l,trsf) return true; } @@ -156,13 +166,37 @@ bool IfcGeom::CgalKernel::convert(const IfcSchema::IfcObjectPlacement* l, cgal_p Logger::Message(Logger::LOG_ERROR, "Unsupported IfcObjectPlacement:", l->entity); return false; } + +// std::cout << "initial trsf (identity?)" << std::endl; +// for (int i = 0; i < 3; ++i) { +// for (int j = 0; j < 4; ++j) { +// std::cout << trsf.cartesian(i, j) << " "; +// } std::cout << std::endl; +// } + IfcSchema::IfcLocalPlacement* current = (IfcSchema::IfcLocalPlacement*)l; for (;;) { cgal_placement_t trsf2; + IfcSchema::IfcAxis2Placement* relplacement = current->RelativePlacement(); if ( relplacement->is(IfcSchema::Type::IfcAxis2Placement3D) ) { IfcGeom::CgalKernel::convert((IfcSchema::IfcAxis2Placement3D*)relplacement,trsf2); + +// std::cout << "trsf2" << std::endl; +// for (int i = 0; i < 3; ++i) { +// for (int j = 0; j < 4; ++j) { +// std::cout << trsf2.cartesian(i, j) << " "; +// } std::cout << std::endl; +// } + trsf = trsf * trsf2; // TODO: I think it's fine, but maybe should it be the other way around? + +// std::cout << "trsf (after multiplication)" << std::endl; +// for (int i = 0; i < 3; ++i) { +// for (int j = 0; j < 4; ++j) { +// std::cout << trsf.cartesian(i, j) << " "; +// } std::cout << std::endl; +// } } if ( current->hasPlacementRelTo() ) { IfcSchema::IfcObjectPlacement* relto = current->PlacementRelTo(); diff --git a/src/ifcgeom/kernels/cgal/CgalConversionResult.h b/src/ifcgeom/kernels/cgal/CgalConversionResult.h index 940a598b67..b02e6e5c95 100644 --- a/src/ifcgeom/kernels/cgal/CgalConversionResult.h +++ b/src/ifcgeom/kernels/cgal/CgalConversionResult.h @@ -35,7 +35,8 @@ namespace IfcGeom { virtual double Value(int i, int j) const { // TODO: Check - return CGAL::to_double(trsf_.cartesian(i, j)); +// std::cout << "Getting CgalPlacement with i = " << i << " and j = " << j << std::endl; + return CGAL::to_double(trsf_.cartesian(i-1, j-1)); } virtual void Multiply(const ConversionResultPlacement* other) { // TODO: Check @@ -51,7 +52,7 @@ namespace IfcGeom { private: cgal_placement_t trsf_; }; - + class CgalShape : public ConversionResultShape { public: CgalShape(const cgal_shape_t& shape) diff --git a/src/ifcgeom/kernels/cgal/CgalKernel.cpp b/src/ifcgeom/kernels/cgal/CgalKernel.cpp index 73f9bd761e..7d346c93fc 100644 --- a/src/ifcgeom/kernels/cgal/CgalKernel.cpp +++ b/src/ifcgeom/kernels/cgal/CgalKernel.cpp @@ -96,6 +96,13 @@ IfcGeom::NativeElement* IfcGeom::CgalKernel::create_brep_for_representat try { convert(product->ObjectPlacement(), trsf); } catch (...) {} + + std::cout << "trsf" << std::endl; + for (int i = 0; i < 3; ++i) { + for (int j = 0; j < 4; ++j) { + std::cout << trsf.cartesian(i, j) << " "; + } std::cout << std::endl; + } // Does the IfcElement have any IfcOpenings? // Note that openings for IfcOpeningElements are not processed