0026106: BRepMesh - revision of data model
[occt.git] / src / IMeshTools / IMeshTools_MeshBuilder.cxx
1 // Created on: 2016-04-07
2 // Copyright (c) 2016 OPEN CASCADE SAS
3 // Created by: Oleg AGASHIN
4 //
5 // This file is part of Open CASCADE Technology software library.
6 //
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.
12 //
13 // Alternatively, this file may be used under the terms of Open CASCADE
14 // commercial license or contractual agreement.
15
16 #include <IMeshTools_MeshBuilder.hxx>
17 #include <IMeshData_Face.hxx>
18 #include <OSD_Parallel.hxx>
19
20 //=======================================================================
21 // Function: Constructor
22 // Purpose : 
23 //=======================================================================
24 IMeshTools_MeshBuilder::IMeshTools_MeshBuilder ()
25 {
26 }
27
28 //=======================================================================
29 // Function: Constructor
30 // Purpose : 
31 //=======================================================================
32 IMeshTools_MeshBuilder::IMeshTools_MeshBuilder (
33   const Handle (IMeshTools_Context)& theContext)
34   : myContext(theContext)
35 {
36 }
37
38 //=======================================================================
39 // Function: Destructor
40 // Purpose : 
41 //=======================================================================
42 IMeshTools_MeshBuilder::~IMeshTools_MeshBuilder ()
43 {
44 }
45
46 //=======================================================================
47 // Function: Perform
48 // Purpose : 
49 //=======================================================================
50 void IMeshTools_MeshBuilder::Perform ()
51 {
52   ClearStatus ();
53
54   const Handle (IMeshTools_Context)& aContext = GetContext ();
55   if (aContext.IsNull ())
56   {
57     SetStatus (Message_Fail1);
58     return;
59   }
60
61   if (aContext->BuildModel ())
62   {
63     if (aContext->DiscretizeEdges ())
64     {
65       if (aContext->HealModel ())
66       {
67         if (aContext->PreProcessModel())
68         {
69           if (aContext->DiscretizeFaces())
70           {
71             if (aContext->PostProcessModel())
72             {
73               SetStatus(Message_Done1);
74             }
75             else
76             {
77               SetStatus(Message_Fail7);
78             }
79           }
80           else
81           {
82             SetStatus(Message_Fail6);
83           }
84         }
85         else
86         {
87           SetStatus(Message_Fail5);
88         }
89       }
90       else
91       {
92         SetStatus(Message_Fail4);
93       }
94     }
95     else
96     {
97       SetStatus (Message_Fail3);
98     }
99   }
100   else
101   {
102     const Handle (IMeshTools_ModelBuilder)& aModelBuilder =
103       aContext->GetModelBuilder ();
104
105     if (aModelBuilder.IsNull ())
106     {
107       SetStatus (Message_Fail1);
108     }
109     else
110     {
111       // Is null shape or another problem?
112       SetStatus (aModelBuilder->GetStatus ().IsSet (Message_Fail1) ?
113         Message_Warn1 : Message_Fail2);
114     }
115   }
116
117   aContext->Clean ();
118 }