1 // Copyright (C) 2007-2024 CEA, EDF, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License, or (at your option) any later version.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
23 #include <GEOMImpl_ITestOperations.hxx>
25 #include <GEOMUtils.hxx>
27 #include <BRepBuilderAPI_Copy.hxx>
29 #include <utilities.h>
32 #define MAX2(X, Y) (Abs(X) > Abs(Y) ? Abs(X) : Abs(Y))
35 #define MAX3(X, Y, Z) (MAX2(MAX2(X, Y), Z))
38 //=============================================================================
42 //=============================================================================
43 GEOMImpl_ITestOperations::GEOMImpl_ITestOperations(GEOM_Engine* theEngine)
44 : GEOM_IOperations(theEngine)
46 MESSAGE("GEOMImpl_ITestOperations::GEOMImpl_ITestOperations");
49 //=============================================================================
53 //=============================================================================
54 GEOMImpl_ITestOperations::~GEOMImpl_ITestOperations()
56 MESSAGE("GEOMImpl_ITestOperations::~GEOMImpl_ITestOperations");
60 //=============================================================================
62 * \brief Build a mesh on (a copy of ) the given shape.
64 * This test function is aimed for checking performance of OCCT tesselation
65 * algorithm on particlar geometrical shapes.
67 * \param theShape is a source object
68 * \param theLinearDeflection is a value of deflection coefficient
69 * \param theIsRelative says if given value of deflection is relative to shape's bounding box
70 * \param theAngularDeflection is a angular deflection for edges in radians
71 * \return \c true in case of success; otherwise \c false.
73 //=============================================================================
74 bool GEOMImpl_ITestOperations::Tesselate(Handle(GEOM_Object) theShape,
75 double theLinearDeflection,
77 double theAngularDeflection)
80 // We don't need results of this method to be present in the data tree;
81 // so we don't need a driver for it.
86 // create a copy of the source shape
87 TopoDS_Shape aShape = BRepBuilderAPI_Copy(theShape->GetValue()).Shape();
89 // use default deflection if necessary
90 if (theLinearDeflection <= 0)
91 theLinearDeflection = 0.001;
93 // use default deviation angle if necessary: 20 degrees
94 if (theAngularDeflection <= 0)
95 theAngularDeflection = 20. * M_PI / 180.;
97 // compute triangulation
98 GEOMUtils::MeshShape(aShape, theLinearDeflection, /*theForced*/ true,
99 theAngularDeflection, theIsRelative);
101 // set OK status and return