1 // Created on: 1995-06-20
2 // Created by: Stagiaire Alain JOURDAIN
3 // Copyright (c) 1995-1999 Matra Datavision
4 // Copyright (c) 1999-2014 OPEN CASCADE SAS
6 // This file is part of Open CASCADE Technology software library.
8 // This library is free software; you can redistribute it and/or modify it under
9 // the terms of the GNU Lesser General Public License version 2.1 as published
10 // by the Free Software Foundation, with special exception defined in the file
11 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
12 // distribution for complete text of the license and disclaimer of any warranty.
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
17 #include <BRepMesh_IncrementalMesh.hxx>
18 #include <BRepMesh_Context.hxx>
19 #include <BRepMesh_PluginMacro.hxx>
20 #include <IMeshData_Face.hxx>
21 #include <IMeshData_Wire.hxx>
22 #include <IMeshTools_MeshBuilder.hxx>
24 IMPLEMENT_STANDARD_RTTIEXT(BRepMesh_IncrementalMesh, BRepMesh_DiscretRoot)
28 //! Default flag to control parallelization for BRepMesh_IncrementalMesh
29 //! tool returned for Mesh Factory
30 static Standard_Boolean IS_IN_PARALLEL = Standard_False;
33 //=======================================================================
34 //function : Default constructor
36 //=======================================================================
37 BRepMesh_IncrementalMesh::BRepMesh_IncrementalMesh()
38 : myModified(Standard_False),
39 myStatus(IMeshData_NoError)
43 //=======================================================================
44 //function : Constructor
46 //=======================================================================
47 BRepMesh_IncrementalMesh::BRepMesh_IncrementalMesh( const TopoDS_Shape& theShape,
48 const Standard_Real theLinDeflection,
49 const Standard_Boolean isRelative,
50 const Standard_Real theAngDeflection,
51 const Standard_Boolean isInParallel)
52 : myModified(Standard_False),
53 myStatus(IMeshData_NoError)
55 myParameters.Deflection = theLinDeflection;
56 myParameters.Angle = theAngDeflection;
57 myParameters.Relative = isRelative;
58 myParameters.InParallel = isInParallel;
64 //=======================================================================
65 //function : Constructor
67 //=======================================================================
68 BRepMesh_IncrementalMesh::BRepMesh_IncrementalMesh(
69 const TopoDS_Shape& theShape,
70 const IMeshTools_Parameters& theParameters,
71 const Message_ProgressRange& theRange)
72 : myParameters(theParameters)
78 //=======================================================================
79 //function : Destructor
81 //=======================================================================
82 BRepMesh_IncrementalMesh::~BRepMesh_IncrementalMesh()
86 //=======================================================================
89 //=======================================================================
90 void BRepMesh_IncrementalMesh::Perform(const Message_ProgressRange& theRange)
92 Handle(BRepMesh_Context) aContext = new BRepMesh_Context (myParameters.MeshAlgo);
93 Perform (aContext, theRange);
96 //=======================================================================
99 //=======================================================================
100 void BRepMesh_IncrementalMesh::Perform(const Handle(IMeshTools_Context)& theContext, const Message_ProgressRange& theRange)
104 theContext->SetShape(Shape());
105 theContext->ChangeParameters() = myParameters;
106 theContext->ChangeParameters().CleanModel = Standard_False;
108 Message_ProgressScope aPS(theRange, "Perform incmesh", 10);
109 IMeshTools_MeshBuilder aIncMesh(theContext);
110 aIncMesh.Perform(aPS.Next(9));
113 myStatus = IMeshData_UserBreak;
116 myStatus = IMeshData_NoError;
117 const Handle(IMeshData_Model)& aModel = theContext->GetModel();
118 if (!aModel.IsNull())
120 for (Standard_Integer aFaceIt = 0; aFaceIt < aModel->FacesNb(); ++aFaceIt)
122 const IMeshData::IFaceHandle& aDFace = aModel->GetFace(aFaceIt);
123 myStatus |= aDFace->GetStatusMask();
125 for (Standard_Integer aWireIt = 0; aWireIt < aDFace->WiresNb(); ++aWireIt)
127 const IMeshData::IWireHandle& aDWire = aDFace->GetWire(aWireIt);
128 myStatus |= aDWire->GetStatusMask();
136 //=======================================================================
139 //=======================================================================
140 Standard_Integer BRepMesh_IncrementalMesh::Discret(
141 const TopoDS_Shape& theShape,
142 const Standard_Real theDeflection,
143 const Standard_Real theAngle,
144 BRepMesh_DiscretRoot* &theAlgo)
146 BRepMesh_IncrementalMesh* anAlgo = new BRepMesh_IncrementalMesh();
147 anAlgo->ChangeParameters().Deflection = theDeflection;
148 anAlgo->ChangeParameters().Angle = theAngle;
149 anAlgo->ChangeParameters().InParallel = IS_IN_PARALLEL;
150 anAlgo->SetShape (theShape);
152 return 0; // no error
155 //=======================================================================
156 //function : IsParallelDefault
158 //=======================================================================
159 Standard_Boolean BRepMesh_IncrementalMesh::IsParallelDefault()
161 return IS_IN_PARALLEL;
164 //=======================================================================
167 //=======================================================================
168 void BRepMesh_IncrementalMesh::SetParallelDefault(
169 const Standard_Boolean theInParallel)
171 IS_IN_PARALLEL = theInParallel;
174 //! Export Mesh Plugin entry function
175 DISCRETPLUGIN(BRepMesh_IncrementalMesh)