1 // Created on: 2016-04-07
2 // Copyright (c) 2016 OPEN CASCADE SAS
3 // Created by: Oleg AGASHIN
5 // This file is part of Open CASCADE Technology software library.
7 // This library is free software; you can redistribute it and/or modify it under
8 // the terms of the GNU Lesser General Public License version 2.1 as published
9 // by the Free Software Foundation, with special exception defined in the file
10 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
11 // distribution for complete text of the license and disclaimer of any warranty.
13 // Alternatively, this file may be used under the terms of Open CASCADE
14 // commercial license or contractual agreement.
16 #include <BRepMesh_ModelBuilder.hxx>
17 #include <BRepMeshData_Model.hxx>
18 #include <BRepMesh_ShapeVisitor.hxx>
19 #include <BRepMesh_ShapeTool.hxx>
20 #include <IMeshTools_ShapeExplorer.hxx>
21 #include <Standard_ErrorHandler.hxx>
23 #include <Bnd_Box.hxx>
24 #include <BRepBndLib.hxx>
26 //=======================================================================
27 // Function: Constructor
29 //=======================================================================
30 BRepMesh_ModelBuilder::BRepMesh_ModelBuilder ()
34 //=======================================================================
35 // Function: Destructor
37 //=======================================================================
38 BRepMesh_ModelBuilder::~BRepMesh_ModelBuilder ()
42 //=======================================================================
45 //=======================================================================
46 Handle (IMeshData_Model) BRepMesh_ModelBuilder::Perform (
47 const TopoDS_Shape& theShape,
48 const IMeshTools_Parameters& theParameters)
52 Handle (BRepMeshData_Model) aModel;
58 BRepBndLib::Add (theShape, aBox, Standard_False);
62 // Build data model for further processing.
63 aModel = new BRepMeshData_Model (theShape);
65 if (theParameters.Relative)
67 Standard_Real aMaxSize;
68 BRepMesh_ShapeTool::BoxMaxDimension (aBox, aMaxSize);
69 aModel->SetMaxSize(aMaxSize);
73 aModel->SetMaxSize(Max(theParameters.Deflection,
74 theParameters.DeflectionInterior));
77 Handle (IMeshTools_ShapeVisitor) aVisitor =
78 new BRepMesh_ShapeVisitor (aModel);
80 IMeshTools_ShapeExplorer aExplorer (theShape);
81 aExplorer.Accept (aVisitor);
82 SetStatus (Message_Done1);
86 SetStatus(Message_Fail1);
89 catch (Standard_Failure&)
91 SetStatus (Message_Fail2);