diff --git a/src/Mod/Cam/App/AppCam.cpp b/src/Mod/Cam/App/AppCam.cpp deleted file mode 100644 index f3d36f428a..0000000000 --- a/src/Mod/Cam/App/AppCam.cpp +++ /dev/null @@ -1,59 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2007 Joachim Zettler * - * Copyright (c) 2007 Jürgen Riegel * - * * - * This file is part of the FreeCAD CAx development system. * - * * - * This library is free software; you can redistribute it and/or * - * modify it under the terms of the GNU Library General Public * - * License as published by the Free Software Foundation; either * - * version 2 of the License, or (at your option) any later version. * - * * - * This library is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * - * GNU Library General Public License for more details. * - * * - * You should have received a copy of the GNU Library General Public * - * License along with this library; see the file COPYING.LIB. If not, * - * write to the Free Software Foundation, Inc., 59 Temple Place, * - * Suite 330, Boston, MA 02111-1307, USA * - * * - ***************************************************************************/ - -#include "PreCompiled.h" - -#include -#include - - -extern struct PyMethodDef Cam_methods[]; - -PyDoc_STRVAR(module_part_doc, - "This module is the playground for the CAM stuff."); - -extern "C" -{ - void CamExport initCam() - { - // load dependent module - try { - Base::Interpreter().loadModule("Part"); - Base::Interpreter().loadModule("Mesh"); - } - catch(const Base::Exception& e) { - PyErr_SetString(PyExc_ImportError, e.what()); - return; - } - - Py_InitModule3("Cam", Cam_methods, module_part_doc); /* mod name, table ptr */ - Base::Console().Log("Loading Cam module... done\n"); - - // NOTE: To finish the initialization of our own type objects we must - // call PyType_Ready, otherwise we run into a segmentation fault, later on. - // This function is responsible for adding inherited slots from a type's base class. - - return; - } - -} // extern "C" diff --git a/src/Mod/Cam/App/AppCamPy.cpp b/src/Mod/Cam/App/AppCamPy.cpp deleted file mode 100644 index 822616df14..0000000000 --- a/src/Mod/Cam/App/AppCamPy.cpp +++ /dev/null @@ -1,4260 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2007 Joachim Zettler * - * Copyright (c) 2007 Jürgen Riegel * - * * - * This file is part of the FreeCAD CAx development system. * - * * - * This library is free software; you can redistribute it and/or * - * modify it under the terms of the GNU Library General Public * - * License as published by the Free Software Foundation; either * - * version 2 of the License, or (at your option) any later version. * - * * - * This library is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * - * GNU Library General Public License for more details. * - * * - * You should have received a copy of the GNU Library General Public * - * License along with this library; see the file COPYING.LIB. If not, * - * write to the Free Software Foundation, Inc., 59 Temple Place, * - * Suite 330, Boston, MA 02111-1307, USA * - * * - ***************************************************************************/ - -#include "PreCompiled.h" - -# if defined (_POSIX_C_SOURCE) -# undef _POSIX_C_SOURCE -# endif // (re-)defined in pyconfig.h -#include - -#ifndef PI -#define PI M_PI -#endif - -//Basic Stuff -#include -#include -#include -#include -#include -#include -#include -#include - - -//Part Stuff -#include -#include - -//Mesh Stuff -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -//OCC Stuff -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -//Own Stuff -#include "Approx.h" -#include "ConvertDyna.h" -#include "cutting_tools.h" -#include "best_fit.h" -#include "SpringbackCorrection.h" - - -using namespace Part; -using namespace Mesh; -using namespace std; -using MeshCore::MeshKernel; - - -/* module functions */ -static PyObject * -open(PyObject *self, PyObject *args) -{ - char* Name; - if (!PyArg_ParseTuple(args, "et","utf-8",&Name)) - return NULL; - std::string EncodedName = std::string(Name); - PyMem_Free(Name); - - PY_TRY - { - - - } PY_CATCH; - - Py_Return; -} - - -/* module functions */ -static PyObject * insert(PyObject *self, PyObject *args) -{ - char* Name; - const char* DocName; - if (!PyArg_ParseTuple(args, "ets","utf-8",&Name,&DocName)) - return NULL; - std::string EncodedName = std::string(Name); - PyMem_Free(Name); - - PY_TRY - { - - } PY_CATCH; - - Py_Return; -} - -/* module functions */ -static PyObject * read(PyObject *self, PyObject *args) -{ - char* Name; - if (!PyArg_ParseTuple(args, "et","utf-8",&Name)) - return NULL; - std::string EncodedName = std::string(Name); - PyMem_Free(Name); - PY_TRY - { - - } PY_CATCH; - Py_Return; -} - - -static PyObject * tesselateShape(PyObject *self, PyObject *args) -{ - - PyObject *pcObj; - float aDeflection; - //PyObject *pcObj2; - if (!PyArg_ParseTuple(args, "O!f", &(TopoShapePy::Type), &pcObj, &aDeflection)) // convert args: Python->C - return NULL; // NULL triggers exception - - TopoShapePy *pcShape = static_cast(pcObj); //Surface or step file is passed - - - Base::Builder3D aBuild; - - MeshCore::MeshKernel mesh; - MeshCore::MeshBuilder builder(mesh); - builder.Initialize(1000); - Base::Vector3f Points[3]; - - PY_TRY - { - // removes all the triangulations of the faces , - //and all the polygons on the triangulations of the edges: - TopoDS_Shape aShape = pcShape->getTopoShapePtr()->_Shape; - BRepTools::Clean(aShape); - - // adds a triangulation of the shape aShape with the deflection aDeflection: - //BRepMesh_IncrementalMesh Mesh(pcShape->getShape(),aDeflection); - - BRepMesh::Mesh(aShape,aDeflection); - TopExp_Explorer aExpFace; - for (aExpFace.Init(aShape,TopAbs_FACE);aExpFace.More();aExpFace.Next()) - { - TopoDS_Face aFace = TopoDS::Face(aExpFace.Current()); - TopLoc_Location aLocation; - // takes the triangulation of the face aFace: - Handle_Poly_Triangulation aTr = BRep_Tool::Triangulation(aFace,aLocation); - if (!aTr.IsNull()) // if this triangulation is not NULL - { - // takes the array of nodes for this triangulation: - const TColgp_Array1OfPnt& aNodes = aTr->Nodes(); - // takes the array of triangles for this triangulation: - const Poly_Array1OfTriangle& triangles = aTr->Triangles(); - // create array of node points in absolute coordinate system - TColgp_Array1OfPnt aPoints(1, aNodes.Length()); - for ( Standard_Integer i = 1; i < aNodes.Length()+1; i++) - aPoints(i) = aNodes(i).Transformed(aLocation); - // Takes the node points of each triangle of this triangulation. - // takes a number of triangles: - Standard_Integer nnn = aTr->NbTriangles(); - Standard_Integer nt,n1,n2,n3; - for ( nt = 1 ; nt < nnn+1 ; nt++) - { - // takes the node indices of each triangle in n1,n2,n3: - triangles(nt).Get(n1,n2,n3); - // takes the node points: - gp_Pnt aPnt1 = aPoints(n1); - Points[0].Set(float(aPnt1.X()),float(aPnt1.Y()),float(aPnt1.Z())); - gp_Pnt aPnt2 = aPoints(n2); - Points[1].Set(float(aPnt2.X()),float(aPnt2.Y()),float(aPnt2.Z())); - gp_Pnt aPnt3 = aPoints(n3); - Points[2].Set(float(aPnt3.X()),float(aPnt3.Y()),float(aPnt3.Z())); - // give the occ faces to the internal mesh structure of freecad - MeshCore::MeshGeomFacet Face(Points[0],Points[1],Points[2]); - builder.AddFacet(Face); - - } - - } - // if the triangulation of only one face is not possible to get - else - { - throw Base::RuntimeError("Empty face triangulation\n"); - } - } - // finish FreeCAD Mesh Builder and exit with new mesh - builder.Finish(); - /*return new MeshPy(&mesh);*/ - } PY_CATCH; - - Py_Return; -} - -static PyObject * best_fit_coarse(PyObject *self, PyObject *args) -{ - PyObject *pcObj2; - - if (!PyArg_ParseTuple(args, "O!; Need one Mesh objects and one toposhape", &(TopoShapePy::Type), &pcObj2)) // convert args: Python->C - return NULL; // NULL triggers exception - - PY_TRY - { - - TopoShapePy *pcShape = static_cast(pcObj2); //Shape is passed - TopoDS_Shape cad = pcShape->getTopoShapePtr()->_Shape; // Input CAD - - - //best_fit befi(cad); - //best_fit::Tesselate_Shape(pcShape->getShape(),mesh,0.1); - - //return new MeshPy(&befi.m_CadMesh); - - //return new TopoShapePyOld(befi.m_Cad); - - /* - befi.MeshFit_Coarse(); - */ - - }PY_CATCH; - - Py_Return; -} - - -#include -#include - -//static PyObject * makeToolPath(PyObject *self, PyObject *args) -//{ -//// Py::List AllCuts = Py::List(); -//// double offset=0.0; -// ofstream anoutput,anoutput2; -// anoutput.open("c:/bspline_output.txt"); -// anoutput2.open("c:/bspline2_output.txt"); -// PyObject *pcObj; -// //PyObject *pcObj2; -// if (!PyArg_ParseTuple(args, "O!", &(TopoShapePyOld::Type), &pcObj)) // convert args: Python->C -// return NULL; // NULL triggers exception -// -// TopoShapePyOld *pcShape = static_cast(pcObj); //Surface is passed -//// TopoShapePyOld *pcShape2 = static_cast(pcObj2); //Cut-Curve -// PY_TRY -// { -// -// cutting_tools anewCuttingEnv(pcShape->getShape(),10.0); -// anewCuttingEnv.arrangecuts_ZLEVEL(); -// std::vector > aTestOutput = anewCuttingEnv.getCutShape(); -// BRep_Builder BB; -// -// TopoDS_Compound aCompound; -// -// BB.MakeCompound(aCompound); -// for (unsigned int i=0;i topCurves; -// std::vector botCurves; -// std::vector::iterator an_it; -// topCurves = *(anewCuttingEnv.getOutputhigh()); -// botCurves = *(anewCuttingEnv.getOutputlow()); -// for (unsigned int i=0;i(pcObj); //Original shape is passed here - - PY_TRY - { - - BRepOffsetAPI_MakeOffsetShape MakeOffsetShape (pcShape->getTopoShapePtr()->_Shape, - offset,0.001,BRepOffset_Skin); - return new TopoShapePy(new TopoShape(MakeOffsetShape.Shape())); - - - } PY_CATCH; - -} - - -/* -static PyObject * cut(PyObject *self, PyObject *args) -{ - PyObject *pcObj; - double z_pitch; - //double rGap = 1000.0; //Border around the bounding box for a clean result - if (!PyArg_ParseTuple(args, "O!d", &(TopoShapePyOld::Type), &pcObj,&z_pitch)) // convert args: Python->C - return NULL; // NULL triggers exception - - TopoShapePyOld *pcShape = static_cast(pcObj); //Surface to cut - //TopoShapePyOld *pcShape2 = static_cast(pcObj2); //Cutting Plane - - - ofstream outputfile; - outputfile.open("c:/allpoints.out"); - - PY_TRY - { - - - Base::Builder3D logit; - - - Now create the actual cuts: - 1. If the top level is a flat area, the bounding wires will be taken from there - Determination by means of the bounding box - 2. Then use the difference between two flat areas to determine the number of cuts with the given distance - 3. Convert the edges or wires into B-spline curves and then evaluate them - 4. Determine the sequence of operations and prepare the output for the simulation or experiment - - - - - //builder.Add(totalwire,mkWire.Wire()); - - - - - - - BRep_Builder buildface; - TopoDS_Face topoface; - buildface.MakeFace(topoface,asecondPlane,0.001); - //TopoDS_Wire wire = TopoDS::Wire(explore_cut.Current()); - - //Exp_Wire.Init(wire); - explore_cut.ReInit(); - for(; explore_cut.More(); explore_cut.Next()) - { - TopoDS_Edge edge = TopoDS::Edge(explore_cut.Current()); - BRepAdaptor_Curve cutedge(edge); - - Handle(BRepAdaptor_HCurve) hadapt_cutedge = new BRepAdaptor_HCurve(cutedge); - BRepAdaptor_Surface cutplane(topoface); - Handle(BRepAdaptor_HSurface) hadapt_cutplane = new BRepAdaptor_HSurface(cutplane); - intersect.Perform(hadapt_cutedge,hadapt_cutplane); - int numberofpoints = 0; - numberofpoints = intersect.NbPoints(); - if (numberofpoints > 0) - { - IntCurveSurface_IntersectionPoint pointofintersect = intersect.Point(1); - gp_Pnt actualIntersectPoint = pointofintersect.Pnt(); - logit.addSinglePoint(actualIntersectPoint.X(),actualIntersectPoint.Y(),actualIntersectPoint.Z(),10); - } - } - - } - } - - } - for(int i =0;iSurface () ; - - BRepBuilderAPI_MakeFace Face(Final_Approx); - - return new TopoShapePy(new TopoShape(Face.Face())); - } PY_CATCH; -} -/* BREP test function */ -static PyObject * -createTestBSPLINE(PyObject *self, PyObject *args) -{ - //const char* Name; - if (! PyArg_ParseTuple(args, "")) - return NULL; - - PY_TRY - { - TColgp_Array2OfPnt Poles(1,48,1,48); - - - Poles.SetValue(1,1,gp_Pnt(-150.004,-150.032,0.000561847)); - Poles.SetValue(1,2,gp_Pnt(-150.002,-142.327,-0.00168953)); - Poles.SetValue(1,3,gp_Pnt(-150,-126.92,-0.00028435)); - Poles.SetValue(1,4,gp_Pnt(-150,-103.831,-0.000519289)); - Poles.SetValue(1,5,gp_Pnt(-150,-84.6001,-0.000265669)); - Poles.SetValue(1,6,gp_Pnt(-150,-71.1405,-0.00162853)); - Poles.SetValue(1,7,gp_Pnt(-150,-63.4497,0.00623225)); - Poles.SetValue(1,8,gp_Pnt(-150,-57.6819,-0.00552693)); - Poles.SetValue(1,9,gp_Pnt(-150,-51.9139,-0.000608209)); - Poles.SetValue(1,10,gp_Pnt(-150.001,-47.107,-0.000761491)); - Poles.SetValue(1,11,gp_Pnt(-150.001,-43.2611,-0.000606976)); - Poles.SetValue(1,12,gp_Pnt(-150.001,-40.3767,0.000301703)); - Poles.SetValue(1,13,gp_Pnt(-150.001,-37.492,0.00136356)); - Poles.SetValue(1,14,gp_Pnt(-150.001,-34.6077,-0.000772864)); - Poles.SetValue(1,15,gp_Pnt(-150.001,-32.2036,-0.00110298)); - Poles.SetValue(1,16,gp_Pnt(-150.001,-30.2806,-0.000821554)); - Poles.SetValue(1,17,gp_Pnt(-150.001,-27.3959,-0.000341639)); - Poles.SetValue(1,18,gp_Pnt(-150.002,-24.0305,0.00107516)); - Poles.SetValue(1,19,gp_Pnt(-150.002,-20.1843,0.000545201)); - Poles.SetValue(1,20,gp_Pnt(-150.003,-16.3382,-0.0036344)); - Poles.SetValue(1,21,gp_Pnt(-150.003,-12.4921,-0.00133336)); - Poles.SetValue(1,22,gp_Pnt(-150.003,-8.64594,0.000602981)); - Poles.SetValue(1,23,gp_Pnt(-150.004,-5.76127,0.000740304)); - Poles.SetValue(1,24,gp_Pnt(-150.004,-1.91501,-0.000669011)); - Poles.SetValue(1,25,gp_Pnt(-150.004,1.93125,0.00331739)); - Poles.SetValue(1,26,gp_Pnt(-150.003,5.77745,0.00628266)); - Poles.SetValue(1,27,gp_Pnt(-150.003,8.6621,0.00185797)); - Poles.SetValue(1,28,gp_Pnt(-150.002,12.5083,0.00117201)); - Poles.SetValue(1,29,gp_Pnt(-150.002,16.3543,0.00359695)); - Poles.SetValue(1,30,gp_Pnt(-150.001,20.2004,-0.000866218)); - Poles.SetValue(1,31,gp_Pnt(-150.001,24.0465,0.0024382)); - Poles.SetValue(1,32,gp_Pnt(-150.001,27.4119,0.000782921)); - Poles.SetValue(1,33,gp_Pnt(-150.001,30.2965,0.00019153)); - Poles.SetValue(1,34,gp_Pnt(-150.001,32.2196,0.000181438)); - Poles.SetValue(1,35,gp_Pnt(-150.001,34.6234,-0.00175203)); - Poles.SetValue(1,36,gp_Pnt(-150,37.5078,0.00248825)); - Poles.SetValue(1,37,gp_Pnt(-150.001,40.3923,0.000162624)); - Poles.SetValue(1,38,gp_Pnt(-150.001,43.2767,-0.00043742)); - Poles.SetValue(1,39,gp_Pnt(-150.001,47.1224,-0.00243046)); - Poles.SetValue(1,40,gp_Pnt(-150,51.9291,0.00271265)); - Poles.SetValue(1,41,gp_Pnt(-150,57.6971,-0.00206532)); - Poles.SetValue(1,42,gp_Pnt(-150,63.4651,-0.000689487)); - Poles.SetValue(1,43,gp_Pnt(-150,71.1557,0.000696594)); - Poles.SetValue(1,44,gp_Pnt(-150,84.6148,-0.00159957)); - Poles.SetValue(1,45,gp_Pnt(-150,103.843,0.00079398)); - Poles.SetValue(1,46,gp_Pnt(-150,126.921,0.00325858)); - Poles.SetValue(1,47,gp_Pnt(-150,142.308,-0.00205645)); - Poles.SetValue(1,48,gp_Pnt(-150.001,150.002,0.000266785)); - Poles.SetValue(2,1,gp_Pnt(-142.31,-150.021,-0.00181926)); - Poles.SetValue(2,2,gp_Pnt(-142.309,-142.316,-0.126204)); - Poles.SetValue(2,3,gp_Pnt(-142.305,-126.903,-0.0907513)); - Poles.SetValue(2,4,gp_Pnt(-142.304,-103.808,-0.172784)); - Poles.SetValue(2,5,gp_Pnt(-142.302,-84.571,-0.256387)); - Poles.SetValue(2,6,gp_Pnt(-142.298,-71.1085,-0.215109)); - Poles.SetValue(2,7,gp_Pnt(-142.301,-63.4178,-0.321454)); - Poles.SetValue(2,8,gp_Pnt(-142.302,-57.6491,-0.362883)); - Poles.SetValue(2,9,gp_Pnt(-142.304,-51.8812,-0.411528)); - Poles.SetValue(2,10,gp_Pnt(-142.305,-47.0752,-0.435599)); - Poles.SetValue(2,11,gp_Pnt(-142.305,-43.2302,-0.438131)); - Poles.SetValue(2,12,gp_Pnt(-142.305,-40.3466,-0.445607)); - Poles.SetValue(2,13,gp_Pnt(-142.305,-37.4617,-0.436859)); - Poles.SetValue(2,14,gp_Pnt(-142.305,-34.5771,-0.442155)); - Poles.SetValue(2,15,gp_Pnt(-142.304,-32.1727,-0.43872)); - Poles.SetValue(2,16,gp_Pnt(-142.305,-30.2502,-0.452521)); - Poles.SetValue(2,17,gp_Pnt(-142.307,-27.3666,-0.474689)); - Poles.SetValue(2,18,gp_Pnt(-142.311,-24.0038,-0.521193)); - Poles.SetValue(2,19,gp_Pnt(-142.314,-20.1589,-0.56475)); - Poles.SetValue(2,20,gp_Pnt(-142.319,-16.3146,-0.619306)); - Poles.SetValue(2,21,gp_Pnt(-142.321,-12.4685,-0.646119)); - Poles.SetValue(2,22,gp_Pnt(-142.321,-8.62227,-0.646118)); - Poles.SetValue(2,23,gp_Pnt(-142.321,-5.73782,-0.634708)); - Poles.SetValue(2,24,gp_Pnt(-142.317,-1.89155,-0.588682)); - Poles.SetValue(2,25,gp_Pnt(-142.316,1.95492,-0.560158)); - Poles.SetValue(2,26,gp_Pnt(-142.316,5.80123,-0.547648)); - Poles.SetValue(2,27,gp_Pnt(-142.313,8.68585,-0.518341)); - Poles.SetValue(2,28,gp_Pnt(-142.312,12.532,-0.500341)); - Poles.SetValue(2,29,gp_Pnt(-142.311,16.3777,-0.499537)); - Poles.SetValue(2,30,gp_Pnt(-142.307,20.2226,-0.465716)); - Poles.SetValue(2,31,gp_Pnt(-142.307,24.0679,-0.460146)); - Poles.SetValue(2,32,gp_Pnt(-142.304,27.4314,-0.438242)); - Poles.SetValue(2,33,gp_Pnt(-142.304,30.315,-0.433771)); - Poles.SetValue(2,34,gp_Pnt(-142.304,32.2374,-0.432231)); - Poles.SetValue(2,35,gp_Pnt(-142.306,34.6411,-0.446475)); - Poles.SetValue(2,36,gp_Pnt(-142.306,37.525,-0.445412)); - Poles.SetValue(2,37,gp_Pnt(-142.307,40.4085,-0.44998)); - Poles.SetValue(2,38,gp_Pnt(-142.306,43.2916,-0.431981)); - Poles.SetValue(2,39,gp_Pnt(-142.305,47.1355,-0.408878)); - Poles.SetValue(2,40,gp_Pnt(-142.303,51.94,-0.366882)); - Poles.SetValue(2,41,gp_Pnt(-142.301,57.7052,-0.307906)); - Poles.SetValue(2,42,gp_Pnt(-142.301,63.4721,-0.30131)); - Poles.SetValue(2,43,gp_Pnt(-142.302,71.1622,-0.256453)); - Poles.SetValue(2,44,gp_Pnt(-142.302,84.6149,-0.220375)); - Poles.SetValue(2,45,gp_Pnt(-142.31,103.846,-0.23077)); - Poles.SetValue(2,46,gp_Pnt(-142.304,126.92,0.0181769)); - Poles.SetValue(2,47,gp_Pnt(-142.309,142.309,-0.0738464)); - Poles.SetValue(2,48,gp_Pnt(-142.307,150.001,0.000863329)); - Poles.SetValue(3,1,gp_Pnt(-126.921,-150,0.00165292)); - Poles.SetValue(3,2,gp_Pnt(-126.921,-142.291,-0.108971)); - Poles.SetValue(3,3,gp_Pnt(-126.916,-126.875,-0.280815)); - Poles.SetValue(3,4,gp_Pnt(-126.912,-103.76,-0.548913)); - Poles.SetValue(3,5,gp_Pnt(-126.904,-84.5133,-0.647195)); - Poles.SetValue(3,6,gp_Pnt(-126.909,-71.0494,-0.979561)); - Poles.SetValue(3,7,gp_Pnt(-126.905,-63.3539,-0.997419)); - Poles.SetValue(3,8,gp_Pnt(-126.904,-57.5844,-1.07424)); - Poles.SetValue(3,9,gp_Pnt(-126.902,-51.8141,-1.11764)); - Poles.SetValue(3,10,gp_Pnt(-126.901,-47.0063,-1.16545)); - Poles.SetValue(3,11,gp_Pnt(-126.904,-43.162,-1.23177)); - Poles.SetValue(3,12,gp_Pnt(-126.906,-40.2796,-1.27218)); - Poles.SetValue(3,13,gp_Pnt(-126.91,-37.3996,-1.3403)); - Poles.SetValue(3,14,gp_Pnt(-126.913,-34.5199,-1.37958)); - Poles.SetValue(3,15,gp_Pnt(-126.918,-32.1209,-1.42493)); - Poles.SetValue(3,16,gp_Pnt(-126.919,-30.1996,-1.43471)); - Poles.SetValue(3,17,gp_Pnt(-126.92,-27.3171,-1.44871)); - Poles.SetValue(3,18,gp_Pnt(-126.916,-23.9503,-1.43521)); - Poles.SetValue(3,19,gp_Pnt(-126.915,-20.1051,-1.43151)); - Poles.SetValue(3,20,gp_Pnt(-126.906,-16.2565,-1.38855)); - Poles.SetValue(3,21,gp_Pnt(-126.903,-12.4114,-1.40876)); - Poles.SetValue(3,22,gp_Pnt(-126.9,-8.56614,-1.41947)); - Poles.SetValue(3,23,gp_Pnt(-126.897,-5.68165,-1.41744)); - Poles.SetValue(3,24,gp_Pnt(-126.899,-1.83662,-1.46074)); - Poles.SetValue(3,25,gp_Pnt(-126.896,2.00777,-1.45305)); - Poles.SetValue(3,26,gp_Pnt(-126.895,5.85236,-1.4119)); - Poles.SetValue(3,27,gp_Pnt(-126.9,8.73579,-1.42133)); - Poles.SetValue(3,28,gp_Pnt(-126.903,12.58,-1.39958)); - Poles.SetValue(3,29,gp_Pnt(-126.905,16.4245,-1.35132)); - Poles.SetValue(3,30,gp_Pnt(-126.914,20.2695,-1.36455)); - Poles.SetValue(3,31,gp_Pnt(-126.911,24.1114,-1.3157)); - Poles.SetValue(3,32,gp_Pnt(-126.913,27.4746,-1.29886)); - Poles.SetValue(3,33,gp_Pnt(-126.911,30.3549,-1.2689)); - Poles.SetValue(3,34,gp_Pnt(-126.909,32.275,-1.24747)); - Poles.SetValue(3,35,gp_Pnt(-126.904,34.6731,-1.20445)); - Poles.SetValue(3,36,gp_Pnt(-126.901,37.5522,-1.17054)); - Poles.SetValue(3,37,gp_Pnt(-126.898,40.4322,-1.14411)); - Poles.SetValue(3,38,gp_Pnt(-126.898,43.3131,-1.12165)); - Poles.SetValue(3,39,gp_Pnt(-126.899,47.1552,-1.1049)); - Poles.SetValue(3,40,gp_Pnt(-126.903,51.9593,-1.08453)); - Poles.SetValue(3,41,gp_Pnt(-126.906,57.7251,-1.02902)); - Poles.SetValue(3,42,gp_Pnt(-126.909,63.4889,-0.984029)); - Poles.SetValue(3,43,gp_Pnt(-126.912,71.1726,-0.939984)); - Poles.SetValue(3,44,gp_Pnt(-126.916,84.6287,-0.75009)); - Poles.SetValue(3,45,gp_Pnt(-126.914,103.84,-0.446948)); - Poles.SetValue(3,46,gp_Pnt(-126.922,126.917,-0.208932)); - Poles.SetValue(3,47,gp_Pnt(-126.919,142.304,-0.0369009)); - Poles.SetValue(3,48,gp_Pnt(-126.921,150,-0.00113251)); - Poles.SetValue(4,1,gp_Pnt(-103.843,-150,-0.0010153)); - Poles.SetValue(4,2,gp_Pnt(-103.841,-142.278,-0.149614)); - Poles.SetValue(4,3,gp_Pnt(-103.841,-126.835,-0.557018)); - Poles.SetValue(4,4,gp_Pnt(-103.832,-103.697,-1.04331)); - Poles.SetValue(4,5,gp_Pnt(-103.825,-84.4296,-1.51248)); - Poles.SetValue(4,6,gp_Pnt(-103.814,-70.9483,-1.71721)); - Poles.SetValue(4,7,gp_Pnt(-103.81,-63.2492,-1.91447)); - Poles.SetValue(4,8,gp_Pnt(-103.805,-57.475,-2.0133)); - Poles.SetValue(4,9,gp_Pnt(-103.802,-51.7032,-2.17279)); - Poles.SetValue(4,10,gp_Pnt(-103.796,-46.8927,-2.30177)); - Poles.SetValue(4,11,gp_Pnt(-103.786,-43.0402,-2.38814)); - Poles.SetValue(4,12,gp_Pnt(-103.778,-40.152,-2.44243)); - Poles.SetValue(4,13,gp_Pnt(-103.765,-37.2574,-2.50059)); - Poles.SetValue(4,14,gp_Pnt(-103.753,-34.3676,-2.54694)); - Poles.SetValue(4,15,gp_Pnt(-103.741,-31.9551,-2.60633)); - Poles.SetValue(4,16,gp_Pnt(-103.734,-30.0306,-2.65752)); - Poles.SetValue(4,17,gp_Pnt(-103.725,-27.1449,-2.73151)); - Poles.SetValue(4,18,gp_Pnt(-103.722,-23.7866,-2.82704)); - Poles.SetValue(4,19,gp_Pnt(-103.716,-19.9474,-2.91344)); - Poles.SetValue(4,20,gp_Pnt(-103.726,-16.1157,-3.04938)); - Poles.SetValue(4,21,gp_Pnt(-103.727,-12.2811,-3.06216)); - Poles.SetValue(4,22,gp_Pnt(-103.73,-8.44811,-3.0722)); - Poles.SetValue(4,23,gp_Pnt(-103.734,-5.57452,-3.08626)); - Poles.SetValue(4,24,gp_Pnt(-103.733,-1.74218,-3.02862)); - Poles.SetValue(4,25,gp_Pnt(-103.739,2.09027,-3.04208)); - Poles.SetValue(4,26,gp_Pnt(-103.743,5.92168,-3.09969)); - Poles.SetValue(4,27,gp_Pnt(-103.739,8.795,-3.08108)); - Poles.SetValue(4,28,gp_Pnt(-103.737,12.6264,-3.09153)); - Poles.SetValue(4,29,gp_Pnt(-103.739,16.4571,-3.11293)); - Poles.SetValue(4,30,gp_Pnt(-103.733,20.2881,-3.01659)); - Poles.SetValue(4,31,gp_Pnt(-103.744,24.1243,-2.98515)); - Poles.SetValue(4,32,gp_Pnt(-103.749,27.4798,-2.90047)); - Poles.SetValue(4,33,gp_Pnt(-103.759,30.3609,-2.8434)); - Poles.SetValue(4,34,gp_Pnt(-103.766,32.282,-2.80723)); - Poles.SetValue(4,35,gp_Pnt(-103.781,34.6883,-2.77627)); - Poles.SetValue(4,36,gp_Pnt(-103.792,37.5714,-2.73126)); - Poles.SetValue(4,37,gp_Pnt(-103.803,40.4561,-2.66247)); - Poles.SetValue(4,38,gp_Pnt(-103.811,43.3376,-2.62498)); - Poles.SetValue(4,39,gp_Pnt(-103.819,47.1799,-2.53849)); - Poles.SetValue(4,40,gp_Pnt(-103.824,51.9789,-2.42499)); - Poles.SetValue(4,41,gp_Pnt(-103.828,57.7369,-2.30022)); - Poles.SetValue(4,42,gp_Pnt(-103.83,63.4966,-2.12922)); - Poles.SetValue(4,43,gp_Pnt(-103.832,71.1786,-1.8623)); - Poles.SetValue(4,44,gp_Pnt(-103.837,84.6178,-1.53092)); - Poles.SetValue(4,45,gp_Pnt(-103.85,103.844,-1.13325)); - Poles.SetValue(4,46,gp_Pnt(-103.848,126.916,-0.481826)); - Poles.SetValue(4,47,gp_Pnt(-103.846,142.306,-0.137169)); - Poles.SetValue(4,48,gp_Pnt(-103.844,150,0.000586788)); - Poles.SetValue(5,1,gp_Pnt(-84.614,-150,0.000270488)); - Poles.SetValue(5,2,gp_Pnt(-84.6141,-142.269,-0.159149)); - Poles.SetValue(5,3,gp_Pnt(-84.6159,-126.815,-0.660259)); - Poles.SetValue(5,4,gp_Pnt(-84.6086,-103.651,-1.4185)); - Poles.SetValue(5,5,gp_Pnt(-84.5935,-84.3582,-2.06391)); - Poles.SetValue(5,6,gp_Pnt(-84.5714,-70.8586,-2.4464)); - Poles.SetValue(5,7,gp_Pnt(-84.5628,-63.1503,-2.67335)); - Poles.SetValue(5,8,gp_Pnt(-84.5613,-57.3748,-2.91676)); - Poles.SetValue(5,9,gp_Pnt(-84.5613,-51.6011,-3.07405)); - Poles.SetValue(5,10,gp_Pnt(-84.5691,-46.7952,-3.20612)); - Poles.SetValue(5,11,gp_Pnt(-84.5837,-42.9554,-3.33601)); - Poles.SetValue(5,12,gp_Pnt(-84.5994,-40.0793,-3.44324)); - Poles.SetValue(5,13,gp_Pnt(-84.6194,-37.2057,-3.54474)); - Poles.SetValue(5,14,gp_Pnt(-84.6441,-34.3358,-3.66032)); - Poles.SetValue(5,15,gp_Pnt(-84.6655,-31.9433,-3.73538)); - Poles.SetValue(5,16,gp_Pnt(-84.6811,-30.0273,-3.78877)); - Poles.SetValue(5,17,gp_Pnt(-84.704,-27.1526,-3.87363)); - Poles.SetValue(5,18,gp_Pnt(-84.7235,-23.7921,-3.94992)); - Poles.SetValue(5,19,gp_Pnt(-84.7453,-19.953,-4.04994)); - Poles.SetValue(5,20,gp_Pnt(-84.7487,-16.1062,-4.06117)); - Poles.SetValue(5,21,gp_Pnt(-84.761,-12.2635,-4.21439)); - Poles.SetValue(5,22,gp_Pnt(-84.7646,-8.4186,-4.30051)); - Poles.SetValue(5,23,gp_Pnt(-84.7638,-5.53345,-4.32728)); - Poles.SetValue(5,24,gp_Pnt(-84.7694,-1.6881,-4.45068)); - Poles.SetValue(5,25,gp_Pnt(-84.762,2.15614,-4.45867)); - Poles.SetValue(5,26,gp_Pnt(-84.7563,6.00003,-4.40673)); - Poles.SetValue(5,27,gp_Pnt(-84.7609,8.88229,-4.44703)); - Poles.SetValue(5,28,gp_Pnt(-84.7604,12.7235,-4.42816)); - Poles.SetValue(5,29,gp_Pnt(-84.7534,16.563,-4.35447)); - Poles.SetValue(5,30,gp_Pnt(-84.754,20.3999,-4.39459)); - Poles.SetValue(5,31,gp_Pnt(-84.7327,24.2293,-4.30122)); - Poles.SetValue(5,32,gp_Pnt(-84.7173,27.5803,-4.27802)); - Poles.SetValue(5,33,gp_Pnt(-84.6977,30.4479,-4.21241)); - Poles.SetValue(5,34,gp_Pnt(-84.6843,32.3595,-4.16497)); - Poles.SetValue(5,35,gp_Pnt(-84.6617,34.7453,-4.05325)); - Poles.SetValue(5,36,gp_Pnt(-84.642,37.6106,-3.97243)); - Poles.SetValue(5,37,gp_Pnt(-84.626,40.4793,-3.88558)); - Poles.SetValue(5,38,gp_Pnt(-84.613,43.3488,-3.76512)); - Poles.SetValue(5,39,gp_Pnt(-84.602,47.1786,-3.6382)); - Poles.SetValue(5,40,gp_Pnt(-84.5979,51.9706,-3.48883)); - Poles.SetValue(5,41,gp_Pnt(-84.5955,57.7241,-3.24621)); - Poles.SetValue(5,42,gp_Pnt(-84.5981,63.4805,-3.0356)); - Poles.SetValue(5,43,gp_Pnt(-84.6055,71.1595,-2.79784)); - Poles.SetValue(5,44,gp_Pnt(-84.622,84.6125,-2.27334)); - Poles.SetValue(5,45,gp_Pnt(-84.632,103.829,-1.5763)); - Poles.SetValue(5,46,gp_Pnt(-84.6319,126.911,-0.827433)); - Poles.SetValue(5,47,gp_Pnt(-84.6202,142.302,-0.277168)); - Poles.SetValue(5,48,gp_Pnt(-84.616,150,-0.00084759)); - Poles.SetValue(6,1,gp_Pnt(-71.1545,-150,0.000818217)); - Poles.SetValue(6,2,gp_Pnt(-71.1559,-142.265,-0.171988)); - Poles.SetValue(6,3,gp_Pnt(-71.1636,-126.808,-0.877511)); - Poles.SetValue(6,4,gp_Pnt(-71.156,-103.621,-1.6021)); - Poles.SetValue(6,5,gp_Pnt(-71.1356,-84.3088,-2.3871)); - Poles.SetValue(6,6,gp_Pnt(-71.1082,-70.796,-2.8955)); - Poles.SetValue(6,7,gp_Pnt(-71.0937,-63.0781,-3.24057)); - Poles.SetValue(6,8,gp_Pnt(-71.0799,-57.2886,-3.46587)); - Poles.SetValue(6,9,gp_Pnt(-71.0655,-51.499,-3.70299)); - Poles.SetValue(6,10,gp_Pnt(-71.0546,-46.6771,-3.94985)); - Poles.SetValue(6,11,gp_Pnt(-71.0462,-42.8205,-4.15299)); - Poles.SetValue(6,12,gp_Pnt(-71.0381,-39.9275,-4.28235)); - Poles.SetValue(6,13,gp_Pnt(-71.0329,-37.0353,-4.43768)); - Poles.SetValue(6,14,gp_Pnt(-71.026,-34.1434,-4.56256)); - Poles.SetValue(6,15,gp_Pnt(-71.0223,-31.7352,-4.68719)); - Poles.SetValue(6,16,gp_Pnt(-71.0206,-29.8116,-4.79297)); - Poles.SetValue(6,17,gp_Pnt(-71.0187,-26.9274,-4.95523)); - Poles.SetValue(6,18,gp_Pnt(-71.0182,-23.5685,-5.15222)); - Poles.SetValue(6,19,gp_Pnt(-71.0127,-19.7304,-5.35227)); - Poles.SetValue(6,20,gp_Pnt(-71.0136,-15.8989,-5.56506)); - Poles.SetValue(6,21,gp_Pnt(-71.0096,-12.0712,-5.68795)); - Poles.SetValue(6,22,gp_Pnt(-71.0107,-8.25242,-5.79463)); - Poles.SetValue(6,23,gp_Pnt(-71.0139,-5.39299,-5.88817)); - Poles.SetValue(6,24,gp_Pnt(-71.0145,-1.5833,-5.93167)); - Poles.SetValue(6,25,gp_Pnt(-71.0292,2.22315,-5.99844)); - Poles.SetValue(6,26,gp_Pnt(-71.0411,6.02965,-6.03414)); - Poles.SetValue(6,27,gp_Pnt(-71.0445,8.88553,-5.98762)); - Poles.SetValue(6,28,gp_Pnt(-71.0538,12.6963,-5.9483)); - Poles.SetValue(6,29,gp_Pnt(-71.0673,16.5105,-5.90522)); - Poles.SetValue(6,30,gp_Pnt(-71.0725,20.328,-5.76435)); - Poles.SetValue(6,31,gp_Pnt(-71.0851,24.1504,-5.66147)); - Poles.SetValue(6,32,gp_Pnt(-71.0875,27.4934,-5.51298)); - Poles.SetValue(6,33,gp_Pnt(-71.0908,30.364,-5.39372)); - Poles.SetValue(6,34,gp_Pnt(-71.0932,32.2778,-5.31749)); - Poles.SetValue(6,35,gp_Pnt(-71.0997,34.6747,-5.24058)); - Poles.SetValue(6,36,gp_Pnt(-71.1085,37.552,-5.1317)); - Poles.SetValue(6,37,gp_Pnt(-71.1096,40.4266,-4.95936)); - Poles.SetValue(6,38,gp_Pnt(-71.1188,43.3052,-4.8684)); - Poles.SetValue(6,39,gp_Pnt(-71.1247,47.1418,-4.66742)); - Poles.SetValue(6,40,gp_Pnt(-71.1323,51.9393,-4.41857)); - Poles.SetValue(6,41,gp_Pnt(-71.1417,57.6996,-4.12519)); - Poles.SetValue(6,42,gp_Pnt(-71.1508,63.4613,-3.8404)); - Poles.SetValue(6,43,gp_Pnt(-71.162,71.1459,-3.46491)); - Poles.SetValue(6,44,gp_Pnt(-71.1789,84.5949,-2.84945)); - Poles.SetValue(6,45,gp_Pnt(-71.191,103.827,-1.9693)); - Poles.SetValue(6,46,gp_Pnt(-71.1797,126.907,-0.936212)); - Poles.SetValue(6,47,gp_Pnt(-71.1648,142.304,-0.336438)); - Poles.SetValue(6,48,gp_Pnt(-71.1568,150,-0.000475897)); - Poles.SetValue(7,1,gp_Pnt(-63.4635,-150,0.000362352)); - Poles.SetValue(7,2,gp_Pnt(-63.4667,-142.266,-0.270865)); - Poles.SetValue(7,3,gp_Pnt(-63.4754,-126.801,-0.886325)); - Poles.SetValue(7,4,gp_Pnt(-63.4707,-103.604,-1.70578)); - Poles.SetValue(7,5,gp_Pnt(-63.4505,-84.2857,-2.5768)); - Poles.SetValue(7,6,gp_Pnt(-63.4181,-70.7632,-3.20272)); - Poles.SetValue(7,7,gp_Pnt(-63.3948,-63.0341,-3.53045)); - Poles.SetValue(7,8,gp_Pnt(-63.3767,-57.2389,-3.80851)); - Poles.SetValue(7,9,gp_Pnt(-63.3583,-51.4454,-4.13513)); - Poles.SetValue(7,10,gp_Pnt(-63.338,-46.6134,-4.37957)); - Poles.SetValue(7,11,gp_Pnt(-63.319,-42.7455,-4.60555)); - Poles.SetValue(7,12,gp_Pnt(-63.3044,-39.8447,-4.78324)); - Poles.SetValue(7,13,gp_Pnt(-63.2827,-36.9396,-4.96843)); - Poles.SetValue(7,14,gp_Pnt(-63.2624,-34.0396,-5.18158)); - Poles.SetValue(7,15,gp_Pnt(-63.2386,-31.6189,-5.33987)); - Poles.SetValue(7,16,gp_Pnt(-63.221,-29.6882,-5.45269)); - Poles.SetValue(7,17,gp_Pnt(-63.1927,-26.7909,-5.60579)); - Poles.SetValue(7,18,gp_Pnt(-63.1645,-23.4252,-5.7359)); - Poles.SetValue(7,19,gp_Pnt(-63.1509,-19.5935,-5.838)); - Poles.SetValue(7,20,gp_Pnt(-63.1439,-15.77,-5.92716)); - Poles.SetValue(7,21,gp_Pnt(-63.1534,-11.9628,-6.05663)); - Poles.SetValue(7,22,gp_Pnt(-63.1624,-8.16097,-6.16538)); - Poles.SetValue(7,23,gp_Pnt(-63.1713,-5.31206,-6.20947)); - Poles.SetValue(7,24,gp_Pnt(-63.193,-1.51882,-6.33325)); - Poles.SetValue(7,25,gp_Pnt(-63.1982,2.26931,-6.42672)); - Poles.SetValue(7,26,gp_Pnt(-63.2064,6.05752,-6.45684)); - Poles.SetValue(7,27,gp_Pnt(-63.2158,8.89967,-6.49216)); - Poles.SetValue(7,28,gp_Pnt(-63.2266,12.6896,-6.5197)); - Poles.SetValue(7,29,gp_Pnt(-63.2272,16.4827,-6.46308)); - Poles.SetValue(7,30,gp_Pnt(-63.2514,20.2851,-6.51582)); - Poles.SetValue(7,31,gp_Pnt(-63.2665,24.0915,-6.41687)); - Poles.SetValue(7,32,gp_Pnt(-63.3025,27.4349,-6.36479)); - Poles.SetValue(7,33,gp_Pnt(-63.3303,30.3117,-6.22694)); - Poles.SetValue(7,34,gp_Pnt(-63.3488,32.2305,-6.13272)); - Poles.SetValue(7,35,gp_Pnt(-63.366,34.6316,-5.97585)); - Poles.SetValue(7,36,gp_Pnt(-63.3837,37.5115,-5.82491)); - Poles.SetValue(7,37,gp_Pnt(-63.4034,40.3963,-5.69285)); - Poles.SetValue(7,38,gp_Pnt(-63.4132,43.2758,-5.49842)); - Poles.SetValue(7,39,gp_Pnt(-63.4263,47.1169,-5.25128)); - Poles.SetValue(7,40,gp_Pnt(-63.4394,51.9183,-4.95511)); - Poles.SetValue(7,41,gp_Pnt(-63.4539,57.6817,-4.64148)); - Poles.SetValue(7,42,gp_Pnt(-63.4684,63.4475,-4.3285)); - Poles.SetValue(7,43,gp_Pnt(-63.4802,71.1311,-3.82751)); - Poles.SetValue(7,44,gp_Pnt(-63.499,84.589,-3.10785)); - Poles.SetValue(7,45,gp_Pnt(-63.5115,103.821,-2.17125)); - Poles.SetValue(7,46,gp_Pnt(-63.4944,126.908,-1.06963)); - Poles.SetValue(7,47,gp_Pnt(-63.4761,142.304,-0.392153)); - Poles.SetValue(7,48,gp_Pnt(-63.4659,150,0.000947448)); - Poles.SetValue(8,1,gp_Pnt(-57.6952,-150,-0.00314282)); - Poles.SetValue(8,2,gp_Pnt(-57.6995,-142.266,-0.311295)); - Poles.SetValue(8,3,gp_Pnt(-57.7097,-126.797,-0.921112)); - Poles.SetValue(8,4,gp_Pnt(-57.7066,-103.591,-1.73366)); - Poles.SetValue(8,5,gp_Pnt(-57.6899,-84.2722,-2.7131)); - Poles.SetValue(8,6,gp_Pnt(-57.6482,-70.7348,-3.36076)); - Poles.SetValue(8,7,gp_Pnt(-57.6215,-63.0007,-3.76313)); - Poles.SetValue(8,8,gp_Pnt(-57.5991,-57.2001,-4.08499)); - Poles.SetValue(8,9,gp_Pnt(-57.5756,-51.4007,-4.39273)); - Poles.SetValue(8,10,gp_Pnt(-57.554,-46.5664,-4.69516)); - Poles.SetValue(8,11,gp_Pnt(-57.5322,-42.6946,-4.96155)); - Poles.SetValue(8,12,gp_Pnt(-57.5132,-39.7891,-5.21994)); - Poles.SetValue(8,13,gp_Pnt(-57.4836,-36.8743,-5.38283)); - Poles.SetValue(8,14,gp_Pnt(-57.4423,-33.9556,-5.4932)); - Poles.SetValue(8,15,gp_Pnt(-57.402,-31.5272,-5.53467)); - Poles.SetValue(8,16,gp_Pnt(-57.3861,-29.5989,-5.60063)); - Poles.SetValue(8,17,gp_Pnt(-57.3688,-26.7132,-5.72085)); - Poles.SetValue(8,18,gp_Pnt(-57.398,-23.3843,-5.9876)); - Poles.SetValue(8,19,gp_Pnt(-57.4294,-19.5722,-6.26213)); - Poles.SetValue(8,20,gp_Pnt(-57.5035,-15.7794,-6.68012)); - Poles.SetValue(8,21,gp_Pnt(-57.5719,-11.9809,-7.06297)); - Poles.SetValue(8,22,gp_Pnt(-57.6221,-8.1767,-7.32819)); - Poles.SetValue(8,23,gp_Pnt(-57.6505,-5.32072,-7.50978)); - Poles.SetValue(8,24,gp_Pnt(-57.6777,-1.51151,-7.67969)); - Poles.SetValue(8,25,gp_Pnt(-57.7106,2.29043,-7.79385)); - Poles.SetValue(8,26,gp_Pnt(-57.6789,6.09212,-7.72725)); - Poles.SetValue(8,27,gp_Pnt(-57.6575,8.94134,-7.67509)); - Poles.SetValue(8,28,gp_Pnt(-57.6107,12.7342,-7.50788)); - Poles.SetValue(8,29,gp_Pnt(-57.5593,16.5215,-7.2957)); - Poles.SetValue(8,30,gp_Pnt(-57.5083,20.3002,-7.009)); - Poles.SetValue(8,31,gp_Pnt(-57.4814,24.0877,-6.79325)); - Poles.SetValue(8,32,gp_Pnt(-57.4846,27.4081,-6.67069)); - Poles.SetValue(8,33,gp_Pnt(-57.5135,30.2753,-6.61361)); - Poles.SetValue(8,34,gp_Pnt(-57.5328,32.1869,-6.57093)); - Poles.SetValue(8,35,gp_Pnt(-57.5743,34.5945,-6.55824)); - Poles.SetValue(8,36,gp_Pnt(-57.6121,37.4882,-6.44634)); - Poles.SetValue(8,37,gp_Pnt(-57.628,40.3737,-6.21298)); - Poles.SetValue(8,38,gp_Pnt(-57.6442,43.2575,-6.00935)); - Poles.SetValue(8,39,gp_Pnt(-57.6633,47.1029,-5.76432)); - Poles.SetValue(8,40,gp_Pnt(-57.6718,51.9,-5.37064)); - Poles.SetValue(8,41,gp_Pnt(-57.6883,57.6662,-5.02319)); - Poles.SetValue(8,42,gp_Pnt(-57.7048,63.4336,-4.65762)); - Poles.SetValue(8,43,gp_Pnt(-57.7185,71.1203,-4.08762)); - Poles.SetValue(8,44,gp_Pnt(-57.7448,84.5871,-3.3533)); - Poles.SetValue(8,45,gp_Pnt(-57.7511,103.816,-2.29786)); - Poles.SetValue(8,46,gp_Pnt(-57.7309,126.907,-1.1419)); - Poles.SetValue(8,47,gp_Pnt(-57.7091,142.303,-0.384611)); - Poles.SetValue(8,48,gp_Pnt(-57.6978,150,-0.00163315)); - Poles.SetValue(9,1,gp_Pnt(-51.9266,-150,-0.000170689)); - Poles.SetValue(9,2,gp_Pnt(-51.9325,-142.265,-0.308476)); - Poles.SetValue(9,3,gp_Pnt(-51.9437,-126.792,-0.954312)); - Poles.SetValue(9,4,gp_Pnt(-51.9434,-103.579,-1.79846)); - Poles.SetValue(9,5,gp_Pnt(-51.9339,-84.2654,-2.84979)); - Poles.SetValue(9,6,gp_Pnt(-51.8762,-70.7033,-3.47842)); - Poles.SetValue(9,7,gp_Pnt(-51.8492,-62.9676,-3.99915)); - Poles.SetValue(9,8,gp_Pnt(-51.8239,-57.1623,-4.34605)); - Poles.SetValue(9,9,gp_Pnt(-51.7903,-51.3504,-4.69053)); - Poles.SetValue(9,10,gp_Pnt(-51.7729,-46.5189,-5.09883)); - Poles.SetValue(9,11,gp_Pnt(-51.757,-42.6481,-5.27347)); - Poles.SetValue(9,12,gp_Pnt(-51.7513,-39.7469,-5.30536)); - Poles.SetValue(9,13,gp_Pnt(-51.7401,-36.8465,-5.38604)); - Poles.SetValue(9,14,gp_Pnt(-51.7694,-33.9846,-5.66624)); - Poles.SetValue(9,15,gp_Pnt(-51.7798,-31.5914,-5.96847)); - Poles.SetValue(9,16,gp_Pnt(-51.8152,-29.6949,-6.3184)); - Poles.SetValue(9,17,gp_Pnt(-51.8773,-26.8541,-6.90413)); - Poles.SetValue(9,18,gp_Pnt(-51.9335,-23.5242,-7.53269)); - Poles.SetValue(9,19,gp_Pnt(-52.0359,-19.7223,-8.2157)); - Poles.SetValue(9,20,gp_Pnt(-52.1308,-15.9092,-8.84603)); - Poles.SetValue(9,21,gp_Pnt(-52.2346,-12.094,-9.39748)); - Poles.SetValue(9,22,gp_Pnt(-52.3068,-8.26388,-9.81203)); - Poles.SetValue(9,23,gp_Pnt(-52.3488,-5.38726,-10.0427)); - Poles.SetValue(9,24,gp_Pnt(-52.391,-1.54826,-10.2726)); - Poles.SetValue(9,25,gp_Pnt(-52.4088,2.29184,-10.382)); - Poles.SetValue(9,26,gp_Pnt(-52.3622,6.12771,-10.2589)); - Poles.SetValue(9,27,gp_Pnt(-52.3201,8.99991,-10.0938)); - Poles.SetValue(9,28,gp_Pnt(-52.2783,12.8262,-9.86285)); - Poles.SetValue(9,29,gp_Pnt(-52.1925,16.6338,-9.442)); - Poles.SetValue(9,30,gp_Pnt(-52.1187,20.4371,-8.97308)); - Poles.SetValue(9,31,gp_Pnt(-52.0376,24.2289,-8.44813)); - Poles.SetValue(9,32,gp_Pnt(-51.9688,27.5366,-7.90192)); - Poles.SetValue(9,33,gp_Pnt(-51.9242,30.3704,-7.47434)); - Poles.SetValue(9,34,gp_Pnt(-51.9019,32.2644,-7.22041)); - Poles.SetValue(9,35,gp_Pnt(-51.8684,34.6208,-6.88143)); - Poles.SetValue(9,36,gp_Pnt(-51.8535,37.4738,-6.68843)); - Poles.SetValue(9,37,gp_Pnt(-51.8792,40.3596,-6.69292)); - Poles.SetValue(9,38,gp_Pnt(-51.8924,43.2452,-6.61057)); - Poles.SetValue(9,39,gp_Pnt(-51.8939,47.0764,-6.26774)); - Poles.SetValue(9,40,gp_Pnt(-51.9082,51.8812,-5.88782)); - Poles.SetValue(9,41,gp_Pnt(-51.9297,57.653,-5.46697)); - Poles.SetValue(9,42,gp_Pnt(-51.9428,63.4193,-5.00425)); - Poles.SetValue(9,43,gp_Pnt(-51.9613,71.113,-4.45556)); - Poles.SetValue(9,44,gp_Pnt(-51.9912,84.5843,-3.48722)); - Poles.SetValue(9,45,gp_Pnt(-51.9934,103.813,-2.50034)); - Poles.SetValue(9,46,gp_Pnt(-51.9654,126.903,-1.154)); - Poles.SetValue(9,47,gp_Pnt(-51.9437,142.306,-0.456106)); - Poles.SetValue(9,48,gp_Pnt(-51.9293,150,0.00113058)); - Poles.SetValue(10,1,gp_Pnt(-46.1581,-150.001,-0.000638257)); - Poles.SetValue(10,2,gp_Pnt(-46.1658,-142.266,-0.338908)); - Poles.SetValue(10,3,gp_Pnt(-46.1771,-126.787,-0.982666)); - Poles.SetValue(10,4,gp_Pnt(-46.1819,-103.569,-1.90958)); - Poles.SetValue(10,5,gp_Pnt(-46.1784,-84.261,-2.93134)); - Poles.SetValue(10,6,gp_Pnt(-46.1093,-70.6785,-3.69831)); - Poles.SetValue(10,7,gp_Pnt(-46.0739,-62.928,-4.17581)); - Poles.SetValue(10,8,gp_Pnt(-46.047,-57.1203,-4.57934)); - Poles.SetValue(10,9,gp_Pnt(-46.0154,-51.3116,-5.03379)); - Poles.SetValue(10,10,gp_Pnt(-45.9925,-46.4699,-5.18556)); - Poles.SetValue(10,11,gp_Pnt(-46.012,-42.6314,-5.32418)); - Poles.SetValue(10,12,gp_Pnt(-46.0662,-39.7925,-5.76494)); - Poles.SetValue(10,13,gp_Pnt(-46.1808,-37.0074,-6.4582)); - Poles.SetValue(10,14,gp_Pnt(-46.2627,-34.1775,-7.11737)); - Poles.SetValue(10,15,gp_Pnt(-46.3521,-31.8361,-7.6892)); - Poles.SetValue(10,16,gp_Pnt(-46.4119,-29.9436,-8.15917)); - Poles.SetValue(10,17,gp_Pnt(-46.4974,-27.1051,-8.83871)); - Poles.SetValue(10,18,gp_Pnt(-46.6385,-23.7928,-9.76221)); - Poles.SetValue(10,19,gp_Pnt(-46.7404,-19.9549,-10.6246)); - Poles.SetValue(10,20,gp_Pnt(-46.8688,-16.1204,-11.4653)); - Poles.SetValue(10,21,gp_Pnt(-46.9478,-12.2561,-12.113)); - Poles.SetValue(10,22,gp_Pnt(-47.0023,-8.38515,-12.5828)); - Poles.SetValue(10,23,gp_Pnt(-47.0269,-5.4785,-12.8456)); - Poles.SetValue(10,24,gp_Pnt(-47.0386,-1.60018,-13.0705)); - Poles.SetValue(10,25,gp_Pnt(-47.0287,2.2868,-13.1044)); - Poles.SetValue(10,26,gp_Pnt(-47.034,6.16793,-13.0276)); - Poles.SetValue(10,27,gp_Pnt(-47.0114,9.0735,-12.8621)); - Poles.SetValue(10,28,gp_Pnt(-46.9836,12.9397,-12.5471)); - Poles.SetValue(10,29,gp_Pnt(-46.9389,16.7984,-12.1024)); - Poles.SetValue(10,30,gp_Pnt(-46.8056,20.6199,-11.386)); - Poles.SetValue(10,31,gp_Pnt(-46.729,24.4527,-10.7291)); - Poles.SetValue(10,32,gp_Pnt(-46.5805,27.7429,-9.92361)); - Poles.SetValue(10,33,gp_Pnt(-46.5017,30.5752,-9.34857)); - Poles.SetValue(10,34,gp_Pnt(-46.4461,32.4597,-8.95609)); - Poles.SetValue(10,35,gp_Pnt(-46.3462,34.7849,-8.34287)); - Poles.SetValue(10,36,gp_Pnt(-46.2837,37.6128,-7.82045)); - Poles.SetValue(10,37,gp_Pnt(-46.162,40.3806,-7.10571)); - Poles.SetValue(10,38,gp_Pnt(-46.1171,43.2098,-6.73439)); - Poles.SetValue(10,39,gp_Pnt(-46.1366,47.0603,-6.75792)); - Poles.SetValue(10,40,gp_Pnt(-46.1512,51.8648,-6.41774)); - Poles.SetValue(10,41,gp_Pnt(-46.1664,57.632,-5.86914)); - Poles.SetValue(10,42,gp_Pnt(-46.1871,63.4077,-5.41307)); - Poles.SetValue(10,43,gp_Pnt(-46.2021,71.1,-4.72497)); - Poles.SetValue(10,44,gp_Pnt(-46.2443,84.5899,-3.70014)); - Poles.SetValue(10,45,gp_Pnt(-46.2336,103.804,-2.61154)); - Poles.SetValue(10,46,gp_Pnt(-46.2013,126.902,-1.24637)); - Poles.SetValue(10,47,gp_Pnt(-46.1774,142.306,-0.449946)); - Poles.SetValue(10,48,gp_Pnt(-46.1611,150.001,-0.00144769)); - Poles.SetValue(11,1,gp_Pnt(-41.3506,-150.001,0.000129401)); - Poles.SetValue(11,2,gp_Pnt(-41.3604,-142.268,-0.369782)); - Poles.SetValue(11,3,gp_Pnt(-41.3715,-126.784,-1.01965)); - Poles.SetValue(11,4,gp_Pnt(-41.381,-103.559,-1.98585)); - Poles.SetValue(11,5,gp_Pnt(-41.3846,-84.2649,-3.02478)); - Poles.SetValue(11,6,gp_Pnt(-41.3076,-70.6584,-3.82604)); - Poles.SetValue(11,7,gp_Pnt(-41.2583,-62.8898,-4.34596)); - Poles.SetValue(11,8,gp_Pnt(-41.2301,-57.0807,-4.77554)); - Poles.SetValue(11,9,gp_Pnt(-41.208,-51.2838,-5.08544)); - Poles.SetValue(11,10,gp_Pnt(-41.2328,-46.4935,-5.34778)); - Poles.SetValue(11,11,gp_Pnt(-41.3268,-42.7488,-6.24075)); - Poles.SetValue(11,12,gp_Pnt(-41.4109,-39.9421,-6.96341)); - Poles.SetValue(11,13,gp_Pnt(-41.4934,-37.1246,-7.70505)); - Poles.SetValue(11,14,gp_Pnt(-41.6366,-34.3514,-8.60427)); - Poles.SetValue(11,15,gp_Pnt(-41.7592,-32.0314,-9.39254)); - Poles.SetValue(11,16,gp_Pnt(-41.866,-30.171,-10.027)); - Poles.SetValue(11,17,gp_Pnt(-42.007,-27.3579,-10.9448)); - Poles.SetValue(11,18,gp_Pnt(-42.1295,-24.0111,-11.8554)); - Poles.SetValue(11,19,gp_Pnt(-42.2841,-20.1843,-12.84)); - Poles.SetValue(11,20,gp_Pnt(-42.4397,-16.3348,-13.7597)); - Poles.SetValue(11,21,gp_Pnt(-42.6184,-12.4706,-14.5978)); - Poles.SetValue(11,22,gp_Pnt(-42.7575,-8.5647,-15.2417)); - Poles.SetValue(11,23,gp_Pnt(-42.8491,-5.62091,-15.6293)); - Poles.SetValue(11,24,gp_Pnt(-42.8914,-1.67076,-15.914)); - Poles.SetValue(11,25,gp_Pnt(-42.8577,2.29453,-15.9201)); - Poles.SetValue(11,26,gp_Pnt(-42.8099,6.24375,-15.7308)); - Poles.SetValue(11,27,gp_Pnt(-42.7438,9.19033,-15.4664)); - Poles.SetValue(11,28,gp_Pnt(-42.6546,13.1006,-15.0329)); - Poles.SetValue(11,29,gp_Pnt(-42.4397,16.9381,-14.2592)); - Poles.SetValue(11,30,gp_Pnt(-42.3321,20.793,-13.586)); - Poles.SetValue(11,31,gp_Pnt(-42.202,24.6193,-12.7928)); - Poles.SetValue(11,32,gp_Pnt(-42.0702,27.9455,-11.976)); - Poles.SetValue(11,33,gp_Pnt(-41.926,30.743,-11.1473)); - Poles.SetValue(11,34,gp_Pnt(-41.8424,32.617,-10.6229)); - Poles.SetValue(11,35,gp_Pnt(-41.7499,34.9475,-9.97304)); - Poles.SetValue(11,36,gp_Pnt(-41.6445,37.7479,-9.23094)); - Poles.SetValue(11,37,gp_Pnt(-41.557,40.5517,-8.47969)); - Poles.SetValue(11,38,gp_Pnt(-41.4664,43.3478,-7.79497)); - Poles.SetValue(11,39,gp_Pnt(-41.3421,47.0459,-6.80636)); - Poles.SetValue(11,40,gp_Pnt(-41.3394,51.8371,-6.68123)); - Poles.SetValue(11,41,gp_Pnt(-41.3706,57.6167,-6.22193)); - Poles.SetValue(11,42,gp_Pnt(-41.3831,63.3849,-5.68374)); - Poles.SetValue(11,43,gp_Pnt(-41.4131,71.0964,-4.98988)); - Poles.SetValue(11,44,gp_Pnt(-41.4553,84.5966,-3.8597)); - Poles.SetValue(11,45,gp_Pnt(-41.4358,103.797,-2.69226)); - Poles.SetValue(11,46,gp_Pnt(-41.396,126.901,-1.33321)); - Poles.SetValue(11,47,gp_Pnt(-41.3733,142.306,-0.423026)); - Poles.SetValue(11,48,gp_Pnt(-41.3535,150.001,0.000856916)); - Poles.SetValue(12,1,gp_Pnt(-37.5046,-150.002,-0.000990159)); - Poles.SetValue(12,2,gp_Pnt(-37.5158,-142.268,-0.362104)); - Poles.SetValue(12,3,gp_Pnt(-37.5275,-126.781,-1.04216)); - Poles.SetValue(12,4,gp_Pnt(-37.54,-103.548,-2.02727)); - Poles.SetValue(12,5,gp_Pnt(-37.5516,-84.2718,-3.08919)); - Poles.SetValue(12,6,gp_Pnt(-37.4692,-70.645,-3.92736)); - Poles.SetValue(12,7,gp_Pnt(-37.4034,-62.8516,-4.46926)); - Poles.SetValue(12,8,gp_Pnt(-37.3656,-57.0305,-4.90814)); - Poles.SetValue(12,9,gp_Pnt(-37.38,-51.2739,-5.03776)); - Poles.SetValue(12,10,gp_Pnt(-37.4847,-46.6009,-5.98182)); - Poles.SetValue(12,11,gp_Pnt(-37.5865,-42.8757,-7.03982)); - Poles.SetValue(12,12,gp_Pnt(-37.6857,-40.0925,-7.9519)); - Poles.SetValue(12,13,gp_Pnt(-37.8317,-37.3448,-9.00586)); - Poles.SetValue(12,14,gp_Pnt(-38.0147,-34.6055,-10.1344)); - Poles.SetValue(12,15,gp_Pnt(-38.1289,-32.2759,-10.9655)); - Poles.SetValue(12,16,gp_Pnt(-38.2014,-30.3789,-11.5644)); - Poles.SetValue(12,17,gp_Pnt(-38.3098,-27.5372,-12.4577)); - Poles.SetValue(12,18,gp_Pnt(-38.5591,-24.2661,-13.6428)); - Poles.SetValue(12,19,gp_Pnt(-38.8481,-20.4819,-14.8886)); - Poles.SetValue(12,20,gp_Pnt(-39.176,-16.67,-16.0722)); - Poles.SetValue(12,21,gp_Pnt(-39.431,-12.7582,-16.9903)); - Poles.SetValue(12,22,gp_Pnt(-39.6338,-8.78775,-17.6581)); - Poles.SetValue(12,23,gp_Pnt(-39.7083,-5.77365,-17.9709)); - Poles.SetValue(12,24,gp_Pnt(-39.7945,-1.73776,-18.2789)); - Poles.SetValue(12,25,gp_Pnt(-39.7792,2.31582,-18.3108)); - Poles.SetValue(12,26,gp_Pnt(-39.7111,6.3468,-18.1589)); - Poles.SetValue(12,27,gp_Pnt(-39.6071,9.34647,-17.8966)); - Poles.SetValue(12,28,gp_Pnt(-39.4225,13.3136,-17.3697)); - Poles.SetValue(12,29,gp_Pnt(-39.1565,17.2006,-16.5688)); - Poles.SetValue(12,30,gp_Pnt(-38.8412,21.0139,-15.5401)); - Poles.SetValue(12,31,gp_Pnt(-38.5614,24.7878,-14.4514)); - Poles.SetValue(12,32,gp_Pnt(-38.3865,28.1004,-13.5309)); - Poles.SetValue(12,33,gp_Pnt(-38.2837,30.935,-12.7238)); - Poles.SetValue(12,34,gp_Pnt(-38.1998,32.81,-12.1537)); - Poles.SetValue(12,35,gp_Pnt(-38.0919,35.1348,-11.3864)); - Poles.SetValue(12,36,gp_Pnt(-37.9482,37.9015,-10.4242)); - Poles.SetValue(12,37,gp_Pnt(-37.8069,40.6462,-9.43281)); - Poles.SetValue(12,38,gp_Pnt(-37.7142,43.4352,-8.61957)); - Poles.SetValue(12,39,gp_Pnt(-37.5907,47.134,-7.52689)); - Poles.SetValue(12,40,gp_Pnt(-37.5157,51.8377,-6.80127)); - Poles.SetValue(12,41,gp_Pnt(-37.5183,57.5848,-6.49516)); - Poles.SetValue(12,42,gp_Pnt(-37.5412,63.3635,-5.90827)); - Poles.SetValue(12,43,gp_Pnt(-37.5834,71.0941,-5.20371)); - Poles.SetValue(12,44,gp_Pnt(-37.6269,84.6055,-3.9813)); - Poles.SetValue(12,45,gp_Pnt(-37.5971,103.791,-2.77693)); - Poles.SetValue(12,46,gp_Pnt(-37.5523,126.898,-1.36182)); - Poles.SetValue(12,47,gp_Pnt(-37.5291,142.307,-0.42845)); - Poles.SetValue(12,48,gp_Pnt(-37.5076,150.002,0.00471985)); - Poles.SetValue(13,1,gp_Pnt(-34.62,-150.003,-0.0023316)); - Poles.SetValue(13,2,gp_Pnt(-34.632,-142.268,-0.349958)); - Poles.SetValue(13,3,gp_Pnt(-34.645,-126.78,-1.05185)); - Poles.SetValue(13,4,gp_Pnt(-34.6586,-103.539,-2.05983)); - Poles.SetValue(13,5,gp_Pnt(-34.6791,-84.2792,-3.11805)); - Poles.SetValue(13,6,gp_Pnt(-34.591,-70.6351,-4.00171)); - Poles.SetValue(13,7,gp_Pnt(-34.5131,-62.8198,-4.56575)); - Poles.SetValue(13,8,gp_Pnt(-34.4669,-56.9824,-4.92811)); - Poles.SetValue(13,9,gp_Pnt(-34.5266,-51.29,-5.24163)); - Poles.SetValue(13,10,gp_Pnt(-34.6876,-46.7104,-6.52793)); - Poles.SetValue(13,11,gp_Pnt(-34.8026,-43.0114,-7.78986)); - Poles.SetValue(13,12,gp_Pnt(-34.9344,-40.2726,-8.89694)); - Poles.SetValue(13,13,gp_Pnt(-35.0891,-37.5373,-10.0435)); - Poles.SetValue(13,14,gp_Pnt(-35.2348,-34.7597,-11.1199)); - Poles.SetValue(13,15,gp_Pnt(-35.3211,-32.4067,-11.9429)); - Poles.SetValue(13,16,gp_Pnt(-35.4497,-30.5606,-12.6961)); - Poles.SetValue(13,17,gp_Pnt(-35.614,-27.7584,-13.7623)); - Poles.SetValue(13,18,gp_Pnt(-35.9962,-24.5678,-15.2273)); - Poles.SetValue(13,19,gp_Pnt(-36.363,-20.7882,-16.5677)); - Poles.SetValue(13,20,gp_Pnt(-36.6904,-16.9282,-17.7055)); - Poles.SetValue(13,21,gp_Pnt(-36.8578,-12.9306,-18.3233)); - Poles.SetValue(13,22,gp_Pnt(-36.9527,-8.88561,-18.7197)); - Poles.SetValue(13,23,gp_Pnt(-36.9967,-5.83477,-18.8948)); - Poles.SetValue(13,24,gp_Pnt(-37.0318,-1.75551,-19.0735)); - Poles.SetValue(13,25,gp_Pnt(-37.0313,2.32873,-19.1232)); - Poles.SetValue(13,26,gp_Pnt(-37.0175,6.39695,-19.1615)); - Poles.SetValue(13,27,gp_Pnt(-36.9594,9.43212,-19.0345)); - Poles.SetValue(13,28,gp_Pnt(-36.8675,13.4561,-18.7867)); - Poles.SetValue(13,29,gp_Pnt(-36.6616,17.4137,-18.1833)); - Poles.SetValue(13,30,gp_Pnt(-36.3331,21.2595,-17.2008)); - Poles.SetValue(13,31,gp_Pnt(-35.995,25.041,-16.0204)); - Poles.SetValue(13,32,gp_Pnt(-35.6555,28.2725,-14.7687)); - Poles.SetValue(13,33,gp_Pnt(-35.5108,31.0696,-13.8117)); - Poles.SetValue(13,34,gp_Pnt(-35.4456,32.9642,-13.2402)); - Poles.SetValue(13,35,gp_Pnt(-35.3492,35.2949,-12.4616)); - Poles.SetValue(13,36,gp_Pnt(-35.189,38.0465,-11.4098)); - Poles.SetValue(13,37,gp_Pnt(-35.0275,40.7699,-10.3096)); - Poles.SetValue(13,38,gp_Pnt(-34.9073,43.5243,-9.30737)); - Poles.SetValue(13,39,gp_Pnt(-34.7987,47.2339,-8.14392)); - Poles.SetValue(13,40,gp_Pnt(-34.651,51.8373,-6.91992)); - Poles.SetValue(13,41,gp_Pnt(-34.6284,57.5527,-6.63443)); - Poles.SetValue(13,42,gp_Pnt(-34.659,63.3436,-6.09258)); - Poles.SetValue(13,43,gp_Pnt(-34.7102,71.0895,-5.31871)); - Poles.SetValue(13,44,gp_Pnt(-34.7584,84.6162,-4.09984)); - Poles.SetValue(13,45,gp_Pnt(-34.7172,103.784,-2.82096)); - Poles.SetValue(13,46,gp_Pnt(-34.6703,126.897,-1.3891)); - Poles.SetValue(13,47,gp_Pnt(-34.6455,142.308,-0.431219)); - Poles.SetValue(13,48,gp_Pnt(-34.6232,150.002,0.00496173)); - Poles.SetValue(14,1,gp_Pnt(-31.7352,-150.003,-0.00154848)); - Poles.SetValue(14,2,gp_Pnt(-31.7482,-142.267,-0.331617)); - Poles.SetValue(14,3,gp_Pnt(-31.763,-126.779,-1.063)); - Poles.SetValue(14,4,gp_Pnt(-31.7766,-103.527,-2.07596)); - Poles.SetValue(14,5,gp_Pnt(-31.8089,-84.2907,-3.17444)); - Poles.SetValue(14,6,gp_Pnt(-31.7122,-70.6219,-4.03525)); - Poles.SetValue(14,7,gp_Pnt(-31.6249,-62.7848,-4.66387)); - Poles.SetValue(14,8,gp_Pnt(-31.5769,-56.9282,-4.89998)); - Poles.SetValue(14,9,gp_Pnt(-31.6802,-51.3146,-5.53692)); - Poles.SetValue(14,10,gp_Pnt(-31.8745,-46.8081,-7.10223)); - Poles.SetValue(14,11,gp_Pnt(-32.018,-43.1597,-8.56607)); - Poles.SetValue(14,12,gp_Pnt(-32.1638,-40.4524,-9.81769)); - Poles.SetValue(14,13,gp_Pnt(-32.3073,-37.7124,-11.0081)); - Poles.SetValue(14,14,gp_Pnt(-32.4358,-34.9155,-12.0817)); - Poles.SetValue(14,15,gp_Pnt(-32.5926,-32.6407,-13.1205)); - Poles.SetValue(14,16,gp_Pnt(-32.7344,-30.7964,-13.9191)); - Poles.SetValue(14,17,gp_Pnt(-33.0143,-28.0979,-15.252)); - Poles.SetValue(14,18,gp_Pnt(-33.4113,-24.8923,-16.747)); - Poles.SetValue(14,19,gp_Pnt(-33.7395,-21.0593,-17.9381)); - Poles.SetValue(14,20,gp_Pnt(-33.9529,-17.0987,-18.7264)); - Poles.SetValue(14,21,gp_Pnt(-34.0517,-13.0389,-19.0923)); - Poles.SetValue(14,22,gp_Pnt(-34.0927,-8.94344,-19.1565)); - Poles.SetValue(14,23,gp_Pnt(-34.1148,-5.86615,-19.2346)); - Poles.SetValue(14,24,gp_Pnt(-34.1342,-1.75859,-19.3087)); - Poles.SetValue(14,25,gp_Pnt(-34.1496,2.34806,-19.3815)); - Poles.SetValue(14,26,gp_Pnt(-34.1479,6.43942,-19.5269)); - Poles.SetValue(14,27,gp_Pnt(-34.1348,9.49773,-19.5973)); - Poles.SetValue(14,28,gp_Pnt(-34.086,13.5579,-19.6271)); - Poles.SetValue(14,29,gp_Pnt(-33.9618,17.5747,-19.3248)); - Poles.SetValue(14,30,gp_Pnt(-33.7384,21.5045,-18.634)); - Poles.SetValue(14,31,gp_Pnt(-33.4066,25.3178,-17.5646)); - Poles.SetValue(14,32,gp_Pnt(-33.0544,28.5653,-16.2703)); - Poles.SetValue(14,33,gp_Pnt(-32.8588,31.3256,-15.1565)); - Poles.SetValue(14,34,gp_Pnt(-32.6532,33.099,-14.2631)); - Poles.SetValue(14,35,gp_Pnt(-32.5381,35.4039,-13.3772)); - Poles.SetValue(14,36,gp_Pnt(-32.393,38.1751,-12.3245)); - Poles.SetValue(14,37,gp_Pnt(-32.231,40.8861,-11.1505)); - Poles.SetValue(14,38,gp_Pnt(-32.1223,43.6538,-10.1046)); - Poles.SetValue(14,39,gp_Pnt(-31.9975,47.3317,-8.76792)); - Poles.SetValue(14,40,gp_Pnt(-31.8214,51.8667,-7.32186)); - Poles.SetValue(14,41,gp_Pnt(-31.7377,57.5022,-6.67478)); - Poles.SetValue(14,42,gp_Pnt(-31.7779,63.3209,-6.2713)); - Poles.SetValue(14,43,gp_Pnt(-31.838,71.0853,-5.43635)); - Poles.SetValue(14,44,gp_Pnt(-31.8903,84.6268,-4.19797)); - Poles.SetValue(14,45,gp_Pnt(-31.8372,103.777,-2.86658)); - Poles.SetValue(14,46,gp_Pnt(-31.7884,126.895,-1.40853)); - Poles.SetValue(14,47,gp_Pnt(-31.7622,142.309,-0.438532)); - Poles.SetValue(14,48,gp_Pnt(-31.7384,150.003,0.00199423)); - Poles.SetValue(15,1,gp_Pnt(-28.8504,-150.003,-0.000296043)); - Poles.SetValue(15,2,gp_Pnt(-28.8644,-142.267,-0.326339)); - Poles.SetValue(15,3,gp_Pnt(-28.8809,-126.778,-1.04463)); - Poles.SetValue(15,4,gp_Pnt(-28.8954,-103.518,-2.13061)); - Poles.SetValue(15,5,gp_Pnt(-28.9393,-84.3,-3.15907)); - Poles.SetValue(15,6,gp_Pnt(-28.837,-70.6117,-4.10819)); - Poles.SetValue(15,7,gp_Pnt(-28.7434,-62.7489,-4.72495)); - Poles.SetValue(15,8,gp_Pnt(-28.708,-56.8994,-4.89063)); - Poles.SetValue(15,9,gp_Pnt(-28.8485,-51.3762,-6.00024)); - Poles.SetValue(15,10,gp_Pnt(-29.054,-46.9121,-7.70424)); - Poles.SetValue(15,11,gp_Pnt(-29.2298,-43.3343,-9.40211)); - Poles.SetValue(15,12,gp_Pnt(-29.3671,-40.6219,-10.6912)); - Poles.SetValue(15,13,gp_Pnt(-29.4868,-37.8621,-11.8917)); - Poles.SetValue(15,14,gp_Pnt(-29.653,-35.1193,-13.1207)); - Poles.SetValue(15,15,gp_Pnt(-29.8374,-32.8838,-14.2764)); - Poles.SetValue(15,16,gp_Pnt(-30.0554,-31.1218,-15.2551)); - Poles.SetValue(15,17,gp_Pnt(-30.3616,-28.4511,-16.6604)); - Poles.SetValue(15,18,gp_Pnt(-30.7128,-25.1891,-18.0319)); - Poles.SetValue(15,19,gp_Pnt(-30.8848,-21.2184,-18.7039)); - Poles.SetValue(15,20,gp_Pnt(-31.0171,-17.1843,-19.1198)); - Poles.SetValue(15,21,gp_Pnt(-31.0697,-13.0808,-19.0549)); - Poles.SetValue(15,22,gp_Pnt(-31.0917,-8.96259,-19.0617)); - Poles.SetValue(15,23,gp_Pnt(-31.1082,-5.8717,-19.0769)); - Poles.SetValue(15,24,gp_Pnt(-31.1282,-1.74971,-19.1218)); - Poles.SetValue(15,25,gp_Pnt(-31.1451,2.36805,-19.2344)); - Poles.SetValue(15,26,gp_Pnt(-31.1463,6.47208,-19.4017)); - Poles.SetValue(15,27,gp_Pnt(-31.1369,9.5398,-19.563)); - Poles.SetValue(15,28,gp_Pnt(-31.125,13.624,-19.676)); - Poles.SetValue(15,29,gp_Pnt(-31.0629,17.6731,-19.8221)); - Poles.SetValue(15,30,gp_Pnt(-30.9394,21.6753,-19.5784)); - Poles.SetValue(15,31,gp_Pnt(-30.7208,25.5796,-18.8941)); - Poles.SetValue(15,32,gp_Pnt(-30.429,28.8939,-17.7437)); - Poles.SetValue(15,33,gp_Pnt(-30.1355,31.5716,-16.4029)); - Poles.SetValue(15,34,gp_Pnt(-30.004,33.4123,-15.6337)); - Poles.SetValue(15,35,gp_Pnt(-29.7454,35.5561,-14.3595)); - Poles.SetValue(15,36,gp_Pnt(-29.5827,38.3004,-13.2055)); - Poles.SetValue(15,37,gp_Pnt(-29.4071,40.9896,-11.9148)); - Poles.SetValue(15,38,gp_Pnt(-29.3087,43.7647,-10.8315)); - Poles.SetValue(15,39,gp_Pnt(-29.1671,47.4036,-9.29662)); - Poles.SetValue(15,40,gp_Pnt(-28.9805,51.9045,-7.68659)); - Poles.SetValue(15,41,gp_Pnt(-28.8656,57.4635,-6.70615)); - Poles.SetValue(15,42,gp_Pnt(-28.899,63.2886,-6.3862)); - Poles.SetValue(15,43,gp_Pnt(-28.9679,71.0817,-5.5474)); - Poles.SetValue(15,44,gp_Pnt(-29.0236,84.6395,-4.29974)); - Poles.SetValue(15,45,gp_Pnt(-28.9571,103.767,-2.89536)); - Poles.SetValue(15,46,gp_Pnt(-28.9071,126.895,-1.43175)); - Poles.SetValue(15,47,gp_Pnt(-28.8786,142.31,-0.451004)); - Poles.SetValue(15,48,gp_Pnt(-28.8536,150.003,-0.000328798)); - Poles.SetValue(16,1,gp_Pnt(-25.9656,-150.004,0.00137713)); - Poles.SetValue(16,2,gp_Pnt(-25.9803,-142.267,-0.325925)); - Poles.SetValue(16,3,gp_Pnt(-25.9991,-126.777,-1.02412)); - Poles.SetValue(16,4,gp_Pnt(-26.0145,-103.507,-2.17811)); - Poles.SetValue(16,5,gp_Pnt(-26.071,-84.312,-3.15724)); - Poles.SetValue(16,6,gp_Pnt(-25.9635,-70.5999,-4.17961)); - Poles.SetValue(16,7,gp_Pnt(-25.8703,-62.7171,-4.72997)); - Poles.SetValue(16,8,gp_Pnt(-25.8574,-56.9015,-4.98549)); - Poles.SetValue(16,9,gp_Pnt(-26.0153,-51.4433,-6.4689)); - Poles.SetValue(16,10,gp_Pnt(-26.2167,-47.0041,-8.31462)); - Poles.SetValue(16,11,gp_Pnt(-26.414,-43.4866,-10.1773)); - Poles.SetValue(16,12,gp_Pnt(-26.5319,-40.7572,-11.4557)); - Poles.SetValue(16,13,gp_Pnt(-26.6786,-38.0475,-12.8017)); - Poles.SetValue(16,14,gp_Pnt(-26.9109,-35.41,-14.2563)); - Poles.SetValue(16,15,gp_Pnt(-27.1481,-33.2466,-15.577)); - Poles.SetValue(16,16,gp_Pnt(-27.3362,-31.4586,-16.4821)); - Poles.SetValue(16,17,gp_Pnt(-27.6323,-28.7816,-17.8543)); - Poles.SetValue(16,18,gp_Pnt(-27.8191,-25.3474,-18.6862)); - Poles.SetValue(16,19,gp_Pnt(-27.9266,-21.3202,-19.0118)); - Poles.SetValue(16,20,gp_Pnt(-27.9944,-17.2306,-19.0069)); - Poles.SetValue(16,21,gp_Pnt(-28.0229,-13.1072,-18.9149)); - Poles.SetValue(16,22,gp_Pnt(-28.0429,-8.9775,-18.9805)); - Poles.SetValue(16,23,gp_Pnt(-28.0561,-5.87853,-19.0437)); - Poles.SetValue(16,24,gp_Pnt(-28.0792,-1.74655,-19.1248)); - Poles.SetValue(16,25,gp_Pnt(-28.0969,2.38173,-19.2133)); - Poles.SetValue(16,26,gp_Pnt(-28.121,6.50036,-19.3792)); - Poles.SetValue(16,27,gp_Pnt(-28.1339,9.58285,-19.5254)); - Poles.SetValue(16,28,gp_Pnt(-28.1071,13.6792,-19.5675)); - Poles.SetValue(16,29,gp_Pnt(-28.0705,17.7504,-19.8531)); - Poles.SetValue(16,30,gp_Pnt(-28.0003,21.791,-19.912)); - Poles.SetValue(16,31,gp_Pnt(-27.911,25.7842,-19.8198)); - Poles.SetValue(16,32,gp_Pnt(-27.6949,29.1933,-18.9987)); - Poles.SetValue(16,33,gp_Pnt(-27.4332,31.8849,-17.6989)); - Poles.SetValue(16,34,gp_Pnt(-27.2196,33.6394,-16.7355)); - Poles.SetValue(16,35,gp_Pnt(-26.9796,35.7881,-15.4254)); - Poles.SetValue(16,36,gp_Pnt(-26.7348,38.4053,-13.9907)); - Poles.SetValue(16,37,gp_Pnt(-26.6103,41.1531,-12.7843)); - Poles.SetValue(16,38,gp_Pnt(-26.4815,43.872,-11.5302)); - Poles.SetValue(16,39,gp_Pnt(-26.3471,47.5059,-9.95418)); - Poles.SetValue(16,40,gp_Pnt(-26.1542,51.9566,-8.16439)); - Poles.SetValue(16,41,gp_Pnt(-26.0013,57.4301,-6.7748)); - Poles.SetValue(16,42,gp_Pnt(-26.0309,63.2656,-6.51026)); - Poles.SetValue(16,43,gp_Pnt(-26.0987,71.0753,-5.64577)); - Poles.SetValue(16,44,gp_Pnt(-26.1566,84.652,-4.37635)); - Poles.SetValue(16,45,gp_Pnt(-26.0777,103.757,-2.92071)); - Poles.SetValue(16,46,gp_Pnt(-26.0262,126.895,-1.44846)); - Poles.SetValue(16,47,gp_Pnt(-25.9946,142.312,-0.475798)); - Poles.SetValue(16,48,gp_Pnt(-25.9691,150.004,0.000603631)); - Poles.SetValue(17,1,gp_Pnt(-23.0806,-150.004,0.0019641)); - Poles.SetValue(17,2,gp_Pnt(-23.0964,-142.267,-0.330405)); - Poles.SetValue(17,3,gp_Pnt(-23.1173,-126.777,-0.994297)); - Poles.SetValue(17,4,gp_Pnt(-23.1339,-103.497,-2.23784)); - Poles.SetValue(17,5,gp_Pnt(-23.203,-84.3232,-3.12651)); - Poles.SetValue(17,6,gp_Pnt(-23.0914,-70.5857,-4.25051)); - Poles.SetValue(17,7,gp_Pnt(-23.0079,-62.6967,-4.71921)); - Poles.SetValue(17,8,gp_Pnt(-23.0207,-56.9337,-5.11304)); - Poles.SetValue(17,9,gp_Pnt(-23.1812,-51.5274,-6.94389)); - Poles.SetValue(17,10,gp_Pnt(-23.3792,-47.1212,-8.95957)); - Poles.SetValue(17,11,gp_Pnt(-23.5592,-43.5991,-10.8437)); - Poles.SetValue(17,12,gp_Pnt(-23.6823,-40.8919,-12.1796)); - Poles.SetValue(17,13,gp_Pnt(-23.8673,-38.2715,-13.717)); - Poles.SetValue(17,14,gp_Pnt(-24.1096,-35.6834,-15.2627)); - Poles.SetValue(17,15,gp_Pnt(-24.3579,-33.557,-16.646)); - Poles.SetValue(17,16,gp_Pnt(-24.5176,-31.7432,-17.4483)); - Poles.SetValue(17,17,gp_Pnt(-24.7308,-28.9759,-18.5377)); - Poles.SetValue(17,18,gp_Pnt(-24.8179,-25.4266,-18.8272)); - Poles.SetValue(17,19,gp_Pnt(-24.8974,-21.3738,-18.951)); - Poles.SetValue(17,20,gp_Pnt(-24.9391,-17.2569,-18.7823)); - Poles.SetValue(17,21,gp_Pnt(-24.9579,-13.1274,-18.8788)); - Poles.SetValue(17,22,gp_Pnt(-24.9753,-8.98927,-18.9409)); - Poles.SetValue(17,23,gp_Pnt(-24.9913,-5.88506,-19.0143)); - Poles.SetValue(17,24,gp_Pnt(-25.0155,-1.74473,-19.0767)); - Poles.SetValue(17,25,gp_Pnt(-25.0387,2.39217,-19.1733)); - Poles.SetValue(17,26,gp_Pnt(-25.0554,6.52043,-19.304)); - Poles.SetValue(17,27,gp_Pnt(-25.062,9.61116,-19.3704)); - Poles.SetValue(17,28,gp_Pnt(-25.0579,13.7179,-19.5885)); - Poles.SetValue(17,29,gp_Pnt(-25.0328,17.8051,-19.6948)); - Poles.SetValue(17,30,gp_Pnt(-24.9947,21.8711,-19.9465)); - Poles.SetValue(17,31,gp_Pnt(-24.9153,25.8755,-20.1336)); - Poles.SetValue(17,32,gp_Pnt(-24.8254,29.3978,-19.7884)); - Poles.SetValue(17,33,gp_Pnt(-24.5662,32.0898,-18.5604)); - Poles.SetValue(17,34,gp_Pnt(-24.4055,33.8853,-17.7436)); - Poles.SetValue(17,35,gp_Pnt(-24.178,36.0383,-16.4151)); - Poles.SetValue(17,36,gp_Pnt(-23.9261,38.6092,-14.8899)); - Poles.SetValue(17,37,gp_Pnt(-23.7426,41.2345,-13.4103)); - Poles.SetValue(17,38,gp_Pnt(-23.6547,44.0121,-12.2559)); - Poles.SetValue(17,39,gp_Pnt(-23.4902,47.5631,-10.4569)); - Poles.SetValue(17,40,gp_Pnt(-23.3099,52.0088,-8.56085)); - Poles.SetValue(17,41,gp_Pnt(-23.1561,57.4374,-6.92122)); - Poles.SetValue(17,42,gp_Pnt(-23.1683,63.2457,-6.58119)); - Poles.SetValue(17,43,gp_Pnt(-23.2319,71.0684,-5.75082)); - Poles.SetValue(17,44,gp_Pnt(-23.2881,84.6629,-4.4223)); - Poles.SetValue(17,45,gp_Pnt(-23.199,103.747,-2.94621)); - Poles.SetValue(17,46,gp_Pnt(-23.1451,126.896,-1.46385)); - Poles.SetValue(17,47,gp_Pnt(-23.1109,142.313,-0.498328)); - Poles.SetValue(17,48,gp_Pnt(-23.0842,150.004,0.000641323)); - Poles.SetValue(18,1,gp_Pnt(-20.1956,-150.004,-0.000939892)); - Poles.SetValue(18,2,gp_Pnt(-20.2119,-142.265,-0.324814)); - Poles.SetValue(18,3,gp_Pnt(-20.2367,-126.781,-0.99002)); - Poles.SetValue(18,4,gp_Pnt(-20.2522,-103.48,-2.25874)); - Poles.SetValue(18,5,gp_Pnt(-20.3366,-84.3417,-3.14413)); - Poles.SetValue(18,6,gp_Pnt(-20.2198,-70.5658,-4.30028)); - Poles.SetValue(18,7,gp_Pnt(-20.1558,-62.6899,-4.68856)); - Poles.SetValue(18,8,gp_Pnt(-20.1905,-56.9911,-5.31764)); - Poles.SetValue(18,9,gp_Pnt(-20.3412,-51.6127,-7.37483)); - Poles.SetValue(18,10,gp_Pnt(-20.5364,-47.2541,-9.61034)); - Poles.SetValue(18,11,gp_Pnt(-20.6972,-43.7208,-11.486)); - Poles.SetValue(18,12,gp_Pnt(-20.8365,-41.0734,-12.9256)); - Poles.SetValue(18,13,gp_Pnt(-21.037,-38.5159,-14.5838)); - Poles.SetValue(18,14,gp_Pnt(-21.299,-36.0127,-16.2371)); - Poles.SetValue(18,15,gp_Pnt(-21.5046,-33.834,-17.4931)); - Poles.SetValue(18,16,gp_Pnt(-21.6031,-31.945,-18.0503)); - Poles.SetValue(18,17,gp_Pnt(-21.7517,-29.0964,-18.8401)); - Poles.SetValue(18,18,gp_Pnt(-21.7895,-25.4868,-18.7856)); - Poles.SetValue(18,19,gp_Pnt(-21.8447,-21.407,-18.7832)); - Poles.SetValue(18,20,gp_Pnt(-21.8724,-17.2831,-18.7158)); - Poles.SetValue(18,21,gp_Pnt(-21.8885,-13.1476,-18.8247)); - Poles.SetValue(18,22,gp_Pnt(-21.9053,-9.00401,-18.9335)); - Poles.SetValue(18,23,gp_Pnt(-21.9203,-5.89434,-19.0031)); - Poles.SetValue(18,24,gp_Pnt(-21.9444,-1.74696,-19.0678)); - Poles.SetValue(18,25,gp_Pnt(-21.9704,2.39832,-19.1774)); - Poles.SetValue(18,26,gp_Pnt(-21.9895,6.53686,-19.2539)); - Poles.SetValue(18,27,gp_Pnt(-21.9976,9.63356,-19.3732)); - Poles.SetValue(18,28,gp_Pnt(-21.9987,13.7521,-19.5004)); - Poles.SetValue(18,29,gp_Pnt(-21.9832,17.8493,-19.6642)); - Poles.SetValue(18,30,gp_Pnt(-21.9481,21.9195,-19.8425)); - Poles.SetValue(18,31,gp_Pnt(-21.8998,25.958,-20.0751)); - Poles.SetValue(18,32,gp_Pnt(-21.8165,29.4779,-20.0877)); - Poles.SetValue(18,33,gp_Pnt(-21.6537,32.2814,-19.218)); - Poles.SetValue(18,34,gp_Pnt(-21.5332,34.1277,-18.592)); - Poles.SetValue(18,35,gp_Pnt(-21.3059,36.244,-17.2119)); - Poles.SetValue(18,36,gp_Pnt(-21.0772,38.8004,-15.6898)); - Poles.SetValue(18,37,gp_Pnt(-20.8763,41.346,-14.041)); - Poles.SetValue(18,38,gp_Pnt(-20.7928,44.1142,-12.8629)); - Poles.SetValue(18,39,gp_Pnt(-20.6422,47.6606,-11.0393)); - Poles.SetValue(18,40,gp_Pnt(-20.4703,52.0726,-9.0358)); - Poles.SetValue(18,41,gp_Pnt(-20.3288,57.4895,-7.14688)); - Poles.SetValue(18,42,gp_Pnt(-20.3107,63.2274,-6.59652)); - Poles.SetValue(18,43,gp_Pnt(-20.366,71.0607,-5.86066)); - Poles.SetValue(18,44,gp_Pnt(-20.4189,84.6755,-4.47339)); - Poles.SetValue(18,45,gp_Pnt(-20.32,103.734,-2.95074)); - Poles.SetValue(18,46,gp_Pnt(-20.2644,126.899,-1.49374)); - Poles.SetValue(18,47,gp_Pnt(-20.227,142.314,-0.508887)); - Poles.SetValue(18,48,gp_Pnt(-20.1991,150.004,-0.00112432)); - Poles.SetValue(19,1,gp_Pnt(-16.3491,-150.003,0.00439318)); - Poles.SetValue(19,2,gp_Pnt(-16.3656,-142.264,-0.34061)); - Poles.SetValue(19,3,gp_Pnt(-16.3951,-126.785,-0.955435)); - Poles.SetValue(19,4,gp_Pnt(-16.4123,-103.462,-2.32584)); - Poles.SetValue(19,5,gp_Pnt(-16.5104,-84.3597,-3.09639)); - Poles.SetValue(19,6,gp_Pnt(-16.3944,-70.5334,-4.33957)); - Poles.SetValue(19,7,gp_Pnt(-16.3623,-62.6963,-4.6472)); - Poles.SetValue(19,8,gp_Pnt(-16.4203,-57.084,-5.58419)); - Poles.SetValue(19,9,gp_Pnt(-16.5511,-51.7391,-7.92073)); - Poles.SetValue(19,10,gp_Pnt(-16.7137,-47.3952,-10.3398)); - Poles.SetValue(19,11,gp_Pnt(-16.8584,-43.8683,-12.2379)); - Poles.SetValue(19,12,gp_Pnt(-17.0069,-41.2968,-13.8148)); - Poles.SetValue(19,13,gp_Pnt(-17.234,-38.8784,-15.6644)); - Poles.SetValue(19,14,gp_Pnt(-17.4559,-36.3846,-17.2802)); - Poles.SetValue(19,15,gp_Pnt(-17.5711,-34.0769,-18.2311)); - Poles.SetValue(19,16,gp_Pnt(-17.6306,-32.1332,-18.5268)); - Poles.SetValue(19,17,gp_Pnt(-17.7058,-29.1815,-18.8298)); - Poles.SetValue(19,18,gp_Pnt(-17.7222,-25.5444,-18.565)); - Poles.SetValue(19,19,gp_Pnt(-17.755,-21.4437,-18.6143)); - Poles.SetValue(19,20,gp_Pnt(-17.7721,-17.3146,-18.6936)); - Poles.SetValue(19,21,gp_Pnt(-17.7833,-13.1725,-18.7973)); - Poles.SetValue(19,22,gp_Pnt(-17.7956,-9.02146,-18.8982)); - Poles.SetValue(19,23,gp_Pnt(-17.8084,-5.90664,-18.9585)); - Poles.SetValue(19,24,gp_Pnt(-17.8297,-1.75266,-19.0369)); - Poles.SetValue(19,25,gp_Pnt(-17.8562,2.40144,-19.105)); - Poles.SetValue(19,26,gp_Pnt(-17.8776,6.54951,-19.2157)); - Poles.SetValue(19,27,gp_Pnt(-17.8892,9.65525,-19.2919)); - Poles.SetValue(19,28,gp_Pnt(-17.8977,13.7848,-19.4492)); - Poles.SetValue(19,29,gp_Pnt(-17.8891,17.8872,-19.6002)); - Poles.SetValue(19,30,gp_Pnt(-17.8651,21.9666,-19.7805)); - Poles.SetValue(19,31,gp_Pnt(-17.8168,26.0004,-19.778)); - Poles.SetValue(19,32,gp_Pnt(-17.7893,29.5844,-20.0714)); - Poles.SetValue(19,33,gp_Pnt(-17.6844,32.4681,-19.7048)); - Poles.SetValue(19,34,gp_Pnt(-17.6156,34.381,-19.3921)); - Poles.SetValue(19,35,gp_Pnt(-17.468,36.5995,-18.2429)); - Poles.SetValue(19,36,gp_Pnt(-17.273,39.1443,-16.764)); - Poles.SetValue(19,37,gp_Pnt(-17.0603,41.5783,-14.9142)); - Poles.SetValue(19,38,gp_Pnt(-16.942,44.2046,-13.5092)); - Poles.SetValue(19,39,gp_Pnt(-16.8113,47.7336,-11.6467)); - Poles.SetValue(19,40,gp_Pnt(-16.6707,52.1542,-9.5335)); - Poles.SetValue(19,41,gp_Pnt(-16.5537,57.549,-7.39217)); - Poles.SetValue(19,42,gp_Pnt(-16.5136,63.2221,-6.59968)); - Poles.SetValue(19,43,gp_Pnt(-16.5433,71.0421,-5.99115)); - Poles.SetValue(19,44,gp_Pnt(-16.5912,84.6886,-4.45254)); - Poles.SetValue(19,45,gp_Pnt(-16.4831,103.728,-3.08142)); - Poles.SetValue(19,46,gp_Pnt(-16.423,126.896,-1.4405)); - Poles.SetValue(19,47,gp_Pnt(-16.3811,142.316,-0.552973)); - Poles.SetValue(19,48,gp_Pnt(-16.3527,150.004,0.00512247)); - Poles.SetValue(20,1,gp_Pnt(-11.5409,-150.004,0.00117643)); - Poles.SetValue(20,2,gp_Pnt(-11.5567,-142.255,-0.323629)); - Poles.SetValue(20,3,gp_Pnt(-11.5945,-126.808,-1.00415)); - Poles.SetValue(20,4,gp_Pnt(-11.6123,-103.418,-2.2741)); - Poles.SetValue(20,5,gp_Pnt(-11.7238,-84.4038,-3.17774)); - Poles.SetValue(20,6,gp_Pnt(-11.6216,-70.4805,-4.34939)); - Poles.SetValue(20,7,gp_Pnt(-11.6306,-62.7158,-4.61848)); - Poles.SetValue(20,8,gp_Pnt(-11.6985,-57.2166,-5.86008)); - Poles.SetValue(20,9,gp_Pnt(-11.804,-51.9451,-8.59692)); - Poles.SetValue(20,10,gp_Pnt(-11.9017,-47.511,-11.0341)); - Poles.SetValue(20,11,gp_Pnt(-12.0348,-44.054,-13.0527)); - Poles.SetValue(20,12,gp_Pnt(-12.1892,-41.6494,-14.8698)); - Poles.SetValue(20,13,gp_Pnt(-12.3712,-39.2779,-16.7157)); - Poles.SetValue(20,14,gp_Pnt(-12.4805,-36.6354,-17.9375)); - Poles.SetValue(20,15,gp_Pnt(-12.5363,-34.226,-18.5069)); - Poles.SetValue(20,16,gp_Pnt(-12.561,-32.2298,-18.5446)); - Poles.SetValue(20,17,gp_Pnt(-12.6007,-29.2245,-18.4861)); - Poles.SetValue(20,18,gp_Pnt(-12.6061,-25.5943,-18.4035)); - Poles.SetValue(20,19,gp_Pnt(-12.6185,-21.4799,-18.541)); - Poles.SetValue(20,20,gp_Pnt(-12.6259,-17.3464,-18.6219)); - Poles.SetValue(20,21,gp_Pnt(-12.6294,-13.198,-18.7456)); - Poles.SetValue(20,22,gp_Pnt(-12.6383,-9.04337,-18.8541)); - Poles.SetValue(20,23,gp_Pnt(-12.6485,-5.92505,-18.9104)); - Poles.SetValue(20,24,gp_Pnt(-12.6659,-1.76525,-18.964)); - Poles.SetValue(20,25,gp_Pnt(-12.6869,2.39485,-19.067)); - Poles.SetValue(20,26,gp_Pnt(-12.7086,6.55182,-19.1737)); - Poles.SetValue(20,27,gp_Pnt(-12.7237,9.66537,-19.2438)); - Poles.SetValue(20,28,gp_Pnt(-12.7365,13.803,-19.406)); - Poles.SetValue(20,29,gp_Pnt(-12.7387,17.9165,-19.5004)); - Poles.SetValue(20,30,gp_Pnt(-12.725,21.9984,-19.5481)); - Poles.SetValue(20,31,gp_Pnt(-12.7006,26.0496,-19.5971)); - Poles.SetValue(20,32,gp_Pnt(-12.6724,29.61,-19.7481)); - Poles.SetValue(20,33,gp_Pnt(-12.6172,32.5589,-19.7855)); - Poles.SetValue(20,34,gp_Pnt(-12.577,34.5045,-19.6765)); - Poles.SetValue(20,35,gp_Pnt(-12.5091,36.8627,-18.9431)); - Poles.SetValue(20,36,gp_Pnt(-12.3992,39.4504,-17.717)); - Poles.SetValue(20,37,gp_Pnt(-12.2417,41.8732,-15.8993)); - Poles.SetValue(20,38,gp_Pnt(-12.1136,44.3374,-14.2229)); - Poles.SetValue(20,39,gp_Pnt(-12.0124,47.8838,-12.4053)); - Poles.SetValue(20,40,gp_Pnt(-11.9096,52.2497,-10.0193)); - Poles.SetValue(20,41,gp_Pnt(-11.8312,57.645,-7.74397)); - Poles.SetValue(20,42,gp_Pnt(-11.7795,63.2306,-6.59009)); - Poles.SetValue(20,43,gp_Pnt(-11.7676,71.0031,-6.05246)); - Poles.SetValue(20,44,gp_Pnt(-11.803,84.7251,-4.53343)); - Poles.SetValue(20,45,gp_Pnt(-11.6834,103.69,-3.04429)); - Poles.SetValue(20,46,gp_Pnt(-11.6246,126.918,-1.52563)); - Poles.SetValue(20,47,gp_Pnt(-11.5716,142.307,-0.515972)); - Poles.SetValue(20,48,gp_Pnt(-11.5446,150.004,0.000245205)); - Poles.SetValue(21,1,gp_Pnt(-7.21355,-150.004,-0.0025218)); - Poles.SetValue(21,2,gp_Pnt(-7.23063,-142.252,-0.331648)); - Poles.SetValue(21,3,gp_Pnt(-7.2677,-126.82,-1.02226)); - Poles.SetValue(21,4,gp_Pnt(-7.30323,-103.391,-2.23259)); - Poles.SetValue(21,5,gp_Pnt(-7.39757,-84.4224,-3.1889)); - Poles.SetValue(21,6,gp_Pnt(-7.34772,-70.4538,-4.37072)); - Poles.SetValue(21,7,gp_Pnt(-7.3712,-62.7345,-4.5951)); - Poles.SetValue(21,8,gp_Pnt(-7.42816,-57.2934,-6.04634)); - Poles.SetValue(21,9,gp_Pnt(-7.49535,-52.026,-8.86275)); - Poles.SetValue(21,10,gp_Pnt(-7.55838,-47.6033,-11.3943)); - Poles.SetValue(21,11,gp_Pnt(-7.65,-44.2056,-13.5286)); - Poles.SetValue(21,12,gp_Pnt(-7.75695,-41.8805,-15.4454)); - Poles.SetValue(21,13,gp_Pnt(-7.85282,-39.4135,-17.0864)); - Poles.SetValue(21,14,gp_Pnt(-7.91823,-36.7399,-18.1659)); - Poles.SetValue(21,15,gp_Pnt(-7.94146,-34.2627,-18.4245)); - Poles.SetValue(21,16,gp_Pnt(-7.95506,-32.2581,-18.4508)); - Poles.SetValue(21,17,gp_Pnt(-7.97185,-29.2355,-18.438)); - Poles.SetValue(21,18,gp_Pnt(-7.9724,-25.6227,-18.4383)); - Poles.SetValue(21,19,gp_Pnt(-7.97498,-21.5055,-18.5136)); - Poles.SetValue(21,20,gp_Pnt(-7.97332,-17.3696,-18.5895)); - Poles.SetValue(21,21,gp_Pnt(-7.9724,-13.2197,-18.6677)); - Poles.SetValue(21,22,gp_Pnt(-7.97728,-9.06333,-18.7605)); - Poles.SetValue(21,23,gp_Pnt(-7.98383,-5.94346,-18.8376)); - Poles.SetValue(21,24,gp_Pnt(-7.99613,-1.78048,-18.9102)); - Poles.SetValue(21,25,gp_Pnt(-8.0124,2.38413,-18.9749)); - Poles.SetValue(21,26,gp_Pnt(-8.03056,6.5435,-19.1002)); - Poles.SetValue(21,27,gp_Pnt(-8.04412,9.658,-19.2087)); - Poles.SetValue(21,28,gp_Pnt(-8.06164,13.8027,-19.2687)); - Poles.SetValue(21,29,gp_Pnt(-8.0717,17.9217,-19.335)); - Poles.SetValue(21,30,gp_Pnt(-8.07055,22.0086,-19.4167)); - Poles.SetValue(21,31,gp_Pnt(-8.05978,26.0647,-19.4458)); - Poles.SetValue(21,32,gp_Pnt(-8.05131,29.6191,-19.5118)); - Poles.SetValue(21,33,gp_Pnt(-8.01648,32.5759,-19.5302)); - Poles.SetValue(21,34,gp_Pnt(-7.99358,34.5369,-19.5134)); - Poles.SetValue(21,35,gp_Pnt(-7.96305,36.995,-19.2659)); - Poles.SetValue(21,36,gp_Pnt(-7.89264,39.5831,-18.0731)); - Poles.SetValue(21,37,gp_Pnt(-7.80775,42.0631,-16.4261)); - Poles.SetValue(21,38,gp_Pnt(-7.72798,44.4322,-14.6014)); - Poles.SetValue(21,39,gp_Pnt(-7.66064,47.9074,-12.6609)); - Poles.SetValue(21,40,gp_Pnt(-7.60827,52.3383,-10.3218)); - Poles.SetValue(21,41,gp_Pnt(-7.5563,57.6762,-7.76823)); - Poles.SetValue(21,42,gp_Pnt(-7.51475,63.2251,-6.53953)); - Poles.SetValue(21,43,gp_Pnt(-7.4842,70.9764,-6.08044)); - Poles.SetValue(21,44,gp_Pnt(-7.47797,84.7397,-4.49862)); - Poles.SetValue(21,45,gp_Pnt(-7.3721,103.678,-3.1159)); - Poles.SetValue(21,46,gp_Pnt(-7.30045,126.923,-1.49726)); - Poles.SetValue(21,47,gp_Pnt(-7.24466,142.305,-0.525039)); - Poles.SetValue(21,48,gp_Pnt(-7.21746,150.004,0.00128023)); - Poles.SetValue(22,1,gp_Pnt(-4.32857,-150.003,-0.00540373)); - Poles.SetValue(22,2,gp_Pnt(-4.34699,-142.25,-0.340193)); - Poles.SetValue(22,3,gp_Pnt(-4.38209,-126.827,-1.02934)); - Poles.SetValue(22,4,gp_Pnt(-4.43222,-103.375,-2.20818)); - Poles.SetValue(22,5,gp_Pnt(-4.51083,-84.4311,-3.19069)); - Poles.SetValue(22,6,gp_Pnt(-4.50022,-70.4378,-4.36422)); - Poles.SetValue(22,7,gp_Pnt(-4.53329,-62.7487,-4.58414)); - Poles.SetValue(22,8,gp_Pnt(-4.57686,-57.3432,-6.16997)); - Poles.SetValue(22,9,gp_Pnt(-4.61953,-52.0531,-8.97091)); - Poles.SetValue(22,10,gp_Pnt(-4.66076,-47.6551,-11.5891)); - Poles.SetValue(22,11,gp_Pnt(-4.71605,-44.2575,-13.7456)); - Poles.SetValue(22,12,gp_Pnt(-4.77767,-41.9525,-15.6786)); - Poles.SetValue(22,13,gp_Pnt(-4.83539,-39.4972,-17.3021)); - Poles.SetValue(22,14,gp_Pnt(-4.8662,-36.7917,-18.2384)); - Poles.SetValue(22,15,gp_Pnt(-4.87772,-34.2883,-18.3918)); - Poles.SetValue(22,16,gp_Pnt(-4.88127,-32.275,-18.4126)); - Poles.SetValue(22,17,gp_Pnt(-4.88815,-29.2471,-18.3654)); - Poles.SetValue(22,18,gp_Pnt(-4.88172,-25.6402,-18.4073)); - Poles.SetValue(22,19,gp_Pnt(-4.87676,-21.522,-18.4843)); - Poles.SetValue(22,20,gp_Pnt(-4.86998,-17.3855,-18.5721)); - Poles.SetValue(22,21,gp_Pnt(-4.86604,-13.2345,-18.6261)); - Poles.SetValue(22,22,gp_Pnt(-4.868,-9.07675,-18.7038)); - Poles.SetValue(22,23,gp_Pnt(-4.87197,-5.95561,-18.7836)); - Poles.SetValue(22,24,gp_Pnt(-4.88122,-1.79016,-18.8508)); - Poles.SetValue(22,25,gp_Pnt(-4.89416,2.37596,-18.9454)); - Poles.SetValue(22,26,gp_Pnt(-4.91129,6.53746,-19.0539)); - Poles.SetValue(22,27,gp_Pnt(-4.92518,9.65454,-19.1026)); - Poles.SetValue(22,28,gp_Pnt(-4.944,13.8012,-19.1613)); - Poles.SetValue(22,29,gp_Pnt(-4.95795,17.9235,-19.2456)); - Poles.SetValue(22,30,gp_Pnt(-4.96475,22.0131,-19.3102)); - Poles.SetValue(22,31,gp_Pnt(-4.96533,26.0736,-19.3498)); - Poles.SetValue(22,32,gp_Pnt(-4.96079,29.6176,-19.4284)); - Poles.SetValue(22,33,gp_Pnt(-4.94348,32.5873,-19.466)); - Poles.SetValue(22,34,gp_Pnt(-4.93172,34.561,-19.4669)); - Poles.SetValue(22,35,gp_Pnt(-4.91254,37.0161,-19.3038)); - Poles.SetValue(22,36,gp_Pnt(-4.88212,39.6621,-18.2512)); - Poles.SetValue(22,37,gp_Pnt(-4.83796,42.1306,-16.6572)); - Poles.SetValue(22,38,gp_Pnt(-4.79279,44.4479,-14.7487)); - Poles.SetValue(22,39,gp_Pnt(-4.75792,47.9195,-12.7903)); - Poles.SetValue(22,40,gp_Pnt(-4.73201,52.3475,-10.3957)); - Poles.SetValue(22,41,gp_Pnt(-4.70638,57.7231,-7.87102)); - Poles.SetValue(22,42,gp_Pnt(-4.67107,63.2171,-6.47477)); - Poles.SetValue(22,43,gp_Pnt(-4.63073,70.9601,-6.08756)); - Poles.SetValue(22,44,gp_Pnt(-4.59233,84.7477,-4.47556)); - Poles.SetValue(22,45,gp_Pnt(-4.49985,103.673,-3.18097)); - Poles.SetValue(22,46,gp_Pnt(-4.41639,126.923,-1.46262)); - Poles.SetValue(22,47,gp_Pnt(-4.36049,142.305,-0.536542)); - Poles.SetValue(22,48,gp_Pnt(-4.3327,150.004,0.000952771)); - Poles.SetValue(23,1,gp_Pnt(-2.88635,-150.004,-0.00575623)); - Poles.SetValue(23,2,gp_Pnt(-2.90517,-142.249,-0.341549)); - Poles.SetValue(23,3,gp_Pnt(-2.93974,-126.829,-1.02278)); - Poles.SetValue(23,4,gp_Pnt(-2.99795,-103.372,-2.19554)); - Poles.SetValue(23,5,gp_Pnt(-3.06615,-84.432,-3.18891)); - Poles.SetValue(23,6,gp_Pnt(-3.07817,-70.436,-4.35294)); - Poles.SetValue(23,7,gp_Pnt(-3.11358,-62.751,-4.58803)); - Poles.SetValue(23,8,gp_Pnt(-3.149,-57.3489,-6.16224)); - Poles.SetValue(23,9,gp_Pnt(-3.18087,-52.0832,-9.02443)); - Poles.SetValue(23,10,gp_Pnt(-3.20794,-47.6671,-11.6136)); - Poles.SetValue(23,11,gp_Pnt(-3.24262,-44.2844,-13.7946)); - Poles.SetValue(23,12,gp_Pnt(-3.28123,-41.9804,-15.721)); - Poles.SetValue(23,13,gp_Pnt(-3.31573,-39.5144,-17.3255)); - Poles.SetValue(23,14,gp_Pnt(-3.33437,-36.7949,-18.2234)); - Poles.SetValue(23,15,gp_Pnt(-3.34011,-34.2951,-18.3746)); - Poles.SetValue(23,16,gp_Pnt(-3.34154,-32.2808,-18.382)); - Poles.SetValue(23,17,gp_Pnt(-3.34327,-29.2512,-18.3471)); - Poles.SetValue(23,18,gp_Pnt(-3.33398,-25.6485,-18.3903)); - Poles.SetValue(23,19,gp_Pnt(-3.32526,-21.5295,-18.4702)); - Poles.SetValue(23,20,gp_Pnt(-3.31575,-17.3931,-18.5594)); - Poles.SetValue(23,21,gp_Pnt(-3.30973,-13.2415,-18.6106)); - Poles.SetValue(23,22,gp_Pnt(-3.3096,-9.08307,-18.6879)); - Poles.SetValue(23,23,gp_Pnt(-3.31238,-5.96107,-18.7525)); - Poles.SetValue(23,24,gp_Pnt(-3.31981,-1.7953,-18.8291)); - Poles.SetValue(23,25,gp_Pnt(-3.33173,2.3711,-18.9327)); - Poles.SetValue(23,26,gp_Pnt(-3.34803,6.53266,-19.0255)); - Poles.SetValue(23,27,gp_Pnt(-3.36177,9.6497,-19.0722)); - Poles.SetValue(23,28,gp_Pnt(-3.38073,13.796,-19.1329)); - Poles.SetValue(23,29,gp_Pnt(-3.39705,17.9191,-19.2008)); - Poles.SetValue(23,30,gp_Pnt(-3.40752,22.0091,-19.2675)); - Poles.SetValue(23,31,gp_Pnt(-3.41262,26.0715,-19.318)); - Poles.SetValue(23,32,gp_Pnt(-3.4138,29.6137,-19.3688)); - Poles.SetValue(23,33,gp_Pnt(-3.40248,32.5858,-19.4134)); - Poles.SetValue(23,34,gp_Pnt(-3.39479,34.5605,-19.4192)); - Poles.SetValue(23,35,gp_Pnt(-3.38139,37.0117,-19.2935)); - Poles.SetValue(23,36,gp_Pnt(-3.36593,39.6724,-18.2438)); - Poles.SetValue(23,37,gp_Pnt(-3.34268,42.1365,-16.6785)); - Poles.SetValue(23,38,gp_Pnt(-3.32014,44.4714,-14.7844)); - Poles.SetValue(23,39,gp_Pnt(-3.30336,47.9303,-12.8108)); - Poles.SetValue(23,40,gp_Pnt(-3.29238,52.3621,-10.4158)); - Poles.SetValue(23,41,gp_Pnt(-3.27781,57.7309,-7.88219)); - Poles.SetValue(23,42,gp_Pnt(-3.24892,63.2201,-6.4727)); - Poles.SetValue(23,43,gp_Pnt(-3.20448,70.9551,-6.07441)); - Poles.SetValue(23,44,gp_Pnt(-3.14808,84.7489,-4.47297)); - Poles.SetValue(23,45,gp_Pnt(-3.06369,103.669,-3.15564)); - Poles.SetValue(23,46,gp_Pnt(-2.97399,126.928,-1.47488)); - Poles.SetValue(23,47,gp_Pnt(-2.9181,142.304,-0.533731)); - Poles.SetValue(23,48,gp_Pnt(-2.8902,150.005,-0.00415237)); - Poles.SetValue(24,1,gp_Pnt(-0.963346,-150.005,-0.00635749)); - Poles.SetValue(24,2,gp_Pnt(-0.982765,-142.248,-0.343803)); - Poles.SetValue(24,3,gp_Pnt(-1.01653,-126.833,-1.01474)); - Poles.SetValue(24,4,gp_Pnt(-1.0855,-103.368,-2.17966)); - Poles.SetValue(24,5,gp_Pnt(-1.14,-84.4332,-3.18535)); - Poles.SetValue(24,6,gp_Pnt(-1.18193,-70.4337,-4.33879)); - Poles.SetValue(24,7,gp_Pnt(-1.22089,-62.7532,-4.58618)); - Poles.SetValue(24,8,gp_Pnt(-1.24557,-57.3605,-6.16284)); - Poles.SetValue(24,9,gp_Pnt(-1.26254,-52.1152,-9.08105)); - Poles.SetValue(24,10,gp_Pnt(-1.27132,-47.6865,-11.6584)); - Poles.SetValue(24,11,gp_Pnt(-1.27992,-44.3077,-13.8385)); - Poles.SetValue(24,12,gp_Pnt(-1.28505,-42.028,-15.8032)); - Poles.SetValue(24,13,gp_Pnt(-1.29202,-39.5278,-17.3361)); - Poles.SetValue(24,14,gp_Pnt(-1.29044,-36.8146,-18.2432)); - Poles.SetValue(24,15,gp_Pnt(-1.2914,-34.2976,-18.337)); - Poles.SetValue(24,16,gp_Pnt(-1.28862,-32.2873,-18.3422)); - Poles.SetValue(24,17,gp_Pnt(-1.28371,-29.2589,-18.3188)); - Poles.SetValue(24,18,gp_Pnt(-1.27051,-25.6583,-18.3674)); - Poles.SetValue(24,19,gp_Pnt(-1.25674,-21.5399,-18.4519)); - Poles.SetValue(24,20,gp_Pnt(-1.24362,-17.4031,-18.5423)); - Poles.SetValue(24,21,gp_Pnt(-1.23485,-13.2508,-18.5894)); - Poles.SetValue(24,22,gp_Pnt(-1.23205,-9.09139,-18.6638)); - Poles.SetValue(24,23,gp_Pnt(-1.23315,-5.96846,-18.7159)); - Poles.SetValue(24,24,gp_Pnt(-1.23832,-1.80206,-18.7988)); - Poles.SetValue(24,25,gp_Pnt(-1.24872,2.36463,-18.9162)); - Poles.SetValue(24,26,gp_Pnt(-1.26403,6.5264,-18.9901)); - Poles.SetValue(24,27,gp_Pnt(-1.27763,9.64349,-19.0285)); - Poles.SetValue(24,28,gp_Pnt(-1.29677,13.7898,-19.0962)); - Poles.SetValue(24,29,gp_Pnt(-1.31634,17.9135,-19.1409)); - Poles.SetValue(24,30,gp_Pnt(-1.33161,22.005,-19.2088)); - Poles.SetValue(24,31,gp_Pnt(-1.34301,26.0674,-19.2798)); - Poles.SetValue(24,32,gp_Pnt(-1.35106,29.6117,-19.2876)); - Poles.SetValue(24,33,gp_Pnt(-1.34846,32.5823,-19.3398)); - Poles.SetValue(24,34,gp_Pnt(-1.34527,34.5559,-19.385)); - Poles.SetValue(24,35,gp_Pnt(-1.34071,37.0193,-19.2612)); - Poles.SetValue(24,36,gp_Pnt(-1.34509,39.6789,-18.263)); - Poles.SetValue(24,37,gp_Pnt(-1.35008,42.1558,-16.6984)); - Poles.SetValue(24,38,gp_Pnt(-1.35773,44.4897,-14.8274)); - Poles.SetValue(24,39,gp_Pnt(-1.36444,47.9479,-12.8384)); - Poles.SetValue(24,40,gp_Pnt(-1.37307,52.376,-10.4394)); - Poles.SetValue(24,41,gp_Pnt(-1.37346,57.7433,-7.89619)); - Poles.SetValue(24,42,gp_Pnt(-1.35291,63.2224,-6.46618)); - Poles.SetValue(24,43,gp_Pnt(-1.30269,70.9487,-6.0561)); - Poles.SetValue(24,44,gp_Pnt(-1.2225,84.7507,-4.47221)); - Poles.SetValue(24,45,gp_Pnt(-1.1488,103.665,-3.1278)); - Poles.SetValue(24,46,gp_Pnt(-1.05086,126.933,-1.48899)); - Poles.SetValue(24,47,gp_Pnt(-0.994938,142.302,-0.530106)); - Poles.SetValue(24,48,gp_Pnt(-0.966871,150.006,-0.0110631)); - Poles.SetValue(25,1,gp_Pnt(0.959819,-150.003,0.00568631)); - Poles.SetValue(25,2,gp_Pnt(0.940055,-142.247,-0.331366)); - Poles.SetValue(25,3,gp_Pnt(0.906483,-126.833,-0.995719)); - Poles.SetValue(25,4,gp_Pnt(0.827614,-103.361,-2.15145)); - Poles.SetValue(25,5,gp_Pnt(0.785273,-84.4342,-3.16894)); - Poles.SetValue(25,6,gp_Pnt(0.714392,-70.4325,-4.31753)); - Poles.SetValue(25,7,gp_Pnt(0.672237,-62.7537,-4.559)); - Poles.SetValue(25,8,gp_Pnt(0.659329,-57.3653,-6.14528)); - Poles.SetValue(25,9,gp_Pnt(0.661645,-52.1004,-9.03387)); - Poles.SetValue(25,10,gp_Pnt(0.669516,-47.6625,-11.5964)); - Poles.SetValue(25,11,gp_Pnt(0.689569,-44.3049,-13.8062)); - Poles.SetValue(25,12,gp_Pnt(0.71644,-42.0351,-15.7831)); - Poles.SetValue(25,13,gp_Pnt(0.738005,-39.535,-17.3193)); - Poles.SetValue(25,14,gp_Pnt(0.754916,-36.82,-18.2146)); - Poles.SetValue(25,15,gp_Pnt(0.759797,-34.3048,-18.3011)); - Poles.SetValue(25,16,gp_Pnt(0.766913,-32.293,-18.3232)); - Poles.SetValue(25,17,gp_Pnt(0.776889,-29.2662,-18.2948)); - Poles.SetValue(25,18,gp_Pnt(0.794825,-25.6669,-18.3503)); - Poles.SetValue(25,19,gp_Pnt(0.812837,-21.5492,-18.4233)); - Poles.SetValue(25,20,gp_Pnt(0.829745,-17.4125,-18.5129)); - Poles.SetValue(25,21,gp_Pnt(0.841595,-13.2595,-18.5688)); - Poles.SetValue(25,22,gp_Pnt(0.847267,-9.09893,-18.6407)); - Poles.SetValue(25,23,gp_Pnt(0.848219,-5.97561,-18.6984)); - Poles.SetValue(25,24,gp_Pnt(0.844946,-1.80848,-18.7707)); - Poles.SetValue(25,25,gp_Pnt(0.835788,2.35803,-18.8937)); - Poles.SetValue(25,26,gp_Pnt(0.820538,6.52081,-18.96)); - Poles.SetValue(25,27,gp_Pnt(0.806453,9.63874,-18.9827)); - Poles.SetValue(25,28,gp_Pnt(0.786356,13.7858,-19.059)); - Poles.SetValue(25,29,gp_Pnt(0.763708,17.9106,-19.0832)); - Poles.SetValue(25,30,gp_Pnt(0.743879,22.0023,-19.1557)); - Poles.SetValue(25,31,gp_Pnt(0.727329,26.0648,-19.2442)); - Poles.SetValue(25,32,gp_Pnt(0.712384,29.6076,-19.2121)); - Poles.SetValue(25,33,gp_Pnt(0.709962,32.5804,-19.3472)); - Poles.SetValue(25,34,gp_Pnt(0.705581,34.5476,-19.3214)); - Poles.SetValue(25,35,gp_Pnt(0.704066,37.0253,-19.2554)); - Poles.SetValue(25,36,gp_Pnt(0.68005,39.6706,-18.2118)); - Poles.SetValue(25,37,gp_Pnt(0.648205,42.1617,-16.677)); - Poles.SetValue(25,38,gp_Pnt(0.61021,44.4849,-14.7789)); - Poles.SetValue(25,39,gp_Pnt(0.578672,47.947,-12.7969)); - Poles.SetValue(25,40,gp_Pnt(0.549361,52.3609,-10.3659)); - Poles.SetValue(25,41,gp_Pnt(0.531102,57.7221,-7.80854)); - Poles.SetValue(25,42,gp_Pnt(0.542483,63.2121,-6.41916)); - Poles.SetValue(25,43,gp_Pnt(0.600457,70.9445,-6.01981)); - Poles.SetValue(25,44,gp_Pnt(0.701564,84.7526,-4.48639)); - Poles.SetValue(25,45,gp_Pnt(0.766341,103.657,-3.09192)); - Poles.SetValue(25,46,gp_Pnt(0.870496,126.929,-1.44947)); - Poles.SetValue(25,47,gp_Pnt(0.927725,142.298,-0.506458)); - Poles.SetValue(25,48,gp_Pnt(0.955638,150.002,0.013664)); - Poles.SetValue(26,1,gp_Pnt(2.88276,-150.003,0.00510712)); - Poles.SetValue(26,2,gp_Pnt(2.86273,-142.249,-0.334571)); - Poles.SetValue(26,3,gp_Pnt(2.82941,-126.831,-0.981236)); - Poles.SetValue(26,4,gp_Pnt(2.74035,-103.363,-2.14876)); - Poles.SetValue(26,5,gp_Pnt(2.71066,-84.4321,-3.14812)); - Poles.SetValue(26,6,gp_Pnt(2.61085,-70.4333,-4.28563)); - Poles.SetValue(26,7,gp_Pnt(2.56523,-62.7558,-4.53254)); - Poles.SetValue(26,8,gp_Pnt(2.56347,-57.3598,-6.10287)); - Poles.SetValue(26,9,gp_Pnt(2.58158,-52.1003,-8.99526)); - Poles.SetValue(26,10,gp_Pnt(2.60803,-47.6567,-11.5441)); - Poles.SetValue(26,11,gp_Pnt(2.65382,-44.2876,-13.7304)); - Poles.SetValue(26,12,gp_Pnt(2.71408,-42.0076,-15.6963)); - Poles.SetValue(26,13,gp_Pnt(2.7632,-39.5234,-17.2513)); - Poles.SetValue(26,14,gp_Pnt(2.80034,-36.8171,-18.1742)); - Poles.SetValue(26,15,gp_Pnt(2.81048,-34.3087,-18.2745)); - Poles.SetValue(26,16,gp_Pnt(2.82183,-32.2984,-18.2966)); - Poles.SetValue(26,17,gp_Pnt(2.83832,-29.2732,-18.2842)); - Poles.SetValue(26,18,gp_Pnt(2.8597,-25.6748,-18.3055)); - Poles.SetValue(26,19,gp_Pnt(2.88306,-21.5575,-18.3968)); - Poles.SetValue(26,20,gp_Pnt(2.9041,-17.4213,-18.4977)); - Poles.SetValue(26,21,gp_Pnt(2.91912,-13.2677,-18.5504)); - Poles.SetValue(26,22,gp_Pnt(2.92733,-9.10621,-18.6181)); - Poles.SetValue(26,23,gp_Pnt(2.9299,-5.98236,-18.6736)); - Poles.SetValue(26,24,gp_Pnt(2.92848,-1.81523,-18.7537)); - Poles.SetValue(26,25,gp_Pnt(2.92031,2.35123,-18.8647)); - Poles.SetValue(26,26,gp_Pnt(2.90582,6.51345,-18.9446)); - Poles.SetValue(26,27,gp_Pnt(2.89198,9.63105,-18.9812)); - Poles.SetValue(26,28,gp_Pnt(2.87035,13.7782,-19.0068)); - Poles.SetValue(26,29,gp_Pnt(2.84585,17.9026,-19.0689)); - Poles.SetValue(26,30,gp_Pnt(2.82094,21.9938,-19.1239)); - Poles.SetValue(26,31,gp_Pnt(2.79658,26.0594,-19.1547)); - Poles.SetValue(26,32,gp_Pnt(2.77809,29.5996,-19.2041)); - Poles.SetValue(26,33,gp_Pnt(2.76651,32.5773,-19.2914)); - Poles.SetValue(26,34,gp_Pnt(2.75864,34.5628,-19.3306)); - Poles.SetValue(26,35,gp_Pnt(2.74443,36.979,-19.1345)); - Poles.SetValue(26,36,gp_Pnt(2.70387,39.6961,-18.1971)); - Poles.SetValue(26,37,gp_Pnt(2.63982,42.114,-16.5479)); - Poles.SetValue(26,38,gp_Pnt(2.5746,44.4902,-14.7277)); - Poles.SetValue(26,39,gp_Pnt(2.51798,47.9308,-12.7131)); - Poles.SetValue(26,40,gp_Pnt(2.46965,52.3578,-10.3138)); - Poles.SetValue(26,41,gp_Pnt(2.43642,57.712,-7.75158)); - Poles.SetValue(26,42,gp_Pnt(2.43995,63.2076,-6.38184)); - Poles.SetValue(26,43,gp_Pnt(2.50293,70.9438,-5.9876)); - Poles.SetValue(26,44,gp_Pnt(2.62733,84.7471,-4.46429)); - Poles.SetValue(26,45,gp_Pnt(2.68225,103.665,-3.11603)); - Poles.SetValue(26,46,gp_Pnt(2.79269,126.925,-1.43235)); - Poles.SetValue(26,47,gp_Pnt(2.85123,142.301,-0.519032)); - Poles.SetValue(26,48,gp_Pnt(2.87892,150.003,0.00754219)); - Poles.SetValue(27,1,gp_Pnt(4.32494,-150.003,0.00465984)); - Poles.SetValue(27,2,gp_Pnt(4.30474,-142.25,-0.336806)); - Poles.SetValue(27,3,gp_Pnt(4.2716,-126.829,-0.969986)); - Poles.SetValue(27,4,gp_Pnt(4.17478,-103.363,-2.1468)); - Poles.SetValue(27,5,gp_Pnt(4.15476,-84.4306,-3.13459)); - Poles.SetValue(27,6,gp_Pnt(4.0329,-70.4336,-4.25922)); - Poles.SetValue(27,7,gp_Pnt(3.98517,-62.757,-4.50984)); - Poles.SetValue(27,8,gp_Pnt(3.9913,-57.3574,-6.07543)); - Poles.SetValue(27,9,gp_Pnt(4.02248,-52.0977,-8.96381)); - Poles.SetValue(27,10,gp_Pnt(4.06134,-47.6524,-11.5091)); - Poles.SetValue(27,11,gp_Pnt(4.12878,-44.273,-13.6756)); - Poles.SetValue(27,12,gp_Pnt(4.21141,-41.9866,-15.6295)); - Poles.SetValue(27,13,gp_Pnt(4.28353,-39.5132,-17.2059)); - Poles.SetValue(27,14,gp_Pnt(4.33348,-36.8179,-18.1432)); - Poles.SetValue(27,15,gp_Pnt(4.34938,-34.3123,-18.2685)); - Poles.SetValue(27,16,gp_Pnt(4.36331,-32.3022,-18.2773)); - Poles.SetValue(27,17,gp_Pnt(4.38418,-29.2798,-18.2738)); - Poles.SetValue(27,18,gp_Pnt(4.40847,-25.6802,-18.2617)); - Poles.SetValue(27,19,gp_Pnt(4.43585,-21.5644,-18.385)); - Poles.SetValue(27,20,gp_Pnt(4.45998,-17.428,-18.4847)); - Poles.SetValue(27,21,gp_Pnt(4.47734,-13.274,-18.5362)); - Poles.SetValue(27,22,gp_Pnt(4.48745,-9.11172,-18.5999)); - Poles.SetValue(27,23,gp_Pnt(4.49128,-5.98756,-18.6581)); - Poles.SetValue(27,24,gp_Pnt(4.49121,-1.8203,-18.7405)); - Poles.SetValue(27,25,gp_Pnt(4.48385,2.34609,-18.8459)); - Poles.SetValue(27,26,gp_Pnt(4.46986,6.50806,-18.9314)); - Poles.SetValue(27,27,gp_Pnt(4.45634,9.62519,-18.9867)); - Poles.SetValue(27,28,gp_Pnt(4.43334,13.773,-18.962)); - Poles.SetValue(27,29,gp_Pnt(4.40783,17.8965,-19.0659)); - Poles.SetValue(27,30,gp_Pnt(4.37876,21.9885,-19.0986)); - Poles.SetValue(27,31,gp_Pnt(4.34905,26.0539,-19.0891)); - Poles.SetValue(27,32,gp_Pnt(4.32668,29.5961,-19.1878)); - Poles.SetValue(27,33,gp_Pnt(4.30965,32.5756,-19.2608)); - Poles.SetValue(27,34,gp_Pnt(4.29649,34.547,-19.2801)); - Poles.SetValue(27,35,gp_Pnt(4.27784,36.9972,-19.1272)); - Poles.SetValue(27,36,gp_Pnt(4.21947,39.6638,-18.1139)); - Poles.SetValue(27,37,gp_Pnt(4.13554,42.1168,-16.5088)); - Poles.SetValue(27,38,gp_Pnt(4.04783,44.4726,-14.6594)); - Poles.SetValue(27,39,gp_Pnt(3.97295,47.9284,-12.6694)); - Poles.SetValue(27,40,gp_Pnt(3.90975,52.3484,-10.2657)); - Poles.SetValue(27,41,gp_Pnt(3.86598,57.7104,-7.72202)); - Poles.SetValue(27,42,gp_Pnt(3.86291,63.2023,-6.3517)); - Poles.SetValue(27,43,gp_Pnt(3.92956,70.9439,-5.96309)); - Poles.SetValue(27,44,gp_Pnt(4.07168,84.743,-4.45222)); - Poles.SetValue(27,45,gp_Pnt(4.11915,103.671,-3.13599)); - Poles.SetValue(27,46,gp_Pnt(4.23427,126.922,-1.42098)); - Poles.SetValue(27,47,gp_Pnt(4.2939,142.303,-0.528462)); - Poles.SetValue(27,48,gp_Pnt(4.3214,150.003,0.00181057)); - Poles.SetValue(28,1,gp_Pnt(7.20975,-150.003,0.00199379)); - Poles.SetValue(28,2,gp_Pnt(7.18882,-142.253,-0.339409)); - Poles.SetValue(28,3,gp_Pnt(7.15603,-126.823,-0.960991)); - Poles.SetValue(28,4,gp_Pnt(7.04705,-103.378,-2.14121)); - Poles.SetValue(28,5,gp_Pnt(7.04011,-84.4152,-3.0599)); - Poles.SetValue(28,6,gp_Pnt(6.8827,-70.4519,-4.22491)); - Poles.SetValue(28,7,gp_Pnt(6.82633,-62.7416,-4.45356)); - Poles.SetValue(28,8,gp_Pnt(6.84632,-57.3274,-5.92928)); - Poles.SetValue(28,9,gp_Pnt(6.90313,-52.0603,-8.76894)); - Poles.SetValue(28,10,gp_Pnt(6.96541,-47.6191,-11.2651)); - Poles.SetValue(28,11,gp_Pnt(7.06713,-44.2153,-13.3835)); - Poles.SetValue(28,12,gp_Pnt(7.19512,-41.9163,-15.3266)); - Poles.SetValue(28,13,gp_Pnt(7.31552,-39.4707,-16.9917)); - Poles.SetValue(28,14,gp_Pnt(7.39349,-36.7863,-18.0229)); - Poles.SetValue(28,15,gp_Pnt(7.42239,-34.3003,-18.2325)); - Poles.SetValue(28,16,gp_Pnt(7.44451,-32.3001,-18.2769)); - Poles.SetValue(28,17,gp_Pnt(7.47675,-29.2865,-18.2652)); - Poles.SetValue(28,18,gp_Pnt(7.50629,-25.6849,-18.2576)); - Poles.SetValue(28,19,gp_Pnt(7.5408,-21.5692,-18.3235)); - Poles.SetValue(28,20,gp_Pnt(7.57163,-17.4339,-18.426)); - Poles.SetValue(28,21,gp_Pnt(7.59489,-13.282,-18.5025)); - Poles.SetValue(28,22,gp_Pnt(7.60855,-9.11981,-18.5619)); - Poles.SetValue(28,23,gp_Pnt(7.61471,-5.99647,-18.6513)); - Poles.SetValue(28,24,gp_Pnt(7.6166,-1.8301,-18.7256)); - Poles.SetValue(28,25,gp_Pnt(7.61019,2.33523,-18.8123)); - Poles.SetValue(28,26,gp_Pnt(7.59637,6.49519,-18.8964)); - Poles.SetValue(28,27,gp_Pnt(7.5818,9.61113,-18.9175)); - Poles.SetValue(28,28,gp_Pnt(7.55779,13.7559,-18.9587)); - Poles.SetValue(28,29,gp_Pnt(7.52587,17.8776,-18.9626)); - Poles.SetValue(28,30,gp_Pnt(7.4901,21.9674,-19.0247)); - Poles.SetValue(28,31,gp_Pnt(7.45312,26.0294,-19.1257)); - Poles.SetValue(28,32,gp_Pnt(7.42514,29.5856,-19.167)); - Poles.SetValue(28,33,gp_Pnt(7.39395,32.555,-19.2183)); - Poles.SetValue(28,34,gp_Pnt(7.37239,34.5295,-19.2131)); - Poles.SetValue(28,35,gp_Pnt(7.33162,36.946,-18.9418)); - Poles.SetValue(28,36,gp_Pnt(7.24313,39.6032,-17.8455)); - Poles.SetValue(28,37,gp_Pnt(7.11296,42.0514,-16.191)); - Poles.SetValue(28,38,gp_Pnt(6.98647,44.4381,-14.3835)); - Poles.SetValue(28,39,gp_Pnt(6.88127,47.9054,-12.4221)); - Poles.SetValue(28,40,gp_Pnt(6.79154,52.3186,-10.0449)); - Poles.SetValue(28,41,gp_Pnt(6.72185,57.6668,-7.53612)); - Poles.SetValue(28,42,gp_Pnt(6.71345,63.1976,-6.30207)); - Poles.SetValue(28,43,gp_Pnt(6.78803,70.9427,-5.8544)); - Poles.SetValue(28,44,gp_Pnt(6.9604,84.7347,-4.44573)); - Poles.SetValue(28,45,gp_Pnt(6.99436,103.676,-3.08077)); - Poles.SetValue(28,46,gp_Pnt(7.11838,126.92,-1.41297)); - Poles.SetValue(28,47,gp_Pnt(7.17835,142.303,-0.517264)); - Poles.SetValue(28,48,gp_Pnt(7.20607,150.004,0.000972213)); - Poles.SetValue(29,1,gp_Pnt(11.537,-150.004,-0.0019364)); - Poles.SetValue(29,2,gp_Pnt(11.5153,-142.257,-0.344646)); - Poles.SetValue(29,3,gp_Pnt(11.4814,-126.814,-0.945148)); - Poles.SetValue(29,4,gp_Pnt(11.3573,-103.399,-2.13514)); - Poles.SetValue(29,5,gp_Pnt(11.367,-84.3943,-2.97324)); - Poles.SetValue(29,6,gp_Pnt(11.1587,-70.4767,-4.1361)); - Poles.SetValue(29,7,gp_Pnt(11.0926,-62.7343,-4.37369)); - Poles.SetValue(29,8,gp_Pnt(11.1242,-57.2568,-5.69537)); - Poles.SetValue(29,9,gp_Pnt(11.2126,-51.9572,-8.35841)); - Poles.SetValue(29,10,gp_Pnt(11.3271,-47.5822,-10.8942)); - Poles.SetValue(29,11,gp_Pnt(11.4644,-44.1049,-12.8681)); - Poles.SetValue(29,12,gp_Pnt(11.6405,-41.7204,-14.7153)); - Poles.SetValue(29,13,gp_Pnt(11.826,-39.3053,-16.4686)); - Poles.SetValue(29,14,gp_Pnt(11.9708,-36.7063,-17.7552)); - Poles.SetValue(29,15,gp_Pnt(12.0323,-34.2848,-18.2164)); - Poles.SetValue(29,16,gp_Pnt(12.0665,-32.2944,-18.2456)); - Poles.SetValue(29,17,gp_Pnt(12.1134,-29.2928,-18.2183)); - Poles.SetValue(29,18,gp_Pnt(12.1502,-25.6859,-18.2702)); - Poles.SetValue(29,19,gp_Pnt(12.1962,-21.5727,-18.2883)); - Poles.SetValue(29,20,gp_Pnt(12.2377,-17.4404,-18.3531)); - Poles.SetValue(29,21,gp_Pnt(12.2704,-13.2922,-18.4587)); - Poles.SetValue(29,22,gp_Pnt(12.2909,-9.1316,-18.5394)); - Poles.SetValue(29,23,gp_Pnt(12.3004,-6.00847,-18.5853)); - Poles.SetValue(29,24,gp_Pnt(12.3062,-1.84393,-18.668)); - Poles.SetValue(29,25,gp_Pnt(12.3017,2.31872,-18.7656)); - Poles.SetValue(29,26,gp_Pnt(12.2867,6.47589,-18.8211)); - Poles.SetValue(29,27,gp_Pnt(12.27,9.58913,-18.8432)); - Poles.SetValue(29,28,gp_Pnt(12.242,13.7302,-18.8857)); - Poles.SetValue(29,29,gp_Pnt(12.2013,17.8471,-18.8567)); - Poles.SetValue(29,30,gp_Pnt(12.1551,21.9335,-18.9411)); - Poles.SetValue(29,31,gp_Pnt(12.1027,25.9912,-19.0065)); - Poles.SetValue(29,32,gp_Pnt(12.0689,29.5626,-19.1079)); - Poles.SetValue(29,33,gp_Pnt(12.0248,32.536,-19.2146)); - Poles.SetValue(29,34,gp_Pnt(11.9908,34.506,-19.2085)); - Poles.SetValue(29,35,gp_Pnt(11.9133,36.8769,-18.6385)); - Poles.SetValue(29,36,gp_Pnt(11.7541,39.4633,-17.3418)); - Poles.SetValue(29,37,gp_Pnt(11.5496,41.8804,-15.5601)); - Poles.SetValue(29,38,gp_Pnt(11.3811,44.3392,-13.8642)); - Poles.SetValue(29,39,gp_Pnt(11.2454,47.87,-12.0305)); - Poles.SetValue(29,40,gp_Pnt(11.1037,52.2433,-9.63697)); - Poles.SetValue(29,41,gp_Pnt(11.0077,57.6157,-7.26995)); - Poles.SetValue(29,42,gp_Pnt(10.9873,63.1748,-6.14324)); - Poles.SetValue(29,43,gp_Pnt(11.0809,70.9505,-5.75361)); - Poles.SetValue(29,44,gp_Pnt(11.2905,84.7164,-4.38829)); - Poles.SetValue(29,45,gp_Pnt(11.3097,103.688,-3.03385)); - Poles.SetValue(29,46,gp_Pnt(11.443,126.913,-1.36961)); - Poles.SetValue(29,47,gp_Pnt(11.5055,142.304,-0.513898)); - Poles.SetValue(29,48,gp_Pnt(11.5331,150.004,0.00143569)); - Poles.SetValue(30,1,gp_Pnt(16.3445,-150.003,0.00578743)); - Poles.SetValue(30,2,gp_Pnt(16.3249,-142.267,-0.370801)); - Poles.SetValue(30,3,gp_Pnt(16.2799,-126.795,-0.898163)); - Poles.SetValue(30,4,gp_Pnt(16.1574,-103.437,-2.15905)); - Poles.SetValue(30,5,gp_Pnt(16.1621,-84.359,-2.81595)); - Poles.SetValue(30,6,gp_Pnt(15.9355,-70.522,-4.02929)); - Poles.SetValue(30,7,gp_Pnt(15.8353,-62.7113,-4.30109)); - Poles.SetValue(30,8,gp_Pnt(15.8592,-57.1301,-5.29219)); - Poles.SetValue(30,9,gp_Pnt(15.9885,-51.8279,-7.70639)); - Poles.SetValue(30,10,gp_Pnt(16.1458,-47.454,-10.0875)); - Poles.SetValue(30,11,gp_Pnt(16.3056,-43.9394,-11.9786)); - Poles.SetValue(30,12,gp_Pnt(16.4697,-41.3722,-13.5536)); - Poles.SetValue(30,13,gp_Pnt(16.7346,-38.9838,-15.419)); - Poles.SetValue(30,14,gp_Pnt(16.9692,-36.4718,-16.9881)); - Poles.SetValue(30,15,gp_Pnt(17.0978,-34.1539,-17.8546)); - Poles.SetValue(30,16,gp_Pnt(17.1618,-32.2064,-18.1241)); - Poles.SetValue(30,17,gp_Pnt(17.2498,-29.2572,-18.3817)); - Poles.SetValue(30,18,gp_Pnt(17.2843,-25.6335,-18.1023)); - Poles.SetValue(30,19,gp_Pnt(17.349,-21.5427,-18.2505)); - Poles.SetValue(30,20,gp_Pnt(17.4018,-17.4207,-18.275)); - Poles.SetValue(30,21,gp_Pnt(17.4446,-13.282,-18.3905)); - Poles.SetValue(30,22,gp_Pnt(17.4712,-9.12898,-18.4481)); - Poles.SetValue(30,23,gp_Pnt(17.484,-6.01145,-18.4793)); - Poles.SetValue(30,24,gp_Pnt(17.4931,-1.85495,-18.5611)); - Poles.SetValue(30,25,gp_Pnt(17.489,2.29988,-18.6221)); - Poles.SetValue(30,26,gp_Pnt(17.4726,6.44817,-18.6907)); - Poles.SetValue(30,27,gp_Pnt(17.4549,9.55413,-18.7566)); - Poles.SetValue(30,28,gp_Pnt(17.4205,13.6861,-18.7666)); - Poles.SetValue(30,29,gp_Pnt(17.3732,17.7936,-18.8446)); - Poles.SetValue(30,30,gp_Pnt(17.3181,21.8766,-18.906)); - Poles.SetValue(30,31,gp_Pnt(17.2501,25.9253,-18.909)); - Poles.SetValue(30,32,gp_Pnt(17.2175,29.502,-19.3082)); - Poles.SetValue(30,33,gp_Pnt(17.1165,32.4131,-19.0021)); - Poles.SetValue(30,34,gp_Pnt(17.0447,34.3389,-18.7229)); - Poles.SetValue(30,35,gp_Pnt(16.8753,36.5819,-17.6749)); - Poles.SetValue(30,36,gp_Pnt(16.6444,39.1331,-16.2131)); - Poles.SetValue(30,37,gp_Pnt(16.3774,41.5535,-14.3732)); - Poles.SetValue(30,38,gp_Pnt(16.2266,44.1917,-12.9771)); - Poles.SetValue(30,39,gp_Pnt(16.0512,47.7031,-11.1156)); - Poles.SetValue(30,40,gp_Pnt(15.8965,52.1551,-9.02732)); - Poles.SetValue(30,41,gp_Pnt(15.7531,57.497,-6.73597)); - Poles.SetValue(30,42,gp_Pnt(15.7515,63.1508,-5.99587)); - Poles.SetValue(30,43,gp_Pnt(15.8708,70.9704,-5.59492)); - Poles.SetValue(30,44,gp_Pnt(16.0904,84.6832,-4.25753)); - Poles.SetValue(30,45,gp_Pnt(16.1141,103.717,-3.04271)); - Poles.SetValue(30,46,gp_Pnt(16.2429,126.893,-1.24525)); - Poles.SetValue(30,47,gp_Pnt(16.3147,142.31,-0.535292)); - Poles.SetValue(30,48,gp_Pnt(16.341,150.003,0.00253219)); - Poles.SetValue(31,1,gp_Pnt(20.1907,-150.004,-0.000526058)); - Poles.SetValue(31,2,gp_Pnt(20.1704,-142.268,-0.331239)); - Poles.SetValue(31,3,gp_Pnt(20.122,-126.794,-0.970591)); - Poles.SetValue(31,4,gp_Pnt(19.9951,-103.451,-1.9936)); - Poles.SetValue(31,5,gp_Pnt(19.9957,-84.3412,-2.79149)); - Poles.SetValue(31,6,gp_Pnt(19.7663,-70.5532,-3.8958)); - Poles.SetValue(31,7,gp_Pnt(19.6372,-62.6961,-4.24537)); - Poles.SetValue(31,8,gp_Pnt(19.6312,-57.0153,-4.8376)); - Poles.SetValue(31,9,gp_Pnt(19.8029,-51.7257,-7.12882)); - Poles.SetValue(31,10,gp_Pnt(19.9903,-47.3456,-9.33312)); - Poles.SetValue(31,11,gp_Pnt(20.1544,-43.7936,-11.1495)); - Poles.SetValue(31,12,gp_Pnt(20.3067,-41.1475,-12.5808)); - Poles.SetValue(31,13,gp_Pnt(20.5363,-38.6079,-14.2468)); - Poles.SetValue(31,14,gp_Pnt(20.84,-36.134,-15.9275)); - Poles.SetValue(31,15,gp_Pnt(21.0623,-33.9474,-17.1599)); - Poles.SetValue(31,16,gp_Pnt(21.1716,-32.0518,-17.667)); - Poles.SetValue(31,17,gp_Pnt(21.3214,-29.179,-18.3673)); - Poles.SetValue(31,18,gp_Pnt(21.3793,-25.5812,-18.3124)); - Poles.SetValue(31,19,gp_Pnt(21.4548,-21.5049,-18.1853)); - Poles.SetValue(31,20,gp_Pnt(21.5142,-17.3922,-18.2366)); - Poles.SetValue(31,21,gp_Pnt(21.558,-13.2603,-18.3063)); - Poles.SetValue(31,22,gp_Pnt(21.5878,-9.11659,-18.3336)); - Poles.SetValue(31,23,gp_Pnt(21.6056,-6.00831,-18.4512)); - Poles.SetValue(31,24,gp_Pnt(21.6167,-1.86141,-18.4833)); - Poles.SetValue(31,25,gp_Pnt(21.6127,2.2836,-18.5266)); - Poles.SetValue(31,26,gp_Pnt(21.5944,6.42098,-18.6074)); - Poles.SetValue(31,27,gp_Pnt(21.5727,9.51941,-18.6404)); - Poles.SetValue(31,28,gp_Pnt(21.5378,13.6411,-18.7487)); - Poles.SetValue(31,29,gp_Pnt(21.4866,17.743,-18.7215)); - Poles.SetValue(31,30,gp_Pnt(21.4258,21.8165,-18.8984)); - Poles.SetValue(31,31,gp_Pnt(21.3369,25.8371,-19.0188)); - Poles.SetValue(31,32,gp_Pnt(21.2862,29.4092,-19.1007)); - Poles.SetValue(31,33,gp_Pnt(21.1135,32.2368,-18.3775)); - Poles.SetValue(31,34,gp_Pnt(20.9861,34.1014,-17.8358)); - Poles.SetValue(31,35,gp_Pnt(20.7501,36.2734,-16.587)); - Poles.SetValue(31,36,gp_Pnt(20.4474,38.7816,-15.0031)); - Poles.SetValue(31,37,gp_Pnt(20.2219,41.3577,-13.4124)); - Poles.SetValue(31,38,gp_Pnt(20.0752,44.046,-12.1119)); - Poles.SetValue(31,39,gp_Pnt(19.9,47.6135,-10.3667)); - Poles.SetValue(31,40,gp_Pnt(19.7027,52.0328,-8.33553)); - Poles.SetValue(31,41,gp_Pnt(19.5529,57.4314,-6.41226)); - Poles.SetValue(31,42,gp_Pnt(19.5744,63.1466,-5.88305)); - Poles.SetValue(31,43,gp_Pnt(19.7084,70.9809,-5.38238)); - Poles.SetValue(31,44,gp_Pnt(19.9269,84.6646,-4.23097)); - Poles.SetValue(31,45,gp_Pnt(19.9547,103.723,-2.89651)); - Poles.SetValue(31,46,gp_Pnt(20.0869,126.892,-1.26097)); - Poles.SetValue(31,47,gp_Pnt(20.16,142.308,-0.498836)); - Poles.SetValue(31,48,gp_Pnt(20.1872,150.004,-0.000635283)); - Poles.SetValue(32,1,gp_Pnt(23.0753,-150.004,0.00144521)); - Poles.SetValue(32,2,gp_Pnt(23.0548,-142.27,-0.337801)); - Poles.SetValue(32,3,gp_Pnt(23.0016,-126.788,-0.942781)); - Poles.SetValue(32,4,gp_Pnt(22.8773,-103.469,-1.9433)); - Poles.SetValue(32,5,gp_Pnt(22.8673,-84.3255,-2.74248)); - Poles.SetValue(32,6,gp_Pnt(22.6434,-70.5754,-3.79108)); - Poles.SetValue(32,7,gp_Pnt(22.4949,-62.6931,-4.17157)); - Poles.SetValue(32,8,gp_Pnt(22.4768,-56.9735,-4.67076)); - Poles.SetValue(32,9,gp_Pnt(22.6398,-51.6068,-6.54067)); - Poles.SetValue(32,10,gp_Pnt(22.85,-47.2263,-8.64328)); - Poles.SetValue(32,11,gp_Pnt(23.0318,-43.6813,-10.4638)); - Poles.SetValue(32,12,gp_Pnt(23.1562,-40.9615,-11.764)); - Poles.SetValue(32,13,gp_Pnt(23.368,-38.3504,-13.3038)); - Poles.SetValue(32,14,gp_Pnt(23.6652,-35.817,-14.919)); - Poles.SetValue(32,15,gp_Pnt(23.9354,-33.6785,-16.2623)); - Poles.SetValue(32,16,gp_Pnt(24.0927,-31.8451,-17.0162)); - Poles.SetValue(32,17,gp_Pnt(24.3261,-29.0715,-18.0603)); - Poles.SetValue(32,18,gp_Pnt(24.4211,-25.5163,-18.3534)); - Poles.SetValue(32,19,gp_Pnt(24.5253,-21.4717,-18.3276)); - Poles.SetValue(32,20,gp_Pnt(24.5868,-17.3628,-18.1811)); - Poles.SetValue(32,21,gp_Pnt(24.6337,-13.2388,-18.2382)); - Poles.SetValue(32,22,gp_Pnt(24.6633,-9.10443,-18.3301)); - Poles.SetValue(32,23,gp_Pnt(24.6763,-6.00141,-18.3329)); - Poles.SetValue(32,24,gp_Pnt(24.6883,-1.86447,-18.4)); - Poles.SetValue(32,25,gp_Pnt(24.685,2.27094,-18.4513)); - Poles.SetValue(32,26,gp_Pnt(24.6679,6.39927,-18.5271)); - Poles.SetValue(32,27,gp_Pnt(24.6503,9.49024,-18.6028)); - Poles.SetValue(32,28,gp_Pnt(24.6143,13.6057,-18.6066)); - Poles.SetValue(32,29,gp_Pnt(24.5631,17.7003,-18.6756)); - Poles.SetValue(32,30,gp_Pnt(24.4992,21.766,-18.9712)); - Poles.SetValue(32,31,gp_Pnt(24.3992,25.7809,-18.8799)); - Poles.SetValue(32,32,gp_Pnt(24.3004,29.3057,-18.7554)); - Poles.SetValue(32,33,gp_Pnt(24.037,32.0419,-17.6838)); - Poles.SetValue(32,34,gp_Pnt(23.8657,33.8604,-16.9256)); - Poles.SetValue(32,35,gp_Pnt(23.5774,35.9803,-15.5713)); - Poles.SetValue(32,36,gp_Pnt(23.2968,38.5683,-14.0879)); - Poles.SetValue(32,37,gp_Pnt(23.093,41.2165,-12.6479)); - Poles.SetValue(32,38,gp_Pnt(22.9531,43.9435,-11.4158)); - Poles.SetValue(32,39,gp_Pnt(22.7622,47.5105,-9.68785)); - Poles.SetValue(32,40,gp_Pnt(22.5568,51.9527,-7.8039)); - Poles.SetValue(32,41,gp_Pnt(22.4004,57.3744,-6.1033)); - Poles.SetValue(32,42,gp_Pnt(22.4489,63.1511,-5.80662)); - Poles.SetValue(32,43,gp_Pnt(22.5902,70.9891,-5.2305)); - Poles.SetValue(32,44,gp_Pnt(22.799,84.6457,-4.15543)); - Poles.SetValue(32,45,gp_Pnt(22.8398,103.734,-2.83232)); - Poles.SetValue(32,46,gp_Pnt(22.9682,126.889,-1.24771)); - Poles.SetValue(32,47,gp_Pnt(23.0442,142.308,-0.479822)); - Poles.SetValue(32,48,gp_Pnt(23.072,150.003,-0.00023355)); - Poles.SetValue(33,1,gp_Pnt(25.96,-150.004,-0.00107395)); - Poles.SetValue(33,2,gp_Pnt(25.9383,-142.271,-0.323802)); - Poles.SetValue(33,3,gp_Pnt(25.883,-126.787,-0.940847)); - Poles.SetValue(33,4,gp_Pnt(25.7581,-103.481,-1.84472)); - Poles.SetValue(33,5,gp_Pnt(25.7408,-84.3172,-2.76066)); - Poles.SetValue(33,6,gp_Pnt(25.52,-70.5894,-3.62915)); - Poles.SetValue(33,7,gp_Pnt(25.366,-62.7115,-4.17081)); - Poles.SetValue(33,8,gp_Pnt(25.3057,-56.9037,-4.30025)); - Poles.SetValue(33,9,gp_Pnt(25.4874,-51.5283,-6.03263)); - Poles.SetValue(33,10,gp_Pnt(25.6972,-47.1048,-7.91375)); - Poles.SetValue(33,11,gp_Pnt(25.8911,-43.5608,-9.71674)); - Poles.SetValue(33,12,gp_Pnt(26.0083,-40.8113,-10.9474)); - Poles.SetValue(33,13,gp_Pnt(26.1812,-38.1233,-12.3183)); - Poles.SetValue(33,14,gp_Pnt(26.4261,-35.4747,-13.7471)); - Poles.SetValue(33,15,gp_Pnt(26.7228,-33.3637,-15.1404)); - Poles.SetValue(33,16,gp_Pnt(26.9425,-31.5869,-16.0448)); - Poles.SetValue(33,17,gp_Pnt(27.2466,-28.8898,-17.3418)); - Poles.SetValue(33,18,gp_Pnt(27.4392,-25.4377,-18.079)); - Poles.SetValue(33,19,gp_Pnt(27.5703,-21.4197,-18.3425)); - Poles.SetValue(33,20,gp_Pnt(27.6524,-17.3331,-18.2754)); - Poles.SetValue(33,21,gp_Pnt(27.691,-13.2136,-18.2387)); - Poles.SetValue(33,22,gp_Pnt(27.7352,-9.09145,-18.3076)); - Poles.SetValue(33,23,gp_Pnt(27.7708,-5.99784,-18.3543)); - Poles.SetValue(33,24,gp_Pnt(27.7901,-1.8693,-18.4133)); - Poles.SetValue(33,25,gp_Pnt(27.7867,2.25931,-18.461)); - Poles.SetValue(33,26,gp_Pnt(27.7597,6.37821,-18.527)); - Poles.SetValue(33,27,gp_Pnt(27.7183,9.46104,-18.5728)); - Poles.SetValue(33,28,gp_Pnt(27.6728,13.5629,-18.5809)); - Poles.SetValue(33,29,gp_Pnt(27.6341,17.6553,-18.7896)); - Poles.SetValue(33,30,gp_Pnt(27.5313,21.69,-18.856)); - Poles.SetValue(33,31,gp_Pnt(27.4221,25.7022,-18.6912)); - Poles.SetValue(33,32,gp_Pnt(27.1858,29.0914,-17.9663)); - Poles.SetValue(33,33,gp_Pnt(26.8754,31.7892,-16.6502)); - Poles.SetValue(33,34,gp_Pnt(26.6629,33.5795,-15.8008)); - Poles.SetValue(33,35,gp_Pnt(26.392,35.7345,-14.5141)); - Poles.SetValue(33,36,gp_Pnt(26.1302,38.3859,-13.1359)); - Poles.SetValue(33,37,gp_Pnt(25.9577,41.0989,-11.8672)); - Poles.SetValue(33,38,gp_Pnt(25.8174,43.84,-10.6733)); - Poles.SetValue(33,39,gp_Pnt(25.6131,47.4059,-8.97942)); - Poles.SetValue(33,40,gp_Pnt(25.4162,51.8971,-7.31061)); - Poles.SetValue(33,41,gp_Pnt(25.2618,57.3518,-5.8554)); - Poles.SetValue(33,42,gp_Pnt(25.3309,63.1621,-5.70901)); - Poles.SetValue(33,43,gp_Pnt(25.4737,70.9955,-5.07709)); - Poles.SetValue(33,44,gp_Pnt(25.6714,84.6291,-4.0924)); - Poles.SetValue(33,45,gp_Pnt(25.7247,103.742,-2.75106)); - Poles.SetValue(33,46,gp_Pnt(25.8505,126.888,-1.25015)); - Poles.SetValue(33,47,gp_Pnt(25.9279,142.307,-0.4543)); - Poles.SetValue(33,48,gp_Pnt(25.9567,150.003,1.78031e-006)); - Poles.SetValue(34,1,gp_Pnt(28.8443,-150.003,-0.000814414)); - Poles.SetValue(34,2,gp_Pnt(28.822,-142.272,-0.314965)); - Poles.SetValue(34,3,gp_Pnt(28.7639,-126.784,-0.915393)); - Poles.SetValue(34,4,gp_Pnt(28.6408,-103.496,-1.77607)); - Poles.SetValue(34,5,gp_Pnt(28.6108,-84.3033,-2.7051)); - Poles.SetValue(34,6,gp_Pnt(28.4002,-70.6057,-3.51828)); - Poles.SetValue(34,7,gp_Pnt(28.2459,-62.7375,-4.07858)); - Poles.SetValue(34,8,gp_Pnt(28.1744,-56.9104,-4.20906)); - Poles.SetValue(34,9,gp_Pnt(28.3177,-51.4347,-5.41731)); - Poles.SetValue(34,10,gp_Pnt(28.5405,-47,-7.20566)); - Poles.SetValue(34,11,gp_Pnt(28.7156,-43.4043,-8.86385)); - Poles.SetValue(34,12,gp_Pnt(28.8516,-40.6751,-10.1127)); - Poles.SetValue(34,13,gp_Pnt(28.9811,-37.9111,-11.2996)); - Poles.SetValue(34,14,gp_Pnt(29.1942,-35.2049,-12.5938)); - Poles.SetValue(34,15,gp_Pnt(29.4218,-32.9982,-13.7949)); - Poles.SetValue(34,16,gp_Pnt(29.6546,-31.2373,-14.7599)); - Poles.SetValue(34,17,gp_Pnt(30.0209,-28.5986,-16.2161)); - Poles.SetValue(34,18,gp_Pnt(30.3511,-25.2896,-17.4304)); - Poles.SetValue(34,19,gp_Pnt(30.5644,-21.3363,-18.1086)); - Poles.SetValue(34,20,gp_Pnt(30.6971,-17.2907,-18.3429)); - Poles.SetValue(34,21,gp_Pnt(30.7624,-13.191,-18.3042)); - Poles.SetValue(34,22,gp_Pnt(30.7888,-9.07614,-18.2619)); - Poles.SetValue(34,23,gp_Pnt(30.7984,-5.98767,-18.2612)); - Poles.SetValue(34,24,gp_Pnt(30.8028,-1.86922,-18.3218)); - Poles.SetValue(34,25,gp_Pnt(30.8038,2.24578,-18.378)); - Poles.SetValue(34,26,gp_Pnt(30.7952,6.35643,-18.4258)); - Poles.SetValue(34,27,gp_Pnt(30.783,9.43271,-18.5099)); - Poles.SetValue(34,28,gp_Pnt(30.7508,13.5293,-18.5862)); - Poles.SetValue(34,29,gp_Pnt(30.6756,17.5933,-18.7948)); - Poles.SetValue(34,30,gp_Pnt(30.5377,21.6111,-18.5821)); - Poles.SetValue(34,31,gp_Pnt(30.3253,25.5499,-17.9497)); - Poles.SetValue(34,32,gp_Pnt(29.9809,28.8453,-16.7757)); - Poles.SetValue(34,33,gp_Pnt(29.6116,31.4959,-15.4039)); - Poles.SetValue(34,34,gp_Pnt(29.3795,33.2673,-14.4675)); - Poles.SetValue(34,35,gp_Pnt(29.1738,35.5112,-13.3894)); - Poles.SetValue(34,36,gp_Pnt(28.9461,38.2178,-12.1512)); - Poles.SetValue(34,37,gp_Pnt(28.8226,41.0067,-11.0898)); - Poles.SetValue(34,38,gp_Pnt(28.6485,43.7085,-9.8326)); - Poles.SetValue(34,39,gp_Pnt(28.4613,47.3204,-8.29397)); - Poles.SetValue(34,40,gp_Pnt(28.2597,51.8236,-6.71601)); - Poles.SetValue(34,41,gp_Pnt(28.1363,57.35,-5.69854)); - Poles.SetValue(34,42,gp_Pnt(28.2228,63.1847,-5.58611)); - Poles.SetValue(34,43,gp_Pnt(28.3583,70.9987,-4.92408)); - Poles.SetValue(34,44,gp_Pnt(28.5449,84.6147,-4.02298)); - Poles.SetValue(34,45,gp_Pnt(28.6102,103.75,-2.67549)); - Poles.SetValue(34,46,gp_Pnt(28.733,126.887,-1.24976)); - Poles.SetValue(34,47,gp_Pnt(28.8119,142.306,-0.431209)); - Poles.SetValue(34,48,gp_Pnt(28.8411,150.003,0.000394087)); - Poles.SetValue(35,1,gp_Pnt(31.7287,-150.003,-0.00159563)); - Poles.SetValue(35,2,gp_Pnt(31.7054,-142.271,-0.292958)); - Poles.SetValue(35,3,gp_Pnt(31.6455,-126.784,-0.897779)); - Poles.SetValue(35,4,gp_Pnt(31.5244,-103.509,-1.70454)); - Poles.SetValue(35,5,gp_Pnt(31.4818,-84.2933,-2.66393)); - Poles.SetValue(35,6,gp_Pnt(31.2818,-70.6177,-3.40872)); - Poles.SetValue(35,7,gp_Pnt(31.1379,-62.7777,-3.96987)); - Poles.SetValue(35,8,gp_Pnt(31.0487,-56.922,-4.10969)); - Poles.SetValue(35,9,gp_Pnt(31.1572,-51.3677,-4.89488)); - Poles.SetValue(35,10,gp_Pnt(31.3712,-46.8953,-6.51595)); - Poles.SetValue(35,11,gp_Pnt(31.5139,-43.2378,-7.96936)); - Poles.SetValue(35,12,gp_Pnt(31.6758,-40.5316,-9.22108)); - Poles.SetValue(35,13,gp_Pnt(31.8199,-37.7807,-10.3811)); - Poles.SetValue(35,14,gp_Pnt(31.9893,-35.0147,-11.5145)); - Poles.SetValue(35,15,gp_Pnt(32.1247,-32.7053,-12.464)); - Poles.SetValue(35,16,gp_Pnt(32.3218,-30.8986,-13.34)); - Poles.SetValue(35,17,gp_Pnt(32.6432,-28.2165,-14.6979)); - Poles.SetValue(35,18,gp_Pnt(33.097,-25.0373,-16.1855)); - Poles.SetValue(35,19,gp_Pnt(33.4343,-21.1834,-17.345)); - Poles.SetValue(35,20,gp_Pnt(33.6567,-17.2197,-18.0405)); - Poles.SetValue(35,21,gp_Pnt(33.7429,-13.1456,-18.2543)); - Poles.SetValue(35,22,gp_Pnt(33.7947,-9.05496,-18.3306)); - Poles.SetValue(35,23,gp_Pnt(33.814,-5.97761,-18.3713)); - Poles.SetValue(35,24,gp_Pnt(33.8326,-1.87322,-18.3889)); - Poles.SetValue(35,25,gp_Pnt(33.8307,2.23248,-18.5068)); - Poles.SetValue(35,26,gp_Pnt(33.8103,6.3285,-18.5284)); - Poles.SetValue(35,27,gp_Pnt(33.7859,9.39575,-18.5442)); - Poles.SetValue(35,28,gp_Pnt(33.7311,13.4669,-18.5787)); - Poles.SetValue(35,29,gp_Pnt(33.6309,17.5149,-18.4035)); - Poles.SetValue(35,30,gp_Pnt(33.3631,21.4402,-17.6914)); - Poles.SetValue(35,31,gp_Pnt(33.0314,25.2897,-16.6389)); - Poles.SetValue(35,32,gp_Pnt(32.5814,28.4766,-15.2398)); - Poles.SetValue(35,33,gp_Pnt(32.2879,31.1937,-13.9832)); - Poles.SetValue(35,34,gp_Pnt(32.101,33.016,-13.1896)); - Poles.SetValue(35,35,gp_Pnt(31.9711,35.3393,-12.3157)); - Poles.SetValue(35,36,gp_Pnt(31.762,38.0751,-11.166)); - Poles.SetValue(35,37,gp_Pnt(31.6205,40.8468,-10.1215)); - Poles.SetValue(35,38,gp_Pnt(31.4569,43.5672,-8.96315)); - Poles.SetValue(35,39,gp_Pnt(31.304,47.2348,-7.63002)); - Poles.SetValue(35,40,gp_Pnt(31.1056,51.7662,-6.18385)); - Poles.SetValue(35,41,gp_Pnt(31.032,57.3778,-5.59198)); - Poles.SetValue(35,42,gp_Pnt(31.1183,63.208,-5.41945)); - Poles.SetValue(35,43,gp_Pnt(31.2462,71.0036,-4.78942)); - Poles.SetValue(35,44,gp_Pnt(31.4185,84.5987,-3.92699)); - Poles.SetValue(35,45,gp_Pnt(31.4967,103.758,-2.61174)); - Poles.SetValue(35,46,gp_Pnt(31.6157,126.886,-1.24044)); - Poles.SetValue(35,47,gp_Pnt(31.6958,142.305,-0.417113)); - Poles.SetValue(35,48,gp_Pnt(31.7255,150.002,0.00194988)); - Poles.SetValue(36,1,gp_Pnt(34.613,-150.003,-8.84142e-006)); - Poles.SetValue(36,2,gp_Pnt(34.5892,-142.271,-0.281898)); - Poles.SetValue(36,3,gp_Pnt(34.5259,-126.782,-0.842126)); - Poles.SetValue(36,4,gp_Pnt(34.4114,-103.526,-1.69502)); - Poles.SetValue(36,5,gp_Pnt(34.3501,-84.279,-2.54815)); - Poles.SetValue(36,6,gp_Pnt(34.1678,-70.6326,-3.32282)); - Poles.SetValue(36,7,gp_Pnt(34.0367,-62.8161,-3.82536)); - Poles.SetValue(36,8,gp_Pnt(33.9563,-56.9857,-4.13682)); - Poles.SetValue(36,9,gp_Pnt(34.0087,-51.3335,-4.46806)); - Poles.SetValue(36,10,gp_Pnt(34.1924,-46.7917,-5.85857)); - Poles.SetValue(36,11,gp_Pnt(34.3026,-43.0822,-7.10693)); - Poles.SetValue(36,12,gp_Pnt(34.4437,-40.3441,-8.2133)); - Poles.SetValue(36,13,gp_Pnt(34.6249,-37.6272,-9.39894)); - Poles.SetValue(36,14,gp_Pnt(34.7778,-34.844,-10.4473)); - Poles.SetValue(36,15,gp_Pnt(34.8915,-32.5077,-11.3048)); - Poles.SetValue(36,16,gp_Pnt(35.0303,-30.6596,-12.0421)); - Poles.SetValue(36,17,gp_Pnt(35.2632,-27.9023,-13.1946)); - Poles.SetValue(36,18,gp_Pnt(35.6871,-24.7181,-14.6532)); - Poles.SetValue(36,19,gp_Pnt(36.0775,-20.9311,-15.9594)); - Poles.SetValue(36,20,gp_Pnt(36.3883,-17.0442,-16.9645)); - Poles.SetValue(36,21,gp_Pnt(36.6346,-13.0717,-17.6564)); - Poles.SetValue(36,22,gp_Pnt(36.703,-9.00817,-17.8864)); - Poles.SetValue(36,23,gp_Pnt(36.753,-5.9561,-18.0651)); - Poles.SetValue(36,24,gp_Pnt(36.7617,-1.86876,-18.1671)); - Poles.SetValue(36,25,gp_Pnt(36.7651,2.21985,-18.2173)); - Poles.SetValue(36,26,gp_Pnt(36.7472,6.29944,-18.1998)); - Poles.SetValue(36,27,gp_Pnt(36.7037,9.34658,-18.1186)); - Poles.SetValue(36,28,gp_Pnt(36.6083,13.3906,-17.8978)); - Poles.SetValue(36,29,gp_Pnt(36.3678,17.3552,-17.2999)); - Poles.SetValue(36,30,gp_Pnt(36.0217,21.2169,-16.3136)); - Poles.SetValue(36,31,gp_Pnt(35.6137,24.997,-15.0642)); - Poles.SetValue(36,32,gp_Pnt(35.226,28.2063,-13.7406)); - Poles.SetValue(36,33,gp_Pnt(34.9984,30.9793,-12.6852)); - Poles.SetValue(36,34,gp_Pnt(34.8482,32.8226,-11.9616)); - Poles.SetValue(36,35,gp_Pnt(34.7496,35.1802,-11.2179)); - Poles.SetValue(36,36,gp_Pnt(34.5774,37.9518,-10.2031)); - Poles.SetValue(36,37,gp_Pnt(34.4083,40.6991,-9.15684)); - Poles.SetValue(36,38,gp_Pnt(34.2536,43.4345,-8.10986)); - Poles.SetValue(36,39,gp_Pnt(34.1265,47.141,-6.95245)); - Poles.SetValue(36,40,gp_Pnt(33.9694,51.7379,-5.79187)); - Poles.SetValue(36,41,gp_Pnt(33.9407,57.4177,-5.51793)); - Poles.SetValue(36,42,gp_Pnt(34.0186,63.2307,-5.20171)); - Poles.SetValue(36,43,gp_Pnt(34.1362,71.0089,-4.67244)); - Poles.SetValue(36,44,gp_Pnt(34.2957,84.5851,-3.80167)); - Poles.SetValue(36,45,gp_Pnt(34.383,103.766,-2.5642)); - Poles.SetValue(36,46,gp_Pnt(34.4993,126.886,-1.22044)); - Poles.SetValue(36,47,gp_Pnt(34.5794,142.304,-0.409319)); - Poles.SetValue(36,48,gp_Pnt(34.61,150.002,0.00244459)); - Poles.SetValue(37,1,gp_Pnt(37.4972,-150.002,0.000555526)); - Poles.SetValue(37,2,gp_Pnt(37.4728,-142.27,-0.265447)); - Poles.SetValue(37,3,gp_Pnt(37.4079,-126.783,-0.802161)); - Poles.SetValue(37,4,gp_Pnt(37.2967,-103.539,-1.66555)); - Poles.SetValue(37,5,gp_Pnt(37.2229,-84.2708,-2.46547)); - Poles.SetValue(37,6,gp_Pnt(37.0545,-70.6462,-3.22563)); - Poles.SetValue(37,7,gp_Pnt(36.9382,-62.8514,-3.69803)); - Poles.SetValue(37,8,gp_Pnt(36.8695,-57.0355,-4.05169)); - Poles.SetValue(37,9,gp_Pnt(36.8664,-51.3068,-4.20071)); - Poles.SetValue(37,10,gp_Pnt(36.9963,-46.6801,-5.21492)); - Poles.SetValue(37,11,gp_Pnt(37.1028,-42.9622,-6.32347)); - Poles.SetValue(37,12,gp_Pnt(37.2217,-40.1924,-7.25707)); - Poles.SetValue(37,13,gp_Pnt(37.3806,-37.45,-8.32532)); - Poles.SetValue(37,14,gp_Pnt(37.5666,-34.6987,-9.40192)); - Poles.SetValue(37,15,gp_Pnt(37.6875,-32.3677,-10.2225)); - Poles.SetValue(37,16,gp_Pnt(37.7796,-30.4815,-10.8337)); - Poles.SetValue(37,17,gp_Pnt(37.8949,-27.6361,-11.7039)); - Poles.SetValue(37,18,gp_Pnt(38.1939,-24.3881,-12.9412)); - Poles.SetValue(37,19,gp_Pnt(38.5477,-20.6236,-14.2289)); - Poles.SetValue(37,20,gp_Pnt(38.9367,-16.8248,-15.4489)); - Poles.SetValue(37,21,gp_Pnt(39.2113,-12.9073,-16.3298)); - Poles.SetValue(37,22,gp_Pnt(39.4234,-8.92763,-16.959)); - Poles.SetValue(37,23,gp_Pnt(39.4867,-5.90171,-17.2202)); - Poles.SetValue(37,24,gp_Pnt(39.5456,-1.85585,-17.4489)); - Poles.SetValue(37,25,gp_Pnt(39.5315,2.20624,-17.47)); - Poles.SetValue(37,26,gp_Pnt(39.4789,6.249,-17.3411)); - Poles.SetValue(37,27,gp_Pnt(39.3801,9.26259,-17.0826)); - Poles.SetValue(37,28,gp_Pnt(39.1782,13.2421,-16.5416)); - Poles.SetValue(37,29,gp_Pnt(38.9025,17.148,-15.7336)); - Poles.SetValue(37,30,gp_Pnt(38.4895,20.9378,-14.5637)); - Poles.SetValue(37,31,gp_Pnt(38.1479,24.7114,-13.3818)); - Poles.SetValue(37,32,gp_Pnt(37.8908,27.991,-12.3161)); - Poles.SetValue(37,33,gp_Pnt(37.7444,30.8157,-11.4556)); - Poles.SetValue(37,34,gp_Pnt(37.6502,32.7032,-10.8985)); - Poles.SetValue(37,35,gp_Pnt(37.5088,35.0224,-10.1)); - Poles.SetValue(37,36,gp_Pnt(37.3138,37.7726,-9.07484)); - Poles.SetValue(37,37,gp_Pnt(37.1382,40.5101,-8.05559)); - Poles.SetValue(37,38,gp_Pnt(37.054,43.3215,-7.31185)); - Poles.SetValue(37,39,gp_Pnt(36.9421,47.0468,-6.33184)); - Poles.SetValue(37,40,gp_Pnt(36.8379,51.7166,-5.49796)); - Poles.SetValue(37,41,gp_Pnt(36.8607,57.4567,-5.443)); - Poles.SetValue(37,42,gp_Pnt(36.9222,63.2529,-5.029)); - Poles.SetValue(37,43,gp_Pnt(37.0259,71.0129,-4.53609)); - Poles.SetValue(37,44,gp_Pnt(37.1745,84.5734,-3.68955)); - Poles.SetValue(37,45,gp_Pnt(37.2692,103.772,-2.50735)); - Poles.SetValue(37,46,gp_Pnt(37.3831,126.887,-1.20321)); - Poles.SetValue(37,47,gp_Pnt(37.4633,142.303,-0.401612)); - Poles.SetValue(37,48,gp_Pnt(37.4942,150.002,0.00165959)); - Poles.SetValue(38,1,gp_Pnt(41.3427,-150.002,0.000910129)); - Poles.SetValue(38,2,gp_Pnt(41.3172,-142.269,-0.250994)); - Poles.SetValue(38,3,gp_Pnt(41.252,-126.785,-0.743205)); - Poles.SetValue(38,4,gp_Pnt(41.1432,-103.556,-1.64006)); - Poles.SetValue(38,5,gp_Pnt(41.0572,-84.2638,-2.33977)); - Poles.SetValue(38,6,gp_Pnt(40.9025,-70.662,-3.09061)); - Poles.SetValue(38,7,gp_Pnt(40.8094,-62.8944,-3.52967)); - Poles.SetValue(38,8,gp_Pnt(40.7531,-57.091,-3.91119)); - Poles.SetValue(38,9,gp_Pnt(40.7096,-51.3094,-4.15327)); - Poles.SetValue(38,10,gp_Pnt(40.7225,-46.5336,-4.39732)); - Poles.SetValue(38,11,gp_Pnt(40.8349,-42.8149,-5.35507)); - Poles.SetValue(38,12,gp_Pnt(40.9198,-40.01,-6.07186)); - Poles.SetValue(38,13,gp_Pnt(41.039,-37.2275,-6.89946)); - Poles.SetValue(38,14,gp_Pnt(41.1807,-34.446,-7.76251)); - Poles.SetValue(38,15,gp_Pnt(41.3421,-32.1529,-8.6033)); - Poles.SetValue(38,16,gp_Pnt(41.4528,-30.2866,-9.22754)); - Poles.SetValue(38,17,gp_Pnt(41.6048,-27.4727,-10.1338)); - Poles.SetValue(38,18,gp_Pnt(41.7346,-24.1213,-11.015)); - Poles.SetValue(38,19,gp_Pnt(41.93,-20.3071,-12.0361)); - Poles.SetValue(38,20,gp_Pnt(42.1256,-16.4709,-12.9787)); - Poles.SetValue(38,21,gp_Pnt(42.3664,-12.6243,-13.8833)); - Poles.SetValue(38,22,gp_Pnt(42.5253,-8.71352,-14.5112)); - Poles.SetValue(38,23,gp_Pnt(42.6203,-5.76323,-14.8691)); - Poles.SetValue(38,24,gp_Pnt(42.6798,-1.79912,-15.1424)); - Poles.SetValue(38,25,gp_Pnt(42.6737,2.17503,-15.1747)); - Poles.SetValue(38,26,gp_Pnt(42.5953,6.13666,-14.9438)); - Poles.SetValue(38,27,gp_Pnt(42.5039,9.08523,-14.6485)); - Poles.SetValue(38,28,gp_Pnt(42.3376,12.9911,-14.0849)); - Poles.SetValue(38,29,gp_Pnt(42.1163,16.8397,-13.292)); - Poles.SetValue(38,30,gp_Pnt(41.8966,20.6667,-12.3969)); - Poles.SetValue(38,31,gp_Pnt(41.7151,24.4907,-11.5063)); - Poles.SetValue(38,32,gp_Pnt(41.5833,27.8377,-10.6892)); - Poles.SetValue(38,33,gp_Pnt(41.412,30.6412,-9.8422)); - Poles.SetValue(38,34,gp_Pnt(41.2857,32.4975,-9.24392)); - Poles.SetValue(38,35,gp_Pnt(41.1281,34.7988,-8.48532)); - Poles.SetValue(38,36,gp_Pnt(40.9982,37.5923,-7.7491)); - Poles.SetValue(38,37,gp_Pnt(40.9022,40.4018,-7.05478)); - Poles.SetValue(38,38,gp_Pnt(40.8045,43.2027,-6.38438)); - Poles.SetValue(38,39,gp_Pnt(40.6947,46.9351,-5.51775)); - Poles.SetValue(38,40,gp_Pnt(40.6936,51.7133,-5.40542)); - Poles.SetValue(38,41,gp_Pnt(40.7465,57.4932,-5.2213)); - Poles.SetValue(38,42,gp_Pnt(40.7949,63.2798,-4.80832)); - Poles.SetValue(38,43,gp_Pnt(40.8787,71.0181,-4.35466)); - Poles.SetValue(38,44,gp_Pnt(41.0184,84.563,-3.55086)); - Poles.SetValue(38,45,gp_Pnt(41.1158,103.778,-2.42645)); - Poles.SetValue(38,46,gp_Pnt(41.2295,126.889,-1.17679)); - Poles.SetValue(38,47,gp_Pnt(41.308,142.302,-0.393553)); - Poles.SetValue(38,48,gp_Pnt(41.3397,150.001,-0.000267641)); - Poles.SetValue(39,1,gp_Pnt(46.1496,-150.001,0.00111063)); - Poles.SetValue(39,2,gp_Pnt(46.1222,-142.268,-0.24987)); - Poles.SetValue(39,3,gp_Pnt(46.0591,-126.79,-0.697635)); - Poles.SetValue(39,4,gp_Pnt(45.9503,-103.571,-1.56599)); - Poles.SetValue(39,5,gp_Pnt(45.856,-84.2638,-2.23446)); - Poles.SetValue(39,6,gp_Pnt(45.7158,-70.683,-2.88403)); - Poles.SetValue(39,7,gp_Pnt(45.6442,-62.9379,-3.34584)); - Poles.SetValue(39,8,gp_Pnt(45.5919,-57.1341,-3.69072)); - Poles.SetValue(39,9,gp_Pnt(45.5333,-51.33,-4.08565)); - Poles.SetValue(39,10,gp_Pnt(45.4961,-46.5017,-4.13549)); - Poles.SetValue(39,11,gp_Pnt(45.5149,-42.6839,-4.33983)); - Poles.SetValue(39,12,gp_Pnt(45.5827,-39.8663,-4.80837)); - Poles.SetValue(39,13,gp_Pnt(45.6781,-37.0642,-5.3692)); - Poles.SetValue(39,14,gp_Pnt(45.8102,-34.2784,-6.16223)); - Poles.SetValue(39,15,gp_Pnt(45.8709,-31.9134,-6.65192)); - Poles.SetValue(39,16,gp_Pnt(45.9562,-30.039,-7.1593)); - Poles.SetValue(39,17,gp_Pnt(46.0717,-27.2191,-7.89044)); - Poles.SetValue(39,18,gp_Pnt(46.2519,-23.9199,-8.84437)); - Poles.SetValue(39,19,gp_Pnt(46.4143,-20.1034,-9.76693)); - Poles.SetValue(39,20,gp_Pnt(46.5429,-16.2588,-10.5643)); - Poles.SetValue(39,21,gp_Pnt(46.6217,-12.3944,-11.1733)); - Poles.SetValue(39,22,gp_Pnt(46.681,-8.52657,-11.622)); - Poles.SetValue(39,23,gp_Pnt(46.7153,-5.61927,-11.8682)); - Poles.SetValue(39,24,gp_Pnt(46.7497,-1.73975,-12.0911)); - Poles.SetValue(39,25,gp_Pnt(46.7278,2.15162,-12.0955)); - Poles.SetValue(39,26,gp_Pnt(46.7066,6.03283,-11.9712)); - Poles.SetValue(39,27,gp_Pnt(46.6796,8.93942,-11.7865)); - Poles.SetValue(39,28,gp_Pnt(46.6257,12.8059,-11.425)); - Poles.SetValue(39,29,gp_Pnt(46.5243,16.6605,-10.8643)); - Poles.SetValue(39,30,gp_Pnt(46.3615,20.4856,-10.0971)); - Poles.SetValue(39,31,gp_Pnt(46.2089,24.304,-9.28958)); - Poles.SetValue(39,32,gp_Pnt(46.0224,27.5938,-8.42989)); - Poles.SetValue(39,33,gp_Pnt(45.9077,30.415,-7.785)); - Poles.SetValue(39,34,gp_Pnt(45.8414,32.3032,-7.38582)); - Poles.SetValue(39,35,gp_Pnt(45.7555,34.647,-6.87832)); - Poles.SetValue(39,36,gp_Pnt(45.6756,37.4791,-6.33131)); - Poles.SetValue(39,37,gp_Pnt(45.5588,40.2637,-5.71115)); - Poles.SetValue(39,38,gp_Pnt(45.4983,43.0898,-5.31195)); - Poles.SetValue(39,39,gp_Pnt(45.4876,46.9076,-5.26074)); - Poles.SetValue(39,40,gp_Pnt(45.5315,51.7279,-5.25925)); - Poles.SetValue(39,41,gp_Pnt(45.5802,57.5155,-4.81316)); - Poles.SetValue(39,42,gp_Pnt(45.6332,63.3069,-4.55574)); - Poles.SetValue(39,43,gp_Pnt(45.6962,71.0259,-4.09811)); - Poles.SetValue(39,44,gp_Pnt(45.8254,84.5537,-3.37827)); - Poles.SetValue(39,45,gp_Pnt(45.9243,103.783,-2.3236)); - Poles.SetValue(39,46,gp_Pnt(46.0379,126.89,-1.12458)); - Poles.SetValue(39,47,gp_Pnt(46.1137,142.301,-0.395727)); - Poles.SetValue(39,48,gp_Pnt(46.1465,150.001,0.000996613)); - Poles.SetValue(40,1,gp_Pnt(51.9175,-150,-0.000207971)); - Poles.SetValue(40,2,gp_Pnt(51.8891,-142.268,-0.241315)); - Poles.SetValue(40,3,gp_Pnt(51.8282,-126.796,-0.673804)); - Poles.SetValue(40,4,gp_Pnt(51.7199,-103.588,-1.45857)); - Poles.SetValue(40,5,gp_Pnt(51.6194,-84.2705,-2.10744)); - Poles.SetValue(40,6,gp_Pnt(51.5011,-70.7153,-2.68959)); - Poles.SetValue(40,7,gp_Pnt(51.438,-62.979,-3.06884)); - Poles.SetValue(40,8,gp_Pnt(51.3917,-57.1815,-3.4528)); - Poles.SetValue(40,9,gp_Pnt(51.333,-51.3737,-3.73088)); - Poles.SetValue(40,10,gp_Pnt(51.2926,-46.5422,-4.00316)); - Poles.SetValue(40,11,gp_Pnt(51.2652,-42.6804,-4.15327)); - Poles.SetValue(40,12,gp_Pnt(51.2481,-39.786,-4.14827)); - Poles.SetValue(40,13,gp_Pnt(51.2355,-36.9009,-4.17909)); - Poles.SetValue(40,14,gp_Pnt(51.269,-34.0518,-4.48805)); - Poles.SetValue(40,15,gp_Pnt(51.2999,-31.6825,-4.8317)); - Poles.SetValue(40,16,gp_Pnt(51.3423,-29.7917,-5.18954)); - Poles.SetValue(40,17,gp_Pnt(51.4157,-26.9599,-5.75758)); - Poles.SetValue(40,18,gp_Pnt(51.4915,-23.638,-6.34409)); - Poles.SetValue(40,19,gp_Pnt(51.6134,-19.8436,-7.01661)); - Poles.SetValue(40,20,gp_Pnt(51.7563,-16.0473,-7.67254)); - Poles.SetValue(40,21,gp_Pnt(51.9147,-12.2466,-8.28467)); - Poles.SetValue(40,22,gp_Pnt(52.0172,-8.41953,-8.69997)); - Poles.SetValue(40,23,gp_Pnt(52.0633,-5.54232,-8.92052)); - Poles.SetValue(40,24,gp_Pnt(52.1076,-1.69853,-9.12971)); - Poles.SetValue(40,25,gp_Pnt(52.1149,2.14658,-9.19114)); - Poles.SetValue(40,26,gp_Pnt(52.0573,5.98803,-9.04481)); - Poles.SetValue(40,27,gp_Pnt(52.0106,8.86368,-8.89058)); - Poles.SetValue(40,28,gp_Pnt(51.8867,12.6814,-8.51757)); - Poles.SetValue(40,29,gp_Pnt(51.7526,16.4859,-8.05187)); - Poles.SetValue(40,30,gp_Pnt(51.6058,20.2741,-7.46264)); - Poles.SetValue(40,31,gp_Pnt(51.4828,24.0629,-6.88014)); - Poles.SetValue(40,32,gp_Pnt(51.4123,27.3832,-6.35298)); - Poles.SetValue(40,33,gp_Pnt(51.3431,30.2167,-5.90237)); - Poles.SetValue(40,34,gp_Pnt(51.2972,32.1041,-5.6001)); - Poles.SetValue(40,35,gp_Pnt(51.2645,34.472,-5.32012)); - Poles.SetValue(40,36,gp_Pnt(51.2449,37.3238,-5.1352)); - Poles.SetValue(40,37,gp_Pnt(51.2601,40.2033,-5.10074)); - Poles.SetValue(40,38,gp_Pnt(51.2747,43.0862,-5.12741)); - Poles.SetValue(40,39,gp_Pnt(51.2989,46.9359,-5.04137)); - Poles.SetValue(40,40,gp_Pnt(51.3275,51.7504,-4.70088)); - Poles.SetValue(40,41,gp_Pnt(51.3841,57.5438,-4.49279)); - Poles.SetValue(40,42,gp_Pnt(51.4284,63.3289,-4.20573)); - Poles.SetValue(40,43,gp_Pnt(51.4853,71.0399,-3.80369)); - Poles.SetValue(40,44,gp_Pnt(51.5952,84.5486,-3.19745)); - Poles.SetValue(40,45,gp_Pnt(51.696,103.788,-2.1844)); - Poles.SetValue(40,46,gp_Pnt(51.8075,126.892,-1.07015)); - Poles.SetValue(40,47,gp_Pnt(51.8814,142.3,-0.382549)); - Poles.SetValue(40,48,gp_Pnt(51.9141,150,0.00156463)); - Poles.SetValue(41,1,gp_Pnt(57.6856,-150,-0.00138605)); - Poles.SetValue(41,2,gp_Pnt(57.6563,-142.267,-0.207898)); - Poles.SetValue(41,3,gp_Pnt(57.5975,-126.803,-0.672181)); - Poles.SetValue(41,4,gp_Pnt(57.4914,-103.604,-1.36423)); - Poles.SetValue(41,5,gp_Pnt(57.3865,-84.2807,-1.92972)); - Poles.SetValue(41,6,gp_Pnt(57.2896,-70.7489,-2.50829)); - Poles.SetValue(41,7,gp_Pnt(57.2325,-63.0194,-2.86727)); - Poles.SetValue(41,8,gp_Pnt(57.1871,-57.2225,-3.14507)); - Poles.SetValue(41,9,gp_Pnt(57.1423,-51.4292,-3.42927)); - Poles.SetValue(41,10,gp_Pnt(57.1017,-46.5994,-3.67864)); - Poles.SetValue(41,11,gp_Pnt(57.0621,-42.7292,-3.85432)); - Poles.SetValue(41,12,gp_Pnt(57.03,-39.8239,-4.01388)); - Poles.SetValue(41,13,gp_Pnt(56.9862,-36.9115,-4.15465)); - Poles.SetValue(41,14,gp_Pnt(56.9332,-33.9994,-4.17982)); - Poles.SetValue(41,15,gp_Pnt(56.8867,-31.5805,-4.17145)); - Poles.SetValue(41,16,gp_Pnt(56.8715,-29.6623,-4.20861)); - Poles.SetValue(41,17,gp_Pnt(56.8491,-26.7863,-4.25366)); - Poles.SetValue(41,18,gp_Pnt(56.889,-23.4691,-4.52661)); - Poles.SetValue(41,19,gp_Pnt(56.9549,-19.6804,-4.85027)); - Poles.SetValue(41,20,gp_Pnt(57.0475,-15.8997,-5.24921)); - Poles.SetValue(41,21,gp_Pnt(57.1486,-12.1132,-5.61949)); - Poles.SetValue(41,22,gp_Pnt(57.2089,-8.31776,-5.89532)); - Poles.SetValue(41,23,gp_Pnt(57.2368,-5.4661,-6.04286)); - Poles.SetValue(41,24,gp_Pnt(57.2712,-1.66308,-6.20009)); - Poles.SetValue(41,25,gp_Pnt(57.2835,2.13802,-6.25618)); - Poles.SetValue(41,26,gp_Pnt(57.2397,5.93802,-6.16615)); - Poles.SetValue(41,27,gp_Pnt(57.2064,8.78585,-6.08208)); - Poles.SetValue(41,28,gp_Pnt(57.1543,12.5793,-5.9372)); - Poles.SetValue(41,29,gp_Pnt(57.0517,16.3584,-5.62801)); - Poles.SetValue(41,30,gp_Pnt(56.9666,20.1329,-5.34449)); - Poles.SetValue(41,31,gp_Pnt(56.9077,23.9136,-5.10547)); - Poles.SetValue(41,32,gp_Pnt(56.8624,27.2205,-4.90474)); - Poles.SetValue(41,33,gp_Pnt(56.894,30.0927,-4.90413)); - Poles.SetValue(41,34,gp_Pnt(56.9172,32.0097,-4.91734)); - Poles.SetValue(41,35,gp_Pnt(56.9647,34.4197,-4.99635)); - Poles.SetValue(41,36,gp_Pnt(57.0094,37.3184,-4.96512)); - Poles.SetValue(41,37,gp_Pnt(57.0441,40.2167,-4.87499)); - Poles.SetValue(41,38,gp_Pnt(57.074,43.1143,-4.7391)); - Poles.SetValue(41,39,gp_Pnt(57.107,46.9716,-4.56627)); - Poles.SetValue(41,40,gp_Pnt(57.1445,51.7898,-4.39661)); - Poles.SetValue(41,41,gp_Pnt(57.1814,57.5667,-4.1162)); - Poles.SetValue(41,42,gp_Pnt(57.2214,63.3465,-3.84863)); - Poles.SetValue(41,43,gp_Pnt(57.2769,71.057,-3.56972)); - Poles.SetValue(41,44,gp_Pnt(57.3669,84.5447,-2.9687)); - Poles.SetValue(41,45,gp_Pnt(57.468,103.793,-2.06019)); - Poles.SetValue(41,46,gp_Pnt(57.5787,126.894,-1.02905)); - Poles.SetValue(41,47,gp_Pnt(57.6483,142.299,-0.34422)); - Poles.SetValue(41,48,gp_Pnt(57.682,150,-0.00209716)); - Poles.SetValue(42,1,gp_Pnt(63.4538,-150,0.0025406)); - Poles.SetValue(42,2,gp_Pnt(63.4247,-142.269,-0.215374)); - Poles.SetValue(42,3,gp_Pnt(63.3664,-126.808,-0.616228)); - Poles.SetValue(42,4,gp_Pnt(63.2638,-103.618,-1.25801)); - Poles.SetValue(42,5,gp_Pnt(63.16,-84.297,-1.79523)); - Poles.SetValue(42,6,gp_Pnt(63.0783,-70.7815,-2.3401)); - Poles.SetValue(42,7,gp_Pnt(63.027,-63.0578,-2.63615)); - Poles.SetValue(42,8,gp_Pnt(62.9884,-57.2671,-2.89533)); - Poles.SetValue(42,9,gp_Pnt(62.9474,-51.4766,-3.14791)); - Poles.SetValue(42,10,gp_Pnt(62.9083,-46.6481,-3.34003)); - Poles.SetValue(42,11,gp_Pnt(62.8727,-42.7819,-3.50126)); - Poles.SetValue(42,12,gp_Pnt(62.844,-39.8816,-3.60833)); - Poles.SetValue(42,13,gp_Pnt(62.8104,-36.9784,-3.72009)); - Poles.SetValue(42,14,gp_Pnt(62.778,-34.08,-3.87178)); - Poles.SetValue(42,15,gp_Pnt(62.7431,-31.6622,-3.99896)); - Poles.SetValue(42,16,gp_Pnt(62.716,-29.7336,-4.07291)); - Poles.SetValue(42,17,gp_Pnt(62.6769,-26.8425,-4.18869)); - Poles.SetValue(42,18,gp_Pnt(62.6426,-23.4886,-4.19616)); - Poles.SetValue(42,19,gp_Pnt(62.6334,-19.6721,-4.26579)); - Poles.SetValue(42,20,gp_Pnt(62.6295,-15.8635,-4.27213)); - Poles.SetValue(42,21,gp_Pnt(62.646,-12.069,-4.36676)); - Poles.SetValue(42,22,gp_Pnt(62.6617,-8.28186,-4.45874)); - Poles.SetValue(42,23,gp_Pnt(62.6691,-5.44261,-4.50132)); - Poles.SetValue(42,24,gp_Pnt(62.6758,-1.65987,-4.58196)); - Poles.SetValue(42,25,gp_Pnt(62.6653,2.12054,-4.61217)); - Poles.SetValue(42,26,gp_Pnt(62.6597,5.90097,-4.63357)); - Poles.SetValue(42,27,gp_Pnt(62.6549,8.73683,-4.65964)); - Poles.SetValue(42,28,gp_Pnt(62.6418,12.5178,-4.65205)); - Poles.SetValue(42,29,gp_Pnt(62.6327,16.3026,-4.65055)); - Poles.SetValue(42,30,gp_Pnt(62.6435,20.0986,-4.70703)); - Poles.SetValue(42,31,gp_Pnt(62.662,23.9034,-4.72568)); - Poles.SetValue(42,32,gp_Pnt(62.7054,27.2507,-4.79821)); - Poles.SetValue(42,33,gp_Pnt(62.7415,30.1344,-4.72137)); - Poles.SetValue(42,34,gp_Pnt(62.7653,32.0573,-4.65936)); - Poles.SetValue(42,35,gp_Pnt(62.7973,34.4696,-4.55886)); - Poles.SetValue(42,36,gp_Pnt(62.8292,37.3615,-4.47524)); - Poles.SetValue(42,37,gp_Pnt(62.8611,40.2567,-4.4017)); - Poles.SetValue(42,38,gp_Pnt(62.885,43.1468,-4.31334)); - Poles.SetValue(42,39,gp_Pnt(62.9162,47.0013,-4.18874)); - Poles.SetValue(42,40,gp_Pnt(62.9483,51.8154,-4.00002)); - Poles.SetValue(42,41,gp_Pnt(62.9852,57.5918,-3.80305)); - Poles.SetValue(42,42,gp_Pnt(63.0192,63.3675,-3.57283)); - Poles.SetValue(42,43,gp_Pnt(63.0676,71.0714,-3.31891)); - Poles.SetValue(42,44,gp_Pnt(63.1421,84.547,-2.75086)); - Poles.SetValue(42,45,gp_Pnt(63.2424,103.797,-1.92907)); - Poles.SetValue(42,46,gp_Pnt(63.3482,126.895,-0.959019)); - Poles.SetValue(42,47,gp_Pnt(63.4166,142.297,-0.27787)); - Poles.SetValue(42,48,gp_Pnt(63.4498,150,0.00445876)); - Poles.SetValue(43,1,gp_Pnt(71.145,-150,-0.000857612)); - Poles.SetValue(43,2,gp_Pnt(71.1162,-142.27,-0.152808)); - Poles.SetValue(43,3,gp_Pnt(71.0596,-126.815,-0.587576)); - Poles.SetValue(43,4,gp_Pnt(70.9617,-103.636,-1.09496)); - Poles.SetValue(43,5,gp_Pnt(70.8648,-84.3248,-1.63803)); - Poles.SetValue(43,6,gp_Pnt(70.796,-70.8215,-2.12446)); - Poles.SetValue(43,7,gp_Pnt(70.7543,-63.1072,-2.37388)); - Poles.SetValue(43,8,gp_Pnt(70.7215,-57.3211,-2.55159)); - Poles.SetValue(43,9,gp_Pnt(70.6876,-51.5353,-2.75534)); - Poles.SetValue(43,10,gp_Pnt(70.6596,-46.716,-2.93875)); - Poles.SetValue(43,11,gp_Pnt(70.638,-42.8622,-3.09314)); - Poles.SetValue(43,12,gp_Pnt(70.6204,-39.9716,-3.17812)); - Poles.SetValue(43,13,gp_Pnt(70.6043,-37.0819,-3.28977)); - Poles.SetValue(43,14,gp_Pnt(70.5873,-34.1932,-3.36653)); - Poles.SetValue(43,15,gp_Pnt(70.5748,-31.7872,-3.44513)); - Poles.SetValue(43,16,gp_Pnt(70.5669,-29.8663,-3.51303)); - Poles.SetValue(43,17,gp_Pnt(70.5542,-26.9849,-3.60722)); - Poles.SetValue(43,18,gp_Pnt(70.5428,-23.6313,-3.75743)); - Poles.SetValue(43,19,gp_Pnt(70.5216,-19.7991,-3.8651)); - Poles.SetValue(43,20,gp_Pnt(70.5074,-15.9743,-4.01435)); - Poles.SetValue(43,21,gp_Pnt(70.4895,-12.1568,-4.07719)); - Poles.SetValue(43,22,gp_Pnt(70.4779,-8.34932,-4.14211)); - Poles.SetValue(43,23,gp_Pnt(70.4743,-5.49851,-4.2144)); - Poles.SetValue(43,24,gp_Pnt(70.4711,-1.70019,-4.26983)); - Poles.SetValue(43,25,gp_Pnt(70.4772,2.09575,-4.33461)); - Poles.SetValue(43,26,gp_Pnt(70.4818,5.8932,-4.36337)); - Poles.SetValue(43,27,gp_Pnt(70.4863,8.74296,-4.35931)); - Poles.SetValue(43,28,gp_Pnt(70.4965,12.5464,-4.34509)); - Poles.SetValue(43,29,gp_Pnt(70.5111,16.3559,-4.34157)); - Poles.SetValue(43,30,gp_Pnt(70.5238,20.1732,-4.25483)); - Poles.SetValue(43,31,gp_Pnt(70.5444,23.9982,-4.20505)); - Poles.SetValue(43,32,gp_Pnt(70.5565,27.3468,-4.1081)); - Poles.SetValue(43,33,gp_Pnt(70.5753,30.2247,-4.08653)); - Poles.SetValue(43,34,gp_Pnt(70.5877,32.1436,-4.07523)); - Poles.SetValue(43,35,gp_Pnt(70.6023,34.545,-4.05073)); - Poles.SetValue(43,36,gp_Pnt(70.6195,37.4276,-3.98741)); - Poles.SetValue(43,37,gp_Pnt(70.6334,40.3106,-3.90872)); - Poles.SetValue(43,38,gp_Pnt(70.6494,43.1951,-3.83)); - Poles.SetValue(43,39,gp_Pnt(70.6689,47.0414,-3.71793)); - Poles.SetValue(43,40,gp_Pnt(70.6945,51.851,-3.59864)); - Poles.SetValue(43,41,gp_Pnt(70.7214,57.6214,-3.39071)); - Poles.SetValue(43,42,gp_Pnt(70.7489,63.3924,-3.20505)); - Poles.SetValue(43,43,gp_Pnt(70.7842,71.0857,-2.88826)); - Poles.SetValue(43,44,gp_Pnt(70.8464,84.5547,-2.43588)); - Poles.SetValue(43,45,gp_Pnt(70.9463,103.804,-1.8405)); - Poles.SetValue(43,46,gp_Pnt(71.0396,126.896,-0.842595)); - Poles.SetValue(43,47,gp_Pnt(71.1097,142.298,-0.284851)); - Poles.SetValue(43,48,gp_Pnt(71.1403,150,0.000935964)); - Poles.SetValue(44,1,gp_Pnt(84.6054,-150,-0.00110981)); - Poles.SetValue(44,2,gp_Pnt(84.578,-142.276,-0.19879)); - Poles.SetValue(44,3,gp_Pnt(84.5262,-126.827,-0.428048)); - Poles.SetValue(44,4,gp_Pnt(84.4365,-103.667,-0.830318)); - Poles.SetValue(44,5,gp_Pnt(84.36,-84.3785,-1.33467)); - Poles.SetValue(44,6,gp_Pnt(84.3031,-70.89,-1.70138)); - Poles.SetValue(44,7,gp_Pnt(84.275,-63.1861,-1.89652)); - Poles.SetValue(44,8,gp_Pnt(84.2584,-57.4138,-2.07504)); - Poles.SetValue(44,9,gp_Pnt(84.248,-51.6477,-2.24438)); - Poles.SetValue(44,10,gp_Pnt(84.2459,-46.8473,-2.35057)); - Poles.SetValue(44,11,gp_Pnt(84.2519,-43.0105,-2.40101)); - Poles.SetValue(44,12,gp_Pnt(84.2621,-40.138,-2.47508)); - Poles.SetValue(44,13,gp_Pnt(84.2775,-37.2661,-2.50855)); - Poles.SetValue(44,14,gp_Pnt(84.2986,-34.4008,-2.62094)); - Poles.SetValue(44,15,gp_Pnt(84.3172,-32.0111,-2.66065)); - Poles.SetValue(44,16,gp_Pnt(84.3284,-30.0979,-2.70139)); - Poles.SetValue(44,17,gp_Pnt(84.3451,-27.2279,-2.76856)); - Poles.SetValue(44,18,gp_Pnt(84.3501,-23.8723,-2.78848)); - Poles.SetValue(44,19,gp_Pnt(84.3568,-20.039,-2.88096)); - Poles.SetValue(44,20,gp_Pnt(84.3439,-16.1977,-2.86279)); - Poles.SetValue(44,21,gp_Pnt(84.3401,-12.3571,-2.99929)); - Poles.SetValue(44,22,gp_Pnt(84.3364,-8.51254,-3.10404)); - Poles.SetValue(44,23,gp_Pnt(84.3307,-5.62646,-3.13212)); - Poles.SetValue(44,24,gp_Pnt(84.3261,-1.77822,-3.18231)); - Poles.SetValue(44,25,gp_Pnt(84.3219,2.0692,-3.18879)); - Poles.SetValue(44,26,gp_Pnt(84.3241,5.91518,-3.18419)); - Poles.SetValue(44,27,gp_Pnt(84.3283,8.7991,-3.19732)); - Poles.SetValue(44,28,gp_Pnt(84.3322,12.6435,-3.19362)); - Poles.SetValue(44,29,gp_Pnt(84.3367,16.4878,-3.15729)); - Poles.SetValue(44,30,gp_Pnt(84.3449,20.3298,-3.212)); - Poles.SetValue(44,31,gp_Pnt(84.3382,24.1652,-3.18681)); - Poles.SetValue(44,32,gp_Pnt(84.3328,27.5176,-3.24238)); - Poles.SetValue(44,33,gp_Pnt(84.3137,30.3832,-3.1762)); - Poles.SetValue(44,34,gp_Pnt(84.3012,32.2934,-3.13458)); - Poles.SetValue(44,35,gp_Pnt(84.2835,34.6788,-3.05639)); - Poles.SetValue(44,36,gp_Pnt(84.2688,37.5436,-3.03341)); - Poles.SetValue(44,37,gp_Pnt(84.2567,40.4108,-2.97846)); - Poles.SetValue(44,38,gp_Pnt(84.2493,43.2807,-2.94203)); - Poles.SetValue(44,39,gp_Pnt(84.2426,47.1105,-2.85403)); - Poles.SetValue(44,40,gp_Pnt(84.2423,51.9032,-2.73437)); - Poles.SetValue(44,41,gp_Pnt(84.2552,57.6633,-2.65697)); - Poles.SetValue(44,42,gp_Pnt(84.2707,63.4255,-2.51041)); - Poles.SetValue(44,43,gp_Pnt(84.2947,71.1123,-2.33047)); - Poles.SetValue(44,44,gp_Pnt(84.3464,84.5727,-1.97042)); - Poles.SetValue(44,45,gp_Pnt(84.4215,103.814,-1.51302)); - Poles.SetValue(44,46,gp_Pnt(84.5086,126.896,-0.626681)); - Poles.SetValue(44,47,gp_Pnt(84.5693,142.301,-0.243958)); - Poles.SetValue(44,48,gp_Pnt(84.5995,150,-0.000554027)); - Poles.SetValue(45,1,gp_Pnt(103.838,-149.999,0.000693631)); - Poles.SetValue(45,2,gp_Pnt(103.817,-142.283,-0.134708)); - Poles.SetValue(45,3,gp_Pnt(103.771,-126.851,-0.393149)); - Poles.SetValue(45,4,gp_Pnt(103.704,-103.715,-0.554331)); - Poles.SetValue(45,5,gp_Pnt(103.653,-84.4538,-0.85582)); - Poles.SetValue(45,6,gp_Pnt(103.619,-70.9776,-1.13828)); - Poles.SetValue(45,7,gp_Pnt(103.6,-63.2834,-1.26826)); - Poles.SetValue(45,8,gp_Pnt(103.585,-57.5128,-1.32722)); - Poles.SetValue(45,9,gp_Pnt(103.569,-51.7417,-1.39145)); - Poles.SetValue(45,10,gp_Pnt(103.554,-46.933,-1.47713)); - Poles.SetValue(45,11,gp_Pnt(103.538,-43.0832,-1.56351)); - Poles.SetValue(45,12,gp_Pnt(103.524,-40.1968,-1.61145)); - Poles.SetValue(45,13,gp_Pnt(103.505,-37.3056,-1.67968)); - Poles.SetValue(45,14,gp_Pnt(103.487,-34.4181,-1.71097)); - Poles.SetValue(45,15,gp_Pnt(103.468,-32.0079,-1.76122)); - Poles.SetValue(45,16,gp_Pnt(103.458,-30.085,-1.80205)); - Poles.SetValue(45,17,gp_Pnt(103.443,-27.2014,-1.86016)); - Poles.SetValue(45,18,gp_Pnt(103.436,-23.8458,-1.96204)); - Poles.SetValue(45,19,gp_Pnt(103.426,-20.0087,-2.01108)); - Poles.SetValue(45,20,gp_Pnt(103.432,-16.1784,-2.11951)); - Poles.SetValue(45,21,gp_Pnt(103.429,-12.3464,-2.09847)); - Poles.SetValue(45,22,gp_Pnt(103.426,-8.51499,-2.09843)); - Poles.SetValue(45,23,gp_Pnt(103.427,-5.64258,-2.13298)); - Poles.SetValue(45,24,gp_Pnt(103.428,-1.81239,-2.15552)); - Poles.SetValue(45,25,gp_Pnt(103.429,2.01779,-2.2127)); - Poles.SetValue(45,26,gp_Pnt(103.425,5.84787,-2.24947)); - Poles.SetValue(45,27,gp_Pnt(103.42,8.7205,-2.23377)); - Poles.SetValue(45,28,gp_Pnt(103.419,12.5505,-2.2506)); - Poles.SetValue(45,29,gp_Pnt(103.418,16.3787,-2.27936)); - Poles.SetValue(45,30,gp_Pnt(103.409,20.2066,-2.15004)); - Poles.SetValue(45,31,gp_Pnt(103.421,24.0411,-2.1335)); - Poles.SetValue(45,32,gp_Pnt(103.43,27.3967,-2.05519)); - Poles.SetValue(45,33,gp_Pnt(103.449,30.2805,-2.04635)); - Poles.SetValue(45,34,gp_Pnt(103.463,32.2036,-2.0388)); - Poles.SetValue(45,35,gp_Pnt(103.484,34.6131,-2.03358)); - Poles.SetValue(45,36,gp_Pnt(103.502,37.4987,-2.0062)); - Poles.SetValue(45,37,gp_Pnt(103.523,40.3884,-1.97852)); - Poles.SetValue(45,38,gp_Pnt(103.537,43.2734,-1.95553)); - Poles.SetValue(45,39,gp_Pnt(103.557,47.1221,-1.93252)); - Poles.SetValue(45,40,gp_Pnt(103.574,51.9281,-1.89403)); - Poles.SetValue(45,41,gp_Pnt(103.584,57.6907,-1.74768)); - Poles.SetValue(45,42,gp_Pnt(103.596,63.4551,-1.66735)); - Poles.SetValue(45,43,gp_Pnt(103.612,71.1425,-1.54309)); - Poles.SetValue(45,44,gp_Pnt(103.644,84.5989,-1.46411)); - Poles.SetValue(45,45,gp_Pnt(103.687,103.818,-0.980467)); - Poles.SetValue(45,46,gp_Pnt(103.757,126.905,-0.536908)); - Poles.SetValue(45,47,gp_Pnt(103.805,142.3,-0.161313)); - Poles.SetValue(45,48,gp_Pnt(103.83,150,-0.000163518)); - Poles.SetValue(46,1,gp_Pnt(126.927,-150.004,-0.000100752)); - Poles.SetValue(46,2,gp_Pnt(126.912,-142.299,-0.130631)); - Poles.SetValue(46,3,gp_Pnt(126.883,-126.887,-0.24799)); - Poles.SetValue(46,4,gp_Pnt(126.843,-103.777,-0.260883)); - Poles.SetValue(46,5,gp_Pnt(126.816,-84.5309,-0.411687)); - Poles.SetValue(46,6,gp_Pnt(126.804,-71.0707,-0.543712)); - Poles.SetValue(46,7,gp_Pnt(126.796,-63.376,-0.610079)); - Poles.SetValue(46,8,gp_Pnt(126.79,-57.6067,-0.646868)); - Poles.SetValue(46,9,gp_Pnt(126.783,-51.839,-0.65842)); - Poles.SetValue(46,10,gp_Pnt(126.779,-47.033,-0.68082)); - Poles.SetValue(46,11,gp_Pnt(126.778,-43.1892,-0.711667)); - Poles.SetValue(46,12,gp_Pnt(126.779,-40.3077,-0.742656)); - Poles.SetValue(46,13,gp_Pnt(126.782,-37.4269,-0.771362)); - Poles.SetValue(46,14,gp_Pnt(126.785,-34.5477,-0.808585)); - Poles.SetValue(46,15,gp_Pnt(126.79,-32.1486,-0.836321)); - Poles.SetValue(46,16,gp_Pnt(126.79,-30.2277,-0.847354)); - Poles.SetValue(46,17,gp_Pnt(126.791,-27.3461,-0.865188)); - Poles.SetValue(46,18,gp_Pnt(126.786,-23.9805,-0.850589)); - Poles.SetValue(46,19,gp_Pnt(126.785,-20.137,-0.872177)); - Poles.SetValue(46,20,gp_Pnt(126.774,-16.2901,-0.841412)); - Poles.SetValue(46,21,gp_Pnt(126.771,-12.4455,-0.888617)); - Poles.SetValue(46,22,gp_Pnt(126.77,-8.6011,-0.924689)); - Poles.SetValue(46,23,gp_Pnt(126.769,-5.71714,-0.928362)); - Poles.SetValue(46,24,gp_Pnt(126.767,-1.87221,-0.950812)); - Poles.SetValue(46,25,gp_Pnt(126.766,1.97273,-0.93774)); - Poles.SetValue(46,26,gp_Pnt(126.768,5.81772,-0.926189)); - Poles.SetValue(46,27,gp_Pnt(126.773,8.70129,-0.947427)); - Poles.SetValue(46,28,gp_Pnt(126.775,12.5459,-0.942477)); - Poles.SetValue(46,29,gp_Pnt(126.78,16.3917,-0.92351)); - Poles.SetValue(46,30,gp_Pnt(126.795,20.2388,-1.01431)); - Poles.SetValue(46,31,gp_Pnt(126.796,24.0826,-1.01183)); - Poles.SetValue(46,32,gp_Pnt(126.802,27.4469,-1.0509)); - Poles.SetValue(46,33,gp_Pnt(126.799,30.3276,-1.04049)); - Poles.SetValue(46,34,gp_Pnt(126.797,32.2478,-1.03441)); - Poles.SetValue(46,35,gp_Pnt(126.793,34.647,-1.02114)); - Poles.SetValue(46,36,gp_Pnt(126.79,37.5265,-1.01193)); - Poles.SetValue(46,37,gp_Pnt(126.787,40.4072,-0.994831)); - Poles.SetValue(46,38,gp_Pnt(126.786,43.2878,-0.961342)); - Poles.SetValue(46,39,gp_Pnt(126.783,47.1296,-0.902547)); - Poles.SetValue(46,40,gp_Pnt(126.782,51.9326,-0.817673)); - Poles.SetValue(46,41,gp_Pnt(126.787,57.6992,-0.788109)); - Poles.SetValue(46,42,gp_Pnt(126.789,63.4643,-0.707706)); - Poles.SetValue(46,43,gp_Pnt(126.797,71.1523,-0.758598)); - Poles.SetValue(46,44,gp_Pnt(126.808,84.6041,-0.552723)); - Poles.SetValue(46,45,gp_Pnt(126.827,103.836,-0.468498)); - Poles.SetValue(46,46,gp_Pnt(126.872,126.912,-0.205591)); - Poles.SetValue(46,47,gp_Pnt(126.901,142.306,-0.0896176)); - Poles.SetValue(46,48,gp_Pnt(126.919,150,-0.00186706)); - Poles.SetValue(47,1,gp_Pnt(142.331,-150.022,-0.0011824)); - Poles.SetValue(47,2,gp_Pnt(142.32,-142.319,-0.0845723)); - Poles.SetValue(47,3,gp_Pnt(142.296,-126.912,-0.0348247)); - Poles.SetValue(47,4,gp_Pnt(142.281,-103.817,-0.216625)); - Poles.SetValue(47,5,gp_Pnt(142.273,-84.5809,-0.194036)); - Poles.SetValue(47,6,gp_Pnt(142.264,-71.117,-0.0962207)); - Poles.SetValue(47,7,gp_Pnt(142.262,-63.4269,-0.109676)); - Poles.SetValue(47,8,gp_Pnt(142.261,-57.6591,-0.134362)); - Poles.SetValue(47,9,gp_Pnt(142.261,-51.8912,-0.17447)); - Poles.SetValue(47,10,gp_Pnt(142.261,-47.0855,-0.198201)); - Poles.SetValue(47,11,gp_Pnt(142.261,-43.2412,-0.213413)); - Poles.SetValue(47,12,gp_Pnt(142.261,-40.3577,-0.219481)); - Poles.SetValue(47,13,gp_Pnt(142.261,-37.474,-0.231785)); - Poles.SetValue(47,14,gp_Pnt(142.261,-34.5899,-0.238239)); - Poles.SetValue(47,15,gp_Pnt(142.261,-32.1863,-0.245761)); - Poles.SetValue(47,16,gp_Pnt(142.261,-30.264,-0.25701)); - Poles.SetValue(47,17,gp_Pnt(142.262,-27.3805,-0.273362)); - Poles.SetValue(47,18,gp_Pnt(142.265,-24.0175,-0.308423)); - Poles.SetValue(47,19,gp_Pnt(142.266,-20.1723,-0.320574)); - Poles.SetValue(47,20,gp_Pnt(142.269,-16.3277,-0.347549)); - Poles.SetValue(47,21,gp_Pnt(142.268,-12.4815,-0.333554)); - Poles.SetValue(47,22,gp_Pnt(142.267,-8.63539,-0.333702)); - Poles.SetValue(47,23,gp_Pnt(142.267,-5.75114,-0.350197)); - Poles.SetValue(47,24,gp_Pnt(142.267,-1.9053,-0.361855)); - Poles.SetValue(47,25,gp_Pnt(142.269,1.94054,-0.382183)); - Poles.SetValue(47,26,gp_Pnt(142.27,5.78645,-0.393577)); - Poles.SetValue(47,27,gp_Pnt(142.27,8.67102,-0.385519)); - Poles.SetValue(47,28,gp_Pnt(142.271,12.5173,-0.39336)); - Poles.SetValue(47,29,gp_Pnt(142.272,16.3631,-0.412844)); - Poles.SetValue(47,30,gp_Pnt(142.268,20.2079,-0.378051)); - Poles.SetValue(47,31,gp_Pnt(142.268,24.0533,-0.383864)); - Poles.SetValue(47,32,gp_Pnt(142.265,27.4171,-0.365288)); - Poles.SetValue(47,33,gp_Pnt(142.265,30.301,-0.36621)); - Poles.SetValue(47,34,gp_Pnt(142.265,32.2237,-0.366061)); - Poles.SetValue(47,35,gp_Pnt(142.266,34.6274,-0.366875)); - Poles.SetValue(47,36,gp_Pnt(142.265,37.5114,-0.360017)); - Poles.SetValue(47,37,gp_Pnt(142.265,40.395,-0.352827)); - Poles.SetValue(47,38,gp_Pnt(142.264,43.2786,-0.337981)); - Poles.SetValue(47,39,gp_Pnt(142.264,47.1233,-0.322015)); - Poles.SetValue(47,40,gp_Pnt(142.263,51.9292,-0.307379)); - Poles.SetValue(47,41,gp_Pnt(142.263,57.6957,-0.274754)); - Poles.SetValue(47,42,gp_Pnt(142.265,63.4634,-0.312079)); - Poles.SetValue(47,43,gp_Pnt(142.267,71.1535,-0.274627)); - Poles.SetValue(47,44,gp_Pnt(142.268,84.6121,-0.229297)); - Poles.SetValue(47,45,gp_Pnt(142.275,103.837,-0.124819)); - Poles.SetValue(47,46,gp_Pnt(142.29,126.918,-0.114093)); - Poles.SetValue(47,47,gp_Pnt(142.315,142.308,0.0555229)); - Poles.SetValue(47,48,gp_Pnt(142.328,150.004,0.00172523)); - Poles.SetValue(48,1,gp_Pnt(150.034,-150.032,0.000374255)); - Poles.SetValue(48,2,gp_Pnt(150.024,-142.329,-0.0018713)); - Poles.SetValue(48,3,gp_Pnt(150.004,-126.925,0.00327151)); - Poles.SetValue(48,4,gp_Pnt(149.999,-103.837,-0.00371772)); - Poles.SetValue(48,5,gp_Pnt(150,-84.6045,0.00227291)); - Poles.SetValue(48,6,gp_Pnt(150,-71.1444,-0.00370124)); - Poles.SetValue(48,7,gp_Pnt(150,-63.4533,0.00501253)); - Poles.SetValue(48,8,gp_Pnt(150,-57.6854,-0.0023337)); - Poles.SetValue(48,9,gp_Pnt(150,-51.9177,-0.00081928)); - Poles.SetValue(48,10,gp_Pnt(150.001,-47.1109,-0.000992593)); - Poles.SetValue(48,11,gp_Pnt(150.001,-43.2652,0.000772656)); - Poles.SetValue(48,12,gp_Pnt(150.001,-40.381,-3.16637e-006)); - Poles.SetValue(48,13,gp_Pnt(150.001,-37.4966,0.00148961)); - Poles.SetValue(48,14,gp_Pnt(150.001,-34.6123,0.00149543)); - Poles.SetValue(48,15,gp_Pnt(150.001,-32.2086,-0.000131478)); - Poles.SetValue(48,16,gp_Pnt(150.001,-30.2856,-0.000312929)); - Poles.SetValue(48,17,gp_Pnt(150.001,-27.4012,-0.00119273)); - Poles.SetValue(48,18,gp_Pnt(150.002,-24.036,0.000913256)); - Poles.SetValue(48,19,gp_Pnt(150.002,-20.19,-0.000202949)); - Poles.SetValue(48,20,gp_Pnt(150.003,-16.3441,0.0036406)); - Poles.SetValue(48,21,gp_Pnt(150.003,-12.4982,0.0019362)); - Poles.SetValue(48,22,gp_Pnt(150.004,-8.65203,0.000622563)); - Poles.SetValue(48,23,gp_Pnt(150.005,-5.7673,0.00229496)); - Poles.SetValue(48,24,gp_Pnt(150.005,-1.92098,-7.68902e-005)); - Poles.SetValue(48,25,gp_Pnt(150.005,1.92543,0.000370792)); - Poles.SetValue(48,26,gp_Pnt(150.005,5.77187,0.00239266)); - Poles.SetValue(48,27,gp_Pnt(150.004,8.65667,0.000574651)); - Poles.SetValue(48,28,gp_Pnt(150.004,12.503,0.00222324)); - Poles.SetValue(48,29,gp_Pnt(150.003,16.3492,0.00598073)); - Poles.SetValue(48,30,gp_Pnt(150.002,20.1954,0.000135085)); - Poles.SetValue(48,31,gp_Pnt(150.002,24.0417,0.00238843)); - Poles.SetValue(48,32,gp_Pnt(150.002,27.4072,-0.000189144)); - Poles.SetValue(48,33,gp_Pnt(150.001,30.2919,0.000229755)); - Poles.SetValue(48,34,gp_Pnt(150.001,32.2151,0.000156563)); - Poles.SetValue(48,35,gp_Pnt(150.001,34.6191,-0.00112558)); - Poles.SetValue(48,36,gp_Pnt(150.001,37.5038,-0.000249663)); - Poles.SetValue(48,37,gp_Pnt(150.001,40.3885,0.000316503)); - Poles.SetValue(48,38,gp_Pnt(150.001,43.273,-0.00132504)); - Poles.SetValue(48,39,gp_Pnt(150.001,47.119,-0.00179323)); - Poles.SetValue(48,40,gp_Pnt(150,51.9261,0.00186415)); - Poles.SetValue(48,41,gp_Pnt(150,57.6944,0.000887863)); - Poles.SetValue(48,42,gp_Pnt(150,63.4625,-0.00455467)); - Poles.SetValue(48,43,gp_Pnt(150,71.1535,0.00329757)); - Poles.SetValue(48,44,gp_Pnt(150,84.613,-0.00125356)); - Poles.SetValue(48,45,gp_Pnt(150,103.842,0.000250841)); - Poles.SetValue(48,46,gp_Pnt(150,126.921,-0.00110007)); - Poles.SetValue(48,47,gp_Pnt(150.022,142.311,0.00127182)); - Poles.SetValue(48,48,gp_Pnt(150.034,150.006,9.4637e-005)); - - - - - TColStd_Array1OfReal UKnots(1,46); - UKnots.SetValue(1,0); - UKnots.SetValue(2,0.0769231); - UKnots.SetValue(3,0.153846); - UKnots.SetValue(4,0.230769); - UKnots.SetValue(5,0.269231); - UKnots.SetValue(6,0.288462); - UKnots.SetValue(7,0.307692); - UKnots.SetValue(8,0.326923); - UKnots.SetValue(9,0.346154); - UKnots.SetValue(10,0.365385); - UKnots.SetValue(11,0.375); - UKnots.SetValue(12,0.384615); - UKnots.SetValue(13,0.394231); - UKnots.SetValue(14,0.403846); - UKnots.SetValue(15,0.413462); - UKnots.SetValue(16,0.423077); - UKnots.SetValue(17,0.432692); - UKnots.SetValue(18,0.442308); - UKnots.SetValue(19,0.461538); - UKnots.SetValue(20,0.480769); - UKnots.SetValue(21,0.485577); - UKnots.SetValue(22,0.490385); - UKnots.SetValue(23,0.495192); - UKnots.SetValue(24,0.504808); - UKnots.SetValue(25,0.509615); - UKnots.SetValue(26,0.514423); - UKnots.SetValue(27,0.519231); - UKnots.SetValue(28,0.538462); - UKnots.SetValue(29,0.557692); - UKnots.SetValue(30,0.567308); - UKnots.SetValue(31,0.576923); - UKnots.SetValue(32,0.586538); - UKnots.SetValue(33,0.596154); - UKnots.SetValue(34,0.605769); - UKnots.SetValue(35,0.615385); - UKnots.SetValue(36,0.625); - UKnots.SetValue(37,0.634615); - UKnots.SetValue(38,0.653846); - UKnots.SetValue(39,0.673077); - UKnots.SetValue(40,0.692308); - UKnots.SetValue(41,0.711538); - UKnots.SetValue(42,0.730769); - UKnots.SetValue(43,0.769231); - UKnots.SetValue(44,0.846154); - UKnots.SetValue(45,0.923077); - UKnots.SetValue(46,1); - - TColStd_Array1OfReal VKnots(1,46); - VKnots.SetValue(1,0); - VKnots.SetValue(2,0.0769231); - VKnots.SetValue(3,0.153846); - VKnots.SetValue(4,0.230769); - VKnots.SetValue(5,0.269231); - VKnots.SetValue(6,0.288462); - VKnots.SetValue(7,0.307692); - VKnots.SetValue(8,0.326923); - VKnots.SetValue(9,0.346154); - VKnots.SetValue(10,0.355769); - VKnots.SetValue(11,0.365385); - VKnots.SetValue(12,0.375); - VKnots.SetValue(13,0.384615); - VKnots.SetValue(14,0.394231); - VKnots.SetValue(15,0.399038); - VKnots.SetValue(16,0.403846); - VKnots.SetValue(17,0.423077); - VKnots.SetValue(18,0.432692); - VKnots.SetValue(19,0.442308); - VKnots.SetValue(20,0.461538); - VKnots.SetValue(21,0.471154); - VKnots.SetValue(22,0.480769); - VKnots.SetValue(23,0.490385); - VKnots.SetValue(24,0.509615); - VKnots.SetValue(25,0.519231); - VKnots.SetValue(26,0.528846); - VKnots.SetValue(27,0.538462); - VKnots.SetValue(28,0.557692); - VKnots.SetValue(29,0.567308); - VKnots.SetValue(30,0.576923); - VKnots.SetValue(31,0.596154); - VKnots.SetValue(32,0.600962); - VKnots.SetValue(33,0.605769); - VKnots.SetValue(34,0.615385); - VKnots.SetValue(35,0.625); - VKnots.SetValue(36,0.634615); - VKnots.SetValue(37,0.644231); - VKnots.SetValue(38,0.653846); - VKnots.SetValue(39,0.673077); - VKnots.SetValue(40,0.692308); - VKnots.SetValue(41,0.711538); - VKnots.SetValue(42,0.730769); - VKnots.SetValue(43,0.769231); - VKnots.SetValue(44,0.846154); - VKnots.SetValue(45,0.923077); - VKnots.SetValue(46,1); - - TColStd_Array1OfInteger UMults(1,46); - UMults.SetValue(1,4); - UMults.SetValue(2,1); - UMults.SetValue(3,1); - UMults.SetValue(4,1); - UMults.SetValue(5,1); - UMults.SetValue(6,1); - UMults.SetValue(7,1); - UMults.SetValue(8,1); - UMults.SetValue(9,1); - UMults.SetValue(10,1); - UMults.SetValue(11,1); - UMults.SetValue(12,1); - UMults.SetValue(13,1); - UMults.SetValue(14,1); - UMults.SetValue(15,1); - UMults.SetValue(16,1); - UMults.SetValue(17,1); - UMults.SetValue(18,1); - UMults.SetValue(19,1); - UMults.SetValue(20,1); - UMults.SetValue(21,1); - UMults.SetValue(22,1); - UMults.SetValue(23,1); - UMults.SetValue(24,1); - UMults.SetValue(25,1); - UMults.SetValue(26,1); - UMults.SetValue(27,1); - UMults.SetValue(28,1); - UMults.SetValue(29,1); - UMults.SetValue(30,1); - UMults.SetValue(31,1); - UMults.SetValue(32,1); - UMults.SetValue(33,1); - UMults.SetValue(34,1); - UMults.SetValue(35,1); - UMults.SetValue(36,1); - UMults.SetValue(37,1); - UMults.SetValue(38,1); - UMults.SetValue(39,1); - UMults.SetValue(40,1); - UMults.SetValue(41,1); - UMults.SetValue(42,1); - UMults.SetValue(43,1); - UMults.SetValue(44,1); - UMults.SetValue(45,1); - UMults.SetValue(46,4); - - TColStd_Array1OfInteger VMults(1,46); - VMults.SetValue(1,4); - VMults.SetValue(2,1); - VMults.SetValue(3,1); - VMults.SetValue(4,1); - VMults.SetValue(5,1); - VMults.SetValue(6,1); - VMults.SetValue(7,1); - VMults.SetValue(8,1); - VMults.SetValue(9,1); - VMults.SetValue(10,1); - VMults.SetValue(11,1); - VMults.SetValue(12,1); - VMults.SetValue(13,1); - VMults.SetValue(14,1); - VMults.SetValue(15,1); - VMults.SetValue(16,1); - VMults.SetValue(17,1); - VMults.SetValue(18,1); - VMults.SetValue(19,1); - VMults.SetValue(20,1); - VMults.SetValue(21,1); - VMults.SetValue(22,1); - VMults.SetValue(23,1); - VMults.SetValue(24,1); - VMults.SetValue(25,1); - VMults.SetValue(26,1); - VMults.SetValue(27,1); - VMults.SetValue(28,1); - VMults.SetValue(29,1); - VMults.SetValue(30,1); - VMults.SetValue(31,1); - VMults.SetValue(32,1); - VMults.SetValue(33,1); - VMults.SetValue(34,1); - VMults.SetValue(35,1); - VMults.SetValue(36,1); - VMults.SetValue(37,1); - VMults.SetValue(38,1); - VMults.SetValue(39,1); - VMults.SetValue(40,1); - VMults.SetValue(41,1); - VMults.SetValue(42,1); - VMults.SetValue(43,1); - VMults.SetValue(44,1); - VMults.SetValue(45,1); - VMults.SetValue(46,4); - - // Creating the BSpline Surface - Handle(Geom_BSplineSurface) Surface = new Geom_BSplineSurface( - Poles, // const TColgp_Array2OfPnt & Poles, - UKnots, // const TColStd_Array1OfReal & UKnots, - VKnots, // const TColStd_Array1OfReal & VKnots, - UMults, // const TColStd_Array1OfInteger & UMults, - VMults, // const TColStd_Array1OfInteger & VMults, - 3, // const Standard_Integer UDegree, - 3 // const Standard_Integer VDegree, - // const Standard_Boolean UPeriodic = Standard_False, - // const Standard_Boolean VPeriodic = Standard_False*/ - ); - - - - - - BRepBuilderAPI_MakeFace Face(Surface); - - return new TopoShapePy(new TopoShape(Face.Face())); - } PY_CATCH; -} - - -static PyObject * createPlane(PyObject *self, PyObject *args) -{ - - double z_level; - - //const char* Name; - if (! PyArg_ParseTuple(args, "d", &z_level)) - return NULL; - - - PY_TRY - { - - gp_Pnt aPlanePnt(0,0,z_level); - gp_Dir aPlaneDir(0,0,1); - Handle_Geom_Plane aPlane = new Geom_Plane(aPlanePnt, aPlaneDir); - BRepBuilderAPI_MakeFace Face(aPlane); - - return new TopoShapePy(new TopoShape(Face.Face())); - } PY_CATCH; -} - -static PyObject * createBox(PyObject *self, PyObject *args) -{ - double X, Y, Z , L, H, W ; - - //const char* Name; - if (! PyArg_ParseTuple(args, "dddddd", &X, &Y, &Z , &L, &H, &W )) - return NULL; - - - PY_TRY - { - // Build a box using the dimension and position attributes - BRepPrimAPI_MakeBox mkBox( gp_Pnt( X, Y, Z ), L, H, W ); - - TopoDS_Shape ResultShape = mkBox.Shape(); - - return new TopoShapePy(new TopoShape(ResultShape)); - } PY_CATCH; -} - -static PyObject * useMesh(PyObject *self, PyObject *args) -{ - MeshPy *pcObject; - PyObject *pcObj; - if (!PyArg_ParseTuple(args, "O!; Need exactly one Mesh object", &(MeshPy::Type), &pcObj)) // convert args: Python->C - return NULL; // NULL triggers exception - - pcObject = (MeshPy*)pcObj; - - PY_TRY - { - - const MeshObject *aMeshObject = pcObject->getMeshObjectPtr(); - const MeshKernel& m = aMeshObject->getKernel(); - //MeshAlgos::boolean(&_cMesh,&m,&_cMesh,0); - MeshKernel copy = m; - MeshCore::MeshAlgorithm algo(copy); - std::list< std::vector > BoundariesIndex; - std::list< std::vector > ::iterator bin_it; - std::list< std::vector > BoundariesPoints; - algo.GetMeshBorders(BoundariesIndex); - algo.GetMeshBorders(BoundariesPoints); - Base::BoundBox3f BoundBox = copy.GetBoundBox(); - - - // Count of edges - m.CountEdges(); - // Count of vertices - m.CountPoints(); - // Count of Triangles - m.CountFacets(); - - // Neighbour triangles - unsigned long idx1,idx2,idx3,idx=0; - m.GetFacetNeighbours(idx,idx1,idx2,idx3); - - // points of a triangle - m.GetFacetPoints(idx,idx1,idx2,idx3); - MeshCore::MeshPoint p = m.GetPoint(idx1); - //float x = p[0]; - //float y = p[1]; - //float z = p[2]; - - // topological stuff, works only on a non const copy.... - //MeshCore::MeshTopoAlgorithm TopAlgs(m); - - // e.g. Iterators - MeshCore::MeshFacetIterator It(m); - while (It.More()) - { - ++It; - } - - // most of the algorithms are under src/Mod/Mesh/App/Core! - - } PY_CATCH; - - Py_Return; -} -//static PyObject * MyApprox(PyObject *self, PyObject *args) -//{ -// MeshPy *pcObject; -// PyObject *pcObj; -// double tolerance; -// if (!PyArg_ParseTuple(args, "O!d; Usage:- MyApprox(meshobject, tolerance)", &(MeshPy::Type), &pcObj, &tolerance)) // convert args: Python->C -// return NULL; // NULL triggers exception -// -// pcObject = (MeshPy*)pcObj; -// -// PY_TRY { -// const MeshObject *o = pcObject->getMesh(); -// const MeshKernel &m = o->getKernel(); -// //MeshAlgos::boolean(&_cMesh,&m,&_cMesh,0); -// //MeshKernel copy = m; -// -// std::vector Control; -// std::vector KntU; -// std::vector KntV; -// int OrdU; -// int OrdV; -// try { -// Approximate approx((MeshKernel &)m,Control,KntU,KntV,OrdU,OrdV,tolerance); -// } -// catch(const char *errstr) { std::cerr << errstr << std::endl; } -// int maxCntrlU = KntU.size() - OrdU; -// int maxCntrlV = KntU.size() - OrdV; -// //Load Control Pnts -// TColgp_Array2OfPnt Poles(1,maxCntrlU,1,maxCntrlV); -// for(int u = 0; u < maxCntrlU; u++) -// { -// for(int v = 0; v < maxCntrlV; v++) -// Poles.SetValue(u+1,v+1,gp_Pnt(Control[(u*3)+(3*maxCntrlU*v)],Control[(u*3)+(3*maxCntrlU*v)+1], -// Control[(u*3)+(3*maxCntrlU*v)+2])); -// } -// //Load U-Knot Vector -// TColStd_Array1OfReal UKnots(1,KntU.size() - 6); -// TColStd_Array1OfInteger UMults(1,KntU.size() - 6); -// UKnots.SetValue(1,KntU[0]); -// for(unsigned int i = 1, j = 1; i < KntU.size(); i++) -// { -// if(KntU[i] == KntU[i-1]) -// continue; -// else -// { -// UKnots.SetValue(j+1,KntU[i]); -// j++; -// } -// -// } -// UMults.SetValue(1,4); -// UMults.SetValue(KntU.size() - 6,4); -// for(unsigned int i = 1; i < KntU.size() - 7; i++) -// UMults.SetValue(i+1,1); -// //Load V-Knot Vector -// TColStd_Array1OfReal VKnots(1,KntU.size() - 6); -// TColStd_Array1OfInteger VMults(1,KntU.size() - 6); -// VKnots.SetValue(1,KntV[0]); -// for(unsigned int i = 1, j = 1; i < KntV.size(); i++) -// { -// if(KntV[i] == KntV[i-1]) -// continue; -// else -// { -// VKnots.SetValue(j+1,KntV[i]); -// j++; -// } -// -// } -// VMults.SetValue(1,4); -// VMults.SetValue(KntV.size() - 6,4); -// for(unsigned int i = 1; i < KntV.size() - 7; i++) -// VMults.SetValue(i+1,1); -// -// Handle(Geom_BSplineSurface) Surface = new Geom_BSplineSurface( -// Poles, // const TColgp_Array2OfPnt & Poles, -// UKnots, // const TColStd_Array1OfReal & UKnots, -// VKnots, // const TColStd_Array1OfReal & VKnots, -// UMults, // const TColStd_Array1OfInteger & UMults, -// VMults, // const TColStd_Array1OfInteger & VMults, -// 3, // const Standard_Integer UDegree, -// 3 // const Standard_Integer VDegree, -// // const Standard_Boolean UPeriodic = Standard_False, -// // const Standard_Boolean VPeriodic = Standard_False*/ -// ); -// -// -// -// -// -// BRepBuilderAPI_MakeFace Face(Surface); -// -// return new TopoShapePyOld(Face.Face()); -// } PY_CATCH; -// -// Py_Return; -//} -static PyObject * openDYNA(PyObject *self, PyObject *args) -{ - const char* filename; - if (! PyArg_ParseTuple(args, "s;Usage:- openDYNA(filename)", &filename)) - return NULL; - PY_TRY - { - MeshCore::MeshKernel mesh; - ReadDyna parse(mesh,filename); - MeshObject aObject(mesh); - - return aObject.getPyObject(); - } - PY_CATCH; - - Py_Return; - -} - - -static PyObject * offset_mesh(PyObject *self, PyObject *args) -{ - double offset; - - MeshPy *pcObject; - PyObject *pcObj; - if (!PyArg_ParseTuple(args, "O!d; Need exactly one Mesh object", &(MeshPy::Type), &pcObj, &offset)) // convert args: Python->C - return NULL; // NULL triggers exception - - pcObject = (MeshPy*)pcObj; - Base::Builder3D log3d; - - PY_TRY - { - - MeshObject *o = pcObject->getMeshObjectPtr(); - MeshKernel &mesh = o->getKernel(); - - //Base::Vector3f Point[3]; - Base::Vector3f current_pnt; - - - //const MeshCore::MeshFacetArray& Facets = mesh.GetFacets(); - //const MeshCore::MeshPointArray& Points = mesh.GetPoints(); - - MeshCore::MeshPointIterator p_it(mesh); - MeshCore::MeshFacetIterator f_it(mesh); - MeshCore::MeshRefPointToFacets rf2pt(mesh); - MeshCore::MeshGeomFacet t_face; - - //int NumOfPoints = mesh.CountPoints(); - - Base::Vector3f normal,local_normal; - //float fArea = 0.0f; - - - - for (unsigned long i=0; i& faceSet = rf2pt[i]; - float fArea = 0.0; - normal.Set(0.0,0.0,0.0); - - - // Iterate over the triangles to each point - for (std::set::const_iterator it = faceSet.begin(); it != faceSet.end(); ++it) - { - // Dereferencing once it gets to the MeshFacet - // and handing over to the kernel so that it delivers a MeshGeomFacet - t_face = mesh.GetFacet(*it); - // Sum up the area content - float local_Area = t_face.Area(); - local_normal = t_face.GetNormal(); - if (local_normal.z < 0) - { - local_normal = local_normal * (-1); - } - - fArea = fArea + local_Area; - normal = normal + local_normal; - - } - - normal.Normalize(); - log3d.addSingleArrow(mesh.GetPoint(i),mesh.GetPoint(i) + (normal*float(offset))); - mesh.MovePoint(i,(normal*float(offset))); - - } - - log3d.saveToFile("c:/test.iv"); - MeshObject aObject(mesh); - return new MeshPy(&aObject); - } - PY_CATCH; - - Py_Return; - - - - /*for(p_it.Begin();!(p_it.EndReached()); ++p_it) - { - cout << "First loop" <C -// return NULL; // NULL triggers exception -// -// -// TopoShapePyOld *pcShape = static_cast(pcObj); //Surface is passed -// -// TopExp_Explorer Ex; -// Ex.Init(pcShape->getShape(),TopAbs_FACE); // initialize cad geometry (trimmed surface) -// -// Base::Builder3D m_log3d; -// -// // surface types -// TopoDS_Face atopo_surface,atopo_surface2; -// BRepAdaptor_Surface adaptor_surface; -// GeomAdaptor_Surface geom_adapterSurface; -// Handle_Geom_Surface geom_surf; -// GeomAbs_SurfaceType type; -// gp_Pln plane; -// -// TopoDS_Shape cad = pcShape->getShape(); -// -// // point types -// std::vector point_list; -// gp_Pnt tmp_pnt; -// Base::Vector3f pnt; -// gp_Dir pl_vec; -// gp_Lin lin; -// -// -// // bounding box -// Bnd_Box BBox; -// Standard_Real XMin1, YMin1, ZMin1, XMax1, YMax1, ZMax1; -// -// IntCurvesFace_ShapeIntersector shp_int; -// BRepClass3d_SolidClassifier check; -// -// -// double u_min,v_min,u_max,v_max; -// double u_range, v_range; -// double N; -// int n1,n2; -// bool b; -// -// if (!Ex.More()) return false; -// -// for (;Ex.More();Ex.Next()) -// { -// // pass the single patches -// atopo_surface = TopoDS::Face (Ex.Current()); -// adaptor_surface.Initialize(atopo_surface); -// -// type = adaptor_surface.GetType(); -// -// if(type == GeomAbs_Plane) -// { -// check.Load(atopo_surface); -// -// plane = adaptor_surface.Plane(); -// pl_vec = (plane.Axis()).Direction(); -// -// /*geom_adapterSurface = adaptor_surface.Surface(); -// geom_surf = geom_adapterSurface.Surface();*/ -// -// u_min = adaptor_surface.FirstUParameter(); -// u_max = adaptor_surface.LastUParameter(); -// -// v_min = adaptor_surface.FirstVParameter(); -// v_max = adaptor_surface.LastVParameter(); -// -// u_range = u_max - u_min; -// v_range = v_max - v_min; -// -// BRepBndLib::Add(atopo_surface, BBox); -// BBox.SetGap(0.0); -// BBox.Get(XMin1, YMin1, ZMin1, XMax1, YMax1, ZMax1); -// -// N = (XMax1 - XMin1)*(YMax1 - YMin1)/1e+4; -// n1 = sqrt(N);//(XMax1 - XMin1)*sqrt(N)/(YMax1 - YMin1); -// n2 = sqrt(N);//(YMax1 - YMin1)*sqrt(N)/(XMax1 - XMin1); -// -// if(n1<2) -// n1=2; -// if(n2<2) -// n2=2; -// -// BBox.SetVoid(); -// -// for(int i=0; iC -// return NULL; // NULL triggers exception -// -// pcObject = (MeshPy*)pcObj; -// pcObject2 = (MeshPy*)pcObj2; -// -// -// PY_TRY -// { -// MeshCore::MeshKernel mesh = pcObject->getMesh(); // Input Mesh -// MeshCore::MeshKernel mesh2 = pcObject2->getMesh(); // Mesh from CAD -// -// MeshCore::MeshEigensystem pca(mesh); -// pca.Evaluate(); -// -// MeshCore::MeshEigensystem pca2(mesh2); -// pca2.Evaluate(); -// -// -// -// Base::Matrix4D T1 = pca.Transform(); -// Base::Matrix4D T2 = pca2.Transform(); -// -// T2[0][3] = 0.0; -// T2[1][3] = 0.0; -// T2[2][3] = 0.0; -// -// Base::Matrix4D C; -// C.unity(); -// -// T2.inverse(); -// mesh.Transform(T2*T1); -// -// /* -// const MeshCore::MeshPointArray& rPoints = mesh.GetPoints(); -// Base::Vector3f vec(0.0,0.0,0.0); -// unsigned long c=0; -// -// -// for(MeshCore::MeshPointArray::_TConstIterator it = rPoints.begin(); it != rPoints.end(); ++it) -// { -// vec = *it; -// //vec = T*vec; -// //T.transform(vec,T); -// mesh.SetPoint(c,vec); -// ++c; -// } -// */ -// -// -// log3d.addSinglePoint(pnt); -// log3d.saveToFile("c:/origin.iv"); -// return new MeshPy(mesh); -// -// }PY_CATCH; -// -// Py_Return; -//} - - - -static PyObject * best_fit_complete(PyObject *self, PyObject *args) -{ - MeshPy *pcObject; - PyObject *pcObj; - PyObject *pcObj2; - - if (!PyArg_ParseTuple(args, "O!O!; Need one Mesh objects and one toposhape", &(MeshPy::Type), &pcObj, &(TopoShapePy::Type), &pcObj2)) // convert args: Python->C - return NULL; // NULL triggers exception - - PY_TRY - { - GProp_GProps prop; - GProp_PrincipalProps pprop; - gp_Pnt orig; - - pcObject = (MeshPy*)pcObj; - TopoShapePy *pcShape = static_cast(pcObj2); //Shape is passed - TopoDS_Shape cad = pcShape->getTopoShapePtr()->_Shape; // Input CAD - MeshCore::MeshKernel mesh = pcObject->getMeshObjectPtr()->getKernel(); // Input Mesh - -// best_fit befi(&mesh,&cad); - //befi.Perform(); - - //MeshObject anObject(*(befi.m_Mesh)); - - //return new MeshPy(&anObject); - - }PY_CATCH; - - Py_Return; -} - -#include "WireExplorer.h" -#include -#include -#include "BRepAdaptor_CompCurve2.h" -#include "SpringbackCorrection.h" -static PyObject * best_fit_test(PyObject *self, PyObject *args) -{ - - PyObject *pcObj; - - - if (!PyArg_ParseTuple(args, "O!", &(TopoShapePy::Type), &pcObj)) // convert args: Python->C - return NULL; // NULL triggers exception - - PY_TRY - { - - TopoShapePy *pcShape = static_cast(pcObj); //Shape is passed - TopoDS_Shape aShape = pcShape->getTopoShapePtr()->_Shape; - TopExp_Explorer anExplorer; - TopExp_Explorer aFaceExplorer; - - //SpringbackCorrection aShapeTriangulator(pcShape->getShape()); - //aShapeTriangulator.Init(); - std::vector anEdgeList; - TopoDS_Face first,second; - anEdgeList.clear(); - bool firstrun=true; - bool finished=false; - for (anExplorer.Init(aShape,TopAbs_FACE);anExplorer.More();anExplorer.Next()) - { - if (finished) break; - for (aFaceExplorer.Init(anExplorer.Current(),TopAbs_EDGE);aFaceExplorer.More();aFaceExplorer.Next()) - { - if (!firstrun && finished==false) - { - for (unsigned int i=0;iSurface () ; - //Now offset the wires from the original face. - TopExp_Explorer asecondFaceExplorer; - TopoDS_Wire aFaceWire; - for (asecondFaceExplorer.Init(first,TopAbs_WIRE);asecondFaceExplorer.More();asecondFaceExplorer.Next()) - { - aFaceWire = TopoDS::Wire(asecondFaceExplorer.Current()); - } - WireExplorer awireexplorer(aFaceWire); - //Create points on the wire and then insert these points into the delay as inputs - BRepAdaptor_CompCurve2 aWireAdapter(aFaceWire); - Standard_Real first_p,last_p,delta_u; - last_p = aWireAdapter.LastParameter(); - first_p = aWireAdapter.FirstParameter(); - delta_u = fabs(last_p-first_p)/50; - std::vector mesh_input; - mesh_input.clear(); - for (int k=0;k<=50;++k) - { - gp_Pnt currentPoint = aWireAdapter.Value(first_p+(k*delta_u)); - Base::Vector3f aVector; - aVector.x = float(currentPoint.X()); - aVector.y = float(currentPoint.Y()); - aVector.z = float(currentPoint.Z()); - mesh_input.push_back(aVector); - } - MeshCore::MeshKernel ameshkernel; - MeshCore::MeshBuilder aBuilder(ameshkernel); - std::vector mesh_output; - //MeshCore::MeshPolygonTriangulation aTriangulator; - //aTriangulator.SetPolygon(mesh_input); - Base::Matrix4D matrix; - //Base::Vector3f cPlaneNormal = aTriangulator.TransformToFitPlane(matrix); - //aTriangulator.ComputeQualityDelaunay(20,mesh_output); - std::vector geomfacets;// = aTriangulator.GetTriangles(); - aBuilder.Initialize(100); - - - for ( std::vector::iterator kt = geomfacets.begin(); kt != geomfacets.end(); ++kt ) - { - MeshCore::MeshGeomFacet atempfacet(matrix*(kt->_aclPoints[0]),matrix*(kt->_aclPoints[1]),matrix*(kt->_aclPoints[2])); - atempfacet.CalcNormal(); - aBuilder.AddFacet(atempfacet); - } - aBuilder.Finish(); - MeshObject anObject(ameshkernel); - return new MeshPy(&anObject); - - - TopoDS_Wire newWire; - for (awireexplorer.Init();awireexplorer.More();awireexplorer.Next()) - { - TopoDS_Edge currentEdge = TopoDS::Edge(awireexplorer.Current()); - Standard_Real uf,ul,schrittweite_edge; - Handle_Geom2d_Curve aPCurve = BRep_Tool::CurveOnSurface(currentEdge,first,uf,ul); - schrittweite_edge = fabs(uf-ul)/10; - std::vector offsetPoints; - offsetPoints.clear(); - for (int i=0;i<=10;++i) - { - gp_Pnt2d a2dPoint; - aPCurve->D0(uf+i*schrittweite_edge,a2dPoint); - //Koordinaten von der Surface holen - gp_Pnt point; - gp_Vec vecu,vecv,normal; - afirstFaceAdaptor.D1(a2dPoint.X(),a2dPoint.Y(),point,vecu,vecv); - vecu.Cross(vecv); - normal = vecu; - normal.Normalize(); - normal.Multiply(20.0); - gp_Pnt OffsetPoint; - OffsetPoint.SetXYZ(point.XYZ()+normal.XYZ()); - offsetPoints.push_back(OffsetPoint); - } - Handle(TColgp_HArray1OfPnt) MasterOffsetPoints = new TColgp_HArray1OfPnt(1, offsetPoints.size()); - for (unsigned int t=0;tSetValue(t+1,offsetPoints[t]); - } - GeomAPI_Interpolate aBSplineInterp(MasterOffsetPoints, Standard_False, Precision::Confusion()); - aBSplineInterp.Perform(); - Handle_Geom_BSplineCurve currentOffsetCurve(aBSplineInterp.Curve()); - } - BRepBuilderAPI_MakeFace Face(Final_Approx); - - //return new TopoShapePyOld(Face.Face()); - - - }PY_CATCH; - - Py_Return; -} - -static PyObject * shape2orig(PyObject *self, PyObject *args) -{ - PyObject *pcObj; - - if (!PyArg_ParseTuple(args, "O!; Need one toposhape", &(TopoShapePy::Type), &pcObj)) // convert args: Python->C - return NULL; // NULL triggers exception - - PY_TRY - { - GProp_GProps prop; - GProp_PrincipalProps pprop; - gp_Pnt orig; - - TopoShapePy *pcShape = static_cast(pcObj); //shape is passed - TopoDS_Shape cad = pcShape->getTopoShapePtr()->_Shape; // Input CAD - -// best_fit befi(cad); - // befi.ShapeFit_Coarse(); - - // return new TopoShapePyOld(*(befi.m_Cad)); - - }PY_CATCH; - - Py_Return; -} - - - - -static PyObject * spring_back(PyObject *self, PyObject *args) -{ - MeshPy *pcObject; - PyObject *pcObj; - PyObject *pcObj2; - - if (!PyArg_ParseTuple(args, "O!O!; Need one Mesh objects and one toposhape", &(MeshPy::Type), &pcObj, &(TopoShapePy::Type), &pcObj2)) // convert args: Python->C - return NULL; // NULL triggers exception - - PY_TRY - { - GProp_GProps prop; - GProp_PrincipalProps pprop; - gp_Pnt orig; - - pcObject = (MeshPy*)pcObj; - TopoShapePy *pcShape = static_cast(pcObj2); //Shape is passed - TopoDS_Shape cad = pcShape->getTopoShapePtr()->_Shape; // Input CAD - MeshObject* anObject = pcObject->getMeshObjectPtr(); // Input Mesh - MeshCore::MeshKernel mesh = anObject->getKernel(); - - time_t seconds1, seconds2; - seconds1 = time(NULL); - - /*-----------------------------------------------*/ - SpringbackCorrection aShapeTri(cad, mesh); - aShapeTri.Perform(60,1); - /*-----------------------------------------------*/ - - seconds2 = time(NULL); - cout << "laufzeit: " << seconds2-seconds1 << " sec" << endl; - - //anObject->setKernel(aShapeTri.m_Mesh); - - return new MeshPy(anObject); - - }PY_CATCH; - - Py_Return; -} - - - - - - - -static PyObject * tess_shape(PyObject *self, PyObject *args) -{ - PyObject *pcObj; - float aDeflection; - //PyObject *pcObj2; - if (!PyArg_ParseTuple(args, "O!f", &(TopoShapePy::Type), &pcObj, &aDeflection)) // convert args: Python->C - return NULL; // NULL triggers exception - - PY_TRY - { - - TopoShapePy *pcShape = static_cast(pcObj); //shape is passed - TopoDS_Shape cad = pcShape->getTopoShapePtr()->_Shape; // Input CAD - - //best_fit befi(cad); - //befi.ShapeFit_Coarse(); - - MeshCore::MeshKernel mesh; - best_fit::Tesselate_Shape(cad, mesh, float(0.1)); - MeshObject* anObject = new MeshObject(mesh); - return new MeshPy(anObject); - - }PY_CATCH; - - Py_Return; -} - - - - - - - - - - - - - - - - - - - - -//static PyObject * trafo_mesh(PyObject *self, PyObject *args) -//{ -// MeshPy *pcObject; -// -// -// Base::Vector3f pnt; -// -// if (!PyArg_ParseTuple(args, "O!; Need one Mesh objects", &(MeshPy::Type), &pcObj)) // convert args: Python->C -// return NULL; // NULL triggers exception -// -// pcObject = (MeshPy*)pcObj; -// -// PY_TRY -// { -// gp_Trsf trf; -// trf.SetTranslation(trafo); -// -// BRepBuilderAPI_Transform trsf(tsf); -// trsf.Perform(cad); -// TopoDS_Shape ResultShape = trsf.Shape(); -// -// return new MeshPy(mesh); -// -// }PY_CATCH; -// -// Py_Return; -//} -// -//static PyObject * trafo_cad(PyObject *self, PyObject *args) -//{ -// MeshPy *pcObject; -// -// Base::Vector3f pnt; -// -// if (!PyArg_ParseTuple(args, "O!; Need one TopoShape objects", &(MeshPy::Type), &pcObj)) // convert args: Python->C -// return NULL; // NULL triggers exception -// -// pcObject = (MeshPy*)pcObj; -// -// PY_TRY -// { -// gp_Trsf trf; -// trf.SetTranslation(trafo); -// -// BRepBuilderAPI_Transform trsf(tsf); -// trsf.Perform(cad); -// TopoDS_Shape ResultShape = trsf.Shape(); -// -// return new MeshPy(mesh); -// -// }PY_CATCH; -// -// Py_Return; -//} - -static PyObject * fit_iter(PyObject *self, PyObject *args) -{ - MeshPy *pcObject; - PyObject *pcObj; - PyObject *pcObj2; - - if (!PyArg_ParseTuple(args, "O!O!; Need exactly one Mesh object", &(MeshPy::Type), &pcObj, &(TopoShapePy::Type), &pcObj2)) // convert args: Python->C - return NULL; // NULL triggers exception - - TopoShapePy *pcShape = static_cast(pcObj2); //Surface is passed - TopoDS_Shape cad = pcShape->getTopoShapePtr()->_Shape; - - TopExp_Explorer Ex; - Ex.Init(cad,TopAbs_FACE); // initialize cad geometry (trimmed surface) - - pcObject = (MeshPy*)pcObj; - - Base::Builder3D log3d; - gp_Dir pl_vec; - gp_Lin lin; - gp_Pnt pnt; - Base::Vector3f tmp_pnt; - IntCurvesFace_ShapeIntersector shp_int; - - std::vector< std::vector > R(3, std::vector(3,0.0)); // Rotation matrix - double err = 1001; - - TopoDS_Face atopo_surface; - - MeshCore::MeshKernel mesh = pcObject->getMeshObjectPtr()->getKernel(); - - PY_TRY - { - //Base::Vector3f Point[3]; - Base::Vector3f current_pnt; - - - - - //const MeshCore::MeshFacetArray& Facets = mesh.GetFacets(); - //const MeshCore::MeshPointArray& Points = mesh.GetPoints(); - - MeshCore::MeshPointIterator p_it(mesh); - MeshCore::MeshFacetIterator f_it(mesh); - MeshCore::MeshRefPointToFacets rf2pt(mesh); - MeshCore::MeshGeomFacet t_face; - - int NumOfPoints = mesh.CountPoints(); - - //int NumOfPoints = mesh.CountPoints(); - - Base::Vector3f normal,local_normal; - //float fArea = 0.0f; - - while (err > 1000) - { - - err = 0.0; - for (unsigned long i=0; i& faceSet = rf2pt[i]; - float fArea = 0.0; - normal.Set(0.0,0.0,0.0); - - - // Iterate over the triangles to each point - for (std::set::const_iterator it = faceSet.begin(); it != faceSet.end(); ++it) - { - // Dereference once to get to the MeshFacet and to hand over to the kernel that it delivers a MeshGeomFacet - t_face = mesh.GetFacet(*it); - // Sum up the area content - float local_Area = t_face.Area(); - local_normal = t_face.GetNormal(); - if (local_normal.z < 0) - { - local_normal = local_normal * (-1); - } - - fArea = fArea + local_Area; - normal = normal + local_normal; - - } - - pnt.SetX((mesh.GetPoint(i)).x); - pnt.SetY((mesh.GetPoint(i)).y); - pnt.SetZ((mesh.GetPoint(i)).z); - - lin.SetLocation(pnt); - - pl_vec.SetX(normal.x); - pl_vec.SetY(normal.y); - pl_vec.SetZ(normal.z); - - lin.SetDirection(pl_vec); - - shp_int.Load(cad, 0.1); - shp_int.PerformNearest(lin,-RealLast(),+RealLast()); - - if (shp_int.IsDone()) - { - err += sqrt((pnt.X() - shp_int.Pnt(1).X())*(pnt.X() - shp_int.Pnt(1).X())* - (pnt.Y() - shp_int.Pnt(1).Y())*(pnt.Y() - shp_int.Pnt(1).Y())* - (pnt.Z() - shp_int.Pnt(1).Z())*(pnt.Z() - shp_int.Pnt(1).Z())); - - - pnt = shp_int.Pnt(1); - - tmp_pnt.x = float(pnt.X()); - tmp_pnt.y = float(pnt.Y()); - tmp_pnt.z = float(pnt.Z()); - - //point_list.push_back(pnt); - log3d.addSinglePoint(tmp_pnt,2,0,0,0); - } - } - - - R[0][0] = cos(PI); - R[0][1] = -sin(PI); - R[1][0] = sin(PI); - R[1][1] = cos(PI); - R[2][2] = 1; - - MeshCore::MeshPoint mpnt; - - for (int i=0; i TOL) - //{ - // traf += fl*traf_step; - - // err = 0; - // for(int i=0; i * - * Copyright (c) 2007 Human Rezai * - * Copyright (c) 2007 Mohamad Najib Muhammad Noor - * * - * This file is part of the FreeCAD CAx development system. * - * * - * This library is free software; you can redistribute it and/or * - * modify it under the terms of the GNU Library General Public * - * License as published by the Free Software Foundation; either * - * version 2 of the License, or (at your option) any later version. * - * * - * This library is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * - * GNU Library General Public License for more details. * - * * - * You should have received a copy of the GNU Library General Public * - * License along with this library; see the file COPYING.LIB. If not, * - * write to the Free Software Foundation, Inc., 59 Temple Place, * - * Suite 330, Boston, MA 02111-1307, USA * - * * - ***************************************************************************/ - -/*****************APPROX.CPP***************** -* Contains implementations from Approx.h -* -* -*********************************************/ - - -/*********MAIN INCLUDES***********/ -#include "PreCompiled.h" -#include "Approx.h" -#include -#include -#include - - -#include -#include -#include -#include -#include -#include - -/*************BOOST***************/ - -/********UBLAS********/ -#include -#include -#include -#include - -/*********BINDINGS********/ -#include -#include -#include -#include -#include - -/*****ADDITIONAL FOR DEBUGGING*****/ -//#include -/*****NAMESPACE**/ -using namespace boost::numeric::bindings; - -Approximate::Approximate(const MeshCore::MeshKernel &m,std::vector &_Cntrl, std::vector &_KnotU, std::vector &_KnotV, - int &_OrderU, int &_OrderV, double tol) -{ - MinX = 0, MinY = 0, MaxX = 0; - MaxY = 0; - tolerance = tol; - int NumPnts = m.CountPoints(); //number of points to approximate - Base::BoundBox3f bbox = m.GetBoundBox(); // get bounding box - double x_len = bbox.LengthX(); - double y_len = bbox.LengthY(); - - LocalMesh = m; //make a copy... - - - //Initialize the NURB - MainNurb.DegreeU = 3; - MainNurb.DegreeV = 3; - MainNurb.MaxU = std::max(MainNurb.DegreeU+1, (int)sqrt(double(NumPnts)*y_len/x_len)); - MainNurb.MaxV = std::max(MainNurb.DegreeV+1, (int)sqrt(double(NumPnts)*x_len/y_len)); - - GenerateUniformKnot(MainNurb.MaxU,MainNurb.DegreeU,MainNurb.KnotU); - GenerateUniformKnot(MainNurb.MaxV,MainNurb.DegreeV,MainNurb.KnotV); - MainNurb.MaxKnotU = MainNurb.KnotU.size(); - MainNurb.MaxKnotV = MainNurb.KnotV.size(); - - //GOTO Main program - ApproxMain(); - - ofstream anOutputFile; - anOutputFile.open("c:/approx_build_surface.txt"); - - anOutputFile << "start building surface" << endl; - - //Copying the Output - //mesh = ParameterMesh; - _Cntrl = MainNurb.CntrlArray; - _KnotU = MainNurb.KnotU; - _KnotV = MainNurb.KnotV; - _OrderU = MainNurb.DegreeU + 1; - _OrderV = MainNurb.DegreeV + 1; - - gp_Pnt pnt; - TColgp_Array2OfPnt Poles(1,MainNurb.MaxU+1, 1,MainNurb.MaxV+1); - - for(int j=0; j< (MainNurb.MaxV+1); ++j) - { - for(int i=0; i < (MainNurb.MaxU+1); ++i) - { - pnt.SetX(_Cntrl[3*i + j*3*(MainNurb.MaxU+1)]); - pnt.SetY(_Cntrl[3*i+1 + j*3*(MainNurb.MaxU+1)]); - pnt.SetZ(_Cntrl[3*i+2 + j*3*(MainNurb.MaxU+1)]); - - Poles.SetValue(i+1,j+1,pnt); - } - } - - anOutputFile << "control points done" << endl; - - int c=1; - for (unsigned int i=0; i<_KnotU.size()-1; ++i) - { - if (_KnotU[i+1] != _KnotU[i]) - { - ++c; - } - } - - - TColStd_Array1OfReal UKnots(1,c); - TColStd_Array1OfInteger UMults(1,c); - - c=1; - for (unsigned int i=0; i<_KnotV.size()-1; ++i) - { - if (_KnotV[i+1] != _KnotV[i]) - { - ++c; - } - } - - - TColStd_Array1OfReal VKnots(1,c); - TColStd_Array1OfInteger VMults(1,c); - - int d=0; - c=1; - for (unsigned int i=0; i<_KnotU.size(); ++i) - { - if (_KnotU[i+1] != _KnotU[i]) - { - UKnots.SetValue(d+1,_KnotU[i]); - UMults.SetValue(d+1,c); - ++d; - c=1; - - } - else - { - ++c; - } - - if (i==(_KnotU.size()-2)) - { - UKnots.SetValue(d+1,_KnotU[i+1]); - UMults.SetValue(d+1,c); - break; - } - } - - d=0; - c=1; - for (unsigned int i=0; i<_KnotV.size(); ++i) - { - if (_KnotV[i+1] != _KnotV[i]) - { - VKnots.SetValue(d+1,_KnotV[i]); - VMults.SetValue(d+1,c); - ++d; - c=1; - - } - else - { - ++c; - } - - if (i==(_KnotV.size()-2)) - { - VKnots.SetValue(d+1,_KnotV[i+1]); - VMults.SetValue(d+1,c); - break; - } - } - - /*cout << "UKnots: " << endl; - for(int i=0; i CornerIndex; - std::vector Pointdistance; - std::vector::iterator vec_it; - std::vector ::iterator pnt_it; - - //Get BoundariesIndex and BoundariesPoints and extract it to v_neighbour - algo.GetMeshBorders(BoundariesIndex); - algo.GetMeshBorders(BoundariesPoints); - std::list< std::vector >::iterator bInd = BoundariesIndex.begin(); - std::list< std::vector >::iterator bPnt = BoundariesPoints.begin(); - std::vector v_neighbour = *bInd; - std::vector v_pnts = *bPnt; - - Base::BoundBox3f BoundBox = ParameterMesh.GetBoundBox(); - - //Resize the needed arrays - NumOfOuterPoints = v_neighbour.size()-1; - BoundariesX.resize(NumOfOuterPoints); - BoundariesY.resize(NumOfOuterPoints); - UnparamBoundariesX.resize(NumOfOuterPoints); - UnparamBoundariesY.resize(NumOfOuterPoints); - UnparamBoundariesZ.resize(NumOfOuterPoints); - std::vector nei_tmp(NumOfOuterPoints); - std::vector pnts_tmp(NumOfOuterPoints); - - - //Look for corner points - std::cout << "Looking for corners..." << std::endl; - CornerIndex.push_back(FindCorner(BoundBox.MinX,BoundBox.MinY,v_neighbour,v_pnts)); //FindCorner(Parameter1, Parameter2, neighbour_list, mesh) - CornerIndex.push_back(FindCorner(BoundBox.MaxX,BoundBox.MinY,v_neighbour,v_pnts)); - CornerIndex.push_back(FindCorner(BoundBox.MaxX,BoundBox.MaxY,v_neighbour,v_pnts)); - CornerIndex.push_back(FindCorner(BoundBox.MinX,BoundBox.MaxY,v_neighbour,v_pnts)); - - //Redo the list, start from (0,0), we are using the arrays in nei_tmp and pnts_tmp - vec_it = find(v_neighbour.begin(),v_neighbour.end(),CornerIndex[0]); - pnt_it = find(v_pnts.begin(), v_pnts.end(), LocalMesh.GetPoint(CornerIndex[0])); - for (unsigned int i = 0; i < v_neighbour.size()-1; i++) - { - nei_tmp[i] = *vec_it; - pnts_tmp[i] = *pnt_it; - UnparamBoundariesX[i] = (*pnt_it).x; - UnparamBoundariesY[i] = (*pnt_it).y; - UnparamBoundariesZ[i] = (*pnt_it).z; - ++vec_it; - ++pnt_it; - if (vec_it == v_neighbour.end()-1) - { - vec_it = v_neighbour.begin(); - pnt_it = v_pnts.begin(); - a = i; - } - - - } - v_pnts.clear(); - v_pnts = pnts_tmp; - - std::cout << "Parametirizing..." << std::endl; - //Parameter the boundaries - - //Parameter the _ Boundaries - //v_handle = CornerIndex[0]; - double totaldistance = 0; - unsigned int g = 0; - unsigned int temp1 = g; - unsigned int temp2 = g; - do //Get distance first - { - distance = sqrt(((v_pnts[g+1][0] - v_pnts[g][0])*(v_pnts[g+1][0] - v_pnts[g][0])) - + ((v_pnts[g+1][1] - v_pnts[g][1])*(v_pnts[g+1][1] - v_pnts[g][1]))); - Pointdistance.push_back(distance); - totaldistance += distance; - g++; - } - while ((vec_it = find(CornerIndex.begin(), CornerIndex.end(), nei_tmp[g])) == CornerIndex.end()); - - //Secure current g-counter and reinitialize g-counter to initial value - temp1 = g; - g = temp2; - - //Parameter the first point, fill up the list we are using - pnts_tmp[g][0] = 0.0f, pnts_tmp[g][1] = 0.0f; - BoundariesX[g] = pnts_tmp[g][0], BoundariesY[g] = pnts_tmp[g][1]; - g++; - for (unsigned int i = 0; i < Pointdistance.size() - 1;i++) - { - //Parametirizing - //0 < X < 1, Y = 0.0, Z = don't care lalalala - pnts_tmp[g][0] = (Pointdistance[i]/totaldistance)+pnts_tmp[g-1][0], pnts_tmp[g][1] = 0.0f; - BoundariesX[g] = pnts_tmp[g][0], BoundariesY[g] = pnts_tmp[g][1]; - g++; - } - - //Secure the counters and reinitialize the things we needed - g = temp1; - temp2 = g; - Pointdistance.clear(); - totaldistance = 0; - - //Parameter the -| boundary - do //Get distance first - { - distance = sqrt(((v_pnts[g+1][0] - v_pnts[g][0])*(v_pnts[g+1][0] - v_pnts[g][0])) - + ((v_pnts[g+1][1] - v_pnts[g][1])*(v_pnts[g+1][1] - v_pnts[g][1]))); - Pointdistance.push_back(distance); - totaldistance += distance; - g++; - } - while ((vec_it = find(CornerIndex.begin(), CornerIndex.end(), nei_tmp[g])) == CornerIndex.end()); - - //Secure current g-counter and reinitialize g-counter to initial value - temp1 = g; - g = temp2; - pnts_tmp[g][0] = 1.0f, pnts_tmp[g][1] = 0.0f; - BoundariesX[g] = pnts_tmp[g][0], BoundariesY[g] = pnts_tmp[g][1]; - g++; - for (unsigned int i = 0; i < Pointdistance.size() - 1;i++) - { - //Parametirizing - //X = 1, 0 < Y < 1, Z = don't care lalalala - pnts_tmp[g][0] = 1.0f, pnts_tmp[g][1] = (Pointdistance[i]/totaldistance)+pnts_tmp[g-1][1]; - BoundariesX[g] = pnts_tmp[g][0], BoundariesY[g] = pnts_tmp[g][1]; - g++; - } - - //Secure the counters and reinitialize´the things we needed - g = temp1; - temp2 = g; - Pointdistance.clear(); - totaldistance = 0; - - //Parameter the - boundary - do //Get distance first - { - distance = sqrt(((v_pnts[g+1][0] - v_pnts[g][0])*(v_pnts[g+1][0] - v_pnts[g][0])) - + ((v_pnts[g+1][1] - v_pnts[g][1])*(v_pnts[g+1][1] - v_pnts[g][1]))); - Pointdistance.push_back(distance); - totaldistance += distance; - g++; - } - while ((vec_it = find(CornerIndex.begin(), CornerIndex.end(), nei_tmp[g])) == CornerIndex.end()); - - //Secure current g-counter and reinitialize g-counter to initial value - temp1 = g; - g = temp2; - pnts_tmp[g][0] = 1.0f, pnts_tmp[g][1] = 1.0f; - float prev = pnts_tmp[g][0]; - BoundariesX[g] = pnts_tmp[g][0], BoundariesY[g] = pnts_tmp[g][1]; - g++; - for (unsigned int i = 0; i < Pointdistance.size() - 1;i++) - { - //Parametirizing - //0 < X < 1,Y = 1, Z = don't care lalalala - pnts_tmp[g][0] = (Pointdistance[i]/totaldistance)+prev, pnts_tmp[g][1] = 1.0f; - prev = pnts_tmp[g][0]; - pnts_tmp[g][0] = 2.0f - pnts_tmp[g][0]; - BoundariesX[g] = pnts_tmp[g][0], BoundariesY[g] = pnts_tmp[g][1]; - g++; - } - - //Secure the counters and reinitialize´the things we needed - g = temp1; - temp2 = g; - Pointdistance.clear(); - totaldistance = 0; - - //Parameter the |- boundary - do //Get distance first - { - distance = sqrt(((v_pnts[g+1][0] - v_pnts[g][0])*(v_pnts[g+1][0] - v_pnts[g][0])) - + ((v_pnts[g+1][1] - v_pnts[g][1])*(v_pnts[g+1][1] - v_pnts[g][1]))); - Pointdistance.push_back(distance); - totaldistance += distance; - g++; - if (g+1 == v_pnts.size()) - { - distance = sqrt(((v_pnts[0][0] - v_pnts[g][0])*(v_pnts[0][0] - v_pnts[g][0])) - + ((v_pnts[0][1] - v_pnts[g][1])*(v_pnts[0][1] - v_pnts[g][1]))); - Pointdistance.push_back(distance); - totaldistance += distance; - break; - } - } - while ((vec_it = find(CornerIndex.begin(), CornerIndex.end(), nei_tmp[g])) == CornerIndex.end()); - - //Secure current g-counter and reinitialize g-counter to initial value - temp1 = g; - g = temp2; - pnts_tmp[g][0] = 0.0f, pnts_tmp[g][1] = 1.0f; - prev = pnts_tmp[g][1]; - BoundariesX[g] = pnts_tmp[g][0], BoundariesY[g] = pnts_tmp[g][1]; - g++; - for (unsigned int i = 0; i < Pointdistance.size() - 1;i++) - { - //Parametirizing - //0 < X < 1, Y = 0, Z = don't care lalalala - pnts_tmp[g][0] = 0.0, pnts_tmp[g][1] = (Pointdistance[i]/totaldistance)+prev; - prev = pnts_tmp[g][1]; - pnts_tmp[g][1] = 2.0f - pnts_tmp[g][1]; - BoundariesX[g] = pnts_tmp[g][0], BoundariesY[g] = pnts_tmp[g][1]; - g++; - } - - //Secure the counters and reinitialize´the things we needed - g = temp1; - temp2 = g; - Pointdistance.clear(); - totaldistance = 0; - - ParameterX.resize(NumOfOuterPoints); - ParameterY.resize(NumOfOuterPoints); - int count = 0; - NumOfInnerPoints = NumOfPoints - NumOfOuterPoints; - mapper.resize(NumOfPoints); - MeshCore::MeshPointIterator v_it(LocalMesh); - a = 0; - int b = 0; - for (v_it.Begin(); !v_it.EndReached(); ++v_it) //For all points... - { - if ((vec_it = find(nei_tmp.begin(), nei_tmp.end(), v_it.Position())) != nei_tmp.end()) //...is it boundary? - { - //Yes - ParameterX[count] = pnts_tmp[int(vec_it-nei_tmp.begin())][0]; - ParameterY[count] = pnts_tmp[int(vec_it-nei_tmp.begin())][1]; - mapper[v_it.Position()] = a+NumOfInnerPoints; - a++, count++; - } - else - { - //No - mapper[v_it.Position()] = b; - b++; - } - } -} -/*! \brief Parameterizing the Inner Points - - This function will parameterize the inner points. Using the algorithm based on paper from - Michael S. Floater, published in Computer Aided Design 14(1997) page 231 - 250, - entitled Parametrization and smooth approximation of surface triangulation -*/ -void Approximate::ParameterInnerPoints() -{ - std::cout << "Computing the parameter for the inner points..." << std::endl; - MeshCore::MeshPointIterator v_it(LocalMesh); - MeshCore::MeshAlgorithm algo(LocalMesh); - MeshCore::MeshRefPointToPoints vv_it(LocalMesh); - MeshCore::MeshRefPointToFacets vf_it(LocalMesh); - std::set PntNei; - std::set FacetNei; - ublas::compressed_matrix Lambda(NumOfInnerPoints, NumOfPoints); - int count = 0; - - std::cout << "Prepping the Lambda" << std::endl; - std::list< std::vector >::iterator bInd = BoundariesIndex.begin(); - std::vector neiIndexes = *bInd; - std::vector ::iterator vec_it; - for (v_it.Begin(); !v_it.EndReached(); ++v_it) - { - if ((vec_it = find(neiIndexes.begin(), neiIndexes.end(), v_it.Position())) == neiIndexes.end()) - { - - std::vector NeiPnts; - std::vector nei; - std::vector::iterator nei_it; - PntNei = vv_it[v_it.Position()]; - FacetNei = vf_it[v_it.Position()]; - ReorderNeighbourList(PntNei,FacetNei,nei,v_it.Position()); - std::vector Angle; - std::vector Magnitude; - Base::Vector3f CurrentPoint(*v_it); - double TotAngle = 0; - unsigned int NumOfNeighbour = PntNei.size(); - unsigned int i = 0; - //Angle and magnitude calculations for projection. - //With respect to CurrentPoint - while (i < NumOfNeighbour) - { - if (i+1 != NumOfNeighbour) - { - Base::Vector3f CurrentNeighbour(LocalMesh.GetPoint(nei[i])); - Base::Vector3f NextNeighbour(LocalMesh.GetPoint(nei[i+1])); - double ang = CalcAngle(CurrentNeighbour, CurrentPoint, NextNeighbour); - double magn = sqrt((CurrentNeighbour - CurrentPoint) * (CurrentNeighbour - CurrentPoint)); - Angle.push_back(ang); - Magnitude.push_back(magn); - TotAngle += ang; - i++; - } - else - { - Base::Vector3f CurrentNeighbour(LocalMesh.GetPoint(nei[i])); - Base::Vector3f NextNeighbour(LocalMesh.GetPoint(nei[0])); - double ang = CalcAngle(CurrentNeighbour, CurrentPoint, NextNeighbour); - double magn = sqrt((CurrentNeighbour - CurrentPoint) * (CurrentNeighbour - CurrentPoint)); - Angle.push_back(ang); - Magnitude.push_back(magn); - TotAngle += ang; - i++; - } - - } - //Projection - //Current point is (0,0), First neighbour is on the X-Axis (y = 0), all other are projected - //depending on angle and magnitude - Base::Vector3f CurrentNeighbour(Magnitude[0],0.0,0.0); - NeiPnts.push_back(CurrentNeighbour); - double alpha = 0; - unsigned int k = 0; - for (unsigned int i = 1; i < NumOfNeighbour; i++) - { - alpha = alpha + ((2 * D_PI * Angle[i-1]) / TotAngle); - double x_pnt = Magnitude[i] * cos(alpha), y_pnt = Magnitude[i] * sin(alpha); - Base::Vector3f NewPoint(x_pnt,y_pnt,0.0); - NeiPnts.push_back(NewPoint); - ++k; - - } - k = 0; - //Preparing the needed matrix for iterating - std::vector< std::vector > Mu(NumOfNeighbour, std::vector(NumOfNeighbour, 0.0)); //Mu Matrix - std::vector< std::vector > MMatrix(2, std::vector(2,0.0)); //for the solver - std::vector bMatrix(2,0.0); - std::vector lMatrix(2,0.0); - if (NumOfNeighbour > 3) //if NumOfNeighbour > 3... - { - for (k = 0; k < NumOfNeighbour;k++) //...for all neighbours... - { - for (unsigned int l = k+1; l < NumOfNeighbour+k; l++) //...another iterator iterate through other neighbour - { - MMatrix[0][0] = NeiPnts[(unsigned int)fmod((double)l,(double)NumOfNeighbour)][0] - - NeiPnts[(unsigned int)fmod((double)l-1,(double)NumOfNeighbour)][0]; - MMatrix[1][0] = NeiPnts[(unsigned int)fmod((double)l,(double)NumOfNeighbour)][1] - - NeiPnts[(unsigned int)fmod((double)l-1,(double)NumOfNeighbour)][1]; - MMatrix[0][1] = NeiPnts[k][0]; - MMatrix[1][1] = NeiPnts[k][1]; - - bMatrix[0] = -NeiPnts[(unsigned int)fmod((double)l-1,(double)NumOfNeighbour)][0]; - bMatrix[1] = -NeiPnts[(unsigned int)fmod((double)l-1,(double)NumOfNeighbour)][1]; - - if (det2(MMatrix) != 0) - { - CramerSolve(MMatrix, bMatrix, lMatrix); //Solve it - if (lMatrix[0] <= 1.00001f && lMatrix[0] >= 0.0f && lMatrix[1] > 0.0f) //Condition for a solution - { - unsigned int r = (unsigned int)fmod((double)l-1,(double)NumOfNeighbour); - MMatrix[0][0] = NeiPnts[k][0] - - NeiPnts[(unsigned int)fmod((double)l,(double)NumOfNeighbour)][0]; - MMatrix[1][0] = NeiPnts[k][1] - - NeiPnts[(unsigned int)fmod((double)l,(double)NumOfNeighbour)][1]; - MMatrix[0][1] = NeiPnts[(unsigned int)fmod((double)l-1,(double)NumOfNeighbour)][0] - - NeiPnts[(unsigned int)fmod((double)l,(double)NumOfNeighbour)][0]; - MMatrix[1][1] = NeiPnts[(unsigned int)fmod((double)l-1,(double)NumOfNeighbour)][1] - - NeiPnts[(unsigned int)fmod((double)l,(double)NumOfNeighbour)][1]; - - bMatrix[0] = -NeiPnts[(unsigned int)fmod((double)l,(double)NumOfNeighbour)][0]; - bMatrix[1] = -NeiPnts[(unsigned int)fmod((double)l,(double)NumOfNeighbour)][1]; - CramerSolve(MMatrix, bMatrix, lMatrix); //Solve it - - Mu[k][k] = fabs(lMatrix[0]); //Solution found, fill up the Mu - Mu[r][k] = fabs(lMatrix[1]); - if ((unsigned int)fmod((double)r,(double)NumOfNeighbour)+1 == NumOfNeighbour) - Mu[0][k] = 1 -lMatrix[0] - lMatrix[1]; - else - Mu[(unsigned int)fmod((double)r,(double)NumOfNeighbour)+1][k] = 1 -lMatrix[0] - lMatrix[1]; - break; - - } - } - } - } - //Fill in the lambda - /*for(int j = 0; j < NumOfNeighbour; j++) //quick checker, if any bug comes out, one of - { //possible bugspawn is here - double sum = 0; - for(int k = 0; k < NumOfNeighbour; k++) - sum += Mu[k][j]; - - if(sum < 0.9999 || sum > 1.0001) - { - std::cout << "Mu is not correct.\nSum: " << sum << - "\nCount: " << count << "\nNumOfNeighbour: " << NumOfNeighbour << std::endl; - getchar(); - } - - }*/ - for (unsigned int j = 0; j < NumOfNeighbour; j++) - { - double sum = 0; - for (unsigned int k = 0; k < NumOfNeighbour; k++) - sum += Mu[j][k]; - - Lambda(count,mapper[nei[j]]) = sum/NumOfNeighbour; - } - count++; - } - else if (NumOfNeighbour == 3) //If NumOfNeighbour == 3... - { - Base::Vector3f Point1(NeiPnts[0]); - Base::Vector3f Point2(NeiPnts[1]); - Base::Vector3f Point3(NeiPnts[2]); - Base::Vector3f Zeroes(0,0,0); - double A = AreaTriangle(Point1,Point2,Point3); - - Lambda(count,mapper[nei[0]]) = - AreaTriangle(Zeroes,Point2,Point3) / A; - - Lambda(count,mapper[nei[1]]) = - AreaTriangle(Point1,Zeroes,Point3) / A; - - Lambda(count,mapper[nei[2]]) = - AreaTriangle(Point1,Point2,Zeroes) / A; - - count++; - } - else //Can an inside point have less than 3 neighbours...? - { - throw Base::RuntimeError("Something's wrong here. Less than 3 Neighbour"); - } - } - } - - //Now, we split the lambda matrix - //Using the compressed matrix class from boost - std::cout << "Splitting the lambdas..." << std::endl; - ublas::compressed_matrix, ublas::unbounded_array > - UpperTerm(NumOfInnerPoints, NumOfInnerPoints); - ublas::compressed_matrix OutLambda(NumOfInnerPoints, NumOfOuterPoints); - //We need to extract this columnwise, and (i,j) is a row-major style of numbering... - //Also, later we need to I - Upperterm, I := IdentityMatrix, this will also be done in this step - for (int i = 0; i < NumOfInnerPoints; i++) - { - for (int j = 0; j < NumOfInnerPoints; j++) - { - if (Lambda(i,j) != 0) - UpperTerm(i,j) = -Lambda(i,j); - else if (i == j) - UpperTerm(i,j) = 1.0 - Lambda(i,j); - } - } - - for (int j = NumOfInnerPoints, k = 0; j < NumOfPoints; j++, k++) - { - for (int i = 0; i < NumOfInnerPoints; i++) - { - if (Lambda(i,j) != 0) - OutLambda(i,k) = Lambda(i,j); - } - } - - //Result Storage - ublas::vector xResult(NumOfInnerPoints); - ublas::vector MultResult(NumOfInnerPoints); - ublas::vector yResult(NumOfInnerPoints); - - ofstream anOutputFile; - anOutputFile.open("c:/approx_param_log.txt"); - anOutputFile << 1 << endl; - //Solving the X Term - std::cout << "Solving the X Term..." << std::endl; - //atlas::gemm and atlas::gemv can't work with sparse matrices it seems, therefore using axpy_prod - ublas::axpy_prod(OutLambda, ParameterX, MultResult); - anOutputFile << 2 << endl; - bindings::umfpack::umf_solve (UpperTerm, xResult,MultResult ); //umfpack to solve sparse matrices equations - anOutputFile << 3 << endl; - //Solving the Y Term - std::cout << "Solving the Y Term..." << std::endl; - ublas::axpy_prod(OutLambda, ParameterY, MultResult); - anOutputFile << 4 << endl; - bindings::umfpack::umf_solve (UpperTerm, yResult, MultResult); - anOutputFile << 5 << endl; - std::cout << "Replacing the results.." << std::endl; - - - - //Another counter, temporary storage for old ParameterX and ParameterY, and resizing to include ALL points now - unsigned int s = 0; - unsigned int b = 0; - - ublas::vector tempox = ParameterX; - ublas::vector tempoy = ParameterY; - ParameterX.clear(), ParameterX.resize(NumOfPoints); - ParameterY.clear(), ParameterY.resize(NumOfPoints); - UnparamX.resize(NumOfPoints), UnparamY.resize(NumOfPoints),UnparamZ.resize(NumOfPoints); - //Reextract the boundaries list - anOutputFile << 6 << endl; - std::vector boundarieslist = *bInd; - - anOutputFile << 7 << endl; - - - - /**************************/ - MeshParam = LocalMesh; - MeshCore::MeshPointArray pntArr= MeshParam.GetPoints(); - MeshCore::MeshFacetArray fctArr= MeshParam.GetFacets(); - /**************************/ - - - for (v_it.Begin(); !v_it.EndReached(); ++v_it) - { - anOutputFile << 0 << endl; - //Inner Points goes into the beginning of the list - if ((vec_it = find(boundarieslist.begin(), boundarieslist.end(), v_it.Position())) == boundarieslist.end()) - { - ParameterX[s] = xResult[s]; - ParameterY[s] = yResult[s]; - - pntArr[v_it.Position()].x = ParameterX[s]; - pntArr[v_it.Position()].y = ParameterY[s]; - pntArr[v_it.Position()].z = 0; - - UnparamX[s] = LocalMesh.GetPoint(v_it.Position())[0]; - UnparamY[s] = LocalMesh.GetPoint(v_it.Position())[1]; - UnparamZ[s] = LocalMesh.GetPoint(v_it.Position())[2]; - s++; - } - //Boundaries goes into the end of the list - else - { - ParameterX[NumOfInnerPoints+b] = tempox[b]; - ParameterY[NumOfInnerPoints+b] = tempoy[b]; - - pntArr[v_it.Position()].x = ParameterX[NumOfInnerPoints+b]; - pntArr[v_it.Position()].y = ParameterY[NumOfInnerPoints+b]; - pntArr[v_it.Position()].z = 0; - - UnparamX[NumOfInnerPoints+b] = LocalMesh.GetPoint(v_it.Position())[0]; - UnparamY[NumOfInnerPoints+b] = LocalMesh.GetPoint(v_it.Position())[1]; - UnparamZ[NumOfInnerPoints+b] = LocalMesh.GetPoint(v_it.Position())[2]; - b++; - } - } - - anOutputFile << 8 << endl; - MeshParam.Assign(pntArr,fctArr); - anOutputFile << 9 << endl; - - std::cout << "DONE" << std::endl; - std::cout << "Information about the meshes:-" << std::endl; - std::cout << "Number of Points: " << NumOfPoints << std::endl; - std::cout << "Number of Inner Points: " << NumOfInnerPoints << std::endl; - std::cout << "Number of Outer Points: " << NumOfOuterPoints << std::endl; - //clear the mesh, we will continue working with the lists we have made - ParameterMesh.Clear(); - anOutputFile << 10 << endl; - LocalMesh.Clear(); - anOutputFile << 11 << endl; - anOutputFile.close(); - -} - - -/*! \brief Main Error Approximations routine - - This function will be ended once max_err < tolerance -*/ -void Approximate::ErrorApprox() -{ - ofstream anOutputFile; - anOutputFile.open("c:/approx_param_log.txt"); - - anOutputFile << "Begin constructing NURB for first pass" << std::endl; - double max_err = 0; - bool ErrThere = true; //for breaking the while - int h = 0; - int cnt = 0; - double av = 0, c2 = 0; - double lam; - - anOutputFile << "Constructing" << std::endl; - ublas::matrix C_Temp(NumOfPoints,3); - anOutputFile << "C_Temp successfully constructed" << std::endl; - //Time saving... C_Temp matrix is constant for all time - - anOutputFile << "number of points: " << NumOfPoints << std::endl; - std::vector err_w(NumOfPoints); - anOutputFile << "checkpoint 1 " << std::endl; - for (int i=1; i B_Matrix(NumOfPoints,(MainNurb.MaxU+1)*(MainNurb.MaxV+1)); - anOutputFile << "********************************" << endl; - anOutputFile << "B_Matrix successfully constructed" << std::endl; - anOutputFile << "Preparing B-Matrix..." << std::endl; - - std::vector N_u(MainNurb.MaxU+1, 0.0); - std::vector N_v(MainNurb.MaxV+1, 0.0); - std::vector TempU(MainNurb.DegreeU+1, 0.0); - std::vector TempV(MainNurb.DegreeV+1, 0.0); - std::vector swapDegreeU(MainNurb.DegreeU+1, 0.0); - std::vector swapDegreeV(MainNurb.DegreeV+1, 0.0); - std::vector swapV(MainNurb.MaxV+1, 0.0); - std::vector swapU(MainNurb.MaxU+1, 0.0); - - for (int i = 0; i < NumOfPoints; i++) - { - std::vector N_u(MainNurb.MaxU+1, 0.0); - std::vector N_v(MainNurb.MaxV+1, 0.0); - std::vector TempU(MainNurb.DegreeU+1, 0.0); - std::vector TempV(MainNurb.DegreeV+1, 0.0); - - int j1 = FindSpan(MainNurb.MaxU, MainNurb.DegreeU, ParameterX[i], MainNurb.KnotU); - int j2 = FindSpan(MainNurb.MaxV, MainNurb.DegreeV, ParameterY[i], MainNurb.KnotV); - - - Basisfun(j1,ParameterX[i], MainNurb.DegreeU, MainNurb.KnotU, TempU); - Basisfun(j2,ParameterY[i], MainNurb.DegreeV, MainNurb.KnotV, TempV); - - for (int k = j1 - MainNurb.DegreeU, s = 0; k < j1+1; k++, s++) - N_u[k] = TempU[s]; - for (int k = j2 - MainNurb.DegreeV, s = 0; k < j2+1; k++, s++) - N_v[k] = TempV[s]; - - for (int j = 0; j <= MainNurb.MaxV; j++) - { - for (int h = 0; h <= MainNurb.MaxU; h++) - { - //double result = N_u[h] * N_v[j]; - B_Matrix(i,(j*(MainNurb.MaxU+1))+h) = sqrt(err_w[i]) * N_u[h] * N_v[j]; - } - } - } - - for (unsigned int i = 0; i < UnparamX.size(); ++i) - { - C_Temp(i,0) = sqrt(err_w[i])*UnparamX[i]; - C_Temp(i,1) = sqrt(err_w[i])*UnparamY[i]; - C_Temp(i,2) = sqrt(err_w[i])*UnparamZ[i]; - } - - ublas::matrix G_Matrix((MainNurb.MaxU+1)*(MainNurb.MaxV+1),(MainNurb.MaxU+1)*(MainNurb.MaxV+1)); - ublas::matrix C_Tempo((MainNurb.MaxU+1)*(MainNurb.MaxV+1),3); - atlas::gemm(CblasTrans, CblasNoTrans, 1.0, B_Matrix,C_Temp,0.0,C_Tempo); - atlas::gemm(CblasTrans,CblasNoTrans,1.0,B_Matrix,B_Matrix,0.0,G_Matrix); //Multiplication with Boost bindings - //to ATLAS's bindings to LAPACK - B_Matrix.resize(1,1,false); - B_Matrix.clear(); - - anOutputFile << "Preparing the A_Matrix" << std::endl; - //ublas::matrix G_Matrix((MainNurb.MaxU+1)*(MainNurb.MaxV+1),(MainNurb.MaxU+1)*(MainNurb.MaxV+1)); - ublas::compressed_matrix, ublas::unbounded_array > - A_Matrix((MainNurb.MaxU+1)*(MainNurb.MaxV+1),(MainNurb.MaxU+1)*(MainNurb.MaxV+1)); - anOutputFile << "Multiply..." << std::endl; - - anOutputFile << "Euclidean Norm" << std::endl; - A_Matrix = G_Matrix; - - if(cnt == 0) - lam = 10*ublas::norm_frobenius(G_Matrix); - else - lam /= 2; - - G_Matrix.resize(1,1, false); - G_Matrix.clear(); - ublas::compressed_matrix E_Matrix((MainNurb.MaxU+1)*(MainNurb.MaxV+1), (MainNurb.MaxU+1)*(MainNurb.MaxV+1)); - anOutputFile << "E_Matrix successfully constructed" << std::endl; - anOutputFile << "Smoothing..." << std::endl; - eFair2(E_Matrix); - - if(cnt == 0){ - lam = lam / ublas::norm_frobenius(E_Matrix); - } - - ++cnt; - - anOutputFile << "lam: " << lam << std::endl; - A_Matrix = A_Matrix + (E_Matrix*lam); - - //Destroying the unneeded matrix - E_Matrix.resize(1,1,false); - E_Matrix.clear(); - anOutputFile << "Preparing the C_Matrix" << std::endl; - std::vector< std::vector > Solver; - std::vector TempoSolv((MainNurb.MaxU+1)*(MainNurb.MaxV+1)); - std::vector TempoB; - - anOutputFile << "Solving" << std::endl; - for (unsigned int i = 0; i < 3; i++) //Since umfpack can only solve Ax = B, where x and B are vectors - //instead of matrices... - { - //We will solve it column wise - for (int j = 0; j < (MainNurb.MaxU+1)*(MainNurb.MaxV+1); j++) - TempoB.push_back(C_Tempo(j,i)); //push back a column - - umfpack::umf_solve(A_Matrix,TempoSolv,TempoB); //solve - Solver.push_back(TempoSolv); //push back the solution - TempoB.clear(); - } - MainNurb.CntrlArray.clear(); - anOutputFile << "Loading the Control Points" << std::endl; - for (int i = 0; i < (MainNurb.MaxU+1)*(MainNurb.MaxV+1); i++) //now load the control points - { - MainNurb.CntrlArray.push_back(Solver[0][i]); //X - MainNurb.CntrlArray.push_back(Solver[1][i]); //Y - MainNurb.CntrlArray.push_back(Solver[2][i]); //Z - } - - std::vector ContrArr = MainNurb.CntrlArray; - - anOutputFile << "Cntrl Count" << std::endl; - anOutputFile << "U: " << MainNurb.MaxU + 1 << std::endl; - anOutputFile << "V: " << MainNurb.MaxV + 1 << std::endl; - - //ComputeError(h, 0.1, 0.1, max_err,av, c2, err_w); - - //anOutputFile << "Maximum error is " << max_err < &E_Matrix) -{ - ofstream anOutputFile; - anOutputFile.open("c:/approx_param_log_efair.txt"); - - int precision = 100; - std::vector U(precision+1, 0); - std::vector V(precision+1, 0); - for (int i = 1; i <= precision; i++) //Load U and V vectors uniformly, according to precision - { - U[i] = (1.0/(double)precision) + U[i-1]; - V[i] = (1.0/(double)precision) + V[i-1]; - } - U[precision] = 1.0; - V[precision] = 1.0; - precision = precision + 1; - - int mu = MainNurb.MaxKnotU; - int mv = MainNurb.MaxKnotV; - int k = mu-MainNurb.MaxU-2; - int l = mv-MainNurb.MaxV-2; - //Preparing the needed matrices - std::vector< std::vector > N_u0(precision, std::vector(mu-1-k,0.0)); - std::vector< std::vector > N_u1(precision, std::vector(mu-1-k,0.0)); - std::vector< std::vector > N_u2(precision, std::vector(mu-1-k,0.0)); - std::vector< std::vector > N_v0(precision, std::vector(mu-1-l,0.0)); - std::vector< std::vector > N_v1(precision, std::vector(mu-1-l,0.0)); - std::vector< std::vector > N_v2(precision, std::vector(mu-1-l,0.0)); - - std::vector A_1(precision,0.0); - std::vector B_1(precision,0.0); - std::vector C_1(precision,0.0); - std::vector A_2(precision,0.0); - std::vector B_2(precision,0.0); - std::vector C_2(precision,0.0); - - //Filling up the first six matrices - for (int i = 0; i < precision; i++) - { - std::vector< std::vector > dersU(2+1, std::vector(k+1)); - std::vector< std::vector > dersV(2+1, std::vector(k+1)); - int s = FindSpan(MainNurb.MaxU, k, U[i], MainNurb.KnotU); - DersBasisFuns(s, U[i], k, 2, MainNurb.KnotU, dersU); - for (int a = s-k, b = 0; a < s+1; a++, b++) - { - N_u0[i][a] = dersU[0][b]; - N_u1[i][a] = dersU[1][b]; - N_u2[i][a] = dersU[2][b]; - } - - s = FindSpan(MainNurb.MaxV, l, V[i], MainNurb.KnotV); - DersBasisFuns(s, V[i], l, 2, MainNurb.KnotV, dersV); - for (int a = s-l, b = 0; a < s+1; a++, b++) - { - N_v0[i][a] = dersV[0][b]; - N_v1[i][a] = dersV[1][b]; - N_v2[i][a] = dersV[2][b]; - } - - } - - double A,B,C; //Needed Variables for the Trapezoid-Integration - //Now lets fill up the E - for (int a = 0; a < MainNurb.MaxV+1; a++) - { - - //anOutputFile << "\r" << ceil(100.0*((double) a/(double) MainNurb.MaxV)) << "%" << " "; - for (int b = 0; b < MainNurb.MaxU+1; b++) - { - for (int c = 0; c < MainNurb.MaxV+1; c++) - { - - for (int d = 0; d < MainNurb.MaxU+1; d++) - { - for (int w = 0; w < precision; w++) //Fill up the last 6 Matrices from the first matrix - { - A_1[w] = (N_u2[w][b]*N_u2[w][d]); - A_2[w] = (N_v0[w][a]*N_v0[w][c]); - - B_1[w] = (N_u1[w][b]*N_u1[w][d]); - B_2[w] = (N_v1[w][a]*N_v1[w][c]); - - C_1[w] = (N_u0[w][b]*N_u0[w][d]); - C_2[w] = (N_v2[w][a]*N_v2[w][c]); - } - - - - //SehnenTrapezRegel - A = TrapezoidIntergration(U, A_1); - A *= TrapezoidIntergration(U, A_2); - - B = TrapezoidIntergration(U, B_1); - B *= TrapezoidIntergration(U, B_2); - - C = TrapezoidIntergration(U, C_1); - C *= TrapezoidIntergration(U, C_2); - - //result = A + 2*B + C; - E_Matrix((a*(MainNurb.MaxU+1))+b,(c*(MainNurb.MaxV+1))+d) = A + 2*B + C; - } - } - } - } - anOutputFile << std::endl; - anOutputFile.close(); -} - -/*! \brief This function will compute the current error -*/ -void Approximate::ComputeError(int &h, double eps_1, double eps_2, double &max_error, - double &av, double &c2, std::vector &err_w) -{ - std::cout << "Computing Error..." << std::endl; - av = 0; - c2 = 0; - max_error = 0; - for (int i = 0; i < NumOfPoints; i++) //For all points - { - - std::vector DerivNurb; - std::vector DerivUNurb; - std::vector DerivVNurb; - std::vector > Jac; - std::vector CurPoint; - CurPoint.push_back(ParameterX[i]); - CurPoint.push_back(ParameterY[i]); - std::vector V(2,0.0); - V[0] = CurPoint[0]; - V[1] = CurPoint[1]; - unsigned int j = 0; - PointNrbDerivate(MainNurb, DerivNurb); - PointNrbDerivate(DerivNurb[0], DerivUNurb); - PointNrbDerivate(DerivNurb[1], DerivVNurb); - int c = 0; - std::vector error; - std::vector EvalPoint; - - NrbDEval(MainNurb, DerivNurb, CurPoint, EvalPoint, Jac); - EvalPoint[0] = EvalPoint[0] - UnparamX[i]; - EvalPoint[1] = EvalPoint[1] - UnparamY[i]; - EvalPoint[2] = EvalPoint[2] - UnparamZ[i]; - ublas::matrix EvalMat(1, EvalPoint.size()); - for (j = 0; j < 3; j++) - EvalMat(0,j) = EvalPoint[j]; - for (j = 0; j < 2; j++) - { - ublas::matrix Holder(1, 1); - ublas::matrix JacPoint(Jac[j].size(), 1); - for (unsigned int k = 0; k < Jac[j].size(); k++) - JacPoint(k,0) = Jac[j][k]; - - atlas::gemm(CblasTrans, CblasTrans, 1.0, JacPoint,EvalMat,0.0,Holder); - double lam = ublas::norm_frobenius(JacPoint) * ublas::norm_frobenius(EvalMat); - if (lam == 0) - throw "Division by Zero in ComputeError function"; - lam = fabs(Holder(0,0) / lam); - error.push_back(lam); - } - //recheck the... thingy here... - while (((norm_frobenius(EvalMat) > eps_1) && ((error[0] > eps_2) || (error[1] > eps_2))) && c < 1000) //If somehow the eps is not reached... - { - c += 1; - std::vector p_uu; - std::vector p_uv; - std::vector p_vu; - std::vector p_vv; - ublas::matrix P_UU(3, 1); - ublas::matrix P_UV(3, 1); - ublas::matrix P_VU(3, 1); - ublas::matrix P_VV(3, 1); - ublas::matrix JacPoint1(Jac[0].size(), 1); - ublas::matrix JacPoint2(Jac[0].size(), 1); - PointNrbEval(p_uu,CurPoint,DerivUNurb[0]); - PointNrbEval(p_uv,CurPoint,DerivUNurb[1]); - PointNrbEval(p_vu,CurPoint,DerivVNurb[0]); - PointNrbEval(p_vv,CurPoint,DerivVNurb[1]); - - //Prepping the needed matrix - - for (unsigned int a = 0; a < Jac[0].size();a++) - JacPoint1(a,0) = Jac[0][a]; - for (unsigned int a = 0; a < Jac[1].size();a++) - JacPoint2(a,0) = Jac[1][a]; - for (unsigned int a = 0; a < 3; a++) - { - P_UU(a,0) = p_uu[a]; - P_UV(a,0) = p_uv[a]; - P_VU(a,0) = p_vu[a]; - P_VV(a,0) = p_vv[a]; - } - - std::vector< std::vector > J(2, std::vector(2,0.0)); - std::vector K(2,0.0); - //Newton iterate - //J[0][0] - ublas::matrix MultResult(1,1); - atlas::gemm(CblasTrans, CblasNoTrans, 1.0, JacPoint1,JacPoint1,0.0,MultResult); - J[0][0] += MultResult(0,0); - atlas::gemm(CblasNoTrans, CblasNoTrans, 1.0, EvalMat,P_UU,0.0,MultResult); - J[0][0] += MultResult(0,0); - - //J[0][1] - atlas::gemm(CblasTrans, CblasNoTrans, 1.0, JacPoint1,JacPoint2,0.0,MultResult); - J[0][1] += MultResult(0,0); - atlas::gemm(CblasNoTrans, CblasNoTrans, 1.0, EvalMat,P_UV,0.0,MultResult); - J[0][1] += MultResult(0,0); - - //J[1][0] - atlas::gemm(CblasTrans, CblasNoTrans, 1.0, JacPoint1,JacPoint2,0.0,MultResult); - J[1][0] += MultResult(0,0); - atlas::gemm(CblasNoTrans, CblasNoTrans, 1.0, EvalMat,P_VU,0.0,MultResult); - J[1][0] += MultResult(0,0); - - //J[1][1] - atlas::gemm(CblasTrans, CblasNoTrans, 1.0, JacPoint2,JacPoint2,0.0,MultResult); - J[1][1] += MultResult(0,0); - atlas::gemm(CblasNoTrans, CblasNoTrans, 1.0, EvalMat,P_VV,0.0,MultResult); - J[1][1] += MultResult(0,0); - - //K[0] - atlas::gemm(CblasNoTrans, CblasNoTrans, 1.0, EvalMat,JacPoint1,0.0,MultResult); - K[0] = (J[0][0]*V[0]) + (J[0][1]*V[1]) - MultResult(0,0); - - //K[1] - atlas::gemm(CblasNoTrans, CblasNoTrans, 1.0, EvalMat,JacPoint2,0.0,MultResult); - K[1] = (J[1][0]*V[0]) + (J[1][1]*V[1]) - MultResult(0,0); - - CramerSolve(J,K,V); - - if (V[0] < 0) - V[0] = 0; - else if (V[0] > 1) - V[0] = 1; - - if (V[1] < 0) - V[1] = 0; - else if (V[1] > 1) - V[1] = 1; - - if (c == 500) - { - V[0] = 0.5; - V[1] = 0.5; - } - //Reevaluate - error.clear(); - CurPoint[0] = V[0]; - CurPoint[1] = V[1]; - EvalPoint.clear(); - Jac.clear(); - NrbDEval(MainNurb, DerivNurb, CurPoint, EvalPoint, Jac); - EvalPoint[0] = EvalPoint[0] - UnparamX[i]; - EvalPoint[1] = EvalPoint[1] - UnparamY[i]; - EvalPoint[2] = EvalPoint[2] - UnparamZ[i]; - for (j = 0; j < 3; j++) - EvalMat(0,j) = EvalPoint[j]; - for (j = 0; j < 2; j++) - { - ublas::matrix Holder(1, 1); - ublas::matrix JacPoint(Jac[j].size(), 1); - for (unsigned int k = 0; k < Jac[j].size(); k++) - JacPoint(k,0) = Jac[j][k]; - - atlas::gemm(CblasTrans, CblasTrans, 1.0, JacPoint,EvalMat,0.0,Holder); - double lam = ublas::norm_frobenius(JacPoint) * ublas::norm_frobenius(EvalMat); - if (lam == 0) - throw "Division by Zero in ComputeError function"; - else - lam = fabs(Holder(0,0) / lam); - error.push_back(lam); - } - } - ParameterX[i] = V[0]; - ParameterY[i] = V[1]; - av += norm_frobenius(EvalMat); //Average Error - - err_w[i] = norm_frobenius(EvalMat); - - if (norm_frobenius(EvalMat) > max_error && c < 1000) - { - max_error = norm_frobenius(EvalMat); - h = i; - //if(max_error > (3*tolerance)) - // break; - - } - if (norm_frobenius(EvalMat) > tolerance) - c2++; //% of point's error still above tolerance - } - c2 /= NumOfPoints; - av /= NumOfPoints; - - std::cout << " DONE" << std::endl; -} - -/*! \brief Reparameterization after error computation -*/ -double Approximate::Reparam() -{ - MeshCore::MeshPointArray pntArr = MeshParam.GetPoints(); - MeshCore::MeshFacetArray fctArr = MeshParam.GetFacets(); - - double error = 0.0; - - std::cout << "Reparameterization..."; - for (int i = 0; i < NumOfPoints; i++) - { - std::vector DerivNurb; - std::vector p; - std::vector EvalPoint; - std::vector< std::vector > T; - std::vector< std::vector > A(2,std::vector(2,0.0)); - std::vector bt(2,0.0); - - p.push_back(ParameterX[i]); - p.push_back(ParameterY[i]); - PointNrbDerivate(MainNurb, DerivNurb); - NrbDEval(MainNurb, DerivNurb, p, EvalPoint, T); - - EvalPoint[0] = UnparamX[i] - EvalPoint[0]; - EvalPoint[1] = UnparamY[i] - EvalPoint[1]; - EvalPoint[2] = UnparamZ[i] - EvalPoint[2]; - - error += sqrt(EvalPoint[0]*EvalPoint[0] + EvalPoint[1]*EvalPoint[1] + EvalPoint[2]*EvalPoint[2]); - - for (int j = 0; j < 2; j++) - { - for (int k = 0; k < 2; k++) - { - std::vector JacHolder1(3, 0.0); - std::vector JacHolder2(3, 0.0); - std::vector Result(1, 0.0); - if (j == 0 && k == 0) - { - for (int l = 0; l < 3; l++) - { - JacHolder1[l] = T[0][l]; - JacHolder2[l] = T[0][l]; - } - cblas_dgemm(CblasRowMajor, CblasNoTrans, CblasNoTrans,1,1,3,1.0, - &JacHolder1[0],3,&JacHolder2[0],1,0.0,&Result[0], 1); - - A[j][k] = Result[0]; - } - else if (j == 1 && k == 1) - { - for (int l = 0; l < 3; l++) - { - JacHolder1[l] = T[1][l]; - JacHolder2[l] = T[1][l]; - } - cblas_dgemm(CblasRowMajor, CblasNoTrans, CblasNoTrans,1,1,3,1.0, - &JacHolder1[0],3,&JacHolder2[0],1,0.0,&Result[0], 1); - - A[j][k] = Result[0]; - } - else - { - for (int l = 0; l < 3; l++) - { - JacHolder1[l] = T[0][l]; - JacHolder2[l] = T[1][l]; - } - cblas_dgemm(CblasRowMajor, CblasNoTrans, CblasNoTrans,1,1,3,1.0, - &JacHolder1[0],3,&JacHolder2[0],1,0.0,&Result[0], 1); - - A[j][k] = Result[0]; - } - } - std::vector Resultant(1, 0.0); - std::vector BJacHolder(3, 0.0); - for (int l = 0; l < 3; l++) - BJacHolder[l] = T[j][l]; - cblas_dgemm(CblasRowMajor, CblasNoTrans, CblasNoTrans,1,1,3,1.0, - &EvalPoint[0],3,&BJacHolder[0],1,0.0,&Resultant[0], 1); - - bt[j] = Resultant[0]; - - } - - std::vector delt(2,0.0); - CramerSolve(A,bt,delt); - - //Reparam - if (ParameterX[i] + delt[0] <= 0) - ParameterX[i] = 0; - else if (ParameterX[i] + delt[0] >= 1) - ParameterX[i] = 1; - else ParameterX[i] += delt[0]; - - if (ParameterY[i] + delt[1] <= 0) - ParameterY[i] = 0; - else if (ParameterY[i] + delt[1] >= 1) - ParameterY[i] = 1; - else ParameterY[i] += delt[1]; - - } - - error /= NumOfPoints; - - MeshCore::MeshPointIterator v_it(MeshParam); - std::list< std::vector >::iterator bInd = BoundariesIndex.begin(); - std::vector boundarieslist = *bInd; - std::vector ::iterator vec_it; - int s=0; - int b=0; - for (v_it.Begin(); !v_it.EndReached(); ++v_it) - { - //Inner Points goes into the beginning of the list - if ((vec_it = find(boundarieslist.begin(), boundarieslist.end(), v_it.Position())) == boundarieslist.end()) - { - - pntArr[v_it.Position()].x = ParameterX[s]; - pntArr[v_it.Position()].y = ParameterY[s]; - s++; - } - //Boundaries goes into the end of the list - else - { - - pntArr[v_it.Position()].x = ParameterX[NumOfInnerPoints+b]; - pntArr[v_it.Position()].y = ParameterY[NumOfInnerPoints+b]; - - b++; - } - } - - - MeshParam.Assign(pntArr,fctArr); - std::cout << "DONE" << std::endl; - return error; -} - -/*! \brief Extend the Nurb - - Once error is computed and the generated nurb is still not satisfactory (i.e max_err > tolerance), this function will extend - the given Nurb by extending the Knot vectors by 2 and, because the degree is held constant, the control points -*/ -void Approximate::ExtendNurb(double c2, int h) -{ - std::cout << "Extending Knot Vector" << std::endl; - std::cout << "Two knot extension" << std::endl; - MainNurb.MaxU += 2; - MainNurb.MaxV += 2; - MainNurb.MaxKnotU += 2; - MainNurb.MaxKnotV += 2; - //U-V Knot Extension - ExtendKnot(ParameterX[h], MainNurb.DegreeU, MainNurb.MaxU, MainNurb.KnotU); - ExtendKnot(ParameterY[h], MainNurb.DegreeV, MainNurb.MaxV, MainNurb.KnotV); - -} - -/*! \brief Reorder the neighbour list - - This function will reorder the list in one-direction. Clockwise or counter clockwise is dependent on the - facet list and will not be checked by this function. (i.e the third vertex i.e vertex in first facet that - is not the CurIndex or the first neighbour in pnt[Ok, I am also lost with this... just debug and step to see what I mean...]) -*/ -void Approximate::ReorderNeighbourList(std::set &pnt, - std::set &face, std::vector &nei, unsigned long CurInd) -{ - MeshCore::MeshPointArray::_TConstIterator v_beg = LocalMesh.GetPoints().begin(); - MeshCore::MeshFacetArray::_TConstIterator f_beg = LocalMesh.GetFacets().begin(); - std::set::iterator pnt_it; - std::set::iterator face_it; - std::vector::iterator vec_it; - std::vector::iterator ulong_it; - unsigned long PrevIndex; - pnt_it = pnt.begin(); - face_it = face.begin(); - nei.push_back(v_beg[*pnt_it]._ulProp); //push back first neighbour - vec_it = nei.begin(); - PrevIndex = nei[0]; //Initialize PrevIndex - for (unsigned int i = 1; i < pnt.size(); i++) //Start - { - while (true) - { - std::vector facetpnt; - facetpnt.push_back(f_beg[*face_it]._aulPoints[0]); //push back into a vector for easier iteration - facetpnt.push_back(f_beg[*face_it]._aulPoints[1]); - facetpnt.push_back(f_beg[*face_it]._aulPoints[2]); - if ((ulong_it = find(facetpnt.begin(), facetpnt.end(), PrevIndex)) == facetpnt.end()) //if PrevIndex not found - { - //in current facet - ++face_it; //next face please - continue; - } - else - { - for (unsigned int k = 0 ; k < 3; k++) - { - //If current facetpnt[k] is not yet in nei_list AND it is not the CurIndex - if (((vec_it = find(nei.begin(), nei.end(), facetpnt[k])) == nei.end()) && facetpnt[k] != CurInd) - { - face.erase(face_it); //erase this face - nei.push_back(facetpnt[k]); //push back the index - PrevIndex = facetpnt[k]; //this index is now PrevIndex - face_it = face.begin(); //reassign the iterator - break; //end this for-loop - } - } - break; //end this while loop - } - } - } -} diff --git a/src/Mod/Cam/App/Approx.h b/src/Mod/Cam/App/Approx.h deleted file mode 100644 index d44dfc4415..0000000000 --- a/src/Mod/Cam/App/Approx.h +++ /dev/null @@ -1,134 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2007 Joachim Zettler * - * Copyright (c) 2007 Human Rezai * - * Copyright (c) 2007 Mohamad Najib Muhammad Noor - * * - * This file is part of the FreeCAD CAx development system. * - * * - * This library is free software; you can redistribute it and/or * - * modify it under the terms of the GNU Library General Public * - * License as published by the Free Software Foundation; either * - * version 2 of the License, or (at your option) any later version. * - * * - * This library is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * - * GNU Library General Public License for more details. * - * * - * You should have received a copy of the GNU Library General Public * - * License along with this library; see the file COPYING.LIB. If not, * - * write to the Free Software Foundation, Inc., 59 Temple Place, * - * Suite 330, Boston, MA 02111-1307, USA * - * * - ***************************************************************************/ -/**************APPROX.H********************* -*Class Approximate, inheriting from Routines -*Dependencies:- BOOST, ATLAS, UMFPACK, BLAS -* LAPACK -********************************************/ - -#ifndef APPROX_H -#define APPROX_H - -#ifndef NDEBUG //This is for faster matrix operations. In fact, some checks are turned off in the uBlas functions -#define NDEBUG -#endif -/*******MAIN INCLUDE*********/ -#include "routine.h" - -#include - -/*******BOOST********/ -#include - -/*****NAMESPACE******/ -using namespace boost::numeric; - -/*! \class Approximate - \brief The main class for the approximate routine - - Inheriting the Routines class defined in Routines.h, it takes a mesh structure and tolerance level as it's input parameter. - - As output, it gives out the following NURBS info:- - Control Points, Knot U, Knot V, Order U, Order V - - where Control Points, Knot U, Knot V are of type std::vectors, Order U and Order V of type int - - In this program, it will be directly converted into a topo surface from the given information - */ -class CamExport Approximate : protected Routines -{ -public: - Approximate(const MeshCore::MeshKernel &m, std::vector &_Cntrl, std::vector &_KnotU, std::vector &_KnotV, - int &_OrderU, int &_OrderV, double tol); - ~Approximate(); - MeshCore::MeshKernel MeshParam; - - GeomAdaptor_Surface aAdaptorSurface; -protected: - void ParameterBoundary(); - void ParameterInnerPoints(); - void ErrorApprox(); - void ApproxMain(); - double Reparam(); - void eFair2(ublas::compressed_matrix &E_Matrix); - void ComputeError(int &h, double eps_1, double eps_2, double &max_error, - double &av, double &c2, std::vector &err_w); - void ExtendNurb(double c2, int h); - void ReorderNeighbourList(std::set &pnt, - std::set &face, std::vector &nei,unsigned long CurInd); - //void RemakeList(std::vector &v_neighbour); - -private: - /** @brief Local Mesh */ - MeshCore::MeshKernel LocalMesh; //Local Mesh - /** @brief Parameterized Mesh */ - MeshCore::MeshKernel ParameterMesh; //Parameterized Mesh - ONLY USED FOR VISUALIZING TO CHECK FOR PARAMETERIZATION ERRORS - /** @brief total number of mesh-points */ - int NumOfPoints; //Info about the Mesh - /** @brief number of inner mesh-points */ - int NumOfInnerPoints; - /** @brief number of boundary mesh-points */ - int NumOfOuterPoints; - /** @brief error-tolerance */ - double tolerance; //error level - /** @brief Parametervalues in x-direction*/ - ublas::vector ParameterX; //Parameterized Coordinate Lists - /** @brief Parametervalues in y-direction*/ - ublas::vector ParameterY; - /** @brief Parametervalues of the boundary-points in x-direction*/ - ublas::vector BoundariesX; //Parametrized Boundaries' Coordinate List - /** @brief Parametervalues of the boundary-points in y-direction*/ - ublas::vector BoundariesY; - /** @brief Original Boundaries' Coordinate List in x-direction*/ - std::vector UnparamBoundariesX; //Original Boundaries' Coordinate List - /** @brief Original Boundaries' Coordinate List in y-direction*/ - std::vector UnparamBoundariesY; - /** @brief Original Boundaries' Coordinate List in z-direction*/ - std::vector UnparamBoundariesZ; - /** @brief Original Coordinate List in x-direction*/ - std::vector UnparamX; //Original Coordinate Lists - /** @brief Original Coordinate List in y-direction*/ - std::vector UnparamY; - /** @brief Original Coordinate List in z-direction*/ - std::vector UnparamZ; - - std::vector mapper; - /** @brief List of indices of the boundary points*/ - std::list< std::vector > BoundariesIndex; - /** @brief List of point-coordinates of the boundary points*/ - std::list< std::vector > BoundariesPoints; - - //NURBS - NURBS MainNurb; - - //Bounding box - double MinX; - double MaxX; - double MinY; - double MaxY; - -}; - -#endif /*APPROX_H DEFINED*/ - diff --git a/src/Mod/Cam/App/BRepAdaptor_CompCurve2.cxx b/src/Mod/Cam/App/BRepAdaptor_CompCurve2.cxx deleted file mode 100644 index 0edd0a739b..0000000000 --- a/src/Mod/Cam/App/BRepAdaptor_CompCurve2.cxx +++ /dev/null @@ -1,517 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2007 Joachim Zettler * - * Adapted by Joachim Zettler to use with a WireExplorer made * - * by Stephane Routelous * - * * - * This file is part of the FreeCAD CAx development system. * - * * - * This library is free software; you can redistribute it and/or * - * modify it under the terms of the GNU Library General Public * - * License as published by the Free Software Foundation; either * - * version 2 of the License, or (at your option) any later version. * - * * - * This library is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * - * GNU Library General Public License for more details. * - * * - * You should have received a copy of the GNU Library General Public * - * License along with this library; see the file COPYING.LIB. If not, * - * write to the Free Software Foundation, Inc., 59 Temple Place, * - * Suite 330, Boston, MA 02111-1307, USA * - * * - ***************************************************************************/ - -// - -#include "PreCompiled.h" - -#include "BRepAdaptor_CompCurve2.h" -#include -#include -#include -#include -#include -#include - -#include - -#include -#include -#include -#include -#include "WireExplorer.h" - -BRepAdaptor_CompCurve2::BRepAdaptor_CompCurve2() -{ -} - -BRepAdaptor_CompCurve2::BRepAdaptor_CompCurve2(const TopoDS_Wire& W, - const Standard_Boolean AC) -{ - Initialize(W, AC); -} - -BRepAdaptor_CompCurve2::BRepAdaptor_CompCurve2(const TopoDS_Wire& W, - const Standard_Boolean AC, - const Standard_Real First, - const Standard_Real Last, - const Standard_Real Tol) -{ - Initialize(W, AC, First, Last, Tol); -} - - void BRepAdaptor_CompCurve2::Initialize(const TopoDS_Wire& W, - const Standard_Boolean AC) -{ - Standard_Integer ii, NbEdge; - - TopoDS_Edge E; - - myWire = W; - WireExplorer wexp(myWire); - PTol = 0.0; - IsbyAC = AC; - - for (NbEdge=0, wexp.Init();wexp.More(); wexp.Next()) - if (! BRep_Tool::Degenerated(wexp.Current())) NbEdge++; - - if (NbEdge == 0) return; - - CurIndex = (NbEdge+1)/2; - myCurves = new BRepAdaptor_HArray1OfCurve(1,NbEdge); - myKnots = new (TColStd_HArray1OfReal) (1,NbEdge+1); - myKnots->SetValue(1, 0.); - - for (ii=0, wexp.Init();wexp.More(); wexp.Next()) { - E = wexp.Current(); - if (! BRep_Tool::Degenerated(E)) { - ii++; - myCurves->ChangeValue(ii).Initialize(E); - if (AC) { - myKnots->SetValue(ii+1, myKnots->Value(ii)); - myKnots->ChangeValue(ii+1) += - GCPnts_AbscissaPoint::Length(myCurves->ChangeValue(ii)); - } - else myKnots->SetValue(ii+1, (Standard_Real)ii); - } - } - - Forward = Standard_True; // Default; Led Edge Reverse will be counted backward. - if((NbEdge > 2) || ((NbEdge==2) && (!myWire.Closed())) ) { - TopAbs_Orientation Or = myCurves->Value(1).Edge().Orientation(); - Standard_Boolean B; - TopoDS_Vertex VI, VL; - B = TopExp::CommonVertex(myCurves->Value(1).Edge(), - myCurves->Value(2).Edge(), - VI); - VL = TopExp::LastVertex(myCurves->Value(1).Edge()); - if (VI.IsSame(VL)) { // We always keep the direction of the path - if (Or == TopAbs_REVERSED) - Forward = Standard_False; - } - else {// We always reverse the direction of path - if (Or != TopAbs_REVERSED) - Forward = Standard_False; - } - } - - TFirst = 0; - TLast = myKnots->Value(myKnots->Length()); - myPeriod = TLast - TFirst; - if (NbEdge == 1) { - Periodic = myCurves->Value(1).IsPeriodic(); - } - else { - Periodic = Standard_False; - } -} - - void BRepAdaptor_CompCurve2::Initialize(const TopoDS_Wire& W, - const Standard_Boolean AC, - const Standard_Real First, - const Standard_Real Last, - const Standard_Real Tol) -{ - Initialize(W, AC); - TFirst = First; - TLast = Last; - PTol = Tol; - - // Trim extreme curves. - Handle (BRepAdaptor_HCurve) HC; - Standard_Integer i1, i2; - Standard_Real f=TFirst, l=TLast, d; - i1 = i2 = CurIndex; - Prepare(f, d, i1); - Prepare(l, d, i2); - CurIndex = (i1+i2)/2; // Small optimization - if (i1==i2) { - if (l > f) - HC = Handle(BRepAdaptor_HCurve)::DownCast(myCurves->Value(i1).Trim(f, l, PTol)); - else - HC = Handle(BRepAdaptor_HCurve)::DownCast(myCurves->Value(i1).Trim(l, f, PTol)); - myCurves->SetValue(i1, HC->ChangeCurve()); - } - else { - const BRepAdaptor_Curve& c1 = myCurves->Value(i1); - const BRepAdaptor_Curve& c2 = myCurves->Value(i2); - Standard_Real k; - - k = c1.LastParameter(); - if (k>f) - HC = Handle(BRepAdaptor_HCurve)::DownCast(c1.Trim(f, k, PTol)); - else - HC = Handle(BRepAdaptor_HCurve)::DownCast(c1.Trim(k, f, PTol)); - myCurves->SetValue(i1, HC->ChangeCurve()); - - k = c2.FirstParameter(); - if (k<=l) - HC = Handle(BRepAdaptor_HCurve)::DownCast(c2.Trim(k, l, PTol)); - else - HC = Handle(BRepAdaptor_HCurve)::DownCast(c2.Trim(l, k, PTol)); - myCurves->SetValue(i2, HC->ChangeCurve()); - } -} - - -void BRepAdaptor_CompCurve2::SetPeriodic(const Standard_Boolean isPeriodic) -{ - if (myWire.Closed()) { - Periodic = isPeriodic; - } -} - - -const TopoDS_Wire& BRepAdaptor_CompCurve2::Wire() const -{ - return myWire; -} - - void BRepAdaptor_CompCurve2::Edge(const Standard_Real U, - TopoDS_Edge& E, - Standard_Real& UonE) const -{ - Standard_Real d; - Standard_Integer index = CurIndex; - UonE = U; - Prepare(UonE, d, index); - E = myCurves->Value(index).Edge(); -} - - Standard_Real BRepAdaptor_CompCurve2::FirstParameter() const -{ - return TFirst; -} - - Standard_Real BRepAdaptor_CompCurve2::LastParameter() const -{ - return TLast; -} - - GeomAbs_Shape BRepAdaptor_CompCurve2::Continuity() const -{ - if ( myCurves->Length() > 1) return GeomAbs_C0; - return myCurves->Value(1).Continuity(); -} - - Standard_Integer BRepAdaptor_CompCurve2::NbIntervals(const GeomAbs_Shape S) -{ - Standard_Integer NbInt, ii; - for (ii=1, NbInt=0; ii<=myCurves->Length(); ii++) - NbInt += myCurves->ChangeValue(ii).NbIntervals(S); - - return NbInt; -} - - void BRepAdaptor_CompCurve2::Intervals(TColStd_Array1OfReal& T, - const GeomAbs_Shape S) -{ - Standard_Integer ii, jj, kk, n; - Standard_Real f, F, delta; - - // First curve (direction of path edge) - n = myCurves->ChangeValue(1).NbIntervals(S); - Handle(TColStd_HArray1OfReal) Ti = new (TColStd_HArray1OfReal) (1, n+1); - myCurves->ChangeValue(1).Intervals(Ti->ChangeArray1(), S); - InvPrepare(1, f, delta); - F = myKnots->Value(1); - if (delta < 0) { - //reverse direction of path - for (kk=1,jj=Ti->Length(); jj>0; kk++, jj--) - T(kk) = F + (Ti->Value(jj)-f)*delta; - } - else { - for (kk=1; kk<=Ti->Length(); kk++) - T(kk) = F + (Ti->Value(kk)-f)*delta; - } - - // and the following - for (ii=2; ii<=myCurves->Length(); ii++) { - n = myCurves->ChangeValue(ii).NbIntervals(S); - if (n != Ti->Length()-1) Ti = new (TColStd_HArray1OfReal) (1, n+1); - myCurves->ChangeValue(ii).Intervals(Ti->ChangeArray1(), S); - InvPrepare(ii, f, delta); - F = myKnots->Value(ii); - if (delta < 0) { - //reverse direction of path - for (jj=Ti->Length()-1; jj>0; kk++, jj--) - T(kk) = F + (Ti->Value(jj)-f)*delta; - } - else { - for (jj=2; jj<=Ti->Length(); kk++, jj++) - T(kk) = F + (Ti->Value(jj)-f)*delta; - } - } -} - - - - Standard_Boolean BRepAdaptor_CompCurve2::IsClosed() const -{ - return myWire.Closed(); -} - - Standard_Boolean BRepAdaptor_CompCurve2::IsPeriodic() const -{ - return Periodic; - -} - - Standard_Real BRepAdaptor_CompCurve2::Period() const -{ - return myPeriod; -} - - gp_Pnt BRepAdaptor_CompCurve2::Value(const Standard_Real U) const -{ - Standard_Real u = U, d; - Standard_Integer index = CurIndex; - Prepare(u, d, index); - return myCurves->Value(index).Value(u); -} - - void BRepAdaptor_CompCurve2::D0(const Standard_Real U, - gp_Pnt& P) const -{ - Standard_Real u = U, d; - Standard_Integer index = CurIndex; - Prepare(u, d, index); - myCurves->Value(index).D0(u, P); -} - - void BRepAdaptor_CompCurve2::D1(const Standard_Real U, - gp_Pnt& P, - gp_Vec& V) const -{ - Standard_Real u = U, d; - Standard_Integer index = CurIndex; - Prepare(u, d, index); - myCurves->Value(index).D1(u, P, V); - V*=d; -} - - void BRepAdaptor_CompCurve2::D2(const Standard_Real U, - gp_Pnt& P, - gp_Vec& V1, - gp_Vec& V2) const -{ - Standard_Real u = U, d; - Standard_Integer index = CurIndex; - Prepare(u, d, index); - myCurves->Value(index).D2(u, P, V1, V2); - V1*=d; - V2 *= d*d; -} - - void BRepAdaptor_CompCurve2::D3(const Standard_Real U, - gp_Pnt& P,gp_Vec& V1, - gp_Vec& V2, - gp_Vec& V3) const -{ - Standard_Real u = U, d; - Standard_Integer index = CurIndex; - Prepare(u, d, index); - myCurves->Value(index).D3(u, P, V1, V2, V3); - V1*=d; - V2 *= d*d; - V3 *= d*d*d; -} - - gp_Vec BRepAdaptor_CompCurve2::DN(const Standard_Real U, - const Standard_Integer N) const -{ - Standard_Real u = U, d; - Standard_Integer index = CurIndex; - Prepare(u, d, index); - - return (myCurves->Value(index).DN(u, N) * Pow(d, N)); -} - - Standard_Real BRepAdaptor_CompCurve2::Resolution(const Standard_Real R3d) const -{ - Standard_Real Res = 1.e200, r; - Standard_Integer ii, L = myCurves->Length(); - for (ii=1; ii<=L; ii++) { - r = myCurves->Value(ii).Resolution(R3d); - if (r < Res) Res = r; - } - return Res; -} - - GeomAbs_CurveType BRepAdaptor_CompCurve2::GetType() const -{ - return GeomAbs_OtherCurve; //temporary -// if ( myCurves->Length() > 1) return GeomAbs_OtherCurve; -// return myCurves->Value(1).GetType(); -} - - gp_Lin BRepAdaptor_CompCurve2::Line() const -{ - return myCurves->Value(1).Line(); -} - - gp_Circ BRepAdaptor_CompCurve2::Circle() const -{ - return myCurves->Value(1).Circle(); -} - - gp_Elips BRepAdaptor_CompCurve2::Ellipse() const -{ - return myCurves->Value(1).Ellipse(); -} - - gp_Hypr BRepAdaptor_CompCurve2::Hyperbola() const -{ - return myCurves->Value(1).Hyperbola(); -} - - gp_Parab BRepAdaptor_CompCurve2::Parabola() const -{ - return myCurves->Value(1).Parabola(); -} - - Standard_Integer BRepAdaptor_CompCurve2::Degree() const -{ - return myCurves->Value(1).Degree(); -} - - Standard_Boolean BRepAdaptor_CompCurve2::IsRational() const -{ - return myCurves->Value(1).IsRational(); -} - - Standard_Integer BRepAdaptor_CompCurve2::NbPoles() const -{ - return myCurves->Value(1).NbPoles(); -} - - Standard_Integer BRepAdaptor_CompCurve2::NbKnots() const -{ - return myCurves->Value(1).NbKnots(); -} - - Handle(Geom_BezierCurve) BRepAdaptor_CompCurve2::Bezier() const -{ - return myCurves->Value(1).Bezier(); -} - - Handle(Geom_BSplineCurve) BRepAdaptor_CompCurve2::BSpline() const -{ - return myCurves->Value(1).BSpline(); -} - -//======================================================================= -//function : Prepare -//purpose : -// When the parameter is near a "node" we determine the law by -// function of the sign of Tol: -// - negative -> Law preceding the node. -// - positive -> Law following the node. -//======================================================================= - - void BRepAdaptor_CompCurve2::Prepare(Standard_Real& W, - Standard_Real& Delta, - Standard_Integer& CurIndex) const -{ - Standard_Real f,l, Wtest, Eps; - Standard_Integer ii; - if (W-TFirst < TLast-W) { Eps = PTol; } - else { Eps = -PTol;} - - - Wtest = W+Eps; //Offset to discriminate between nodes - if(Periodic){ - Wtest = ElCLib::InPeriod(Wtest, - 0, - myPeriod); - W = Wtest-Eps; - } - - // Index search - Standard_Boolean Trouve = Standard_False; - if (myKnots->Value(CurIndex) > Wtest) { - for (ii=CurIndex-1; ii>0 && !Trouve; ii--) - if (myKnots->Value(ii)<= Wtest) { - CurIndex = ii; - Trouve = Standard_True; - } - if (!Trouve) CurIndex = 1; // Out of bounds... - } - - else if (myKnots->Value(CurIndex+1) <= Wtest) { - for (ii=CurIndex+1; ii<=myCurves->Length() && !Trouve; ii++) - if (myKnots->Value(ii+1)> Wtest) { - CurIndex = ii; - Trouve = Standard_True; - } - if (!Trouve) CurIndex = myCurves->Length(); // Out of bounds... - } - - // Reverse ? - const TopoDS_Edge& E = myCurves->Value(CurIndex).Edge(); - TopAbs_Orientation Or = E.Orientation(); - Standard_Boolean Reverse; - Reverse = (Forward && (Or == TopAbs_REVERSED)) || - (!Forward && (Or != TopAbs_REVERSED)); - - // Calculation of the local parameter - BRep_Tool::Range(E, f, l); - Delta = myKnots->Value(CurIndex+1) - myKnots->Value(CurIndex); - if (Delta > PTol*1.e-9) Delta = (l-f)/Delta; - - if (Reverse) { - Delta *= -1; - W = l + (W-myKnots->Value(CurIndex)) * Delta; - } - else { - W = f + (W-myKnots->Value(CurIndex)) * Delta; - } -} - -void BRepAdaptor_CompCurve2::InvPrepare(const Standard_Integer index, - Standard_Real& First, - Standard_Real& Delta) const -{ - // Reverse ? - const TopoDS_Edge& E = myCurves->Value(index).Edge(); - TopAbs_Orientation Or = E.Orientation(); - Standard_Boolean Reverse; - Reverse = (Forward && (Or == TopAbs_REVERSED)) || - (!Forward && (Or != TopAbs_REVERSED)); - - // Calculation of reparametrization parameters - // such as: T = Ti + (t-First)*Delta - Standard_Real f, l; - BRep_Tool::Range(E, f, l); - Delta = myKnots->Value(index+1) - myKnots->Value(index); - if (l-f > PTol*1.e-9) Delta /= (l-f); - - if (Reverse) { - Delta *= -1; - First = l; - } - else { - First = f; - } -} diff --git a/src/Mod/Cam/App/BRepAdaptor_CompCurve2.h b/src/Mod/Cam/App/BRepAdaptor_CompCurve2.h deleted file mode 100644 index 5a6fefb56d..0000000000 --- a/src/Mod/Cam/App/BRepAdaptor_CompCurve2.h +++ /dev/null @@ -1,285 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2007 Joachim Zettler * - * Adapted by Joachim Zettler to use with a WireExplorer made * - * by Stephane Routelous * - * * - * This file is part of the FreeCAD CAx development system. * - * * - * This library is free software; you can redistribute it and/or * - * modify it under the terms of the GNU Library General Public * - * License as published by the Free Software Foundation; either * - * version 2 of the License, or (at your option) any later version. * - * * - * This library is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * - * GNU Library General Public License for more details. * - * * - * You should have received a copy of the GNU Library General Public * - * License along with this library; see the file COPYING.LIB. If not, * - * write to the Free Software Foundation, Inc., 59 Temple Place, * - * Suite 330, Boston, MA 02111-1307, USA * - * * - ***************************************************************************/ - -#ifndef _BRepAdaptor_CompCurve2_HeaderFile -#define _BRepAdaptor_CompCurve2_HeaderFile - -#ifndef _TopoDS_Wire_HeaderFile -#include -#endif -#ifndef _Standard_Real_HeaderFile -#include -#endif -#ifndef _Handle_BRepAdaptor_HArray1OfCurve_HeaderFile -#include -#endif -#ifndef _Handle_TColStd_HArray1OfReal_HeaderFile -#include -#endif -#ifndef _Standard_Integer_HeaderFile -#include -#endif -#ifndef _Standard_Boolean_HeaderFile -#include -#endif -#ifndef _Adaptor3d_Curve_HeaderFile -#include -#endif -#ifndef _GeomAbs_Shape_HeaderFile -#include -#endif -#ifndef _Handle_Adaptor3d_HCurve_HeaderFile -#include -#endif -#ifndef _GeomAbs_CurveType_HeaderFile -#include -#endif -#ifndef _Handle_Geom_BezierCurve_HeaderFile -#include -#endif -#ifndef _Handle_Geom_BSplineCurve_HeaderFile -#include -#endif -class BRepAdaptor_HArray1OfCurve; -class TColStd_HArray1OfReal; -class Standard_NullObject; -class Standard_DomainError; -class Standard_OutOfRange; -class Standard_NoSuchObject; -class TopoDS_Wire; -class TopoDS_Edge; -class TColStd_Array1OfReal; -class Adaptor3d_HCurve; -class gp_Pnt; -class gp_Vec; -class gp_Lin; -class gp_Circ; -class gp_Elips; -class gp_Hypr; -class gp_Parab; -class Geom_BezierCurve; -class Geom_BSplineCurve; - - -#ifndef _Standard_HeaderFile -#include -#endif -#ifndef _Standard_Macro_HeaderFile -#include -#endif - -//! The Curve from BRepAdaptor allows to use a Wire of the BRep topology -//! like a 3D curve.
-//! Warning: With this class of curve, C0 and C1 continuities -//! are not assumed. So be careful with some algorithms! -class BRepAdaptor_CompCurve2 : public Adaptor3d_Curve -{ - -public: - - void* operator new(size_t,void* anAddress) - { - return anAddress; - } - void* operator new(size_t size) - { - return Standard::Allocate(size); - } - void operator delete(void *anAddress) - { - if (anAddress) Standard::Free((Standard_Address&)anAddress); - } -// Methods PUBLIC -// - -//! Creates an undefined Curve with no Wire loaded. - Standard_EXPORT BRepAdaptor_CompCurve2(); - - - Standard_EXPORT BRepAdaptor_CompCurve2(const TopoDS_Wire& W,const Standard_Boolean KnotByCurvilinearAbcissa = Standard_False); - -//! Creates a Curve to access to the geometry of edge \p W. - Standard_EXPORT BRepAdaptor_CompCurve2(const TopoDS_Wire& W,const Standard_Boolean KnotByCurvilinearAbcissa,const Standard_Real First,const Standard_Real Last,const Standard_Real Tol); - -//! Sets the wire \p W. - Standard_EXPORT void Initialize(const TopoDS_Wire& W,const Standard_Boolean KnotByCurvilinearAbcissa) ; - -//! Sets wire \p W and trimmed parameter. - Standard_EXPORT void Initialize(const TopoDS_Wire& W,const Standard_Boolean KnotByCurvilinearAbcissa,const Standard_Real First,const Standard_Real Last,const Standard_Real Tol) ; - -//! Set the flag Periodic.
-//! Warning: This method has no effect if the wire is not closed. - Standard_EXPORT void SetPeriodic(const Standard_Boolean Periodic) ; - -//! Returns the wire. - Standard_EXPORT const TopoDS_Wire& Wire() const; - -//! returns an edge and one parameter on them -//! corresponding to the parameter \p U. - Standard_EXPORT void Edge(const Standard_Real U,TopoDS_Edge& E,Standard_Real& UonE) const; - - - Standard_EXPORT Standard_Real FirstParameter() const; - - - Standard_EXPORT Standard_Real LastParameter() const; - - - Standard_EXPORT GeomAbs_Shape Continuity() const; - -//! Returns the number of intervals for continuity \.
-//! May be one if Continuity(me) >= \ - Standard_EXPORT Standard_Integer NbIntervals(const GeomAbs_Shape S) ; - -//! Stores in \ the parameters bounding the intervals of continuity \.
- -//! The array must provide enough room to accommodate for the parameters. -//! i.e. T.Length() > NbIntervals() - Standard_EXPORT void Intervals(TColStd_Array1OfReal& T,const GeomAbs_Shape S) ; - - - Standard_EXPORT Standard_Boolean IsClosed() const; - - - Standard_EXPORT Standard_Boolean IsPeriodic() const; - - - Standard_EXPORT Standard_Real Period() const; - -//! Computes the point of parameter \p U on the curve - Standard_EXPORT gp_Pnt Value(const Standard_Real U) const; - -//! Computes the point of parameter \p U. - Standard_EXPORT void D0(const Standard_Real U,gp_Pnt& P) const; - -//! Computes the point of parameter \p U on the curve with its first -//! derivative.
-//! Raised if the continuity of the current interval is not C1. - Standard_EXPORT void D1(const Standard_Real U,gp_Pnt& P,gp_Vec& V) const; - - -//! Returns the point \p P of parameter \p U, the first and second -//! derivatives \p V1 and \p V2.
-//! Raised if the continuity of the current interval is not C2. - Standard_EXPORT void D2(const Standard_Real U,gp_Pnt& P,gp_Vec& V1,gp_Vec& V2) const; - - -//! Returns the point \p P of parameter \p U, the first, the second -//! and the third derivative.
-//! Raised if the continuity of the current interval is not C3. - Standard_EXPORT void D3(const Standard_Real U,gp_Pnt& P,gp_Vec& V1,gp_Vec& V2,gp_Vec& V3) const; - - -//! The returned vector gives the value of the derivative for the -//! order of derivation N.
-//! Raised if the continuity of the current interval is not CN.
-//! Raised if N < 1. - Standard_EXPORT gp_Vec DN(const Standard_Real U,const Standard_Integer N) const; - -//! returns the parametric resolution - Standard_EXPORT Standard_Real Resolution(const Standard_Real R3d) const; - - - Standard_EXPORT GeomAbs_CurveType GetType() const; - - - Standard_EXPORT gp_Lin Line() const; - - - Standard_EXPORT gp_Circ Circle() const; - - - Standard_EXPORT gp_Elips Ellipse() const; - - - Standard_EXPORT gp_Hypr Hyperbola() const; - - - Standard_EXPORT gp_Parab Parabola() const; - - - Standard_EXPORT Standard_Integer Degree() const; - - - Standard_EXPORT Standard_Boolean IsRational() const; - - - Standard_EXPORT Standard_Integer NbPoles() const; - - - Standard_EXPORT Standard_Integer NbKnots() const; - - - Standard_EXPORT Handle_Geom_BezierCurve Bezier() const; - - - Standard_EXPORT Handle_Geom_BSplineCurve BSpline() const; - - - - - -protected: - -// Methods PROTECTED -// - - -// Fields PROTECTED -// - - -private: - -// Methods PRIVATE -// - - - Standard_EXPORT void Prepare(Standard_Real& W,Standard_Real& D,Standard_Integer& ind) const; - - - Standard_EXPORT void InvPrepare(const Standard_Integer ind,Standard_Real& F,Standard_Real& D) const; - - -// Fields PRIVATE -// - TopoDS_Wire myWire; - Standard_Real TFirst; - Standard_Real TLast; - Standard_Real PTol; - Standard_Real myPeriod; - Handle_BRepAdaptor_HArray1OfCurve myCurves; - Handle_TColStd_HArray1OfReal myKnots; - Standard_Integer CurIndex; - Standard_Boolean Forward; - Standard_Boolean IsbyAC; - Standard_Boolean Periodic; - - -}; - - - - -#endif diff --git a/src/Mod/Cam/App/BRepUtils.cpp b/src/Mod/Cam/App/BRepUtils.cpp deleted file mode 100644 index 47138c92eb..0000000000 --- a/src/Mod/Cam/App/BRepUtils.cpp +++ /dev/null @@ -1,45 +0,0 @@ -#include "BRepUtils.h" - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - - - -double BRepUtils::GetLength(const TopoDS_Edge& edge) -{ - GProp_GProps lProps; - BRepGProp::LinearProperties(edge,lProps); - return lProps.Mass(); -} - -bool BRepUtils::CheckTopologie(const TopoDS_Shape& shape) -{ - TopTools_IndexedDataMapOfShapeListOfShape aMap; - aMap.Clear(); - TopExp::MapShapesAndAncestors(shape,TopAbs_EDGE,TopAbs_FACE,aMap); - TopExp_Explorer anExplorer; - for(anExplorer.Init(shape,TopAbs_EDGE);anExplorer.More();anExplorer.Next()) - { - const TopTools_ListOfShape& aFaceList = aMap.FindFromKey(anExplorer.Current()); - - TopTools_ListIteratorOfListOfShape aListIterator(aFaceList); - int i=0; - for(aListIterator.Initialize(aFaceList);aListIterator.More();aListIterator.Next()) - { - i++; - } - if(i<2) - { - cout << "less" << endl; - } - } - return true; -} diff --git a/src/Mod/Cam/App/BRepUtils.h b/src/Mod/Cam/App/BRepUtils.h deleted file mode 100644 index 4413ae2a87..0000000000 --- a/src/Mod/Cam/App/BRepUtils.h +++ /dev/null @@ -1,22 +0,0 @@ -#ifndef _BRepUtils_HeaderFile -#define _BRepUtils_HeaderFile - -#ifndef _Standard_Macro_HeaderFile -#include -#endif - -class TopoDS_Edge; -class TopoDS_Shape; - -class BRepUtils -{ -public: - - Standard_EXPORT static bool CheckTopologie(const TopoDS_Shape& shape); - Standard_EXPORT static double GetLength(const TopoDS_Edge& edge); - -}; - - -#endif //_BRepUtils_HeaderFile - diff --git a/src/Mod/Cam/App/CMakeLists.txt b/src/Mod/Cam/App/CMakeLists.txt deleted file mode 100644 index dfb7f5cec4..0000000000 --- a/src/Mod/Cam/App/CMakeLists.txt +++ /dev/null @@ -1,101 +0,0 @@ -if(WIN32) - add_definitions(-DWNT -DFCAppCam -DHAVE_ACOSH -DHAVE_ATANH -DHAVE_ASINH) -else(WIN32) - add_definitions(-DFCAppCam) -endif(WIN32) - -include_directories( - ${CMAKE_SOURCE_DIR}/src - ${CMAKE_SOURCE_DIR}/src/3rdParty - ${CMAKE_SOURCE_DIR}/src/3rdParty/ANN/include - #${CMAKE_SOURCE_DIR}/src/3rdParty/OCCAdaptMesh/Include - ${Boost_INCLUDE_DIRS} - ${QT_INCLUDE_DIR} - ${OCC_INCLUDE_DIR} - ${ZLIB_INCLUDE_DIR} - ${PYTHON_INCLUDE_PATH} - ${UMFPACK_INCLUDE_DIR} - ${SMSH_INCLUDE_DIR} - ${SMESH_INCLUDE_DIR} -) - -if(MSVC) - set(Cam_LIBS - Mesh - Part - ${QT_QTCORE_LIBRARY} - ${QT_QTCORE_LIBRARY_DEBUG} - ANN - #${ATLAS_LIBRARIES} - importlib_atlas.lib - importlib_umfpackamd.lib - ${SMSH_LIBRARIES} - ${SMESH_LIBRARIES} - ) -else(MSVC) - set(Cam_LIBS - Mesh - Part - ${QT_QTCORE_LIBRARY} - ${SMESH_LIBRARIES} - ANN - atlas - blas - lapack - umfpack - amd - ) -endif(MSVC) - -SET(Cam_SRCS - AppCamPy.cpp - deviation.cpp - deviation.h - Approx.cpp - Approx.h - mergedata.h - mergedata.cpp - best_fit.cpp - best_fit.h - BRepAdaptor_CompCurve2.cxx - BRepAdaptor_CompCurve2.h - BRepUtils.h - BRepUtils.cpp - ChangeDyna.cpp - ChangeDyna.h - ConvertDyna.cpp - ConvertDyna.h - cutting_tools.cpp - cutting_tools.h - edgesort.cpp - edgesort.h - path_simulate.cpp - path_simulate.h - PreCompiled.cpp - PreCompiled.h - routine.cpp - routine.h - stuff.h - SpringbackCorrection.cpp - SpringbackCorrection.h - UniGridApprox.cpp - UniGridApprox.h - WireExplorer.cxx - WireExplorer.h - AppCam.cpp -) - -add_library(Cam SHARED ${Cam_SRCS}) -target_link_libraries(Cam ${Cam_LIBS}) - -fc_target_copy_resource(Cam - ${CMAKE_SOURCE_DIR}/src/Mod/Cam - ${CMAKE_BINARY_DIR}/Mod/Cam - Init.py) - -SET_BIN_DIR(Cam Cam /Mod/Cam) -if(WIN32) - set_target_properties(Cam PROPERTIES SUFFIX ".pyd") -endif(WIN32) - -INSTALL(TARGETS Cam DESTINATION ${CMAKE_INSTALL_LIBDIR}) diff --git a/src/Mod/Cam/App/ChangeDyna.cpp b/src/Mod/Cam/App/ChangeDyna.cpp deleted file mode 100644 index a114582892..0000000000 --- a/src/Mod/Cam/App/ChangeDyna.cpp +++ /dev/null @@ -1,184 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2007 Joachim Zettler * - * * - * This file is part of the FreeCAD CAx development system. * - * * - * This library is free software; you can redistribute it and/or * - * modify it under the terms of the GNU Library General Public * - * License as published by the Free Software Foundation; either * - * version 2 of the License, or (at your option) any later version. * - * * - * This library is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * - * GNU Library General Public License for more details. * - * * - * You should have received a copy of the GNU Library General Public * - * License along with this library; see the file COPYING.LIB. If not, * - * write to the Free Software Foundation, Inc., 59 Temple Place, * - * Suite 330, Boston, MA 02111-1307, USA * - * * - ***************************************************************************/ - - -#include "PreCompiled.h" -#include "ChangeDyna.h" -#include -#include -#include -#include - -ChangeDyna::ChangeDyna() -{ - m_ProperTime.clear(); -} -bool ChangeDyna::Read( const std::string & _filename) -{ - // open file for reading - std::ifstream input( _filename.c_str() ); - std::ifstream input2("CurveTimes.k"); - if (!input2.is_open()) return false; - if (!ReadTimes(input2)) return false; - std::ofstream output("dyna2.str"); - if ( !input.is_open() ) - { - std::cout << "failed to open file" << std::endl; - return false; - } - if ( !ReadCurve( input, output ) ) - { - std::cout << "failed to read curve_data" << std::endl; - return false; - } - - input.close(); - output.close(); - input2.close(); - return true; -} - - -bool ChangeDyna::ReadTimes(std::ifstream &input2) -{ - input2.seekg(std::ifstream::beg); - std::string line; - unsigned int i=0; - std::pair tempPair; - std::stringstream astream1; - do - { - std::getline(input2,line); - if (line.size() == 0) continue; - astream1.str(line); - astream1 >> tempPair.first >> tempPair.second; - m_ProperTime.push_back(tempPair); - astream1.str(""); - astream1.clear(); - - } - while (input2.good()); - return true; -} - - -bool ChangeDyna::ReadCurve(std::ifstream &input,std::ofstream &output) -{ - input.seekg( std::ifstream::beg ); - std::string line,subline1; - bool found = false; - int current_index; - do - { - std::getline( input, line ); - if (line.size() == 0) //if we have an empty line - { - continue; - } - if (found) - { - //If we find a new Keyword description - if (line.size() > 3 && line.at(0) == '$' && (line.find("nid") == std::string::npos)) - { - found = false; - output << line << std::endl; - continue; //go directly to the next line - } - else if (line.at(0) == '$') - { - output << line << std::endl; - continue; - } - else // Now we change the Birth and Death-Times - { - std::stringstream astream1,astream2; - astream1.precision(20); - astream2.precision(20); - if (line.at(9) != '0') //If we are at the first line - { - //Extract the Curve-Index - astream1.str(line.substr(10,5)); - astream1 >> current_index; - //Exchange the Death time. We need a vector of pairs (birth,death) - if ((current_index-2) < 0) - return false; - astream2 << m_ProperTime[current_index-2].second; - //Now we have to reformat the string to fit exactly 9 digits - try - { - ReformatStream(astream2,subline1); - output << line.substr(0,66) << subline1 << line.substr(75,5) << std::endl; - } - catch (const std::out_of_range&) - { - output << line << std::endl; - return false; - } - - continue; - } - else //we are at the second line and can exchange the Birth-Time - { - - astream2 << m_ProperTime[current_index-2].first; - try - { - ReformatStream(astream2,subline1); - output << line.substr(0,31) << subline1 << std::endl; - } - catch (std::out_of_range) - { - output << line << std::endl; - return false; - } - - continue; - } - } - } - else - { - std::string search("Velocity/Acceleration/"); - if (line.find(search)!=std::string::npos) - found = true; - output << line << std::endl; - continue; - } - } - while ( input.good()); - return true; -} - - -bool ChangeDyna::ReformatStream(const std::stringstream& astream, std::string& astring) -{ - astring.clear(); - std::string tempstring(astream.str()); - unsigned int found=tempstring.find('.'); - astring = tempstring.substr(0,found); - astring += '.'; - //Now add the rest. We have only space for 9 digits in total (the '-' is already there) - astring += tempstring.substr(found+1,9-astring.size()); - while (astring.size() < 9) - astring += '0'; //We add '0' until we have a size of 9 - return true; -} diff --git a/src/Mod/Cam/App/ChangeDyna.h b/src/Mod/Cam/App/ChangeDyna.h deleted file mode 100644 index 0c960fb33a..0000000000 --- a/src/Mod/Cam/App/ChangeDyna.h +++ /dev/null @@ -1,44 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2007 Joachim Zettler * - * * - * This file is part of the FreeCAD CAx development system. * - * * - * This library is free software; you can redistribute it and/or * - * modify it under the terms of the GNU Library General Public * - * License as published by the Free Software Foundation; either * - * version 2 of the License, or (at your option) any later version. * - * * - * This library is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * - * GNU Library General Public License for more details. * - * * - * You should have received a copy of the GNU Library General Public * - * License along with this library; see the file COPYING.LIB. If not, * - * write to the Free Software Foundation, Inc., 59 Temple Place, * - * Suite 330, Boston, MA 02111-1307, USA * - * * - ***************************************************************************/ - -#ifndef CHANGEDYNA_H -#define CHANGEDYNA_H - -#include -#include -#include - -class CamExport ChangeDyna -{ -public: - ChangeDyna(); - bool Read(const std::string &filename); - // ~ChangeDyna(); -private: - bool ReformatStream(const std::stringstream& astream, std::string& astring); - bool ReadCurve(std::ifstream &input,std::ofstream &output); - bool ReadTimes(std::ifstream &input2); - std::vector > m_ProperTime; - -}; -#endif - diff --git a/src/Mod/Cam/App/ConvertDyna.cpp b/src/Mod/Cam/App/ConvertDyna.cpp deleted file mode 100644 index 83cf3edbaf..0000000000 --- a/src/Mod/Cam/App/ConvertDyna.cpp +++ /dev/null @@ -1,608 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2007 Joachim Zettler * - * * - * This file is part of the FreeCAD CAx development system. * - * * - * This library is free software; you can redistribute it and/or * - * modify it under the terms of the GNU Library General Public * - * License as published by the Free Software Foundation; either * - * version 2 of the License, or (at your option) any later version. * - * * - * This library is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * - * GNU Library General Public License for more details. * - * * - * You should have received a copy of the GNU Library General Public * - * License along with this library; see the file COPYING.LIB. If not, * - * write to the Free Software Foundation, Inc., 59 Temple Place, * - * Suite 330, Boston, MA 02111-1307, USA * - * * - ***************************************************************************/ - - -/******CONVERTDYNA.CPP******/ - -/******MAIN INCLUDES******/ -#include "PreCompiled.h" -#include "ConvertDyna.h" -#include - -ReadDyna::ReadDyna(MeshCore::MeshKernel &m, const char* &inputname) -{ - //Open the file and perform standard check for file - std::ifstream inputfile; - inputfile.open(inputname); - std::string line; - if (!inputfile.is_open()) //Exists...? - { - std::cerr << "File not found. Exiting..." << std::endl; - return; - } - getline(inputfile,line); - if (line.find("*KEYWORD") == std::string::npos) //Really a DYNA file...? - { - std::cerr << "NOT A DYNA FILE\a" << std::endl; - return; - } - while (inputfile) //First find *NODE Keyword to initialize the VERTICES list (it's the main list) - { - getline(inputfile,line); - if (line.find("*NODE") != std::string::npos) - { - std::cout << "*NODE found. Parsing... "; - ReadNode(inputfile); - std::cout << "done\n"; - break; - } - } - inputfile.seekg(std::ios::beg); //bring back the file pointer, you never know where those two other will spawn... - if (inputfile.fail()) - inputfile.clear(); //...clear the badbits... - while (inputfile) //and reread. - { - getline(inputfile,line); - if (line.find("*ELEMENT_SHELL_THICKNESS") != std::string::npos) //For Faces - { - std::cout << "*ELEMENT_SHELL_THICKNESS found. Parsing... "; - ReadShellThickness(inputfile); - std::cout << "done\n"; - } - else if (line.find("*CONSTRAINED_ADAPTIVITY") != std::string::npos) //For constraints - { - std::cout << "*CONSTRAINED_ADAPTIVITY found. Parsing... "; - ReadConstraints(inputfile); - std::cout << "done\n"; - } - } - inputfile.close(); - std::cout << "Triangulating... "; - Convert(); - std::cout << "done\nWriting into list... "; - PutInMesh(m); - std::cout << "done\n"; -} -/*! \brief *NODE Keyword Information Parser -*/ -void ReadDyna::ReadNode(std::ifstream &inputfile) -{ - std::string line; - getline(inputfile, line); - char *cstr; - char Byte[16] = {0}; - char Nibble[8] = {0}; - int i = 0, j = 0; - while (line.find("*") == std::string::npos) //while next keyword is not yet found... - { - if (line.find("$") != std::string::npos) //comment, ignore - { - getline(inputfile, line); - continue; - } - VERTICES Temp; - Temp.Constrain = false; //Initialize both flags to false - Temp.Constrained = false; - cstr = new char [line.size()+1]; - strcpy(cstr, line.c_str()); - for (i = 0; i < 8; i++) - { - Nibble[j] = cstr[i]; - j++; - } - Temp.PointIndex = atoi(Nibble); //Index - j = 0; - for (i = 8; i < 24; i++) - { - Byte[j] = cstr[i]; - j++; - } - Temp.Coords.push_back(atof(Byte)); //X Coords - j = 0; - - for (i = 24; i < 40; i++) - { - Byte[j] = cstr[i]; - j++; - } - Temp.Coords.push_back(atof(Byte)); //Y Coords - j = 0; - - for (i = 40; i < 56; i++) - { - Byte[j] = cstr[i]; - j++; - } - Temp.Coords.push_back(atof(Byte)); //Z Coords - j = 0; - - Pointlist.insert(std::pair(Temp.PointIndex, Temp)); - delete[] cstr; - getline(inputfile, line); - } -} -/*! \brief Face Reader - - Inside *ELEMENT_SHELL_THICKNESS there's the information about which points makes up a face. All other infos are ignored. - - Maybe it is in other keywords there is such infos, but I dunno... -*/ -void ReadDyna::ReadShellThickness(std::ifstream &inputfile) -{ - std::map::iterator pnt_it(Pointlist.begin()); - std::string line; - char *c_str; - char Info[8] = {0}; - int i = 0, j = 0; - getline(inputfile, line); - while (line.find("*") == std::string::npos) //While next keyword is not yet found.. - { - if (line.find("$") != std::string::npos) //Ignore the comments - { - getline(inputfile, line); - continue; - } - FACE Temp; - c_str = new char [line.size()+1]; - strcpy(c_str, line.c_str()); - - for (i = 0; i < 8; i++,j++) - Info[j] = c_str[i]; - Temp.FaceIndex = atoi(Info); //Facet Index - j= 0; - - for (i = 16; i < 24; i++,j++) - Info[j] = c_str[i]; - Temp.PointIndex.push_back(atoi(Info)); //First Point - j = 0; - - for (i = 24; i < 32; i++,j++) - Info[j] = c_str[i]; - Temp.PointIndex.push_back(atoi(Info)); //Second Point - j = 0; - - for (i = 32; i < 40; i++,j++) - Info[j] = c_str[i]; - Temp.PointIndex.push_back(atoi(Info)); //Third Point - j = 0; - - for (i = 40; i < 48; i++,j++) - Info[j] = c_str[i]; - Temp.PointIndex.push_back(atoi(Info)); //Fourth Point - j = 0; - - getline(inputfile,line); - /*If you need extra info from here, extract it here*/ - - for (unsigned int k = 0; k < Temp.PointIndex.size(); k++) - { - pnt_it = Pointlist.find(Temp.PointIndex[k]); - (*pnt_it).second.FacetRef.push_back(Temp.FaceIndex); //Put into the Facet Reference - - } - Facelist.insert(std::pair(Temp.FaceIndex, Temp)); - getline(inputfile,line); - } -} - -/*! \brief *CONSTRAINTS_ADATIVITY parser -*/ -void ReadDyna::ReadConstraints(std::ifstream &inputfile) -{ - std::map::iterator pnt_it(Pointlist.begin()); - std::string line; - char *str; - char Info[10] = {0}; - int i = 0, j = 0; - unsigned int First; - unsigned int Second; - unsigned int Third; - getline(inputfile, line); - while (line.find("*") == std::string::npos) //While... you know the drill - { - if (line.find("$") != std::string::npos) //Ignore comments... - { - getline(inputfile, line); - continue; - } - str = new char [line.size()+1]; - strcpy(str, line.c_str()); - - for (i = 0; i < 10; i++,j++) - Info[j] = str[i]; - First = atoi(Info); //Constrained Point - - j = 0; - - for (i = 10; i < 20; i++,j++) - Info[j] = str[i]; - Second = atoi(Info); //Constrainer 1 - - j = 0; - - for (i = 20; i < 30; i++,j++) - Info[j] = str[i]; - Third = atoi(Info); //Constrainer 2 - - j = 0; - - //Set all necessary flags fill the necessary std::vector's - pnt_it = Pointlist.find(First); - (*pnt_it).second.Constrained = true; - (*pnt_it).second.ConstrainedBy.push_back(Second); - (*pnt_it).second.ConstrainedBy.push_back(Third); - - pnt_it = Pointlist.find(Second); - (*pnt_it).second.Constrain = true; - (*pnt_it).second.Constraining.push_back(First); - - pnt_it = Pointlist.find(Third); - (*pnt_it).second.Constrain = true; - (*pnt_it).second.Constraining.push_back(First); - - delete[] str; - getline(inputfile,line); - } -} - -/*! \brief Triangulator - - This will triangulate the squares, taking note of the constraining point that might come into play. - - To date, only three things are considered now: No constraints in the edges, One Constraint in the edges, and Two - Constraints next to each other (not opposite each other!) in the edges - - Sparing some commenting... I got lost inside of it too... -*/ -void ReadDyna::Convert() -{ - std::map::iterator pnt_it(Pointlist.begin()); - std::map::iterator constraint_it(Pointlist.begin()); - std::map::iterator face_it(Facelist.begin()); - std::vector::iterator ver_it; - std::vector::iterator constrainter_it; - for ( ; face_it != Facelist.end(); face_it++) //For every face... - { - FACE CurFace = (*face_it).second; - std::vector AdditionalPoint; - std::vector Constrainter; - unsigned int Doubler = 0; - bool HaveConstraint = false; - bool Side = false; - for (unsigned int i = 0; i < CurFace.PointIndex.size(); i++)//...and for every point in the face... - { - pnt_it = Pointlist.find(CurFace.PointIndex[i]); - if ((*pnt_it).second.Constrain)//...does it constraining any other points? - { - int NumOfConstraint = 0; - for (unsigned int j = 0; j < (*pnt_it).second.Constraining.size(); j++) //Yes, so for every point it constraints... - { - constraint_it = Pointlist.find((*pnt_it).second.Constraining[j]); - if ((constrainter_it = find(CurFace.PointIndex.begin(),CurFace.PointIndex.end(), - (*constraint_it).second.PointIndex)) != CurFace.PointIndex.end()) //...does the constraint point also a part of the current face? - { - continue; //Yes, so skip it. - } - unsigned int ver = (*constraint_it).second.ConstrainedBy[0]; //No, so... - if (ver == CurFace.PointIndex[i]) //...the point is current point? - ver = (*constraint_it).second.ConstrainedBy[1]; //Yes, so move to second point in ConstrainedBy - if ((constrainter_it = find(CurFace.PointIndex.begin(),CurFace.PointIndex.end(),ver)) - != CurFace.PointIndex.end()) //So, the point we are checking, is it a part of the current face? - { - HaveConstraint = true; - NumOfConstraint++; //Yes, so... - if ((ver_it = find(AdditionalPoint.begin(), AdditionalPoint.end(),(*pnt_it).second.Constraining[j])) - == AdditionalPoint.end()) //...have the additional point been added to the list? - { - //Yes, push it back, and push the current point index too!!! - AdditionalPoint.push_back((*pnt_it).second.Constraining[j]); - Constrainter.push_back(i); - } - } - } - if (NumOfConstraint == 2) //One point constraining two point...? - { - Side = true; - Doubler = i; //Set the doubler~ - } - } - } - if (!HaveConstraint) //No Constraints, so... - { - /* ------ - | /| - | / | - | / | - | / | - ------- - or so... - */ - STLINDEX Temp; - Temp.PointIndex.push_back(CurFace.PointIndex[0]); - Temp.PointIndex.push_back(CurFace.PointIndex[1]); - Temp.PointIndex.push_back(CurFace.PointIndex[3]); - Stllist.push_back(Temp); - Temp.PointIndex.clear(); - - Temp.PointIndex.push_back(CurFace.PointIndex[1]); - Temp.PointIndex.push_back(CurFace.PointIndex[2]); - Temp.PointIndex.push_back(CurFace.PointIndex[3]); - Stllist.push_back(Temp); - - } - else - { - //Houston, we have some constraints... - switch (AdditionalPoint.size()) //"How much" asks Houston - { - case 1: //1 constrain is the reply - { - /* ____ - | /| - |/ | - |\ | - | \| - ---- - */ - STLINDEX Temp; - int checker; - if (Constrainter[0] != 0) - { - Temp.PointIndex.push_back(CurFace.PointIndex[Constrainter[0]]); - Temp.PointIndex.push_back(AdditionalPoint[0]); - Temp.PointIndex.push_back(CurFace.PointIndex[Constrainter[0] - 1]); - Stllist.push_back(Temp); - Temp.PointIndex.clear(); - - Temp.PointIndex.push_back(AdditionalPoint[0]); - - checker = Constrainter[0] - 2; - if (checker < 0) - Temp.PointIndex.push_back(CurFace.PointIndex[Constrainter[0]+2]); - - - else Temp.PointIndex.push_back(CurFace.PointIndex[checker]); - - - checker = Constrainter[0] - 1; - if (checker < 0) - Temp.PointIndex.push_back(CurFace.PointIndex[3]); - else Temp.PointIndex.push_back(CurFace.PointIndex[checker]); - - - Stllist.push_back(Temp); - Temp.PointIndex.clear(); - - Temp.PointIndex.push_back(AdditionalPoint[0]); - - Temp.PointIndex.push_back(CurFace.PointIndex[Constrainter[0] + 1]); - - checker = Constrainter[0] + 2; - if (checker >= 4) - { - Temp.PointIndex.push_back(CurFace.PointIndex[Constrainter[0] - 2]); - - } - else - { - Temp.PointIndex.push_back(CurFace.PointIndex[checker]); - - } - Stllist.push_back(Temp); - } - else //Seems Constrainter[0] == 0 have it's own... possibilities - { - - Temp.PointIndex.push_back(AdditionalPoint[0]); - Temp.PointIndex.push_back(CurFace.PointIndex[2]); - Temp.PointIndex.push_back(CurFace.PointIndex[3]); - - Stllist.push_back(Temp); - Temp.PointIndex.clear(); - - Temp.PointIndex.push_back(AdditionalPoint[0]); - Temp.PointIndex.push_back(CurFace.PointIndex[1]); - Temp.PointIndex.push_back(CurFace.PointIndex[2]); - - Stllist.push_back(Temp); - Temp.PointIndex.clear(); - - Temp.PointIndex.push_back(AdditionalPoint[0]); - - std::map::iterator pnt = Pointlist.find(AdditionalPoint[0]); - std::vector temp = (*pnt).second.ConstrainedBy; - std::vector::iterator vec = find(temp.begin(), temp.end(), CurFace.PointIndex[1]); - if (vec != temp.end()) - { - Temp.PointIndex.push_back(CurFace.PointIndex[3]); - Temp.PointIndex.push_back(CurFace.PointIndex[0]); - Stllist.push_back(Temp); - } - else - { - Temp.PointIndex.push_back(CurFace.PointIndex[0]); - Temp.PointIndex.push_back(CurFace.PointIndex[1]); - Stllist.push_back(Temp); - } - } - break; - } - - case 2: //2 Constraints is the reply - { - /* This one i can't draw... sorry - */ - STLINDEX temp; - if (Doubler != 0 && Doubler != 3) - { - int checker; - temp.PointIndex.push_back(AdditionalPoint[1]); - temp.PointIndex.push_back(AdditionalPoint[0]); - temp.PointIndex.push_back(CurFace.PointIndex[Doubler]); - - Stllist.push_back(temp); - - - checker = Doubler + 2; - temp.PointIndex[0] = AdditionalPoint[0]; - temp.PointIndex[1] = AdditionalPoint[1]; - - if (checker >= 4) - { - temp.PointIndex[2] = CurFace.PointIndex[Doubler-2]; - - } - else - { - temp.PointIndex[2] = CurFace.PointIndex[Doubler+2]; - - } - Stllist.push_back(temp); - - checker = Doubler - 2; - temp.PointIndex[0] = AdditionalPoint[0]; - - if (checker < 0) - temp.PointIndex[1] = CurFace.PointIndex[Doubler+2]; - else - temp.PointIndex[1] = CurFace.PointIndex[Doubler-2]; - - temp.PointIndex[2] = CurFace.PointIndex[Doubler-1]; - - Stllist.push_back(temp); - - - temp.PointIndex[0] = AdditionalPoint[1]; - - checker = Doubler + 1; - temp.PointIndex[1] = CurFace.PointIndex[Doubler+1]; - - checker = Doubler + 2; - if (checker >= 4) - temp.PointIndex[2] = CurFace.PointIndex[Doubler-2]; - else - temp.PointIndex[2] = CurFace.PointIndex[Doubler+2]; - - - Stllist.push_back(temp); - - } - else if (Doubler == 0) - { - temp.PointIndex.push_back(AdditionalPoint[0]); - temp.PointIndex.push_back(AdditionalPoint[1]); - temp.PointIndex.push_back(CurFace.PointIndex[0]); - - Stllist.push_back(temp); - - temp.PointIndex[0] = AdditionalPoint[1]; - temp.PointIndex[1] = AdditionalPoint[0]; - temp.PointIndex[2] = CurFace.PointIndex[2]; - - Stllist.push_back(temp); - - temp.PointIndex[0] = CurFace.PointIndex[1]; - temp.PointIndex[1] = CurFace.PointIndex[2]; - temp.PointIndex[2] = AdditionalPoint[0]; - - Stllist.push_back(temp); - - temp.PointIndex[0] = CurFace.PointIndex[2]; - temp.PointIndex[1] = CurFace.PointIndex[3]; - temp.PointIndex[2] = AdditionalPoint[1]; - - Stllist.push_back(temp); - } - else - { - temp.PointIndex.push_back(AdditionalPoint[0]); - temp.PointIndex.push_back(AdditionalPoint[1]); - temp.PointIndex.push_back(CurFace.PointIndex[3]); - - Stllist.push_back(temp); - - temp.PointIndex[0] = AdditionalPoint[1]; - temp.PointIndex[1] = AdditionalPoint[0]; - temp.PointIndex[2] = CurFace.PointIndex[1]; - - Stllist.push_back(temp); - - temp.PointIndex[0] = CurFace.PointIndex[1]; - temp.PointIndex[1] = CurFace.PointIndex[2]; - temp.PointIndex[2] = AdditionalPoint[1]; - - Stllist.push_back(temp); - - temp.PointIndex[0] = CurFace.PointIndex[0]; - temp.PointIndex[1] = CurFace.PointIndex[1]; - temp.PointIndex[2] = AdditionalPoint[0]; - - Stllist.push_back(temp); - - } - break; - - } - case 3: - { - std::cout << "3 Constraints" << std::endl; - break; - } - case 4: - { - std::cout << "4 Constraints" << std::endl; - break; - } - default: //Have constraints, but no constraining points, or more than 5...? BUGSPAWN - { - std::cout << AdditionalPoint.size() << std::endl; - std::cout << "Blah...?" << std::endl; - break; - } - } - } - } -} - -/*! \brief Loading into Mesh Function... -*/ -void ReadDyna::PutInMesh(MeshCore::MeshKernel &mesh) -{ - std::map::iterator pnt_it(Pointlist.begin()); - Base::Vector3f Points[3]; - MeshCore::MeshBuilder builder(mesh); - builder.Initialize(Stllist.size()); - for (unsigned int i = 0; i < Stllist.size();i++) - { - for (unsigned int j = 0; j < 3; j++) - { - pnt_it = Pointlist.find(Stllist[i].PointIndex[j]); - Base::Vector3f Temp((float)(*pnt_it).second.Coords[0],(float)(*pnt_it).second.Coords[1],(float)(*pnt_it).second.Coords[2]); - Points[j] = Temp; - } - MeshCore::MeshGeomFacet Face(Points[0],Points[1],Points[2]); - Face.CalcNormal(); - builder.AddFacet(Face); - } - builder.Finish(); -} - diff --git a/src/Mod/Cam/App/ConvertDyna.h b/src/Mod/Cam/App/ConvertDyna.h deleted file mode 100644 index 9d41259e87..0000000000 --- a/src/Mod/Cam/App/ConvertDyna.h +++ /dev/null @@ -1,103 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2007 Joachim Zettler * - * * - * This file is part of the FreeCAD CAx development system. * - * * - * This library is free software; you can redistribute it and/or * - * modify it under the terms of the GNU Library General Public * - * License as published by the Free Software Foundation; either * - * version 2 of the License, or (at your option) any later version. * - * * - * This library is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * - * GNU Library General Public License for more details. * - * * - * You should have received a copy of the GNU Library General Public * - * License along with this library; see the file COPYING.LIB. If not, * - * write to the Free Software Foundation, Inc., 59 Temple Place, * - * Suite 330, Boston, MA 02111-1307, USA * - * * - ***************************************************************************/ - -/******CONVERTDYNA.H******/ -#ifndef CONVERTDYNA_H -#define CONVERTDYNA_H - -/******MAIN INCLUDES******/ -#include -#include -#include -#include - -/******MESH INCLUDES******/ -#include -#include -#include -#include -#include -#include - -/******STRUCTS******/ -//This structure will be used internally in this routine without any affects of outside variable -typedef struct -{ - unsigned int PointIndex; - std::vector Coords; - bool Constrained; //Another pair of points constraining this point...? - bool Constrain; //This point constraining another point...? - std::vector ConstrainedBy; - std::vector Constraining; - std::vector FacetRef; - -}VERTICES; /*!< VERTICES struct. Contains coordinates, index, face reference, and constraining information*/ - -typedef struct -{ - unsigned int FaceIndex; - std::vector PointIndex; - -}FACE; /*!< FACE struct. Contains the face index, and the reference to the point*/ - - - -typedef struct -{ - std::vector PointIndex; -}STLINDEX; /*!< STLINDEX struct, contains only the triangulated face vertex indexes */ - -/*! \brief DYNA Files Reader - - This Function will read in a DYNA file, designated by inputname. Only three Information will be parsed:- - *NODE, *CONSTRAINTS_ADAPTIVITY, and *ELEMENT_SHELL_THICKNESS (for the third, only first line will be parsed) - - From *NODE the coordinates and vertex index will be parsed. From *ELEMENT_SHELL_THICKNESS only the face nodal - will be parsed, and from *CONSTRAINTS_ADAPTIVITY the constraints point (flagged by Constrain and Constrained) will - be parsed. - - As output, a mesh. - - TODO:- - 1. A face might consists of 2 opposite constraint points, 3 constraint points or 4 constraint points in it's - edges. These are not implemented yet. - 2. Some other keyword might contain the face information other than *ELEMENT_SHELL_THICKNESS - 3. Multiple-PIDS DYNA files is not yet implemented. This program still assumes that it's only a single PID DYNA -*/ -class ReadDyna -{ -public: - ReadDyna(MeshCore::MeshKernel &m,const char* &inputname); -protected: - void ReadNode(std::ifstream &inputfile); - void ReadConstraints(std::ifstream &inputfile); - void ReadShellThickness(std::ifstream &inputfile); - void Convert(); - void PutInMesh(MeshCore::MeshKernel &mesh); -private: - std::map Pointlist; - std::map Facelist; - std::vector Stllist; - -}; -#endif /*CONVERTDYNA_H DEFINED*/ - diff --git a/src/Mod/Cam/App/MeshInterface.h b/src/Mod/Cam/App/MeshInterface.h deleted file mode 100644 index 5f238e60f2..0000000000 --- a/src/Mod/Cam/App/MeshInterface.h +++ /dev/null @@ -1,132 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2007 Werner Mayer * - * * - * This file is part of the FreeCAD CAx development system. * - * * - * This library is free software; you can redistribute it and/or * - * modify it under the terms of the GNU Library General Public * - * License as published by the Free Software Foundation; either * - * version 2 of the License, or (at your option) any later version. * - * * - * This library is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * - * GNU Library General Public License for more details. * - * * - * You should have received a copy of the GNU Library General Public * - * License along with this library; see the file COPYING.LIB. If not, * - * write to the Free Software Foundation, Inc., 59 Temple Place, * - * Suite 330, Boston, MA 02111-1307, USA * - * * - ***************************************************************************/ - - -#ifndef MESH_INTERFACE_H -#define MESH_INTERFACE_H - -#include -#include -#include -#include - -#include -#error -namespace Mesh -{ - -/** The Interface class is useful to convert between the MeshKernel and the OpenMesh data - * structures. This class is implemented as template to accept any OpenMesh kernel type. - * @author Werner Mayer - */ -template -class Interface : public Kernel -{ -public: - Interface() - { - } - - Interface(const MeshCore::MeshKernel& kernel) - { - copy(kernel); - } - - ~Interface() - { - } - - void copy(const MeshCore::MeshKernel& kernel_In) - { - this->clear(); - std::vector vertex_handles; - vertex_handles.reserve(kernel_In.CountPoints()); - MeshCore::MeshPointIterator it(kernel_In); - for (it.Init(); it.More(); it.Next()) { - vertex_handles.push_back(this->add_vertex(Kernel::Point(it->x, it->y, it->z))); - } - - const MeshCore::MeshFacetArray& ary = kernel_In.GetFacets(); - for (MeshCore::MeshFacetArray::_TConstIterator it = ary.begin(); it != ary.end(); ++it) { - this->add_face(vertex_handles[it->_aulPoints[0]], vertex_handles[it->_aulPoints[1]], vertex_handles[it->_aulPoints[2]]); - } - vertex_handles.clear(); - } - - void release(MeshCore::MeshKernel& kernel_Out) - { - MeshCore::MeshFacetArray facets; - MeshCore::MeshPointArray points; - - facets.reserve(this->n_faces()); - points.reserve(this->n_vertices()); - - // get the points - Kernel::ConstVertexIter v_it, v_end(this->vertices_end()); - for (v_it=this->vertices_begin(); v_it!=v_end; ++v_it) { - Kernel::Point p = this->point(v_it); - points.push_back(Base::Vector3f(p[0], p[1], p[2])); - } - - // get the facets - Kernel::ConstFaceIter f_it, f_end(this->faces_end()); - for (f_it=this->faces_begin(); f_it!=f_end; ++f_it) { - MeshCore::MeshFacet face; - int i=0; - for (Kernel::ConstFaceVertexIter fv_it=this->cfv_iter(f_it); fv_it; ++fv_it) { - face._aulPoints[i++] = fv_it.handle().idx(); - } - - facets.push_back(face); - } - // get the neighbourhood - // - // iterate over all faces - for (f_it=this->faces_begin(); f_it!=f_end; ++f_it) { - // iterate over the half edges to which belong the current face - for (Kernel::ConstFaceHalfedgeIter fh_it=this->cfh_iter(f_it); fh_it; ++fh_it) { - // get the opposite half edge of the current half edge - Kernel::HalfedgeHandle hh = this->opposite_halfedge_handle(fh_it); - if (hh.is_valid()) { - // if the opposite half edge is valid a neighbour face must exist - Kernel::FaceHandle fh = this->face_handle(hh); - Kernel::VertexHandle vh = this->to_vertex_handle(hh); - for (int j=0; j<3; j++) { - // find the appropriate vertex and set the neighbour face - if (facets[f_it.handle().idx()]._aulPoints[j] == vh.idx()) { - facets[f_it.handle().idx()]._aulNeighbours[j] = fh.idx(); - break; - } - } - } - } - } - - this->clear(); - kernel_Out.Adopt(points, facets, false); - } -}; - -} // namespace Mesh - - -#endif // MESH_INTERFACE_H diff --git a/src/Mod/Cam/App/PreCompiled.cpp b/src/Mod/Cam/App/PreCompiled.cpp deleted file mode 100644 index b2ceb9185b..0000000000 --- a/src/Mod/Cam/App/PreCompiled.cpp +++ /dev/null @@ -1,24 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2007 Joachim Zettler * - * * - * This file is part of the FreeCAD CAx development system. * - * * - * This library is free software; you can redistribute it and/or * - * modify it under the terms of the GNU Library General Public * - * License as published by the Free Software Foundation; either * - * version 2 of the License, or (at your option) any later version. * - * * - * This library is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * - * GNU Library General Public License for more details. * - * * - * You should have received a copy of the GNU Library General Public * - * License along with this library; see the file COPYING.LIB. If not, * - * write to the Free Software Foundation, Inc., 59 Temple Place, * - * Suite 330, Boston, MA 02111-1307, USA * - * * - ***************************************************************************/ - - -#include "PreCompiled.h" diff --git a/src/Mod/Cam/App/PreCompiled.h b/src/Mod/Cam/App/PreCompiled.h deleted file mode 100644 index 44cfacef44..0000000000 --- a/src/Mod/Cam/App/PreCompiled.h +++ /dev/null @@ -1,79 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2007 Joachim Zettler * - * * - * This file is part of the FreeCAD CAx development system. * - * * - * This library is free software; you can redistribute it and/or * - * modify it under the terms of the GNU Library General Public * - * License as published by the Free Software Foundation; either * - * version 2 of the License, or (at your option) any later version. * - * * - * This library is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * - * GNU Library General Public License for more details. * - * * - * You should have received a copy of the GNU Library General Public * - * License along with this library; see the file COPYING.LIB. If not, * - * write to the Free Software Foundation, Inc., 59 Temple Place, * - * Suite 330, Boston, MA 02111-1307, USA * - * * - ***************************************************************************/ - - -#ifndef __PRECOMPILED__ -#define __PRECOMPILED__ - -#include - - -// Exporting of App classes -#ifdef FC_OS_WIN32 - # define CamExport __declspec(dllexport) - # define CamExport __declspec(dllexport) - # define PartExport __declspec(dllimport) - # define MeshExport __declspec(dllimport) -#else // for Linux - # define CamExport - # define CamExport - # define PartExport - # define MeshExport -#endif - -#ifdef _MSC_VER - # pragma warning(disable : 4251) - # pragma warning(disable : 4290) - # pragma warning(disable : 4275) - # pragma warning(disable : 4503) - # pragma warning(disable : 4786) - # pragma warning(disable : 4101) -#endif - -#ifdef _PreComp_ - - // STL - #include - #include - #include - #include - #include - #include - #include - #include - #include - - #ifdef FC_OS_WIN32 - #include - #endif - - // OpenCasCade Base - #include - - // OpenCascade View - #include - -#endif //_PreComp_ - -#endif //__PRECOMPILED__ - - diff --git a/src/Mod/Cam/App/SpringbackCorrection.cpp b/src/Mod/Cam/App/SpringbackCorrection.cpp deleted file mode 100644 index 093a6657f7..0000000000 --- a/src/Mod/Cam/App/SpringbackCorrection.cpp +++ /dev/null @@ -1,3098 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2007 Joachim Zettler * - * Copyright (c) 2007 Human Rezai * - * * - * This file is part of the FreeCAD CAx development system. * - * * - * This library is free software; you can redistribute it and/or * - * modify it under the terms of the GNU Library General Public * - * License as published by the Free Software Foundation; either * - * version 2 of the License, or (at your option) any later version. * - * * - * This library is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * - * GNU Library General Public License for more details. * - * * - * You should have received a copy of the GNU Library General Public * - * License along with this library; see the file COPYING.LIB. If not, * - * write to the Free Software Foundation, Inc., 59 Temple Place, * - * Suite 330, Boston, MA 02111-1307, USA * - * * - ***************************************************************************/ - -#include "PreCompiled.h" - -#include "SpringbackCorrection.h" -#include "best_fit.h" - - -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - - - - -///*********BINDINGS********/ -#include -#include - -using namespace boost::numeric::bindings; - -using namespace boost::numeric; - - -SpringbackCorrection::SpringbackCorrection() -{ -} - -SpringbackCorrection::SpringbackCorrection(const TopoDS_Shape& aShape, const MeshCore::MeshKernel& aMesh) - :m_Shape(aShape),m_Mesh(aMesh) -{ - m_EdgeStruct.clear(); - EdgeMap.clear(); - MeshMap.clear(); - //Remove any existing Triangulation on the Shape - BRepTools::Clean(m_Shape); - best_fit::Tesselate_Shape(m_Shape,m_CadMesh,(float) 0.1); // Basic triangulation of the entire shape - - MeshCore::MeshTopoAlgorithm algo(m_CadMesh); - algo.HarmonizeNormals(); - - // flip all normals so that they are oriented in positive z-direction - MeshCore::MeshGeomFacet facet = m_CadMesh.GetFacet(0); - if (facet.GetNormal().z < 0.0) - algo.FlipNormals(); - - int n = m_CadMesh.CountFacets(); - Base::Vector3f normal; - - MeshCore::MeshPointArray points = m_CadMesh.GetPoints(); - MeshCore::MeshFacetArray facets = m_CadMesh.GetFacets(); - - for (int i=0; i inp; - std::vector MeanVec; - std::vector FacePntVector; - TopLoc_Location aloc; - Base::Vector3f mP; - gp_Pnt e_pnt, m_pnt; - double dist, distSum, revSum;; - int n; - - std::map, Edge_Less>::iterator edge_it; - std::map::iterator meshIt; - std::vector::iterator pIt; - - m_CurvPos.resize(m_CadMesh.CountPoints()); - m_CurvNeg.resize(m_CadMesh.CountPoints()); - m_MeshStruct.resize(m_CadMesh.CountPoints()); - MeanVec.resize(m_CadMesh.CountPoints(), 0); - - // Fill the map with points (key) and their indices, which correspond - // to the basic triangulation - MeshPnts = m_CadMesh.GetPoints(); - MeshPntsCop = MeshPnts; - MeshFacets2 = m_CadMesh.GetFacets(); - - for (unsigned int i=0; i m_MeshStruct - Handle_Poly_Triangulation aTr = BRep_Tool::Triangulation(aFace,aLocation); - const TColgp_Array1OfPnt& aNodes = aTr->Nodes(); - // create array of node points in absolute coordinate system - TColgp_Array1OfPnt aPoints(1, aNodes.Length()); - for ( Standard_Integer i = 1; i <= aNodes.Length(); i++) - aPoints(i) = aNodes(i).Transformed(aLocation); - - const TColgp_Array1OfPnt2d& aUVNodes = aTr->UVNodes(); - - - BRepAdaptor_Surface aSurface(aFace); - Base::Vector3f Pnt1, Pnt2; - gp_Pnt2d par; - gp_Pnt P; - gp_Vec D1U, D1V; - - for (int i=1; i_ulProp == 0) - { - m_pnt.SetCoord(pIt->x, pIt->y, pIt->z); - VertexBuild.MakeVertex(V,m_pnt,0.001); - pnt2edge.LoadS2(V); - pnt2edge.Perform(); - - if (pnt2edge.IsDone() == false) - { - throw Base::RuntimeError("couldn't perform distance calculation pnt2edge \n"); - } - - dist = pnt2edge.Value(); - - FacePntVector[counter].pnt = *pIt; - FacePntVector[counter].distances.push_back(dist); - FacePntVector[counter].MinEdgeOff.push_back((*edge_it).second[0]); - FacePntVector[counter].MaxEdgeOff.push_back((*edge_it).second[1]); - ++counter; - } - - } - - // Assign the EdgeOffset values to the node on the EDGE - - // Edge -> Polygon -> Nodes - Handle(Poly_PolygonOnTriangulation) polyg; - Handle_Poly_Triangulation aTrLoc; - BRep_Tool::PolygonOnTriangulation(aEdge,polyg,aTrLoc,aloc); - - TColStd_Array1OfInteger IndArr(1,polyg->NbNodes()); - IndArr = polyg->Nodes(); - - const TColgp_Array1OfPnt& Nodes = aTrLoc->Nodes(); - TColgp_Array1OfPnt TrLocPnts(1, Nodes.Length()); - for ( Standard_Integer i = 1; i <= Nodes.Length(); i++) - TrLocPnts(i) = Nodes(i).Transformed(aloc); - - for (int k=0; kNodes().Upper(); ++k) - { - e_pnt = TrLocPnts(IndArr.Value(k+1)); - - mP.x = (float) e_pnt.X(); - mP.y = (float) e_pnt.Y(); - mP.z = (float) e_pnt.Z(); - - meshIt = MeshMap.find(mP); - if (meshIt == MeshMap.end()) - { - cout << "error2" << endl; - return false; - } - - - ++MeanVec[meshIt->second.index]; - - // always use the minimum value - if (((*edge_it).second[0])>((*meshIt).second).minCurv) - ((*meshIt).second).minCurv = (*edge_it).second[0]; - - if ((*edge_it).second[1]<((*meshIt).second).maxCurv) - ((*meshIt).second).maxCurv = (*edge_it).second[1]; - } - } - - // Assign the offset values to the node INSIDE a face - for (unsigned int k=0; ksecond.index; - m_MeshStruct[w].pnt = (*meshIt).first; - - m_MeshStruct[w].minCurv = (((*meshIt).second).minCurv); - m_MeshStruct[w].maxCurv = (((*meshIt).second).maxCurv); - - // output - if (m_MeshStruct[w].maxCurv<10000000000) - { - snprintf(text,10,"%f",m_MeshStruct[w].minCurv); - //snprintf(text,10,"%i",w); - log.addText(m_MeshStruct[w].pnt.x, m_MeshStruct[w].pnt.y, m_MeshStruct[w].pnt.z,text); - } - - if (MeanVec[w] == 1) - log3d.addSinglePoint(m_MeshStruct[w].pnt,4,0,0,0); // inner points -> black - else if (MeanVec[w] == 2) - log3d.addSinglePoint(m_MeshStruct[w].pnt,4,1,1,1); // edge points -> white - else - log3d.addSinglePoint(m_MeshStruct[w].pnt,4,1,0,0); // corner points -> red - - //m_MeshStruct[w].minCurv = (((*meshIt).second).minCurv)/MeanVec[w]; - //m_MeshStruct[w].maxCurv = (((*meshIt).second).maxCurv)/MeanVec[w]; - - //if(m_MeshStruct[w].maxCurv < 100 || fabs(m_MeshStruct[w].minCurv) < 100) - //{ - // if(m_MeshStruct[w].maxCurv > fabs(m_MeshStruct[w].minCurv)) - // { - // snprintf(text,10,"%f",m_MeshStruct[w].minCurv); - // //m_MeshStruct[w].normal.Scale(m_MeshStruct[w].minCurv,m_MeshStruct[w].minCurv,m_MeshStruct[w].minCurv); - // logo.addSingleArrow(m_MeshStruct[w].pnt, m_MeshStruct[w].pnt+m_MeshStruct[w].normal); - // } - // else - // { - // //snprintf(text,4,"%f",m_MeshStruct[w].maxCurv); - // m_MeshStruct[w].normal.Scale(m_MeshStruct[w].maxCurv,m_MeshStruct[w].maxCurv,m_MeshStruct[w].maxCurv); - // logo.addSingleArrow(m_MeshStruct[w].pnt, m_MeshStruct[w].pnt+m_MeshStruct[w].normal); - // } - //} - - //if(m_MeshStruct[w].maxCurv < 100) - //{ - // m_MeshStruct[w].normal.Scale(0.5*m_MeshStruct[w].maxCurv,0.5*m_MeshStruct[w].maxCurv,0.5*m_MeshStruct[w].maxCurv); - // logo.addSingleArrow(m_MeshStruct[w].pnt, m_MeshStruct[w].pnt+m_MeshStruct[w].normal); - //}*/ - - //snprintf(text,10,"%f",m_MeshStruct[w].maxCurv); - //snprintf(text,10,"%i",w); - - - /*if(m_MeshStruct[w].maxCurv > fabs(m_MeshStruct[w].minCurv)) - { - snprintf(text,10,"%f",m_MeshStruct[w].minCurv); - - } - else - { - snprintf(text,10,"%f",m_MeshStruct[w].maxCurv); - }*/ - - - - } - - log.saveToFile("c:/printCurv.iv"); - log3d.saveToFile("c:/triPnts.iv"); - logo.saveToFile("c:/NormalsCurv.iv"); - - MeshPntsCad = m_CadMesh.GetPoints(); - - - for (unsigned int j=0; j m_MeshStruct - Handle_Poly_Triangulation aTr = BRep_Tool::Triangulation(aFace,aLocation); - const TColgp_Array1OfPnt& aNodes = aTr->Nodes(); - // create array of node points in absolute coordinate system - TColgp_Array1OfPnt aPoints(1, aNodes.Length()); - for ( Standard_Integer i = 1; i <= aNodes.Length(); i++) - aPoints(i) = aNodes(i).Transformed(aLocation); - - const TColgp_Array1OfPnt2d& aUVNodes = aTr->UVNodes(); - - BRepAdaptor_Surface aSurface(aFace); - Base::Vector3f Pnt1, Pnt2; - gp_Pnt2d par; - gp_Pnt P; - gp_Vec D1U, D1V; - std::vector trans_check(m_MeshStruct.size(), false); - - for (int i=1; i EdgeVec; - MeshCore::MeshKernel FaceMesh; - std::vector curvature(2); - std::pair > aPair; - - float maxOffset, minOffset; - - for (anExplorer.Init(m_Shape,TopAbs_EDGE);anExplorer.More();anExplorer.Next()) - { - tempEdgeStruct.aFace.clear(); - tempEdgeStruct.MaxOffset = 1e+10; - tempEdgeStruct.MinOffset = -1e+10; - tempEdgeStruct.anEdge = TopoDS::Edge(anExplorer.Current()); // store current edge - - const TopTools_ListOfShape& aFaceList = anIndex.FindFromKey(tempEdgeStruct.anEdge); - TopTools_ListIteratorOfListOfShape aListIterator; - - for (aListIterator.Initialize(aFaceList);aListIterator.More(); aListIterator.Next()) - { - // store corresponding faces - aFace = TopoDS::Face(aListIterator.Value()); - tempEdgeStruct.aFace.push_back(aFace); - TransferFaceTriangulationtoFreeCAD(aFace, FaceMesh); - curvature = MeshCurvature(aFace, FaceMesh); - - if (aFace.Orientation() == TopAbs_REVERSED) - { - maxOffset = (float) -curvature[1]; - minOffset = (float) -curvature[0]; - } - else - { - maxOffset = (float) curvature[0]; - minOffset = (float) curvature[1]; - } - - if (maxOffset < tempEdgeStruct.MaxOffset) - tempEdgeStruct.MaxOffset = maxOffset; - - if (minOffset > tempEdgeStruct.MinOffset) - tempEdgeStruct.MinOffset = minOffset; - } - - - if (tempEdgeStruct.MaxOffset > max) - curvature[1] = tempEdgeStruct.MaxOffset; - else - curvature[1] = cMin; - - if (-tempEdgeStruct.MinOffset > max) - curvature[0] = tempEdgeStruct.MinOffset; - else - curvature[0] = -cMin; - - aPair.first = tempEdgeStruct.anEdge; - aPair.second = curvature; - EdgeMap.insert(aPair); - - } - return true; -} - -bool SpringbackCorrection::Init_Setting(struct CuttingToolsSettings& set) -{ - m_set = set; - return true; -} - -bool SpringbackCorrection::SetFixEdges() -{ - TopExp_Explorer anExplorer; - TopoDS_Edge anEdge; - std::map, Edge_Less>::iterator edge_it; - std::vector pair(2,0.0); - - for (unsigned int i=0; isecond = pair; - } - } - - return true; -} - -bool SpringbackCorrection::TransferFaceTriangulationtoFreeCAD(const TopoDS_Face& aFace, MeshCore::MeshKernel& FaceMesh) -{ - FaceMesh.Clear(); - MeshCore::MeshBuilder builder(FaceMesh); - builder.Initialize(1000); - Base::Vector3f Points[3]; - - TopLoc_Location aLocation; - // takes the triangulation of the face aFace: - Handle_Poly_Triangulation aTr = BRep_Tool::Triangulation(aFace,aLocation); - if (!aTr.IsNull()) // if this triangulation is not NULL - { - // takes the array of nodes for this triangulation: - const TColgp_Array1OfPnt& aNodes = aTr->Nodes(); - // takes the array of triangles for this triangulation: - const Poly_Array1OfTriangle& triangles = aTr->Triangles(); - // create array of node points in absolute coordinate system - TColgp_Array1OfPnt aPoints(1, aNodes.Length()); - for ( Standard_Integer i = 1; i <= aNodes.Length(); i++) - aPoints(i) = aNodes(i).Transformed(aLocation); - // Takes the node points of each triangle of this triangulation. - // takes a number of triangles: - Standard_Integer nnn = aTr->NbTriangles(); - Standard_Integer nt,n1,n2,n3; - for ( nt = 1 ; nt < nnn+1 ; nt++) - { - // takes the node indices of each triangle in n1,n2,n3: - triangles(nt).Get(n1,n2,n3); - // takes the node points: - gp_Pnt aPnt1 = aPoints(n1); - Points[0].Set(float(aPnt1.X()),float(aPnt1.Y()),float(aPnt1.Z())); - gp_Pnt aPnt2 = aPoints(n2); - Points[1].Set((float) aPnt2.X(),(float) aPnt2.Y(),(float) aPnt2.Z()); - gp_Pnt aPnt3 = aPoints(n3); - Points[2].Set((float) aPnt3.X(),(float) aPnt3.Y(),(float) aPnt3.Z()); - // give the occ faces to the internal mesh structure of freecad - MeshCore::MeshGeomFacet Face(Points[0],Points[1],Points[2]); - builder.AddFacet(Face); - } - - } - // if the triangulation of only one face is not possible to get - else - { - throw Base::RuntimeError("Empty face triangulation\n"); - } - - // finish FreeCAD Mesh Builder and exit with new mesh - builder.Finish(); - return true; - -} - -/* -MeshCore::MeshKernel SpringbackCorrection::BuildMesh(Handle_Poly_Triangulation aTri, std::vector TrPoints) -{ - MeshCore::MeshKernel FaceMesh; - MeshCore::MeshBuilder builder(FaceMesh); - builder.Initialize(1000); - Base::Vector3f Points[3]; - - const Poly_Array1OfTriangle& triangles = aTri->Triangles(); - Standard_Integer nnn = aTri->NbTriangles(); - Standard_Integer nt,n1,n2,n3; - - for ( nt = 1 ; nt < nnn+1 ; nt++) - { - // takes the node indices of each triangle in n1,n2,n3: - triangles(nt).Get(n1,n2,n3); - // takes the node points: - Points[0] = TrPoints[n1]; - Points[1] = TrPoints[n2]; - Points[2] = TrPoints[n3]; - // give the occ faces to the internal mesh structure of freecad - MeshCore::MeshGeomFacet Face(Points[0],Points[1],Points[2]); - builder.AddFacet(Face); - } - - // finish FreeCAD Mesh Builder and exit with new mesh - builder.Finish(); - - return FaceMesh; -} -*/ - -int SpringbackCorrection::GetBoundary(const MeshCore::MeshKernel &mesh, MeshCore::MeshPointArray &meshPnts) -{ - // get mesh-boundary - // purpose: the curvature value is only calculated for the inner points using the edge distances - std::list< std::vector > BoundariesIndex; - std::list< std::vector >::iterator bInd; - - - MeshCore::MeshAlgorithm algo(mesh); - algo.GetMeshBorders(BoundariesIndex); - //Set all MeshPoints to Property 0 - for (unsigned int i=0;isize();++i) - { - meshPnts[(*bInd).at(i)].SetProperty(1); - } - - } - for (unsigned int i=0;i PntNei; - std::set::iterator pnt_it; - - int n = m_MeshStruct.size(); - - std::vector SCMax(n); - std::vector SCMin(n); - double maxCurv = 0.0, minCurv = 0.0; - - for (v_it.Begin(); v_it.More(); v_it.Next()) - { - PntNei = vv_it[v_it.Position()]; - maxCurv += m_MeshStruct[v_it.Position()].maxCurv; - minCurv += m_MeshStruct[v_it.Position()].minCurv; - - for (pnt_it = PntNei.begin(); pnt_it !=PntNei.end(); ++pnt_it) - { - maxCurv += m_MeshStruct[(*pnt_it)[0]._ulProp].maxCurv; - minCurv += m_MeshStruct[(*pnt_it)[0]._ulProp].minCurv; - } - - SCMax[v_it.Position()] = maxCurv/(PntNei.size()+1); - SCMin[v_it.Position()] = minCurv/(PntNei.size()+1); - - maxCurv = 0.0; - minCurv = 0.0; - } - - for (int i=0; i::const_iterator pnt_it; - MeshCore::MeshPointArray::_TConstIterator v_beg = Mesh.GetPoints().begin(); - - Base::Vector3f N, L, coor; - int n = m_MeshStruct.size(); - int g; - - for (v_it.Begin(); v_it.More(); v_it.Next()) - { - - g = v_it.Position(); - spnt.Set(0.0, 0.0, 0.0); - locPointArray.push_back(*v_it); - spnt += *v_it; - const std::set& PntNei = vv_it[(*v_it)._ulProp]; - - if (PntNei.size() < 3) - continue; - - for (pnt_it = PntNei.begin(); pnt_it !=PntNei.end(); ++pnt_it) - { - locPointArray.push_back(v_beg[*pnt_it]); - spnt += v_beg[*pnt_it]; - } - - spnt.Scale((float) (1.0/(double(PntNei.size()) + 1.0)),(float) (1.0/(double(PntNei.size()) + 1.0)),(float) (1.0/(double(PntNei.size()) + 1.0))); - - localMesh.Assign(locPointArray, locFacetArray); - - - // need at least one facet to perform the PCA - MeshCore::MeshGeomFacet face; - face._aclPoints[0] = locPointArray[0]; - face._aclPoints[1] = locPointArray[1]; - face._aclPoints[2] = locPointArray[2]; - localMesh.AddFacet(face); - - MeshCore::MeshEigensystem pca(localMesh); - pca.Evaluate(); - Base::Matrix4D T1 = pca.Transform(); - - N.x = (float) T1[0][0]; - N.y = (float) T1[0][1]; - N.z = (float) T1[0][2]; - L.Set(v_it->x - spnt.x, v_it->y - spnt.y, v_it->z - spnt.z); - N.Normalize(); - - - if (N*L < 0.0) - N.Scale(-1.0, -1.0, -1.0); - - if ((*v_it)._ulProp == 2286) - { - log.addSinglePoint(spnt,4,1,0,0); - log.addSinglePoint(*v_it,4,0,0,0); - for (unsigned int i=0; ix, v_it->y, v_it->z,text);*/ - } - - double d = d_max; - if (fabs(N*L)< d_max) d = fabs(N*L); - N.Scale((float) d,(float) d,(float) d); - - PointArray[v_it.Position()].Set(v_it->x - N.x, v_it->y - N.y, v_it->z - N.z); - locPointArray.clear(); - localMesh = Meshtmp; - } - - Mesh.Assign(PointArray, FacetArray); - log.saveToFile("c:/checkNormals.iv"); - - return true; -} - -bool SpringbackCorrection::SmoothMesh(MeshCore::MeshKernel &Mesh, std::vector ind, double d_max) -{ - Base::Builder3D log; - MeshCore::MeshKernel localMesh, Meshtmp; - MeshCore::MeshPoint mpnt, spnt; - MeshCore::MeshPointArray locPointArray, PointArray = Mesh.GetPoints(); - MeshCore::MeshFacetArray locFacetArray, FacetArray = Mesh.GetFacets(); - - MeshCore::MeshPointIterator v_it(Mesh); - MeshCore::MeshRefPointToPoints vv_it(Mesh); - std::set::const_iterator pnt_it; - MeshCore::MeshPointArray::_TConstIterator v_beg = Mesh.GetPoints().begin(); - - Base::Vector3f N, L, coor; - - int n = ind.size(); - - for (int i=0; i& PntNei = vv_it[(*v_it)._ulProp]; - - if (PntNei.size() < 3) - continue; - - for (pnt_it = PntNei.begin(); pnt_it !=PntNei.end(); ++pnt_it) - { - locPointArray.push_back(v_beg[*pnt_it]); - spnt += v_beg[*pnt_it]; - } - - spnt.Scale((float) (1.0/(double(PntNei.size()) + 1.0)),(float) (1.0/(double(PntNei.size()) + 1.0)),(float) (1.0/(double(PntNei.size()) + 1.0))); - - localMesh.Assign(locPointArray, locFacetArray); - - - // need at least one facet to perform the PCA - MeshCore::MeshGeomFacet face; - face._aclPoints[0] = locPointArray[0]; - face._aclPoints[1] = locPointArray[1]; - face._aclPoints[2] = locPointArray[2]; - localMesh.AddFacet(face); - - MeshCore::MeshEigensystem pca(localMesh); - pca.Evaluate(); - Base::Matrix4D T1 = pca.Transform(); - - N.x = (float) T1[0][0]; - N.y = (float) T1[0][1]; - N.z = (float) T1[0][2]; - L.Set(v_it->x - spnt.x, v_it->y - spnt.y, v_it->z - spnt.z); - N.Normalize(); - - - if (N*L < 0.0) - N.Scale(-1.0, -1.0, -1.0); - - if ((*v_it)._ulProp == 2286) - { - log.addSinglePoint(spnt,4,1,0,0); - log.addSinglePoint(*v_it,4,0,0,0); - for (unsigned int i=0; ix, v_it->y, v_it->z,text);*/ - } - - double d = d_max; - if (fabs(N*L)< d_max) d = fabs(N*L); - N.Scale((float) d,(float) d,(float) d); - - PointArray[v_it.Position()].Set(v_it->x - N.x, v_it->y - N.y, v_it->z - N.z); - locPointArray.clear(); - localMesh = Meshtmp; - } - - Mesh.Assign(PointArray, FacetArray); - log.saveToFile("c:/checkNormals.iv"); - - return true; -} - -/* -bool SpringbackCorrection::GetFaceAng(MeshCore::MeshKernel &mesh, int deg_tol) -{ - Base::Vector3f normal, base; - double deg; - int n = mesh.CountFacets(); - bool b = true; - - for (int i=0; i deg_tol) - b = false; - - m_FaceAng.push_back(deg); - } - - return b; -} -*/ - -std::vector SpringbackCorrection::InitFaceCheck(MeshCore::MeshKernel &mesh, int degree) -{ - std::vector faceInd; - double tol = degree; - double alpha; - MeshCore::MeshFacetIterator fIt(mesh); - MeshCore::MeshPointIterator mIt(mesh); - MeshCore::MeshRefPointToFacets p2fIt(mesh); - Base::Vector3f normal, base, gpnt; - Base::Builder3D log; - - MeshCore::MeshPointArray mPnts = mesh.GetPoints(); - MeshCore::MeshFacetArray mFacets = mesh.GetFacets(); - MeshCore::MeshFacetArray::_TConstIterator f_beg = mesh.GetFacets().begin(); - - int n = mesh.CountFacets(); - - - for (int i=0; i tol) - { - // highlight critical face - mFacets[i].SetProperty(0); - - for (int j=0; j<3; ++j) - { - const std::set& faceSet = p2fIt[mFacets[i]._aulPoints[j]]; - - for (std::set::const_iterator it = faceSet.begin(); it != faceSet.end(); ++it) - { - f_beg[*it].SetProperty(5); - } - } - - log.addSingleArrow(gpnt,gpnt+normal,4,1,0,0); - } - else - { - mFacets[i].SetProperty(1); - faceInd.push_back(i); - } - } - - log.saveToFile("c:/normalschecker.iv"); - - MeshCore::MeshFacetArray mFacets2 = mesh.GetFacets(); - - for (unsigned int i=0; i SpringbackCorrection::FaceCheck(MeshCore::MeshKernel &mesh, int degree) -{ - std::vector faceInd; - double tol = degree; - double alpha; - MeshCore::MeshFacetIterator fIt(mesh); - MeshCore::MeshPointIterator mIt(mesh); - Base::Vector3f normal, base, gpnt; - Base::Builder3D log; - - - MeshCore::MeshPointArray mPnts = mesh.GetPoints(); - MeshCore::MeshFacetArray mFacets = mesh.GetFacets(); - - int n = mesh.CountFacets(); - - for (int i=0; i tol) - { - faceInd.push_back(i); - cout << "i: " << i << ", angle: " << alpha << endl; - } - } - - log.saveToFile("c:/angles.iv"); - return faceInd; -} - -/* -bool SpringbackCorrection::CorrectScale(double zLim) -{ - // DISPLACEMENT VECTORS... - // Calculation of the scaling factors in relation to the Cad norms - int n = m_CadMesh.CountPoints(); - double zLev; - for (int i=0; izLim) - m_Offset[i] = (zLim - m_MeshStruct[i].pnt.z)/m_MeshStruct[i].normal.z; - } - - return true; -} -*/ - -bool SpringbackCorrection::Perform(int deg_Tol, bool out) -{ - unsigned int NumRef; - std::vector dist_vec; - - //GetFaceAng(m_CadMesh, deg_Tol+1); - //cout << "Init" << endl; - //Init(); // tessellate shape -> basic triangulation CAD mesh - // EdgeMap will be filled here - - Base::Vector3f nullvec(0.0,0.0,0.0); - m_dist_vec.resize(m_CadMesh.CountPoints(), nullvec); // fill with null vectors - - cout << "SetFixEdges" << endl; - - SetFixEdges(); - - const MeshCore::MeshKernel RefMesh23 = m_CadMesh; - - cout << "CalcCurv" << endl; - - if (!CalcCurv()) - return false; - - // calculate curvature values using edge curvatures - // MeshMap is filled here - - const MeshCore::MeshKernel RefMesh = m_CadMesh; // apply CAD mesh before deforming - - /*Base::Builder3D log; - Base::Vector3f gpnt, normal; - int numb = m_CadMesh.CountFacets(); - - for (int i=0; i (m_MeshStruct[i].maxCurv - m_set.master_radius)) - m_Offset.push_back(m_MeshStruct[i].maxCurv - m_set.master_radius); - else - m_Offset.push_back(-m_MeshStruct[i].error); - } - else - { - if ((m_MeshStruct[i].minCurv + m_set.slave_radius) > 0.0) - m_Offset.push_back(0.0); - else if (m_MeshStruct[i].error > -(m_MeshStruct[i].minCurv + m_set.slave_radius)) - m_Offset.push_back(m_MeshStruct[i].minCurv + m_set.slave_radius); - else - m_Offset.push_back(-m_MeshStruct[i].error); - } - } - - //Base::BoundBox3f bbox = m_CadMesh.GetBoundBox(); // hole bounding box - //CorrectScale(bbox.MaxZ); // correct displacement vectors... - - //m_set.correction_factor = -0.1; - // scaling of the Cad normals - for (int i=0; i tmpVec; - tmpVec = FaceCheck(m_CadMesh, deg_Tol+1); - - NumRef = (int) tmpVec.size(); - - MeshCore::MeshPointArray pntAr = m_CadMesh.GetPoints(); - MeshCore::MeshFacetArray facAr = m_CadMesh.GetFacets(); - - // Mirroring - Base::Builder3D log3d; - for (int i=0; i tmpVec; - std::vector normalsRef = m_normals; - int cc = 0; - - - - // ********************************** GLOBAL CORRECTION **************************************** - int cm = 49; - InitFaceCheck(m_CadMesh, deg_Tol+1); // critical triangles -> _ulProp = 0 - MeshCore::MeshFacetArray facAr2 = m_CadMesh.GetFacets(); - - while (true) - { - tmpVec = FaceCheck(m_CadMesh, deg_Tol+1); - cout << "remaining: " << tmpVec.size() << endl; - if (tmpVec.size() == NumRef || cm == 0) - { - cout << cm << "left" << endl; - break; - } - - --cm; - MeshCore::MeshPointArray pntAr2 = RefMesh.GetPoints(); - - for (unsigned int i=0; i aRegion; - std::vector< std::pair > skals; - std::vector< std::vector< std::pair > > RegionSkals; - - MeshCore::MeshBuilder builder(m_Mesh_vis); - builder.Initialize(10000); - MeshCore::MeshBuilder builder2(m_Mesh_vis2); - builder2.Initialize(10000); - - for (int i=0; i& faceSet = p2fIt[m_Regions[0][i]._aulPoints[j]]; - - for (std::set::const_iterator it = faceSet.begin(); it != faceSet.end(); ++it) - { - if((*it)[0]._ulProp == 0) - m_RegionBounds.push_back((*it)[0]); - } - } - }*/ - - - - tmpVec = InitFaceCheck(m_CadMesh, deg_Tol+1); - - cout << " glob: " << tmpVec.size() << endl; - - // ********************************** LOCAL CORRECTION **************************************** - unsigned long ind; - - MeshCore::MeshPointArray tmpPnts = m_CadMesh.GetPoints(); - MeshCore::MeshFacetArray tmpFact = m_CadMesh.GetFacets(); - - Base::Builder3D logic; - int cm_ref = 50-cm; - - for (unsigned int i=0; i NumRef || cm == 0) - { - tmpPnts = m_CadMesh.GetPoints(); - - for (unsigned int k=0; k > SpringbackCorrection::RegionEvaluate(const MeshCore::MeshKernel &mesh, std::vector &RegionFacets, std::vector &normals) -{ - std::list< std::vector > Borders; - std::list< std::vector >::iterator bIt; - std::map RegionMap; - std::map ::iterator rIt; - std::map DistMap; - std::map ::iterator dIt; - std::pair Ind2Pnt; - std::pair Dist2Ind; - - std::vector< std::pair > dists; - std::vector< std::pair< unsigned long, double> > skals; - - MeshCore::MeshAlgorithm algo(mesh); // pass mesh - algo.GetFacetBorders(RegionFacets, Borders); // saves edges of the region in Borders - - MeshCore::MeshFacetArray facets = mesh.GetFacets(); - MeshCore::MeshPointArray points = mesh.GetPoints(); - - // in order to avoid duplicate indices push the points of the region into a map - for (unsigned int i=0; isize(); ++i) - { - distVec = (*rIt).second - (*bIt).at(i); - - if (distVec.Length() < distVal) - distVal = distVec.Length(); - } - } - - Dist2Ind.first = distVal; - Dist2Ind.second = (*rIt).first; - - dists.push_back(Dist2Ind); - DistMap.insert(Dist2Ind); - } - - dIt = DistMap.end(); - --dIt; - double d_max = (*dIt).first; - std::pair pair; - - for (unsigned int i=0; i &FacetRegion, - MeshCore::MeshFacetArray &mFacets) -{ - MeshCore::MeshRefFacetToFacets ff_It(mesh); - - MeshCore::MeshFacet facet = FacetRegion.back(); - const std::set& FacetNei = ff_It[facet._ulProp]; - MeshCore::MeshFacetArray::_TConstIterator f_beg = mesh.GetFacets().begin(); - - std::set::const_iterator f_it; - for (f_it = FacetNei.begin(); f_it != FacetNei.end(); ++f_it) - { - if (f_beg[*f_it]._ucFlag == MeshCore::MeshFacet::VISIT) - { - FacetRegion.push_back(f_beg[*f_it]); - mFacets[f_beg[*f_it]._ulProp].SetFlag(MeshCore::MeshFacet::INVALID); // mark as already assigned - FacetRegionGrowing(mesh, FacetRegion, mFacets); - } - } - - return true; -} - -// -//bool SpringbackCorrection::Init() -//{ -// Base::Builder3D log; -// Base::Vector3f p1,p2; -// double curv; -// // Triangulate Shape (vorläufig) -// best_fit::Tesselate_Shape(m_Shape, m_Mesh, 1); -// -// MeshCurvature(m_Mesh); -// -// std::vector normals = best_fit::Comp_Normals(m_Mesh); -// MeshCore::MeshPointIterator p_it(m_Mesh); -// int i = 0; -// -// for(p_it.Begin(); p_it.More(); p_it.Next()){ -// normals[i].Scale(m_CurvMax[i], m_CurvMax[i], m_CurvMax[i]); -// //p1.Set(PointArray[i].x, PointArray[i].y, PointArray[i].z); -// p2.Set(p_it->x + normals[i].x, p_it->y + normals[i].y, p_it->z + normals[i].z); -// -// -// if(m_CurvMax[i] < 100) -// log.addSingleLine(*p_it, p2, 1 ,0, 0, 0 ); -// -// //cout << p_it->x << ", " << p_it->y << ", " << p_it->z << endl; -// //cout <D2(u_par,v_par,proPnt,D1U,D1V,D2U,D2V,D2UV); - - // first & second main curve - k1 = D1U.CrossMagnitude(D2U) / D1U.Magnitude(); - k2 = D1V.CrossMagnitude(D2V) / D1V.Magnitude(); - - /*if(k1>k2) PointArray[i].SetProperty(1/k1); - else PointArray[i].SetProperty(1/k2);*/ - - if (abs(k1)>abs(k2)) - { - m_CurvMax[i] = 1/k1; - } - else - if (k2!=0) - m_CurvMax[i] = 1/k2; - else - m_CurvMax[i] = 100; - - - D1U.Cross(D1V); - D1U.Normalize(); - D1U.Scale(m_CurvMax[i]); - - p1.x = (float) (proPnt.X() + D1U.X()); - p1.y = (float) (proPnt.Y() + D1U.Y()); - p1.z = (float) (proPnt.Z() + D1U.Z()); - - p2.x = (float) proPnt.X(); - p2.y = (float) proPnt.Y(); - p2.z = (float) proPnt.Z(); - - log.addSingleLine(p2, p1, 1 ,0, 0, 0 ); - } - - - MeshCore::MeshPointIterator v_it(m_Mesh); - MeshCore::MeshRefPointToPoints vv_it(m_Mesh); - MeshCore::MeshPointArray::_TConstIterator v_beg = m_Mesh.GetPoints().begin(); - std::set PntNei; - std::set PntNei2; - std::set PntNei3; - std::set PntNei4; - std::set::iterator pnt_it1; - std::set::iterator pnt_it2; - std::set::iterator pnt_it3; - std::set::iterator pnt_it4; - std::vector nei; - double curv; - - std::vector CurvCop = m_CurvMax; - - for (v_it.Begin(); v_it.More(); v_it.Next()) - { - PntNei = vv_it[v_it.Position()]; - curv = m_CurvMax[v_it.Position()]; - - for (pnt_it1 = PntNei.begin(); pnt_it1 !=PntNei.end(); ++pnt_it1) - { - if (m_CurvMax[v_beg[*pnt_it1]._ulProp] < curv) - curv = m_CurvMax[v_beg[*pnt_it1]._ulProp]; - - PntNei2 = vv_it[v_beg[*pnt_it1]._ulProp]; - for (pnt_it2 = PntNei2.begin(); pnt_it2 !=PntNei2.end(); ++pnt_it2) - { - if (m_CurvMax[v_beg[*pnt_it2]._ulProp] < curv) - curv = m_CurvMax[v_beg[*pnt_it2]._ulProp]; - - - PntNei3 = vv_it[v_beg[*pnt_it2]._ulProp]; - for (pnt_it3 = PntNei3.begin(); pnt_it3 !=PntNei3.end(); ++pnt_it3) - { - if (m_CurvMax[v_beg[*pnt_it3]._ulProp] < curv) - curv = m_CurvMax[v_beg[*pnt_it3]._ulProp]; - - PntNei4 = vv_it[v_beg[*pnt_it3]._ulProp]; - for (pnt_it4 = PntNei4.begin(); pnt_it4 !=PntNei4.end(); ++pnt_it4) - { - if (m_CurvMax[v_beg[*pnt_it4]._ulProp] < curv) - curv = m_CurvMax[v_beg[*pnt_it4]._ulProp]; - } - } - } - } - - CurvCop[v_it.Position()] = curv; - } - - m_CurvMax = CurvCop; - - - return true; -} - - -// 1. Computes the curvature of the mesh at the vertices -// 2. Stores the minimum curvatures along the neighbours for all vertices in a vector -std::vector SpringbackCorrection::MeshCurvature(const TopoDS_Face& aFace, const MeshCore::MeshKernel& mesh) -{ - - TopLoc_Location aLocation; - Handle_Poly_Triangulation aTr = BRep_Tool::Triangulation(aFace,aLocation); - const TColgp_Array1OfPnt2d& aUVNodes = aTr->UVNodes(); - int n = aUVNodes.Length(); - BRepAdaptor_Surface aSurface(aFace); - - gp_Pnt2d par; - gp_Pnt P; - gp_Vec D1U, D1V, D2U, D2V, D2UV, nor, xvv, xuv, xuu; - double H,K; // Gaussian and average curvature - - std::vector aMaxCurve, aMinCurve; - std::vector curv(2); - - for (int i=0; i 0) m_CurvPos[i] = 1 / aMaxCurve[i]; - else m_CurvPos[i] = 1e+10; - - if (aMinCurve[i] < 0) m_CurvNeg[i] = 1 / aMinCurve[i]; - else m_CurvNeg[i] = -1e+10; - - if (m_CurvPos[i] < tmp1) - tmp1 = m_CurvPos[i]; - - if (m_CurvNeg[i] > tmp2) - tmp2 = m_CurvNeg[i]; - - if (aMaxCurve[i] > 0) - { - ++c1; - mean_curvMax += 1/aMaxCurve[i]; - } - - if (aMinCurve[i] < 0) - { - ++c2; - mean_curvMin += 1/aMinCurve[i]; - } - } - - if (c1==0) - mean_curvMax = 1e+3; - else - mean_curvMax /= mesh.CountPoints(); - - if (c2==0) - mean_curvMin = -1e+3; - else - mean_curvMin /= mesh.CountPoints(); - - curv[0] = tmp1; - curv[1] = tmp2; - - - - - //Mesh-based curvature - - for(int i=0; i > aPnts; - std::vector aPnts_tmp; - MeshCore::MeshPointIterator cPIt( mesh ); - for ( cPIt.Init(); cPIt.More(); cPIt.Next() ) - { - Wm4::Vector3 cP( cPIt->x, cPIt->y, cPIt->z ); - Base::Vector3f cP_tmp( cPIt->x, cPIt->y, cPIt->z ); - aPnts.push_back( cP ); - aPnts_tmp.push_back(cP_tmp); - } - - // get all point connections - std::vector anIdx; - const std::vector& MeshFacetArray = mesh.GetFacets(); - for ( std::vector::const_iterator jt = MeshFacetArray.begin(); jt != MeshFacetArray.end(); ++jt ) - { - for (int i=0; i<3; i++) - { - anIdx.push_back( (int)jt->_aulPoints[i] ); - } - } - - // compute vertex based curvatures - Wm4::MeshCurvature meshCurv(mesh.CountPoints(), &(aPnts[0]), mesh.CountFacets(), &(anIdx[0])); - - // get curvature information now - const Wm4::Vector3* aMaxCurvDir = meshCurv.GetMaxDirections(); - const Wm4::Vector3* aMinCurvDir = meshCurv.GetMinDirections(); - const float* aMaxCurv = meshCurv.GetMaxCurvatures(); - const float* aMinCurv = meshCurv.GetMinCurvatures(); - - double maxCurv = 0.0; - double avgCurv = 0.0; - double tmp1 = 1e+10; - double tmp2 = -1e+10; - - double mean_curvMax = 0.0, mean_curvMin = 0.0; - int c1 = 0, c2 = 0; - - m_CurvPos.clear(); - m_CurvNeg.clear(); - m_CurvMax.clear(); - m_CurvPos.resize(mesh.CountPoints()); - m_CurvNeg.resize(mesh.CountPoints()); - m_CurvMax.resize(mesh.CountPoints()); - - for ( unsigned long i=0; i 0) m_CurvPos[i] = 1 / aMaxCurv[i]; - else m_CurvPos[i] = 1e+10; - - if (aMinCurv[i] < 0) m_CurvNeg[i] = 1 / aMinCurv[i]; - else m_CurvNeg[i] = -1e+10; - - if (m_CurvPos[i] < tmp1) - tmp1 = m_CurvPos[i]; - - if (m_CurvNeg[i] > tmp2) - tmp2 = m_CurvNeg[i]; - - if (aMaxCurv[i] > 0) - { - ++c1; - mean_curvMax += 1/aMaxCurv[i]; - } - - if (aMinCurv[i] < 0) - { - ++c2; - mean_curvMin += 1/aMinCurv[i]; - } - } - - if (c1==0) - mean_curvMax = 1e+3; - else - mean_curvMax /= mesh.CountPoints(); - - if (c2==0) - mean_curvMin = -1e+3; - else - mean_curvMin /= mesh.CountPoints(); - - curv[0] = tmp1; - curv[1] = tmp2; - } - - - return curv; -} - -/* -bool SpringbackCorrection::MirrorMesh(std::vector error) -{ - // Flags: 0 - not yet checked - // 1 - no correction applied, but necessary - // 2 - first correction applied and still necessary - // 3 - done successfully - // 4 - done without success - // 5 - boundary point - - int n = error.size(); - m_error = error; - - std::vector InterPnts; - std::vector InterFace; - std::vector IFCopy; - - bool boo = true; - - std::vector ind; - std::vector copy; - - MeshRef = m_Mesh; - std::vector NormalsRef = m_normals; - std::vector NormalOrig = m_normals; - - PointArray = MeshRef.GetPoints(); - MeshCore::MeshPointArray PntArray = m_Mesh.GetPoints(); - MeshCore::MeshFacetArray FctArray = m_Mesh.GetFacets(); - MeshCore::MeshFacetArray FacetArray = MeshRef.GetFacets(); - - MeshCore::MeshFacetIterator f_it(MeshRef); - MeshCore::MeshPointIterator v_it(MeshRef); - MeshCore::MeshRefPointToPoints vv_it(MeshRef); - MeshCore::MeshRefPointToFacets vf_it(MeshRef); - - std::set PntNei; - std::set FacetNei; - - // Iterates in facets in form of MeshGeomFacets - std::set::iterator face_it; - std::set::iterator pnt_it; - - std::vector NeiLoc; - std::vector NorLoc; - std::vector TmpPntVec; - std::vector TmpIndVec; - std::vector nei; - - bool k=true; - int count = 0; - - while (k==true) - { - // ------ Self-Intersection Check + Correction ------------------------------------------------------ - - if (count ==2) break; - count++; - - Base::Builder3D log3d; - Base::Builder3D loga; - Base::Vector3f Pnt, NeiPnt, NeiPntNext, NeiPntPrev, TmpPnt, TmpNor; - - std::vector Neis; - double minScale, tmp; - bool sign; - - ublas::matrix A(3, 3); - ublas::matrix b(1, 3); - - ind.clear(); - for (unsigned int i=0; i 0); // (+) -> true , (-) -> false - - MeshRef.Assign(PointArray, FacetArray); - - v_it.Set(ind[j]); - - Pnt = *v_it; - PntNei = vv_it[ind[j]]; - FacetNei = vf_it[ind[j]]; - - nei.clear(); - - // falls boundary-point tue nichts bzw. gehe zum nächsten punkt - if (FacetNei.size() != PntNei.size()) - { - PointArray[ind[j]]._ucFlag = 5; - m_CurvMax[ind[j]] = abs(error[ind[j]]); // vorübergehend - continue; - } - - // ordne nachbarn - ReorderNeighbourList(PntNei,FacetNei,nei,ind[j]); - - NeiLoc.clear(); - NorLoc.clear(); - NeiLoc.push_back(Pnt); - NorLoc.push_back(NormalsRef[ind[j]]); - - for (unsigned int r=0; r 0) - { - PointArray[ind[j]]._ucFlag = 3; - m_CurvMax[ind[j]] = abs(minScale); - //cout << "t, "; - continue; - } - else - { - PointArray[ind[j]]._ucFlag = 4; - m_CurvMax[ind[j]] = abs(minScale); - cout << "f, "; - continue; - } - } - - - if (sign ==true) minScale = -(1e+10); - else minScale = 1e+10; - - minScale = LocalCorrection(NeiLoc,NorLoc,sign,minScale); - - if ((abs(0.8*minScale) - abs(error[ind[j]])) > 0) - { - PointArray[ind[j]]._ucFlag = 3; - m_CurvMax[ind[j]] = abs(minScale); - continue; - } - - //---------------------------- 1. Correction -------------------- - tmp = 0; - std::vector ConvComb = FillConvex(NeiLoc,NorLoc,20); - - for (unsigned int l=0; l abs(tmp)) - { - tmp = minScale; - TmpPnt = NeiLoc[0]; - } - } - - NeiLoc[0] = PointArray[ind[j]]; - cout << "new minScale: " << tmp << endl; - - if ((abs(0.8*tmp) - abs(error[ind[j]])) > 0) - { - PointArray[ind[j]].Set(TmpPnt.x, TmpPnt.y, TmpPnt.z); - PointArray[ind[j]]._ucFlag = 3; - m_CurvMax[ind[j]] = abs(tmp); - continue; - } - else - { - PointArray[ind[j]]._ucFlag = 2; - m_CurvMax[ind[j]] = abs(tmp); - } - - //------------------------------- END ------------------------------- - - // update - for (unsigned int r=0; r 0) - { - PointArray[ind[j]].Set(NeiLoc[0].x, NeiLoc[0].y, NeiLoc[0].z); - NormalsRef[ind[j]].Set(NorLoc[0].x, NorLoc[0].y, NorLoc[0].z); - PointArray[ind[j]]._ucFlag = 3; - m_CurvMax[ind[j]] = abs(tmp); - continue; - } - else - { - if (m_CurvMax[ind[j]] < abs(tmp)) - { - m_CurvMax[ind[j]] = abs(tmp); - PointArray[ind[j]].Set(NeiLoc[0].x, NeiLoc[0].y, NeiLoc[0].z); - NormalsRef[ind[j]].Set(NorLoc[0].x, NorLoc[0].y, NorLoc[0].z); - } - // flag bleibt 2 - } - - //------------------------------- END ------------------------------- - - } // end for - - cout << "Replace Mesh..." << endl; - PntArray = PointArray; - m_normals = NormalsRef; - m_Mesh = MeshRef; - - } // end while - - - double ver, mx=100; - for (unsigned int i=0; i IndexVec,NumVec, NumVecCopy; - int c, lastNum, lastInd; - - // Save critical points plus number of your critical neighbors - //ind.clear(); - for (unsigned int j=0; j_ulProp]._ucFlag == 4) - c++; - } - - IndexVec.push_back(ind[j]); - NumVec.push_back(c); - } - } - - // normal scaling - for (unsigned int j=0; j SortNumVec(NumVec.size(), -1); - std::vector SortIndVec(NumVec.size(), -1); - cout << NumVec.size() << endl; - - //cout << "before sorting: "; - //for(int j=0; j v(3); - - v[0].x = (float) T1[0][0]; - v[0].y = (float) T1[0][1]; - v[0].z = (float) T1[0][2]; - v[1].x = (float) T1[1][0]; - v[1].y = (float) T1[1][1]; - v[1].z = (float) T1[1][2]; - v[2].x = (float) T1[2][0]; - v[2].y = (float) T1[2][1]; - v[2].z = (float) T1[2][2]; - - v[0].Normalize(); - v[1].Normalize(); - v[2].Normalize(); - - double deg,temp=0; - int s; - - for (int i=0; i<3; ++i) - { - deg = v[i]*NormalOrig[SortIndVec[j]]; - if (abs(deg)>temp) - { - temp = abs(deg); - s=i; - } - } - - if (v[s].z < 0.0) - v[s] *= -1; - - for (unsigned int i=0; i Convs = FillConvex(NeiLoc, NorLoc, 20); - - for (unsigned int i=0; i Neib , - std::vector Normal, bool sign, double minScale) -{ - Base::Vector3f Pnt, NeiPnt, NeiPntNext, NeiPntPrev; - - ublas::matrix A(3, 3); - ublas::matrix b(1, 3); - - // 2. Spalte bleibt unverändert - A(0,2) = -Normal[0].x; - A(1,2) = -Normal[0].y; - A(2,2) = -Normal[0].z; - - // forward - for (unsigned int k=1; k=0) && (b(0,1)<=1)) - { - if (minScale < b(0,2)) - minScale = b(0,2); - } - else if (b(0,2)>=0 && sign == false && (b(0,1)>=0) && (b(0,1)<=1)) - { - if (minScale > b(0,2)) - minScale = b(0,2); - } - } - - // backward - for (unsigned int k=1; k=0) && (b(0,1)<=1)) - { - if (minScale < b(0,2)) - minScale = b(0,2); - } - else if (b(0,2)>0 && sign == false && (b(0,1)>=0) && (b(0,1)<=1)) - { - if (minScale > b(0,2)) - minScale = b(0,2); - } - } - - return minScale; -} -*/ - -/* -std::vector SpringbackCorrection::FillConvex(std::vector Neib, std::vector Normals, int n) -{ - std::vector ConvComb; - Base::Vector3f tmp; - for (unsigned int i=1; i Neib) -{ - Base::Vector3f Pnt, NeiPnt, NeiPntNext, Cross; - - ublas::matrix A(3, 3); - ublas::matrix b(1, 3); - - bool b1 = true, b2; - - for (unsigned int k=1; k0) - { - b1 = false; - b2 = false; - } - } - - if (b1==false) - { - if ((b2 == true) && (b(0,2) > 0)) return false; - if ((b2 == false) && (b(0,2) < 0)) return false; - } - } - return true; -} -*/ - -/* -double SpringbackCorrection::GlobalCorrection(std::vector NeiLoc, std::vector NorLoc, - bool sign, int ind) -{ - double minScale,mScRef,tmp = 0; - Base::Vector3f TmpPnt, TmpNor; - - if (sign ==true) mScRef = -(1e+10); - else mScRef = 1e+10; - - minScale = mScRef; - minScale = LocalCorrection(NeiLoc,NorLoc,sign,minScale); - - if ((abs(0.8*minScale) - abs(m_error[ind])) > 0) - { - PointArray[ind]._ucFlag = 3; - m_CurvMax[ind] = abs(minScale); - return minScale; - } - - std::vector ConvComb = FillConvex(NeiLoc,NorLoc,20); - - // füge schwerpunkte der umgebenden faces hinzu - std::set FacetNei; - std::set::iterator face_it; - MeshCore::MeshFacetIterator f_it (MeshRef); - MeshCore::MeshRefPointToFacets vf_it(MeshRef); - - FacetNei = vf_it[ind]; - - for (face_it = FacetNei.begin(); face_it != FacetNei.end(); ++face_it) - { - TmpPnt.Set(0.0, 0.0, 0.0); - TmpPnt += PointArray[(*face_it)->_aulPoints[0]]; - TmpPnt += PointArray[(*face_it)->_aulPoints[1]]; - TmpPnt += PointArray[(*face_it)->_aulPoints[2]]; - TmpPnt.Scale((float) (1.0/3.0),(float) (1.0/3.0),(float) (1.0/3.0)); - ConvComb.push_back(TmpPnt); - } - - //Base::Builder3D logg; - //for(int i=0; i tmp) - { - tmp = minScale; - TmpPnt = NeiLoc[0]; - TmpNor = NorLoc[0]; - } - } - } - - NeiLoc[0] = TmpPnt; - NorLoc[0] = TmpNor; - - if ((abs(0.8*tmp) - abs(m_error[ind])) > 0) - { - PointArray[ind]._ucFlag = 3; - m_CurvMax[ind] = abs(tmp); - } - else - { - PointArray[ind]._ucFlag = 4; - m_CurvMax[ind] = abs(tmp); - } - - return tmp; -} -/* - -/*! \brief Reorder the neighbour list - - This function will reorder the list in one-direction. Clockwise or counter clockwise is depending on the - facet list and will not be checked by this function. (i.e the third vertex i.e vertex in first facet that - is not the CurIndex or the first neighbour in pnt[Ok, I am also lost with this..., just debug and step to see what I mean...]) -*/ - -/* -void SpringbackCorrection::ReorderNeighbourList(std::set &pnt, - std::set &face, std::vector &nei, unsigned long CurInd) -{ - std::set::iterator pnt_it; - std::set::iterator face_it; - std::vector::iterator vec_it; - std::vector::iterator ulong_it; - unsigned long PrevIndex; - - if (face.size() != pnt.size()) //this means boundary point - { - for (pnt_it = pnt.begin(); pnt_it != pnt.end(); ++pnt_it) - { - int c = 0; - for (face_it = face.begin(); face_it != face.end(); ++face_it) - { - if ((*pnt_it)[0]._ulProp == (*face_it)[0]._aulPoints[0]) - ++c; - if ((*pnt_it)[0]._ulProp == (*face_it)[0]._aulPoints[1]) - ++c; - if ((*pnt_it)[0]._ulProp == (*face_it)[0]._aulPoints[2]) - ++c; - } - - if (c==1) - break; - } - } - else - pnt_it = pnt.begin(); - - - - face_it = face.begin(); - - nei.push_back((*pnt_it)->_ulProp); //push back first neighbour - vec_it = nei.begin(); - PrevIndex = nei[0]; //Initialize PrevIndex - for (unsigned int i = 1; i < pnt.size(); i++) //Start - { - while (true) - { - std::vector facetpnt; - facetpnt.push_back((*face_it)->_aulPoints[0]); //push back into a vector for easier iteration - facetpnt.push_back((*face_it)->_aulPoints[1]); - facetpnt.push_back((*face_it)->_aulPoints[2]); - if ((ulong_it = find(facetpnt.begin(), facetpnt.end(), PrevIndex)) == facetpnt.end()) //if PrevIndex not found - { - //in current facet - if (face_it != face.end()) - ++face_it; //next face please - else - break; - - continue; - } - else - { - for (unsigned int k = 0 ; k < 3; k++) - { - //If current facetpnt[k] is not yet in nei_list AND it is not the CurIndex - if (((vec_it = find(nei.begin(), nei.end(), facetpnt[k])) == nei.end()) && facetpnt[k] != CurInd) - { - face.erase(face_it); //erase this face - nei.push_back(facetpnt[k]); //push back the index - PrevIndex = facetpnt[k]; //this index is now PrevIndex - face_it = face.begin(); //reassign the iterator - break; //end this for-loop - } - } - break; //end this while loop - } - } - } -} -*/ - - -bool SpringbackCorrection::Visit(const MeshCore::MeshFacet &rclFacet, const MeshCore::MeshFacet &rclFrom, unsigned long ulFInd, unsigned long ulLevel) -{ - if (ulLevel != m_RingCurrent) - { - ++m_RingCurrent; - - if (m_RingVector.size() == 0) - { - return false; - } - //else if(m_RingVector.size() < 2 && m_RingCurrent > 2) - //{ - // m_RingVector.clear(); - // return false; - //} - else - { - m_RegionVector.push_back(m_RingVector); - m_RingVector.clear(); - } - } - - if (rclFacet._ulProp == 1 && rclFrom._ulProp == 1) - m_RingVector.push_back(ulFInd); - - return true; -} diff --git a/src/Mod/Cam/App/SpringbackCorrection.h b/src/Mod/Cam/App/SpringbackCorrection.h deleted file mode 100644 index 8dce189c78..0000000000 --- a/src/Mod/Cam/App/SpringbackCorrection.h +++ /dev/null @@ -1,341 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2007 Joachim Zettler * - * Copyright (c) 2007 Human Rezai * - * * - * This file is part of the FreeCAD CAx development system. * - * * - * This library is free software; you can redistribute it and/or * - * modify it under the terms of the GNU Library General Public * - * License as published by the Free Software Foundation; either * - * version 2 of the License, or (at your option) any later version. * - * * - * This library is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * - * GNU Library General Public License for more details. * - * * - * You should have received a copy of the GNU Library General Public * - * License along with this library; see the file COPYING.LIB. If not, * - * write to the Free Software Foundation, Inc., 59 Temple Place, * - * Suite 330, Boston, MA 02111-1307, USA * - * * - ***************************************************************************/ - -#ifndef _SpringbackCorrection_H_ -#define _SpringbackCorrection_H_ - - -#include -#include "cutting_tools.h" - -/** @brief The main class for the SpringbackCorrection routine - - It takes a mesh and a Topo_Shape and computes - a deformation of the triangulated Topo_Shape. - The deformation is based on mirroring the input-mesh on the Topo_Shape. -*/ - -class MeshFacet; - - - - -# define cMin 15.0 -# define toolRad 5.0 - -/** @brief a struct referring to the edges of the input-shape - - @param anEdge edge - @param aFace vector of faces limited by edge - @param pntList point-vector of the mesh-points of the edge - @param MaxOffset maximum curvature-radius - @param MinOffset minimum curvature-radius -*/ -struct EdgeStruct -{ - TopoDS_Edge anEdge; - std::vector aFace; - std::vector pntList; - double MaxOffset; - double MinOffset; -}; - -/** @brief a struct referring to the mesh-points of the input-shape - - @param index index of the mesh-point - @param minCurv minimum curvature-radius - @param maxCurv maximum curvature-radius - @param error distance value - @param pnt mesh-point - @param normal normal-vector -*/ -struct MeshPnt -{ - int index; - double minCurv; - double maxCurv; - double error; - Base::Vector3f pnt; - Base::Vector3f normal; -}; - -/** @brief a struct for computing the maximum and minimum curvature-radius - of a single mesh-point - @param pnt mesh-point - @param distances distance-vector to all surrounding edges - @param MinEdgeOff minimum curvature-radii of surrounding edges - @param MaxEdgeOff maximum curvature-radii of surrounding edges -*/ -struct FacePnt -{ - Base::Vector3f pnt; - std::vector distances; - std::vector MinEdgeOff; - std::vector MaxEdgeOff; -}; - -struct EdgeStruct_Less -{ - bool operator()(const EdgeStruct& _Left, const EdgeStruct& _Right) const - { - - if (_Left.anEdge.IsSame(_Right.anEdge)) return false; - - return true; - } -}; - -struct Edge_Less -{ - bool operator()(const TopoDS_Edge& _Left, const TopoDS_Edge& _Right) const - { - return(_Left.HashCode(IntegerLast())<_Right.HashCode(IntegerLast())); - } -}; - - - - -struct MeshPntLess -{ - bool operator()(const Base::Vector3f& _Left, const Base::Vector3f& _Right) const - { - if ( fabs(_Left.x - _Right.x) > 0.0001 ) - return _Left.x < _Right.x; - else if ( fabs(_Left.y - _Right.y) > 0.0001) - return _Left.y < _Right.y; - else if ( fabs(_Left.z - _Right.z) > 0.0001 ) - return _Left.z < _Right.z; - return false; - - } -}; - -class CamExport SpringbackCorrection : public MeshCore::MeshFacetVisitor -{ -public: - /** @brief Constructor */ - SpringbackCorrection(); - /** @brief Constructor - - @param aShape input-shape (CAD-Model) - @param aMesh input-mesh - */ - SpringbackCorrection(const TopoDS_Shape& aShape, const MeshCore::MeshKernel& aMesh); - /** @brief Constructor */ - //SpringbackCorrection(const TopoDS_Shape& aShape, const MeshCore::MeshKernel& aMesh, const MeshCore::MeshKernel& bMesh); - - ~SpringbackCorrection(); - /** @brief loads input-mesh */ - bool Load(const MeshCore::MeshKernel& aMesh); - /** @brief loads input-shape */ - bool Load(const TopoDS_Shape& aShape); - /** @brief loads input-shape and -mesh */ - bool Load(const TopoDS_Shape& aShape, const MeshCore::MeshKernel& aMesh); - /** @brief sets parameter-values to initial state, tessellates the input - shape and computes a curvature-radius-value at each edge - contained in the input-shape */ - bool Init(); - /** @brief get external setting-parameters */ - bool Init_Setting(struct CuttingToolsSettings& set); - - /** @brief main-function - - @param deg_Tol limiting forming-angle - @param out - @todo undocumented parameter out - */ - bool Perform(int deg_Tol, bool out); - - /** @brief sets curvature-radius-value of user-specified edges to zero */ - bool SetFixEdges(); - /** @brief calculates curvature-values as a distance-weighted - convexcombination */ - bool CalcCurv(); - - /** @brief Computes mesh-based curvature-values at each mesh-point - - @param aFace - @param mesh input-mesh - @todo undocumented parameter aFace - */ - std::vector MeshCurvature(const TopoDS_Face& aFace, const MeshCore::MeshKernel& mesh); - - /** @brief computes maximum and minimum curvature-values of the specified - input-face \p aFace - @param aFace input-face */ - bool GetCurvature(TopoDS_Face aFace); - - //bool MirrorMesh(std::vector error); - //double LocalCorrection(std::vector Neib ,std::vector Normal, - // bool sign, double minScale); - //double GlobalCorrection(std::vector Neib ,std::vector Normal, - // bool sign, int ind); - - //std::vector FillConvex(std::vector Neib,std::vector Normals, int n); - //bool InsideCheck(Base::Vector3f pnt, Base::Vector3f normal, std::vector Neib); - - //MeshCore::MeshKernel BuildMesh(Handle_Poly_Triangulation aTri, std::vector TrPoints); - /** @brief returns index-value which specifies the boundary-points of the - input-mesh - - @param mesh input-mesh - @param meshPnts mesh-points of input-mesh - */ - int GetBoundary(const MeshCore::MeshKernel &mesh, MeshCore::MeshPointArray &meshPnts); - //bool SmoothCurvature(); - /** @brief smooths input-mesh - - @param mesh input-mesh - @param maxTranslation value which stands for the maximum deviation - from the initial-mesh - */ - bool SmoothMesh(MeshCore::MeshKernel &mesh, double maxTranslation); - /** @brief smooths specified mesh-points of the input-mesh - - @param mesh input-mesh - @param indicies vector of indicies of the mesh-points for - smoothing - @param maxTranslation value which stands for the maximum deviation - from the initial-mesh - */ - bool SmoothMesh(MeshCore::MeshKernel &mesh, std::vector indicies, double maxTranslation); - /** @brief computes current angles of all triangles and stores the angle - degrees in a vector - - @param mesh input-mesh - @param deg_tol limiting forming-angle - */ - //bool GetFaceAng(MeshCore::MeshKernel &mesh, int deg_tol); - /** @brief computes current angles of all triangles and stores the - critical-triangle-indicies in a vector - - @param mesh input-mesh - @param deg_tol limiting forming-angle - */ - std::vector FaceCheck(MeshCore::MeshKernel &mesh, int deg_tol); - /** @brief computes current angles of all triangles and sets the property - value of the critical triangles to zero - - @param mesh input-mesh - @param deg_tol limiting forming-angle - */ - std::vector InitFaceCheck(MeshCore::MeshKernel &mesh, int deg_tol); - //void ReorderNeighbourList(std::set &pnt, - // std::set &face, - // std::vector &nei, - // unsigned long CurInd); - - /** @brief performs a region-growing-algorithm */ - bool FacetRegionGrowing(MeshCore::MeshKernel &mesh, - std::vector &arr, - MeshCore::MeshFacetArray &mFacets); - - //bool CorrectScale(double max_zVal); - /** @brief checks the visit-state of specified triangle */ - bool Visit(const MeshCore::MeshFacet &rclFacet, const MeshCore::MeshFacet &rclFrom, unsigned long ulFInd, unsigned long ulLevel); - - /** @brief builds a mesh-kernel out of one face-triangulation - - @param aFace face of concern - @param TFaceMesh MeshKernel where the triangulation will be stored - */ - bool TransferFaceTriangulationtoFreeCAD(const TopoDS_Face& aFace, MeshCore::MeshKernel& TFaceMesh); - - /** @brief computes offset-values for the inner-points of the specified - region */ - std::vector< std::pair > RegionEvaluate(const MeshCore::MeshKernel &mesh, std::vector &RegionFacets, std::vector &normals); - - /** @brief input-mesh */ - MeshCore::MeshKernel m_Mesh; - /** @brief mesh containing the movable regions for the local translation - */ - MeshCore::MeshKernel m_Mesh_vis; - /** @brief mesh containing the fix regions for the local translation */ - MeshCore::MeshKernel m_Mesh_vis2; - /** @brief triangulation of the CAD-shape */ - MeshCore::MeshKernel m_CadMesh; - /** @brief vector containing translation-vectors at all mesh-points */ - std::vector m_dist_vec; - -private: - - /** @brief initial input-shape (CAD-model) */ - TopoDS_Shape m_Shape; - /** @brief vector containing the maximum curvature-radius-values at all - mesh-points */ - std::vector m_CurvPos; - /** @brief vector containing the minimum curvature-radius-values at all - mesh-points */ - std::vector m_CurvNeg; - /** @brief */ - std::vector m_CurvMax; - /** @brief struct-vector over all edges */ - std::vector m_EdgeStruct; - /** @brief index-vector for the region-growing-algorithm containing the - triangles at the current ring-neighbourhood */ - std::vector m_RingVector; - /** @brief index-vector for the region-growing-algorithm containing the - triangles of one computed region */ - std::vector< std::vector > m_RegionVector; - /** @brief index-vector for the region-growing-algorithm containing the - triangles of all computed region */ - std::vector< std::vector > m_Regions; - /** @brief */ - //std::vector m_RegionBounds; - /** @brief external setting-parameters */ - CuttingToolsSettings m_set; - /** @brief index which specifies the current ring-neighbourhood for the - region-growing-algorithm */ - int m_RingCurrent; -private: - /** @brief vector over all input-meshes for the iteration-process */ - std::vector m_MeshVec; - /** @brief copy of the initial input-mesh */ - MeshCore::MeshKernel MeshRef; - /** @brief */ - //MeshCore::MeshKernel m_Mesh2Fit; - /** @brief vector over the normal-vectors at all mesh-points */ - std::vector m_normals; - /** @brief vector containing the distance-values at all mesh points - between the initial input-shape (CAD-model) and -mesh */ - std::vector m_error; - /** @brief vector containing the initial angle-degrees of all triangles */ - std::vector m_FaceAng; - /** @brief struct-vector over all mesh-points */ - std::vector m_MeshStruct; - /** @brief vector containing the resulting offset-values of all mesh - points */ - std::vector m_Offset; -public: - /** @brief map which links mesh-point to mesh-index */ - std::map MeshMap; - /** @brief map over all edges */ - std::map, Edge_Less> EdgeMap; - - /** @brief vector containing the user-specified faces which stands fix - during the springback-correction */ - std::vector m_FixFaces; -}; - -#endif diff --git a/src/Mod/Cam/App/UniGridApprox.cpp b/src/Mod/Cam/App/UniGridApprox.cpp deleted file mode 100644 index c2023113ef..0000000000 --- a/src/Mod/Cam/App/UniGridApprox.cpp +++ /dev/null @@ -1,993 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2007 Joachim Zettler * - * Copyright (c) 2007 Human Rezai * - * * - * This file is part of the FreeCAD CAx development system. * - * * - * This library is free software; you can redistribute it and/or * - * modify it under the terms of the GNU Library General Public * - * License as published by the Free Software Foundation; either * - * version 2 of the License, or (at your option) any later version. * - * * - * This library is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * - * GNU Library General Public License for more details. * - * * - * You should have received a copy of the GNU Library General Public * - * License along with this library; see the file COPYING.LIB. If not, * - * write to the Free Software Foundation, Inc., 59 Temple Place, * - * Suite 330, Boston, MA 02111-1307, USA * - * * - ***************************************************************************/ - -#include "PreCompiled.h" -#include "UniGridApprox.h" - -#include "best_fit.h" - -#include -#include - -#include -#include -#include -#include -#include -#include -#include - -// -///*********BINDINGS********/ -#include -#include -#include -// -using namespace boost::numeric::bindings; - -typedef ublas::matrix cm_t; -typedef ublas::symmetric_adaptor adapt; - -UniGridApprox::UniGridApprox(const MeshCore::MeshKernel &mesh, double Tol) - :m_Mesh(mesh),m_Tol(Tol),m_udeg(3),m_vdeg(3) -{ -} - -UniGridApprox::~UniGridApprox() -{ -} - -bool UniGridApprox::Perform(double TOL) -{ - - double maxErr; - cout << "MeshOffset" << endl; - MeshOffset(); - - cout << "SurfMeshParam" << endl; - SurfMeshParam(); - - while (true) - { - cout << "CompKnots" << endl; - CompKnots(uCP, vCP); - - cout << "MatComp" << endl; - MatComp(uCP, vCP); - - BuildSurf(); - - cout << "Compute Error"; - maxErr = CompMeshError(); - - if (maxErr == -1) - throw Base::RuntimeError("CompError() couldn't project one point..."); - - cout << " -> " << maxErr << endl; - - if (maxErr <= TOL) break; - else - { - if (uCP >= vCP) - { - uCP += 10; - vCP += vCP*10/uCP; - } - else - { - vCP += 10; - uCP += uCP*10/vCP; - } - } - - if ( (uCP > (n_x + m_udeg + 1)) || (vCP > (n_y + m_vdeg + 1)) ) break; - - m_Grid.clear(); - m_Grid = m_GridCopy; - } - - return true; -} - -bool UniGridApprox::MeshOffset() -{ - - MeshCore::MeshPointIterator p_it(m_Mesh); - - //temporary solution until CAD standards can be used - std::vector normals = best_fit::Comp_Normals(m_Mesh); - - double x_max=-(1e+10),y_max=-(1e+10),z_max=-(1e+10),x_min=1e+10,y_min=1e+10,st_x,st_y; - int n = normals.size(); - - // perform shift - - //for(int i=0; iz>z_max) z_max = p_it->z; - if (p_it->x>x_max) x_max = p_it->x; - if (p_it->xx; - if (p_it->y>y_max) y_max = p_it->y; - if (p_it->yy; - } - - // grid size can be determined using the bounding box - n_x = int((x_max - x_min)/(y_max - y_min)*sqrt((x_max - x_min)*(y_max - y_min))); - n_y = int((y_max - y_min)/(x_max - x_min)*sqrt((x_max - x_min)*(y_max - y_min))); - - st_x = (x_max - x_min)/n_x; - st_y = (y_max - y_min)/n_y; - - uCP = n_x/10; - vCP = n_y/10; - - m_Grid.resize(n_x+1); - for (int i=0; i (u,v) , ( R x R ) -> ( [0,1] x [0,1] ) - - int n = m_Grid.size()-1; // number of points to be approximated in x-direction - int m = m_Grid[0].size()-1; // number of points to be approximated in y-direction - - std::vector dist_x, dist_y; - double sum,d; - Base::Vector3f vlen; - - m_uParam.clear(); - m_vParam.clear(); - m_uParam.resize(n+1); - m_vParam.resize(m+1); - m_uParam[n] = 1.0; - m_vParam[m] = 1.0; - - // calculate node vector in u-direction (corresponds to x-direction) - for (int j=0; j Nu_full(r - 1, n + 1); - ublas::matrix Nv_full(s - 1, m + 1); - ublas::matrix Nu_left(r - 1, n - 1); - ublas::matrix Nv_left(s - 1, m - 1); - ublas::matrix Nu (n - 1, n - 1); - ublas::matrix Nv (m - 1, m - 1); - - ublas::matrix bx (1, n - 1); - ublas::matrix by (1, n - 1); - ublas::matrix bz (1, n - 1); - - // pre-initialize with zero - for (int i=0; i output(p+1); - - int ind; - for (int i=1; i upiv(n - 1); // pivot element - atlas::lu_factor(Nu,upiv); // performs LU decomposition - std::vector vpiv(m - 1); - atlas::lu_factor(Nv,vpiv); - - ublas::matrix uCP_x(n + 1, s + 1); - ublas::matrix uCP_y(n + 1, s + 1); - ublas::matrix uCP_z(n + 1, s + 1); - - CPx.resize(n + 1, m + 1); - CPy.resize(n + 1, m + 1); - CPz.resize(n + 1, m + 1); - - // pre-initialize with zero - for (int i=0; i > Ru_x(s+1); - std::vector< ublas::matrix > Ru_y(s+1); - std::vector< ublas::matrix > Ru_z(s+1); - - for (int j=0; j > Rv_x(n+1); - std::vector< ublas::matrix > Rv_y(n+1); - std::vector< ublas::matrix > Rv_z(n+1); - - Base::Builder3D log,logo; - - for (int j=0; j Tmp = CPz; - - //Smoothing the control point network - for (int i=1; i tmp) - tmp = mG_err[i][j]; - - } - } - - return tmp; -} - -bool UniGridApprox::WriteMatrix(ublas::matrix M) -{ - - int row = M.size1(); - int col = M.size2(); - - for (int i=0; i normals = best_fit::Comp_Normals(mesh); - - double tmp = 0.0, sqrdis; - double errSum = 0.0; - int c=0; - - m_err.clear(); - m_err.resize(mesh.CountPoints(), 0.0); - - MeshCore::MeshFacetGrid aFacetGrid(m_Mesh); - MeshCore::MeshAlgorithm malg(m_Mesh); - MeshCore::MeshAlgorithm malg2(m_Mesh); - MeshCore::MeshPointIterator p_it(mesh); - - Base::Vector3f projPoint, distVec, pnt; - unsigned long facetIndex; - - - for (p_it.Begin(); p_it.More(); p_it.Next()) - { - if (!malg.NearestFacetOnRay(*p_it, normals[p_it.Position()], aFacetGrid, projPoint, facetIndex)) // gridoptimiert - { - if (malg2.NearestFacetOnRay(*p_it, normals[p_it.Position()], projPoint, facetIndex)) - { - pnt.x = p_it->x; - pnt.y = p_it->y; - pnt.z = p_it->z; - log3d.addSingleLine(pnt,projPoint); - distVec = projPoint - pnt; - sqrdis = distVec*distVec; - } - else - { - cout << "oops, "; - continue; - } - } - else - { - pnt.x = p_it->x; - pnt.y = p_it->y; - pnt.z = p_it->z; - log3d.addSingleLine(pnt,projPoint); - distVec = projPoint - pnt; - sqrdis = distVec*distVec; - } - - errSum += sqrt(sqrdis); - ++c; - - if (sqrt(sqrdis) > tmp) - { - m_err[p_it.Position()] = sqrt(sqrdis); - tmp = m_err[p_it.Position()]; - } - } - - log3d.saveToFile("c:/Error.iv"); - - return errSum/c; -} diff --git a/src/Mod/Cam/App/UniGridApprox.h b/src/Mod/Cam/App/UniGridApprox.h deleted file mode 100644 index c9e75204d0..0000000000 --- a/src/Mod/Cam/App/UniGridApprox.h +++ /dev/null @@ -1,82 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2007 Joachim Zettler * - * Copyright (c) 2007 Human Rezai * - * * - * This file is part of the FreeCAD CAx development system. * - * * - * This library is free software; you can redistribute it and/or * - * modify it under the terms of the GNU Library General Public * - * License as published by the Free Software Foundation; either * - * version 2 of the License, or (at your option) any later version. * - * * - * This library is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * - * GNU Library General Public License for more details. * - * * - * You should have received a copy of the GNU Library General Public * - * License along with this library; see the file COPYING.LIB. If not, * - * write to the Free Software Foundation, Inc., 59 Temple Place, * - * Suite 330, Boston, MA 02111-1307, USA * - * * - ***************************************************************************/ - -#ifndef UNIGRIDAPPROX_H -#define UNIGRIDAPPROX_H - -#include "routine.h" -#include -#include -#include - -using namespace boost::numeric; - - -class CamExport UniGridApprox: public Routines -{ -public: - UniGridApprox(const MeshCore::MeshKernel &InputMesh, double Tol); - ~UniGridApprox(); - - bool Perform(double TOL); - bool MeshOffset(); - bool SurfMeshParam(); - bool CompKnots(int m, int n); - bool MatComp(int m, int n); - bool BuildSurf(); - double CompGridError(); - double CompMeshError(); - bool WriteMatrix(ublas::matrix M); - - MeshCore::MeshKernel m_Mesh; - GeomAdaptor_Surface aAdaptorSurface; - double m_offset; - - std::vector< std::vector > m_Grid; - std::vector< std::vector > m_GridCopy; - std::vector m_err; - std::vector< std::vector > mG_err; - ublas::matrix Q; //Data-Matrix - ublas::matrix CPx; - ublas::matrix CPy; - ublas::matrix CPz; - std::vector m_uParam; - std::vector m_vParam; - std::vector m_uknots; - std::vector m_vknots; - int uCP, vCP; - int m_um; - int m_vm; - int m_udeg; - int m_vdeg; - int n_x; - int n_y; - double m_Tol; - - TopoDS_Face m_Face; - -protected: - -}; - -#endif \ No newline at end of file diff --git a/src/Mod/Cam/App/WireExplorer.cxx b/src/Mod/Cam/App/WireExplorer.cxx deleted file mode 100644 index 89542f9fcf..0000000000 --- a/src/Mod/Cam/App/WireExplorer.cxx +++ /dev/null @@ -1,238 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2007 Stephane Routelous * - * * - * This file is part of the FreeCAD CAx development system. * - * * - * This library is free software; you can redistribute it and/or * - * modify it under the terms of the GNU Library General Public * - * License as published by the Free Software Foundation; either * - * version 2 of the License, or (at your option) any later version. * - * * - * This library is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * - * GNU Library General Public License for more details. * - * * - * You should have received a copy of the GNU Library General Public * - * License along with this library; see the file COPYING.LIB. If not, * - * write to the Free Software Foundation, Inc., 59 Temple Place, * - * Suite 330, Boston, MA 02111-1307, USA * - * * - ***************************************************************************/ - -#include "PreCompiled.h" - -#include "WireExplorer.h" -#include -#include -#include -#include -#include -#include - - -WireExplorer::WireExplorer(const TopoDS_Wire& wire) -:m_wire(wire),m_done(false) -{ -} - -WireExplorer::~WireExplorer(void) -{ -} - -void WireExplorer::Init() -{ - if ( !m_done ) - Perform(); - - m_edgeIter = m_edges.begin(); -} - -bool WireExplorer::More() -{ - return m_edgeIter != m_edges.end(); -} - -bool WireExplorer::MoreEdge() -{ - return (m_edgeIter+1) != m_edges.end(); -} - -void WireExplorer::Next() -{ - ++m_edgeIter; -} - -const TopoDS_Edge& WireExplorer::Current() -{ - return *m_edgeIter; -} - -const TopoDS_Edge& WireExplorer::NextEdge() -{ - return *(m_edgeIter+1); -} - -void WireExplorer::Perform() -{ - if ( m_wire.IsNull() ) - return; - - //adds all the vertices to a map, and store the associated edges - TopExp_Explorer explorer; - Standard_Integer nbEdges = 0; - Standard_Integer nbNonEdges = 0; - for ( explorer.Init(m_wire,TopAbs_EDGE) ; explorer.More() ; explorer.Next() ) - { - const TopoDS_Edge& currentEdge = TopoDS::Edge(explorer.Current()); - if (IsValidEdge(currentEdge)) - { - Perform(currentEdge); - nbEdges++; - } - else - { - nbNonEdges++; - } - } - - //now, iterate through the edge to sort them - - //take the first entry in the map - tMapPntShapes::iterator iter = m_vertices.begin(); - const gp_Pnt& firstPoint = iter->first; - - gp_Pnt currentPoint = firstPoint; - Standard_Boolean toContinue; - do - { - toContinue = PerformEdges(currentPoint); - } - while (toContinue == Standard_True); - - m_done = true; - -} - -bool WireExplorer::PerformEdges(gp_Pnt& point) -{ - tMapPntShapes::iterator iter = m_vertices.find(point); - if ( iter == m_vertices.end() ) - return false; - - tEdgeVector& edges = iter->second; - - tEdgeVector::iterator edgeIt = edges.begin(); - - //no more edges. pb - if ( edgeIt == edges.end() ) - return false; - - TopoDS_Edge theEdge = *edgeIt; - - //we are storing the edge, so remove it from the vertex association - edges.erase(edgeIt); - - //if no more edges, remove the vertex - if ( edges.empty() ) - m_vertices.erase(iter); - - - TopoDS_Vertex V1,V2; - TopExp::Vertices(theEdge,V1,V2); - gp_Pnt P1 = BRep_Tool::Pnt(V1); - gp_Pnt P2 = BRep_Tool::Pnt(V2); - if ( theEdge.Orientation() == TopAbs_REVERSED ) - { - //switch the points - gp_Pnt tmpP = P1; - P1 = P2; - P2 = tmpP; - } - - gp_Pnt nextPoint; - if ( P2.IsEqual(point,Precision::Confusion()) ) - { - //need to reverse the edge - theEdge.Reverse(); - nextPoint = P1; - } - else - { - nextPoint = P2; - } - - //need to erase the edge from the second point - iter = m_vertices.find(nextPoint); - if ( iter != m_vertices.end() ) - { - tEdgeVector& nextEdges = iter->second; - bool somethingRemoved = false; - for ( edgeIt = nextEdges.begin() ; edgeIt != nextEdges.end(); ++edgeIt ) - { - if ( theEdge.IsSame(*edgeIt) ) - { - nextEdges.erase(edgeIt); - somethingRemoved = true; - break; - } - } - } - - //put the edge at the end of the list - m_edges.push_back(theEdge); - - point = nextPoint; - return true; - -} - -void WireExplorer::Perform(const TopoDS_Edge& edge) -{ - if ( edge.IsNull() ) - return; - TopoDS_Vertex V1,V2; - TopExp::Vertices(edge,V1,V2); - gp_Pnt P1 = BRep_Tool::Pnt(V1); - gp_Pnt P2 = BRep_Tool::Pnt(V2); - - tEdgeVector emptyList; - std::pair iter = m_vertices.insert(tMapPntShapesPair(P1,emptyList)); - iter.first->second.push_back(edge); - iter = m_vertices.insert(tMapPntShapesPair(P2,emptyList)); - iter.first->second.push_back(edge); -} - -#include - -bool WireExplorer::IsValidEdge(const TopoDS_Edge& edge) -{ - if ( edge.IsNull() ) - return false; - if ( BRep_Tool::Degenerated(edge) ) - return false; - - BRepAdaptor_Curve bac(edge); - - Standard_Real fparam = bac.FirstParameter(); - Standard_Real lparam = bac.LastParameter(); - - gp_Pnt fpoint = bac.Value(fparam); - gp_Pnt lpoint = bac.Value(lparam); - - //do not test the distance first last in case of a full circle edge (fpoint == lastpoint) - //if ( fpoint.IsEqual(lpoint,1e-5 ) ) - // return false; - - gp_Pnt mpoint = bac.Value((fparam+lparam)*0.5); - - Standard_Real dist = mpoint.Distance(lpoint); - if ( dist <= 1e-5 ) - return false; - dist = mpoint.Distance(fpoint); - if ( dist <= 1e-5 ) - return false; - - return true; -} - diff --git a/src/Mod/Cam/App/WireExplorer.h b/src/Mod/Cam/App/WireExplorer.h deleted file mode 100644 index 3487b7dc82..0000000000 --- a/src/Mod/Cam/App/WireExplorer.h +++ /dev/null @@ -1,80 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2007 Stephane Routelous * - * * - * This file is part of the FreeCAD CAx development system. * - * * - * This library is free software; you can redistribute it and/or * - * modify it under the terms of the GNU Library General Public * - * License as published by the Free Software Foundation; either * - * version 2 of the License, or (at your option) any later version. * - * * - * This library is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * - * GNU Library General Public License for more details. * - * * - * You should have received a copy of the GNU Library General Public * - * License along with this library; see the file COPYING.LIB. If not, * - * write to the Free Software Foundation, Inc., 59 Temple Place, * - * Suite 330, Boston, MA 02111-1307, USA * - * * - ***************************************************************************/ - -#ifndef WIREEXPLORER_H -#define WIREEXPLORER_H - -#include -#include -#include -#include -#include -#include -#include - -struct WireExplorer_gp_PntLess -{ - bool operator()(const gp_Pnt& _Left, const gp_Pnt& _Right) const - { - Standard_Real x1,y1,z1,x2,y2,z2; - _Left.Coord(x1,y1,z1); - _Right.Coord(x2,y2,z2); - if ( x1 != x2 ) - return x1 < x2; - else if ( y1 != y2 ) - return y1 < y2; - return z1 < z2; - } -}; - -typedef std::vector tEdgeVector; -typedef std::map tMapPntShapes; -typedef std::pair tMapPntShapesPair; - -class WireExplorer -{ -public: - Standard_EXPORT WireExplorer(const TopoDS_Wire& wire); - Standard_EXPORT virtual ~WireExplorer(void); - - Standard_EXPORT void Init(); - Standard_EXPORT bool More(); - Standard_EXPORT bool MoreEdge(); - Standard_EXPORT void Next(); - Standard_EXPORT const TopoDS_Edge& NextEdge(); - Standard_EXPORT const TopoDS_Edge& Current(); -private: - void Perform(); - void Perform(const TopoDS_Edge& edge); - bool PerformEdges(gp_Pnt& point); - bool IsValidEdge(const TopoDS_Edge& edge); - TopoDS_Wire m_wire; - - tMapPntShapes m_vertices; - - bool m_done; - tEdgeVector m_edges; - tEdgeVector::const_iterator m_edgeIter; -}; - -#endif - diff --git a/src/Mod/Cam/App/best_fit.cpp b/src/Mod/Cam/App/best_fit.cpp deleted file mode 100644 index ac0c306d97..0000000000 --- a/src/Mod/Cam/App/best_fit.cpp +++ /dev/null @@ -1,1965 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2007 Joachim Zettler * - * Copyright (c) 2007 Human Rezai * - * * - * This file is part of the FreeCAD CAx development system. * - * * - * This library is free software; you can redistribute it and/or * - * modify it under the terms of the GNU Library General Public * - * License as published by the Free Software Foundation; either * - * version 2 of the License, or (at your option) any later version. * - * * - * This library is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * - * GNU Library General Public License for more details. * - * * - * You should have received a copy of the GNU Library General Public * - * License along with this library; see the file COPYING.LIB. If not, * - * write to the Free Software Foundation, Inc., 59 Temple Place, * - * Suite 330, Boston, MA 02111-1307, USA * - * * - ***************************************************************************/ - -/*****************best_fit.CPP***************** -* Contains implementations from best_fit.h -* -* -*********************************************/ - -#include "PreCompiled.h" -#include "best_fit.h" -#include "routine.h" -#include - -#include -#include -#include - -#include - -#include -#include "BRepUtils.h" -#include - -//#include -#include -#include -#include - -#include -#include -#include -#include -#include - -#include -#include - -#include // ANN declarations - -#include - - -best_fit::best_fit() -{ - m_LSPnts.resize(2); -} - -best_fit::~best_fit() -{ -} - -void best_fit::Load(const MeshCore::MeshKernel &mesh, const TopoDS_Shape &cad) -{ - m_Mesh = mesh; - m_Cad = cad; - - m_MeshWork = m_Mesh; - -} - -double best_fit::ANN() -{ - ANNpointArray dataPts; // data points - ANNpoint queryPt; // query point - ANNidxArray nnIdx; // near neighbor indices - ANNdistArray dists; // near neighbor distances - ANNkd_tree* kdTree; // search structure - - Base::Builder3D log_error; - - //MeshCore::MeshPointArray meshPnts = m_MeshWork.GetPoints(); - m_pntCloud_2; - Base::Vector3f projPoint; - - double error = 0.0; - - int a_dim = 3; - int a_nbPnts =(int) m_pntCloud_2.size(); // Size of the scanned network - int a_nbNear = 1; // number of return values - queryPt = annAllocPt(a_dim); // allocate query point storage - dataPts = annAllocPts(a_nbPnts, a_dim); // allocate data points storage - nnIdx = new ANNidx[a_nbNear]; // allocate near neighbor indices - dists = new ANNdist[a_nbNear]; // allocate near neighbor dists - - m_LSPnts[0].clear(); - m_LSPnts[1].clear(); - - for (int i=0; iannkSearch( // search - queryPt, // query point - a_nbNear, // number of near neighbors - nnIdx, // nearest neighbors (returned) - dists // distance (returned) - ); // error bound - - m_LSPnts[1].push_back(m_pntCloud_1[i]); - m_LSPnts[0].push_back(m_pntCloud_2[nnIdx[0]]); - - if(m_pntCloud_1[i].z <= m_pntCloud_2[nnIdx[0]].z) - { - log_error.addSingleLine(m_pntCloud_1[i],m_pntCloud_2[nnIdx[0]],8,1,0,0); - } - else - { - log_error.addSingleLine(m_pntCloud_1[i],m_pntCloud_2[nnIdx[0]],8,0,1,0); - } - - //if(dists[0] > error) - error += dists[0]; - - } - - log_error.saveToFile("c:/errorVec_fit.iv"); - - error /= double(m_pntCloud_1.size()); - m_weights_loc = m_weights; - - - delete [] nnIdx; // clean things up - delete [] dists; - delete kdTree; - annClose(); // done with ANN - - return error; -} - -bool best_fit::Perform() -{ - Base::Matrix4D M; - - ofstream Runtime_BestFit; - time_t sec1, sec2; - - Runtime_BestFit.open("c:/Runtime_BestFit.txt"); - Runtime_BestFit << "Runtime Best-Fit" << std::endl; - - - cout << "tessellate shape" << endl; - - sec1 = time(NULL); - Tesselate_Shape(m_Cad, m_CadMesh, 1); // Tessellates m_Cad Shape and stores Tessellation in m_CadMesh - sec2 = time(NULL); - - Runtime_BestFit << "Tessellate Shape: " << sec2 - sec1 << " sec" << std::endl; - - sec1 = time(NULL); - Comp_Weights(); // m_pntCloud_1, m_weights, m_normals des/r Cad-Meshs/Punktewolke werden hier gefüllt - sec2 = time(NULL); - - Runtime_BestFit << "Compute Weights: " << sec2 - sec1 << " sec" << std::endl; - - - /*RotMat(M, 180, 1); - m_MeshWork.Transform(M); - return true;*/ - - - //MeshCore::MeshPointArray pntarr = m_MeshWork.GetPoints(); - //MeshCore::MeshFacetArray facetarr = m_MeshWork.GetFacets(); - - //for(int i=0; i CAD - ShapeFit_Coarse(); // Translation CAD -> Origin - - //return true; - - M.setToUnity(); - M[0][3] = m_cad2orig.X(); - M[1][3] = m_cad2orig.Y(); - M[2][3] = m_cad2orig.Z(); - - m_CadMesh.Transform(M); // better: tessellation after the transformer! - m_MeshWork.Transform(M); - PointTransform(m_pntCloud_1,M); - - MeshCore::MeshPointArray pnts = m_MeshWork.GetPoints(); - - for (unsigned int i=0; i no intersect - // for a segment, also test if (r > 1.0) => no intersect - - dir.Scale(r,r,r); - I = P + dir; // intersect point of ray and plane - - // is I inside T? - float uu, uv, vv, wu, wv, D; - uu = u*u; - uv = u*v; - vv = v*v; - w = I - T._aclPoints[0]; - wu = w*u; - wv = w*v; - D = uv * uv - uu * vv; - - // get and test parametric coords - float s, t; - s = (uv * wv - vv * wu) / D; - if (s < 0.0 || s > 1.0) // I is outside T - return 0; - t = (uv * wu - uu * wv) / D; - if (t < 0.0 || (s + t) > 1.0) // I is outside T - return 0; - - return 1; // I is in T -} -*/ - -bool best_fit::Coarse_correction() -{ - double error, error_tmp, rot = 0.0; - Base::Matrix4D M,T; - ofstream CoarseCorr; - - CoarseCorr.open("c:/CoarseCorr.txt"); - - std::vector m_pntCloud_Work = m_pntCloud_2; - - T.setToUnity(); - best_fit befi; - - //error = CompError_GetPnts(m_pnts, m_normals)[0]; // start error int n=360/rstep_corr; - - error = ANN(); - - for (int i=1; i<4; ++i) - { - RotMat(M, 180, i); - PointTransform(m_pntCloud_2, M); - //m_MeshWork.Transform(M); - - error_tmp = ANN(); - - //error_tmp = CompError_GetPnts(m_pnts, m_normals)[0]; - //error_tmp = befi.CompTotalError(m_MeshWork); - - CoarseCorr << i << ", " << error_tmp << endl; - - if (error_tmp < error) - { - T = M; - error = error_tmp; - } - - m_pntCloud_2 = m_pntCloud_Work; - } - - CoarseCorr << "BEST CHOICE: " << error << endl; - CoarseCorr.close(); - PointTransform(m_pntCloud_2, T); - m_MeshWork.Transform(T); - - - return true; -} - - -bool best_fit::LSM() -{ - double TOL = 0.05; // Termination criterion of the Newton method - int maxIter = 100; // maximum number of iterations for the case, - // that the termination criterion is not met - - int mult = 2; // to halve the step size in the event of failure of the Newton method - - double val, tmp = 1e+10, delta, delta_tmp = 0.0; - Base::Matrix4D Tx,Ty,Tz,Rx,Ry,Rz,M; // Transformation matrices - - ofstream anOutputFile; - anOutputFile.open("c:/outputBestFit.txt"); - anOutputFile.precision(7); - - int c=0; // Run variable - - - - std::vector del_x(3,0.0); - std::vector x(3,0.0); // Start parameter corresponds to zero vector - - Base::Vector3f centr_l,centr_r, cent; // Focal points of the point sets - - // Newton's method: 1. Solve H*del_x = -J - // 2. Set x = x + del_x - - std::vector Jac(3); // 1. Deriving the error function (Jacobi-Matrix) - std::vector< std::vector > H; // 2. Deriving the error function (Hesse-Matrix) - - time_t seconds1, seconds2, sec1, sec2; - seconds1 = time(NULL); - - while (true) - { - - seconds1 = time(NULL); - //m_Mesh = m_MeshWork; - - // Error calculation from CAD -> Mesh - //tmp = CompError_GetPnts(m_pnts, m_normals); // here: - Calculation of the LS point sets - // CompTotalError() // - Calculation of the corresponding weightings - - delta = delta_tmp; - delta_tmp = ANN(); // returns average absolute errors - delta = delta - delta_tmp ; // the error correction for the previous iteration step is stored here - - if (c==maxIter || delta < ERR_TOL && c>1) break; // Abort criterion (if maximum iteration steps are reached or if - // the change in error is insignificantly small) - - seconds2 = time(NULL); - anOutputFile << c << ", " << delta_tmp << ", " << delta << " - Time: " << seconds2 - seconds1 << " sec" << endl; - seconds1 = time(NULL); - - sec1 = time(NULL); - for (unsigned int i=0; itmp && mult < 1e+4) - { - for (unsigned int i=0; i best_fit::Comp_Jacobi(const std::vector &x) -{ - std::vector F(3,0.0); - double s1 = sin(x[0]), c1 = cos(x[0]); - double s2 = sin(x[1]), c2 = cos(x[1]); - double s3 = sin(x[2]), c3 = cos(x[2]); - - Base::Vector3f p,q; - - for (unsigned int i=0; i > best_fit::Comp_Hess(const std::vector &x) -{ - std::vector > DF(3); - for (unsigned int i=0; iNodes(); - - // takes the array of triangles for this triangulation: - const Poly_Array1OfTriangle& triangles = aTr->Triangles(); - - // create array of node points in absolute coordinate system - TColgp_Array1OfPnt aPoints(1, aNodes.Length()); - for ( Standard_Integer i = 1; i <= aNodes.Length(); i++) - aPoints(i) = aNodes(i).Transformed(aLocation); - - // Takes the node points of each triangle of this triangulation. - // takes a number of triangles: - Standard_Integer nnn = aTr->NbTriangles(); - Standard_Integer nt,n1,n2,n3; - for ( nt = 1 ; nt < nnn+1 ; nt++) - { - // takes the node indices of each triangle in n1,n2,n3: - triangles(nt).Get(n1,n2,n3); - // takes the node points: - gp_Pnt aPnt1 = aPoints(n1); - Points[0].Set(float(aPnt1.X()),float(aPnt1.Y()),float(aPnt1.Z())); - gp_Pnt aPnt2 = aPoints(n2); - Points[1].Set((float) aPnt2.X(),(float) aPnt2.Y(),(float) aPnt2.Z()); - gp_Pnt aPnt3 = aPoints(n3); - Points[2].Set((float) aPnt3.X(),(float) aPnt3.Y(),(float) aPnt3.Z()); - - // give the occ faces to the internal mesh structure of freecad - MeshCore::MeshGeomFacet Face(Points[0],Points[1],Points[2]); - - if (bf == false) builder1.AddFacet(Face); - else builder2.AddFacet(Face); - - } - } - } - - builder1.Finish(); - builder2.Finish(); - - m_pntCloud_1.clear(); - m_weights.clear(); - - MeshCore::MeshPointArray pnts = mesh1.GetPoints(); - - for (unsigned int i=0; i tmp = Comp_Normals(mesh2); - - for (unsigned int i=0; i &pnts, - std::vector &normals, - Base::Matrix4D &M) -{ - int m = pnts.size(); - Base::Vector3f pnt,normal; - - for (int i=0; iGetMeshDS()->nodesIterator(); - - for(;aNodeIter->more();) - { - const SMDS_MeshNode* aNode = aNodeIter->next(); - m_meshtobefit->GetMeshDS()->MoveNode(aNode,m_pntCloud_2[(aNode->GetID()-1)].x,m_pntCloud_2[(aNode->GetID()-1)].y,m_pntCloud_2[(aNode->GetID()-1)].z); - } - m_meshtobefit->ExportUNV("c:/best_fit_mesh.unv"); - - return true; -} - -bool best_fit::Initialize_Mesh_Geometrie_1() -{ - m_aMeshGen1 = new SMESH_Gen(); - m_referencemesh = m_aMeshGen1->CreateMesh(1,false); - m_referencemesh->UNVToMesh("c:/cad_mesh_cenaero.unv"); - - m_pntCloud_1.clear(); - - //add the nodes - SMDS_NodeIteratorPtr aNodeIter = m_referencemesh->GetMeshDS()->nodesIterator(); - for(;aNodeIter->more();) { - const SMDS_MeshNode* aNode = aNodeIter->next(); - Base::Vector3f a3DVector; - a3DVector.Set((float) aNode->X(),(float) aNode->Y(),(float) aNode->Z()), - m_pntCloud_1.push_back(a3DVector); - } - - - - return true; -} - - - -bool best_fit::Initialize_Mesh_Geometrie_2() -{ - - m_aMeshGen2 = new SMESH_Gen(); - m_meshtobefit = m_aMeshGen2->CreateMesh(1,false); - m_meshtobefit->UNVToMesh("c:/mesh_cenaero.unv"); - - m_pntCloud_2.clear(); - - //add the nodes - SMDS_NodeIteratorPtr aNodeIter = m_meshtobefit->GetMeshDS()->nodesIterator(); - for(;aNodeIter->more();) { - const SMDS_MeshNode* aNode = aNodeIter->next(); - Base::Vector3f a3DVector; - a3DVector.Set((float) aNode->X(),(float) aNode->Y(), (float) aNode->Z()), - m_pntCloud_2.push_back(a3DVector); - } - - ////add the 2D edge-Elements - //SMDS_EdgeIteratorPtr anEdgeIter = Reference_Mesh->GetMeshDS()->edgesIterator(); - //for(;anEdgeIter->more();) { - // const SMDS_MeshEdge* anElem = anEdgeIter->next(); - // myElements.push_back( anElem->GetID() ); - //} - ////add the 2D-Planar Elements like triangles - //SMDS_FaceIteratorPtr aFaceIter = Reference_Mesh->GetMeshDS()->facesIterator(); - //for(;aFaceIter->more();) { - // const SMDS_MeshFace* anElem = aFaceIter->next(); - // int element_node_count = anElem->NbNodes(); - // myElements.push_back( anElem->GetID() ); - //} - ////Add the Volume-Elements - //SMDS_VolumeIteratorPtr aVolumeIter = Reference_Mesh->GetMeshDS()->volumesIterator(); - //for(;aVolumeIter->more();) { - // const SMDS_MeshVolume* anElem = aVolumeIter->next(); - // myElements.push_back( anElem->GetID() ); - //} - - //int testsize = myElements.size(); - - //SMDS_VolumeTool aTooling; - - - ////Now take the Element-Vector and work with the elements - ////check validity of element - //for (unsigned int i=0;iGetMeshDS()->FindElement(myElements[i]); - // if (CurrentElement->GetType() == SMDSAbs_Volume) - // { - // //We encountered a Surface-Element like a triangle and we have to check if its a triangle or not - // aTooling.Set(CurrentElement); - // //Now we have to check what kind of volume element we have - // if(aTooling.GetVolumeType()== SMDS_VolumeTool::HEXA) - // { - // //Found a HEXA Element - // } - // } - //} - - return true; -} - -bool best_fit::PointTransform(std::vector &pnts, const Base::Matrix4D &M) -{ - int m = pnts.size(); - Base::Vector3f pnt; - - for (int i=0; i local coordinate system - - x.x = 50.0f*(float)v1.X(); x.y = 50.0f*(float)v1.Y(); x.z = 50.0f*(float)v1.Z(); - y.x = 50.0f*(float)v2.X(); y.y = 50.0f*(float)v2.Y(); y.z = 50.0f*(float)v2.Z(); - z.x = 50.0f*(float)v3.X(); z.y = 50.0f*(float)v3.Y(); z.z = 50.0f*(float)v3.Z(); - - pnt.x = (float) orig.X(); - pnt.y = (float) orig.Y(); - pnt.z = (float) orig.Z(); - - log3d_cad.addSingleArrow(pnt,x,3,1,0,0); - log3d_cad.addSingleArrow(pnt,y,3,0,1,0); - log3d_cad.addSingleArrow(pnt,z,3,0,0,1); - - //log3d_cad.addSinglePoint(pnt,6,1,1,1); - - log3d_cad.saveToFile("c:/CAD_CoordSys.iv"); - - PointTransform(m_pntCloud_2,T5*T1); - - //m_MeshWork.Transform(T1); - // plot Mesh -> local coordinate system - - v1.SetX(T1[0][0]);v1.SetY(T1[0][1]);v1.SetZ(T1[0][2]); - v2.SetX(T1[1][0]);v2.SetY(T1[1][1]);v2.SetZ(T1[1][2]); - v3.SetX(T1[2][0]);v3.SetY(T1[2][1]);v3.SetZ(T1[2][2]); - - T1.inverse(); - orig.SetX(T1[0][3]);orig.SetY(T1[1][3]);orig.SetZ(T1[2][3]); - - x.x = 50.0f*(float)v1.X(); x.y = 50.0f*(float)v1.Y(); x.z = 50.0f*(float)v1.Z(); - y.x = 50.0f*(float)v2.X(); y.y = 50.0f*(float)v2.Y(); y.z = 50.0f*(float)v2.Z(); - z.x = 50.0f*(float)v3.X(); z.y = 50.0f*(float)v3.Y(); z.z = 50.0f*(float)v3.Z(); - - pnt.x = (float) orig.X(); - pnt.y = (float) orig.Y(); - pnt.z = (float) orig.Z(); - - log3d_mesh.addSingleArrow(pnt,x,3,1,0,0);log3d_mesh.addSingleArrow(pnt,y,3,0,1,0);log3d_mesh.addSingleArrow(pnt,z,3,0,0,1); - log3d_mesh.addSinglePoint(0,0,0,20,1,1,1); // plot origins - //log3d_mesh.addSinglePoint(pnt,6,0,0,0); - log3d_mesh.saveToFile("c:/Mesh_CoordSys.iv"); - - /*for(int i=0; i< m_pntCloud_2.size(); i++) - { - m_pntCloud_2[i].x = m_pntCloud_2[i].x + Grav_1.x - Grav_2.x; - m_pntCloud_2[i].y = m_pntCloud_2[i].y + Grav_1.y - Grav_2.y; - m_pntCloud_2[i].z = m_pntCloud_2[i].z + Grav_1.z - Grav_2.z; - }*/ - - return true; -} -bool best_fit::MeshFit_Coarse() -{ - - GProp_GProps prop; - GProp_PrincipalProps pprop; - - Base::Vector3f pnt(0.0,0.0,0.0); - Base::Vector3f x,y,z; - Base::Builder3D log3d_mesh, log3d_cad; - gp_Pnt orig; - - gp_Vec v1,v2,v3,v,vec; // Major axis directions - gp_Trsf trafo; - - /* BRepGProp::SurfaceProperties(m_Cad, prop); - pprop = prop.PrincipalProperties(); - - v1 = pprop.FirstAxisOfInertia(); - v2 = pprop.SecondAxisOfInertia(); - v3 = pprop.ThirdAxisOfInertia();*/ - - MeshCore::MeshEigensystem pca(m_CadMesh); - pca.Evaluate(); - Base::Matrix4D T5 = pca.Transform(); - - v1.SetX(T5[0][0]);v1.SetY(T5[0][1]);v1.SetZ(T5[0][2]); - v2.SetX(T5[1][0]);v2.SetY(T5[1][1]);v2.SetZ(T5[1][2]); - v3.SetX(T5[2][0]);v3.SetY(T5[2][1]);v3.SetZ(T5[2][2]); - - v1.Normalize(); - v2.Normalize(); - v3.Normalize(); - - - v = v1; - v.Cross(v2); - - // right-hand-system check - if ( v.Dot(v3) < 0.0 ) - v3 *= -1; - - T5.inverse(); - - orig.SetX(T5[0][3]);orig.SetY(T5[1][3]);orig.SetZ(T5[2][3]); - //orig = prop.CentreOfMass(); - - // plot CAD -> local coordinate system - - x.x = 50.0f*(float)v1.X(); x.y = 50.0f*(float)v1.Y(); x.z = 50.0f*(float)v1.Z(); - y.x = 50.0f*(float)v2.X(); y.y = 50.0f*(float)v2.Y(); y.z = 50.0f*(float)v2.Z(); - z.x = 50.0f*(float)v3.X(); z.y = 50.0f*(float)v3.Y(); z.z = 50.0f*(float)v3.Z(); - - pnt.x = (float) orig.X(); - pnt.y = (float) orig.Y(); - pnt.z = (float) orig.Z(); - - log3d_cad.addSingleArrow(pnt,x,3,1,0,0); - log3d_cad.addSingleArrow(pnt,y,3,0,1,0); - log3d_cad.addSingleArrow(pnt,z,3,0,0,1); - - //log3d_cad.addSinglePoint(pnt,6,1,1,1); - - log3d_cad.saveToFile("c:/CAD_CoordSys.iv"); - - MeshCore::MeshEigensystem pca2(m_MeshWork); - pca2.Evaluate(); - Base::Matrix4D T1 = pca2.Transform(); - m_MeshWork.Transform(T5*T1); - //m_MeshWork.Transform(T1); - // plot Mesh -> local coordinate system - - - v1.SetX(T1[0][0]);v1.SetY(T1[0][1]);v1.SetZ(T1[0][2]); - v2.SetX(T1[1][0]);v2.SetY(T1[1][1]);v2.SetZ(T1[1][2]); - v3.SetX(T1[2][0]);v3.SetY(T1[2][1]);v3.SetZ(T1[2][2]); - - - - T1.inverse(); - orig.SetX(T1[0][3]);orig.SetY(T1[1][3]);orig.SetZ(T1[2][3]); - - x.x = 50.0f*(float)v1.X(); x.y = 50.0f*(float)v1.Y(); x.z = 50.0f*(float)v1.Z(); - y.x = 50.0f*(float)v2.X(); y.y = 50.0f*(float)v2.Y(); y.z = 50.0f*(float)v2.Z(); - z.x = 50.0f*(float)v3.X(); z.y = 50.0f*(float)v3.Y(); z.z = 50.0f*(float)v3.Z(); - - pnt.x = (float) orig.X(); - pnt.y = (float) orig.Y(); - pnt.z = (float) orig.Z(); - - log3d_mesh.addSingleArrow(pnt,x,3,1,0,0);log3d_mesh.addSingleArrow(pnt,y,3,0,1,0);log3d_mesh.addSingleArrow(pnt,z,3,0,0,1); - log3d_mesh.addSinglePoint(0,0,0,20,1,1,1); // plot origins - //log3d_mesh.addSinglePoint(pnt,6,0,0,0); - log3d_mesh.saveToFile("c:/Mesh_CoordSys.iv"); - - return true; -} - -bool best_fit::ShapeFit_Coarse() -{ - GProp_GProps prop; - BRepGProp SurfProp; - gp_Trsf trafo; - gp_Pnt orig; - - SurfProp.SurfaceProperties(m_Cad, prop); - orig = prop.CentreOfMass(); - - // CAD-Mesh -> back to the origin - m_cad2orig.SetX(-orig.X()); - m_cad2orig.SetY(-orig.Y()); - m_cad2orig.SetZ(-orig.Z()); - - trafo.SetTranslation(m_cad2orig); - BRepBuilderAPI_Transform trsf(trafo); - - trsf.Perform(m_Cad); - m_Cad = trsf.Shape(); - - return true; -} - -bool best_fit::Tesselate_Face(const TopoDS_Face &aface, MeshCore::MeshKernel &mesh, float deflection) -{ - Base::Builder3D aBuild; - MeshCore::MeshBuilder builder(mesh); - builder.Initialize(1000); - Base::Vector3f Points[3]; - if (!BRepTools::Triangulation(aface,0.1)) - { - // removes all the triangulations of the faces, - // and all the polygons on the triangulations of the edges: - BRepTools::Clean(aface); - - // adds a triangulation of the shape aShape with the deflection aDeflection: - //BRepMesh_IncrementalMesh Mesh(pcShape->getShape(),aDeflection); - -/*The next two lines have been from the occ6.2 adapt mesh library. They do not work within OCC6.3 - TriangleAdapt_Parameters MeshingParams; - BRepMeshAdapt::Mesh(aface,deflection,MeshingParams); -*/ - BRepMesh_IncrementalMesh Mesh(aface,deflection); - } - TopLoc_Location aLocation; - // takes the triangulation of the face aFace: - Handle_Poly_Triangulation aTr = BRep_Tool::Triangulation(aface,aLocation); - if (!aTr.IsNull()) // if this triangulation is not NULL - { - // takes the array of nodes for this triangulation: - const TColgp_Array1OfPnt& aNodes = aTr->Nodes(); - // takes the array of triangles for this triangulation: - const Poly_Array1OfTriangle& triangles = aTr->Triangles(); - // create array of node points in absolute coordinate system - TColgp_Array1OfPnt aPoints(1, aNodes.Length()); - for ( Standard_Integer i = 1; i < aNodes.Length()+1; i++) - aPoints(i) = aNodes(i).Transformed(aLocation); - // Takes the node points of each triangle of this triangulation. - // takes a number of triangles: - Standard_Integer nnn = aTr->NbTriangles(); - Standard_Integer nt,n1,n2,n3; - for ( nt = 1 ; nt < nnn+1 ; nt++) - { - // takes the node indices of each triangle in n1,n2,n3: - triangles(nt).Get(n1,n2,n3); - // takes the node points: - gp_Pnt aPnt1 = aPoints(n1); - Points[0].Set(float(aPnt1.X()),float(aPnt1.Y()),float(aPnt1.Z())); - gp_Pnt aPnt2 = aPoints(n2); - Points[1].Set((float) aPnt2.X(),(float) aPnt2.Y(),(float) aPnt2.Z()); - gp_Pnt aPnt3 = aPoints(n3); - Points[2].Set((float) aPnt3.X(),(float) aPnt3.Y(),(float) aPnt3.Z()); - // give the occ faces to the internal mesh structure of freecad - MeshCore::MeshGeomFacet Face(Points[0],Points[1],Points[2]); - builder.AddFacet(Face); - } - - } - // if the triangulation of only one face is not possible to get - else - { - throw Base::RuntimeError("Empty face triangulation\n"); - } - - // finish FreeCAD Mesh Builder and exit with new mesh - builder.Finish(); - return true; -} - - -bool best_fit::Tesselate_Shape(const TopoDS_Shape &shape, MeshCore::MeshKernel &mesh, float deflection) -{ - Base::Builder3D aBuild; - - MeshCore::MeshDefinitions::_fMinPointDistanceD1 = (float) 0.0001; - MeshCore::MeshBuilder builder(mesh); - builder.Initialize(1000); - Base::Vector3f Points[3]; - - //bool check = BRepUtils::CheckTopologie(shape); - //if (!check) - //{ - // cout <<"an error"<< endl; - //} - - //BRepBuilderAPI_Sewing aSewer; - //aSewer.Load(shape); - //aSewer.Perform(); - //aSewer.IsModified(shape); - //const TopoDS_Shape& asewedShape = aSewer.SewedShape(); - //if (asewedShape.IsNull()) - //{ - // cout << "Nothing Sewed" << endl; - //} - //int test = aSewer.NbFreeEdges(); - //int test1 = aSewer.NbMultipleEdges(); - //int test2 = aSewer.NbDegeneratedShapes(); - - // adds a triangulation of the shape aShape with the deflection deflection: -/* - TriangleAdapt_Parameters MeshParams; - MeshParams._minAngle = 30.0; - //MeshParams._minNbPntsPerEdgeLine = 3; - //MeshParams._minNbPntsPerEdgeOther = 3; - //MeshParams._minEdgeSplit = 3; - MeshParams._maxTriangleSideSize = 10; //10 - MeshParams._maxArea = 10; //50 - */ - BRepMesh_IncrementalMesh Mesh(shape,deflection); - //BRepMesh::Mesh(shape,deflection); - TopExp_Explorer aExpFace; - - - for (aExpFace.Init(shape,TopAbs_FACE);aExpFace.More();aExpFace.Next()) - { - - TopoDS_Face aFace = TopoDS::Face(aExpFace.Current()); - - TopLoc_Location aLocation; - - // takes the triangulation of the face aFace: - Handle_Poly_Triangulation aTr = BRep_Tool::Triangulation(aFace,aLocation); - if (!aTr.IsNull()) // if this triangulation is not NULL - { - // takes the array of nodes for this triangulation: - const TColgp_Array1OfPnt& aNodes = aTr->Nodes(); - // takes the array of triangles for this triangulation: - const Poly_Array1OfTriangle& triangles = aTr->Triangles(); - // create array of node points in absolute coordinate system - TColgp_Array1OfPnt aPoints(1, aNodes.Length()); - for ( Standard_Integer i = 1; i <= aNodes.Length(); i++) - aPoints(i) = aNodes(i).Transformed(aLocation); - // Takes the node points of each triangle of this triangulation. - // takes a number of triangles: - Standard_Integer nnn = aTr->NbTriangles(); - Standard_Integer nt,n1,n2,n3; - for ( nt = 1 ; nt < nnn+1 ; nt++) - { - // takes the node indices of each triangle in n1,n2,n3: - triangles(nt).Get(n1,n2,n3); - // takes the node points: - gp_Pnt aPnt1 = aPoints(n1); - Points[0].Set(float(aPnt1.X()),float(aPnt1.Y()),float(aPnt1.Z())); - gp_Pnt aPnt2 = aPoints(n2); - Points[1].Set((float) aPnt2.X(),(float) aPnt2.Y(),(float) aPnt2.Z()); - gp_Pnt aPnt3 = aPoints(n3); - Points[2].Set((float) aPnt3.X(),(float) aPnt3.Y(),(float) aPnt3.Z()); - // give the occ faces to the internal mesh structure of freecad - MeshCore::MeshGeomFacet Face(Points[0],Points[1],Points[2]); - builder.AddFacet(Face); - } - } - // if the triangulation of only one face is not possible to get - else - { - throw Base::RuntimeError("Empty face triangulation\n"); - } - } - // finish FreeCAD Mesh Builder and exit with new mesh - builder.Finish(); - - /*MeshCore::MeshAlgorithm algo(mesh); - std::list< std::vector > BoundariesIndex; - algo.GetMeshBorders(BoundariesIndex);*/ - - return true; -} - -std::vector best_fit::Comp_Normals(MeshCore::MeshKernel &M) -{ - Base::Builder3D log3d; - Base::Vector3f normal,local_normal,origPoint; - MeshCore::MeshRefPointToFacets rf2pt(M); - MeshCore::MeshGeomFacet t_face; - MeshCore::MeshPoint mPnt; - std::vector normals; - - int NumOfPoints = M.CountPoints(); - float local_Area; - float fArea; - - for (int i=0; i& faceSet = rf2pt[i]; - fArea = 0.0; - normal.Set(0.0,0.0,0.0); - - // Iterate over the triangles to each point - for (std::set::const_iterator it = faceSet.begin(); it != faceSet.end(); ++it) - { - // Dereference twice to get to the MeshFacet and hand over - // to the kernel that it delivers a MeshGeomFacet - t_face = M.GetFacet(*it); - // Sum up the area content - local_Area = t_face.Area(); - local_normal = t_face.GetNormal(); - if (local_normal.z < 0) - { - local_normal = local_normal * (-1); - } - - fArea = fArea + local_Area; - normal = normal + local_Area*local_normal; - - } - - normal.Normalize(); - normals.push_back(normal); - - log3d.addSingleArrow(origPoint,origPoint+normal,1,0,0,0); - } - - log3d.saveToFile("c:/normals.iv"); - - return normals; -} - -/* -double best_fit::CompError(std::vector &pnts, std::vector &normals) -{ - double err_avg = 0.0; - double err_max = 0.0; - double sqrdis = 0.0; - - MeshCore::MeshFacetGrid aFacetGrid(m_CadMesh); - MeshCore::MeshAlgorithm malg(m_CadMesh); - MeshCore::MeshAlgorithm malg2(m_CadMesh); - - Base::Vector3f origPoint, projPoint, distVec; - unsigned long facetIndex; - - int NumOfPoints = pnts.size(); - int c = 0; - - for (int i=0; i best_fit::CompError_GetPnts(std::vector pnts, - std::vector &normals) - -{ - double err_avg = 0.0; - double dist; - - std::vector errVec(2); // errVec[0]: avg. error, errVec[1]: max. error - - MeshCore::MeshFacetGrid aFacetGrid(m_Mesh); - MeshCore::MeshAlgorithm malg(m_Mesh); - unsigned long facetIndex; - - Base::Vector3f origPoint, projPoint, distVec; - //Base::Builder3D log; - - unsigned int NumOfPoints = pnts.size(); - int c = 0; - - m_LSPnts[0].clear(); - m_LSPnts[1].clear(); - - m_weights_loc.clear(); - - for (unsigned int i=0; i max_err) - max_err = dist; - } - - //log.saveToFile("c:/intersection.iv"); - - errVec[0] = err_avg /= (NumOfPoints-c); // durchschnittlicher Fehlerquadrat - errVec[1] = max_err; // maximaler Fehlerquadrat - - //cout << c << " projections failed" << endl; - - return errVec; -} - -double best_fit::CompError(std::vector &pnts, std::vector &normals, bool plot) -{ - if (plot==false) - return CompError(pnts, normals); - else - { - Base::Builder3D log3d; - double err_avg = 0.0; - double err_max = 0.0; - double sqrdis = 0.0; - - - MeshCore::MeshFacetGrid aFacetGrid(m_CadMesh); - MeshCore::MeshAlgorithm malg(m_CadMesh); - MeshCore::MeshAlgorithm malg2(m_CadMesh); - - Base::Vector3f projPoint, distVec; - unsigned long facetIndex; - - int NumOfPoints = pnts.size(); - int c=0; - - for (int i=0; i(NumOfPoints/2)) - return 1e+10; - - return err_avg/(NumOfPoints-c); - } -} -*/ - -double best_fit::CompTotalError() -{ - Base::Builder3D log3d; - double err_avg = 0.0; - double err_max = 0.0; - double sqrdis = 0.0; - - std::vector FailProj; - - MeshCore::MeshFacetGrid aFacetGrid(m_Mesh,10); - MeshCore::MeshAlgorithm malg(m_Mesh); - MeshCore::MeshAlgorithm malg2(m_Mesh); - MeshCore::MeshPointIterator p_it(m_CadMesh); - - Base::Vector3f projPoint, distVec, projPoint2; - unsigned long facetIndex; - std::stringstream text; - m_error.resize(m_CadMesh.CountPoints()); - - unsigned int c=0; - int i=0; - - - m_LSPnts[0].clear(); - m_LSPnts[1].clear(); - for (p_it.Begin(); p_it.More(); p_it.Next()) - { - if (malg.NearestFacetOnRay(*p_it, m_normals[i], aFacetGrid, projPoint, facetIndex)) // grid-optimized - { - log3d.addSingleArrow(*p_it, projPoint, 3, 0,0,0); - distVec = projPoint - *p_it; - sqrdis = distVec*distVec; - - m_LSPnts[1].push_back(*p_it); - m_LSPnts[0].push_back(projPoint); - - if (((projPoint.z - p_it->z) / m_normals[i].z ) > 0) - m_error[i] = sqrt(sqrdis); - else - m_error[i] = -sqrt(sqrdis); - - err_avg += sqrdis; - } - else - { - - if (!malg2.NearestFacetOnRay(*p_it, m_normals[i], projPoint, facetIndex)) // not grid-optimized - { - c++; - //m_normals[i].Scale(-10,-10,-10); - text << p_it->x << ", " << p_it->y << ", " << p_it->z << "; " << m_normals[i].x << ", " << m_normals[i].y << ", " << m_normals[i].z; - //log3d.addSingleArrow(*p_it, *p_it + m_normals[i], 4, 1,0,0); - //log3d.addText(*p_it,(text.str()).c_str()); - } - else - { - log3d.addSingleArrow(*p_it, projPoint, 3, 0,0,0); - distVec = projPoint - *p_it; - sqrdis = distVec*distVec; - - m_LSPnts[1].push_back(*p_it); - m_LSPnts[0].push_back(projPoint); - - if (((projPoint.z - p_it->z) / m_normals[i].z ) > 0) - m_error[i] = sqrt(sqrdis); - else - m_error[i] = -sqrt(sqrdis); - - err_avg += sqrdis; - } - } - - - ++i; - } - - //for (p_it.Begin(); p_it.More(); p_it.Next()) -// { - // if (!malg.NearestFacetOnRay(*p_it, m_normals[i], aFacetGrid, projPoint, facetIndex)) // grid-optimized -// { -// if (malg2.NearestFacetOnRay(*p_it, m_normals[i], projPoint, facetIndex)) -// { - -// log3d.addSingleArrow(*p_it, projPoint, 3, 0,0,0); -// distVec = projPoint - *p_it; -// sqrdis = distVec*distVec; - -// if (((projPoint.z - p_it->z) / m_normals[i].z ) > 0) -// m_error[i] = sqrt(sqrdis); -// else -// m_error[i] = -sqrt(sqrdis); - -// err_avg += sqrdis; -// } -// else -// { -// c++; -// FailProj.push_back(i); -// } -// } -// else -// { -// distVec = projPoint-*p_it; -// sqrdis = distVec*distVec; - -// m_normals[i].Scale(-1,-1,-1); - -// if (malg.NearestFacetOnRay(*p_it, m_normals[i], aFacetGrid, projPoint2, facetIndex)) -// { -// distVec = projPoint2-*p_it; -// if (sqrdis > distVec*distVec) -// { -// sqrdis = distVec*distVec; -// log3d.addSingleArrow(*p_it, projPoint2, 3, 0,0,0); -// } -// else -// { -// log3d.addSingleArrow(*p_it, projPoint, 3, 0,0,0); -// } - -// } -// m_normals[p_it.Position()].Scale(-1,-1,-1); - -// if (((projPoint.z - p_it->z) / m_normals[i].z ) > 0) -// m_error[i] = sqrt(sqrdis); -// else -// m_error[i] = -sqrt(sqrdis); - -// err_avg += sqrdis; -// } -// ++i; - //} - - - MeshCore::MeshRefPointToPoints vv_it(m_CadMesh); - MeshCore::MeshPointArray::_TConstIterator v_beg = m_CadMesh.GetPoints().begin(); - - std::set::const_iterator v_it; - for (unsigned int i=0; i& PntNei = vv_it[FailProj[i]]; - m_error[FailProj[i]] = 0.0; - - for (v_it = PntNei.begin(); v_it !=PntNei.end(); ++v_it) - { - m_error[FailProj[i]] += m_error[v_beg[*v_it]._ulProp]; - } - - m_error[FailProj[i]] /= double(PntNei.size()); - } - - - log3d.saveToFile("c:/projection.iv"); - - if (c>(m_CadMesh.CountPoints()/2)) - return 1e+10; - - return err_avg/(m_CadMesh.CountPoints()-c); - -} - -double best_fit::CompTotalError(MeshCore::MeshKernel &mesh) -{ - double err_avg = 0.0; - double err_max = 0.0; - double sqrdis = 0.0; - - std::vector FailProj; - - MeshCore::MeshFacetGrid aFacetGrid(mesh,10); - MeshCore::MeshAlgorithm malg(mesh); - MeshCore::MeshAlgorithm malg2(mesh); - MeshCore::MeshPointIterator p_it(m_CadMesh); - - Base::Vector3f projPoint, distVec, projPoint2; - unsigned long facetIndex; - std::stringstream text; - m_error.resize(m_CadMesh.CountPoints()); - - unsigned int c=0; - int i=0; - - for (p_it.Begin(); p_it.More(); p_it.Next()) - { - if (malg.NearestFacetOnRay(*p_it, m_normals[i], aFacetGrid, projPoint, facetIndex)) // grid-optimized - { - distVec = projPoint - *p_it; - sqrdis = distVec*distVec; - - if (((projPoint.z - p_it->z) / m_normals[i].z ) > 0) - m_error[i] += sqrt(sqrdis); - else - m_error[i] += -sqrt(sqrdis); - - err_avg += sqrdis; - } - else - { - - if (!malg2.NearestFacetOnRay(*p_it, m_normals[i], projPoint, facetIndex)) // not grid-optimized - { - c++; - FailProj.push_back(i); - } - else - { - distVec = projPoint - *p_it; - sqrdis = distVec*distVec; - - if (((projPoint.z - p_it->z) / m_normals[i].z ) > 0) - m_error[i] += sqrt(sqrdis); - else - m_error[i] += -sqrt(sqrdis); - - err_avg += sqrdis; - } - } - - - ++i; - } - - MeshCore::MeshRefPointToPoints vv_it(m_CadMesh); - MeshCore::MeshPointArray::_TConstIterator v_beg = m_CadMesh.GetPoints().begin(); - - double error; - std::set::const_iterator v_it; - for (unsigned int i=0; i& PntNei = vv_it[FailProj[i]]; - error = 0.0; - - - for (v_it = PntNei.begin(); v_it !=PntNei.end(); ++v_it) - { - error += m_error[v_beg[*v_it]._ulProp]; - } - - error /= double(PntNei.size()); - m_error[FailProj[i]] += error; - } - - - if (c>(m_CadMesh.CountPoints()/2)) - return 1e+10; - - return err_avg/(m_CadMesh.CountPoints()-c); -} diff --git a/src/Mod/Cam/App/best_fit.h b/src/Mod/Cam/App/best_fit.h deleted file mode 100644 index 05f0f38c61..0000000000 --- a/src/Mod/Cam/App/best_fit.h +++ /dev/null @@ -1,256 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2007 Joachim Zettler * - * Copyright (c) 2007 Human Rezai * - * * - * This file is part of the FreeCAD CAx development system. * - * * - * This library is free software; you can redistribute it and/or * - * modify it under the terms of the GNU Library General Public * - * License as published by the Free Software Foundation; either * - * version 2 of the License, or (at your option) any later version. * - * * - * This library is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * - * GNU Library General Public License for more details. * - * * - * You should have received a copy of the GNU Library General Public * - * License along with this library; see the file COPYING.LIB. If not, * - * write to the Free Software Foundation, Inc., 59 Temple Place, * - * Suite 330, Boston, MA 02111-1307, USA * - * * - ***************************************************************************/ - -#ifndef BEST_FIT_H -#define BEST_FIT_H - - -#include -#include -#include -#include -#include -#include -#include -#include -#include - - -#define SMALL_NUM 1e-6 -#define ERR_TOL 0.001 // Abort criterion for least square matching - // (error change in two successive iteration steps) - - -/*! \brief The main class for the best_fit routine - - It takes a mesh and a Topo_Shape as it's input parameter. - - As output, it gives a transformed mesh (rotation + translation) - based on a weighted ICP-Algorithm (ICP: Iterative Closed Point) which fits the - Topo_Shape -*/ - -class CamExport best_fit -{ -public: - best_fit(); - ~best_fit(); - - /*! \brief Load the input-shapes. Must be called before running the main program - - \param InputMesh Input-mesh - \param CAD_Shape Input-shape - */ - void Load(const MeshCore::MeshKernel &InputMesh, const TopoDS_Shape &CAD_Shape); - - bool Initialize_Mesh_Geometrie_1(); - bool Initialize_Mesh_Geometrie_2(); - - /*! \brief Determines the local-coordinate-systems of the input-shapes and - apply a coordinate transformation to the mesh - */ - bool MeshFit_Coarse(); - - /*! \brief Determines the center of mass of the input-shape and - translates the shape to the global origin - */ - bool ShapeFit_Coarse(); - - /*! \brief Determines the center of mass of the point-cloud and - translates the shape to the global origin - */ - bool PointCloud_Coarse(); - - /*! \brief Main function of the best-fit-algorithm */ - bool Perform(); - - /*! \brief Main function of the best-fit-algorithm only on point clouds */ - bool Perform_PointCloud(); - - bool output_best_fit_mesh(); - - //double CompError(std::vector &pnts, std::vector &normals); - //double CompError(std::vector &pnts, std::vector &normals, bool plot); - - //std::vector CompError_GetPnts(std::vector pnts, - // std::vector &normals); - - /*! \brief Computes error between the input-shapes through intersection - along the normal-directions and returns an average-error-value - */ - double CompTotalError(); - - /*! \brief Computes error between mesh and the input-shape through - intersection along the normal-directions and returns an - average-error-value - */ - double CompTotalError(MeshCore::MeshKernel &mesh); - - /*! \brief Computes a triangulation on shape. - - \param shape specifies the shape to be tessellated - \param mesh output-mesh to store the computed triangulation - \param deflection parameter which determines the accuracy of the - triangulation - */ - static bool Tesselate_Shape(const TopoDS_Shape &shape, MeshCore::MeshKernel &mesh, float deflection); - - /*! \brief Computes a triangulation on aface. - - \param aface specifies the face to be tessellated - \param mesh output-mesh to store the computed triangulation - \param deflection parameter which determines the accuracy of the - triangulation - */ - static bool Tesselate_Face (const TopoDS_Face &aface, MeshCore::MeshKernel &mesh, float deflection); - - /*! \brief Returns a normal-vector of Mesh at the knots with uniform - weighting - - \param Mesh Input-Mesh - */ - static std::vector Comp_Normals(MeshCore::MeshKernel &Mesh); - - /*! \brief Check and corrects mesh-position by rotating around all - coordinate-axes with 180 degree - */ - bool Coarse_correction(); - - /*! \brief Determines two corresponding point-sets for the ICP-Method - using the Nearest-Neighbour-Algorithm - */ - double ANN(); - - /*! \brief Input-shape from the function Load */ - TopoDS_Shape m_Cad; // CAD-Geometrie - - /*! \brief Input-mesh from the function Load */ - MeshCore::MeshKernel m_Mesh; // das zu fittende Netz - - /*! \brief A copy of m_Mesh */ - MeshCore::MeshKernel m_MeshWork; - - /*! \brief Triangulated input-shape m_Cad */ - MeshCore::MeshKernel m_CadMesh; // Netz aus CAD-Triangulierung - - - std::vector m_pntCloud_1; - std::vector m_pntCloud_2; - - - /*! \brief Stores the knots of m_CadMesh in relative order */ - std::vector m_pnts; - - /*! \brief Stores the normals of m_CadMesh in relative order */ - std::vector m_normals; - - /*! \brief Stores the error-values of m_CadMesh in relative order */ - std::vector m_error; - - /*! \brief Stores the point-sets computed with the function ANN() */ - std::vector > m_LSPnts; // Points sets to be fitted for Least-Square - - /*! \brief Stores the weights computed with the function Comp_Weights() */ - std::vector m_weights; // weighting for the Least-Square with respect to all network points - - /*! \brief A working-copy of m_weights */ - std::vector m_weights_loc; // weighting for the Least-Square with respect to the projected network points - - /*! \brief Translation-vector from the function ShapeFit_Coarse() */ - gp_Vec m_cad2orig; // Translation vector that centers the CAD geometry about the origin - - /*! \brief Vector of the preselected-faces for the weighting */ - std::vector m_LowFaces; // Vector of the faces selected in the GUI with little weighting - -private: - /*! \brief Computes the rotation-matrix with reference to the given - parameters - - \param matrix 4x4-output-matrix - \param degree rotation-angle in degree - \param rotationAxis rotation-axis (1: x-axis, 2: y-axis, 3: z-axis) - */ - inline bool RotMat(Base::Matrix4D &matrix, double degree, int rotationAxis); - - /*! \brief Computes the translation-matrix with reference to the given - parameters - - \param matrix 4x4-output-matrix - \param translation translation-value - \param translationAxis translation-axis (1: x-axis, 2: y-axis, 3: z-axis) - */ - inline bool TransMat(Base::Matrix4D &matrix, double translation, int translationAxis); - - /*! \brief Transforms the point-set \p pnts and the corresponding - surface-normals normals with reference to the input-matrix - - \param pnts point-vector to transform - \param normals normal-vector to transform - \param M 4x4-input-matrix - */ - inline bool PointNormalTransform(std::vector &pnts, - std::vector &normals, - Base::Matrix4D &M); - - /*! \brief Transforms the point-set pnts with reference to the input-matrix - - \param pnts point-vector to transform - \param M is the 4x4-input-matrix - */ - bool PointTransform(std::vector &pnts, const Base::Matrix4D &M); - - /*! \brief Sets the weights for the ICP-Algorithm */ - bool Comp_Weights(); - - /*! \brief Performing the ICP-Algorithm */ - bool LSM(); - - /*! \brief Returns the first derivative of the rotation-matrix at the - position x - - \param params is a three-dimensional-vector specifying the rotation - angle along the x-,y- and z-axis - */ - std::vector Comp_Jacobi(const std::vector ¶ms); - - /*! \brief Returns the second derivative (Hessian matrix) of the rotation - matrix at the position x in form of a two-dimensional vector - of type double - - \param params is a three-dimensional-vector specifying the rotation - angle along the x-,y- and z-axis - */ - std::vector > Comp_Hess (const std::vector ¶ms); - - SMESH_Mesh *m_referencemesh; - SMESH_Mesh *m_meshtobefit; - SMESH_Gen *m_aMeshGen1; - SMESH_Gen *m_aMeshGen2; - - - - //int intersect_RayTriangle(const Base::Vector3f &normal,const MeshCore::MeshGeomFacet &T, Base::Vector3f &P, Base::Vector3f &I); - // bool Intersect(const Base::Vector3f &normal,const MeshCore::MeshKernel &mesh, Base::Vector3f &P, Base::Vector3f &I); -}; - -#endif diff --git a/src/Mod/Cam/App/cutting_tools.cpp b/src/Mod/Cam/App/cutting_tools.cpp deleted file mode 100644 index d5279ecace..0000000000 --- a/src/Mod/Cam/App/cutting_tools.cpp +++ /dev/null @@ -1,3646 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2007 Joachim Zettler * - * * - * This file is part of the FreeCAD CAx development system. * - * * - * This library is free software; you can redistribute it and/or * - * modify it under the terms of the GNU Library General Public * - * License as published by the Free Software Foundation; either * - * version 2 of the License, or (at your option) any later version. * - * * - * This library is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * - * GNU Library General Public License for more details. * - * * - * You should have received a copy of the GNU Library General Public * - * License along with this library; see the file COPYING.LIB. If not, * - * write to the Free Software Foundation, Inc., 59 Temple Place, * - * Suite 330, Boston, MA 02111-1307, USA * - * * - ***************************************************************************/ - - -#include "PreCompiled.h" - -//Mesh Stuff -#include -#include -#include -#include -#include -#include -#include - - -//FreeCAD Stuff -#include - -//OCC Stuff -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -//Own Stuff -#include "cutting_tools.h" -#include "best_fit.h" -#include "edgesort.h" -#include "WireExplorer.h" -#include "BRepAdaptor_CompCurve2.h" -//#include "MeshInterface.h" - - - - - - - -cutting_tools::cutting_tools(TopoDS_Shape aShape, float pitch) - : m_Shape(aShape), - m_aMeshAlgo(NULL), - m_CAD_Mesh_Grid(NULL), - m_pitch(pitch) -{ - m_ordered_cuts.clear(); - m_all_offset_cuts_high.clear(); - m_all_offset_cuts_low.clear(); - m_face_bboxes.clear(); - m_cad = false; - m_CAD_Mesh.Clear(); - m_FaceWireMap.clear(); - m_MachiningOrder.clear(); - getShapeBB(); - fillFaceBBoxes(); - classifyShape(); - //checkFlatLevel(); - initializeMeshStuff(); - //BRepBuilderAPI_Sewing aSewer; - //aSewer.Add(m_Shape); - //aSewer. - //Everything should be initialised now - -} - - - -cutting_tools::cutting_tools(TopoDS_Shape aShape) - :m_Shape(aShape),m_aMeshAlgo(NULL),m_CAD_Mesh_Grid(NULL),m_cad(false),m_pitch(0.0) -{ - m_ordered_cuts.clear(); - m_all_offset_cuts_high.clear(); - m_all_offset_cuts_low.clear(); - m_face_bboxes.clear(); - m_CAD_Mesh.Clear(); - m_FaceWireMap.clear(); - m_MachiningOrder.clear(); - getShapeBB(); - fillFaceBBoxes(); - classifyShape(); - //checkFlatLevel(); - initializeMeshStuff(); - - - -} - - -cutting_tools::~cutting_tools() -{ - delete m_aMeshAlgo; - delete m_CAD_Mesh_Grid; -} - - -bool cutting_tools::SetMachiningOrder(const TopoDS_Face &aFace, float x,float y,float z) -{ - std::pair aTempPair; - Base::Vector3f aPoint(x,y,z); - aTempPair.first = aPoint; - aTempPair.second = aFace; - m_MachiningOrder.push_back(aTempPair); - return true; -} - - -bool cutting_tools::fillFaceWireMap() -{ - std::vector >::iterator MOrderIt; - for (MOrderIt = m_MachiningOrder.begin();MOrderIt != m_MachiningOrder.end(); ++MOrderIt) - { - //Here we take the flat areas and put them in a map where we can easily search for the biggest, smallest Wire - std::pair >aTempPair; - aTempPair.second.clear(); - std::pair aTempBBoxPair; - aTempPair.first = MOrderIt->second; - //Now go through the face and filter out the wires - TopExp_Explorer Explore_Face; - Explore_Face.Init(MOrderIt->second,TopAbs_WIRE); - //If there is no Wire -> return - if (!Explore_Face.More()) return false; - - //Now push all wires into the map - for (Explore_Face.ReInit();Explore_Face.More();Explore_Face.Next()) - { - aTempBBoxPair.first = getWireBBox(TopoDS::Wire(Explore_Face.Current())); - aTempBBoxPair.second = TopoDS::Wire(Explore_Face.Current()); - aTempPair.second.insert(aTempBBoxPair); - } - m_FaceWireMap.insert(aTempPair); - } - return true; -} - - - - -bool cutting_tools::getShapeBB() -{ - // The Cascade bounding box is not working properly - // There will probably be a bounding box around the control network - // Therefore, the shape is now briefly tessellated and the bounding box is then read out directly - best_fit::Tesselate_Shape(m_Shape,m_CAD_Mesh,float(0.1)); - Base::BoundBox3f aBoundBox = m_CAD_Mesh.GetBoundBox(); - m_maxlevel = aBoundBox.MaxZ; - m_minlevel = aBoundBox.MinZ; - - // //Here we are testing a few more OpenMesh functions - // typedef OpenMesh::DefaultTraits MyTraits; - // typedef OpenMesh::TriMesh_ArrayKernelT MyMesh; - - //////// Mesh::Interface inherits from MyMesh so that the 'mesh' object can be used directly in the OpenMesh functions - // Mesh::Interface mesh(m_CAD_Mesh); - ////// proceed with mesh, e.g. refining - // MyMesh::EdgeIter e_it,e_end(mesh.edges_end()); - // MyMesh::EdgeHandle eh; - // MyMesh::Scalar dist; - // MyMesh::Point startPoint,midPoint,endPoint; - - // for ( e_it = mesh.edges_begin() ; e_it != e_end ; ++e_it ) - // { - // eh = e_it.handle(); - // dist = mesh.calc_edge_length(eh); //get the length of the current edge - // if(dist>2.6) //Split the Edge now - // { - // - // //Get the Start and EndPoints of the Edge - // - // } - - // } - ////// throw away all tagged edges - ////mesh.garbage_collection(); //Function from OpenMesh - //mesh.release(m_CAD_Mesh); //Function from MeshInterface to convert the Input Kernel back - - - - /* Here is the old OCC BoundingBox function - Bnd_Box currentBBox; - Standard_Real XMin, YMin, ZMin, XMax, YMax, ZMax; - BRepBndLib::Add(m_shape, currentBBox ); - currentBBox.SetGap(1000.0); - currentBBox.Get(XMin, YMin, ZMin, XMax, YMax, ZMax); - */ - return true; -} - - -//bool cutting_tools::fillFaceMeshMap() -//{ -// if(m_CAD_Mesh.size()> - - - - - -bool cutting_tools::fillFaceBBoxes() -{ - TopoDS_Face atopo_surface; - TopExp_Explorer Explorer; - MeshCore::MeshKernel aFaceMesh; - Base::BoundBox3f aBoundBox; - Explorer.Init(m_Shape,TopAbs_FACE); - for (;Explorer.More();Explorer.Next()) - { - aFaceMesh.Clear(); - aBoundBox.Flush(); - atopo_surface = TopoDS::Face (Explorer.Current()); - best_fit::Tesselate_Face(atopo_surface,aFaceMesh,float(0.1)); - aBoundBox = aFaceMesh.GetBoundBox(); - aBoundBox.Enlarge(2.0); - std::pair tempPair; - tempPair.first = atopo_surface; - tempPair.second = aBoundBox; - m_face_bboxes.push_back(tempPair); - } - return true; -} -//Here is the old version to determine the bounding box -// aAdaptor_Surface.Initialize(atopo_surface); -// Standard_Real FirstUParameter, LastUParameter,FirstVParameter,LastVParameter; -// gp_Pnt aSurfacePoint; -// FirstUParameter = aAdaptor_Surface.FirstUParameter(); -// LastUParameter = aAdaptor_Surface.LastUParameter(); -// FirstVParameter = aAdaptor_Surface.FirstVParameter(); -// LastVParameter = aAdaptor_Surface.LastVParameter(); -//float urange = LastUParameter - FirstUParameter; -//float vrange = LastVParameter - FirstVParameter; -////Now make a 10x10 grid per face and determine the BBox in this way -////First of all, set the bounding box to zero -//Bnd_Box currentBBox; -// -//for(int i=0;i<10;++i) -//{ -// for(int j=0;j<10;++j) -// { -// aAdaptor_Surface.D0(FirstUParameter+((urange/10)*i),FirstVParameter+((vrange/10)*j),aSurfacePoint); -// currentBBox.Update(aSurfacePoint.X(),aSurfacePoint.Y(),aSurfacePoint.Z()); -// } -//} -////Now build a border around it -//currentBBox.SetGap(0.5); -////Now push the current bounding box with the current face into a vector -//std::pair tempPair; -//tempPair.first = atopo_surface; -//tempPair.second = currentBBox; -//m_face_bboxes.push_back(tempPair); -////aVertex = BRepBuilderAPI_MakeVertex(aSurfacePoint); -////BRepBndLib::Add(aVertex, currentBBox ); -//currentBBox.SetVoid(); - - -bool cutting_tools::checkPointinFaceBB(const gp_Pnt &aPnt,const Base::BoundBox3f &aBndBox) -{ - if ((aPnt.X()>aBndBox.MinX) && (aPnt.X()aBndBox.MinY) && (aPnt.Y()aBndBox.MinZ) && (aPnt.Z() tempPair; - tempPair.first = z_level_corrected; - tempPair.second = aCutShape; - m_ordered_cuts.push_back(tempPair); - } - return true; - } - //If we have several faces or a CAD geometry is available - else - { - //The machining order is now used to determine the cutting sequence - std::vector >::iterator MOrderIt; - if (m_MachiningOrder.size()<2) return false; //Did not select at least two Levels - //Now take two levels and perform the Cutting Stuff - for (MOrderIt = m_MachiningOrder.begin();MOrderIt != m_MachiningOrder.end(); ++MOrderIt) - { - float temp_max = MOrderIt->first.z; - //the check if MOrderIt+1 != end is performed at the bottom of the function - float temp_min = (MOrderIt+1)->first.z; - //set the direction flags - if (temp_max> temp_min) - m_direction = true; - else m_direction = false; - //Now we cut from temp_max to temp_min, without the flat areas at the top and bottom - - int cutnumber = (int)fabs((temp_max-temp_min)/m_UserSettings.level_distance); - //m_pitch correction to really reach temp_min - m_UserSettings.level_distance = fabs(temp_max-temp_min)/cutnumber; - - float z_level,z_level_corrected; - TopoDS_Shape aCutShape; - //Now lets cut and push the highest and lowest level also into the results vector - std::pair tempPair; - //Highest Level push_back (only the proper Wire) - - tempPair.first = MOrderIt->first.z; - //get the Wire with the smallest Bounding Box if we go from top to bottom for the highest area - tempPair.second = m_FaceWireMap.find(MOrderIt->second)->second.begin()->second; - - m_ordered_cuts.push_back(tempPair); - for (int i=1;ifirst.z; - tempPair.second = m_FaceWireMap.find((MOrderIt+1)->second)->second.rbegin()->second; - m_ordered_cuts.push_back(tempPair); - break; //No more combination to find - } - else - { - tempPair.first = (MOrderIt+1)->first.z; - tempPair.second = m_FaceWireMap.find((MOrderIt+1)->second)->second.rbegin()->second; - m_ordered_cuts.push_back(tempPair); - } - } - } - return true; -} - - - - - - - - -//} -// std::map >::iterator zl_wire_it; -// //We are now getting the next Z-Level out. We have to take something smaller like the highest value, -// //otherwise it will always output the highest value -// zl_wire_it = m_zl_wire_combination.upper_bound(temp_max-0.1); -// if (zl_wire_it->first == temp_max) -// { -// cout << "Well, there is probably only one flat area"; -// temp_min = m_minlevel; -// } -// //If there are multiple flat areas, I have to go over again -// else -// { -// temp_min = zl_wire_it->first; -// cout << "Detected multiple areas"; -// } -// //Now cut from temp_max to temp_min -// int cutnumber = (int)fabs((temp_max-temp_min)/m_pitch); -// //Correct m_pitch slightly to really get to the last level -// m_pitch = fabs(temp_max-temp_min)/cutnumber; -// //Now make the cuts. The highest level is omitted because no sheet is pressed here yet -// float z_level,z_level_corrected; -// TopoDS_Shape aCutShape; -// //Cut now (omit the top layer) -// for (int i=1;i<=20;++i) -// { -// z_level = temp_max-(i*m_pitch); -// z_level_corrected = z_level; -// //cut_Mesh(z_level,m_minlevel,result,z_level_corrected); -// //Now move the resulting points into the vector -// //std::pair > > tempPair; -// //tempPair.first = z_level_corrected; -// //tempPair.second = result; -// //m_ordered_cuts.push_back(tempPair); -// cut(z_level,temp_min, aCutShape,z_level_corrected); -// //Now insert the filled wire into the vector -// std::pair tempPair; -// tempPair.first = z_level_corrected; -// tempPair.second = aCutShape; -// m_ordered_cuts.push_back(tempPair); -// } -// return true; -// } -// return false; -//} - - - -//bool cutting_tools::checkFlatLevel() -//{ -// //If there is no CAD geometry, jump straight out again -// -// if (m_cad==false) return false; -// -// TopoDS_Face atopo_surface; -// BRepAdaptor_Surface aAdaptor_Surface; -// TopExp_Explorer Explorer; -// -// -// for (Explorer.Init(m_Shape,TopAbs_FACE);Explorer.More();Explorer.Next()) -// { -// atopo_surface = TopoDS::Face (Explorer.Current()); -// aAdaptor_Surface.Initialize(atopo_surface); -// Standard_Real FirstUParameter, LastUParameter,FirstVParameter,LastVParameter; -// gp_Pnt first,second,third; -// gp_Vec first_u,first_v,second_u,second_v,third_u,third_v, Norm_first,Norm_second,Norm_third,Norm_average; -// double u_middle,v_middle; -// /* -// Generate three random point on the surface to get the surface normal and decide whether it's a -// planar face or not -// */ -// FirstUParameter = aAdaptor_Surface.FirstUParameter(); -// LastUParameter = aAdaptor_Surface.LastUParameter(); -// FirstVParameter = aAdaptor_Surface.FirstVParameter(); -// LastVParameter = aAdaptor_Surface.LastVParameter(); -// u_middle = sqrt((FirstUParameter - LastUParameter)*(FirstUParameter - LastUParameter))/2; -// v_middle = sqrt((FirstVParameter - LastVParameter)*(FirstVParameter - LastVParameter))/2; -// aAdaptor_Surface.D1(sqrt((FirstUParameter-u_middle)*(FirstUParameter-u_middle))/2,sqrt((FirstVParameter-v_middle)*(FirstVParameter-v_middle))/2,first,first_u,first_v); -// aAdaptor_Surface.D1(sqrt((u_middle)*(u_middle))/2,sqrt((v_middle)*(v_middle))/2,second,second_u,second_v); -// aAdaptor_Surface.D1(sqrt((FirstUParameter+u_middle)*(FirstUParameter+u_middle))/2,sqrt((FirstVParameter+v_middle)*(FirstVParameter+v_middle))/2,third,third_u,third_v); -// //Get Surface normal as Cross-Product between two Vectors -// Norm_first = first_u.Crossed(first_v); -// Norm_first.Normalize(); -// Norm_second = second_u.Crossed(second_v); -// Norm_second.Normalize(); -// Norm_third = third_u.Crossed(third_v); -// Norm_third.Normalize(); -// //Evaluate average normal vector -// Norm_average.SetX((Norm_first.X()+Norm_second.X()+Norm_third.X())/3); -// Norm_average.SetY((Norm_first.Y()+Norm_second.Y()+Norm_third.Y())/3); -// Norm_average.SetZ((Norm_first.Z()+Norm_second.Z()+Norm_third.Z())/3); -// Norm_average.Normalize(); -// gp_Vec z_normal(0,0,1); -// gp_Vec z_normal_opposite(0,0,-1); -// if (Norm_average.IsEqual(z_normal,0.01,0.01) || Norm_average.IsEqual(z_normal_opposite,0.01,0.01)) -// { -// cout << "Found a flat area"; -// std::pair >aTempPair; -// aTempPair.second.clear(); -// std::pair aTempBBoxPair; -// -// //Push the Z-value from the flat area into a temporary pair -// aTempPair.first = ((first.Z()+second.Z()+third.Z())/3); -// //Now go through the face and filter the wires out -// TopExp_Explorer Explore_Face; -// Explore_Face.Init(atopo_surface,TopAbs_WIRE); -// //If there is no Wire -> return -// if (!Explore_Face.More()) return false; -// -// //Now push all wires into the map -// for (Explore_Face.ReInit();Explore_Face.More();Explore_Face.Next()) -// { -// aTempBBoxPair.first = getWireBBox(TopoDS::Wire(Explore_Face.Current())); -// aTempBBoxPair.second = TopoDS::Wire(Explore_Face.Current()); -// aTempPair.second.insert(aTempBBoxPair); -// //aTempPair.first is still at the same Z value as before, so nothing needs to be adjusted -// } -// m_zl_wire_combination.insert(aTempPair); -// } -// } -// -// return true; -//} - -//bool cutting_tools::projectWireToSurface(const TopoDS_Wire &aWire,const TopoDS_Shape &aShape,std::vector &aContainer); -//{ -// //make your wire looks like a curve to other algorithm and generate Points to offset the curve -// aContainer.clear(); -// BRepAdaptor_CompCurve2 wireAdaptor(aWire); -// GCPnts_QuasiUniformDeflection aProp(wireAdaptor,0.01); -// int numberofpoints = aProp.NbPoints(); -// Standard_Real Umin,Vmin,lowestdistance; -// TopoDS_Face atopo_surface,atopo_surface_shortest; -// Handle_Geom_Surface geom_surface; -// -// //Now project the points to the surface and get surface normal. -// for (int i=1;i<=numberofpoints;++i) -// { -// lowestdistance=200; -// //Get the current point -// gp_Pnt currentPoint = aProp.Value(i); -// projectPointContainer aTempContainer; -// //check which face we can project onto -// for(m_face_bb_it = m_face_bboxes.begin();m_face_bb_it!=m_face_bboxes.end();++m_face_bb_it) -// { -// //If the current point is contained in the BBox, then we continue with the projection -// if(checkPointinFaceBB(aProp.Value(i),m_face_bb_it->second)) -// { -// atopo_surface = m_face_bb_it->first; -// geom_surface = BRep_Tool::Surface(atopo_surface); -// GeomAPI_ProjectPointOnSurf aPPS(currentPoint,geom_surface,0.001); -// //If nothing can be projected, it goes straight to the next face or the next BBox -// if (aPPS.NbPoints() == 0) continue; -// //Now the current face has to be saved, as it may be the face that is closest -// double length = aPPS.LowerDistance(); -// if(lowestdistance>length) -// { -// lowestdistance=length; -// atopo_surface_shortest = atopo_surface; -// aPPS.LowerDistanceParameters (Umin,Vmin); -// } -// } -// } -// gp_Vec Uvec,Vvec,normalVec; -// geom_surface = BRep_Tool::Surface(atopo_surface_shortest); -// //Save the face which is closest in the temp-struct -// aTempContainer.face = atopo_surface_shortest; -// geom_surface->D1(Umin,Vmin,aTempContainer.point,Uvec,Vvec); -// //Now calculate the normal vector on the surface -// normalVec = Uvec; -// normalVec.Cross(Vvec); -// normalVec.Normalize(); -// //Now the normal is calculated and normalized -// //Now check if the normal is really pointing to the same side like everyone else. -// //To do this, just check whether the Z-value of the normal is greater than zero (then in the 1st and 2nd quadrant) -// if(normalVec.Z()<0) normalVec.Multiply(-1.0); -// //Briefly calculate the angle to the ground plane -// aTempContainer.normalvector = normalVec; -// aContainer.push_back(aTempContainer); -// -// } -// return true; -//} - - -TopoDS_Wire cutting_tools::ordercutShape(const TopoDS_Shape &aShape) -{ - //So far, the whole thing only works for cuts that only run around once and not yet for islands - TopExp_Explorer exploreShape; - exploreShape.Init(aShape,TopAbs_EDGE); - int k=0; - for (; exploreShape.More(); exploreShape.Next()) //first see how many edges we have - { - k++; - } - //Now pack the edges all into one wire (with Add) and see if there is an error. - //If so, then the next Edge. Until all the edges are in. - - if (k<1) - { - exploreShape.ReInit(); - BRepBuilderAPI_MakeWire mkWire(TopoDS::Edge(exploreShape.Current())); - return mkWire.Wire(); - } - else //Only when there is more than one Edge - { - BRepBuilderAPI_MakeWire mkWire; //Build the WireContainer - std::vector listofedge_tmp,listofedge; - std::vector::iterator it_edge; - edge_container a_edge_container; //Defined in stuff.h - listofedge.clear(); - listofedge_tmp.clear(); - exploreShape.ReInit(); - //Fill Edge List - for (; exploreShape.More(); exploreShape.Next()) - { - a_edge_container.edge = TopoDS::Edge(exploreShape.Current()); - TopoDS_Vertex V1,V2; - TopExp::Vertices(a_edge_container.edge,V1,V2); - a_edge_container.firstPoint = BRep_Tool::Pnt(V1);; - a_edge_container.lastPoint = BRep_Tool::Pnt(V2); - listofedge.push_back(a_edge_container); - } - - gp_Pnt lastpointoflastedge,firstpointoflastedge; - while (listofedge.empty() == false ) - { - listofedge_tmp.clear(); - for (it_edge = listofedge.begin();it_edge!=listofedge.end();++it_edge) - { - mkWire.Add((*it_edge).edge); - if (mkWire.IsDone()) - { - lastpointoflastedge = (*it_edge).lastPoint; - firstpointoflastedge = (*it_edge).firstPoint; - } - else - { - //Calculate distances - double abstand1=sqrt((*it_edge).firstPoint.SquareDistance(lastpointoflastedge)); - double abstand2=sqrt((*it_edge).lastPoint.SquareDistance(lastpointoflastedge)); - double abstand3=sqrt((*it_edge).firstPoint.SquareDistance(firstpointoflastedge)); - double abstand4=sqrt((*it_edge).lastPoint.SquareDistance(firstpointoflastedge)); - if (abstand1<0.5) - { - //Create new edge which goes from the last end point to the current starting point - BRepBuilderAPI_MakeEdge newedge(lastpointoflastedge,(*it_edge).firstPoint); - mkWire.Add(newedge); - mkWire.Add((*it_edge).edge); - lastpointoflastedge = (*it_edge).lastPoint; - firstpointoflastedge = (*it_edge).firstPoint; - } - else if (abstand2<0.5) - { - //Create new edge which goes from the last end point to the current starting point - BRepBuilderAPI_MakeEdge newedge(lastpointoflastedge,(*it_edge).lastPoint); - mkWire.Add(newedge); - mkWire.Add((*it_edge).edge); - lastpointoflastedge = (*it_edge).lastPoint; - firstpointoflastedge = (*it_edge).firstPoint; - - } - - else if (abstand3<0.5) - { - //Create new edge which goes from the last end point to the current starting point - BRepBuilderAPI_MakeEdge newedge(firstpointoflastedge,(*it_edge).firstPoint); - mkWire.Add(newedge); - mkWire.Add((*it_edge).edge); - lastpointoflastedge = (*it_edge).lastPoint; - firstpointoflastedge = (*it_edge).firstPoint; - } - else if (abstand4<0.5) - { - //Create new edge which goes from the last end point to the current starting point - BRepBuilderAPI_MakeEdge newedge(firstpointoflastedge,(*it_edge).lastPoint); - mkWire.Add(newedge); - mkWire.Add((*it_edge).edge); - lastpointoflastedge = (*it_edge).lastPoint; - firstpointoflastedge = (*it_edge).firstPoint; - } - else - { - listofedge_tmp.push_back(*it_edge); - } - } - } - listofedge = listofedge_tmp; - } - return mkWire.Wire(); - } - -} - - -//bool cutting_tools::OffsetWires_Standard(float radius) //Version where it is only shifted in the X,Y plane -//{ -// Base::Builder3D build; -// std::ofstream outfile; -// outfile.open("c:/atest.out"); -// -// -// //The ordered_cuts are a vector where there is a pair for every level -// for(m_ordered_cuts_it = m_ordered_cuts.begin();m_ordered_cuts_it!=m_ordered_cuts.end();++m_ordered_cuts_it) -// { -// float current_z_level = m_ordered_cuts_it->first; -// std::vector finalPoints; -// finalPoints.clear(); -// Standard_Real Umin,Vmin,lowestdistance; -// TopoDS_Face atopo_surface,atopo_surface_shortest; -// Handle_Geom_Surface geom_surface; -// int i=0; -// for (;avector_it!=aPolyline_it->end();++avector_it) -// { -// i++; -// lowestdistance=200; -// //Get the current point -// gp_Pnt currentPoint(avector_it->x,avector_it->y,avector_it->z); -// gp_Pnt nearest_Point; -// //check which face we can project onto -// for(m_face_bb_it = m_face_bboxes.begin();m_face_bb_it!=m_face_bboxes.end();++m_face_bb_it) -// { -// //If the current point is in the BBox, then we continue with the projection -// if(checkPointinFaceBB(currentPoint,m_face_bb_it->second)) -// { -// atopo_surface = m_face_bb_it->first; -// geom_surface = BRep_Tool::Surface(atopo_surface); -// GeomAPI_ProjectPointOnSurf aPPS(currentPoint,geom_surface,0.001); -// //If nothing can be projected, it goes straight to the next face or the next BBox -// if (aPPS.NbPoints() == 0) continue; -// //Now the current face has to be saved, as it may be the face that is closest -// double length = aPPS.LowerDistance(); -// if(lowestdistance>length) -// { -// lowestdistance=length; -// atopo_surface_shortest = atopo_surface; -// //aPPS.LowerDistanceParameters (Umin,Vmin); -// nearest_Point = aPPS.NearestPoint(); -// } -// } -// } -// //For a clean projection on the current plane, the direction vector is now -// //formed from the projected point and the point of origin -// //and then used to project again in that direction -// gp_Vec aVec(currentPoint,nearest_Point); -// aVec.Normalize(); -// aVec.SetZ(0.0); -// gp_Dir aDir(aVec); -// gp_Lin aLine(currentPoint,aDir); -// IntCurvesFace_ShapeIntersector aFaceIntSect; -// aFaceIntSect.Load(m_Shape, 0.001); -// aFaceIntSect.PerformNearest(aLine,-RealLast(), +RealLast()); -// //Now we get the U and V value on the area so that we can then determine D1 and D2 -// gp_Pnt projectedPoint,OffsetPoint; -// gp_Pnt testpoint,testpoint2; -// float abstand,abstand_old; -// int number = aFaceIntSect.NbPnt(); -// abstand_old = 100; -// for(int k=0;kD1(Umin,Vmin,projectedPoint,Uvec,Vvec); -// normalVec = Uvec; -// normalVec.Cross(Vvec); -// normalVec.Normalize(); -// //Now the surface normal is calculated and normalized -// //Now check if the normal is really pointing to the same side like everyone else. -// //To do this, just check whether the Z-value of the normal is greater than zero (then in the 1st and 2nd quadrant) -// if(normalVec.Z()<0) normalVec.Multiply(-1.0); -// //Jetzt die Normale auf die Radiuslänge verlängern -// normalVec.Multiply(radius); -// //Now set the Z component to 0 -// normalVec.SetZ(0.0); -// //float abstand = currentPoint.Distance(projectedPoint); -// //if(abstand>0.2) -// //{cout<<"error"< finalPointscorrected; -// finalPointscorrected.clear(); -// checkPointDistance(finalPoints,finalPointscorrected); -// Handle(TColgp_HArray1OfPnt) finalOffsetPoints = new TColgp_HArray1OfPnt(1, finalPointscorrected.size()); -// for(int t=0;tSetValue(t+1,finalPointscorrected[t]); -// } -// GeomAPI_Interpolate aNoPeriodInterpolate(finalOffsetPoints, Standard_False, Precision::Confusion()); -// aNoPeriodInterpolate.Perform(); -// Handle_Geom_BSplineCurve aCurve(aNoPeriodInterpolate.Curve()); -// //check results -// if (!aNoPeriodInterpolate.IsDone()) return false; -// m_all_offset_cuts_high.push_back(aCurve); -// } -// -// -// -// -// -// build.saveToFile("c:/output.iv"); -// outfile.close(); -// -// -// -// -// -//return true; -// -//} - -//bool cutting_tools::checkPointDistance(std::vector &finalPoints,std::vector &output) -//{ -// std::vector::iterator aPntIt,atempit; -// output.clear(); -// double square_precision = Precision::Confusion()*Precision::Confusion(); -// int i; -// for(aPntIt=finalPoints.begin();aPntIt!=finalPoints.end();++aPntIt) -// { -// atempit=aPntIt; -// output.push_back(*aPntIt); -// i=1; -// while(((*(aPntIt+i)).SquareDistance(*aPntIt))< square_precision && (aPntIt+i)!=finalPoints.end()) -// { -// i++; -// atempit++; -// } -// aPntIt = atempit; -// -// -// -// } -// -// return true; -//} - -//bool cutting_tools::checkPointIntersection(std::vector &finalPoints) -//{ -// //This is where a check is made to see whether the points are really all in the correct order -// std::vector::iterator aPntIt; -// double distance,distance_old; -// projectPointContainer nearestPointStruct; -// int k; -// for(unsigned int j=0;j=finalPoints.size()) break; -// -// distance = (finalPoints[j+i].point).SquareDistance(finalPoints[j].point); -// if(distanceLength()); - //for (int j=1;j<=TangentFlags->Length();++j) - // TangentFlags->SetValue(j,true); - - GeomAPI_Interpolate aBSplineInterpolation(InterpolationPoints, Standard_False, Precision::Confusion()); - //aBSplineInterpolation.Load(Tangents,TangentFlags); - aBSplineInterpolation.Perform(); - Handle_Geom_BSplineCurve aBSplineCurve(aBSplineInterpolation.Curve()); - //check results - //if (!aBSplineInterpolation.IsDone()) cout << "error" << endl; - - return aBSplineCurve; -} - - -bool cutting_tools::CheckEdgeTangency(const TopoDS_Edge& edge1, const TopoDS_Edge& edge2) -{ - //Get the vertex which is equal to both edges - TopoDS_Vertex CommonVertex; - TopExp::CommonVertex(edge1,edge2,CommonVertex); - if (CommonVertex.IsNull()) - { - cout << "Not possible to calculate Tangency" << endl; - return false; - } - gp_Pnt CommonPoint = BRep_Tool::Pnt(CommonVertex); - BRepAdaptor_Curve aCurve1(edge1); - BRepAdaptor_Curve aCurve2(edge2); - gp_Vec Tangent1,Tangent2; - gp_Pnt P; - if (aCurve1.Value(aCurve1.FirstParameter()).IsEqual(CommonPoint,0.1)) - aCurve1.D1(aCurve1.FirstParameter(),P,Tangent1); - else if (aCurve1.Value(aCurve1.LastParameter()).IsEqual(CommonPoint,0.1)) - aCurve1.D1(aCurve1.LastParameter(),P,Tangent1); - if (aCurve2.Value(aCurve2.FirstParameter()).IsEqual(CommonPoint,0.1)) - aCurve2.D1(aCurve1.FirstParameter(),P,Tangent2); - else if (aCurve2.Value(aCurve2.LastParameter()).IsEqual(CommonPoint,0.1)) - aCurve2.D1(aCurve1.LastParameter(),P,Tangent2); - - //Now we calculate the angle between the two Tangents and if the angle is below 10° then we say its continuous - double angle = Tangent1.Angle(Tangent2); - //Angle must be between +/-5° - if (angle<(5.0/180.0*D_PI) || angle>(175.0/180.0*D_PI)) - return true; - else - return false; -} - -bool cutting_tools::CheckforLastPoint(const gp_Pnt& lastPoint, int &start_index,int &start_array,const std::vector > >& MasterPointsStorage) -{ - float dist,distold = FLT_MAX; - for (unsigned int t=0;t >& SlavePointsStorage) -{ - float dist,distold = FLT_MAX; - for (unsigned int t=0;t > >& MasterPointsStorage, - const std::vector >& SlavePointsStorage - ) -{ - float dist,distold = FLT_MAX; - for (unsigned int t=0;t >::iterator current_flat_level; - gp_Pnt lastPoint(0.0,0.0,0.0); //Initialize the first Point to the Origin - current_flat_level = m_ordered_cuts.begin(); - bool slave_is_wire= false; //Necessary if the slave is a wire while the master is not... - //Not at the very beginning, because we don't want to drive that with the master - for (m_ordered_cuts_it = m_ordered_cuts.begin()+1;m_ordered_cuts_it!=m_ordered_cuts.end();++m_ordered_cuts_it) - { - std::vector > MasterPointContainer; - std::vector > > MasterPointsStorage; - std::vector SlavePointContainer; - std::vector > SlavePointsStorage; - std::vector >::iterator anIterator1; - std::vector > >::iterator anIterator2; - MasterPointsStorage.clear(); - SlavePointsStorage.clear(); - MasterPointContainer.clear(); - SlavePointContainer.clear(); - //Now we have to select which strategy to choose - //if the current levels is bigger,the same, or less then the previous one - if (m_ordered_cuts_it->first<(m_ordered_cuts_it-1)->first) - { - //Master is calculated as Usual, Slave follows the Master - //Check if current Level has got a Wire - if (m_ordered_cuts_it->second.ShapeType() == TopAbs_WIRE) - { - WireExplorer aWireExplorer(TopoDS::Wire(m_ordered_cuts_it->second)); - for (aWireExplorer.Init();aWireExplorer.More();aWireExplorer.Next()) - { - BRepAdaptor_Curve curveAdaptor(aWireExplorer.Current()); - GCPnts_QuasiUniformAbscissa aProp(curveAdaptor,100); - for (int i=1;i<=aProp.NbPoints();++i) - { - std::pair aTempPair; - //Check the direction - if (aWireExplorer.Current().Orientation() != TopAbs_REVERSED) - curveAdaptor.D0(aProp.Parameter(i),aTempPair.first); - else curveAdaptor.D0(aProp.Parameter(aProp.NbPoints()-i+1),aTempPair.first); - //aTempPair.first.SetZ(aTempPair.first.Z() + m_UserSettings.master_radius); - aTempPair.first.SetZ(aTempPair.first.Z() ); - aTempPair.second = 0.0; //Initialize of Angle - //check if the new point is too close to the old one. If so, then no push_back - if (MasterPointContainer.size()>0 && (MasterPointContainer.rbegin()->first.SquareDistance(aTempPair.first)>(Precision::Confusion()*Precision::Confusion()))) - { - MasterPointContainer.push_back(aTempPair); - anoutput1 << aTempPair.first.X() <<","<< aTempPair.first.Y() <<","<< aTempPair.first.Z()<size();i++) - { - //We skip the Endpoint as it may be the same point as the start point - if (i+1 == MasterPointsStorage.begin()->size()) - { - i=-1; - first = false; - continue; - } - MasterPointContainer.push_back(MasterPointsStorage[0][i]); - SlavePointContainer.push_back(SlavePointsStorage[0][i]); - if (!first && i == start_index) - break; - } - //Now lets interpolate the Point Cloud - Handle(TColgp_HArray1OfPnt) InterpolationPointsMaster = new TColgp_HArray1OfPnt(1, MasterPointContainer.size()); - Handle(TColgp_HArray1OfPnt) InterpolationPointsSlave = new TColgp_HArray1OfPnt(1, SlavePointContainer.size()); - for (unsigned int t=0;tSetValue(t+1,MasterPointContainer[t].first); - InterpolationPointsSlave->SetValue(t+1,SlavePointContainer[t]); - } - m_all_offset_cuts_high.push_back(InterpolateOrderedPoints(InterpolationPointsMaster,true)); - m_all_offset_cuts_low.push_back(InterpolateOrderedPoints(InterpolationPointsSlave,true)); - //Store the last point - lastPoint = MasterPointContainer.rbegin()->first; - } - else - { - anIterator1 = SlavePointsStorage.begin(); - anIterator2 = MasterPointsStorage.begin(); - MasterPointContainer.clear(); - SlavePointContainer.clear(); - for (int i=0;i<=start_index;i++) - { - MasterPointContainer.push_back(MasterPointsStorage[start_array][i]); - SlavePointContainer.push_back(SlavePointsStorage[start_array][i]); - } - MasterPointsStorage.insert((anIterator2+start_array+1),MasterPointContainer); - SlavePointsStorage.insert((anIterator1+start_array+1),SlavePointContainer); - MasterPointContainer.clear(); - SlavePointContainer.clear(); - //Reinitialize the Iterators - anIterator1 = SlavePointsStorage.begin(); - anIterator2 = MasterPointsStorage.begin(); - for (unsigned int i=start_index;iSetValue(t+1,MasterPointsStorage[j][t].first); - InterpolationPointsSlave->SetValue(t+1,SlavePointsStorage[j][t]); - } - m_all_offset_cuts_high.push_back(InterpolateOrderedPoints(InterpolationPointsMaster,true)); - m_all_offset_cuts_low.push_back(InterpolateOrderedPoints(InterpolationPointsSlave,true)); - if (j+1==MasterPointsStorage.size()) - { - j=-1; - continue; - } - if (j+1==start_array+1) - break; - - } - lastPoint = MasterPointsStorage[start_array].rbegin()->first; - } - } - else //If the current Curve is no Wire (Mode <) - { - Edgesort aCutShapeSorter(m_ordered_cuts_it->second); - for (aCutShapeSorter.Init();aCutShapeSorter.More();aCutShapeSorter.Next()) - { - //Get the PCurve and the GeomSurface - Handle_Geom2d_Curve a2DCurve; - Handle_Geom_Surface aSurface; - TopLoc_Location aLoc; - TopoDS_Edge anEdge; - double first2,last2; - bool reversed = false; - BRep_Tool::CurveOnSurface(aCutShapeSorter.Current(),a2DCurve,aSurface,aLoc,first2,last2); - //Now rotate the resulting surface and the curve cleanly - //(maybe the TopoDS_Face was rotated somehow or the TopoDS_Edge) - if (aCutShapeSorter.Current().Orientation() == TopAbs_REVERSED) - reversed = true; - - BRepAdaptor_Curve aCurveAdaptor(aCutShapeSorter.Current()); - GCPnts_QuasiUniformAbscissa aPointGenerator(aCurveAdaptor,200); - int PointSize = aPointGenerator.NbPoints(); - //Now get the surface normal to the generated points - for (int i=1;i<=PointSize;++i) - { - std::pair PointContactPair; - gp_Pnt2d a2dParaPoint; - gp_Pnt aSurfacePoint; - TopoDS_Face aFace; - gp_Vec Uvec,Vvec,normalVec; - //If the curve is reversed we also have to reverse the point direction - if (reversed) a2DCurve->D0(aPointGenerator.Parameter(PointSize-i+1),a2dParaPoint); - else a2DCurve->D0(aPointGenerator.Parameter(i),a2dParaPoint); - GeomAdaptor_Surface aGeom_Adaptor(aSurface); - int t = aGeom_Adaptor.GetType(); - aGeom_Adaptor.D1(a2dParaPoint.X(),a2dParaPoint.Y(),aSurfacePoint,Uvec,Vvec); - //Now calculate the normal vector on the surface - normalVec = Uvec; - normalVec.Cross(Vvec); - normalVec.Normalize(); - //Now the normal is calculated and normalized - //Now check whether the normal is really pointing to the clean side; - //just check whether the Z-value of the normal is greater than zero (then in the 1st and 2nd quadrant) - if (normalVec.Z()<0) normalVec.Multiply(-1.0); - - //Briefly calculate the angle to the ground plane - gp_Vec planeVec(normalVec.X(),normalVec.Y(),0.0); - //The angle - PointContactPair.second = normalVec.Angle(planeVec); - gp_Vec NormalVecSlave = normalVec; - gp_Pnt SlavePoint; - //Now set the Z component to 0 - //normalVec.SetZ(0.0); - normalVec.Normalize(); - //Now multiply the normal using the following formula for the master - //double multiply = m_UserSettings.master_radius*(1-sin(PointContactPair.second))/cos(PointContactPair.second); - double multiply = m_UserSettings.master_radius; - normalVec.Multiply(multiply); - //and here for the slave - NormalVecSlave.Normalize(); - multiply = m_UserSettings.sheet_thickness+m_UserSettings.slave_radius; - NormalVecSlave.Multiply(multiply); - //Now reverse the direction - NormalVecSlave.Multiply(-1.0); - //Now calculate the offset point - PointContactPair.first.SetXYZ(aSurfacePoint.XYZ()); - //PointContactPair.first.SetXYZ(aSurfacePoint.XYZ() + normalVec.XYZ()); - SlavePoint.SetXYZ(aSurfacePoint.XYZ() + NormalVecSlave.XYZ()); - //PointContactPair.first.SetZ(PointContactPair.first.Z() + m_UserSettings.master_radius); - //So that we don't get any points that are too close together - //Find the last added point - if (MasterPointContainer.size()>0 && (MasterPointContainer.rbegin()->first.SquareDistance(PointContactPair.first)>0.001)) - { - MasterPointContainer.push_back(PointContactPair); - SlavePointContainer.push_back(SlavePoint); - anoutput1 << PointContactPair.first.X() <<","<< PointContactPair.first.Y() <<","<< PointContactPair.first.Z()<(current_flat_level->first-m_UserSettings.sheet_thickness)) - { - slave_is_wire = true; - TopoDS_Wire aWire = TopoDS::Wire(current_flat_level->second); - BRepAdaptor_CompCurve2 wireAdaptor(aWire); - GCPnts_QuasiUniformAbscissa aProp(wireAdaptor,1000); - SlavePointContainer.clear(); - for (int i=1;i<=aProp.NbPoints();++i) - { - gp_Pnt SlaveOffsetPoint; - wireAdaptor.D0(aProp.Parameter(i),SlaveOffsetPoint); - SlaveOffsetPoint.SetZ(SlaveOffsetPoint.Z() - m_UserSettings.slave_radius - m_UserSettings.sheet_thickness); - //check if the new point is too close to the old one. If so, then no push_back - if (SlavePointContainer.size()>0 && (SlavePointContainer.rbegin()->SquareDistance(SlaveOffsetPoint)>(0.001))) - { - SlavePointContainer.push_back(SlaveOffsetPoint); - anoutput2 << SlaveOffsetPoint.X() <<","<< SlaveOffsetPoint.Y() <<","<< SlaveOffsetPoint.Z()<size();i++) - { - //We skip the Endpoint as it may be the same point as the start point - if (i+1 == MasterPointsStorage.begin()->size()) - { - first = false; - i=-1; - continue; - } - MasterPointContainer.push_back(MasterPointsStorage[0][i]); - SlavePointContainer.push_back(SlavePointsStorage[0][i]); - if (!first && i==start_index_master) - break; - } - } - else //if slave is a wire - { - //Reset the flag - slave_is_wire = false; - //Now check the point-cloud with the shortest distance to "lastPoint" - //As the Master and the slave have different number of points we have to do it two times now - //First we have to divide the first PointCloud as it is for sure that we start - //Somewhere in the middle of it. We will then insert the points at the current start - MasterPointContainer.clear(); - SlavePointContainer.clear(); - bool first = true; - for (unsigned int i=start_index_master;isize();i++) - { - //We skip the Endpoint as it may be the same point as the start point - if (i+1 == MasterPointsStorage.begin()->size()) - { - first = false; - i=-1; - continue; - } - MasterPointContainer.push_back(MasterPointsStorage[0][i]); - if (!first && i== start_index_master) - break; - } - first = true; - for (unsigned int i=start_index_slave;isize();i++) - { - //We skip the Endpoint as it may be the same point as the start point - if (i+1 == SlavePointsStorage.begin()->size()) - { - first = false; - i=-1; - continue; - } - SlavePointContainer.push_back(SlavePointsStorage[0][i]); - if (!first && i== start_index_slave) - break; - } - } - //Now lets interpolate the Point Cloud - Handle(TColgp_HArray1OfPnt) InterpolationPointsMaster = new TColgp_HArray1OfPnt(1, MasterPointContainer.size()); - Handle(TColgp_HArray1OfPnt) InterpolationPointsSlave = new TColgp_HArray1OfPnt(1, SlavePointContainer.size()); - for (unsigned int t=0;tSetValue(t+1,MasterPointContainer[t].first); - } - for (unsigned int t=0;tSetValue(t+1,SlavePointContainer[t]); - } - - /*CheckPoints(InterpolationPointsMaster);*/ - /*CheckPoints(InterpolationPointsSlave);*/ - - m_all_offset_cuts_high.push_back(InterpolateOrderedPoints(InterpolationPointsMaster,true)); - m_all_offset_cuts_low.push_back(InterpolateOrderedPoints(InterpolationPointsSlave,true)); - //Store the last point - lastPoint = MasterPointContainer.rbegin()->first; - //SlaveTool Path finished - }//Current Curve < last curve is finished here - } - if (fabs(m_ordered_cuts_it->first-(m_ordered_cuts_it-1)->first)<=0.01) - { - //we only set the new flat level wire here - //no Toolpath is calculated - current_flat_level = m_ordered_cuts_it; - }//end of current == last - if (m_ordered_cuts_it->first>(m_ordered_cuts_it-1)->first) - { - //The Slave Tool is now the Master Tool and therefore we only have to exchange < case - //Check if current Level has got a Wire - if (m_ordered_cuts_it->second.ShapeType() == TopAbs_WIRE) - { - WireExplorer aWireExplorer(TopoDS::Wire(m_ordered_cuts_it->second)); - for (aWireExplorer.Init();aWireExplorer.More();aWireExplorer.Next()) - { - BRepAdaptor_Curve curveAdaptor(aWireExplorer.Current()); - GCPnts_QuasiUniformAbscissa aProp(curveAdaptor,100); - for (int i=1;i<=aProp.NbPoints();++i) - { - std::pair aTempPair; - //Check the direction - if (aWireExplorer.Current().Orientation() != TopAbs_REVERSED) - curveAdaptor.D0(aProp.Parameter(i),aTempPair.first); - else curveAdaptor.D0(aProp.Parameter(aProp.NbPoints()-i+1),aTempPair.first); - aTempPair.first.SetZ(aTempPair.first.Z() -m_UserSettings.slave_radius -m_UserSettings.sheet_thickness); - aTempPair.second = 0.0; //Initialize of Angle - //check if the new point is too close to the old one. If so, then no push_back - if (MasterPointContainer.size()>0 && (MasterPointContainer.rbegin()->first.SquareDistance(aTempPair.first)>(Precision::Confusion()*Precision::Confusion()))) - { - MasterPointContainer.push_back(aTempPair); - anoutput1 << aTempPair.first.X() <<","<< aTempPair.first.Y() <<","<< aTempPair.first.Z()<size();i++) - { - //We skip the Endpoint as it may be the same point as the start point - if (i+1 == MasterPointsStorage.begin()->size()) - { - i=-1; - first = false; - continue; - } - MasterPointContainer.push_back(MasterPointsStorage[0][i]); - SlavePointContainer.push_back(SlavePointsStorage[0][i]); - if (!first && i == start_index) - break; - } - //Now lets interpolate the Point Cloud - Handle(TColgp_HArray1OfPnt) InterpolationPointsMaster = new TColgp_HArray1OfPnt(1, MasterPointContainer.size()); - Handle(TColgp_HArray1OfPnt) InterpolationPointsSlave = new TColgp_HArray1OfPnt(1, SlavePointContainer.size()); - for (unsigned int t=0;tSetValue(t+1,MasterPointContainer[t].first); - InterpolationPointsSlave->SetValue(t+1,SlavePointContainer[t]); - } - m_all_offset_cuts_low.push_back(InterpolateOrderedPoints(InterpolationPointsMaster,true)); - m_all_offset_cuts_high.push_back(InterpolateOrderedPoints(InterpolationPointsSlave,true)); - //Store the last point - lastPoint = MasterPointContainer.rbegin()->first; - } - else - { - anIterator1 = SlavePointsStorage.begin(); - anIterator2 = MasterPointsStorage.begin(); - MasterPointContainer.clear(); - SlavePointContainer.clear(); - for (int i=0;i<=start_index;i++) - { - MasterPointContainer.push_back(MasterPointsStorage[start_array][i]); - SlavePointContainer.push_back(SlavePointsStorage[start_array][i]); - } - MasterPointsStorage.insert((anIterator2+start_array+1),MasterPointContainer); - SlavePointsStorage.insert((anIterator1+start_array+1),SlavePointContainer); - MasterPointContainer.clear(); - SlavePointContainer.clear(); - //Reinitialize the Iterators - anIterator1 = SlavePointsStorage.begin(); - anIterator2 = MasterPointsStorage.begin(); - for (unsigned int i=start_index;iSetValue(t+1,MasterPointsStorage[j][t].first); - InterpolationPointsSlave->SetValue(t+1,SlavePointsStorage[j][t]); - } - m_all_offset_cuts_low.push_back(InterpolateOrderedPoints(InterpolationPointsMaster,true)); - m_all_offset_cuts_high.push_back(InterpolateOrderedPoints(InterpolationPointsSlave,true)); - if (j+1==MasterPointsStorage.size()) - { - j=-1; - continue; - } - if (j+1==start_array+1) - break; - } - lastPoint = MasterPointsStorage[start_array].rbegin()->first; - } - } - else //If the current Curve is no Wire (Mode >) - { - Edgesort aCutShapeSorter(m_ordered_cuts_it->second); - for (aCutShapeSorter.Init();aCutShapeSorter.More();aCutShapeSorter.Next()) - { - //Get the PCurve and the GeomSurface - Handle_Geom2d_Curve a2DCurve; - Handle_Geom_Surface aSurface; - TopLoc_Location aLoc; - TopoDS_Edge anEdge; - double first2,last2; - bool reversed = false; - BRep_Tool::CurveOnSurface(aCutShapeSorter.Current(),a2DCurve,aSurface,aLoc,first2,last2); - //Now rotate the resulting surface and the curve cleanly - //(maybe the TopoDS_Face was somehow rotated or the TopoDS_Edge) - if (aCutShapeSorter.Current().Orientation() == TopAbs_REVERSED) - reversed = true; - - BRepAdaptor_Curve aCurveAdaptor(aCutShapeSorter.Current()); - GCPnts_QuasiUniformAbscissa aPointGenerator(aCurveAdaptor,200); - int PointSize = aPointGenerator.NbPoints(); - //Now get the surface normal to the generated points - for (int i=1;i<=PointSize;++i) - { - std::pair PointContactPair; - gp_Pnt2d a2dParaPoint; - gp_Pnt aSurfacePoint; - TopoDS_Face aFace; - gp_Vec Uvec,Vvec,normalVec; - //If the curve is reversed we also have to reverse the point direction - if (reversed) a2DCurve->D0(aPointGenerator.Parameter(PointSize-i+1),a2dParaPoint); - else a2DCurve->D0(aPointGenerator.Parameter(i),a2dParaPoint); - GeomAdaptor_Surface aGeom_Adaptor(aSurface); - int t = aGeom_Adaptor.GetType(); - aGeom_Adaptor.D1(a2dParaPoint.X(),a2dParaPoint.Y(),aSurfacePoint,Uvec,Vvec); - //Now calculate the normal vector on the surface - normalVec = Uvec; - normalVec.Cross(Vvec); - normalVec.Normalize(); - //Now the normal is calculated and normalized - //Now check whether the normal is really pointing to the clean side - //To do this, just check whether the Z-value of the normal is greater than zero (then in the 1st and 2nd quadrant) - if (normalVec.Z()<0) normalVec.Multiply(-1.0); - - //Briefly calculate the angle to the ground plane - gp_Vec planeVec(normalVec.X(),normalVec.Y(),0.0); - //The angle - PointContactPair.second = normalVec.Angle(planeVec); - gp_Vec NormalVecSlave = normalVec; - gp_Pnt SlavePoint; - //Now set the Z component to 0 - //normalVec.SetZ(0.0); - normalVec.Normalize(); - //Now multiply the normal using the following formula for the master - //double multiply = (m_UserSettings.slave_radius*(1-sin(PointContactPair.second))/cos(PointContactPair.second))+m_UserSettings.sheet_thickness; - double multiply = m_UserSettings.slave_radius + m_UserSettings.sheet_thickness; - //As the Master is now the Slave we have to multiply it also by -1.0 - normalVec.Multiply(-multiply); - //and here for the slave - NormalVecSlave.Normalize(); - multiply = m_UserSettings.master_radius; - NormalVecSlave.Multiply(multiply); - //Now calculate the offset point - PointContactPair.first.SetXYZ(aSurfacePoint.XYZ() + normalVec.XYZ()); - SlavePoint.SetXYZ(aSurfacePoint.XYZ() + NormalVecSlave.XYZ()); - //PointContactPair.first.SetZ(PointContactPair.first.Z() - m_UserSettings.slave_radius); - //So that we don't get any points that are too close together - //Find the last point added - if (MasterPointContainer.size()>0 && (MasterPointContainer.rbegin()->first.SquareDistance(PointContactPair.first)>(Precision::Confusion()*Precision::Confusion()))) - { - MasterPointContainer.push_back(PointContactPair); - SlavePointContainer.push_back(SlavePoint); - anoutput1 << PointContactPair.first.X() <<","<< PointContactPair.first.Y() <<","<< PointContactPair.first.Z()<first)) - { - slave_is_wire = true; - TopoDS_Wire aWire = TopoDS::Wire(current_flat_level->second); - BRepAdaptor_CompCurve2 wireAdaptor(aWire); - GCPnts_QuasiUniformAbscissa aProp(wireAdaptor,1000); - SlavePointContainer.clear(); - for (int i=1;i<=aProp.NbPoints();++i) - { - gp_Pnt SlaveOffsetPoint; - wireAdaptor.D0(aProp.Parameter(i),SlaveOffsetPoint); - SlaveOffsetPoint.SetZ(SlaveOffsetPoint.Z() + m_UserSettings.master_radius); - //check if the new point is too close to the old one. If so, then no push_back - if (SlavePointContainer.size()>0 && (SlavePointContainer.rbegin()->SquareDistance(SlaveOffsetPoint)>(0.001))) - { - SlavePointContainer.push_back(SlaveOffsetPoint); - anoutput2 << SlaveOffsetPoint.X() <<","<< SlaveOffsetPoint.Y() <<","<< SlaveOffsetPoint.Z()<size();i++) - { - if (i+1 == MasterPointsStorage.begin()->size()) - { - i=-1; - first = false; - continue; - } - MasterPointContainer.push_back(MasterPointsStorage[0][i]); - SlavePointContainer.push_back(SlavePointsStorage[0][i]); - if (!first && i == start_index_master) - break; - } - - } - else //if slave is a wire - { - //Now check the point-cloud with the shortest distance to "lastPoint" - //As the Master and the slave have different number of points we have to do it two times now - //First we have to divide the first PointCloud as it is for sure that we start - //Somewhere in the middle of it. We will then insert the points at the current start - MasterPointContainer.clear(); - SlavePointContainer.clear(); - bool first = true; - for (unsigned int i=start_index_master;isize();i++) - { - //We skip the Endpoint as it may be the same point as the start point - if (i+1 == MasterPointsStorage.begin()->size()) - { - i=-1; - first = false; - continue; - } - MasterPointContainer.push_back(MasterPointsStorage[0][i]); - if (!first && i== start_index_master) - break; - } - for (unsigned int i=start_index_slave;isize();i++) - { - //We skip the Endpoint as it may be the same point as the start point - if (i+1 == SlavePointsStorage.begin()->size()) - { - i=-1; - first = false; - continue; - } - SlavePointContainer.push_back(SlavePointsStorage[0][i]); - if (!first && i == start_index_slave) - break; - } - } - //Now lets interpolate the Point Cloud - Handle(TColgp_HArray1OfPnt) InterpolationPointsMaster = new TColgp_HArray1OfPnt(1, MasterPointContainer.size()); - Handle(TColgp_HArray1OfPnt) InterpolationPointsSlave = new TColgp_HArray1OfPnt(1, SlavePointContainer.size()); - for (unsigned int t=0;tSetValue(t+1,MasterPointContainer[t].first); - } - for (unsigned int t=0;tSetValue(t+1,SlavePointContainer[t]); - } - - /*CheckPoints(InterpolationPointsMaster);*/ - /*CheckPoints(InterpolationPointsSlave);*/ - - m_all_offset_cuts_low.push_back(InterpolateOrderedPoints(InterpolationPointsMaster,true)); - m_all_offset_cuts_high.push_back(InterpolateOrderedPoints(InterpolationPointsSlave,true)); - //Store the last point - lastPoint = MasterPointContainer.rbegin()->first; - }//Current Curve > last curve is finished here - } - } - return true; -} - - -bool cutting_tools::CheckPoints(Handle(TColgp_HArray1OfPnt) PointArray) -{ - Standard_Integer ii ; - Standard_Real tolerance_squared = Precision::Confusion() * Precision::Confusion(), - distance_squared ; - Standard_Boolean result = Standard_True ; - for (ii = PointArray->Lower() ; result && ii < PointArray->Upper() ; ii++) - { - distance_squared = PointArray->Value(ii).SquareDistance(PointArray->Value(ii+1)) ; - if (distance_squared < tolerance_squared) - { - return false; - } - - } - return true; - -} -Base::BoundBox3f cutting_tools::getWireBBox(TopoDS_Wire aWire) -{ - //Fill Bounding Boxes with Wires - //Therefore we have to evaluate some points on our wire and feed the BBox Algorithm - Base::BoundBox3f currentBox; - BRepAdaptor_CompCurve2 wireAdaptor(aWire); - GCPnts_QuasiUniformDeflection aProp(wireAdaptor,0.1); - Base::Vector3f aPoint; - currentBox.Flush(); - for (int j=1;j<=aProp.NbPoints();++j) - { - aPoint.x = float(aProp.Value(j).X()); - aPoint.y = float(aProp.Value(j).Y()); - aPoint.z = float(aProp.Value(j).Z()); - currentBox.Add(aPoint); - } - return currentBox; -} - -TopoDS_Shape cutting_tools::getProperCut(TopoDS_Shape& aShape) -{ - //A cutting Shape is aShape - //check direction to decide which Topology to hold and which to delete - if (m_direction)//From top to bottom - { - - } - TopoDS_Shape aReturnShape; - return aReturnShape; -} - -bool cutting_tools::calculateAccurateSlaveZLevel(std::vector >& OffsetPoints, double current_z_level, double &slave_z_level, double &average_sheet_thickness, double &average_angle, bool &cutpos) -{ - //Calculate the mean value of all normal angles and thus the mean value of the sheet metal thickness - - bool direction,area; - //First of all, check in which area of the part we are - if (current_z_level < m_MachiningOrder[0].first.z && current_z_level > m_MachiningOrder[1].first.z) - { - //We're in the first part from top to bottom - direction = true; - area = true; - } - else if (m_MachiningOrder.size() > 2 && current_z_level < m_MachiningOrder[1].first.z) - { - //We're in the second part from top to bottom - direction = true; - area = false; - } - else if (m_MachiningOrder.size() > 2 && current_z_level < m_MachiningOrder[2].first.z && current_z_level > m_MachiningOrder[1].first.z) - { - //We are from the bottom up in the 2nd part - direction = false; - area = false; - - } - else - { - cout << "Couldn't find an assignment" << endl; - } - - average_angle = 0.0; - double slave_z_leveltop,slave_z_levelbottom; - - for (unsigned int i=0;i (m_MachiningOrder[0].first.z-m_UserSettings.sheet_thickness)) - { - if ((slave_z_levelbottom + m_UserSettings.slave_radius) < (m_MachiningOrder[0].first.z - m_UserSettings.sheet_thickness)) - { - slave_z_level = slave_z_levelbottom; - cutpos = false; - return true; - } - else - { - slave_z_level = m_MachiningOrder[0].first.z; - return true; - } - } - //The top level is checked off here - if (direction && !area && slave_z_leveltop < (m_MachiningOrder[1].first.z - m_UserSettings.sheet_thickness)) - { - slave_z_level = slave_z_leveltop; - cutpos = true; - return true; - } - else if (direction && !area && slave_z_leveltop > (m_MachiningOrder[1].first.z-m_UserSettings.sheet_thickness)) - { - if ((slave_z_levelbottom + m_UserSettings.slave_radius) < (m_MachiningOrder[1].first.z - m_UserSettings.sheet_thickness)) - { - slave_z_level = slave_z_levelbottom; - cutpos = false; - return true; - } - else - { - slave_z_level = m_MachiningOrder[1].first.z; - return true; - } - } - //Now the story where we go up again - if (!direction && !area && slave_z_leveltop < (m_MachiningOrder[1].first.z - m_UserSettings.sheet_thickness)) - { - slave_z_level = slave_z_leveltop; - cutpos = true; - return true; - } - else if (direction && !area && slave_z_leveltop > (m_MachiningOrder[2].first.z-m_UserSettings.sheet_thickness)) - { - if ((slave_z_levelbottom + m_UserSettings.slave_radius) < (m_MachiningOrder[2].first.z - m_UserSettings.sheet_thickness)) - { - slave_z_level = slave_z_levelbottom; - cutpos = false; - return true; - } - else - { - slave_z_level = m_MachiningOrder[2].first.z; - return true; - } - } - - return true; -} - -//bool cutting_tools::OffsetWires() //This is the old version -//{ -// for(m_it = m_all_cuts.begin();m_itD1(Umin,Vmin,projectedPoint,Uvec,Vvec); -// normalVec = Uvec; -// normalVec.Cross(Vvec); -// normalVec.Normalize(); //Now the normal is calculated and normalized -// //zeroPoint.SetCoord(0.0,0.0,0.0); // -// projPointVec.SetXYZ(projectedPoint.XYZ()); -// OffsetPoint.SetXYZ((projPointVec + (normalVec*(-21))).XYZ()); -// finalOffsetPoints->SetValue(i,OffsetPoint); //Set the current offset point -// } -// Standard_Boolean isPeriodic = Standard_False; -// GeomAPI_Interpolate aNoPeriodInterpolate(finalOffsetPoints, isPeriodic, Precision::Confusion()); -// aNoPeriodInterpolate.Perform(); -// Handle_Geom_BSplineCurve aCurve(aNoPeriodInterpolate.Curve()); -// -// // check results -// if (!aNoPeriodInterpolate.IsDone()) return false; -// m_all_offset_cuts_high.push_back(aCurve); -// } -//} - -gp_Dir cutting_tools::getPerpendicularVec(gp_Vec& anInput) -{ - double x,y; - gp_Dir Output; - x = anInput.X(); - y = anInput.Y(); - if (x != 0.0 && y != 0.0) - { - Output.SetCoord(1.0,(-x/y),0.0); - } - else if (x == 0 && y == 0) - { - Output.SetCoord(1.0,1.0,0.0); - } - else if (x == 0 && y != 0) - { - Output.SetCoord(1.0,0.0,0.0); - } - else if (x != 0 && y == 0) - { - Output.SetCoord(0.0,1.0,0.0); - } - return Output; -} - - - -bool cutting_tools::OffsetWires_Spiral() -{ - std::ofstream anoutput1; - anoutput1.open("c:/spiral.txt"); - Base::Builder3D log; - std::vector >::iterator current_flat_level; - current_flat_level = m_ordered_cuts.begin(); - SpiralHelper lastPoint; - lastPoint.SurfacePoint.SetCoord(0.0,0.0,0.0); - boJetzt noch die Geschichte wo wir wieder nach oben fahrenol slave_done= false; //Necessary if the slave is already output - bool just_started = true; // - gp_Vec direction_vector(0.0,0.0,1.0),last_direction_vector(0.0,0.0,1.0);//Just to initialize them - bool direction = true; //for the Robot, this tells the algo that we have to switch the direction - //Not at the very beginning, as we don't want to drive it with the master - for (m_ordered_cuts_it = m_ordered_cuts.begin()+1;m_ordered_cuts_it!=m_ordered_cuts.end();++m_ordered_cuts_it) - { - std::vector OffsetSpiralPoints,TempSpiralPoints; - std::vector SlavePointContainer; - OffsetSpiralPoints.clear(); - TempSpiralPoints.clear(); - - //Now we have to select which strategy to choose - //if the current levels is bigger,the same, or less then the previous one - if (m_ordered_cuts_it->first<(m_ordered_cuts_it-1)->first) - { - //Master is calculated as Usual, Slave stays at the currently highest level - //Check if Last Level has got a Wire as we go from the last to the current with our Spiral - SpiralHelper aSpiralStruct; - double CurveLength = 0.0; - if ((m_ordered_cuts_it-1)->second.ShapeType() == TopAbs_WIRE) - { - WireExplorer aWireExplorer(TopoDS::Wire((m_ordered_cuts_it-1)->second)); - for (aWireExplorer.Init();aWireExplorer.More();aWireExplorer.Next()) - { - CurveLength = CurveLength + GetEdgeLength(aWireExplorer.Current()); - BRepAdaptor_Curve curveAdaptor(aWireExplorer.Current()); - //Adjust the point amount based on the curve length make every 0.3mm a point - //GCPnts_QuasiUniformAbscissa aProp(curveAdaptor,int(GetEdgeLength(aWireExplorer.Current())/0.4)); - GCPnts_QuasiUniformAbscissa aProp(curveAdaptor,1000); - for (int i=1;i<=aProp.NbPoints();++i) - { - //Check the direction - if (aWireExplorer.Current().Orientation() != TopAbs_REVERSED) - curveAdaptor.D1(aProp.Parameter(i),aSpiralStruct.SurfacePoint,aSpiralStruct.LineD1); - else curveAdaptor.D1(aProp.Parameter(aProp.NbPoints()-i+1),aSpiralStruct.SurfacePoint,aSpiralStruct.LineD1); - - aSpiralStruct.SurfaceNormal.SetCoord(0.0,0.0,1.0); - TempSpiralPoints.push_back(aSpiralStruct); - } - } - } - else - { - CurveLength = 0.0; - Edgesort aCutShapeSorter((m_ordered_cuts_it-1)->second); - for (aCutShapeSorter.Init();aCutShapeSorter.More();aCutShapeSorter.Next()) - { - CurveLength = CurveLength + GetEdgeLength(aCutShapeSorter.Current()); - //Get the PCurve and the GeomSurface - Handle_Geom2d_Curve a2DCurve; - Handle_Geom_Surface aSurface; - TopLoc_Location aLoc; - double first2,last2; - bool reversed = false; - BRep_Tool::CurveOnSurface(aCutShapeSorter.Current(),a2DCurve,aSurface,aLoc,first2,last2); - //Now rotate the resulting surface and the curve cleanly - //(maybe the TopoDS_Face was somehow rotated or the TopoDS_Edge) - if (aCutShapeSorter.Current().Orientation() == TopAbs_REVERSED) - reversed = true; - - BRepAdaptor_Curve aCurveAdaptor(aCutShapeSorter.Current()); - GCPnts_QuasiUniformAbscissa aPointGenerator(aCurveAdaptor,1000); - int PointSize = aPointGenerator.NbPoints(); - //Now get the surface normal to the generated points - for (int i=1;i<=PointSize;++i) - { - gp_Pnt2d a2dParaPoint; - gp_Pnt aSurfacePoint; - TopoDS_Face aFace; - gp_Vec Uvec,Vvec,normalVec; - //If the curve is reversed we also have to reverse the point direction - if (reversed) - { - a2DCurve->D0(aPointGenerator.Parameter(PointSize-i+1),a2dParaPoint); - aCurveAdaptor.D1(aPointGenerator.Parameter(PointSize-i+1),aSurfacePoint,aSpiralStruct.LineD1); - } - else - { - a2DCurve->D0(aPointGenerator.Parameter(i),a2dParaPoint); - aCurveAdaptor.D1(aPointGenerator.Parameter(i),aSurfacePoint,aSpiralStruct.LineD1); - } - GeomAdaptor_Surface aGeom_Adaptor(aSurface); - aGeom_Adaptor.D1(a2dParaPoint.X(),a2dParaPoint.Y(),aSurfacePoint,Uvec,Vvec); - //Now calculate the normal vector on the surface - normalVec = Uvec; - normalVec.Cross(Vvec); - normalVec.Normalize(); - //Now the normal is calculated and normalized - //Now check whether the normal is really pointing to the clean side - //To do this, just check whether the Z-value of the normal is greater than zero (then in the 1st and 2nd quadrant) - if (normalVec.Z()<0) - normalVec.Multiply(-1.0); - - //Briefly calculate the angle to the ground plane - gp_Vec planeVec(normalVec.X(),normalVec.Y(),0.0); - //Save the angle - float angle = float(normalVec.Angle(planeVec)); - aSpiralStruct.SurfaceNormal = normalVec; - aSpiralStruct.SurfacePoint = aSurfacePoint; - TempSpiralPoints.push_back(aSpiralStruct); - } - } - } - - //Now we have to find the shortest distance to the lastPoint of the previous spiral. - //At the beginning the lastPoint is the Origin - //This represents our startPoint. If we just started, then we skip this point - - unsigned int start_index = 0,adapted_start_index=0; - float dist,distold = FLT_MAX; - for (unsigned int t=0;tsecond); - BRepAdaptor_CompCurve2 wireAdaptor(aWire); - GCPnts_QuasiUniformAbscissa aProp(wireAdaptor,1000); - SlavePointContainer.clear(); - gp_Pnt SlaveOffsetPoint; - for (int i=1;i<=aProp.NbPoints();++i) - { - wireAdaptor.D0(aProp.Parameter(i),SlaveOffsetPoint); - SlaveOffsetPoint.SetZ(SlaveOffsetPoint.Z() - m_UserSettings.sheet_thickness - m_UserSettings.slave_radius); - //check if the new point is too close to the old one. If so, then no push_back - if (SlavePointContainer.size()>0 && (SlavePointContainer.rbegin()->SquareDistance(SlaveOffsetPoint)>(Precision::Confusion()*Precision::Confusion()))) - SlavePointContainer.push_back(SlaveOffsetPoint); - else if (SlavePointContainer.empty()) - SlavePointContainer.push_back(SlaveOffsetPoint); - } - //Now Interpolate the Slave with reordered points based on the last point - int index = 0; - distold = FLT_MAX; - for (unsigned int t=0;tSetValue(t+1,SlavePointContainer[t]); - if (t==index) - break; - if (t+1==SlavePointContainer.size()) - t=-1; - } - - m_all_offset_cuts_low.push_back(InterpolateOrderedPoints(InterpolationPoints,true)); - slave_done = true; - } //Slave done - - gp_Pnt PreviousPoint = TempSpiralPoints[start_index].SurfacePoint; - //check the current direction we would go - gp_Vec help_Vec(TempSpiralPoints[start_index].SurfacePoint.Coord()); - if (!start_index+1>=TempSpiralPoints.size()) - direction_vector = TempSpiralPoints[start_index+1].SurfacePoint.Coord(); - else - direction_vector = TempSpiralPoints[1].SurfacePoint.Coord();//As Start and End-Point are the same - direction_vector.Subtract(help_Vec); - //direction_vector.SetZ(0.0); - direction_vector.Normalize(); - direction_vector.Multiply(1.0); //Zum testen bauen wir keinen Offset ein - //switch the Spiral-direction if the clockwise flag is checked and the - //angle between the last and current round is more then 90° - double angle = direction_vector.Angle(last_direction_vector); - if (m_UserSettings.clockwise && angle<(D_PI*0.5)) - direction = true; //We are already in the wright direction - else if (m_UserSettings.clockwise && angle >(D_PI*0.5)) - direction = false; //we have to switch the direction - else if (!m_UserSettings.clockwise && angle<(D_PI*0.5)) - direction = false; - else if (!m_UserSettings.clockwise && angle>(D_PI*0.5)) - direction = true; - - - IntCurvesFace_ShapeIntersector anIntersector; - anIntersector.Load(m_Shape,0.01); - - //Insert the first point into the TempSpiralPoints if we have just started - std::vector TempSpiralPointsFinal; - TempSpiralPointsFinal.clear(); - if (!just_started) - TempSpiralPointsFinal.push_back(lastPoint); - else - just_started = false;//The first point is now done - - if (direction && ((start_index+1)=TempSpiralPoints.size())) - adapted_start_index = 1;//Not 0 because the last one is already added - else - { - if (start_index==0) - adapted_start_index = TempSpiralPoints.size()-2; //Skip the last Point as its equal to the first one - else - adapted_start_index = start_index-1; - } - std::cout<<"Angle ="<< angle<< " Direction = "<< direction << "Start_Index: "<< adapted_start_index <<","<0) - { - float shortestDistance, shortestDistanceOld = FLT_MAX; - for (int g=1;g<=points;g++) - { - const gp_Pnt& TestPoint = anIntersector.Pnt(g); - shortestDistance = float(TestPoint.SquareDistance(TempSpiralPoints[j].SurfacePoint)); - if (shortestDistance156)//The point is more then 14mm away (square distance) - continue; - TempSpiralPoints[j].SurfacePoint = anIntersector.Pnt(current_index); - } - else //We have to try a mesh intersection as the Nurb Intersection does not seem to work - { - cout << "Big Problem"; - continue; - } - //Now get the Proper Normal at this point - BRepAdaptor_Surface aFaceAdaptor(anIntersector.Face(current_index)); - gp_Pnt P; - gp_Vec U_Vec,V_Vec; - aFaceAdaptor.D1(anIntersector.UParameter(current_index),anIntersector.VParameter(current_index),P,U_Vec,V_Vec); - U_Vec.Cross(V_Vec); - U_Vec.Normalize(); - if (U_Vec.Z() < 0) U_Vec.Multiply(-1.0); - - TempSpiralPoints[j].SurfaceNormal = U_Vec; - TempSpiralPointsFinal.push_back(TempSpiralPoints[j]); - //If we reached the end before we processed all points, then we start at the beginning. - if (direction) - { - if (j==start_index) - break; //Now we have completed all Points - else if (j+1==TempSpiralPoints.size()) - { - j=-1; //-1 because at the for we ++ the variable directly - continue; - } - - } - else - { - if (j==start_index) - break; //Now we have completed all Points - else if (j-1<0) - { - j=TempSpiralPoints.size()-3; - continue; - } - //We switch to the end and skip the last point - //as it's the same as the point at j=0; - j=j-2;//As the for puts +1 for each step - } - } - //Offset for Master and Slave - OffsetSpiralPoints = OffsetSpiral(TempSpiralPointsFinal); - //Now store the lastPoint of the currentSpiral as we need it for the next one - lastPoint = *(TempSpiralPointsFinal.rbegin()); - gp_Vec temp_vector((OffsetSpiralPoints.rbegin()+5)->SurfacePoint.Coord()); - last_direction_vector = OffsetSpiralPoints.rbegin()->SurfacePoint.Coord(); - last_direction_vector.Subtract(temp_vector); - //last_direction_vector.SetZ(0.0); - last_direction_vector.Normalize(); - last_direction_vector.Multiply(10.0); - Handle(TColgp_HArray1OfPnt) InterpolationPoints = new TColgp_HArray1OfPnt(1,OffsetSpiralPoints.size()); - TColgp_Array1OfVec Tangents(1,OffsetSpiralPoints.size()); - for (unsigned int t=0;tSetValue(t+1,OffsetSpiralPoints[t].SurfacePoint); - } - bool check = CheckPoints(InterpolationPoints); - //Here we interpolate. If direction == true this means that the rotation is like the initial rotation - m_all_offset_cuts_high.push_back(InterpolateOrderedPoints(InterpolationPoints,true)); - } - if (m_ordered_cuts_it->first==(m_ordered_cuts_it-1)->first) - { - //we only set the new flat level wire here - //no Toolpath is calculated - current_flat_level = m_ordered_cuts_it; - slave_done = false; //This is to generate the next flat level for the slave - just_started = true; //We start a new section - }//end of current == last - //Now lets take the case when we move up again - if (m_ordered_cuts_it->first>(m_ordered_cuts_it-1)->first) - { - //Slave is calculated as Usual, Master stays at the currently highest level - //Check if Last Level has got a Wire as we go from the last to the current with our Spiral - SpiralHelper aSpiralStruct; - double CurveLength = 0.0; - if ((m_ordered_cuts_it-1)->second.ShapeType() == TopAbs_WIRE) - { - WireExplorer aWireExplorer(TopoDS::Wire((m_ordered_cuts_it-1)->second)); - for (aWireExplorer.Init();aWireExplorer.More();aWireExplorer.Next()) - { - CurveLength = CurveLength + GetEdgeLength(aWireExplorer.Current()); - BRepAdaptor_Curve curveAdaptor(aWireExplorer.Current()); - //Adjust the point amount based on the curve length make every 0.3mm a point - //GCPnts_QuasiUniformAbscissa aProp(curveAdaptor,int(GetEdgeLength(aWireExplorer.Current())/0.4)); - GCPnts_QuasiUniformAbscissa aProp(curveAdaptor,1000); - for (int i=1;i<=aProp.NbPoints();++i) - { - //Check the direction - if (aWireExplorer.Current().Orientation() != TopAbs_REVERSED) - curveAdaptor.D1(aProp.Parameter(i),aSpiralStruct.SurfacePoint,aSpiralStruct.LineD1); - else curveAdaptor.D1(aProp.Parameter(aProp.NbPoints()-i+1),aSpiralStruct.SurfacePoint,aSpiralStruct.LineD1); - - aSpiralStruct.SurfaceNormal.SetCoord(0.0,0.0,1.0); - TempSpiralPoints.push_back(aSpiralStruct); - } - } - } - else - { - CurveLength = 0.0; - Edgesort aCutShapeSorter((m_ordered_cuts_it-1)->second); - for (aCutShapeSorter.Init();aCutShapeSorter.More();aCutShapeSorter.Next()) - { - CurveLength = CurveLength + GetEdgeLength(aCutShapeSorter.Current()); - //Get the PCurve and the GeomSurface - Handle_Geom2d_Curve a2DCurve; - Handle_Geom_Surface aSurface; - TopLoc_Location aLoc; - double first2,last2; - bool reversed = false; - BRep_Tool::CurveOnSurface(aCutShapeSorter.Current(),a2DCurve,aSurface,aLoc,first2,last2); - //Now rotate the resulting surface and the curve cleanly - //(maybe the TopoDS_Face was somehow rotated or the TopoDS_Edge) - if (aCutShapeSorter.Current().Orientation() == TopAbs_REVERSED) - reversed = true; - - BRepAdaptor_Curve aCurveAdaptor(aCutShapeSorter.Current()); - GCPnts_QuasiUniformAbscissa aPointGenerator(aCurveAdaptor,1000); - int PointSize = aPointGenerator.NbPoints(); - //Now get the surface normal to the generated points - for (int i=1;i<=PointSize;++i) - { - gp_Pnt2d a2dParaPoint; - gp_Pnt aSurfacePoint; - TopoDS_Face aFace; - gp_Vec Uvec,Vvec,normalVec; - //If the curve is reversed we also have to reverse the point direction - if (reversed) - { - a2DCurve->D0(aPointGenerator.Parameter(PointSize-i+1),a2dParaPoint); - aCurveAdaptor.D1(aPointGenerator.Parameter(PointSize-i+1),aSurfacePoint,aSpiralStruct.LineD1); - } - else - { - a2DCurve->D0(aPointGenerator.Parameter(i),a2dParaPoint); - aCurveAdaptor.D1(aPointGenerator.Parameter(i),aSurfacePoint,aSpiralStruct.LineD1); - } - GeomAdaptor_Surface aGeom_Adaptor(aSurface); - aGeom_Adaptor.D1(a2dParaPoint.X(),a2dParaPoint.Y(),aSurfacePoint,Uvec,Vvec); - //Now calculate the normal vector on the surface - normalVec = Uvec; - normalVec.Cross(Vvec); - normalVec.Normalize(); - //Now the normal is calculated and normalized - //Now check whether the normal is really pointing to the clean side - //To do this, just check whether the Z-value of the normal is greater than zero (then in the 1st and 2nd quadrant) - if (normalVec.Z()<0) - normalVec.Multiply(-1.0); - - //Briefly calculate the angle to the ground plane - gp_Vec planeVec(normalVec.X(),normalVec.Y(),0.0); - //Save the angle - float angle = float(normalVec.Angle(planeVec)); - aSpiralStruct.SurfaceNormal = normalVec; - aSpiralStruct.SurfacePoint = aSurfacePoint; - TempSpiralPoints.push_back(aSpiralStruct); - } - } - } - - //Now we have to find the shortest distance to the lastPoint of the previous spiral. - //At the beginning the lastPoint is the Origin - //This represents our startPoint. If we just started, then we skip this point - - int start_index = 0,adapted_start_index=0; - float dist,distold = FLT_MAX; - for (unsigned int t=0;tsecond); - BRepAdaptor_CompCurve2 wireAdaptor(aWire); - GCPnts_QuasiUniformAbscissa aProp(wireAdaptor,1000); - SlavePointContainer.clear(); - gp_Pnt SlaveOffsetPoint; - for (int i=1;i<=aProp.NbPoints();++i) - { - wireAdaptor.D0(aProp.Parameter(i),SlaveOffsetPoint); - SlaveOffsetPoint.SetZ(SlaveOffsetPoint.Z() + m_UserSettings.master_radius); - //check if the new point is too close to the old one. If so, then no push_back - if (SlavePointContainer.size()>0 && (SlavePointContainer.rbegin()->SquareDistance(SlaveOffsetPoint)>(Precision::Confusion()*Precision::Confusion()))) - SlavePointContainer.push_back(SlaveOffsetPoint); - else if (SlavePointContainer.empty()) - SlavePointContainer.push_back(SlaveOffsetPoint); - } - - //Now Interpolate the Slave with reordered points based on the last point - Handle(TColgp_HArray1OfPnt) InterpolationPoints = new TColgp_HArray1OfPnt(1, SlavePointContainer.size()); - adapted_start_index = start_index+1; - for (int t=adapted_start_index;tSetValue(t+1,SlavePointContainer[t]); - if (t==start_index) - break; - if (t+1==SlavePointContainer.size()) - t=-1; - } - - m_all_offset_cuts_high.push_back(InterpolateOrderedPoints(InterpolationPoints,true)); - slave_done = true; - } //Slave done - - gp_Pnt PreviousPoint = TempSpiralPoints[start_index].SurfacePoint; - //check the current direction we would go - gp_Vec help_Vec(TempSpiralPoints[start_index].SurfacePoint.Coord()); - direction_vector = TempSpiralPoints[start_index+1].SurfacePoint.Coord(); - direction_vector.Subtract(help_Vec); - //direction_vector.SetZ(0.0); - direction_vector.Normalize(); - direction_vector.Multiply(10.0); - //switch the Spiral-direction if the clockwise flag is checked and the - //angle between the last and current round is more then 90° - double angle = direction_vector.Angle(last_direction_vector); - - if (m_UserSettings.clockwise && angle<(D_PI*0.5)) - direction = true; //We are already in the wright direction - else if (m_UserSettings.clockwise && angle >(D_PI*0.5)) - direction = false; //we have to switch the direction - else if (!m_UserSettings.clockwise && angle<(D_PI*0.5)) - direction = false; - else if (!m_UserSettings.clockwise && angle>(D_PI*0.5)) - direction = true; - - - IntCurvesFace_ShapeIntersector anIntersector; - anIntersector.Load(m_Shape,0.01); - - //Insert the first point into the TempSpiralPoints if we have just started - std::vector TempSpiralPointsFinal; - TempSpiralPointsFinal.clear(); - gp_Pnt origin(0.0,0.0,0.0); - if (!just_started) - TempSpiralPointsFinal.push_back(lastPoint); - else - just_started=false; - - if (direction) - adapted_start_index = start_index+1; - else - { - if (start_index==0) - adapted_start_index = TempSpiralPoints.size()-2; //Skip the last Point as its equal to the first one - else - adapted_start_index = start_index-1; - } - std::cout<<"Angle ="<< angle<< " Direction = "<< direction << "Start_Index: "<< adapted_start_index <<","<0) - { - float shortestDistance, shortestDistanceOld = FLT_MAX; - for (int g=1;g<=points;g++) - { - const gp_Pnt& TestPoint = anIntersector.Pnt(g); - shortestDistance = float(TestPoint.SquareDistance(TempSpiralPoints[j].SurfacePoint)); - if (shortestDistance50 ) - continue; - TempSpiralPoints[j].SurfacePoint = anIntersector.Pnt(current_index); - } - else //We have to try a mesh intersection as the Nurb Intersection does not seem to work - { - cout << "Big Problem"; - continue; - } - //Now get the Proper Normal at this point - BRepAdaptor_Surface aFaceAdaptor(anIntersector.Face(current_index)); - gp_Pnt P; - gp_Vec U_Vec,V_Vec; - aFaceAdaptor.D1(anIntersector.UParameter(current_index),anIntersector.VParameter(current_index),P,U_Vec,V_Vec); - U_Vec.Cross(V_Vec); - U_Vec.Normalize(); - if (U_Vec.Z() < 0) U_Vec.Multiply(-1.0); - - TempSpiralPoints[j].SurfaceNormal = U_Vec; - TempSpiralPointsFinal.push_back(TempSpiralPoints[j]); - //If we reached the end before we processed all points, then we start at the beginning. - if (direction) - { - if (j==start_index) - break; //Now we have completed all Points - else if (j+1==TempSpiralPoints.size()) - { - j=-1; //-1 because at the for we ++ the variable directly - continue; - } - - } - else - { - if (j==start_index) - break; //Now we have completed all Points - else if (j-1<0) - { - j=TempSpiralPoints.size()-3; - continue; - } - //We switch to the end and skip the last point - //as it's the same as the point at j=0; - j=j-2;//As the for puts +1 for each step - } - } - //Offset for the slave - OffsetSpiralPoints = OffsetSpiral(TempSpiralPointsFinal,false); - //Now store the lastPoint of the currentSpiral as we need it for the next one - lastPoint = *(TempSpiralPointsFinal.rbegin()); - gp_Vec temp_vector((OffsetSpiralPoints.rbegin()+5)->SurfacePoint.Coord()); - last_direction_vector = OffsetSpiralPoints.rbegin()->SurfacePoint.Coord(); - last_direction_vector.Subtract(temp_vector); - //last_direction_vector.SetZ(0.0); - last_direction_vector.Normalize(); - last_direction_vector.Multiply(10.0); - Handle(TColgp_HArray1OfPnt) InterpolationPoints = new TColgp_HArray1OfPnt(1,OffsetSpiralPoints.size()); - TColgp_Array1OfVec Tangents(1,OffsetSpiralPoints.size()); - for (unsigned int t=0;tSetValue(t+1,OffsetSpiralPoints[t].SurfacePoint); - } - bool check = CheckPoints(InterpolationPoints); - //Here we interpolate. If direction == true this means that the rotation is like the initial rotation - m_all_offset_cuts_low.push_back(InterpolateOrderedPoints(InterpolationPoints,true)); - } - } - anoutput1.close(); - log.saveToFile("C:/normals.iv"); - return true; -} - - -std::vector cutting_tools::OffsetSpiral(const std::vector& SpiralPoints,bool master_or_slave) -{ - std::vector OffsetPoints; - SpiralHelper OffsetPoint; - OffsetPoints.clear(); - //Offset the Points now - - for (unsigned int i=0;i0 && (OffsetPoints.rbegin()->SurfacePoint.SquareDistance(OffsetPoint.SurfacePoint)>(Precision::Confusion()*Precision::Confusion())) && (fabs(OffsetPoints.rbegin()->SurfacePoint.Z()-OffsetPoint.SurfacePoint.Z())< (m_UserSettings.level_distance/10.0))) - { - OffsetPoints.push_back(OffsetPoint); - } - else if (OffsetPoints.empty()) - { - OffsetPoints.push_back(OffsetPoint); - } - else if ((i+1==SpiralPoints.size()) && (OffsetPoints.rbegin()->SurfacePoint.SquareDistance(OffsetPoint.SurfacePoint)<(Precision::Confusion()*Precision::Confusion()))) - { - //This part is necessary as the last point of the current spiral would otherwise not be offset - OffsetPoints.pop_back();//Delete the two currently last points - OffsetPoints.pop_back(); - OffsetPoints.push_back(OffsetPoint);//Add the last point - } - } - return OffsetPoints; -} -std::vector cutting_tools::getFlatAreas() -{ - std::vector FlatAreas; - FlatAreas.clear(); - for (unsigned int i=0;i >::iterator current_flat_level; - gp_Pnt lastPoint(0.0,0.0,0.0); //Initialize the first Point to the Origin - current_flat_level = m_ordered_cuts.begin(); - bool slave_done= false; //Necessary if the slave is already put out - //Not at the very beginning, because we don't want to drive that with the master - for (m_ordered_cuts_it = m_ordered_cuts.begin()+1;m_ordered_cuts_it!=m_ordered_cuts.end();++m_ordered_cuts_it) - { - std::vector > MasterPointContainer; - std::vector > > MasterPointsStorage; - std::vector SlavePointContainer; - std::vector > SlavePointsStorage; - std::vector >::iterator anIterator1; - std::vector > >::iterator anIterator2; - MasterPointsStorage.clear(); - SlavePointsStorage.clear(); - MasterPointContainer.clear(); - SlavePointContainer.clear(); - //Now we have to select which strategy to choose - //if the current levels is bigger,the same, or less then the previous one - if (m_ordered_cuts_it->first<(m_ordered_cuts_it-1)->first) - { - //Master is calculated as Usual, Slave stays at the currently highest level - //Check if current Level has got a Wire - if (m_ordered_cuts_it->second.ShapeType() == TopAbs_WIRE) - { - WireExplorer aWireExplorer(TopoDS::Wire(m_ordered_cuts_it->second)); - for (aWireExplorer.Init();aWireExplorer.More();aWireExplorer.Next()) - { - BRepAdaptor_Curve curveAdaptor(aWireExplorer.Current()); - GCPnts_QuasiUniformAbscissa aProp(curveAdaptor,100); - for (int i=1;i<=aProp.NbPoints();++i) - { - std::pair aTempPair; - //Check the direction - if (aWireExplorer.Current().Orientation() != TopAbs_REVERSED) - curveAdaptor.D0(aProp.Parameter(i),aTempPair.first); - else curveAdaptor.D0(aProp.Parameter(aProp.NbPoints()-i+1),aTempPair.first); - aTempPair.first.SetZ(aTempPair.first.Z() + m_UserSettings.master_radius); - aTempPair.second = 0.0; //Initialize of Angle - //check if the new point is too close to the old one. If so, then no push_back - if (MasterPointContainer.size()>0 && (MasterPointContainer.rbegin()->first.SquareDistance(aTempPair.first)>(Precision::Confusion()*Precision::Confusion()))) - { - MasterPointContainer.push_back(aTempPair); - } - else if (MasterPointContainer.empty()) - { - MasterPointContainer.push_back(aTempPair); - } - } - //Now Interpolate the Points only if we have a non-continuous edge or if we are finished - //with all edges - bool tangency = true; - //If there are more Edges in the wire - if (aWireExplorer.MoreEdge()) - { - tangency = CheckEdgeTangency(aWireExplorer.Current(),aWireExplorer.NextEdge()); - if (!tangency) - { - //Store all the PointClouds in a StorageVector to arrange the Robot-Movement afterwards - MasterPointsStorage.push_back(MasterPointContainer); - MasterPointContainer.clear(); - } - else continue; - } - else - { - MasterPointsStorage.push_back(MasterPointContainer); - MasterPointContainer.clear(); - } - } - //Now check the point-cloud with the shortest distance to "lastPoint" - int start_index = 0,start_array=0; - CheckforLastPoint(lastPoint,start_index,start_array,MasterPointsStorage); - //Now Interpolate the PointClouds...Cloud by Cloud - //First we have to divide the first PointCloud as it is for sure that we start - //Somewhere in the middle of it. We will then insert the points at the current start - if (MasterPointsStorage.size() == 1) //If we have only one PointCloud - { - MasterPointContainer.clear(); - bool first = true; - for (unsigned int i=start_index;isize();i++) - { - if (i+1 == MasterPointsStorage.begin()->size()) - { - first = false; - i=-1; - continue; - } - MasterPointContainer.push_back(MasterPointsStorage[0][i]); - if (!first && i == start_index) - break; - } - //Now lets interpolate the Point Cloud - Handle(TColgp_HArray1OfPnt) InterpolationPointsMaster = new TColgp_HArray1OfPnt(1, MasterPointContainer.size()); - for (unsigned int t=0;tSetValue(t+1,MasterPointContainer[t].first); - } - m_all_offset_cuts_high.push_back(InterpolateOrderedPoints(InterpolationPointsMaster,true)); - //Store the last point - lastPoint = MasterPointContainer.rbegin()->first; - } - else //If we have more than one PointCloud - { - anIterator2 = MasterPointsStorage.begin(); - MasterPointContainer.clear(); - for (int i=0;i<=start_index;i++) - { - MasterPointContainer.push_back(MasterPointsStorage[start_array][i]); - } - MasterPointsStorage.insert((anIterator2+start_array+1),MasterPointContainer); - MasterPointContainer.clear(); - //Reinitialize the Iterators - anIterator2 = MasterPointsStorage.begin(); - for (unsigned int i=start_index;iSetValue(t+1,MasterPointsStorage[j][t].first); - } - m_all_offset_cuts_high.push_back(InterpolateOrderedPoints(InterpolationPointsMaster,true)); - if (j+1==MasterPointsStorage.size()) - { - j=-1; - continue; - } - if (j+1==start_array+1) - break; - } - lastPoint = MasterPointsStorage[start_array].rbegin()->first; - } - } - else //If the current Curve is no Wire - { - Edgesort aCutShapeSorter(m_ordered_cuts_it->second); - for (aCutShapeSorter.Init();aCutShapeSorter.More();aCutShapeSorter.Next()) - { - //Get the PCurve and the GeomSurface - Handle_Geom2d_Curve a2DCurve; - Handle_Geom_Surface aSurface; - TopLoc_Location aLoc; - TopoDS_Edge anEdge; - double first2,last2; - bool reversed = false; - BRep_Tool::CurveOnSurface(aCutShapeSorter.Current(),a2DCurve,aSurface,aLoc,first2,last2); - //Now rotate the resulting surface and the curve cleanly - //(maybe the TopoDS_Face was somehow rotated or the TopoDS_Edge) - if (aCutShapeSorter.Current().Orientation() == TopAbs_REVERSED) - reversed = true; - - BRepAdaptor_Curve aCurveAdaptor(aCutShapeSorter.Current()); - GCPnts_QuasiUniformAbscissa aPointGenerator(aCurveAdaptor,200); - int PointSize = aPointGenerator.NbPoints(); - //Now get the surface normal to the generated points - for (int i=1;i<=PointSize;++i) - { - std::pair PointContactPair; - gp_Pnt2d a2dParaPoint; - gp_Pnt aSurfacePoint; - TopoDS_Face aFace; - gp_Vec Uvec,Vvec,normalVec; - //If the curve is reversed we also have to reverse the point direction - if (reversed) a2DCurve->D0(aPointGenerator.Parameter(PointSize-i+1),a2dParaPoint); - else a2DCurve->D0(aPointGenerator.Parameter(i),a2dParaPoint); - GeomAdaptor_Surface aGeom_Adaptor(aSurface); - int t = aGeom_Adaptor.GetType(); - aGeom_Adaptor.D1(a2dParaPoint.X(),a2dParaPoint.Y(),aSurfacePoint,Uvec,Vvec); - //Now calculate the normal vector on the surface - normalVec = Uvec; - normalVec.Cross(Vvec); - normalVec.Normalize(); - //Now the normal is calculated and normalized - //Now check whether the normal is really pointing to the clean side - //To do this, just check whether the Z-value of the normal is greater than zero (then in the 1st and 2nd quadrant) - if (normalVec.Z()<0) normalVec.Multiply(-1.0); - - //Briefly calculate the angle to the ground plane - gp_Vec planeVec(normalVec.X(),normalVec.Y(),0.0); - //The angle - PointContactPair.second = normalVec.Angle(planeVec); - gp_Vec NormalVecSlave = normalVec; - //Now set the Z component to 0 - //normalVec.SetZ(0.0); - normalVec.Normalize(); - //Now multiply the normal using the following formula for the master - //double multiply = m_UserSettings.master_radius*(1-sin(PointContactPair.second))/cos(PointContactPair.second); - double multiply = m_UserSettings.master_radius; - normalVec.Multiply(multiply); - //Now calculate the offset point - PointContactPair.first.SetXYZ(aSurfacePoint.XYZ() + normalVec.XYZ()); - //So that we don't get any points that are too close together - //Find the last point added - if (MasterPointContainer.size()>0 && (MasterPointContainer.rbegin()->first.SquareDistance(PointContactPair.first)>0.001)) - { - MasterPointContainer.push_back(PointContactPair); - } - else if (MasterPointContainer.empty()) - { - MasterPointContainer.push_back(PointContactPair); - } - } - } - MasterPointsStorage.push_back(MasterPointContainer); - int start_index_master = 0,start_array_master=0; - CheckforLastPoint(lastPoint,start_index_master,start_array_master,MasterPointsStorage); - //First we have to divide the first PointCloud as it is for sure that we start - //Somewhere in the middle of it. We will then insert the points at the current start - MasterPointContainer.clear(); - bool first = true; - for (unsigned int i=start_index_master;isize();i++) - { - if (i+1 == MasterPointsStorage.begin()->size()) - { - first = false; - i=-1; - continue; - } - MasterPointContainer.push_back(MasterPointsStorage[0][i]); - if (!first && i == start_index_master) - break; - } - //Now lets interpolate the Point Cloud - Handle(TColgp_HArray1OfPnt) InterpolationPointsMaster = new TColgp_HArray1OfPnt(1, MasterPointContainer.size()); - for (unsigned int t=0;tSetValue(t+1,MasterPointContainer[t].first); - - m_all_offset_cuts_high.push_back(InterpolateOrderedPoints(InterpolationPointsMaster,true)); - //Store the last point - lastPoint = MasterPointContainer.rbegin()->first; - //SlaveTool Path finished - }//end calculation of the master if its not a wire - //Calculate the Slave Toolpath - if (!slave_done)//if we did not calculate the slave toolpath for the current flat area - { - TopoDS_Wire aWire = TopoDS::Wire(current_flat_level->second); - BRepAdaptor_CompCurve2 wireAdaptor(aWire); - GCPnts_QuasiUniformAbscissa aProp(wireAdaptor,1000); - SlavePointContainer.clear(); - SlavePointsStorage.clear(); - for (int i=1;i<=aProp.NbPoints();++i) - { - gp_Pnt SlaveOffsetPoint; - wireAdaptor.D0(aProp.Parameter(i),SlaveOffsetPoint); - SlaveOffsetPoint.SetZ(SlaveOffsetPoint.Z() - m_UserSettings.sheet_thickness - m_UserSettings.slave_radius); - //check if the new point is too close to the old one. If so, then no push_back - if (SlavePointContainer.size()>0 && (SlavePointContainer.rbegin()->SquareDistance(SlaveOffsetPoint)>(Precision::Confusion()*Precision::Confusion()))) - SlavePointContainer.push_back(SlaveOffsetPoint); - else if (SlavePointContainer.empty()) - SlavePointContainer.push_back(SlaveOffsetPoint); - } - SlavePointsStorage.push_back(SlavePointContainer); - int start_index_slave = 0,start_array_slave=0; - CheckforLastPoint(lastPoint,start_index_slave,start_array_slave,SlavePointsStorage); - //First we have to divide the first PointCloud as it is for sure that we start - //Somewhere in the middle of it. We will then insert the points at the current start - SlavePointContainer.clear(); - bool first = true; - for (unsigned int i=start_index_slave;isize();i++) - { - if (i+1 == SlavePointsStorage.begin()->size()) - { - first = false; - i=-1; - continue; - } - SlavePointContainer.push_back(SlavePointsStorage[0][i]); - if (!first && i == start_index_slave) - break; - } - //Now Interpolate the Slave, therefore we also have to take the curves normal directions - Handle(TColgp_HArray1OfPnt) InterpolationPoints = new TColgp_HArray1OfPnt(1, SlavePointContainer.size()); - for (unsigned int t=0;tSetValue(t+1,SlavePointContainer[t]); - - m_all_offset_cuts_low.push_back(InterpolateOrderedPoints(InterpolationPoints,true)); - slave_done = true; - } //Slave done - }//Current Curve < last curve is finished here - if (m_ordered_cuts_it->first==(m_ordered_cuts_it-1)->first) - { - //we only set the new flat level wire here - //no Toolpath is calculated - current_flat_level = m_ordered_cuts_it; - slave_done = false; //This is to generate the next flat level for the slave - }//end of current == last - if (m_ordered_cuts_it->first>(m_ordered_cuts_it-1)->first) - { - //The Slave Tool is now the Master Tool and therefore we only have to exchange < case - if (m_ordered_cuts_it->second.ShapeType() == TopAbs_WIRE) - { - WireExplorer aWireExplorer(TopoDS::Wire(m_ordered_cuts_it->second)); - for (aWireExplorer.Init();aWireExplorer.More();aWireExplorer.Next()) - { - BRepAdaptor_Curve curveAdaptor(aWireExplorer.Current()); - GCPnts_QuasiUniformAbscissa aProp(curveAdaptor,100); - for (int i=1;i<=aProp.NbPoints();++i) - { - std::pair aTempPair; - //Check the direction - if (aWireExplorer.Current().Orientation() != TopAbs_REVERSED) - curveAdaptor.D0(aProp.Parameter(i),aTempPair.first); - else curveAdaptor.D0(aProp.Parameter(aProp.NbPoints()-i+1),aTempPair.first); - aTempPair.first.SetZ(aTempPair.first.Z() - m_UserSettings.slave_radius - m_UserSettings.sheet_thickness); - aTempPair.second = 0.0; //Initialize of Angle - //check if the new point is too close to the old one. If so, then no push_back - if (MasterPointContainer.size()>0 && (MasterPointContainer.rbegin()->first.SquareDistance(aTempPair.first)>(Precision::Confusion()*Precision::Confusion()))) - { - MasterPointContainer.push_back(aTempPair); - } - else if (MasterPointContainer.empty()) - { - MasterPointContainer.push_back(aTempPair); - } - } - //Now Interpolate the Points only if we have a non-continuous edge or if we are finished - //with all edges - bool tangency = true; - //If there are more Edges in the wire - if (aWireExplorer.MoreEdge()) - { - tangency = CheckEdgeTangency(aWireExplorer.Current(),aWireExplorer.NextEdge()); - if (!tangency) - { - //Store all the PointClouds in a StorageVector to arrange the Robot-Movement afterwards - MasterPointsStorage.push_back(MasterPointContainer); - MasterPointContainer.clear(); - } - else continue; - } - else - { - MasterPointsStorage.push_back(MasterPointContainer); - MasterPointContainer.clear(); - } - } - //Now check the point-cloud with the shortest distance to "lastPoint" - int start_index = 0,start_array=0; - CheckforLastPoint(lastPoint,start_index,start_array,MasterPointsStorage); - //Now Interpolate the PointClouds...Cloud by Cloud - //First we have to divide the first PointCloud as it is for sure that we start - //Somewhere in the middle of it. We will then insert the points at the current start - if (MasterPointsStorage.size() == 1) //If we have only one PointCloud - { - MasterPointContainer.clear(); - bool first = true; - for (unsigned int i=start_index;isize();i++) - { - if (i+1 == MasterPointsStorage.begin()->size()) - { - first = false; - i=-1; - continue; - } - MasterPointContainer.push_back(MasterPointsStorage[0][i]); - if (!first && i == start_index) - break; - } - //Now lets interpolate the Point Cloud - Handle(TColgp_HArray1OfPnt) InterpolationPointsMaster = new TColgp_HArray1OfPnt(1, MasterPointContainer.size()); - for (unsigned int t=0;tSetValue(t+1,MasterPointContainer[t].first); - } - m_all_offset_cuts_low.push_back(InterpolateOrderedPoints(InterpolationPointsMaster,true)); - //Store the last point - lastPoint = MasterPointContainer.rbegin()->first; - } - else //If we have more than one PointCloud - { - anIterator2 = MasterPointsStorage.begin(); - MasterPointContainer.clear(); - for (int i=0;i<=start_index;i++) - { - MasterPointContainer.push_back(MasterPointsStorage[start_array][i]); - } - MasterPointsStorage.insert((anIterator2+start_array+1),MasterPointContainer); - MasterPointContainer.clear(); - //Reinitialize the Iterators - anIterator2 = MasterPointsStorage.begin(); - for (unsigned int i=start_index;iSetValue(t+1,MasterPointsStorage[j][t].first); - } - m_all_offset_cuts_low.push_back(InterpolateOrderedPoints(InterpolationPointsMaster,true)); - if (j+1==MasterPointsStorage.size()) - { - j=-1; - continue; - } - if (j+1==start_array+1) - break; - } - lastPoint = MasterPointsStorage[start_array].rbegin()->first; - } - } - else //If the current Curve is no Wire - { - Edgesort aCutShapeSorter(m_ordered_cuts_it->second); - for (aCutShapeSorter.Init();aCutShapeSorter.More();aCutShapeSorter.Next()) - { - //Get the PCurve and the GeomSurface - Handle_Geom2d_Curve a2DCurve; - Handle_Geom_Surface aSurface; - TopLoc_Location aLoc; - TopoDS_Edge anEdge; - double first2,last2; - bool reversed = false; - BRep_Tool::CurveOnSurface(aCutShapeSorter.Current(),a2DCurve,aSurface,aLoc,first2,last2); - //Now rotate the resulting surface and the curve cleanly - //(maybe the TopoDS_Face was somehow rotated or the TopoDS_Edge) - if (aCutShapeSorter.Current().Orientation() == TopAbs_REVERSED) - reversed = true; - - BRepAdaptor_Curve aCurveAdaptor(aCutShapeSorter.Current()); - GCPnts_QuasiUniformAbscissa aPointGenerator(aCurveAdaptor,200); - int PointSize = aPointGenerator.NbPoints(); - //Now get the surface normal to the generated points - for (int i=1;i<=PointSize;++i) - { - std::pair PointContactPair; - gp_Pnt2d a2dParaPoint; - gp_Pnt aSurfacePoint; - TopoDS_Face aFace; - gp_Vec Uvec,Vvec,normalVec; - //If the curve is reversed we also have to reverse the point direction - if (reversed) a2DCurve->D0(aPointGenerator.Parameter(PointSize-i+1),a2dParaPoint); - else a2DCurve->D0(aPointGenerator.Parameter(i),a2dParaPoint); - GeomAdaptor_Surface aGeom_Adaptor(aSurface); - int t = aGeom_Adaptor.GetType(); - aGeom_Adaptor.D1(a2dParaPoint.X(),a2dParaPoint.Y(),aSurfacePoint,Uvec,Vvec); - //Now calculate the normal vector on the surface - normalVec = Uvec; - normalVec.Cross(Vvec); - normalVec.Normalize(); - //Now the normal is calculated and normalized - //Now check whether the normal is really pointing to the clean side - //To do this, just check whether the Z-value of the normal is greater than zero (then in the 1st and 2nd quadrant) - if (normalVec.Z()<0) normalVec.Multiply(-1.0); - - //Briefly calculate the angle to the ground plane - gp_Vec planeVec(normalVec.X(),normalVec.Y(),0.0); - //The angle - PointContactPair.second = normalVec.Angle(planeVec); - gp_Vec NormalVecSlave = normalVec; - //Now set the Z component to 0 - //normalVec.SetZ(0.0); - normalVec.Normalize(); - //Now multiply the normal using the following formula for the master - //double multiply = m_UserSettings.master_radius*(1-sin(PointContactPair.second))/cos(PointContactPair.second); - double multiply = m_UserSettings.slave_radius + m_UserSettings.sheet_thickness; - normalVec.Multiply(multiply); - normalVec.Multiply(-1.0); //As the master is the slave - //Now calculate the offset point - PointContactPair.first.SetXYZ(aSurfacePoint.XYZ() + normalVec.XYZ()); - //So that we don't get any points that are too close together - //Find the last point added - if (MasterPointContainer.size()>0 && (MasterPointContainer.rbegin()->first.SquareDistance(PointContactPair.first)>0.001)) - { - MasterPointContainer.push_back(PointContactPair); - } - else if (MasterPointContainer.empty()) - { - MasterPointContainer.push_back(PointContactPair); - } - } - } - MasterPointsStorage.push_back(MasterPointContainer); - int start_index_master = 0,start_array_master=0; - CheckforLastPoint(lastPoint,start_index_master,start_array_master,MasterPointsStorage); - //First we have to divide the first PointCloud as it is for sure that we start - //Somewhere in the middle of it. We will then insert the points at the current start - MasterPointContainer.clear(); - bool first = true; - for (unsigned int i=start_index_master;isize();i++) - { - if (i+1 == MasterPointsStorage.begin()->size()) - { - first = false; - i=-1; - continue; - } - MasterPointContainer.push_back(MasterPointsStorage[0][i]); - if (!first && i == start_index_master) - break; - } - //Now lets interpolate the Point Cloud - Handle(TColgp_HArray1OfPnt) InterpolationPointsMaster = new TColgp_HArray1OfPnt(1, MasterPointContainer.size()); - for (unsigned int t=0;tSetValue(t+1,MasterPointContainer[t].first); - - m_all_offset_cuts_low.push_back(InterpolateOrderedPoints(InterpolationPointsMaster,true)); - //Store the last point - lastPoint = MasterPointContainer.rbegin()->first; - //SlaveTool Path finished - }//end calculation of the master if its not a wire - //Calculate the Slave Toolpath - if (!slave_done)//if we did not calculate the slave toolpath for the current flat area - { - TopoDS_Wire aWire = TopoDS::Wire(current_flat_level->second); - BRepAdaptor_CompCurve2 wireAdaptor(aWire); - GCPnts_QuasiUniformAbscissa aProp(wireAdaptor,1000); - SlavePointContainer.clear(); - SlavePointsStorage.clear(); - for (int i=1;i<=aProp.NbPoints();++i) - { - gp_Pnt SlaveOffsetPoint; - wireAdaptor.D0(aProp.Parameter(i),SlaveOffsetPoint); - SlaveOffsetPoint.SetZ(SlaveOffsetPoint.Z() + m_UserSettings.master_radius); - //check if the new point is too close to the old one. If so, then no push_back - if (SlavePointContainer.size()>0 && (SlavePointContainer.rbegin()->SquareDistance(SlaveOffsetPoint)>(Precision::Confusion()*Precision::Confusion()))) - { - SlavePointContainer.push_back(SlaveOffsetPoint); - } - else if (SlavePointContainer.empty()) - { - SlavePointContainer.push_back(SlaveOffsetPoint); - } - } - SlavePointsStorage.push_back(SlavePointContainer); - int start_index_slave = 0,start_array_slave=0; - CheckforLastPoint(lastPoint,start_index_slave,start_array_slave,SlavePointsStorage); - //First we have to divide the first PointCloud as it is for sure that we start - //Somewhere in the middle of it. We will then insert the points at the current start - SlavePointContainer.clear(); - bool first = true; - for (unsigned int i=start_index_slave;isize();i++) - { - if (i+1 == SlavePointsStorage.begin()->size()) - { - first = false; - i=-1; - continue; - } - SlavePointContainer.push_back(SlavePointsStorage[0][i]); - if (!first && i == start_index_slave) - break; - } - //Now Interpolate the Slave, therefore we also have to take the curves normal directions - Handle(TColgp_HArray1OfPnt) InterpolationPoints = new TColgp_HArray1OfPnt(1, SlavePointContainer.size()); - for (unsigned int t=0;tSetValue(t+1,SlavePointContainer[t]); - - m_all_offset_cuts_high.push_back(InterpolateOrderedPoints(InterpolationPoints,true)); - slave_done = true; - } //Slave done - }//Current Curve > Last Curve - }//Main for Loop which goes through all the curves - - return true; -} - -bool cutting_tools::cut_Mesh(float z_level, float min_level, std::list >&result, float &z_level_corrected) -{ - //std::ofstream outfile; - //outfile.open("c:/mesh_cut.out"); - Base::Vector3f z_level_plane,normal; - z_level_plane.z=z_level; - normal.x=0; - normal.y=0; - normal.z=1.0; - bool cutok; - //The direction for the correction is determined here - bool direction=true; - float factor = 0.0; - do - { - cutok = true; - m_aMeshAlgo->CutWithPlane(z_level_plane,normal,*m_CAD_Mesh_Grid,result); - //std::list >::iterator it; - //std::vector::iterator vector_it; - //check whether a cut has really been made - if (result.size()==0) - { - cutok = false; - //Insert a little more space each time for the correction - factor = factor+float(0.05); - if (factor>=1) factor = float(0.95); - //If we have to make a correction for the first time, we start with a minus - if (direction) - { - z_level_plane.z = (z_level-(m_pitch*factor)); - z_level_corrected = z_level_plane.z; - direction=false; - continue; - } - else - { - z_level_plane.z = (z_level+(m_pitch*factor)); - z_level_corrected = z_level_plane.z; - direction=true; - continue; - } - } - } - while (cutok==false); - //for(vector_it=(*(result.begin())).begin();vector_it<(*(result.begin())).end();++vector_it) - //outfile << (*vector_it).x <<","<<(*vector_it).y <<","<<(*vector_it).z<< std::endl; - //outfile.close(); - return true; -} - - - - - - -bool cutting_tools::cut(float z_level, float min_level, TopoDS_Shape &aCutShape, float &z_level_corrected) -{ - gp_Pnt aPlanePnt(0,0,z_level); - gp_Dir aPlaneDir(0,0,1); - bool cutok; - //The direction for the correction is determined here - bool correction=true; - float factor = 0.0; - do - { - cutok = true; - Handle_Geom_Plane aPlane = new Geom_Plane(aPlanePnt, aPlaneDir); - BRepBuilderAPI_MakeFace Face(aPlane); - BRepAlgo_Section mkCut(m_Shape, Face.Face(),Standard_False); - mkCut.Approximation (Standard_True); - mkCut.ComputePCurveOn1(Standard_True); - mkCut.Build(); - //Check the new algorithm - //Edgesort aSorter(mkCut.Shape()); - //aSorter.Init(); - - //Now check whether there really are edges - TopExp_Explorer exploreShape; - exploreShape.Init(mkCut.Shape(),TopAbs_EDGE); - //If there is no edge - if (!exploreShape.More()) - { - cutok = false; - //Insert a little more space each time for the correction - factor = factor+float(0.05); - if (factor>=1) factor = float(0.95); - //If we have to make a correction for the first time, we start with a minus - if (correction) - { - aPlanePnt.SetZ(z_level-(m_pitch*factor)); - z_level_corrected = float(aPlanePnt.Z()); - correction=false; - continue; - } - else - { - aPlanePnt.SetZ(z_level+(m_pitch*factor)); - z_level_corrected = float(aPlanePnt.Z()); - correction=true; - continue; - } - } - //The shape, which is passed by reference, is now filled with the ordered section - aCutShape = mkCut.Shape(); - - } - while (cutok==false); - - return true; -} - - - - - -bool cutting_tools::classifyShape() -{ - TopExp_Explorer Explorer; - Explorer.Init(m_Shape,TopAbs_FACE); - if (!Explorer.More()) return false; - //check how many different faces we have - int k=0; - for (; Explorer.More(); Explorer.Next()) - { - k++; - } - std::cout <<"We have " << k << "Faces" << std::endl; - //If more than one face is available, then set a member variable - if (k>1) m_cad = true; - return true; -} - - - -/* The old cut started here - - - - - bool cutok=true; - //If we have only one face and no flat areas - if (m_all_cuts.empty()) - { - //Schnitte über die Bounding Box bestimmen - Bnd_Box currentBBox; - - Standard_Real XMin, YMin, ZMin, XMax, YMax, ZMax; - BRepBndLib::Add(m_Shape, currentBBox ); - currentBBox.SetGap(0.0); - currentBBox.Get(XMin, YMin, ZMin, XMax, YMax, ZMax); - double maxlevel=Max(ZMax,ZMin); - double minlevel=Min(ZMax,ZMin); - int cutnumber = fabs((maxlevel-minlevel)/m_pitch); //Cut away the cast by the decimal places - m_pitch = fabs(maxlevel-minlevel)/cutnumber; //Correct m_pitch slightly to really get to the last level - - //Currently, the last level of self-approximated surfaces is not considered as a path curve - //The first level is also completely omitted, since it is unimportant. - //The track is only useful for the lower machine if there are still flat areas at all - for (int i=0;i InitialPlaneLevels; - std::vector > atemp_storage; - atemp_storage.clear(); - std::vector::iterator temp_it; - for (m_it= m_all_cuts.begin();m_itX2Max && Y1Min < Y2Min && Y1Max>Y2Max) //1 is greater - { - if(m_it == m_all_cuts.begin())//When we're at the top level... - { - atemp_storage.push_back(*(m_it+1)); - m_it++;// We skip the next one - // We only have one problem if we have more than two wires on one level. - } - else - { - atemp_storage.push_back(*(m_it)); - } - } - //Let's see if the value is already available in the list - temp_it = std::find(InitialPlaneLevels.begin(),InitialPlaneLevels.end(),(*m_it).first); - if (temp_it == InitialPlaneLevels.end()) - { - InitialPlaneLevels.push_back((*m_it).first); - } - } - //Now sort the flat areas according to their height - std::sort(InitialPlaneLevels.begin(),InitialPlaneLevels.end(),FloatHuge); - - //Now the cuts have to be sorted between the flat pieces - for (temp_it=InitialPlaneLevels.begin();temp_it * - * * - * This file is part of the FreeCAD CAx development system. * - * * - * This library is free software; you can redistribute it and/or * - * modify it under the terms of the GNU Library General Public * - * License as published by the Free Software Foundation; either * - * version 2 of the License, or (at your option) any later version. * - * * - * This library is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * - * GNU Library General Public License for more details. * - * * - * You should have received a copy of the GNU Library General Public * - * License along with this library; see the file COPYING.LIB. If not, * - * write to the Free Software Foundation, Inc., 59 Temple Place, * - * Suite 330, Boston, MA 02111-1307, USA * - * * - ***************************************************************************/ -/**\file -\brief Here you can find the header file for all the cutting stuff. - -This is the place where all the prototypes are declared and the members are defined -*/ -#ifndef Cutting_Tools -#define Cutting_Tools - - -#include -#include -#include -#include -#include -#include - -#include "stuff.h" - -namespace MeshCore { -class MeshAlgorithm; -class MeshFacetGrid; -} - -/**\brief A Container to transfer the GUI settings - -This struct can be used to transfer the settings of the CAM-Workbench GUI to other functions if required. -It provides members for all fields of the GUI settings window. -*/ -struct CuttingToolsSettings -{ - /**This represents the maximum allowed angle for the springback functions*/ - float limit_angle; - /**This represents the minimum CAD-Radius of the forming shape. This is necessary for the springback - to avoid the generation of radii which are below that value*/ - float cad_radius; - /**This represents the radius of the Master Tool*/ - float master_radius; - /**This represents the radius of the Slave Tool*/ - float slave_radius; - /**This represents the cutting distance between two levels (the pitch)*/ - float level_distance; - /**This represents the springback correction factor used for the mirror part*/ - float correction_factor; - /**This represents the sheet thickness*/ - float sheet_thickness; - /**This represents the maximum velocity for the simulation output*/ - float max_Vel; - /**This represents the maximum acceleration for the simulation output*/ - float max_Acc; - /**This represents the pretension of the spring if used during simulation in mm*/ - int spring_pretension; - /**This represents the Y-Offset value for the robot output*/ - float y_offset_robot; - /**This represents the X-Offset value for the robot output*/ - float x_offset_robot; - /**This represents the error of the approximated NURB surface*/ - float error_tolerance; - - /**This value is necessary to tell some special functions if we move zig/zag or clockwise/counterclockwise - without changing direction after each step*/ - bool clockwise; -}; - -/**\brief A Container used for the Spiral-Toolpath Generation*/ -struct SpiralHelper -{ - /**This represents the SurfacePoint of the CAD-Surface*/ - gp_Pnt SurfacePoint; - /**This represents the direction vector between two following points*/ - gp_Vec LineD1; - /**This represents the SurfaceNormal at the SurfacePoint*/ - gp_Vec SurfaceNormal; -}; - -struct BoundBox3f_Less -{ - bool operator()(const Base::BoundBox3f& _Left, const Base::BoundBox3f& _Right) const - { - if (_Left.IsInBox(_Right)) return false; - - return true; - } -}; - -struct Face_Less -{ - bool operator()(const TopoDS_Face& _Left, const TopoDS_Face& _Right) const - { - return(_Left.HashCode(IntegerLast())<_Right.HashCode(IntegerLast())); - } -}; - - - - -/**\brief This class is the main class for the cutting Algorithms. - -Its idea is to provide the basic functionality for cutting CAD surfaces. In this class you can also find -functions useful for generating spiral and feature based toolpaths -*/ -class CamExport cutting_tools -{ -public: - /**\brief The standard constructor - - \param aShape A TopoDS_Shape - */ - cutting_tools(TopoDS_Shape aShape); - - /**\brief The second standard constructor - - This one gets a vertical step down value as well - \param aShape A TopoDS_Shape - \param pitch A vertical step down in[mm] - */ - cutting_tools(TopoDS_Shape aShape, float pitch); - - /**\brief The standard destructor*/ - ~cutting_tools(); - - TopoDS_Wire ordercutShape(const TopoDS_Shape &aShape); - double GetEdgeLength(const TopoDS_Edge& anEdge); - bool OffsetWires_Standard(); - bool OffsetWires_FeatureBased(); - bool OffsetWires_Spiral(); - //The sequence of the flat areas is determined here (the input comes from the GUI) - bool SetMachiningOrder(const TopoDS_Face &aFace, float x,float y,float z); - /* - It is used to check how many faces we have and a vector is also filled here where all - the flat areas are inside - */ - - /*! \brief Here we find a great function */ - bool arrangecuts_ZLEVEL(); - //bool checkPointIntersection(std::vector &finalPoints); - bool calculateAccurateSlaveZLevel(std::vector >&OffsetPoints, double current_z_level, double &slave_z_level, double &average_sheet_thickness,double &average_angle, bool &cutpos); - //bool checkPointDistance(std::vector &finalPoints,std::vector &output); - bool initializeMeshStuff(); - bool arrangecuts_SPIRAL(); - bool arrangecuts_FEATURE_BASED(); - inline const std::vector* getOutputhigh() - { - return &m_all_offset_cuts_high; - } - inline const std::vector* getOutputlow() - { - return &m_all_offset_cuts_low; - } - inline std::vector > getCutShape() - { - return m_ordered_cuts; - } - - std::vector getFlatAreas(); - CuttingToolsSettings m_UserSettings; - -private: - //typedef std::list > Polylines; - bool CheckEdgeTangency(const TopoDS_Edge& edge1, const TopoDS_Edge& edge2); - bool CheckPoints(Handle(TColgp_HArray1OfPnt) PointArray); - bool getShapeBB(); - bool fillFaceWireMap(); - bool CheckforLastPoint(const gp_Pnt& lastPoint,int &start_index,int &start_array,const std::vector > >& MasterPointsStorage); - bool CheckforLastPoint(const gp_Pnt& lastPoint,int &start_index,int &start_array,const std::vector >& SlavePointsStorage); - bool CheckforLastPoint(const gp_Pnt& lastPoint, int &start_index_master,int &start_array_master,int &start_index_slave,int &start_array_slave,const std::vector > >& MasterPointsStorage, const std::vector >& SlavePointsStorage); - TopoDS_Shape getProperCut(TopoDS_Shape& aShape); - Handle_Geom_BSplineCurve InterpolateOrderedPoints(Handle(TColgp_HArray1OfPnt) InterpolationPoints,const bool direction); - //bool projectWireToSurface(const TopoDS_Wire &aWire,const TopoDS_Shape &aShape,std::vector &aContainer); - - bool fillFaceBBoxes(); - Base::BoundBox3f getWireBBox(TopoDS_Wire aWire); - bool checkPointinFaceBB(const gp_Pnt &aPnt,const Base::BoundBox3f &aBndBox); - bool classifyShape(); - //bool GenFlatLevelBSpline( - //bool checkFlatLevel(); - bool cut(float z_level, float min_level, TopoDS_Shape &aCutShape,float &z_level_corrected); - bool cut_Mesh(float z_level, float min_level, std::list > &result,float &z_level_corrected); - std::vector OffsetSpiral(const std::vector& SpiralPoints,bool master_or_slave=true); - gp_Dir getPerpendicularVec(gp_Vec& anInput); - std::vector > m_ordered_cuts; - std::vector > m_face_bboxes; - std::vector >::iterator m_face_bb_it; - - std::vector m_all_offset_cuts_high,m_all_offset_cuts_low; - //std::multimap m_zl_wire_combination; - std::map,Face_Less > m_FaceWireMap; - std::vector >::iterator m_ordered_cuts_it; - - //Member to check whether CAD or not - bool m_cad; - TopoDS_Shape m_Shape; - MeshCore::MeshKernel m_CAD_Mesh; - MeshCore::MeshAlgorithm * m_aMeshAlgo; - MeshCore::MeshFacetGrid * m_CAD_Mesh_Grid; - bool m_mirrortobothsides; - - - //Delivery amount - float m_pitch; - //The highest and lowest z-value of the shape - float m_minlevel,m_maxlevel; - //The radius of the tools - float m_radius,m_radius_slave; - //Sheet metal thickness - float m_sheet_thickness; - bool m_direction; ////If we cut from top to bottom (true) or from bottom to top (false) - std::vector > m_MachiningOrder; -}; - -#endif - - diff --git a/src/Mod/Cam/App/deviation.cpp b/src/Mod/Cam/App/deviation.cpp deleted file mode 100644 index ce1f0a2e1c..0000000000 --- a/src/Mod/Cam/App/deviation.cpp +++ /dev/null @@ -1,228 +0,0 @@ -/************************************************************************** -* Copyright (c) 2007 Joachim Zettler * -* Copyright (c) 2007 Human Rezai * -* * -* This file is part of the FreeCAD CAx development system. * -* * -* This library is free software; you can redistribute it and/or * -* modify it under the terms of the GNU Library General Public * -* License as published by the Free Software Foundation; either * -* version 2 of the License, or (at your option) any later version. * -* * -* This library is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Library General Public License for more details. * -* * -* You should have received a copy of the GNU Library General Public * -* License along with this library; see the file COPYING.LIB. If not, * -* write to the Free Software Foundation, Inc., 59 Temple Place, * -* Suite 330, Boston, MA 02111-1307, USA * -* * -***************************************************************************/ - -#include "PreCompiled.h" -#include "deviation.h" - -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - - -Deviation::Deviation() -{} - -Deviation::~Deviation() -{} - -void Deviation::ImportGeometry(const TopoDS_Shape& aShape, const MeshCore::MeshKernel& aMesh) -{ - m_Mesh = aMesh; - m_Cad = aShape; -} - -bool Deviation::GenNormals() -{ - Base::Builder3D log; - TopExp_Explorer aExpFace; - - MeshPnt aMeshStruct; - std::pair inp; - std::map::iterator meshIt; - - MeshCore::MeshKernel FaceMesh; - MeshCore::MeshPointArray MeshPnts; - - int n; - - MeshPnts = m_MeshCad.GetPoints(); - m_pnts.resize(m_MeshCad.CountPoints()); - m_nlvec.resize((m_MeshCad.CountPoints())); - - for (unsigned int i=0; iNodes(); - - // create array of node points in absolute coordinate system - TColgp_Array1OfPnt aPoints(1, aNodes.Length()); - for (Standard_Integer i = 1; i <= aNodes.Length(); i++) - aPoints(i) = aNodes(i).Transformed(aLocation); - - const TColgp_Array1OfPnt2d& aUVNodes = aTr->UVNodes(); - - BRepAdaptor_Surface aSurface(aFace); - Base::Vector3f pnt, normal; - gp_Pnt2d par; - gp_Pnt P; - gp_Vec D1U, D1V; - - for (int i=1; i FailProj; - - MeshCore::MeshFacetGrid aFacetGrid(m_Mesh,10); - MeshCore::MeshAlgorithm malg(m_Mesh); - MeshCore::MeshAlgorithm malg2(m_Mesh); - MeshCore::MeshPointIterator p_it(m_MeshCad); - - Base::Vector3f projPoint, distVec, nvec(0,0,0), projPoint2; - unsigned long facetIndex; - std::stringstream text; - - unsigned int c=0; - int i=0; - - for (p_it.Begin(); p_it.More(); p_it.Next()) - { - if (malg.NearestFacetOnRay(*p_it, m_nlvec[i], aFacetGrid, projPoint, facetIndex)) // gridoptimiert - { - distVec = projPoint - *p_it; - m_nlvec[i] = distVec; // overwrites normal vector - } - else - { - if (!malg2.NearestFacetOnRay(*p_it, m_nlvec[i], projPoint, facetIndex)) // nicht gridoptimiert - { - c++; - FailProj.push_back(i); - m_nlvec[i] = nvec; - } - else - { - distVec = projPoint - *p_it; - m_nlvec[i] = distVec; // overwrites normal vector - } - } - - ++i; - } - - for(int i=0; i -#include -void Deviation::WriteOutput(const QString &dateiname) -{ - QFile anOutputFile(dateiname); - if (!anOutputFile.open(QIODevice::WriteOnly | QIODevice::Text)) - return; - QTextStream out(&anOutputFile); - - out << m_nlvec.size() << endl; - - for(int i=0; i * -* Copyright (c) 2007 Human Rezai * -* * -* This file is part of the FreeCAD CAx development system. * -* * -* This library is free software; you can redistribute it and/or * -* modify it under the terms of the GNU Library General Public * -* License as published by the Free Software Foundation; either * -* version 2 of the License, or (at your option) any later version. * -* * -* This library is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Library General Public License for more details. * -* * -* You should have received a copy of the GNU Library General Public * -* License along with this library; see the file COPYING.LIB. If not, * -* write to the Free Software Foundation, Inc., 59 Temple Place, * -* Suite 330, Boston, MA 02111-1307, USA * -* * -***************************************************************************/ - - -#ifndef DEVIATION_H -#define DEVIATION_H - -#include "best_fit.h" -#include "SpringbackCorrection.h" -#include -#include - -class CamExport Deviation : public SpringbackCorrection -{ -public: - Deviation(); - ~Deviation(); - - bool GenNormals(); - void ImportGeometry(const TopoDS_Shape& aShape, const MeshCore::MeshKernel& aMesh); - void WriteOutput(const QString &dateiname); - bool Compute(); - - TopoDS_Shape m_Cad; // CAD-Geometry - MeshCore::MeshKernel m_MeshCad; - MeshCore::MeshKernel m_Mesh; - - std::vector m_pnts, m_nlvec; -}; - - -#endif //DEVIATION_H \ No newline at end of file diff --git a/src/Mod/Cam/App/edgesort.cpp b/src/Mod/Cam/App/edgesort.cpp deleted file mode 100644 index 91fa3199fb..0000000000 --- a/src/Mod/Cam/App/edgesort.cpp +++ /dev/null @@ -1,343 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2007 Joachim Zettler * - * * - * This file is part of the FreeCAD CAx development system. * - * * - * This library is free software; you can redistribute it and/or * - * modify it under the terms of the GNU Library General Public * - * License as published by the Free Software Foundation; either * - * version 2 of the License, or (at your option) any later version. * - * * - * This library is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * - * GNU Library General Public License for more details. * - * * - * You should have received a copy of the GNU Library General Public * - * License along with this library; see the file COPYING.LIB. If not, * - * write to the Free Software Foundation, Inc., 59 Temple Place, * - * Suite 330, Boston, MA 02111-1307, USA * - * * - ***************************************************************************/ - -#include "PreCompiled.h" - -#include "edgesort.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - - -Edgesort::Edgesort(const TopoDS_Shape& aShape) - :m_shape(aShape),m_done(false) -{ - m_edges.clear(); - m_EdgeBBoxMap.clear(); - m_vertices.clear(); -} - -Edgesort::~Edgesort(void) -{ -} - -void Edgesort::Init() -{ - - Perform(); - - m_edges.clear(); - m_edges = m_EdgeBBoxMap.begin()->second; - m_edgeIter = m_edges.begin(); -} - -//#include -TopoDS_Shape Edgesort::GetDesiredCutShape(int desiredIndex) -{ - m_edges.clear(); - m_EdgeBBoxMap.clear(); - m_vertices.clear(); - - Perform(); - - if (m_EdgeBBoxMap.size()>1) - { - if (desiredIndex == 1) //Return the smallest to return it - { - m_edges = m_EdgeBBoxMap.begin()->second; - - } - else - { - m_edges = m_EdgeBBoxMap.rbegin()->second; - } - BRep_Builder aBuilder; - TopoDS_Compound aCompound; - aBuilder.MakeCompound(aCompound); - for (m_edgeIter = m_edges.begin();m_edgeIter!=m_edges.end();++m_edgeIter) - { - aBuilder.Add(aCompound,*m_edgeIter); - } - return aCompound; - } - else - { - return m_shape; - } - //Go through the edges of the result you do not like and remove this result from the original shape - -} - -void Edgesort::ReInit(const TopoDS_Shape& aShape) -{ - m_shape= aShape; - m_done = false; - m_edges.clear(); - m_EdgeBBoxMap.clear(); - m_vertices.clear(); - Perform(); - m_edges.clear(); - m_edges = m_EdgeBBoxMap.begin()->second; - m_edgeIter = m_edges.begin(); -} - - -bool Edgesort::More() -{ - return m_edgeIter != m_edges.end(); -} - -bool Edgesort::MoreEdge() -{ - return (m_edgeIter+1) != m_edges.end(); -} -const TopoDS_Edge& Edgesort::NextEdge() -{ - return *(m_edgeIter+1); -} - -void Edgesort::Next() -{ - ++m_edgeIter; -} - -const TopoDS_Edge& Edgesort::Current() -{ - return *m_edgeIter; -} - -void Edgesort::Perform() -{ - if ( m_shape.IsNull() ) - return; - - //adds all the vertices to a map, and store the associated edges - TopExp_Explorer explorer; - Standard_Integer nbEdges = 0; - Standard_Integer nbNonEdges = 0; - for ( explorer.Init(m_shape,TopAbs_EDGE) ; explorer.More() ; explorer.Next() ) - { - const TopoDS_Edge& currentEdge = TopoDS::Edge(explorer.Current()); - if (IsValidEdge(currentEdge)) - { - Perform(currentEdge); - nbEdges++; - } - else - { - nbNonEdges++; - } - } - - //now, iterate through the edges to sort them - - - - do - { - m_edges.clear(); - tMapPntEdge::iterator iter = m_vertices.begin(); - const gp_Pnt& firstPoint = iter->first; - gp_Pnt currentPoint = firstPoint; - Standard_Boolean toContinue; - do - { - toContinue = PerformEdges(currentPoint); - } - while (toContinue == Standard_True); - - tEdgeBBoxPair aTempPair; - aTempPair.first = getBoundingBox(m_edges); - aTempPair.second = m_edges; - m_EdgeBBoxMap.insert(aTempPair); - } - while (!m_vertices.empty()); - - - - m_done = true; - -} - -Base::BoundBox3f Edgesort::getBoundingBox(std::vector& aList) -{ - std::vector::iterator aListIt; - //Fill Bounding Boxes with Edges - //Therefore we have to evaluate some points on our wire and feed the BBox Algorithm - Base::BoundBox3f currentBox; - currentBox.Flush(); - for (aListIt = aList.begin();aListIt!=aList.end();aListIt++) - { - BRepAdaptor_Curve curveAdaptor(*aListIt); - GCPnts_QuasiUniformDeflection aProp(curveAdaptor,0.1); - Base::Vector3f aPoint; - for (int j=1;j<=aProp.NbPoints();++j) - { - aPoint.x = aProp.Value(j).X(); - aPoint.y = aProp.Value(j).Y(); - aPoint.z = aProp.Value(j).Z(); - currentBox.Add(aPoint); - } - } - return currentBox; -} - - - -bool Edgesort::PerformEdges(gp_Pnt& point) -{ - tMapPntEdge::iterator iter = m_vertices.find(point); - if ( iter == m_vertices.end() ) - return false; - - tEdgeVector& edges = iter->second; - - tEdgeVector::iterator edgeIt = edges.begin(); - - //no more edges. pb - if ( edgeIt == edges.end() ) - { - //Delete also the current vertex - m_vertices.erase(iter); - return false; - } - - TopoDS_Edge theEdge = *edgeIt; - - //we are storing the edge, so remove it from the vertex association - edges.erase(edgeIt); - - //if no more edges, remove the vertex - if ( edges.empty() ) - m_vertices.erase(iter); - - - TopoDS_Vertex V1,V2; - TopExp::Vertices(theEdge,V1,V2); - gp_Pnt P1 = BRep_Tool::Pnt(V1); - gp_Pnt P2 = BRep_Tool::Pnt(V2); - if ( theEdge.Orientation() == TopAbs_REVERSED ) - { - //switch the points - gp_Pnt tmpP = P1; - P1 = P2; - P2 = tmpP; - } - - gp_Pnt nextPoint; - if ( P2.IsEqual(point,0.2) ) - { - //need to reverse the edge - - theEdge.Reverse(); - nextPoint = P1; - } - else - { - nextPoint = P2; - } - - - //need to erase the edge from the second point - iter = m_vertices.find(nextPoint); - if ( iter != m_vertices.end() ) - { - tEdgeVector& nextEdges = iter->second; - bool somethingRemoved = false; - for ( edgeIt = nextEdges.begin() ; edgeIt != nextEdges.end(); ++edgeIt ) - { - if ( theEdge.IsSame(*edgeIt) ) - { - nextEdges.erase(edgeIt); - somethingRemoved = true; - break; - } - } - } - - //put the edge at the end of the list - m_edges.push_back(theEdge); - - - point = nextPoint; - return true; - -} - -void Edgesort::Perform(const TopoDS_Edge& edge) -{ - if ( edge.IsNull() ) - return; - TopoDS_Vertex V1,V2; - TopExp::Vertices(edge,V1,V2); - gp_Pnt P1 = BRep_Tool::Pnt(V1); - gp_Pnt P2 = BRep_Tool::Pnt(V2); - - tEdgeVector emptyList; - - std::pair iter = m_vertices.insert(tMapPntEdgePair(P1,emptyList)); - iter.first->second.push_back(edge); - iter = m_vertices.insert(tMapPntEdgePair(P2,emptyList)); - iter.first->second.push_back(edge); -} - -#include - -bool Edgesort::IsValidEdge(const TopoDS_Edge& edge) -{ - if ( edge.IsNull() ) - return false; - if ( BRep_Tool::Degenerated(edge) ) - return false; - - BRepAdaptor_Curve bac(edge); - - Standard_Real fparam = bac.FirstParameter(); - Standard_Real lparam = bac.LastParameter(); - - gp_Pnt fpoint = bac.Value(fparam); - gp_Pnt lpoint = bac.Value(lparam); - - //do not test the distance first last in case of a full circle edge (fpoint == lastpoint) - //if ( fpoint.IsEqual(lpoint,1e-5 ) ) - // return false; - - gp_Pnt mpoint = bac.Value((fparam+lparam)*0.5); - - Standard_Real dist = mpoint.Distance(lpoint); - if ( dist <= 1e-5 ) - return false; - dist = mpoint.Distance(fpoint); - if ( dist <= 1e-5 ) - return false; - - return true; -} - diff --git a/src/Mod/Cam/App/edgesort.h b/src/Mod/Cam/App/edgesort.h deleted file mode 100644 index 13c7a3369b..0000000000 --- a/src/Mod/Cam/App/edgesort.h +++ /dev/null @@ -1,100 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2007 Joachim Zettler * - * * - * This file is part of the FreeCAD CAx development system. * - * * - * This library is free software; you can redistribute it and/or * - * modify it under the terms of the GNU Library General Public * - * License as published by the Free Software Foundation; either * - * version 2 of the License, or (at your option) any later version. * - * * - * This library is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * - * GNU Library General Public License for more details. * - * * - * You should have received a copy of the GNU Library General Public * - * License along with this library; see the file COPYING.LIB. If not, * - * write to the Free Software Foundation, Inc., 59 Temple Place, * - * Suite 330, Boston, MA 02111-1307, USA * - * * - ***************************************************************************/ - -#ifndef EDGESORT_H -#define EDGESORT_H - -#include -#include -#include -#include -#include - -struct Edgesort_gp_Pnt_Less -{ - bool operator()(const gp_Pnt & _Left, const gp_Pnt & _Right) const - { - Standard_Real x1,y1,z1,x2,y2,z2; - _Left.Coord(x1,y1,z1); - _Right.Coord(x2,y2,z2); - if ( fabs(x1- x2) > 0.2 ) - return x1 < x2; - else if ( fabs(y1 -y2) > 0.2 ) - return y1 < y2; - else if ( fabs(z1 -z2) > 0.2 ) - return z1 < z2; - return false; - } -}; - -struct EdgeSortBoundBox_Less -{ - bool operator()(const Base::BoundBox3f& _Left, const Base::BoundBox3f& _Right) const - { - if (_Left.IsInBox(_Right)) return false; - - return true; - } -}; - -typedef std::vector tEdgeVector; -typedef std::map tMapPntEdge; -typedef std::pair tMapPntEdgePair; -typedef std::map,EdgeSortBoundBox_Less> tEdgeBBoxMap; -typedef std::pair >tEdgeBBoxPair; - -class Edgesort -{ -public: - Standard_EXPORT Edgesort(const TopoDS_Shape& aShape); - Standard_EXPORT virtual ~Edgesort(void); - - Standard_EXPORT void Init(); - Standard_EXPORT void ReInit(const TopoDS_Shape& aShape); - Standard_EXPORT bool More(); - Standard_EXPORT bool MoreEdge(); - Standard_EXPORT void Next(); - Standard_EXPORT const TopoDS_Edge& NextEdge(); - Standard_EXPORT const TopoDS_Edge& Current(); - Standard_EXPORT TopoDS_Shape GetDesiredCutShape(int desiredIndex); -private: - void Perform(); - void Perform(const TopoDS_Edge& edge); - bool PerformEdges(gp_Pnt& point); - bool IsValidEdge(const TopoDS_Edge& edge); - Base::BoundBox3f getBoundingBox(std::vector& aList); - - TopoDS_Shape m_shape; - - tMapPntEdge m_vertices; - tEdgeBBoxMap m_EdgeBBoxMap; - bool m_done; - bool m_asecondwire; - bool m_whichedgelist; - tEdgeVector m_edges; - //BoundingBox m_edges, m_edges2 - tEdgeVector::const_iterator m_edgeIter; - -}; - -#endif - diff --git a/src/Mod/Cam/App/mergedata.cpp b/src/Mod/Cam/App/mergedata.cpp deleted file mode 100644 index f7a8368d56..0000000000 --- a/src/Mod/Cam/App/mergedata.cpp +++ /dev/null @@ -1,106 +0,0 @@ - -#include "PreCompiled.h" -#include "mergedata.h" -#include - -#include -#include - - - -MergeData::MergeData(): -m_howmanypoints(0) -{ - -} - -MergeData::~MergeData() -{ - -} - - - - - -bool MergeData::Einlesen (const QStringList &dateinamen) -{ - for (int i=0;i * -* Copyright (c) 2007 Human Rezai * -* * -* This file is part of the FreeCAD CAx development system. * -* * -* This library is free software; you can redistribute it and/or * -* modify it under the terms of the GNU Library General Public * -* License as published by the Free Software Foundation; either * -* version 2 of the License, or (at your option) any later version. * -* * -* This library is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU Library General Public License for more details. * -* * -* You should have received a copy of the GNU Library General Public * -* License along with this library; see the file COPYING.LIB. If not, * -* write to the Free Software Foundation, Inc., 59 Temple Place, * -* Suite 330, Boston, MA 02111-1307, USA * -* * -***************************************************************************/ - - -#ifndef MERGEDATA_H -#define MERGEDATA_H - -#include -#include - -class CamExport MergeData -{ -public: - MergeData(); - ~MergeData(); - - bool WriteOutput(const QString &dateiname); - void Open(); - bool Einlesen(const QStringList &filenames); - -private: - std::vector > m_mergedvalues; - bool m_fit; - long m_howmanypoints; -}; - - -#endif \ No newline at end of file diff --git a/src/Mod/Cam/App/path_simulate.cpp b/src/Mod/Cam/App/path_simulate.cpp deleted file mode 100644 index 529949f0a5..0000000000 --- a/src/Mod/Cam/App/path_simulate.cpp +++ /dev/null @@ -1,3339 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2007 Human Rezaijafari * - * * - * This file is part of the FreeCAD CAM development system. * - * * - * This library is free software; you can redistribute it and/or * - * modify it under the terms of the GNU Library General Public * - * License as published by the Free Software Foundation; either * - * version 2 of the License, or (at your option) any later version. * - * * - * This library is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * - * GNU Library General Public License for more details. * - * * - * You should have received a copy of the GNU Library General Public * - * License along with this library; see the file COPYING.LIB. If not, * - * write to the Free Software Foundation, Inc., 59 Temple Place, * - * Suite 330, Boston, MA 02111-1307, USA * - * * - ***************************************************************************/ - -#include "PreCompiled.h" -#include "path_simulate.h" - -#include - -#include -#include -#include -#include -#include - -#define curvTOL 30.0 // indicates the maximum radius of curvature from which the curve is subdivided -#define TolDist 1.0 // corresponds to the sampling increment of the curve points for the robot output - -/* Constructor with two path sequences (master tool & supporting die) as input */ -path_simulate::path_simulate(const std::vector &BSplineTop, - const std::vector &BSplineBottom, - struct CuttingToolsSettings& set) - :m_BSplineTop(BSplineTop),m_BSplineBottom(BSplineBottom),m_set(set), - m_t0(0.0),m_step(1e-3),m_clip(90000) -{ - - m_pretension = m_set.spring_pretension; - m_blech = m_set.sheet_thickness; - m_amax = m_set.max_Acc; - m_vmax = m_set.max_Vel; - - m_single = false; - - if(m_pretension > 0) beam = true; // flag for "write_output_***" generation - else beam = false; - - //Initialize the Iterators - m_it1 = m_BSplineTop.begin(); - m_it2 = m_BSplineBottom.begin(); - - //Initialise some vars - gp_Pnt p(0,0,0); - gp_Pnt q(0,0,0); - - /*------------------------------Generate the first movement of the Master------------*/ - - /* Fill p with the starting point of the first Master curve*/ - (*m_it1)->D0((*m_it1)->FirstParameter(),p); - - /* Set q to the initial-Z-level in the Simulation: 2mm + Master-Radius over the sheet which is located at Z=0 */ - q.SetZ(2.0 + set.master_radius); - - //First we clear the vectors - m_StartPnts1.clear(); - m_StartPnts2.clear(); - - //Now we insert the start points for the Master movement - m_StartPnts1.push_back(q); - m_StartPnts1.push_back(p); - - //Inserts the start parameter - m_StartParam.push_back((*m_it1)->FirstParameter()); - - /*Master finished here*/ - - /*-----------------------------Generate the first movement for the Slave--------------*/ - - /* Fill p with the starting point of the first Slave curve*/ - (*m_it2)->D0((*m_it2)->FirstParameter(),p); - - // Set q to the initial-Z-level in the Simulation: - // -5mm - Slave-Radius-Spring-Pretensionbelow the sheet upper level which is located at Z=0 - q.SetZ(-5.0 - set.slave_radius - m_pretension); - - /*Now we insert the start points for the Slave movement*/ - m_StartPnts2.push_back(q); - m_StartPnts2.push_back(p); - - //Inserts the start parameter - m_StartParam.push_back((*m_it2)->FirstParameter()); - - /*Slave finished here*/ -} - -path_simulate::~path_simulate() -{ -} - -/* -double path_simulate::GetLength(GeomAdaptor_Curve& curve, const Standard_Real startParameter,const Standard_Real endParameter) -{ - Standard_Real firstParameter = curve.FirstParameter(); - Standard_Real lastParameter = curve.LastParameter(); - - - Standard_Real sParam = Min(startParameter,endParameter); - Standard_Real eParam = Max(startParameter,endParameter); - - //Standard_Real length = 0.0; - - if ( eParam > lastParameter ) - { - //get the first part of the length - Standard_Real l1 = GetLength(curve,firstParameter,eParam-lastParameter); - Standard_Real l2 = GetLength(curve,sParam,lastParameter); - return l1 + l2; - } - if ( sParam < firstParameter ) - { - Standard_Real l1 = GetLength(curve,lastParameter-fabs(sParam),lastParameter); - Standard_Real l2 = GetLength(curve,firstParameter,eParam); - return l1 + l2; - } - - // Accuracy control via parameter TOL according to eParam - return GCPnts_AbscissaPoint::Length(curve,sParam,eParam); -} -*/ - -/* -double path_simulate::FindParamAt(GeomAdaptor_Curve& curve, double dist, double startParam) -{ - double param; - - //compute the parameter of the next point - GCPnts_AbscissaPoint absc(curve, dist, startParam); - if ( absc.IsDone() ) - { - //the parameter is computed - param = absc.Parameter(); - } - - return param; -} -*/ - -/* The absolute speed function is defined here and provides the speed for time input . -The function is divided into three sections with the parameter limits , , , -which e.g. can be determined using path_simulate::ParameterCalculation() -The start and end speed must be determined beforehand in and -The maximum speed that is to be achieved between and corresponds here to */ -double path_simulate::GetVelocity(double t) -{ - double vel; - double c[2]; - - c[0] = m_a/2.0; - - if (t>=m_t0 && t<=m_t1) - { - if (t==m_t0 || (m_v[1] - m_v[0]) == 0.0) - { - vel = m_v[0]; - } - else - { - c[1] = PI*m_a / (m_v[1] - m_v[0]); - vel = c[0]*(sin(c[1]*(t-m_t0) - PI)/c[1] + (t-m_t0)) + m_v[0]; - } - } - else if (t>m_t1 && t<=m_t2) - { - vel = m_v[1]; - } - else if (t>m_t2 && t<=m_T) - { - if (t==m_T) - { - vel = m_v[1] - c[0]*(t-m_t2); - } - else - { - c[1] = PI*m_a / (m_v[1] - m_v[2]); - vel = m_v[1] - c[0]*(sin(c[1]*(t-m_t2) - PI)/c[1] + (t-m_t2)); - } - } - else - throw Base::RuntimeError("time input not inside [t0, T]"); - - return vel; -} - -/* This function supplies the distance covered to enter the time and - corresponds to the integral of the GetVelocity(t) function */ -double path_simulate::GetDistance(double t) -{ - double d; - double c[2]; - - c[0] = m_a/2.0; - - if (t>=m_t0 && t=m_t1 && t<=m_t2) - { - d = c[0]*pow((m_t1-m_t0),2.0)/2 + - m_v[0]*(m_t1-m_t0) + - m_v[1]*(t-m_t1); - } - else if (t>m_t2 && t<=m_T) - { - c[1] = PI*m_a / (m_v[1] - m_v[2]); - - if (t==m_T) - { - d = m_v[0]*(m_t1-m_t0) + c[0]*pow((m_t1-m_t0),2.0)/2 + - m_v[1]*(m_t2-m_t1) - c[0]*pow((t-m_t2),2.0)/2 + - m_v[1]*(t-m_t2); - } - else - { - d = m_v[0]*(m_t1-m_t0) + c[0]*pow((m_t1-m_t0),2.0)/2 + - m_v[1]*(m_t2-m_t1) + (c[0]/pow(c[1],2.0))*cos(c[1]*(t-m_t2) - PI) - - c[0]*pow((t-m_t2),2.0)/2 + - c[0]/pow(c[1],2.0) + - m_v[1]*(t-m_t2); - } - } - else - { - throw Base::RuntimeError("time input not inside [t0,T]"); - } - - return d; -} - -/* -double path_simulate::GetWireLength(TopoDS_Wire &aWire) -{ - GProp_GProps lProps; - BRepGProp::LinearProperties(aWire,lProps); - double length = lProps.Mass(); - return length; -} -*/ - -/*Parameter calculation of the speed function for a straight line of length */ -bool path_simulate::ParameterCalculation_Line(double S1) -{ - if (S1 == 0.0) // there's nothing to be done here - { - m_T = m_t0; - return true; - } - - m_a = m_amax; - - m_v[0] = 0.0; // Start speed is set to zero - m_v[1] = sqrt(m_a*S1/2.0); // Speed that is necessary so that the path at the time is reached - m_v[2] = 0.0; // Final speed is set to zero - - while(m_v[1] > m_vmax) // maximum speed must not be exceeded - { - m_a /= 2; // Retry at half acceleration - m_v[1] = sqrt(m_a*S1/2.0); // Speed that is necessary so that the path at the time is reached - } - - // Now the time limits can be calculated - m_t1 = 2*m_v[1]/m_a + m_t0; - m_t2 = m_t1; - m_T = 2*m_t1 - m_t0; - - return true; -} - -/* Parameter calculation of the speed function (defined in path_simulate::GetVelocity()) -for a curve section of length . The call must always be made before the path_simulate::GetVelocity() function */ -bool path_simulate::ParameterCalculation_Curve(double S1) -{ - // Calculating the time limits - m_t1 = m_t0 + 2*(abs(m_v[1]-m_v[0]))/m_a; - m_t2 = m_t1; - m_T = m_t1 + 2*(abs(m_v[1]-m_v[2]))/m_a; - - double tmp, v_tmp; - tmp = GetDistance(m_T); // returns the path that, under the given parameter settings, - // to accelerate up and down, at least is necessary - - if (tmp <= S1) // i.e. the path is sufficient - { - m_t2 = m_t1 + (S1 - tmp)/m_v[1]; // between and the curve is traversed - // at the constant speed - } - else // Path is not sufficient -> parameter correction - { - // Calculate the speed that is at least necessary so that the path at time is reached - m_v[1] = sqrt((m_a*S1 + m_v[0]*m_v[0] + m_v[2]*m_v[2])/2.0); - m_t1 = m_t0 + 2*(abs(m_v[1]-m_v[0]))/m_a; - m_t2 = m_t1; - - // a correction may be required here - if(m_v[1] > m_vmax) - { - m_v[1] = m_vmax; - - // from here on again as above - m_t1 = m_t0 + 2*(abs(m_v[1]-m_v[0]))/m_a; - m_t2 = m_t1; - m_T = m_t1 + 2*(abs(m_v[1]-m_v[2]))/m_a; - - tmp = GetDistance(m_T); - - if (tmp <= S1) - { - m_t2 = m_t1 + (S1 - tmp)/m_v[1]; - } - else - { - v_tmp = (m_vmax - std::min(m_v[1],m_v[2]))/2.0; - - while(tmp > S1) // here the speed is reduced in the direction - { // until the path is sufficient - m_v[1] = std::min(m_v[1],m_v[2]) + v_tmp; - - m_t1 = m_t0 + 2*(abs(m_v[1]-m_v[0]))/m_a; - m_t2 = m_t1; - m_T = m_t1 + 2*(abs(m_v[1]-m_v[2]))/m_a; - - tmp = GetDistance(m_T); - - v_tmp /= 2.0; - } - } - } - } - - m_T = m_t2 + 2*(abs(m_v[1]-m_v[2]))/m_a; // End time can now be calculated - - return true; -} - -// resets the output vectors and the acceleration parameter . The start time is updated -bool path_simulate::UpdateParam() -{ - m_Output.clear(); - m_Output2.clear(); - m_Output_time.clear(); - m_Output_time2.clear(); - - m_t0 = m_T; // The end time of the last run will become the new start time - m_a = m_amax; - - return true; -} - -/* Auxiliary function for the delivery. Return value defines whether delivery is first made in the z or xy direction*/ -bool path_simulate::CheckConnect() -{ - gp_Pnt tmp; - - // from the 2nd run - if (m_it1 != m_BSplineTop.begin() || m_it2 != m_BSplineBottom.begin()) - { - m_StartPnts1.clear(); - m_StartPnts2.clear(); - - // Calculate new connecting points for the delivery - MASTER - - m_it1--; - - (*m_it1)->D0((*m_it1)->LastParameter(),tmp); // Saves the end point of the previous Master curve in - m_StartPnts1.push_back(tmp); // Push end point of previous Master curve - - m_it1++; - - (*m_it1)->D0((*m_it1)->FirstParameter(),tmp); // Saves the starting point of the previous Mlave curve in - m_StartPnts1.push_back(tmp); // Push start point of the current Master curve - - if (m_single == false) // If both sides are driven, do the same as for the slave (see above) - { - // Calculate new connecting points for the delivery - SLAVE - - m_it2--; - - (*m_it2)->D0((*m_it2)->LastParameter(),tmp); // Saves the starting point of the previous Slave curve in - m_StartPnts2.push_back(tmp); // Push end point of previous Slave curve - - m_it2++; - - (*m_it2)->D0((*m_it2)->FirstParameter(),tmp); // Speichert Startpunkt der aktuellen Slave-Kurve in - m_StartPnts2.push_back(tmp); // Push start point of the current Slave curve - } - } - else - { - return true; // The first delivery is always the same (in the negative z-direction) - } - - if (m_StartPnts1[0].Z() - m_StartPnts1[1].Z() >= 0.0) return true; // Infeed in the negative z-direction - else return false; // Infeed in the positive z-direction -} - -/* Auxiliary function for the delivery. Return value defines whether delivery is first made in the z or xy direction*/ -bool path_simulate::CheckConnect(bool tool) -{ - gp_Pnt tmp; - - // from the 2nd run - if (m_it1 != m_BSplineTop.begin() || m_it2 != m_BSplineBottom.begin()) - { - if (m_Feat == true) // For the feature-based case, the deliveries from Master and Slave are treated separately - { - if (!tool) - { - m_StartPnts1.clear(); - - m_it1--; - - (*m_it1)->D0((*m_it1)->LastParameter(),tmp); - m_StartPnts1.push_back(tmp); // Start point - - m_it1++; - - (*m_it1)->D0((*m_it1)->FirstParameter(),tmp); - m_StartPnts1.push_back(tmp); // Target point - - if(m_StartPnts1[0].Z() - m_StartPnts1[1].Z() >= 0.0) return true; - else return false; - } - else - { - m_StartPnts2.clear(); - - m_it2--; - (*m_it2)->D0((*m_it2)->LastParameter(),tmp); - m_it2++; - m_StartPnts2.push_back(tmp); // Start point - - (*m_it2)->D0((*m_it2)->FirstParameter(),tmp); - m_StartPnts2.push_back(tmp); // Target point - - if(m_StartPnts2[0].Z() - m_StartPnts2[1].Z() >= 0.0) return true; - else return false; - } - } - - // From here: Calculation of the infeed vectors for the synchronous infeed of Master and Slave - m_StartPnts1.clear(); - m_StartPnts2.clear(); - - // Calculate new connecting points for the delivery - MASTER - m_it1--; - - (*m_it1)->D0((*m_it1)->LastParameter(),tmp); - m_StartPnts1.push_back(tmp); // Start point - - m_it1++; - - (*m_it1)->D0((*m_it1)->FirstParameter(),tmp); - m_StartPnts1.push_back(tmp); // Target point - - if (m_single == false) - { - // Calculate new connecting points for the delivery - SLAVE - m_it2--; - - (*m_it2)->D0((*m_it2)->LastParameter(),tmp); - m_StartPnts2.push_back(tmp); // Start point - - m_it2++; - - (*m_it2)->D0((*m_it2)->FirstParameter(),tmp); - m_StartPnts2.push_back(tmp); // Target point - } - } - else - { - return true; // The first delivery is always the same - } - - if (m_StartPnts1[0].Z() - m_StartPnts1[1].Z() >= 0.0) return true; - else return false; -} - -/* Fills the output vectors for the first delivery. The input parameter defines the type of output*/ -bool path_simulate::ConnectPaths_xy(bool brob) -{ - int N; - double t = m_t0; - - std::vector tmp2; - std::vector d; - Base::Vector3d tmp; - - gp_Pnt tmpPnt, pnt1, pnt2, p; - gp_Vec vec_t(m_StartPnts1[0], m_StartPnts1[1]); - - if( 1e-3 > vec_t.Magnitude()) // no delivery necessary - return true; - - if (m_single == false) - { - gp_Vec vec_1(m_StartPnts1[0], m_StartPnts1[1]); - gp_Vec vec_2(m_StartPnts2[0], m_StartPnts2[1]); - - gp_Vec2d vec_11, // Saves Master infeed in the XY-direction - vec_21; // Saves Master infeed in the Z-direction - - vec_11.SetX(vec_1.X()); - vec_11.SetY(vec_1.Y()); - - if (m_it1 == m_BSplineTop.begin() && m_it2 == m_BSplineBottom.begin()) // first run -> xy delivery (Slave) - { - vec_21.SetX(vec_2.X()); - vec_21.SetY(vec_2.Y()); - } - else - { - vec_21.SetX(0.0); - vec_21.SetY(vec_2.Z()); // slave delivery in the z-direction (from 2nd run) - } - - // Simulation output - if (brob == false) - { - // ***** MASTER ****** - - ParameterCalculation_Line(vec_11.Magnitude()); - - if (vec_11.Magnitude() != 0) - vec_11.Normalize(); - - N = std::max(2, int(ceil((m_T - m_t0)/m_step))); // Number of output values to be generated - m_del_t = (m_T - m_t0)/N; // Time increment - - for (int i=0; i of the points for the discretization of the infeed line - if (vec_11.Magnitude() > vec_21.Magnitude()) N = std::max(2, int(ceil(vec_21.Magnitude()/TolDist))); - else N = std::max(2, int(ceil(vec_11.Magnitude()/TolDist))); - - if (vec_11.Magnitude() == 0.0 && vec_21.Magnitude() == 0.0) N=0; - if (!m_conn) con = true; - - // The first point is always omitted - if (m_it1 == m_BSplineTop.begin() && m_it2 == m_BSplineBottom.begin()) - { - // Start point Master - tmp.x = m_StartPnts1[0].X(); - tmp.y = m_StartPnts1[0].Y(); - tmp.z = m_StartPnts1[0].Z(); - - m_Output_robo1.push_back(tmp); - RoboFlag_Master.push_back(0); - - // Start point Slave - tmp.x = m_StartPnts2[0].X(); - tmp.y = m_StartPnts2[0].Y(); - tmp.z = m_StartPnts2[0].Z(); - - m_Output_robo2.push_back(tmp); - RoboFlag_Slave.push_back(0); - } - - // Generate Output - MASTER - for (int i=1; i defines the output type*/ -bool path_simulate::ConnectPaths_z(bool brob) -{ - int N; - double t = m_t0; - - Base::Vector3d tmp; - std::vector d; - std::vector tmp2; - - gp_Vec vec_t(m_StartPnts1[0], m_StartPnts1[1]); - if( 1e-3 > vec_t.Magnitude()) - return true; - - if (m_single == false) - { - gp_Vec vec_1(m_StartPnts1[0], m_StartPnts1[1]); - gp_Vec vec_2(m_StartPnts2[0], m_StartPnts2[1]); - - gp_Vec2d vec_11,vec_12; - - vec_11.SetX(0.0); - vec_11.SetY(vec_1.Z()); - - if (m_it1 == m_BSplineTop.begin() && m_it2 == m_BSplineBottom.begin()) - { - vec_12.SetX(0.0); - vec_12.SetY(vec_2.Z()); - } - else - { - vec_12.SetX(vec_2.X()); - vec_12.SetY(vec_2.Y()); - } - - if (brob == false) - { - // ***** MASTER ****** - ParameterCalculation_Line(vec_11.Magnitude()); - - if (vec_11.Magnitude() != 0) - vec_11.Normalize(); - - N = std::max(2, int(ceil((m_T - m_t0)/m_step))); // Number of output values to be generated - m_del_t = (m_T - m_t0)/N; // Time increment - - for (int i=0; i vec_12.Magnitude()) std::max(2, N = int(ceil(vec_12.Magnitude()/TolDist))); // Number of output values to be generated - else std::max(2, N = int(ceil(vec_11.Magnitude()/TolDist))); // Number of output values to be generated - - if (vec_11.Magnitude() == 0.0 && vec_12.Magnitude() == 0.0) N=1; - - for (int i=1; i defines the type of output*/ -bool path_simulate::ConnectPaths_Feat(bool tool, // Tool (Master, Slave) - bool brob, // Output type (Robot, Simulation) - bool c_typ) // Delivery type (in two or three steps) -{ - int N, ind; - double rad, t; - bool dir; - - std::vector Times; - std::vector ConnPnts; - std::vector< std::vector > Out; - gp_Vec vec[3], vec_tmp[3]; - - Base::Vector3d tmp; - std::vector d; - std::vector tmp2; - double vel; - - dir = CheckConnect(tool); // set new starting points - - if (!tool) - { - ConnPnts = m_StartPnts1; - rad = m_set.master_radius; - } - else - { - ConnPnts = m_StartPnts2; - rad = m_set.slave_radius; - } - - if (c_typ) // Delivery in 2 steps - { - ind = 2; - vec_tmp[0].SetCoord(0.0, 0.0, abs(ConnPnts[1].Z()-ConnPnts[0].Z())); - vec_tmp[1].SetCoord(ConnPnts[1].X()-ConnPnts[0].X(), ConnPnts[1].Y()-ConnPnts[0].Y(), 0.0); - - if (dir) // tool (Master/Slave) must go down - { - if (!tool) - { - vec[0] = vec_tmp[1]; // tool = Master - vec[1] = -vec_tmp[0]; - } - else - { - vec[0] = -vec_tmp[0]; // tool = Slave - vec[1] = vec_tmp[1]; - } - } - else // tool (Master/Slave) must go up - { - if (!tool) - { - vec[0] = vec_tmp[0]; // tool = Master - vec[1] = vec_tmp[1]; - } - else - { - vec[0] = vec_tmp[1]; // tool = Slave - vec[1] = vec_tmp[0]; - } - } - } - else // Delivery in 3 steps - { - ind = 3; - - vec_tmp[0].SetCoord(0.0, 0.0, rad); - vec_tmp[1].SetCoord(ConnPnts[1].X()-ConnPnts[0].X(), ConnPnts[1].Y()-ConnPnts[0].Y(), 0.0); - vec_tmp[2].SetCoord(0.0, 0.0, abs(ConnPnts[1].Z()-ConnPnts[0].Z()) + rad); - - if (dir) // tool (Master/Slave) must go down - { - if (!tool) - { - vec[0] = vec_tmp[0]; // tool = Master - vec[1] = vec_tmp[1]; - vec[2] = -vec_tmp[2]; - } - else - { - vec[0] = -vec_tmp[2]; // tool = Slave - vec[1] = vec_tmp[1]; - vec[2] = vec_tmp[0]; - } - } - else // tool (Master/Slave) must go up - { - if (!tool) - { - vec[0] = vec_tmp[2]; // tool = Master - vec[1] = vec_tmp[1]; - vec[2] = -vec_tmp[0]; - } - else - { - vec[0] = -vec_tmp[0]; // tool = Slave - vec[1] = vec_tmp[1]; - vec[2] = vec_tmp[2]; - } - } - } - - if (brob) // Robot output - { - for (int i=0; i curvature tolerance. -The range limits are returned in the return vector. The output vector is empty when the maximum curvature -does not exceed the tolerance value and therefore no subdivision is necessary */ -std::vector > path_simulate::CompBounds(bool tool,std::vector knots) -{ - m_curMax = 0.0; // set maximum curvature initially to zero - double cr_bound = 1/curvTOL; - double cr_last; - gp_Vec dtmp1, dtmp2; - gp_Pnt dtmp0; - GeomAdaptor_Curve curve; - std::vector single_bound; - std::vector bounds; - std::vector > CriticalBounds; - - // load current curve - if (!tool) curve.Load(*m_it1); - else curve.Load(*m_it2); - - double fParam = curve.FirstParameter(), // First curve parameter - lParam = curve.LastParameter(), // Last curve parameter - period = lParam - fParam; // Length of the parameter range - - - int n = knots.size(); // Length of the knot vector - bool b = false; - - // The maximum curvature is calculated here - // The parameters of the range limits at which the curvature of the curve corresponds to the tolerance - // value corresponds to are filled into the vector for further post-processing - for (int i=0; i= cr_bound && !b) - { - if(knots[i] >= m_boundTol && knots[i] < lParam - m_boundTol) - { - if(cr_last < cr_bound) - { - bounds.push_back(knots[i-1] + (knots[i] - knots[i-1])* - (cr_last - cr_bound)/ - (cr_last - dtmp2.Magnitude())); - } - else - { - bounds.push_back(fParam + m_boundTol); - } - b = true; - } - } - - if(dtmp2.Magnitude() < cr_bound && b) - { - if(knots[i] <= lParam - m_boundTol) - { - bounds.push_back(knots[i-1] + (knots[i] - knots[i-1])* - (cr_bound - cr_last)/ - (dtmp2.Magnitude() - cr_last)); - } - else - { - bounds.push_back(lParam - m_boundTol); - - } - b = false; - } - - cr_last = dtmp2.Magnitude(); // The curvature here corresponds to the amount of the second derivative - - if(m_curMax < cr_last) // Stores maximum curvature - m_curMax = cr_last; - } - - if(period < 2*m_boundTol || bounds.size() == 0) - return CriticalBounds; - - if(b) bounds.push_back(lParam - m_boundTol); // The last limit may have to be added here - - n = (int) bounds.size()/2; // is always of even length - for(int i=0; i - { - single_bound.push_back(bounds[2*i]); - - while(i, , are filled for the current curve. */ -bool path_simulate::CompPath(bool tool) // tool = 0 -> Master - // tool = 1 -> Slave -{ - m_boundTol = pow(m_vmax, 2.0)/m_amax; // Tolerance range in front of critical areas (necessary for high acceleration) - - double cur = 1.0/curvTOL, // Curvature tolerance for curve division - pos = 0.0, - cur_tmp = 0.0; - - int nb_knots; - - std::vector > v_vec; - std::vector v(3), l_vec, a_vec; - - std::vector Pnt1Vec; - - GeomAdaptor_Curve curve; - - gp_Pnt pnt0; - gp_Vec pnt, pnt1, pnt2, vec; - Base::Vector3d Pnt1; - - double start, - fParam, - lParam, - period; - - double d2, velo, tetha, - len, len_1; - - double t0 = m_t0; // Returns the current start time - - int num = Detect_FeatCurve(tool); // Returns the number of curves to be driven (usually num = 1) - - for(int a=0; aNbKnots(); - m_Knots = new TColStd_Array1OfReal(0,nb_knots-1); - (*m_it1)->Knots(*m_Knots); - } - else - { - nb_knots = (*m_it2)->NbKnots(); - m_Knots = new TColStd_Array1OfReal(0,nb_knots-1); - (*m_it2)->Knots(*m_Knots); - } - - std::vector knot_vec(m_Knots->Length()); - for(int i=0; iLength(); i++) - knot_vec[i] = m_Knots->Value(i); - - // *** End of the calculation of the Knot vectors *** - - - std::vector > CriticalBounds = - CompBounds(tool, knot_vec); // Calculated on the basis of the current curve, - // the critical areas in the parameter space and - // simultaneously calculates the maximum curvature - - m_vmid = std::min(m_vmax,sqrt(m_amax/m_curMax)); // Defines the speed with which all critical areas are traveled - -Newtry: // If the generated path lengths are insufficient, a new attempt is started with half the - - v[0] = 0.0; // start every curve with v = 0 - int m = 0; - - for (unsigned int i=0; iValue(m); - - while(pos < m_StartParam[tool]) - { - m++; - pos = m_Knots->Value(m); - } - - /*------------------- Straight section ---------------------*/ - - while(pos < CriticalBounds[i][0]) // Calculate the maximum curvature of this straight section - { - curve.D2(pos, pnt0, pnt1, pnt2); - cur_tmp = pnt2.Magnitude(); // Curvature at the current point - - if(d2 < cur_tmp) - d2 = cur_tmp; // Stores maximum curvature dieses geraden Bereichs - - m++; - pos = m_Knots->Value(m); - } - - tetha = 0.6 + 0.25*sqrt(d2/m_curMax); // Set tetha parameter -> (0.6 < tetha < 0.85) - velo = std::min(m_vmax, tetha*(sqrt(m_amax/d2))); // Sets maximum speed - m_a = m_amax - d2*velo*velo; // if was chosen too large, can possibly become negative - - // Correction - while(m_a <= 0.0) - { - velo = velo/2.0; - m_a = m_amax - d2*velo*velo; - } - - if(velo < m_vmid) - m_vmid = velo; - - v[1] = velo; - - /*-------------- Correction of the speeds (if the path is too long) -------------*/ - - len = CriticalBounds[i][0] - m_StartParam[tool]; // Length of the i. straight section - len_1 = (pow(v[1] - v[0],2.0) + pow(v[1] - m_vmid,2.0))/m_a; // necessary length - - if(len < pow(v[0] - m_vmid,2.0)/m_a) // no correction is possible in this case - { - l_vec.clear(); - v_vec.clear(); - a_vec.clear(); - - m_StartParam[tool] = start; // reset start parameters - m_vmid = m_vmid/2; // halve critical throughput speed - goto Newtry; - } - - while(len < len_1) - { - v[1] = v[0] + (v[1] - v[0])/2.0; - len_1 = (pow(v[1] - v[0],2.0) + pow(v[1] - m_vmid,2.0))/m_a; - } - - v[2] = m_vmid; - - /*---Correction end---*/ - - // fill Vectors - l_vec.push_back(len); // Length - v_vec.push_back(v); // Speeds - a_vec.push_back(m_a); // Acceleration - - m_StartParam[tool] += len; // Sets new start parameters - - /*------------------------ curved area ------------------------*/ - - len = CriticalBounds[i][1] - CriticalBounds[i][0]; // Arc length of the curved area - m_StartParam[tool] += len; // Sets new start parameters - v[0] = v[2]; // End speed becomes the start speed - - l_vec.push_back(len); - } - - d2 = 0; - - // Correct the current knot parameter - while(pos < m_StartParam[tool]) - { - m++; - pos = m_Knots->Value(m); - } - - pos = m_Knots->Value(m); - - // Calculation of the maximum curvature for the last section - while(pos < lParam) - { - curve.D2(pos, pnt0, pnt1, pnt2); - - Pnt1.x = pnt2.X(); - Pnt1.y = pnt2.Y(); - Pnt1.z = pnt2.Z(); - - if(d2 < Pnt1.Length()) d2 = Pnt1.Length(); - - m++; - pos = m_Knots->Value(m); - } - - tetha = 0.6 + 0.25*sqrt(d2/m_curMax); // 0.6 < tetha < 0.85 - velo = std::min(m_vmax, tetha*(sqrt(m_amax/d2))); // see above - - v[1] = velo; - v[2] = 0.0; - m_a = m_amax - d2*velo*velo; // if velo is too large, m_a can become negative - - // Correction - while(m_a <= 0.0) - { - velo = velo/2.0; - v[1] = velo; - m_a = m_amax - cur*velo*velo; - } - - d2 = 0; - - len = lParam - m_StartParam[tool] + start; // Length of the last straight section - len_1 = (pow(v[1] - v[0],2.0) + pow(v[1],2.0))/m_a; // required length - - if(len < pow(v[0],2.0)/m_a) // no correction possible here - { - l_vec.clear(); - v_vec.clear(); - a_vec.clear(); - - m_StartParam[tool] = start; // reset start parameters - m_vmid = m_vmid/2; // halve critical speed and try again - goto Newtry; - } - - while(len < len_1) - { - v[1] = v[0] + (v[1] - v[0])/2; - len_1 = (pow(v[1] - v[0],2.0) + pow(v[1],2.0))/m_a; - } - - // fill Vectors - l_vec.push_back(len); // Length - v_vec.push_back(v); // Speeds - a_vec.push_back(m_a); // Acceleration - - // First fill the output vectors here (once per curve) - if(tool) - { - m_length_sl.push_back(l_vec); - m_velocity_sl.push_back(v_vec); - m_accel_sl.push_back(a_vec); - } - else - { - m_length_ma.push_back(l_vec); - m_velocity_ma.push_back(v_vec); - m_accel_ma.push_back(a_vec); - } - - // load current curves - if (!tool) m_it1++; - else m_it2++; - - m_StartParam[tool] = start; - - l_vec.clear(); - v_vec.clear(); - a_vec.clear(); - - curve.Delete(); - CriticalBounds.clear(); - } - - // Reset iterator and start parameters - if (!tool) - { - for(int i=0; iFirstParameter(); - - } - else - { - for(int i=0; iFirstParameter(); - } - - return true; -} - -/* Only integrates the output values according to the time according to the trapezoid rule and delivers the error vector as a connection between the start and end point. -Finally, the output vectors are corrected by precisely this error vector */ -bool path_simulate::Correction(bool tool) -{ - int N; - gp_Vec vec; - gp_Pnt pnt; - Base::Vector3d tmp; - std::vector tmp2; - - double Sum[3]; - - Sum[0] = 0.0; - Sum[1] = 0.0; - Sum[2] = 0.0; - - // Here the numerical integration of the output vector takes place according to the - // trapezoidal rule and the resulting error vector is stored in - if (tool==false) // Master - { - N = m_Output.size(); - for (int i=1; i 1e-3) // if curve is NOT closed - { - vec.SetCoord(Sum[0],Sum[1],Sum[2]); - vec.SetCoord(m_StartPnts1[1].X() - m_StartPnts1[0].X() - vec.X(), - m_StartPnts1[1].Y() - m_StartPnts1[0].Y() - vec.Y(), - m_StartPnts1[1].Z() - m_StartPnts1[0].Z() - vec.Z()); - } - else - vec.SetCoord(-Sum[0],-Sum[1],-Sum[2]); - } - else // Slave - { - N = m_Output2.size(); - for (int i=1; i 1e-3) // if curve is NOT closed - { - vec.SetCoord(Sum[0],Sum[1],Sum[2]); - vec.SetCoord(m_StartPnts2[1].X() - m_StartPnts2[0].X() - vec.X(), - m_StartPnts2[1].Y() - m_StartPnts2[0].Y() - vec.Y(), - m_StartPnts2[1].Z() - m_StartPnts2[0].Z() - vec.Z()); - } - else - vec.SetCoord(-Sum[0],-Sum[1],-Sum[2]); - } - - ParameterCalculation_Line(vec.Magnitude()); // Calculating the time limits - - N = (int) ceil((m_T - m_t0)/m_step); // Number of output values to be generated - m_del_t = (m_T - m_t0)/N; // Time increment - - if (N==1) // One output vector only - { - m_T = m_t0 + 2e-3; - - if (tool==false) // Master - { - m_Output_time.push_back(m_t0); - m_Output_time.push_back(m_t0 + 1e-3); - } - else // Slave - { - m_Output_time2.push_back(m_t0); - m_Output_time2.push_back(m_t0 + 1e-3); - } - - tmp.x = 0.0; - tmp.y = 0.0; - tmp.z = 0.0; - - tmp2.push_back(tmp); - - if(tool==false) m_Output.push_back(tmp2); // fills Master-Output - else m_Output2.push_back(tmp2); // fills Slave-Output - - tmp2.clear(); - - tmp.x = (vec.X()/vec.Magnitude())*(vec.X()/1e-3); - tmp.y = (vec.Y()/vec.Magnitude())*(vec.Y()/1e-3); - tmp.z = (vec.Z()/vec.Magnitude())*(vec.Z()/1e-3); - - tmp2.push_back(tmp); - - if (tool==false) m_Output.push_back(tmp2); - else m_Output2.push_back(tmp2); - - tmp2.clear(); - } - else - { - double vel,t = m_t0; - if (vec.Magnitude() != 0) vec.Normalize(); - - for (int i=0; i - tmp.x = vec.X()*vel; - tmp.y = vec.Y()*vel; - tmp.z = vec.Z()*vel; - - tmp2.push_back(tmp); - - if (tool==false) m_Output.push_back(tmp2); - else m_Output2.push_back(tmp2); - - t += m_del_t; - tmp2.clear(); - } - } - - // Null vector - tmp.x = 0.0; - tmp.y = 0.0; - tmp.z = 0.0; - - tmp2.push_back(tmp); - - // Pass null vector at end time - if (tool==false) - { - m_Output.push_back(tmp2); - m_Output_time.push_back(m_T); - } - else - { - m_Output2.push_back(tmp2); - m_Output_time2.push_back(m_T); - } - - return true; -} -// This is where the actual output for the simulation process is generated, taking into account -// the vectors calculated in CompPath() m_velocity, m_accel, m_length -bool path_simulate::Gen_Path() -{ - int n,m; - double length, lam, t_start, t_ma, t_sl, t_tmp; - - t_start = m_t0; // Set start time - m_StartPnts1[0] = (*m_it1)->StartPoint(); // Set Start parameters - - if(m_single == false) - { - m_StartPnts2[0] = (*m_it2)->StartPoint(); - -/*------------------------------ Calculate lead time for the Master tool --------------------------------*/ - - n = m_velocity_ma.size(); - for(int i=0; i is calculated here - - if(j != m-1) - { - length = m_length_sl[i][2*j+1];// Length of the critical section - m_T = m_T + length/m_v[2]; // Calculates new end time (critical sections are run through at - } // the constant speed ) - - m_t0 = m_T; // End time becomes start time - } - } - - t_sl = m_T - t_start; // Corresponds to the processing time for the Slave - m_t0 = t_start; // Resets the start time - -/*----------------------- Synchronization of Master and Slave -----------------------------*/ - -// Idea: scale the speeds and accelerations of the path with the shorter processing time, -// so that the processing times for master and slave match - - - if(t_ma <= t_sl) - { - // From here on: Correction for the master - - lam = t_ma/t_sl; // Scaling factor 0 < lam <= 1 - - // First of all, all speeds are scaled down - n = m_velocity_ma.size(); - for(int i=0; iFirstParameter(); // Sets the start parameters of the current curve - - m = m_length_ma[i].size(); - for(int j=0; jFirstParameter(); - m = m_length_sl[i].size(); - - // see Master - for(int j=0; jEndPoint(); // Sets the end point, necessary for the following path correction - Correction(0); // Path correction for the Master - - if(m_single == false) - { - m_t0 = t_tmp; - m_StartPnts2[1] = (*m_it2)->EndPoint(); // Sets the end point, necessary for the following path correction - Correction(1); // Path correction for the Slave - } - - m_t0 = t_start; - -/*END PATH CORRECTION*/ - - - m_velocity_ma.clear(); - m_velocity_sl.clear(); - m_length_ma.clear(); - m_length_sl.clear(); - m_accel_ma.clear(); - m_accel_sl.clear(); - - return true; -} - -/* The simulation output vectors for the respective curve sections are generated here */ -bool path_simulate::MakePathSingle(bool brob, // Describes output type (Robot, Simulation) - double length, // Arc length of the considered section - bool part, // Specifies whether we are looking at a critical section - bool tool) // Tool (Master, Slave) -{ - GeomAdaptor_Curve anAdaptorCurve; - double firstParam, lastParam, param, period, d, velo; - int N; - - if(tool == false) anAdaptorCurve.Load(*m_it1); // Master - else anAdaptorCurve.Load(*m_it2); // Slave - - firstParam = anAdaptorCurve.FirstParameter(); - lastParam = anAdaptorCurve.LastParameter(); - period = lastParam - firstParam; - - gp_Vec dtmp1, dtmp2; - gp_Pnt tmp; - Base::Vector3d tmp2; - std::vector tmp3; - - // Base::Vector3f pnt1,pnt2; - - if(brob) - { - N = std::max(2, (int) ceil(period / double(TolDist))); - - for (int i=1; i lastParam) - { - anAdaptorCurve.D0(m_StartParam[tool] + double(i)*period/(double(N)-1.0) - period, tmp); - } - else if (m_StartParam[tool] + double(i)*period/(double(N)-1.0) < firstParam ) - { - anAdaptorCurve.D0(m_StartParam[tool] + double(i)*period/(double(N)-1.0) + period, tmp); - } - else - { - anAdaptorCurve.D0(m_StartParam[tool] + double(i)*period/(double(N)-1.0), tmp); - } - - tmp2.x = tmp.X(); - tmp2.y = tmp.Y(); - tmp2.z = tmp.Z(); - - if (!tool) - { - m_Output_robo1.push_back(tmp2); - - if (i==1) - { - RoboFlag_Master.pop_back(); - RoboFlag_Master.push_back(1); - } - - RoboFlag_Master.push_back(0); - } - else - { - m_Output_robo2.push_back(tmp2); - - if (i==1) - { - RoboFlag_Slave.pop_back(); - RoboFlag_Slave.push_back(1); - } - - RoboFlag_Slave.push_back(0); - } - } - - return true; - } - - if (part==true) m_T = m_t0 + length/m_v[2]; // critical areas are traversed at a constant speed - else ParameterCalculation_Curve(length); - - N = std::max(2, (int)((m_T-m_t0)/m_step)); - - if (N>=100000) - N = 99999; // maximum number of possible output values - - m_del_t = (m_T-m_t0)/double(N); - - std::vector< std::vector > D0; - std::vector< std::vector > D1; - - double t = m_t0; - - //anAdaptorCurve.D0(m_StartParam[tool],tmp); - //pnt2.Set(tmp.X(),tmp.Y(),tmp.Z()); - - if (part == true) // critical section - { - for (int i=0; i lastParam ){ anAdaptorCurve.D2(param - period, tmp, dtmp1, dtmp2);} - else if ( param < firstParam ){ anAdaptorCurve.D2(param + period, tmp, dtmp1, dtmp2);} - else { anAdaptorCurve.D2(param, tmp, dtmp1, dtmp2);} - - //m_times_tmp.push_back(t); - //m_velo_tmp.push_back(m_v[2]); - - // Output vector at the point in time - tmp2.x = dtmp1.X()*m_v[2]; - tmp2.y = dtmp1.Y()*m_v[2]; - tmp2.z = dtmp1.Z()*m_v[2]; - - tmp3.push_back(tmp2); - - if (!tool) m_Output.push_back(tmp3); - else m_Output2.push_back(tmp3); - - tmp3.clear(); - - /* - if (tool == false) // traces the actual path - { - pnt1 = pnt2; - - pnt2.x = pnt2.x + dtmp1.X()*m_v[2]*m_del_t; - pnt2.y = pnt2.y + dtmp1.Y()*m_v[2]*m_del_t; - pnt2.z = pnt2.z + dtmp1.Z()*m_v[2]*m_del_t; - - if(i==0) - m_log.addSingleArrow(pnt1,pnt2,2,1,1,1); - else - m_log.addSingleArrow(pnt1,pnt2,2,1,0,0); - } - */ - - t += m_del_t; - } - return true; - } - - // uncritical section - for (int i=0; i lastParam ){ anAdaptorCurve.D2(param - period, tmp, dtmp1, dtmp2);} - else if ( param < firstParam ){ anAdaptorCurve.D2(param + period, tmp, dtmp1, dtmp2);} - else { anAdaptorCurve.D2(param, tmp, dtmp1, dtmp2);} - - velo = GetVelocity(t); // Calculates the speed of the tool at the point in time - // with respect to the parameters m_t0, m_t1, m_t2, m_T, m_a, m_v[i], i =1,2,3 - - // Output vector at the point in time - tmp2.x = dtmp1.X()*velo; - tmp2.y = dtmp1.Y()*velo; - tmp2.z = dtmp1.Z()*velo; - - tmp3.push_back(tmp2); - - if (!tool) m_Output.push_back(tmp3); - else m_Output2.push_back(tmp3); - - tmp3.clear(); - - / - if (tool == false) // traces the actual path - { - pnt1 = pnt2; - - pnt2.x = pnt2.x + dtmp1.X()*velo*m_del_t; - pnt2.y = pnt2.y + dtmp1.Y()*velo*m_del_t; - pnt2.z = pnt2.z + dtmp1.Z()*velo*m_del_t; - - if(i==0) - m_log.addSingleArrow(pnt1,pnt2,2,1,1,1); - else - m_log.addSingleArrow(pnt1,pnt2,2,1,0,0); - } - */ - - //m_times_tmp.push_back(t); - //m_velo_tmp.push_back(velo); - - t += m_del_t; - } - - return true; -} - -/* Main routine for generating the robot output for the normal two-sided case */ -bool path_simulate::MakePathRobot() -{ - ofstream anOutputFile; - ofstream anOutputFile2; - - anOutputFile.open("output_master.k"); - anOutputFile.precision(7); - - anOutputFile << "none" << std::endl; - - if (m_single == false) - { - anOutputFile2.open("output_slave.k"); - anOutputFile2.precision(7); - - anOutputFile2 << "none" << std::endl; - } - - // Output generation across all curves - for (m_it1 = m_BSplineTop.begin(); m_it1 != m_BSplineTop.end(); ++m_it1) - { - m_StartParam[0] = ((*m_it1)->FirstParameter()); - if (m_single == false) m_StartParam[1] = ((*m_it2)->FirstParameter()); - - /*------ 1.DELIVERY ------*/ - - m_conn = CheckConnect(); - - if (m_conn) ConnectPaths_xy(1); - else ConnectPaths_z(1); - - UpdateParam(); - - - /*------ 2.DELIVERY ------*/ - - if (m_conn) ConnectPaths_z(1); - else ConnectPaths_xy(1); - - UpdateParam(); - - - /*------ CURVE ------*/ - - MakePathSingle(1,0,0,0); // Master - MakePathSingle(1,0,0,1); // Slave - UpdateParam(); - - if (m_single==false && (m_it1 != (m_BSplineTop.end()-1))) - ++m_it2; - - } - - int c = 1; - - /*--- Write robot output ---*/ - - if (m_single==false) - { - WriteOutputDouble(anOutputFile,anOutputFile2,c,c,1,beam); - anOutputFile2 << "*END" << endl; - anOutputFile2.close(); - } - else - { - WriteOutputSingle(anOutputFile,c,1,0,beam); - } - - anOutputFile << "*END" << endl; - anOutputFile.close(); - - return true; -} - -// Is only called at the beginning of the writing in path_simulate::WriteOurputDouble() -// and fits the output vectors , in such a way that the end times coincide -bool path_simulate::TimeCorrection() -{ - int N; - Base::Vector3d vec(0.0,0.0,0.0); - std::vector vecc; - - vecc.push_back(vec); - - if (m_single == false) // A time correction makes sense only in this case - { - if(m_Output_time.size() == 0 || m_Output_time2.size() == 0) // Special treatment for this case - { - if(m_Output_time.size() > m_Output_time2.size()) - { - m_Output_time2 = m_Output_time; - N = m_Output_time2.size(); - m_Output2.resize(N); - - for (int i=0; i m_Output_time.size()) - { - m_Output_time = m_Output_time2; - N = m_Output_time.size(); - m_Output.resize(N); - - for (int i=0; i tool has to wait) - { - m_Output[i] = vecc; - } - - return true; - } - - return true; //returns true if both output vectors and should be empty - } - - if (m_Output_time[m_Output_time.size()-1] < m_Output_time2[m_Output_time2.size()-1]) - { - m_T = m_Output_time2[m_Output_time2.size()-1]; - - N = std::max(1,int(ceil((m_Output_time2[m_Output_time2.size()-1] - m_Output_time[m_Output_time.size()-1])/ m_step))); - m_del_t = (m_Output_time2[m_Output_time2.size()-1] - m_Output_time[m_Output_time.size()-1])/double(N); - - int ind = m_Output_time.size()-1; - double time = 0.0; - - for (int i=1; i m_Output_time2[m_Output_time2.size()-1]) - { - m_T = m_Output_time[m_Output_time.size()-1]; - - N = std::max(1,int(ceil((m_Output_time[m_Output_time.size()-1] - m_Output_time2[m_Output_time2.size()-1])/ m_step))); - m_del_t = (m_Output_time[m_Output_time.size()-1] - m_Output_time2[m_Output_time2.size()-1])/double(N); - - int ind = m_Output_time2.size()-1; - double time = 0.0; - - for (int i=1; i = true (i.e. only master -> no time correction required!!!) - { - return false; - } - - return true; -} - -/* Main routine for generating the simulation output for the feature-based and spiral-based two-sided case */ -bool path_simulate::MakePathSimulate_Feat(const std::vector &flatAreas, bool spiral) -{ - m_Feat = true; - - double rad[2]; - bool tool; - int c[2]; - - gp_Pnt pnt0, pnt1; - - std::vector::iterator *it_1,*it_2; - std::vector *curves_1, *curves_2; - - ofstream anOutputFile[2]; - - anOutputFile[0].open("output_master.k"); - anOutputFile[1].open("output_slave.k"); - anOutputFile[0].precision(7); - anOutputFile[1].precision(7); - - m_it1 = m_BSplineTop.begin(); - m_it2 = m_BSplineBottom.begin(); - - rad[0] = m_set.master_radius; - rad[1] = - m_set.slave_radius - m_set.sheet_thickness; - - c[0] = 1; // Start index of the Master curves - c[1] = 2001; // Start index of the Slave curves - - int i = 0; - - while (m_it1 != m_BSplineTop.end() && m_it2 != m_BSplineBottom.end()) - { - tool = StartingTool(); // determines which tool must wait: - // tool == true : Robot = Slave & NC = Master - // tool == false : Robot = Master & NC = Slave - if (!tool) - { - it_1 = &m_it1; - it_2 = &m_it2; - curves_1 = &m_BSplineTop; - curves_2 = &m_BSplineBottom; - } - else - { - it_1 = &m_it2; - it_2 = &m_it1; - curves_1 = &m_BSplineBottom; - curves_2 = &m_BSplineTop; - } - - m_StartParam[0] = ((*m_it1)->FirstParameter()); // set new start parameters (in our case always 0) - - if (m_single == false) - m_StartParam[1] = ((*m_it2)->FirstParameter()); - - // the first delivery before contact with the sheet metal is handled separately here - if (i==0) - { - /*------ DELIVERY 1 ------*/ - ConnectPaths_xy(0); - WriteOutputDouble(anOutputFile[0],anOutputFile[1],c[0],c[1],0,beam); - UpdateParam(); - - /*------ DELIVERY 2 ------*/ - ConnectPaths_z(0); - WriteOutputDouble(anOutputFile[0],anOutputFile[1],c[0],c[1],0,beam); - UpdateParam(); - } - - while (true) - { - if (*it_1 != (*curves_1).end()-1) - { - /* ------ Curve ------*/ - CompPath(0); // Calculate parameters for the Master - CompPath(1); // Calculate parameters for the Slave - Gen_Path(); // Generate output for current Curve - WriteOutputDouble(anOutputFile[0],anOutputFile[1],c[0],c[1],0,beam); // Write output - UpdateParam(); - - /*------ Delivery ------*/ - (*it_1)++; // Go to the next curve - ConnectPaths_Feat(tool, 0, 1); // Generate output for delivery - WriteOutputDouble(anOutputFile[0],anOutputFile[1],c[0],c[1],0,beam); // Write output - UpdateParam(); - - if (*it_1 == (*curves_1).end()-1 && *it_2 == (*curves_2).end()-1) // last step - { - /* ------ Curve ------*/ - CompPath(0); // Calculate parameters for the Master - CompPath(1); // Calculate parameters for the Slave - Gen_Path(); // Generate output for current Curve - WriteOutputDouble(anOutputFile[0],anOutputFile[1],c[0],c[1],0,beam); // Write output - UpdateParam(); - break; - } - - (**it_1)->D0((**it_1)->FirstParameter(),pnt0); // pass current starting point - - - if ((pnt0.Z() > (flatAreas[i+1] + rad[tool] - 1e-1)) && // When the MASTER reaches the next level - (pnt0.Z() < (flatAreas[i+1] + rad[tool] + 1e-1))) // Area, the SLAVE must be waited for - { - if(!spiral) // In the case of spiral tracks, delivery takes place immediately - { - /* ------ Curve ------*/ - CompPath(0); // Calculate parameters for the Master - CompPath(1); // Calculate parameters for the Slave - Gen_Path(); // Generate output for current Curve - WriteOutputDouble(anOutputFile[0],anOutputFile[1],c[0],c[1],0,beam); // Write output - UpdateParam(); - } - break; - } - } - else - { - if (*it_2 == (*curves_2).end()-1) // last step - { - /* ------ Curve ------*/ - CompPath(0); // Calculate parameters for the Master - CompPath(1); // Calculate parameters for the Slave - Gen_Path(); // Generate output for current Curve - WriteOutputDouble(anOutputFile[0],anOutputFile[1],c[0],c[1],0,beam); // Write output - UpdateParam(); - break; - } - else break; - } - } - - if (m_it1 == m_BSplineTop.end()-1 && m_it2 == m_BSplineBottom.end()-1) // Fertig !!! - break; - - /* ------ Delivery ------*/ - if(!spiral) - { - (*it_1)++; // Go to the next curve - ConnectPaths_Feat(tool, 0, 1); // Generate output for the Master-delivery - } - - (*it_2)++; // Go to the next curve - ConnectPaths_Feat(!tool, 0, 0); // Generate output for the Slave-devlivery - WriteOutputDouble(anOutputFile[0],anOutputFile[1],c[0],c[1],0,beam); // Write output - UpdateParam(); - - ++i; - } - - anOutputFile[0] << "*END" << endl; - anOutputFile[1] << "*END" << endl; - anOutputFile[0].close(); - anOutputFile[1].close(); - - //WriteTimes(); - - return true; -} - -/* Main routine for generating the robot output for the feature-based and spiral-based two-sided case */ -bool path_simulate::MakePathRobot_Feat(const std::vector &flatAreas) -{ - m_Feat = true; - int f = 0, run; - bool tool; - double rad[2]; - gp_Pnt pnt0, pnt1; - - std::vector::iterator *it_1,*it_2; - std::vector *curves_1, *curves_2; - - ofstream anOutputFile[2]; - - std::stringstream master_file, slave_file; - - m_it1 = m_BSplineTop.begin(); - m_it2 = m_BSplineBottom.begin(); - - rad[0] = m_set.master_radius; - rad[1] = - m_set.slave_radius - m_set.sheet_thickness; - - int i = 0; - - while (m_it1 != m_BSplineTop.end() && m_it2 != m_BSplineBottom.end()) - { - tool = StartingTool(); // Determines which tool must wait - - // Set start parameter (in our case unnecessary because always 0) - m_StartParam[0] = ((*m_it1)->FirstParameter()); - if (m_single == false) m_StartParam[1] = ((*m_it2)->FirstParameter()); - - // The first delivery is handled separately - if (i==0) - { - ConnectPaths_xy(1); /* 1. Delivery */ - ConnectPaths_z(1); /* 2. Delivery */ - } - - if (!tool) - { - it_1 = &m_it1; - it_2 = &m_it2; - curves_1 = &m_BSplineTop; - curves_2 = &m_BSplineBottom; - } - else - { - it_1 = &m_it2; - it_2 = &m_it1; - curves_1 = &m_BSplineBottom; - curves_2 = &m_BSplineTop; - } - - // Main loop - while (true) - { - MakePathSingle(1,0,0,tool); // Path generation of the continuously moving tool for the current curve - - // MASTER - if (*it_1 != (*curves_1).end()-1) - { - (*it_1)++; - (**it_1)->D0((**it_1)->FirstParameter(),pnt0); - - if (*it_1 == (*curves_1).end()-1 && *it_2 == (*curves_2).end()-1) - { - ConnectPaths_Feat(tool, 1, 1); - MakePathSingle(1,0,0,tool); - break; - } - - if ((pnt0.Z() > (flatAreas[i+1] + rad[tool] - 1e-1)) && - (pnt0.Z() < (flatAreas[i+1] + rad[tool] + 1e-1))) - { - - run = Detect_FeatCurve(tool); - - for (int i=0; iD0((**it_2)->FirstParameter(),pnt0); - - while ((pnt0.Z() > (flatAreas[i] + rad[!tool] - 1e-1)) && - (pnt0.Z() < (flatAreas[i] + rad[!tool] + 1e-1))) - { - MakePathSingle(1,0,0,!tool); - - if (*it_2 != (*curves_2).end()-1) - (*it_2)++; - else - break; - - (**it_2)->D0((**it_2)->FirstParameter(),pnt0); - } - - master_file << "output_master" << f << ".k"; - slave_file << "output_slave" << f << ".k"; - ++f; - - std::cout << master_file.str() << " , " << slave_file << std::endl; - - anOutputFile[0].open((master_file.str()).c_str()); - anOutputFile[1].open((slave_file.str()).c_str()); - - if (!tool) - { - anOutputFile[0] << "none" << std::endl; - anOutputFile[1] << "continuous" << std::endl; - } - else - { - anOutputFile[0] << "continuous" << std::endl; - anOutputFile[1] << "none" << std::endl; - } - - WriteOutput_Feat(anOutputFile[0], anOutputFile[1],f,1); - - master_file.str(""); - master_file.clear(); - slave_file.str(""); - slave_file.clear(); - - m_Output_robo1.clear(); - m_Output_robo2.clear(); - - if (*it_1 == (*curves_1).end()-1 && *it_2 == (*curves_2).end()-1) - break; - - ConnectPaths_Feat(0, 1, 1); - ConnectPaths_Feat(1, 1, 0); - ++i; - } - - anOutputFile[0] << "*END" << endl; - anOutputFile[1] << "*END" << endl; - anOutputFile[0].close(); - anOutputFile[1].close(); - - return true; -} - -// Help function for the feature-based part: -// Determines which tool waits while the other is running -bool path_simulate::StartingTool() -{ - double z0,z1; - gp_Pnt pnt0,pnt1; - - if(m_it1 != m_BSplineTop.end()-1) - { - // z-distance to the next path - MASTER - (*m_it1)->D0((*m_it1)->FirstParameter(),pnt0); m_it1++; - (*m_it1)->D0((*m_it1)->FirstParameter(),pnt1); m_it1--; - - z0 = abs(pnt0.Z() - pnt1.Z()); - } - - else - z0 = 1e+3; - - if(m_it2 != m_BSplineBottom.end()-1) - { - // z-distance to the next path - SLAVE - (*m_it2)->D0((*m_it2)->FirstParameter(),pnt0); m_it2++; - (*m_it2)->D0((*m_it2)->FirstParameter(),pnt1); m_it2--; - - z1 = abs(pnt0.Z() - pnt1.Z()); - } - else z1 = 1e+3; - - if(z0StartPoint(); // The starting point of the current master curve - pt1 = (*m_it1)->EndPoint(); // The end point of the current master curve - - while(pt0.Distance(pt1) > 1e-3) // Keep going as long as the start and end point don't match - { - if(m_it1 == m_BSplineTop.end()-1) // Stop when you reach the last corner - { - for(int i=1; iEndPoint(); - } - } - - // Return to the status quo - for(int i=1; iStartPoint(); // The starting point of the current slave curve - pt1 = (*m_it2)->EndPoint(); // The end point of the current slave curve - - while(pt0.Distance(pt1) > 1e-3) // Keep going as long as the start and end point don't match - { - if(m_it2 == m_BSplineBottom.end()-1) // Stop when you reach the last corner - { - for(int i=1; iEndPoint(); - } - } - - // Return to the status quo - for(int i=1; iFirstParameter()); // saves start parameter values of the current master curve - - if (m_single == false) - m_StartParam[1] = ((*m_it2)->FirstParameter()); // saves start parameter values of the current slave curve - - - /*Delivery start*/ - - m_conn = CheckConnect(); // Return value = 1 in the case of a negative z-direction infeed - // Return value = 0 in the case of a positive z-direction feed - - // negative z-direction: 1. XY --> 2. Z - // positive z-direction: 1. Z --> 2. XY - - // *** 1. *** - if (m_conn) ConnectPaths_xy(0); - else ConnectPaths_z(0); - - if (m_single == false) WriteOutputDouble(anOutputFile,anOutputFile2,c1,c2,0,beam); - else WriteOutputSingle(anOutputFile,c1,0,0,beam); - - UpdateParam(); - - // *** 2. *** - if (m_conn) ConnectPaths_z(0); - else ConnectPaths_xy(0); - - // Write output - if (m_single == false) WriteOutputDouble(anOutputFile,anOutputFile2,c1,c2,0,beam); - else WriteOutputSingle(anOutputFile,c1,0,0,beam); - - UpdateParam(); - - /*Delivery end* - - - /*Curve start*/ - - CompPath(0); // Calculate the parameters for the Master - - if (m_single == false) - CompPath(1); // Calculate the parameters for the Slave - - Gen_Path(); // Generation of the output vectors - - // Write output vectors - if (m_single == false) WriteOutputDouble(anOutputFile,anOutputFile2,c1,c2,0,beam); - else WriteOutputSingle(anOutputFile,c1,0,0,beam); - - UpdateParam(); - - if (m_single==false && (m_it1 != (m_BSplineTop.end()-1))) - ++m_it2; - - /*Curve Ende*/ - } - - //m_log.saveToFile("c:/Master-Path.iv"); - - /* - ofstream anOutputvelocity; - anOutputvelocity.open("output_velocity.k"); - anOutputvelocity.precision(7); - - for(int i=0; i<(int)m_times_tmp.size(); ++i) // Write out absolute speed values - anOutputvelocity << m_times_tmp[i] << ", " << m_velo_tmp[i] << endl; - - anOutputvelocity.close(); - */ - - anOutputFile << "*END" << endl; - anOutputFile.close(); - - - if (m_single == false) - { - anOutputFile2 << "*END" << endl; - anOutputFile2.close(); - } - - // WriteTimes(); - return true; -} - -/* Writes the output for the feature-based and spiral-based bilateral case */ -bool path_simulate::WriteOutput_Feat(ofstream &anOutputFile, ofstream &anOutputFile2, int &c, bool brob) -{ - if (m_single == false) - { - if (brob == false) - { - int n = m_Output.size(); - - anOutputFile << "*BOUNDARY_PRESCRIBED_MOTION_RIGID" << std::endl; - anOutputFile << "$# pid dof vad lcid sf vid death birth" << std::endl; - anOutputFile << "2,1,0," << c << ",1.000000, ," << m_Output_time[n-1] << "," << m_Output_time[0] << std::endl; - anOutputFile << "*DEFINE_CURVE" << std::endl << c << std::endl; - - for (int i=0; i > Out_val; - std::vector Out_time; - std::pair times; - int n; - int ind; - - int pid; - - if (brob == true) // Write robot output - { - std::vector Out_rob; - - if (!tool) Out_rob = m_Output_robo1; - else Out_rob = m_Output_robo2; - - n = Out_rob.size(); - - for (int i=0; i1) - { - anOutputFile << "*BOUNDARY_PRESCRIBED_MOTION_RIGID" << std::endl; - anOutputFile << "$# pid dof vad lcid sf vid death birth" << std::endl; - anOutputFile << ind << ",1,0," << c << ",1.000000, ," << Out_time[n-1] << "," << Out_time[0] << std::endl; - - - if (beamfl && tool) - { - anOutputFile << "*BOUNDARY_PRESCRIBED_MOTION_RIGID" << std::endl; - anOutputFile << "$# pid dof vad lcid sf vid death birth" << std::endl; - anOutputFile << pid << ",1,0," << c << ",1.000000, ," << Out_time[n-1] << "," << Out_time[0] << std::endl; - } - - anOutputFile << "*DEFINE_CURVE" << std::endl << c << std::endl; - - for (int i=0; i times; - int pid1 = 2; // Master - int pid2 = 3; // Slave - int pid3 = 4; // Plate - - if (brob == false) // Simulations-Output (brob == true -> robot output) - { - TimeCorrection(); - - int n = m_Output.size(); // Master - int n2 = m_Output2.size(); // Slave - - if (n>1) - { - - // MASTER-X - - anOutputFile << "*BOUNDARY_PRESCRIBED_MOTION_RIGID" << std::endl; - anOutputFile << "$# pid dof vad lcid sf vid death birth" << std::endl; - anOutputFile << pid1 << ",1,0," << c1 << ",1.000000, ," << m_Output_time[n-1] << "," << m_Output_time[0] << std::endl; - anOutputFile << "*DEFINE_CURVE" << std::endl << c1 << std::endl; - - for (int i=0; i * - * * - * This file is part of the FreeCAD CAM development system. * - * * - * This library is free software; you can redistribute it and/or * - * modify it under the terms of the GNU Library General Public * - * License as published by the Free Software Foundation; either * - * version 2 of the License, or (at your option) any later version. * - * * - * This library is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * - * GNU Library General Public License for more details. * - * * - * You should have received a copy of the GNU Library General Public * - * License along with this library; see the file COPYING.LIB. If not, * - * write to the Free Software Foundation, Inc., 59 Temple Place, * - * Suite 330, Boston, MA 02111-1307, USA * - * * - ***************************************************************************/ - -#ifndef Path_Simulate_h -#define Path_Simulate_h - - -#include -#include -#include -#include "cutting_tools.h" -#include - -//#include - -/*! \brief The main class for the path_simulate routine - - As it's input parameters it takes one respectively two vectors of B-Spline - Curves (describing the Tool-Paths for the IBU-simulation), two values - a_max and v_max of type double, which stands for the maximum allowable - acceleration and velocity of the tool-movement and one value m_step of - type double, specifying the step-length of the time-output-vector. - - As output, it gives one respectively two output-files for the simulation - process containing a two-dimensional vector of time vs. velocity which - describes the tool-movement. -*/ - -class CamExport path_simulate -{ -public: - - /** @brief Constructor. - - @param BSplineTop vector of B-Spline-Curves describing the tool- - paths of the master-tool - @param BSplineBottom vector of B-Spline-Curves describing the tool- - paths of the slave-tool - @param set a struct which also includes the parameters - a_max and v_max - */ - path_simulate(const std::vector& BSplineTop, - const std::vector& BSplineBottom, - struct CuttingToolsSettings& set); - ~path_simulate(); - - /** @brief Computes all parameters of the velocity-function for the tool - movement along a straight line. - - @param wirelength length of the straight line - */ - bool ParameterCalculation_Line(double wirelength); - - /** @brief Computes all parameters of the velocity-function for the tool - movement along a curve-segment. - - @param wirelength arc-length of the curve-segment - */ - bool ParameterCalculation_Curve(double wirelength); - - /** @brief Computes output for the connection-part in xy-direction - - @param outputstyle false: simulation, true: robot - */ - bool ConnectPaths_xy(bool outputstyle); - - /** @brief Computes output for the connection-part in z-direction - - @param outputstyle false: simulation, true: robot - */ - bool ConnectPaths_z(bool outputstyle); - - /** @brief Computes output for the connection-part in all directions for - the feature-based-strategy - - @param tool false: master true: slave - @param robo defines outputstyle (false: simulation - true: robot) - @param connection_type false: in 3-steps true: in 2-steps - */ - bool ConnectPaths_Feat(bool tool, bool robo, bool connection_type); - - /** @brief Updates actual parameter sets */ - bool UpdateParam(); - - /** @brief Writes output-vectors to file for the feature-based-strategy - - @param anOutputFile_1 output-file for the master - @param anOutputFile_2 output-file for the slave - @param c startindex of the curve-id - @param outputstyle false: simulation, true: robot - */ - bool WriteOutput_Feat(ofstream &anOutputFile_1, ofstream &anOutputFile_2, int &c, bool outputstyle); - - ///** @brief Write start- and endtime for one tool-path-run (master & slave) */ - // bool WriteTimes(); - - /** @brief Writes output-vectors to file - - @param anOutputFile output-file - @param c - @param outputstyle false: simulation, true: robot - @param tool false: master, true: slave - @param beamfl specifies an additional outputvalue which - determines the waiting-status of the tool - movement - \todo undocumented parameter c - */ - bool WriteOutputSingle(ofstream &anOutputFile, int &c, bool outputstyle, bool tool, bool beamfl); - - /** @brief Writes output-vectors to file - - @param anOutputFile_1 output-file for the master - @param nOutputFile_2 output-file for the slave - @param c1 startindex of the curve-id for the master - @param c2 startindex of the curve-id for the slave - @param outputstyle false: simulation, true: robot - @param beamfl specifies an additional outputvalue using - spring-pretension - */ - bool WriteOutputDouble(ofstream &anOutputFile_1,ofstream &nOutputFile_2, int &c1, int &c2, bool outputstyle,bool beamfl); - - /** @brief Main routine for creating the simulation output for a single - curve, including the synchronisation of master and slave
- CompPath() must have been called before using this function - */ - bool Gen_Path(); - - /** @brief Creates outputvectors for the simulation outputfor a single - curve - - @param outputstyle false: simulation, true: robot - @param length defines length of the path - @param part tells us that we are generating output for a - critical part of the curve or not - @param curveType - \todo undocumented parameter curveType - */ - bool MakePathSingle(bool outputstyle, double length, bool part, bool curveType); - - /** @brief Main function of the output-generation for the simulation - using the standard-strategy - */ - bool MakePathSimulate(); - - /** @brief Main function of the output-generation for the simulation - using the feature-based or spiral-based strategy - - @param flatAreas index-vector specifying the flat areas - @param spiral specifies the strategy (true: spiral-based, - false: feature-based) - */ - bool MakePathSimulate_Feat(const std::vector &flatAreas, bool spiral); - - /** @brief Main function of the output-generation for the robot using the - standard-strategy*/ - bool MakePathRobot(); - - /** @brief Main function of the output-generation for the robot using the - feature-based-strategy - */ - bool MakePathRobot_Feat(const std::vector &flatAreas); - - /** @brief computes path-correction after a tool-path-run - - @param b false: master, true: slave - */ - bool Correction(bool b); - - /** @brief Adds additional time-values to the output-vector of the - waiting tool for synchronisation - */ - bool TimeCorrection(); - - /** @brief Returns the next curve-index for the feature-based-strategy */ - int Detect_FeatCurve(bool tool); - -private: - /** @brief curve-vector for the master-tool*/ - std::vector m_BSplineTop; - /** @brief curve-vector for the slave-tool*/ - std::vector m_BSplineBottom; - /** @brief actual start-point for the connection-part*/ - std::vector m_StartPnts1; - /** @brief actual end-point for the connection-part*/ - std::vector m_StartPnts2; - - // Base::Builder3D m_log; - - /** @brief output-vector for the master including velocity-values for the - simulation-process */ - std::vector< std::vector > m_Output; - /** @brief output-vector for the slave including velocity-values for the - simulation-process*/ - std::vector< std::vector > m_Output2; - /** @brief output-vector for the master including a point-set for the - robot*/ - std::vector m_Output_robo1; - /** @brief output-vector for the slave including a point-set for the - robot*/ - std::vector m_Output_robo2; - /** @brief additional output-vector of the master-tool for the robot - output including values 0 and 1 */ - std::vector RoboFlag_Master; - /** @brief additional output-vector of the slave-tool for the robot - output including values 0 and 1 */ - std::vector RoboFlag_Slave; - /** @brief output-vector for the master including a time-set conform to - m_Output respectively m_Output_robo1*/ - std::vector m_Output_time; - /** @brief output-vector for the slave including a time-set conform to - m_Output2 respectively m_Output_robo2*/ - std::vector m_Output_time2; - /** @brief timestep for the simulation-output*/ - double m_step; - /** @brief pointing to the knot-vector of the current B-spline Curve*/ - TColStd_Array1OfReal *m_Knots; - /** @brief maximum curvature of current curve*/ - double m_curMax; - /** @brief external setting-parameters*/ - CuttingToolsSettings m_set; - - /** @brief iterator for the master-curves*/ - std::vector::iterator m_it1; /* iterator über inner-paths */ - /** @brief iterator for the slave-curves*/ - std::vector::iterator m_it2; /* iterator über outer-paths */ - /** @brief sheet-thickness */ - double m_blech; - /** @brief spring-pretension*/ - double m_pretension; - /** @brief maximum number of output-values per file*/ - int m_clip; - /** @brief flag specifies if spring-pretension is used or not*/ - bool beam; - /** @brief flag specifying the used forming-strategy*/ - bool m_single; - /** @brief flag specifying moving-direction (clockwise vs. anticlockwise) - */ - bool m_dir; - /** @brief vector in which the lengths of the separated curve-segments for - the master-tool are stored*/ - std::vector > m_length_ma; - /** @brief vector in which the lengths of the separated curve-segments for - the slave-tool are stored*/ - std::vector > m_length_sl; - /** @brief vector of acceleration-values regarding to the separated curve - segments for the master-tool*/ - std::vector > m_accel_ma; - /** @brief vector of acceleration-values regarding to the separated curve - segments for the slave-tool*/ - std::vector > m_accel_sl; - /** @brief Matrix of three velocity-values regarding to the curves and curve-segments for the master-tool*/ - std::vector > > m_velocity_ma; - /** @brief Matrix of three velocity-values regarding to the curves and - curve-segments for the slave-tool*/ - std::vector > > m_velocity_sl; - /** @brief maximum allowable resulting velocity of the tool*/ - double m_vmax; - /** @brief maximum allowable resulting acceleration of the tool*/ - double m_amax; - /** @brief pathtolerance which is set (in subject to m_vmax and m_amax) - before and after a critical region*/ - double m_boundTol; - /** @brief acceleration-parameter used in GetVelocity() and GetDistance() - */ - double m_a; - /** @brief three-dimensional vector containing start-, maximum- and end- - velocity used in GetVelocity() and GetDistance()*/ - double m_v[3]; - /** @brief parameter of the velocity-function */ - double m_vmid; - /** @brief initial start-parameter for the current master- and slave- - curves*/ - std::vector m_StartParam; - /** @brief timeparameter of the velocity-function*/ - double m_t0; - /** @brief timeparameter of the velocity-function*/ - double m_t1; - /** @brief timeparameter of the velocity-function*/ - double m_t2; - /** @brief timeparameter of the velocity-function*/ - double m_T; - /** @brief timeparameter of the velocity-function*/ - double m_del_t; /* t_0 - starttime, T - endtime, del_t - timestep */ - /** @brief returns absolute velocity at the time-value t */ - double GetVelocity(double time); - /** @brief returns arc-length of the current tool-path at the time-value - t*/ - double GetDistance(double t); - /** @brief determines connection-strategy for both tools*/ - bool CheckConnect(); - /** @brief determines connection-strategy for the specified tool - - @param tool false: master, true: slave - */ - bool CheckConnect(bool tool); - /** @brief determines critical bounds of the current curve for the - specified tool - - @param tool false: master, true: slave - @param knots - \todo undocumented parameter knots - */ - std::vector > CompBounds(bool tool, std::vector knots); - /** @brief Generates output for the current tool-path*/ - bool CompPath(bool tool); - /** @brief determines which tool should wait (feature-based-stategy only)*/ - bool StartingTool(); - /** @brief vector containing start- and end-times for the master-curves*/ - std::vector > m_PathTimes_Master; - /** @brief vector containing start- and end-times for the slave-curves*/ - std::vector > m_PathTimes_Slave; - - // std::vector m_times_tmp; - // std::vector m_velo_tmp; - - /** @brief flag specifying current connection-type*/ - bool m_conn; - /** @brief flag specifying if a feature-based-strategy is used*/ - bool m_Feat; -}; - - -#endif //Path_Simulate_h - - - - diff --git a/src/Mod/Cam/App/routine.cpp b/src/Mod/Cam/App/routine.cpp deleted file mode 100644 index cb25ca7050..0000000000 --- a/src/Mod/Cam/App/routine.cpp +++ /dev/null @@ -1,648 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2007 Joachim Zettler * - * Copyright (c) 2007 Mohamad Najib Muhammad Noor - * * - * This file is part of the FreeCAD CAx development system. * - * * - * This library is free software; you can redistribute it and/or * - * modify it under the terms of the GNU Library General Public * - * License as published by the Free Software Foundation; either * - * version 2 of the License, or (at your option) any later version. * - * * - * This library is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * - * GNU Library General Public License for more details. * - * * - * You should have received a copy of the GNU Library General Public * - * License along with this library; see the file COPYING.LIB. If not, * - * write to the Free Software Foundation, Inc., 59 Temple Place, * - * Suite 330, Boston, MA 02111-1307, USA * - * * - ***************************************************************************/ - -/*********ROUTINE.CPP*********/ -#include "PreCompiled.h" -#include -#include "routine.h" - - -///*********BINDINGS********/ -#include -#include -#include - -using namespace boost::numeric::bindings; -using namespace boost::numeric; - - - -/*! \brief Numerical Integration according to trapezoid rules - - This routine assumes that the Intergral values are already corresponding with WithRespectTo - i.e: Intergral[i] == Intergral(WithRespectTo[i]); - Also, it is assumed that WithRespectTo are evenly spaced with it's stepWidth -*/ -double Routines::TrapezoidIntergration(const std::vector &WithRespectTo, const std::vector &Integral) -{ - m_h = 0; - m_result = 0; - m_N = Integral.size(); - if (m_N==1) // trapzf(x,y) returns zero for a scalar x - { - m_result = 0; - return m_result; - } - - m_h = WithRespectTo[1] - WithRespectTo[0]; /* the integration stepsize */ - for (int i=1; i< m_N - 1; i++) - m_result = m_result + Integral[i]; - - m_result = m_h/2 * (Integral[0] + 2*(m_result) + Integral[m_N -1]); - return m_result; -} - -std::vector Routines::NewtonStep(std::vector &F,std::vector > &DF) -{ - // solves the following equation system: DF*x = F - int siz = (int) F.size(); - std::vector x_new(siz); - std::vector piv(siz); // pivot element - - ublas::matrix A(siz, siz); - ublas::matrix b(1, siz); - - // fills blow molding matrices - for (unsigned int i=0; i > &RHS1, std::vector& RHS2, std::vector &LHS) -{ - double MainMatrixDet = det2(RHS1); - std::vector< std::vector > Temp(2,std::vector(2,0.0)); - for (int i = 0; i < 2; i++) - for (int j = 0; j < 2; j++) - Temp[i][j] = RHS1[i][j]; - - //first pass - for (int i = 0; i < 2; i++) - Temp[i][0] = RHS2[i]; - - LHS[0] = det2(Temp) / MainMatrixDet; - - //restore - for (int i = 0; i < 2; i++) - for (int j = 0; j < 2; j++) - Temp[i][j] = RHS1[i][j]; - - //second pass - for (int i = 0; i < 2; i++) - Temp[i][1] = RHS2[i]; - - LHS[1] = det2(Temp) / MainMatrixDet; -} - -/*! \brief Calculate angle between two vectors - - Dependencies: Vector3D definitions and routines -*/ -double Routines::CalcAngle(Base::Vector3f a,Base::Vector3f b,Base::Vector3f c) -{ - Base::Vector3f First = a - b; - Base::Vector3f Second = c - b; - Base::Vector3f Third = c - a; - //double test1 = First.Length(), test2 = Second.Length(), test3 = Third.Length(); - double UpperTerm = (First.Length() * First.Length()) + (Second.Length() *Second.Length()) - (Third.Length() * Third.Length() ); - double LowerTerm = 2 * First.Length() * Second.Length() ; - double ang = acos( UpperTerm / LowerTerm ); - return ang; -} - - - - - -/*! \brief Algorithm A2.1 from NURBS Book Page 68*/ -int Routines::FindSpan(int n, int p, double u, std::vector KnotSequence) -{ - if (u == KnotSequence[n+1]) - return n; - int low, high, mid, i; - i = 0; - low = p; - high = n+1; - mid = (low+high) / 2; - while (u < KnotSequence[mid] || u >= KnotSequence[mid+1]) - { - if (u < KnotSequence[mid]) - high = mid; - else - low = mid; - mid = (low + high) / 2; - i++; - } - - return mid; - -} - - -/*! \brief Algorithm A2.4 from NURBS Book page 70*/ -void Routines::Basisfun(int i, double u, int p, std::vector &KnotSequence, std::vector &output) -{ - double temp, saved; - std::vector leftie(p+1, 0.0); - std::vector rightie(p+1, 0.0); - output[0] = 1.0; - for (int j = 1; j <= p; j++) - { - leftie[j] = u - KnotSequence[i+1-j]; - rightie[j] = KnotSequence[i+j] - u; - saved = 0.0; - for (int r = 0; r < j; r++) - { - temp = output[r] / (rightie[r+1] + leftie[j-r]); - output[r] = saved + (rightie[r+1]*temp); - saved = leftie[j-r]*temp; - } - output[j] = saved; - } -} -/*! \brief Algorithm A2.3 from NURBS Book Page 72 */ -void Routines::DersBasisFuns(int i, double u, int p, int n, - std::vector &KnotSequence, std::vector< std::vector > &Derivate) -{ - std::vector< std::vector > ndu(p+1, std::vector(p+1,0.0)); - std::vector< std::vector > a(2, std::vector(p+1,0.0)); - std::vector leftie(p+1, 0.0); - std::vector rightie(p+1, 0.0); - ndu[0][0] = 1.0; - for (int j = 1; j <= p; j++) - { - leftie[j] = u - KnotSequence[i+1-j]; - rightie[j] = KnotSequence[i+j] - u; - double saved = 0.0; - for (int r = 0; r < j; r++) - { - ndu[j][r] = rightie[r+1] + leftie[j-r]; - double temp = ndu[r][j-1] / ndu[j][r]; - - ndu[r][j] = saved + rightie[r+1]*temp; - saved = leftie[j-r]*temp; - } - ndu[j][j] = saved; - } - for (int j = 0; j <= p; j++) - Derivate[0][j] = ndu[j][p]; - - for (int r = 0; r <= p; r++) - { - int j1, j2; - int s1 = 0; - int s2 = 1; - a[0][0] = 1.0; - for (int k = 1; k <= n; k++) - { - double d = 0.0; - int j; - int rk = r - k; - int pk = p - k; - if (r >= k) - { - a[s2][0] = a[s1][0] / ndu[pk+1][rk]; - d += a[s2][0] * ndu[rk][pk]; - } - - if (rk >= -1) - j1 = 1; - else j1 = -rk; - - if (r -1 <= pk) - j2 = k -1; - else j2 = p - r; - - for (j = j1; j <= j2; j++) - { - a[s2][j] = (a[s1][j]-a[s1][j-1]) / ndu[pk+1][rk+j]; - d += a[s2][j] * ndu[rk+j][pk]; - } - - if (r <= pk) - { - a[s2][k] = -a[s1][k-1] / ndu[pk+1][r]; - d += a[s2][k] * ndu[r][pk]; - } - - Derivate[k][r] = d; - j = s1; - s1 = s2; - s2 = j; - - - } - } - int r = p; - for (int k = 1; k <= n; k++) - { - for (int j = 0; j <= p; j++) - Derivate[k][j] *= r; - - r*= (p-k); - } - - -} -/*! \brief Translation from nrbeval.m from NURBS Toolbox. WARNING: ONLY POINT EVALUATION ARE CONSIDERED!!!! */ -void Routines::PointNrbEval(std::vector &p, std::vector &CurPoint, NURBS &MainNurb) -{ - if (!p.empty()) - p.clear(); - int i = 0, j = 0; - //val = reshape(nurbs.coefs,4*num1,num2); - std::vector< std::vector > CntrlPoints(((MainNurb.MaxU+1)*3), std::vector((MainNurb.MaxV+1), 0.0)); - for (unsigned int a = 0; a < MainNurb.CntrlArray.size(); ) - { - CntrlPoints[i][j] = MainNurb.CntrlArray[a]; - CntrlPoints[i+1][j] = MainNurb.CntrlArray[a+1]; - CntrlPoints[i+2][j] = MainNurb.CntrlArray[a+2]; - i += 3; - a += 3; - if (i == ((MainNurb.MaxU+1)*3)) - { - i = 0; - j++; - } - - } - //v direction...? - i = 0; - std::vector Output(CntrlPoints.size(), 0.0); - PointBSPEval(MainNurb.DegreeV, CntrlPoints, MainNurb.KnotV, Output, CurPoint[1]); - std::vector< std::vector > RedoneOutput(3, std::vector(MainNurb.MaxU+1, 0.0)); - for (unsigned int a = 0; a < Output.size(); ) - { - RedoneOutput[0][i] = Output[a]; - RedoneOutput[1][i] = Output[a+1]; - RedoneOutput[2][i] = Output[a+2]; - a += 3; - i++; - } - std::vector OutVect(4,0.0); - PointBSPEval(MainNurb.DegreeU, RedoneOutput, MainNurb.KnotU, OutVect,CurPoint[0]); - p.push_back(OutVect[0]); - p.push_back(OutVect[1]); - p.push_back(OutVect[2]); - - -} - -/*! \brief Translation from bspeval.m from NURBS Toolbox. WARNING: ONLY POINT EVALUATION ARE CONSIDERED!!!! */ -void Routines::PointBSPEval(int Degree, std::vector< std::vector > &Cntrl, std::vector &KnotSequence, - std::vector< double > &Output, double CurEvalPoint) -{ - std::vector Basis(Degree+1, 0.0); - int s = FindSpan(Cntrl[0].size() - 1,Degree,CurEvalPoint,KnotSequence); - Basisfun(s,CurEvalPoint,Degree,KnotSequence,Basis); - int tmp1 = s - Degree; - for (unsigned int row = 0;row < Cntrl.size();row++) - { - double tmp2 = 0.0; - for (int i = 0; i <= Degree; i++) - tmp2 += Basis[i] *Cntrl[row][tmp1+i]; - Output[row] = tmp2; - } - -} -/*! \brief Translation from nrbderivate.m from NURBS Toolbox. WARNING: ONLY POINT EVALUATION ARE CONSIDERED!!!! */ -void Routines::PointNrbDerivate(NURBS MainNurb, std::vector &OutNurbs) -{ - if (!OutNurbs.empty()) - OutNurbs.clear(); - NURBS Temp; - int i = 0, j = 0, k = 0; - std::vector< std::vector > ControlDerivate; - std::vector KnotDerivate; - std::vector< std::vector > CntrlPoints(((MainNurb.MaxV+1)*3), std::vector((MainNurb.MaxU+1), 0.0)); - for (unsigned int a = 0; a < MainNurb.CntrlArray.size(); ) - { - CntrlPoints[i][j] = MainNurb.CntrlArray[a]; - CntrlPoints[i+1][j] = MainNurb.CntrlArray[a+1]; - CntrlPoints[i+2][j] = MainNurb.CntrlArray[a+2]; - j++; - a += 3; - i = k*3; - if (j == (MainNurb.MaxU+1)) - { - j = 0; - k++; - i = k*3; - } - - } - - //U derivate - bspderiv(MainNurb.DegreeU, CntrlPoints, MainNurb.KnotU, ControlDerivate, KnotDerivate); - Temp.CntrlArray.resize(ControlDerivate.size() * ControlDerivate[0].size()); - i = 0, j = 0, k = 0; - for (unsigned int a = 0; a < Temp.CntrlArray.size(); ) - { - Temp.CntrlArray[a] = ControlDerivate[i][j]; - Temp.CntrlArray[a+1] = ControlDerivate[i+1][j]; - Temp.CntrlArray[a+2] = ControlDerivate[i+2][j]; - j++; - a += 3; - i = k*3; - if (j == (int)ControlDerivate[i].size()) - { - j = 0; - k++; - i = k*3; - } - } - Temp.KnotU = KnotDerivate; - Temp.KnotV = MainNurb.KnotV; - Temp.MaxKnotU = Temp.KnotU.size(); - Temp.MaxKnotV = Temp.KnotV.size(); - Temp.MaxU = ControlDerivate[0].size(); - Temp.MaxV = ControlDerivate.size() / 3; - Temp.DegreeU = Temp.MaxKnotU - Temp.MaxU - 1; - Temp.DegreeV = Temp.MaxKnotV - Temp.MaxV - 1; - Temp.MaxU--; - Temp.MaxV--; - OutNurbs.push_back(Temp); - //reset - i = 0, j = 0, k = 0; - CntrlPoints.clear(); - ControlDerivate.clear(); - KnotDerivate.clear(); - CntrlPoints.resize((MainNurb.MaxU+1)*3); - for (unsigned int a = 0; a < CntrlPoints.size(); a++) - CntrlPoints[a].resize(MainNurb.MaxV+1); - - for (unsigned int a = 0; a < MainNurb.CntrlArray.size(); ) - { - CntrlPoints[i][j] = MainNurb.CntrlArray[a]; - CntrlPoints[i+1][j] = MainNurb.CntrlArray[a+1]; - CntrlPoints[i+2][j] = MainNurb.CntrlArray[a+2]; - i += 3; - a += 3; - if (i == ((MainNurb.MaxU+1)*3)) - { - i = 0; - j++; - } - - } - //V derivate - bspderiv(MainNurb.DegreeV, CntrlPoints, MainNurb.KnotV, ControlDerivate, KnotDerivate); - Temp.CntrlArray.resize(ControlDerivate.size() * ControlDerivate[0].size()); - i = 0, j = 0, k = 0; - for (unsigned int a = 0; a < Temp.CntrlArray.size(); ) - { - Temp.CntrlArray[a] = ControlDerivate[i][j]; - Temp.CntrlArray[a+1] = ControlDerivate[i+1][j]; - Temp.CntrlArray[a+2] = ControlDerivate[i+2][j]; - a += 3; - i += 3; - if (i == (int)ControlDerivate.size()) - { - j++; - i = 0; - } - } - Temp.KnotU = MainNurb.KnotU; - Temp.KnotV = KnotDerivate; - Temp.MaxKnotU = Temp.KnotU.size(); - Temp.MaxKnotV = Temp.KnotV.size(); - Temp.MaxU = ControlDerivate.size() / 3; - Temp.MaxV = ControlDerivate[0].size(); - Temp.DegreeU = Temp.MaxKnotU - Temp.MaxU - 1; - Temp.DegreeV = Temp.MaxKnotV - Temp.MaxV - 1; - Temp.MaxU--; - Temp.MaxV--; - OutNurbs.push_back(Temp); -} - -/*! \brief Translation from bspderiv.m from NURBS Toolbox. WARNING: ONLY POINT EVALUATION ARE CONSIDERED!!!! */ -void Routines::bspderiv(int d, std::vector< std::vector > &c, std::vector &k, - std::vector< std::vector > &OutputC, std::vector &Outputk) -{ - OutputC.resize(c.size()); - for (unsigned int i = 0; i < OutputC.size(); i++) - OutputC[i].resize(c[i].size()-1); - - double tmp = 0.0; - - for (unsigned int i = 0; i < OutputC[0].size(); i++) - { - tmp = d / (k[i+d+1]-k[i+1]); - for (unsigned int j = 0; j < OutputC.size(); j++) - OutputC[j][i] = tmp * (c[j][i+1] - c[j][i]); - } - Outputk.resize(k.size() - 2); - for (unsigned int i = 0; i < Outputk.size(); i++) - Outputk[i] = k[i+1]; -} - -/*! \brief Translation from nrbdeval.m from NURBS Toolbox. WARNING: ONLY POINT EVALUATION ARE CONSIDERED!!!! */ -void Routines::NrbDEval(NURBS &MainNurb, std::vector &DerivNurb, std::vector &Point, - std::vector &EvalPoint, std::vector > &jac) -{ - if (!EvalPoint.empty()) - EvalPoint.clear(); - if (!jac.empty()) - jac.clear(); - std::vector TempoPointDeriv; - PointNrbEval(EvalPoint, Point, MainNurb); - for (unsigned int i = 0; i < DerivNurb.size(); i++) - { - PointNrbEval(TempoPointDeriv, Point, DerivNurb[i]); - jac.push_back(TempoPointDeriv); - TempoPointDeriv.clear(); - } -} - -/*! \brief Uniform Knot Generator */ -void Routines::GenerateUniformKnot(int MaxCntrl, int NurbDegree, std::vector &KnotSequence) -{ - if (!KnotSequence.empty()) - KnotSequence.clear(); - - for (int i = 0; i < (MaxCntrl + NurbDegree + 2); i++) - KnotSequence.push_back(0); - - for (int i = NurbDegree; i < MaxCntrl; i++) - KnotSequence[i+1] = (double)(i - NurbDegree + 1.0) / (double)(MaxCntrl - NurbDegree + 1.0); - - for (unsigned int i = MaxCntrl+1; i < KnotSequence.size(); i++) - KnotSequence[i] = 1; - -} - -/*! \brief Find the corner points - - Idea: From the neighbour list, find the shortest distance of a point to the given parameter X and Y. - Parameter X and Y are the bounding boxes parameter of the mesh (combinations of Min and Max of X and Y) -*/ -unsigned long Routines::FindCorner(float ParamX, float ParamY, std::vector &v_neighbour, std::vector &v_pnts) -{ - unsigned int j = 0; - bool change = false; - //double distance = sqrt(((ParamX - ParameterMesh.GetPoint(v_neighbour[0])[0])*(ParamX - ParameterMesh.GetPoint(v_neighbour[0])[0])) + - // ((ParamY - ParameterMesh.GetPoint(v_neighbour[0])[1])*(ParamY - ParameterMesh.GetPoint(v_neighbour[0])[1]))); - double distance = sqrt(((ParamX - v_pnts[0][0])*(ParamX - v_pnts[0][0])) + - ((ParamY - v_pnts[0][1])*(ParamY - v_pnts[0][1]))); - for (unsigned int k = 1; k < v_neighbour.size(); ++k) - { - double eps= sqrt(((ParamX - v_pnts[k][0])*(ParamX - v_pnts[k][0])) + - ((ParamY - v_pnts[k][1])*(ParamY - v_pnts[k][1]))); - if (eps < distance) - { - distance = eps; - j = k; - change = true; - } - - } - if (change) - return v_neighbour[j]; - else return v_neighbour[0]; -} - -/*! \brief Calculate the Area of the triangle, bounded by three vectors from origin. A (bad) diagram is included in source - code */ -double Routines::AreaTriangle(Base::Vector3f &a, Base::Vector3f &b, Base::Vector3f &c) -{ - /* a - * x----->x b - * \ / - * \ / - * \/ - * V - * x c - */ - Base::Vector3f First = b - a; - Base::Vector3f Second = c - a; - std::vector < std::vector > Matrix(2, std::vector(2)); - Matrix[0][0] = First.x; - Matrix[1][0] = First.y; - Matrix[0][1] = Second.x; - Matrix[1][1] = Second.y; - return (0.5 * det2(Matrix)); -} - -/*! \brief Knot Extension - - This method will extend the knots by 2. ErrPnt will tell where the knots should be inserted, NurbDegree - and MaxCntrl will make sure that the amount of 0's and 1's are left untouched. - - The new values will be calculated here and will be inserted in Extension function -*/ -void Routines::ExtendKnot(double ErrPnt, int NurbDegree, int MaxCntrl, std::vector &KnotSequence) -{ - double tol_knot = 0.02; - int ind_1 = 0; - double new1 = 0; - int ind_2 = 0; - double new2 = 0; - bool flag = false; - - if (KnotSequence.size()>40) - tol_knot = 0.015; - - for (unsigned int i = NurbDegree; i < (KnotSequence.size() - NurbDegree); i++) - { - if ((KnotSequence[i] > ErrPnt) && (ErrPnt >= KnotSequence[i-1])) - { - ind_1 = i; - new1 = (KnotSequence[ind_1] + KnotSequence[ind_1-1]) / 2; - - } - } - //START CHANGE - if (!flag) - { - double mid = (double)KnotSequence.size() / 2.0; - - if (ind_1 == mid) - { - - KnotSequence.resize(KnotSequence.size() + 2); - //MainNurb.MaxKnotU += 2; - for (int i = KnotSequence.size() - 1; i > ind_1; i--) - KnotSequence[i] = KnotSequence[i-2]; - KnotSequence[ind_1] = KnotSequence[ind_1-1] + ((new1 - KnotSequence[ind_1-1]) / 2.0); - KnotSequence[ind_1+1] = new1 +((new1 - KnotSequence[ind_1-1]) / 2.0); - - } - else - { - double temp = mid - ((double)ind_1); - ind_2 = (int)(mid + temp); - new2 = (KnotSequence[ind_2-1] + KnotSequence[ind_2]) / 2.0; - if (ind_1 < ind_2) - Extension(KnotSequence,ind_1,ind_2,new1,new2); - else - Extension(KnotSequence,ind_2,ind_1,new2,new1); - } - } - else - { - if (ind_1 < ind_2) - Extension(KnotSequence,ind_1,ind_2,new1,new2); - else - Extension(KnotSequence,ind_2,ind_1,new2,new1); - } -} -/*! \brief This routine is because it is done over and over again... -*/ -void Routines::Extension(std::vector &KnotSequence, int SmallerIndex, int LargerIndex, double SmallerIndNewValue, - double LargerIndNewValue) -{ - KnotSequence.resize(KnotSequence.size() + 1); - - for (int i = KnotSequence.size() - 1; i > SmallerIndex; i--) - KnotSequence[i] = KnotSequence[i-1]; - - KnotSequence[SmallerIndex] = SmallerIndNewValue; - - LargerIndex++; - KnotSequence.resize(KnotSequence.size() + 1); - - for (int i = KnotSequence.size() - 1; i > LargerIndex; i--) - KnotSequence[i] = KnotSequence[i-1]; - - KnotSequence[LargerIndex] = LargerIndNewValue; -} - diff --git a/src/Mod/Cam/App/routine.h b/src/Mod/Cam/App/routine.h deleted file mode 100644 index 1c70df3254..0000000000 --- a/src/Mod/Cam/App/routine.h +++ /dev/null @@ -1,114 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2007 Joachim Zettler * - * Copyright (c) 2007 Mohamad Najib Muhammad Noor - * * - * This file is part of the FreeCAD CAx development system. * - * * - * This library is free software; you can redistribute it and/or * - * modify it under the terms of the GNU Library General Public * - * License as published by the Free Software Foundation; either * - * version 2 of the License, or (at your option) any later version. * - * * - * This library is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * - * GNU Library General Public License for more details. * - * * - * You should have received a copy of the GNU Library General Public * - * License along with this library; see the file COPYING.LIB. If not, * - * write to the Free Software Foundation, Inc., 59 Temple Place, * - * Suite 330, Boston, MA 02111-1307, USA * - * * - ***************************************************************************/ - - -/*********ROUTINE.H**********/ -#ifndef ROUTINE_H -#define ROUTINE_H - -/******MAIN INCLUDE******/ - -#include - -/********FREECAD MESH**********/ - -// Things from the Mesh module -#include -#include -#include -#include -#include - - -/******NURBS STRUCT*********/ -/*! \brief This Nurbs struct will be used internally without any connections to the outside - program -*/ -typedef struct -{ - std::vector CntrlArray; - std::vector KnotU; - std::vector KnotV; - int MaxKnotU; - int MaxKnotV; - int MaxU; - int MaxV; - int DegreeU; - int DegreeV; -}NURBS; - - - -/*! \brief Some Mathematical Routines - - This class will be inherited by the Approx class to reduce code bloat. - This class have all the self-written matrix and vector routines, - and some NURBS routines from the Nurbs Book or translated from the NURBS - Toolbox for MATLAB -*/ -class CamExport Routines -{ -public: - // Multi-dimensional Newton method with a fixed starting value of 0 - static std::vector NewtonStep(std::vector &F,std::vector > &DF); -protected: - double TrapezoidIntergration(const std::vector &WithRespectTo, const std::vector &Intergral); - //Matrix and vectors - void CramerSolve(std::vector< std::vector > &RHS1, std::vector& RHS2, std::vector &LHS); - double CalcAngle(Base::Vector3f a, Base::Vector3f b, Base::Vector3f c); - /*! Determinant of a 2x2 Matrix */ - inline double det2(std::vector< std::vector > &Matrix) - { - return ((Matrix[0][0] * Matrix[1][1]) - (Matrix[0][1] * Matrix[1][0])); - }; - - double AreaTriangle(Base::Vector3f &a, Base::Vector3f &b, Base::Vector3f &c); - - //NURBS - int FindSpan(int n, int p, double u, std::vector KnotSequence); - void DersBasisFuns(int i, double u, int p, int n, - std::vector &KnotSequence, std::vector< std::vector > &Derivate); - void Basisfun(int i, double u, int p, std::vector &KnotSequence, std::vector &output); - void NrbDEval(NURBS &MainNurb, std::vector &DerivNurb, std::vector &Point, - std::vector &EvalPoint, std::vector > &jac); - void PointNrbEval(std::vector &p, std::vector &CurPoint, NURBS &MainNurb); - void PointBSPEval(int DegreeU, std::vector< std::vector > &Cntrl, std::vector &KnotSequence, - std::vector< double > &Output, double CurEvalPoint); - void PointNrbDerivate(NURBS MainNurb, std::vector &OutNurbs); - void bspderiv(int d, std::vector< std::vector > &c, std::vector &k, - std::vector< std::vector > &OutputC, std::vector &Outputk); - void ExtendKnot(double ErrPnt, int NurbDegree, int MaxCntrl, std::vector &KnotSequence); - void Extension(std::vector &KnotSequence, int SmallerIndex, int LargerIndex, double SmallerIndNewValue, - double LargerIndNewValue); - void GenerateUniformKnot(int MaxCntrl, int NurbDegree, std::vector &KnotSequence); - unsigned long FindCorner(float ParamX, float ParamY, std::vector &v_neighbour, std::vector &v_pnts); -private: - //Variables in Use by Routine TrapezoidIntegration - double m_h, m_result; - int m_N; - - -}; - -#endif /*ROUTINE_H DEFINED*/ - diff --git a/src/Mod/Cam/App/stuff.h b/src/Mod/Cam/App/stuff.h deleted file mode 100644 index 95bdd6b860..0000000000 --- a/src/Mod/Cam/App/stuff.h +++ /dev/null @@ -1,78 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2007 Joachim Zettler * - * * - * This file is part of the FreeCAD CAx development system. * - * * - * This library is free software; you can redistribute it and/or * - * modify it under the terms of the GNU Library General Public * - * License as published by the Free Software Foundation; either * - * version 2 of the License, or (at your option) any later version. * - * * - * This library is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * - * GNU Library General Public License for more details. * - * * - * You should have received a copy of the GNU Library General Public * - * License along with this library; see the file COPYING.LIB. If not, * - * write to the Free Software Foundation, Inc., 59 Temple Place, * - * Suite 330, Boston, MA 02111-1307, USA * - * * - ***************************************************************************/ -/**\file -\brief Mostly functors for less operators can be found here -*/ - -#ifndef STUFF_H -#define STUFF_H - -#include -#include -#include - -/**\brief Functor to sort a pair of type pair - -Mostly used in the cutting class as a sorting of the different resulting wires is necessary if there is -more then one resulting cutting curve -\param _Left A pair which consists of a float value (mostly here the Z-Level is stored) and a TopoDS_Wire -\param _Right Exactly the same as _Left but here it is used to compare with _First -\return A Boolean Value which is either true != 0 or false == 0 depending which Z-Level is higher or lower -*/ -bool inline FloatWirePairHuge(const std::pair& _Left, const std::pair& _Right) -{ - return _Left.first > _Right.first; -} - - -/**\brief Functor to sort two float values - -Just a test function which is able to sort also from high to low and not only from low to high -(like the less operator is normally doing it) -\param _Left A float value -\param _Right A float value for the comparison with the _Left -\return A Boolean Value which is either true != 0 or false == 0 depending which float value is higher -*/ -bool inline FloatHuge(const float _Left, const float _Right) -{ - return _Left > _Right; -} - -/**\brief A container to have an easy access to an edge with start and endpoint*/ -struct edge_container -{ - TopoDS_Edge edge; - gp_Pnt firstPoint; - gp_Pnt lastPoint; - -}; - -/**\brief A container used for projecting points on faces along a normal vector*/ -struct projectPointContainer -{ - gp_Pnt point; - gp_Dir normalvector; - TopoDS_Face face; -}; - -#endif /*DEFINE STUFF_H*/ - diff --git a/src/Mod/Cam/CMakeLists.txt b/src/Mod/Cam/CMakeLists.txt deleted file mode 100644 index fac0a1a32b..0000000000 --- a/src/Mod/Cam/CMakeLists.txt +++ /dev/null @@ -1,13 +0,0 @@ - -add_subdirectory(App) -if(BUILD_GUI) - add_subdirectory(Gui) -endif(BUILD_GUI) - -INSTALL( - FILES - Init.py - InitGui.py - DESTINATION - Mod/Cam -) diff --git a/src/Mod/Cam/Cam.sln b/src/Mod/Cam/Cam.sln deleted file mode 100644 index 03d1202bfc..0000000000 --- a/src/Mod/Cam/Cam.sln +++ /dev/null @@ -1,29 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 9.00 -# Visual C++ Express 2005 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "AppCam", "App\AppCam.vcproj", "{7BCA5FC1-6063-4C3C-84F6-29D5029BEB59}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "AppCamGui", "Gui\AppCamGui.vcproj", "{071D36BB-65CE-4219-847D-005D2C142D46}" - ProjectSection(ProjectDependencies) = postProject - {7BCA5FC1-6063-4C3C-84F6-29D5029BEB59} = {7BCA5FC1-6063-4C3C-84F6-29D5029BEB59} - EndProjectSection -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Win32 = Debug|Win32 - Release|Win32 = Release|Win32 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {7BCA5FC1-6063-4C3C-84F6-29D5029BEB59}.Debug|Win32.ActiveCfg = Debug|Win32 - {7BCA5FC1-6063-4C3C-84F6-29D5029BEB59}.Debug|Win32.Build.0 = Debug|Win32 - {7BCA5FC1-6063-4C3C-84F6-29D5029BEB59}.Release|Win32.ActiveCfg = Release|Win32 - {7BCA5FC1-6063-4C3C-84F6-29D5029BEB59}.Release|Win32.Build.0 = Release|Win32 - {071D36BB-65CE-4219-847D-005D2C142D46}.Debug|Win32.ActiveCfg = Debug|Win32 - {071D36BB-65CE-4219-847D-005D2C142D46}.Debug|Win32.Build.0 = Debug|Win32 - {071D36BB-65CE-4219-847D-005D2C142D46}.Release|Win32.ActiveCfg = Release|Win32 - {071D36BB-65CE-4219-847D-005D2C142D46}.Release|Win32.Build.0 = Release|Win32 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal diff --git a/src/Mod/Cam/Gui/AppCamGui.cpp b/src/Mod/Cam/Gui/AppCamGui.cpp deleted file mode 100644 index 4edbdeab58..0000000000 --- a/src/Mod/Cam/Gui/AppCamGui.cpp +++ /dev/null @@ -1,77 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2007 Werner Mayer * - * * - * This file is part of the FreeCAD CAx development system. * - * * - * This library is free software; you can redistribute it and/or * - * modify it under the terms of the GNU Library General Public * - * License as published by the Free Software Foundation; either * - * version 2 of the License, or (at your option) any later version. * - * * - * This library is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * - * GNU Library General Public License for more details. * - * * - * You should have received a copy of the GNU Library General Public * - * License along with this library; see the file COPYING.LIB. If not, * - * write to the Free Software Foundation, Inc., 59 Temple Place, * - * Suite 330, Boston, MA 02111-1307, USA * - * * - ***************************************************************************/ - - -#include "PreCompiled.h" -#ifndef _PreComp_ -#endif - -#include -#include - -#include -#include -#include - -#include "Workbench.h" - -// use a different name to CreateCommand() -void CreateCamCommands(void); - -/* registration table */ -static struct PyMethodDef CamGui_methods[] = -{ - { - NULL, NULL - } /* end of table marker */ -}; - -extern "C" -{ - void CamGuiExport initCamGui() - { - if (!Gui::Application::Instance) - { - PyErr_SetString(PyExc_ImportError, "Cannot load Gui module in console application."); - return; - } - - // load dependent module - try { - Base::Interpreter().loadModule("Cam"); - } - catch(const Base::Exception& e) { - PyErr_SetString(PyExc_ImportError, e.what()); - return; - } - - (void) Py_InitModule("CamGui", CamGui_methods); /* mod name, table ptr */ - Base::Console().Log("Loading GUI of Cam module... done\n"); - - CamGui::Workbench ::init(); - - // instantiating the commands - CreateCamCommands(); - - return; - } -} // extern "C" diff --git a/src/Mod/Cam/Gui/CMakeLists.txt b/src/Mod/Cam/Gui/CMakeLists.txt deleted file mode 100644 index a2baad5e57..0000000000 --- a/src/Mod/Cam/Gui/CMakeLists.txt +++ /dev/null @@ -1,77 +0,0 @@ -if(WIN32) - add_definitions(-DHAVE_ACOSH -DHAVE_ATANH -DHAVE_ASINH) -else(WIN32) -endif(WIN32) - -include_directories( - ${CMAKE_SOURCE_DIR}/src - ${CMAKE_BINARY_DIR}/src - ${CMAKE_CURRENT_BINARY_DIR} - ${Boost_INCLUDE_DIRS} - ${COIN3D_INCLUDE_DIR} - ${OCC_INCLUDE_DIR} - ${PYTHON_INCLUDE_PATH} - ${QT_INCLUDE_DIR} - ${ZLIB_INCLUDE_DIR} - ${XercesC_INCLUDE_DIRS} - ${SMSH_INCLUDE_DIR} - ${SMESH_INCLUDE_DIR} -) - -if(MSVC) - set(CamGui_LIBS - Cam - Mesh - PartGui - FreeCADGui - importlib_atlas.lib - importlib_umfpackamd.lib - ${SMSH_LIBRARIES} - ${SMESH_LIBRARIES} - ) -else(MSVC) - set(CamGui_LIBS - Cam - PartGui - FreeCADGui - ) -endif(MSVC) - -set(CamGui_MOC_HDRS - Cutting.h -) -fc_wrap_cpp(CamGui_MOC_SRCS ${CamGui_MOC_HDRS}) -SOURCE_GROUP("Moc" FILES ${CamGui_MOC_SRCS}) - -set(CamGui_UIC_SRCS - Cutting.ui -) -qt5_wrap_ui(CamGui_UIC_HDRS ${CamGui_UIC_SRCS}) - -SET(CamGui_SRCS - ${CamGui_UIC_HDRS} - AppCamGui.cpp - Command.cpp - Cutting.cpp - Cutting.h - Cutting.ui - PreCompiled.cpp - PreCompiled.h - Workbench.cpp - Workbench.h -) - -add_library(CamGui SHARED ${CamGui_SRCS}) -target_link_libraries(CamGui ${CamGui_LIBS}) - -fc_target_copy_resource(CamGui - ${CMAKE_SOURCE_DIR}/src/Mod/Cam - ${CMAKE_BINARY_DIR}/Mod/Cam - InitGui.py) - -SET_BIN_DIR(CamGui CamGui /Mod/Cam) -if(WIN32) - set_target_properties(CamGui PROPERTIES SUFFIX ".pyd") -endif(WIN32) - -INSTALL(TARGETS CamGui DESTINATION ${CMAKE_INSTALL_LIBDIR}) diff --git a/src/Mod/Cam/Gui/Command.cpp b/src/Mod/Cam/Gui/Command.cpp deleted file mode 100644 index 1d227fe58f..0000000000 --- a/src/Mod/Cam/Gui/Command.cpp +++ /dev/null @@ -1,63 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2007 Werner Mayer * - * * - * This file is part of the FreeCAD CAx development system. * - * * - * This library is free software; you can redistribute it and/or * - * modify it under the terms of the GNU Library General Public * - * License as published by the Free Software Foundation; either * - * version 2 of the License, or (at your option) any later version. * - * * - * This library is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * - * GNU Library General Public License for more details. * - * * - * You should have received a copy of the GNU Library General Public * - * License along with this library; see the file COPYING.LIB. If not, * - * write to the Free Software Foundation, Inc., 59 Temple Place, * - * Suite 330, Boston, MA 02111-1307, USA * - * * - ***************************************************************************/ - -#include "PreCompiled.h" - -#include "Cutting.h" - -#include -#include -#include -#include - - - - -//=========================================================================== -// StdCamCutting -//=========================================================================== -DEF_STD_CMD(StdCamCutting); - -StdCamCutting::StdCamCutting() - :Command("Cam_Cutting") -{ - sGroup = QT_TR_NOOP("Tools"); - sMenuText = QT_TR_NOOP("Cutting..."); - sToolTipText = QT_TR_NOOP("Cutting"); - sWhatsThis = "Cam_Cutting"; - sStatusTip = QT_TR_NOOP("Cutting"); -} - -void StdCamCutting::activated(int iMsg) -{ - static QPointer dlg = 0; - if (!dlg) - dlg = new CamGui::Cutting(Gui::getMainWindow()); - dlg->setAttribute(Qt::WA_DeleteOnClose); - dlg->show(); -} - -void CreateCamCommands() -{ - Gui::CommandManager &rcCmdMgr = Gui::Application::Instance->commandManager(); - rcCmdMgr.addCommand(new StdCamCutting()); -} diff --git a/src/Mod/Cam/Gui/Cutting.cpp b/src/Mod/Cam/Gui/Cutting.cpp deleted file mode 100644 index 6b98e4617a..0000000000 --- a/src/Mod/Cam/Gui/Cutting.cpp +++ /dev/null @@ -1,921 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2007 Joachim Zettler * - * Copyright (c) 2007 Werner Mayer * - * * - * This file is part of the FreeCAD CAx development system. * - * * - * This library is free software; you can redistribute it and/or * - * modify it under the terms of the GNU Library General Public * - * License as published by the Free Software Foundation; either * - * version 2 of the License, or (at your option) any later version. * - * * - * This library is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * - * GNU Library General Public License for more details. * - * * - * You should have received a copy of the GNU Library General Public * - * License along with this library; see the file COPYING.LIB. If not, * - * write to the Free Software Foundation, Inc., 59 Temple Place, * - * Suite 330, Boston, MA 02111-1307, USA * - * * - ***************************************************************************/ - -#include "PreCompiled.h" - -#include "Cutting.h" -#include //Only for Testing -#include -#include -#include -#include -#include -#include -#include -#include - - -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -#include -#include - -using namespace CamGui; - -Cutting::Cutting(QWidget* parent,Qt::WFlags fl) - :QDialog(parent,fl),m_Process(NULL), - m_PathSimulate(NULL),m_CuttingAlgo(NULL), - m_BestFit(NULL),m_MergeData(NULL),m_Deviation(NULL) -{ - this->setupUi(this); - m_timer= false; -} - -Cutting::~Cutting() -{ - delete m_CuttingAlgo; - delete m_PathSimulate; - delete m_Process; - delete m_BestFit; - delete m_Deviation; - delete m_MergeData; -} - -bool Cutting::getProcessOutput() -{ - QByteArray result = m_Process->readAll(); - if (result.contains("Error")) - { - m_Process->kill(); - QMessageBox::critical(this, tr("FreeCAD CamWorkbench"), - tr("Error in generation\n"), - QMessageBox::Ok, QMessageBox::NoButton); - } - else if (result.contains("N o r m a l t e r m i n a t i o n")) - { - QMessageBox::information(this, tr("FreeCAD CamWorkbench"), - tr("Dyna-Job finished well\n"), - QMessageBox::Ok, QMessageBox::NoButton); - } - - return true; -} -void Cutting::on_adaptdynainput_clicked() -{ - //First we have to select the LS-Dyna Masterfile and the current working dir - QString filename, path, program; - QStringList arguments; - QString strcheck("dyna.str"); - filename = QFileDialog::getOpenFileName( this, "Open Dyna.Str or Master-Key File",filename,"Ls-Dyna Keywords (*.k) (*.str)" ); - if (filename.isNull()) - return; - QFileInfo aFileInfo(filename); - path = aFileInfo.absolutePath(); - QDir::setCurrent(path); - program = "c:/Program Files/lsdyna/ls971d"; - //As the new Versions already account for a proper curve file we no longer have to adapt the input - //if we already have a str File we will not step into the next if-case - //if(!aFileInfo.fileName().contains("dyna.str")) - //{ - // arguments << " i="<< aFileInfo.fileName(); - // m_Process = new QProcess(this); - // m_Process->start(program, arguments); - // //Now we check if the output is written correctly - // m_Process->waitForFinished(50000); - // aFileInfo.setFile("dyna.str"); - // if (aFileInfo.size() == 0) //the file does not exist - // { - // QMessageBox::critical(this, tr("FreeCAD CamWorkbench"), - // tr("Error when creating the Struct file\n"), - // QMessageBox::Ok, QMessageBox::NoButton); - // return; - // } - // else - // { - // QMessageBox::information(this, tr("FreeCAD CamWorkbench"), - // tr("Structured Dyna generated well\n"), - // QMessageBox::Ok, QMessageBox::NoButton); - // } - //} - //ChangeDyna aFileChanger; - //if (aFileChanger.Read("dyna.str")) - // start_simulation->show(); - //else{ - // QMessageBox::critical(this, tr("FreeCAD CamWorkbench"), - // tr("Error while parsing the str File\n"), - // QMessageBox::Ok, QMessageBox::NoButton); - // return; - //} - -} - -void Cutting::on_start_simulation_clicked() -{ - //check if the initial process is already killed - m_Process->kill(); - QString program; - QStringList arguments; - program = "c:/Program Files/lsdyna/ls971d"; - arguments << " i=dyna2.str"; - connect(m_Process,SIGNAL(readyReadStandardError()),this,SLOT(getProcessOutput())); - connect(m_Process,SIGNAL(readyReadStandardOutput()),this,SLOT(getProcessOutput())); - m_Process->start(program, arguments); -} - -void Cutting::on_Deviation_button_clicked() -{ - m_Deviation = new Deviation(); - deviation_geometry1_button->setEnabled(true); - deviation_geometry2_button->setEnabled(true); - deviation_go_button->setEnabled(true); -} - -void Cutting::on_deviation_geometry1_button_clicked() -{ - selectShape(); -} - -void Cutting::on_deviation_geometry2_button_clicked() -{ - selectMesh(); -} - -void Cutting::on_deviation_go_button_clicked() -{ - QString current_filename = QFileDialog::getSaveFileName(this,"Select Deviation Files","","*.txt"); - m_Deviation->ImportGeometry(m_Shape, m_Mesh); - m_Deviation->Compute(); - - - m_Deviation->WriteOutput(current_filename); - -} - -void Cutting::on_error_accumulation_select_files_button_clicked() -{ - m_MergeData = new MergeData(); - - QStringList m_dateinamen = QFileDialog::getOpenFileNames( - this, - "Select one or more files to open", - "c:", - "Deviation Files (*.txt)"); - - if (!m_dateinamen.isEmpty()) - { - if (!m_MergeData->Einlesen(m_dateinamen)) - { - QMessageBox::information(this, tr("FreeCAD CamWorkbench"), - tr("Everything OK. Output can be generated\n"), - QMessageBox::Ok, QMessageBox::NoButton); - } - - - } - error_accumulation_go_button->setEnabled(true); - -} - -void Cutting::on_error_accumulation_go_button_clicked() -{ - QString current_filename = QFileDialog::getSaveFileName(this,"Select Output File","","*.txt"); - - m_MergeData->WriteOutput(current_filename); - -} - -void Cutting::selectShape() -{ - if (!m_timer) - { - - int check_box1=0,check_box2=0; - if (!m_Shape.IsNull()) - { - check_box1 = QMessageBox::question(this, tr("FreeCAD CamWorkbench"), - tr("You have already selected a CAD-Shape.\n" - "Do you want to make a new Selection?"), - QMessageBox::Yes, QMessageBox::No); - } - else - { - check_box2 = QMessageBox::information(this, tr("FreeCAD CamWorkbench"), - tr("You have to select a CAD-Shape.\n"), - QMessageBox::Ok, QMessageBox::Cancel); - } - if ((check_box1 == QMessageBox::Yes) || (check_box2 == QMessageBox::Ok)) - { - //First, remove the old selection from the Gui, so that we do not directly have the same CAD once again. - Gui::Selection().clearCompleteSelection(); - //to make a Selection more easy, hide the dialog - this->hide(); - QTimer::singleShot(100,this,SLOT(selectShape())); - m_timer = true; - } - } - else - { - std::vector fea = Gui::Selection().getObjectsOfType(Part::Feature::getClassTypeId()); - if ( fea.size() == 1) - { - m_Shape = static_cast(fea.front())->Shape.getValue(); - //std::vector aSelection = Gui::Selection().getSelection(); - this->show(); - CalculateZLevel->setEnabled(true); - CalculateFeatureBased->setEnabled(true); - CalculateSpiralBased->setEnabled(true); - m_timer = false; - } - else - { - QTimer::singleShot(100,this,SLOT(selectShape())); - m_timer = true; - } - } -} - -void Cutting::selectMesh() -{ - if (!m_timer) - { - int check_box1=0,check_box2=0; - if (m_Mesh.CountPoints() > 0) - { - check_box1 = QMessageBox::question(this, tr("FreeCAD CamWorkbench"), - tr("You have already selected a Mesh.\n" - "Do you want to make a new Selection?"), - QMessageBox::Yes, QMessageBox::No); - } - else - { - check_box2 = QMessageBox::information(this, tr("FreeCAD CamWorkbench"), - tr("You have to select a Mesh.\n"), - QMessageBox::Ok, QMessageBox::Cancel); - } - if ((check_box1 == QMessageBox::Yes) || (check_box2 == QMessageBox::Ok)) - { - //First, remove the old selection from the Gui, so that we do not directly have the same CAD once again. - Gui::Selection().clearCompleteSelection(); - //to make a Selection more easy, hide the dialog - this->hide(); - QTimer::singleShot(100,this,SLOT(selectMesh())); - m_timer = true; - } - } - else - { - std::vector fea = Gui::Selection().getObjectsOfType(Mesh::Feature::getClassTypeId()); - if ( fea.size() == 1) - { - m_Mesh = static_cast(fea.front())->Mesh.getValue().getKernel(); - //std::vector aSelection = Gui::Selection().getSelection(); - this->show(); - m_timer = false; - } - else - { - QTimer::singleShot(100,this,SLOT(selectMesh())); - m_timer = true; - } - } -} - - -void Cutting::setFace(const TopoDS_Shape& aShape, const float x, const float y, const float z) -{ - //check if a Shape is selected - std::vector fea = Gui::Selection().getObjectsOfType(Part::Feature::getClassTypeId()); - if ( fea.size() == 1) - { - int test = aShape.ShapeType(); - //get Hash Code of Selected Face inside the selected Shape and also the Coordinates of the click - if (aShape.ShapeType() != TopAbs_FACE) - { - QMessageBox::information(this, tr("FreeCAD CamWorkbench"), tr("You have to select a Face!!\n")); - return; - } - - TopoDS_Face tempFace = TopoDS::Face(aShape); - //Now search for the Hash-Code in the m_Shape - TopExp_Explorer anExplorer; - TopoDS_Face aselectedFace; - - //pickPoint.Set(x,y,z); - for (anExplorer.Init(m_Shape,TopAbs_FACE);anExplorer.More();anExplorer.Next()) - { - if (tempFace.HashCode(IntegerLast()) == anExplorer.Current().HashCode(IntegerLast())) - { - if (m_selection == Springback) - (m_Spring->m_FixFaces).push_back(TopoDS::Face(anExplorer.Current())); - else if (m_selection == BestFit) - (m_BestFit->m_LowFaces).push_back(TopoDS::Face(anExplorer.Current())); - else if (m_selection == ToolpathCalculation) - m_CuttingAlgo->SetMachiningOrder(TopoDS::Face(anExplorer.Current()),x,y,z); - break; - } - } - } -} - -void Cutting::on_CalculateZLevel_clicked() -{ - // Instantiating Cutting class - if (m_CuttingAlgo == NULL) - m_CuttingAlgo = new cutting_tools(m_Shape); - else - { - delete m_CuttingAlgo; - m_CuttingAlgo = new cutting_tools(m_Shape); - } - m_Mode = 1; - CalculateFeatureBased->setEnabled(false); - CalculateSpiralBased->setEnabled(false); - toolpath_calculation_highest_level_button->setEnabled(true); - m_selection = ToolpathCalculation; -} - -void Cutting::on_CalculateFeatureBased_clicked() -{ - if (m_CuttingAlgo == NULL) - m_CuttingAlgo = new cutting_tools(m_Shape); - else - { - delete m_CuttingAlgo; - m_CuttingAlgo = new cutting_tools(m_Shape); - } - m_Mode = 2; - toolpath_calculation_highest_level_button->setEnabled(true); - m_selection = ToolpathCalculation; - CalculateZLevel->setEnabled(false); - CalculateSpiralBased->setEnabled(false); -} - -void Cutting::on_CalculateSpiralBased_clicked() -{ - if (m_CuttingAlgo == NULL) - m_CuttingAlgo = new cutting_tools(m_Shape); - else - { - delete m_CuttingAlgo; - m_CuttingAlgo = new cutting_tools(m_Shape); - } - m_Mode = 3;// - toolpath_calculation_highest_level_button->setEnabled(true); - m_selection = ToolpathCalculation; - CalculateZLevel->setEnabled(false); - CalculateFeatureBased->setEnabled(false); - -} - -void Cutting::on_select_shape_z_level_button_clicked() -{ - selectShape(); -} - -void Cutting::on_select_shape_feature_based_button_clicked() -{ - selectShape(); -} - -void Cutting::on_select_shape_spiral_based_button_clicked() -{ - selectShape(); -} - -void Cutting::on_toolpath_calculation_highest_level_button_clicked() -{ - Gui::Document* doc = Gui::Application::Instance->activeDocument(); - Gui::View3DInventor* view = static_cast(doc->getActiveView()); - if (view) - { - Gui::View3DInventorViewer* viewer = view->getViewer(); - viewer->setEditing(true); - viewer->addEventCallback(SoMouseButtonEvent::getClassTypeId(), zLevelCallback, this); - QMessageBox::information(this, tr("FreeCAD CamWorkbench"), tr("You have to pick a point.\n")); - this->hide(); - } - toolpath_calculation_middle_level_button->setEnabled(true); - toolpath_calculation_lowest_level_button->setEnabled(true); -} - -void Cutting::on_toolpath_calculation_middle_level_button_clicked() -{ - Gui::Document* doc = Gui::Application::Instance->activeDocument(); - Gui::View3DInventor* view = static_cast(doc->getActiveView()); - if (view) - { - Gui::View3DInventorViewer* viewer = view->getViewer(); - viewer->setEditing(true); - viewer->addEventCallback(SoMouseButtonEvent::getClassTypeId(), zLevelCallback, this); - QMessageBox::information(this, tr("FreeCAD CamWorkbench"), tr("You have to pick a point.\n")); - this->hide(); - } -} - -void Cutting::on_toolpath_calculation_lowest_level_button_clicked() -{ - Gui::Document* doc = Gui::Application::Instance->activeDocument(); - Gui::View3DInventor* view = static_cast(doc->getActiveView()); - if (view) - { - Gui::View3DInventorViewer* viewer = view->getViewer(); - viewer->setEditing(true); - viewer->addEventCallback(SoMouseButtonEvent::getClassTypeId(), zLevelCallback, this); - QMessageBox::information(this, tr("FreeCAD CamWorkbench"), tr("You have to pick a point.\n")); - this->hide(); - } - toolpath_calculation_go_button->setEnabled(true); -} - -void Cutting::on_toolpath_calculation_go_button_clicked() -{ - //Do the actual Cut - //First transfer the settings to the Cutting_tools class - m_CuttingAlgo->m_UserSettings = getSettings(); - - if (!m_CuttingAlgo->arrangecuts_ZLEVEL()) - { - std::cout << "Couldn't cut properly" << std::endl; - } - - bool ok = true; - try - { - switch (m_Mode) - { - case 1: - ok = m_CuttingAlgo->OffsetWires_Standard(); - break; - case 2: - ok = m_CuttingAlgo->OffsetWires_FeatureBased(); - break; - case 3: - ok = m_CuttingAlgo->OffsetWires_Spiral(); - break; - } - } - catch (...) - { - std::cout<<"Error"<setEnabled(true); - GenSimOut->setEnabled(true); -} - -void Cutting::on_GenSimOut_clicked() -{ - QString dir = QFileDialog::getExistingDirectory(this, tr("Select Simulation-Path Output-Directory"),"d:/", - QFileDialog::ShowDirsOnly - | QFileDialog::DontResolveSymlinks); - if (dir.isNull()) - return; - QDir::setCurrent(dir); - if (m_PathSimulate != NULL) delete m_PathSimulate;//If it exists already - m_PathSimulate = new path_simulate(*(m_CuttingAlgo->getOutputhigh()),*(m_CuttingAlgo->getOutputlow()),m_CuttingAlgo->m_UserSettings); - switch (m_Mode) - { - case 1: - if (m_PathSimulate->MakePathSimulate()) - adaptdynainput->setEnabled(true); - break; - case 2: - if (m_PathSimulate->MakePathSimulate_Feat(m_CuttingAlgo->getFlatAreas(),0)) - adaptdynainput->setEnabled(true); - break; - case 3: - if (m_PathSimulate->MakePathSimulate_Feat(m_CuttingAlgo->getFlatAreas(),1)) - adaptdynainput->setEnabled(true); - break; - } - -} - -void Cutting::on_GenRobotOut_clicked() -{ - QString dir = QFileDialog::getExistingDirectory(this, tr("Select File Output-Directory"),"d:/", - QFileDialog::ShowDirsOnly - | QFileDialog::DontResolveSymlinks); - QDir::setCurrent(dir); - if (m_PathSimulate != NULL) delete m_PathSimulate; - m_PathSimulate = new path_simulate(*(m_CuttingAlgo->getOutputhigh()),*(m_CuttingAlgo->getOutputlow()),m_CuttingAlgo->m_UserSettings); - - switch (m_Mode) - { - case 1: - m_PathSimulate->MakePathRobot(); - break; - case 2: - m_PathSimulate->MakePathRobot_Feat(m_CuttingAlgo->getFlatAreas()); - break; - } -} - - -const CuttingToolsSettings& Cutting::getSettings() -{ - //First transfer the settings to the Cutting_tools class - m_Settings.cad_radius = cad_radius_box->value(); - m_Settings.correction_factor = correction_factor_box->value(); - m_Settings.level_distance = level_distance_box->value(); - m_Settings.limit_angle = limit_angle_box->value(); - m_Settings.sheet_thickness = sheet_thickness_box->value(); - m_Settings.slave_radius = slave_radius_box->value(); - m_Settings.master_radius = master_radius_box->value(); - m_Settings.max_Vel = max_vel->value(); - m_Settings.max_Acc = max_acc->value(); - m_Settings.spring_pretension = spring_pretension->value(); - m_Settings.x_offset_robot = xoffset_box->value(); - m_Settings.y_offset_robot = yoffset_box->value(); - m_Settings.clockwise = clockwise_checkbox->isChecked(); - m_Settings.error_tolerance = error_tolerance->value(); - - return m_Settings; -} - - -void Cutting::on_BestFitButton_clicked() -{ - - - - - - - m_selection = BestFit; - m_BestFit = new best_fit(); - - - // Best-Fit based on Point-Clouds - m_BestFit->Initialize_Mesh_Geometrie_1(); - m_BestFit->Initialize_Mesh_Geometrie_2(); - m_BestFit->Perform_PointCloud(); - m_BestFit->output_best_fit_mesh(); - - - best_fit_cad_button->setEnabled(true); -} - -void Cutting::on_SpringbackButton_clicked() -{ - m_Spring = new SpringbackCorrection(); - m_selection = Springback; - best_fit_cad_button->setEnabled(true); - -} - -void Cutting::on_Approximate_button_clicked() -{ - m_selection = Approx; - best_fit_mesh_button->setEnabled(true); -} - -void Cutting::on_best_fit_cad_button_clicked() -{ - selectShape(); - best_fit_mesh_button->setEnabled(true); -} - -void Cutting::on_best_fit_mesh_button_clicked() -{ -if(m_selection == Springback) - { - best_fit_mesh2_button->setEnabled(true); - m_Spring->Load(m_Shape); - } - selectMesh(); - best_fit_go_button->setEnabled(true); - SelectFace_button->setEnabled(true); -if(m_selection == Springback) - best_fit_mesh2_button->setEnabled(true); -} -void Cutting::on_best_fit_mesh2_button_clicked() -{ - m_Spring->Load(m_Mesh); - selectMesh(); -} - -void Cutting::on_SelectFace_button_clicked() -{ - - - Gui::Document* doc = Gui::Application::Instance->activeDocument(); - Gui::View3DInventor* view = static_cast(doc->getActiveView()); - if (view) - { - Gui::View3DInventorViewer* viewer = view->getViewer(); - viewer->setEditing(true); - viewer->addEventCallback(SoMouseButtonEvent::getClassTypeId(), zLevelCallback, this); - QMessageBox::information(this, tr("FreeCAD CamWorkbench"), tr("You have to pick a face.\n")); - this->hide(); - } -} - -void Cutting::on_best_fit_go_button_clicked() -{ - bool out = 1; //specifies whether ONLY the error vectors should be output in the case of springback - getSettings(); //First transfer the settings to the Cutting_tools class (-> m_Settings) - - - switch (m_selection) - { - - case BestFit: - - - m_BestFit->Load(m_Mesh,m_Shape); - m_BestFit->Perform(); - - best_fit_cad_button ->setEnabled(false); - best_fit_mesh_button->setEnabled(false); - best_fit_go_button ->setEnabled(false); - - m_MeshOut = m_BestFit->m_MeshWork; - m_MeshCad = m_BestFit->m_CadMesh; - DisplayMeshOutput(m_MeshOut); - //DisplayMeshOutput(m_MeshCad); - - - - - break; - - case Springback: - - m_Spring->Load(m_Mesh); - m_Spring->Init_Setting(m_Settings); - m_Spring->Init(); - m_Spring->Perform(m_Settings.limit_angle,out); - m_MeshCad = m_Spring->m_CadMesh; - - - - best_fit_cad_button ->setEnabled(false); - best_fit_mesh_button->setEnabled(false); - best_fit_go_button ->setEnabled(false); - - if(out==0) - { - DisplayMeshOutput(m_MeshCad); - DisplayMeshOutput(m_Spring->m_Mesh_vis); - DisplayMeshOutput(m_Spring->m_Mesh_vis2); - } -best_fit_mesh2_button->setEnabled(true); - break; - - case Approx: - // The file "Kleines.stl" has a point above the level ... not compatible with this Algo - /*MeshCore::MeshPointArray pnts = m_Mesh.GetPoints(); - MeshCore::MeshFacetArray facets = m_Mesh.GetFacets(); - - for(int i=0; i0.0) - pnts[i].z *= -1; - } - - m_Mesh.Assign(pnts,facets);*/ - - std::vector CtrlPnts, U_knot, V_knot; - int degU,degV; - m_App = new Approximate(m_Mesh,CtrlPnts,U_knot,V_knot,degU,degV,m_Settings.error_tolerance); - - //m_Approx = new UniGridApprox(m_Mesh, 1); - //m_Approx->Perform(0.1); - - BRepBuilderAPI_MakeFace Face(m_App->aAdaptorSurface.Surface()); - m_Shape = Face.Face(); - - ofstream anOutputFile; - anOutputFile.open("c:/approx_log.txt"); - anOutputFile << "face assigned" << endl; - - DisplayMeshOutput(m_App->MeshParam); - DisplayShapeOutput(); - break; - } -} - -void Cutting::DisplayMeshOutput(const MeshCore::MeshKernel &mesh) -{ - App::Document* doc = App::GetApplication().getActiveDocument(); - App::DocumentObject* obj = doc->addObject("Mesh::Feature","Best_Fit-Mesh"); - - Mesh::Feature* part1 = static_cast(obj); - part1->Mesh.setValue(mesh); - - //doc->recompute(); -} - -void Cutting::DisplayShapeOutput() -{ - App::Document* doc = App::GetApplication().getActiveDocument(); - App::DocumentObject* obj = doc->addObject("Part::Feature","Output-Shape"); - - Part::Feature* part1 = static_cast(obj); - part1->Shape.setValue(m_Shape); - - //doc->recompute(); -} - -void Cutting::DisplayCAMOutput() -{ - BRep_Builder BB; - TopoDS_Compound aCompound1,aCompound2; - BB.MakeCompound(aCompound1); - BB.MakeCompound(aCompound2); - TopoDS_Edge anEdge; - const std::vector* topCurves; - const std::vector* botCurves; - std::vector::const_iterator an_it1; - topCurves = m_CuttingAlgo->getOutputhigh(); - botCurves = m_CuttingAlgo->getOutputlow(); - for (an_it1 = topCurves->begin();an_it1!=topCurves->end();an_it1++) - { - BB.MakeEdge(anEdge,*an_it1,0.01); - BB.Add(aCompound1,anEdge); - - } - for (an_it1 = botCurves->begin();an_it1!=botCurves->end();an_it1++) - { - BB.MakeEdge(anEdge,*an_it1,0.01); - BB.Add(aCompound2,anEdge); - } - - App::Document* doc = App::GetApplication().getActiveDocument(); - App::DocumentObject* obj = doc->addObject("Part::Feature","Master-Tool"); - App::DocumentObject* obj1 = doc->addObject("Part::Feature","Slave-Tool"); - - Part::Feature* part1 = static_cast(obj); - Part::Feature* part2 = static_cast(obj1); - part1->Shape.setValue(aCompound1); - part2->Shape.setValue(aCompound2); - - - - - - - // - // for (unsigned int i=0;i topCurves; - //std::vector botCurves; - //std::vector::iterator an_it; - //topCurves = *(anewCuttingEnv.getOutputhigh()); - //botCurves = *(anewCuttingEnv.getOutputlow()); - - ofstream anoutput; - ofstream anoutput2; - anoutput.open("c:/topCurves.txt"); - anoutput2.open("c:/botCurves.txt"); - for (an_it1 = topCurves->begin();an_it1!=topCurves->end();an_it1++) - { - GeomAdaptor_Curve aCurveAdaptor(*an_it1); - GCPnts_QuasiUniformDeflection aPointGenerator(aCurveAdaptor,0.1); - for (int t=1;t<=aPointGenerator.NbPoints();++t) - { - anoutput << (aPointGenerator.Value(t)).X() <<","<< (aPointGenerator.Value(t)).Y() <<","<<(aPointGenerator.Value(t)).Z()<begin();an_it1!=botCurves->end();an_it1++) - { - GeomAdaptor_Curve aCurveAdaptor(*an_it1); - GCPnts_QuasiUniformDeflection aPointGenerator(aCurveAdaptor,0.1); - for (int t=1;t<=aPointGenerator.NbPoints();++t) - { - anoutput2 << (aPointGenerator.Value(t)).X() <<","<< (aPointGenerator.Value(t)).Y() <<","<<(aPointGenerator.Value(t)).Z()<getEvent(); - Gui::View3DInventorViewer* view = reinterpret_cast(n->getUserData()); - Cutting* that = reinterpret_cast(ud); - - // Mark all incoming mouse button events as handled, especially, to deactivate the selection node - n->getAction()->setHandled(); - if (mbe->getButton() == SoMouseButtonEvent::BUTTON2 && mbe->getState() == SoButtonEvent::UP) - { - n->setHandled(); - view->setEditing(false); - view->removeEventCallback(SoMouseButtonEvent::getClassTypeId(), zLevelCallback, that); - that->show(); - } - else if (mbe->getButton() == SoMouseButtonEvent::BUTTON1 && mbe->getState() == SoButtonEvent::DOWN) - { - const SoPickedPoint * point = n->getPickedPoint(); - if (point == NULL) - { - QMessageBox::warning(Gui::getMainWindow(),"z level", "No shape picked!"); - return; - } - - n->setHandled(); - - // By specifying the indexed mesh node 'pcFaceSet' we make sure that the picked point is - // really from the mesh we render and not from any other geometry - Gui::ViewProvider* vp = static_cast(view->getViewProviderByPath(point->getPath())); - if (!vp || !vp->getTypeId().isDerivedFrom(PartGui::ViewProviderPart::getClassTypeId())) - return; - PartGui::ViewProviderPart* vpp = static_cast(vp); - std::string element = vpp->getElement(point->getDetail()); - TopoDS_Shape sh = static_cast(vpp->getObject())-> - Shape.getShape().getSubShape(element.c_str()); - if (!sh.IsNull()) - { - // ok a shape was picked - n->setHandled(); - view->setEditing(false); - view->removeEventCallback(SoMouseButtonEvent::getClassTypeId(), zLevelCallback, that); - that->show(); - SbVec3f pt = point->getPoint(); - that->setFace(sh, pt[0],pt[1],pt[2]); - } - } -} - - - -#include "moc_Cutting.cpp" diff --git a/src/Mod/Cam/Gui/Cutting.h b/src/Mod/Cam/Gui/Cutting.h deleted file mode 100644 index 6cb85f61b3..0000000000 --- a/src/Mod/Cam/Gui/Cutting.h +++ /dev/null @@ -1,137 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2007 Joachim Zettler * - * Copyright (c) 2007 Werner Mayer * - * * - * This file is part of the FreeCAD CAx development system. * - * * - * This library is free software; you can redistribute it and/or * - * modify it under the terms of the GNU Library General Public * - * License as published by the Free Software Foundation; either * - * version 2 of the License, or (at your option) any later version. * - * * - * This library is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * - * GNU Library General Public License for more details. * - * * - * You should have received a copy of the GNU Library General Public * - * License along with this library; see the file COPYING.LIB. If not, * - * write to the Free Software Foundation, Inc., 59 Temple Place, * - * Suite 330, Boston, MA 02111-1307, USA * - * * - ***************************************************************************/ - -#ifndef CAMGUI_CUTTING_H -#define CAMGUI_CUTTING_H - -#include "ui_Cutting.h" - -#include -#include -#include -#include -#include -#include -#include - -class best_fit; -class cutting_tools; -class path_simulate; -class SpringbackCorrection; -class UniGridApprox; -class TopoDS_Shape; -class Approximate; -class Deviation; -class MergeData; - -namespace CamGui -{ - -class Cutting : public QDialog, public Ui_Cutting -{ - Q_OBJECT - -public: - Cutting(QWidget* parent,Qt::WFlags = 0); - ~Cutting(); -protected Q_SLOTS: - void on_CalculateZLevel_clicked(); - void on_CalculateFeatureBased_clicked(); - void on_CalculateSpiralBased_clicked(); - void on_select_shape_z_level_button_clicked(); - void on_select_shape_feature_based_button_clicked(); - void on_select_shape_spiral_based_button_clicked(); - void on_toolpath_calculation_highest_level_button_clicked(); - void on_toolpath_calculation_middle_level_button_clicked(); - void on_toolpath_calculation_lowest_level_button_clicked(); - void on_toolpath_calculation_go_button_clicked(); - void on_GenSimOut_clicked(); - void on_GenRobotOut_clicked(); - void on_adaptdynainput_clicked(); - void on_start_simulation_clicked(); - void on_BestFitButton_clicked(); - void on_SpringbackButton_clicked(); - void on_Approximate_button_clicked(); - void on_best_fit_cad_button_clicked(); - void on_best_fit_mesh_button_clicked(); - void on_best_fit_mesh2_button_clicked(); - void on_SelectFace_button_clicked(); - void on_best_fit_go_button_clicked(); - void on_Deviation_button_clicked(); - void on_deviation_geometry1_button_clicked(); - void on_deviation_geometry2_button_clicked(); - void on_deviation_go_button_clicked(); - void on_error_accumulation_go_button_clicked(); - void on_error_accumulation_select_files_button_clicked(); - - - void selectShape(); - void selectMesh(); - bool getProcessOutput(); - const CuttingToolsSettings& getSettings(); - void setFace(const TopoDS_Shape &aFace, const float , const float,const float); - -private: - static void zLevelCallback(void * ud, SoEventCallback * n); - void DisplayCAMOutput(); - void DisplayMeshOutput(const MeshCore::MeshKernel &mesh); - void DisplayShapeOutput(); - - -private: - - SpringbackCorrection *m_Spring; - cutting_tools *m_CuttingAlgo; //Generate an instance of the cutting class on the heap - path_simulate *m_PathSimulate; - best_fit *m_BestFit; - UniGridApprox *m_Approx; - Approximate *m_App; - Deviation *m_Deviation; - MergeData *m_MergeData; - - CuttingToolsSettings m_Settings; - - QProcess *m_Process; - TopoDS_Shape m_Shape; - MeshCore::MeshKernel m_Mesh; - MeshCore::MeshKernel m_MeshOut; - MeshCore::MeshKernel m_MeshCad; - bool m_timer; - //1 means Standard, 2 means Feature Based, 3 means Spiral Based - unsigned int m_Mode; - - enum support_selection - { - BestFit, - Springback, - Approx, - ToolpathCalculation - }; - support_selection m_selection; - - -}; - -} - -#endif diff --git a/src/Mod/Cam/Gui/Cutting.ui b/src/Mod/Cam/Gui/Cutting.ui deleted file mode 100644 index c83845117e..0000000000 --- a/src/Mod/Cam/Gui/Cutting.ui +++ /dev/null @@ -1,1197 +0,0 @@ - - - CamGui::Cutting - - - - 0 - 0 - 790 - 604 - - - - Dialog - - - - - 420 - 560 - 351 - 33 - - - - - 6 - - - 0 - - - - - Qt::Horizontal - - - - 131 - 31 - - - - - - - - OK - - - - - - - Cancel - - - - - - - - - 460 - 10 - 320 - 252 - - - - Main-Functions - - - - 6 - - - 9 - - - - - 6 - - - 0 - - - - - 6 - - - 0 - - - - - Select Shape to Cut - - - Select Shape - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - false - - - - 0 - 6 - - - - - - - Calculate Z-Level Toolpath - - - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - 6 - - - 0 - - - - - Select Shape to Cut - - - Select Shape - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - false - - - Calculate Feature Based Toolpath - - - true - - - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - 6 - - - 0 - - - - - Select Shape to Cut - - - Select Shape - - - - - - - false - - - Calculate Spiral Based Toolpath - - - true - - - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - Make a Best-Fit - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - Correct Springback - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - Approximate NURB Surface - - - - - - - Deviation Analysis - - - - - - - - - - - 10 - 10 - 131 - 166 - - - - Selection - - - - 6 - - - 9 - - - - - 6 - - - 0 - - - - - false - - - Highest Level - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - false - - - Middle Level - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - false - - - Lowest Level - - - - - - - false - - - GO - - - - - - - - - - - 460 - 282 - 320 - 94 - - - - Post-Processing - - - - 6 - - - 9 - - - - - 6 - - - 0 - - - - - false - - - Generate Robot-Output - - - - - - - false - - - Generate Simulation-Output - - - true - - - - - - - - - 6 - - - 0 - - - - - true - - - AdaptDynaInput - - - - - - - - - - - 460 - 383 - 321 - 92 - - - - Simulation-Stuff - - - - 6 - - - 9 - - - - - 6 - - - 0 - - - - - false - - - Start Simulation - - - - - - - false - - - <html><head><meta name="qrichtext" content="1" /><style type="text/css"> -p, li { white-space: pre-wrap; } -</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Start Continuous Simulation Mode</p></body></html> - - - Cont-Simulation - - - - - - - - - - - 620 - 490 - 74 - 14 - - - - Y-Offset-Robot - - - - - - 540 - 490 - 74 - 14 - - - - X-Offset-Robot - - - - - - 550 - 510 - 62 - 22 - - - - 1000.000000000000000 - - - 290.000000000000000 - - - - - - 630 - 510 - 62 - 22 - - - - 1000.000000000000000 - - - 145.000000000000000 - - - - - true - - - - 150 - 10 - 132 - 194 - - - - Best-Fit and Springback - - - - 6 - - - 9 - - - - - 7 - - - 0 - - - - - false - - - CAD-Part - - - - - - - false - - - Scanned Mesh - - - - - - - false - - - Scanned Mesh 2 - - - - - - - false - - - Select Face - - - - - - - false - - - GO - - - - - - - - - - - 10 - 219 - 255 - 341 - - - - Settings - - - - - 90 - 25 - 155 - 20 - - - - Smallest CAD radius - - - - - - 90 - 103 - 155 - 20 - - - - Cutting-Distance - - - - - - 11 - 103 - 73 - 20 - - - - 1.000000000000000 - - - - - - 90 - 129 - 155 - 20 - - - - Correction Factor for Springback - - - - - - 90 - 155 - 155 - 20 - - - - Limit Angle - - - - - - 90 - 181 - 155 - 20 - - - - Sheet Thickness - - - - - - 90 - 207 - 155 - 20 - - - - Max-Velocity - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - - - - - 90 - 233 - 155 - 20 - - - - Max-Acceleration - - - - - - 90 - 260 - 155 - 20 - - - - Spring Pretension - - - - - - 90 - 287 - 155 - 20 - - - - Error-Tolerance - - - - - - 11 - 233 - 73 - 20 - - - - 0 - - - 50000.000000000000000 - - - 500.000000000000000 - - - 20000.000000000000000 - - - - - - 11 - 181 - 73 - 20 - - - - - - - - - - 0.500000000000000 - - - 1.000000000000000 - - - - - - 11 - 207 - 73 - 20 - - - - 10000.000000000000000 - - - 600.000000000000000 - - - - - - 11 - 129 - 73 - 20 - - - - 0.700000000000000 - - - - - - 11 - 155 - 73 - 20 - - - - 60.000000000000000 - - - - - - 11 - 77 - 73 - 20 - - - - 10.000000000000000 - - - - - - 11 - 51 - 73 - 20 - - - - 99.989999999999995 - - - 10.000000000000000 - - - - - - 11 - 25 - 73 - 20 - - - - 10.000000000000000 - - - - - - 90 - 51 - 155 - 20 - - - - Master-Radius - - - - - - 90 - 77 - 155 - 20 - - - - Slave-Radius - - - - - - 11 - 320 - 168 - 19 - - - - Clockwise Movement - - - - - - 10 - 287 - 73 - 20 - - - - 1 - - - 10.000000000000000 - - - 0.100000000000000 - - - 0.500000000000000 - - - - - - 10 - 260 - 73 - 20 - - - - 1 - - - 10.000000000000000 - - - 0.100000000000000 - - - 1.000000000000000 - - - - - - true - - - - 310 - 10 - 132 - 194 - - - - Deviation Analysis - - - - 6 - - - 9 - - - - - 7 - - - 0 - - - - - false - - - Geometry 1 - - - - - - - false - - - Geometry 2 - - - - - - - false - - - GO - - - - - - - - - - true - - - - 310 - 220 - 132 - 101 - - - - Error Accumulation - - - - 6 - - - 9 - - - - - 7 - - - 0 - - - - - true - - - Select Files - - - - - - - false - - - GO - - - - - - - - - - - - okButton - clicked() - CamGui::Cutting - accept() - - - 446 - 407 - - - 239 - 398 - - - - - cancelButton - clicked() - CamGui::Cutting - reject() - - - 521 - 404 - - - 581 - 392 - - - - - diff --git a/src/Mod/Cam/Gui/PreCompiled.cpp b/src/Mod/Cam/Gui/PreCompiled.cpp deleted file mode 100644 index b2ceb9185b..0000000000 --- a/src/Mod/Cam/Gui/PreCompiled.cpp +++ /dev/null @@ -1,24 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2007 Joachim Zettler * - * * - * This file is part of the FreeCAD CAx development system. * - * * - * This library is free software; you can redistribute it and/or * - * modify it under the terms of the GNU Library General Public * - * License as published by the Free Software Foundation; either * - * version 2 of the License, or (at your option) any later version. * - * * - * This library is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * - * GNU Library General Public License for more details. * - * * - * You should have received a copy of the GNU Library General Public * - * License along with this library; see the file COPYING.LIB. If not, * - * write to the Free Software Foundation, Inc., 59 Temple Place, * - * Suite 330, Boston, MA 02111-1307, USA * - * * - ***************************************************************************/ - - -#include "PreCompiled.h" diff --git a/src/Mod/Cam/Gui/PreCompiled.h b/src/Mod/Cam/Gui/PreCompiled.h deleted file mode 100644 index 64e156fdfe..0000000000 --- a/src/Mod/Cam/Gui/PreCompiled.h +++ /dev/null @@ -1,130 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2007 Joachim Zettler * - * * - * This file is part of the FreeCAD CAx development system. * - * * - * This library is free software; you can redistribute it and/or * - * modify it under the terms of the GNU Library General Public * - * License as published by the Free Software Foundation; either * - * version 2 of the License, or (at your option) any later version. * - * * - * This library is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * - * GNU Library General Public License for more details. * - * * - * You should have received a copy of the GNU Library General Public * - * License along with this library; see the file COPYING.LIB. If not, * - * write to the Free Software Foundation, Inc., 59 Temple Place, * - * Suite 330, Boston, MA 02111-1307, USA * - * * - ***************************************************************************/ - - -#ifndef __PRECOMPILED_GUI__ -#define __PRECOMPILED_GUI__ - -#include - -#undef QT_NO_CAST_FROM_ASCII - -// Importing of App classes -#ifdef FC_OS_WIN32 -# define MeshExport __declspec(dllimport) -# define PartExport __declspec(dllimport) -# define PartGuiExport __declspec(dllimport) -# define CamExport __declspec(dllimport) -# define CamGuiExport __declspec(dllexport) -#else // for Linux -# define MeshExport -# define PartExport -# define PartGuiExport -# define CamExport -# define CamGuiExport -#endif - -#ifdef _MSC_VER -# pragma warning(disable : 4290) -#endif - -#ifdef _PreComp_ -// standard -#include -//#include -#include -//#include -//#include -//#include - -// STL -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -#ifdef FC_OS_WIN32 -# include -#endif - -// Xerces -#include - -// OpenCasCade Base -#include - -// OpenCascade View -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - - - -// Qt Toolkit -#ifndef __QtAll__ -# include -#endif - -// Inventor -#ifndef __InventorAll__ -# include -#endif - -#include - - -#endif -#endif diff --git a/src/Mod/Cam/Gui/Workbench.cpp b/src/Mod/Cam/Gui/Workbench.cpp deleted file mode 100644 index 6c038a79f3..0000000000 --- a/src/Mod/Cam/Gui/Workbench.cpp +++ /dev/null @@ -1,68 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2005 Werner Mayer * - * * - * This file is part of the FreeCAD CAx development system. * - * * - * This library is free software; you can redistribute it and/or * - * modify it under the terms of the GNU Library General Public * - * License as published by the Free Software Foundation; either * - * version 2 of the License, or (at your option) any later version. * - * * - * This library is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * - * GNU Library General Public License for more details. * - * * - * You should have received a copy of the GNU Library General Public * - * License along with this library; see the file COPYING.LIB. If not, * - * write to the Free Software Foundation, Inc., 59 Temple Place, * - * Suite 330, Boston, MA 02111-1307, USA * - * * - ***************************************************************************/ - - -#include "PreCompiled.h" - -#ifndef _PreComp_ -# include -#endif - -#include "Workbench.h" -#include -#include - -using namespace CamGui; - -/// @namespace CamGui @class Workbench -TYPESYSTEM_SOURCE(CamGui::Workbench, Gui::StdWorkbench) - -Workbench::Workbench() -{ -} - -Workbench::~Workbench() -{ -} - -Gui::MenuItem* Workbench::setupMenuBar() const -{ - Gui::MenuItem* root = StdWorkbench::setupMenuBar(); - Gui::MenuItem* item = root->findItem("&Windows"); - Gui::MenuItem* cam = new Gui::MenuItem; - root->insertItem(item, cam); - cam->setCommand(QT_TR_NOOP("&Cam")); - *cam /*<< "Cam_ShapeInfo"*/ << "Cam_Cutting"; - return root; -} - -Gui::ToolBarItem* Workbench::setupToolBars() const -{ - Gui::ToolBarItem* root = StdWorkbench::setupToolBars(); - return root; -} - -Gui::ToolBarItem* Workbench::setupCommandBars() const -{ - return 0; -} - diff --git a/src/Mod/Cam/Gui/Workbench.h b/src/Mod/Cam/Gui/Workbench.h deleted file mode 100644 index cc852749b9..0000000000 --- a/src/Mod/Cam/Gui/Workbench.h +++ /dev/null @@ -1,52 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2005 Werner Mayer * - * * - * This file is part of the FreeCAD CAx development system. * - * * - * This library is free software; you can redistribute it and/or * - * modify it under the terms of the GNU Library General Public * - * License as published by the Free Software Foundation; either * - * version 2 of the License, or (at your option) any later version. * - * * - * This library is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * - * GNU Library General Public License for more details. * - * * - * You should have received a copy of the GNU Library General Public * - * License along with this library; see the file COPYING.LIB. If not, * - * write to the Free Software Foundation, Inc., 59 Temple Place, * - * Suite 330, Boston, MA 02111-1307, USA * - * * - ***************************************************************************/ - - -#ifndef CAMGUI_WORKBENCH_H -#define CAMGUI_WORKBENCH_H - -#include - -namespace CamGui -{ - -/** - * @author Werner Mayer - */ -class CamGuiExport Workbench : public Gui::StdWorkbench -{ - TYPESYSTEM_HEADER(); - -public: - Workbench(); - virtual ~Workbench(); - -protected: - Gui::MenuItem* setupMenuBar() const; - Gui::ToolBarItem* setupToolBars() const; - Gui::ToolBarItem* setupCommandBars() const; -}; - -} // namespace CamGui - - -#endif // CAMGUI_WORKBENCH_H diff --git a/src/Mod/Cam/Init.py b/src/Mod/Cam/Init.py deleted file mode 100644 index 8e36760035..0000000000 --- a/src/Mod/Cam/Init.py +++ /dev/null @@ -1,25 +0,0 @@ -# FreeCAD init script of the Cam module -# (c) 2007 Juergen Riegel - -#*************************************************************************** -#* Copyright (c) 2007 Juergen Riegel * -#* * -#* This file is Cam of the FreeCAD CAx development system. * -#* * -#* This program is free software; you can redistribute it and/or modify * -#* it under the terms of the GNU Lesser General Public License (LGPL) * -#* as published by the Free Software Foundation; either version 2 of * -#* the License, or (at your option) any later version. * -#* for detail see the LICENCE text file. * -#* * -#* FreeCAD is distributed in the hope that it will be useful, * -#* but WITHOUT ANY WARRANTY; without even the implied warranty of * -#* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -#* GNU Lesser General Public License for more details. * -#* * -#* You should have received a copy of the GNU Library General Public * -#* License along with FreeCAD; if not, write to the Free Software * -#* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 * -#* USA * -#* * -#***************************************************************************/ diff --git a/src/Mod/Cam/InitGui.py b/src/Mod/Cam/InitGui.py deleted file mode 100644 index 254375b793..0000000000 --- a/src/Mod/Cam/InitGui.py +++ /dev/null @@ -1,69 +0,0 @@ -# Cam gui init module -# (c) 2003 Juergen Riegel -# -# Gathering all the information to start FreeCAD -# This is the second one of three init scripts, the third one -# runs when the gui is up - -#*************************************************************************** -#* Copyright (c) 2002 Juergen Riegel * -#* * -#* This file is part of the FreeCAD CAx development system. * -#* * -#* This program is free software; you can redistribute it and/or modify * -#* it under the terms of the GNU Lesser General Public License (LGPL) * -#* as published by the Free Software Foundation; either version 2 of * -#* the License, or (at your option) any later version. * -#* for detail see the LICENCE text file. * -#* * -#* FreeCAD is distributed in the hope that it will be useful, * -#* but WITHOUT ANY WARRANTY; without even the implied warranty of * -#* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -#* GNU Lesser General Public License for more details. * -#* * -#* You should have received a copy of the GNU Library General Public * -#* License along with FreeCAD; if not, write to the Free Software * -#* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 * -#* USA * -#* * -#***************************************************************************/ - - - -class CamWorkbench ( Workbench ): - "Cam workbench object" - Icon = """ - /* XPM */ - static const char *Cam_Box[]={ - "16 16 3 1", - ". c None", - "# c #000000", - "a c #c6c642", - "................", - ".......#######..", - "......#aaaaa##..", - ".....#aaaaa###..", - "....#aaaaa##a#..", - "...#aaaaa##aa#..", - "..#aaaaa##aaa#..", - ".########aaaa#..", - ".#aaaaa#aaaaa#..", - ".#aaaaa#aaaa##..", - ".#aaaaa#aaa##...", - ".#aaaaa#aa##....", - ".#aaaaa#a##... .", - ".#aaaaa###......", - ".########.......", - "................"}; - """ - MenuText = "Cam design" - ToolTip = "Cam" - - def Initialize(self): - import CamGui - import Cam - def GetClassName(self): - return "CamGui::Workbench" - -# No Workbench at the moment -Gui.addWorkbench(CamWorkbench()) diff --git a/src/Mod/Cam/cam.dox b/src/Mod/Cam/cam.dox deleted file mode 100644 index 7ee18af9d6..0000000000 --- a/src/Mod/Cam/cam.dox +++ /dev/null @@ -1,3 +0,0 @@ -/** \defgroup CAM Cam - * \ingroup WORKBENCHES */ - diff --git a/src/Mod/Cam/doxygen_config b/src/Mod/Cam/doxygen_config deleted file mode 100644 index b1c27b2a97..0000000000 --- a/src/Mod/Cam/doxygen_config +++ /dev/null @@ -1,286 +0,0 @@ -# Doxyfile 1.5.6 - -#--------------------------------------------------------------------------- -# Project related configuration options -#--------------------------------------------------------------------------- -DOXYFILE_ENCODING = UTF-8 -PROJECT_NAME = "FreeCAD CAM Module" -PROJECT_NUMBER = 0.1 -OUTPUT_DIRECTORY = Doc -CREATE_SUBDIRS = NO -OUTPUT_LANGUAGE = English -BRIEF_MEMBER_DESC = YES -REPEAT_BRIEF = YES -ABBREVIATE_BRIEF = "The $name class" \ - "The $name widget" \ - "The $name file" \ - is \ - provides \ - specifies \ - contains \ - represents \ - a \ - an \ - the -ALWAYS_DETAILED_SEC = NO -INLINE_INHERITED_MEMB = NO -FULL_PATH_NAMES = NO -STRIP_FROM_PATH = -STRIP_FROM_INC_PATH = -SHORT_NAMES = NO -JAVADOC_AUTOBRIEF = NO -QT_AUTOBRIEF = NO -MULTILINE_CPP_IS_BRIEF = NO -DETAILS_AT_TOP = NO -INHERIT_DOCS = YES -SEPARATE_MEMBER_PAGES = NO -TAB_SIZE = 8 -ALIASES = -OPTIMIZE_OUTPUT_FOR_C = NO -OPTIMIZE_OUTPUT_JAVA = NO -OPTIMIZE_FOR_FORTRAN = NO -OPTIMIZE_OUTPUT_VHDL = NO -BUILTIN_STL_SUPPORT = YES -CPP_CLI_SUPPORT = NO -SIP_SUPPORT = NO -IDL_PROPERTY_SUPPORT = YES -DISTRIBUTE_GROUP_DOC = NO -SUBGROUPING = YES -TYPEDEF_HIDES_STRUCT = NO -#--------------------------------------------------------------------------- -# Build related configuration options -#--------------------------------------------------------------------------- -EXTRACT_ALL = YES -EXTRACT_PRIVATE = YES -EXTRACT_STATIC = YES -EXTRACT_LOCAL_CLASSES = YES -EXTRACT_LOCAL_METHODS = NO -EXTRACT_ANON_NSPACES = NO -HIDE_UNDOC_MEMBERS = NO -HIDE_UNDOC_CLASSES = NO -HIDE_FRIEND_COMPOUNDS = NO -HIDE_IN_BODY_DOCS = NO -INTERNAL_DOCS = NO -CASE_SENSE_NAMES = NO -HIDE_SCOPE_NAMES = NO -SHOW_INCLUDE_FILES = YES -INLINE_INFO = YES -SORT_MEMBER_DOCS = YES -SORT_BRIEF_DOCS = NO -SORT_GROUP_NAMES = NO -SORT_BY_SCOPE_NAME = NO -GENERATE_TODOLIST = YES -GENERATE_TESTLIST = YES -GENERATE_BUGLIST = YES -GENERATE_DEPRECATEDLIST= YES -ENABLED_SECTIONS = -MAX_INITIALIZER_LINES = 30 -SHOW_USED_FILES = YES -SHOW_DIRECTORIES = NO -SHOW_FILES = YES -SHOW_NAMESPACES = YES -FILE_VERSION_FILTER = -#--------------------------------------------------------------------------- -# configuration options related to warning and progress messages -#--------------------------------------------------------------------------- -QUIET = NO -WARNINGS = YES -WARN_IF_UNDOCUMENTED = YES -WARN_IF_DOC_ERROR = YES -WARN_NO_PARAMDOC = NO -WARN_FORMAT = "$file:$line: $text" -WARN_LOGFILE = -#--------------------------------------------------------------------------- -# configuration options related to the input files -#--------------------------------------------------------------------------- -INPUT = App -INPUT_ENCODING = UTF-8 -FILE_PATTERNS = *.c \ - *.cc \ - *.cxx \ - *.cpp \ - *.c++ \ - *.d \ - *.java \ - *.ii \ - *.ixx \ - *.ipp \ - *.i++ \ - *.inl \ - *.h \ - *.hh \ - *.hxx \ - *.hpp \ - *.h++ \ - *.idl \ - *.odl \ - *.cs \ - *.php \ - *.php3 \ - *.inc \ - *.m \ - *.mm \ - *.dox \ - *.py \ - *.f90 \ - *.f \ - *.vhd \ - *.vhdl -RECURSIVE = YES -EXCLUDE = -EXCLUDE_SYMLINKS = NO -EXCLUDE_PATTERNS = -EXCLUDE_SYMBOLS = -EXAMPLE_PATH = -EXAMPLE_PATTERNS = * -EXAMPLE_RECURSIVE = NO -IMAGE_PATH = -INPUT_FILTER = -FILTER_PATTERNS = -FILTER_SOURCE_FILES = NO -#--------------------------------------------------------------------------- -# configuration options related to source browsing -#--------------------------------------------------------------------------- -SOURCE_BROWSER = YES -INLINE_SOURCES = NO -STRIP_CODE_COMMENTS = YES -REFERENCED_BY_RELATION = YES -REFERENCES_RELATION = YES -REFERENCES_LINK_SOURCE = YES -USE_HTAGS = NO -VERBATIM_HEADERS = YES -#--------------------------------------------------------------------------- -# configuration options related to the alphabetical class index -#--------------------------------------------------------------------------- -ALPHABETICAL_INDEX = NO -COLS_IN_ALPHA_INDEX = 5 -IGNORE_PREFIX = -#--------------------------------------------------------------------------- -# configuration options related to the HTML output -#--------------------------------------------------------------------------- -GENERATE_HTML = YES -HTML_OUTPUT = html -HTML_FILE_EXTENSION = .html -HTML_HEADER = -HTML_FOOTER = -HTML_STYLESHEET = -HTML_ALIGN_MEMBERS = YES -GENERATE_HTMLHELP = NO -GENERATE_DOCSET = NO -DOCSET_FEEDNAME = "Doxygen generated docs" -DOCSET_BUNDLE_ID = org.doxygen.Project -HTML_DYNAMIC_SECTIONS = NO -CHM_FILE = -HHC_LOCATION = -GENERATE_CHI = NO -CHM_INDEX_ENCODING = -BINARY_TOC = NO -TOC_EXPAND = NO -DISABLE_INDEX = NO -ENUM_VALUES_PER_LINE = 4 -GENERATE_TREEVIEW = ALL -TREEVIEW_WIDTH = 250 -FORMULA_FONTSIZE = 10 -#--------------------------------------------------------------------------- -# configuration options related to the LaTeX output -#--------------------------------------------------------------------------- -GENERATE_LATEX = NO -LATEX_OUTPUT = latex -LATEX_CMD_NAME = latex -MAKEINDEX_CMD_NAME = makeindex -COMPACT_LATEX = NO -PAPER_TYPE = a4wide -EXTRA_PACKAGES = -LATEX_HEADER = -PDF_HYPERLINKS = YES -USE_PDFLATEX = YES -LATEX_BATCHMODE = NO -LATEX_HIDE_INDICES = NO -#--------------------------------------------------------------------------- -# configuration options related to the RTF output -#--------------------------------------------------------------------------- -GENERATE_RTF = NO -RTF_OUTPUT = rtf -COMPACT_RTF = NO -RTF_HYPERLINKS = NO -RTF_STYLESHEET_FILE = -RTF_EXTENSIONS_FILE = -#--------------------------------------------------------------------------- -# configuration options related to the man page output -#--------------------------------------------------------------------------- -GENERATE_MAN = NO -MAN_OUTPUT = man -MAN_EXTENSION = .3 -MAN_LINKS = NO -#--------------------------------------------------------------------------- -# configuration options related to the XML output -#--------------------------------------------------------------------------- -GENERATE_XML = NO -XML_OUTPUT = xml -XML_SCHEMA = -XML_DTD = -XML_PROGRAMLISTING = YES -#--------------------------------------------------------------------------- -# configuration options for the AutoGen Definitions output -#--------------------------------------------------------------------------- -GENERATE_AUTOGEN_DEF = NO -#--------------------------------------------------------------------------- -# configuration options related to the Perl module output -#--------------------------------------------------------------------------- -GENERATE_PERLMOD = NO -PERLMOD_LATEX = NO -PERLMOD_PRETTY = YES -PERLMOD_MAKEVAR_PREFIX = -#--------------------------------------------------------------------------- -# Configuration options related to the preprocessor -#--------------------------------------------------------------------------- -ENABLE_PREPROCESSING = YES -MACRO_EXPANSION = NO -EXPAND_ONLY_PREDEF = NO -SEARCH_INCLUDES = YES -INCLUDE_PATH = -INCLUDE_FILE_PATTERNS = -PREDEFINED = -EXPAND_AS_DEFINED = -SKIP_FUNCTION_MACROS = YES -#--------------------------------------------------------------------------- -# Configuration::additions related to external references -#--------------------------------------------------------------------------- -TAGFILES = -GENERATE_TAGFILE = -ALLEXTERNALS = NO -EXTERNAL_GROUPS = YES -PERL_PATH = /usr/bin/perl -#--------------------------------------------------------------------------- -# Configuration options related to the dot tool -#--------------------------------------------------------------------------- -CLASS_DIAGRAMS = NO -MSCGEN_PATH = -HIDE_UNDOC_RELATIONS = YES -HAVE_DOT = YES -DOT_FONTNAME = FreeSans -DOT_FONTPATH = -CLASS_GRAPH = YES -COLLABORATION_GRAPH = YES -GROUP_GRAPHS = YES -UML_LOOK = NO -TEMPLATE_RELATIONS = NO -INCLUDE_GRAPH = YES -INCLUDED_BY_GRAPH = YES -CALL_GRAPH = NO -CALLER_GRAPH = NO -GRAPHICAL_HIERARCHY = YES -DIRECTORY_GRAPH = YES -DOT_IMAGE_FORMAT = png -DOT_PATH = "C:/Program Files/Graphviz2.16/bin" -DOTFILE_DIRS = -DOT_GRAPH_MAX_NODES = 50 -MAX_DOT_GRAPH_DEPTH = 1000 -DOT_TRANSPARENT = YES -DOT_MULTI_TARGETS = NO -GENERATE_LEGEND = YES -DOT_CLEANUP = YES -#--------------------------------------------------------------------------- -# Configuration::additions related to the search engine -#--------------------------------------------------------------------------- -SEARCHENGINE = NO