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_Status.hxx>
21 #include <IMeshData_Face.hxx>
22 #include <IMeshData_Wire.hxx>
23 #include <IMeshTools_MeshBuilder.hxx>
27 //! Default flag to control parallelization for BRepMesh_IncrementalMesh
28 //! tool returned for Mesh Factory
29 static Standard_Boolean IS_IN_PARALLEL = Standard_False;
32 //=======================================================================
33 //function : Default constructor
35 //=======================================================================
36 BRepMesh_IncrementalMesh::BRepMesh_IncrementalMesh()
37 : myModified(Standard_False),
38 myStatus(IMeshData_NoError)
42 //=======================================================================
43 //function : Constructor
45 //=======================================================================
46 BRepMesh_IncrementalMesh::BRepMesh_IncrementalMesh( const TopoDS_Shape& theShape,
47 const Standard_Real theLinDeflection,
48 const Standard_Boolean isRelative,
49 const Standard_Real theAngDeflection,
50 const Standard_Boolean isInParallel)
51 : myModified(Standard_False),
52 myStatus(IMeshData_NoError)
54 myParameters.Deflection = theLinDeflection;
55 myParameters.Angle = theAngDeflection;
56 myParameters.Relative = isRelative;
57 myParameters.InParallel = isInParallel;
63 //=======================================================================
64 //function : Constructor
66 //=======================================================================
67 BRepMesh_IncrementalMesh::BRepMesh_IncrementalMesh(
68 const TopoDS_Shape& theShape,
69 const IMeshTools_Parameters& theParameters)
70 : myParameters(theParameters)
76 //=======================================================================
77 //function : Destructor
79 //=======================================================================
80 BRepMesh_IncrementalMesh::~BRepMesh_IncrementalMesh()
84 //=======================================================================
87 //=======================================================================
88 void BRepMesh_IncrementalMesh::Perform()
90 Handle(BRepMesh_Context) aContext = new BRepMesh_Context;
94 //=======================================================================
97 //=======================================================================
98 void BRepMesh_IncrementalMesh::Perform(const Handle(IMeshTools_Context)& theContext)
102 theContext->SetShape(Shape());
103 theContext->ChangeParameters() = myParameters;
104 theContext->ChangeParameters().CleanModel = Standard_False;
106 IMeshTools_MeshBuilder aIncMesh(theContext);
109 myStatus = IMeshData_NoError;
110 const Handle(IMeshData_Model)& aModel = theContext->GetModel();
111 if (!aModel.IsNull())
113 for (Standard_Integer aFaceIt = 0; aFaceIt < aModel->FacesNb(); ++aFaceIt)
115 const IMeshData::IFaceHandle& aDFace = aModel->GetFace(aFaceIt);
116 myStatus |= aDFace->GetStatusMask();
118 for (Standard_Integer aWireIt = 0; aWireIt < aDFace->WiresNb(); ++aWireIt)
120 const IMeshData::IWireHandle& aDWire = aDFace->GetWire(aWireIt);
121 myStatus |= aDWire->GetStatusMask();
129 //=======================================================================
132 //=======================================================================
133 Standard_Integer BRepMesh_IncrementalMesh::Discret(
134 const TopoDS_Shape& theShape,
135 const Standard_Real theDeflection,
136 const Standard_Real theAngle,
137 BRepMesh_DiscretRoot* &theAlgo)
139 BRepMesh_IncrementalMesh* anAlgo = new BRepMesh_IncrementalMesh();
140 anAlgo->ChangeParameters().Deflection = theDeflection;
141 anAlgo->ChangeParameters().Angle = theAngle;
142 anAlgo->ChangeParameters().InParallel = IS_IN_PARALLEL;
143 anAlgo->SetShape (theShape);
145 return 0; // no error
148 //=======================================================================
149 //function : IsParallelDefault
151 //=======================================================================
152 Standard_Boolean BRepMesh_IncrementalMesh::IsParallelDefault()
154 return IS_IN_PARALLEL;
157 //=======================================================================
160 //=======================================================================
161 void BRepMesh_IncrementalMesh::SetParallelDefault(
162 const Standard_Boolean theInParallel)
164 IS_IN_PARALLEL = theInParallel;
167 //! Export Mesh Plugin entry function
168 DISCRETPLUGIN(BRepMesh_IncrementalMesh)