Commit | Line | Data |
---|---|---|
b311480e | 1 | // Created on: 1995-06-20 |
2 | // Created by: Stagiaire Alain JOURDAIN | |
3 | // Copyright (c) 1995-1999 Matra Datavision | |
973c2be1 | 4 | // Copyright (c) 1999-2014 OPEN CASCADE SAS |
b311480e | 5 | // |
973c2be1 | 6 | // This file is part of Open CASCADE Technology software library. |
b311480e | 7 | // |
d5f74e42 | 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 | |
973c2be1 | 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. | |
b311480e | 13 | // |
973c2be1 | 14 | // Alternatively, this file may be used under the terms of Open CASCADE |
15 | // commercial license or contractual agreement. | |
7fd59977 | 16 | |
9bdafcbe | 17 | #include <BRepMesh_IncrementalMesh.hxx> |
7bd071ed | 18 | #include <BRepMesh_Context.hxx> |
0b97567d | 19 | #include <BRepMesh_PluginMacro.hxx> |
7bd071ed | 20 | #include <IMeshData_Status.hxx> |
21 | #include <IMeshData_Face.hxx> | |
22 | #include <IMeshData_Wire.hxx> | |
23 | #include <IMeshTools_MeshBuilder.hxx> | |
92efcf78 | 24 | |
0b97567d K |
25 | namespace |
26 | { | |
27 | //! Default flag to control parallelization for BRepMesh_IncrementalMesh | |
28 | //! tool returned for Mesh Factory | |
29 | static Standard_Boolean IS_IN_PARALLEL = Standard_False; | |
a3f6f591 | 30 | } |
0b97567d | 31 | |
9bdafcbe | 32 | //======================================================================= |
fc9b36d6 | 33 | //function : Default constructor |
9bdafcbe | 34 | //purpose : |
35 | //======================================================================= | |
fc9b36d6 | 36 | BRepMesh_IncrementalMesh::BRepMesh_IncrementalMesh() |
7bd071ed | 37 | : myModified(Standard_False), |
38 | myStatus(IMeshData_NoError) | |
7fd59977 | 39 | { |
7fd59977 | 40 | } |
41 | ||
42 | //======================================================================= | |
fc9b36d6 | 43 | //function : Constructor |
7fd59977 | 44 | //purpose : |
45 | //======================================================================= | |
e71669c6 | 46 | BRepMesh_IncrementalMesh::BRepMesh_IncrementalMesh( const TopoDS_Shape& theShape, |
47 | const Standard_Real theLinDeflection, | |
48 | const Standard_Boolean isRelative, | |
49 | const Standard_Real theAngDeflection, | |
7bd071ed | 50 | const Standard_Boolean isInParallel) |
51 | : myModified(Standard_False), | |
52 | myStatus(IMeshData_NoError) | |
e71669c6 | 53 | { |
54 | myParameters.Deflection = theLinDeflection; | |
7bd071ed | 55 | myParameters.Angle = theAngDeflection; |
56 | myParameters.Relative = isRelative; | |
e71669c6 | 57 | myParameters.InParallel = isInParallel; |
e71669c6 | 58 | |
59 | myShape = theShape; | |
60 | Perform(); | |
61 | } | |
62 | ||
63 | //======================================================================= | |
64 | //function : Constructor | |
65 | //purpose : | |
66 | //======================================================================= | |
7bd071ed | 67 | BRepMesh_IncrementalMesh::BRepMesh_IncrementalMesh( |
68 | const TopoDS_Shape& theShape, | |
69 | const IMeshTools_Parameters& theParameters) | |
e71669c6 | 70 | : myParameters(theParameters) |
7fd59977 | 71 | { |
7bd071ed | 72 | myShape = theShape; |
0b97567d | 73 | Perform(); |
7fd59977 | 74 | } |
75 | ||
76 | //======================================================================= | |
fc9b36d6 | 77 | //function : Destructor |
7fd59977 | 78 | //purpose : |
79 | //======================================================================= | |
fc9b36d6 | 80 | BRepMesh_IncrementalMesh::~BRepMesh_IncrementalMesh() |
7fd59977 | 81 | { |
82 | } | |
83 | ||
7fd59977 | 84 | //======================================================================= |
fc9b36d6 | 85 | //function : Perform |
86 | //purpose : | |
7fd59977 | 87 | //======================================================================= |
fc9b36d6 | 88 | void BRepMesh_IncrementalMesh::Perform() |
4c04741d | 89 | { |
90 | Handle(BRepMesh_Context) aContext = new BRepMesh_Context; | |
91 | Perform (aContext); | |
92 | } | |
93 | ||
94 | //======================================================================= | |
95 | //function : Perform | |
96 | //purpose : | |
97 | //======================================================================= | |
98 | void BRepMesh_IncrementalMesh::Perform(const Handle(IMeshTools_Context)& theContext) | |
7fd59977 | 99 | { |
7bd071ed | 100 | initParameters(); |
fc9b36d6 | 101 | |
4c04741d | 102 | theContext->SetShape(Shape()); |
103 | theContext->ChangeParameters() = myParameters; | |
104 | theContext->ChangeParameters().CleanModel = Standard_False; | |
fc9b36d6 | 105 | |
4c04741d | 106 | IMeshTools_MeshBuilder aIncMesh(theContext); |
7bd071ed | 107 | aIncMesh.Perform(); |
fc9b36d6 | 108 | |
7bd071ed | 109 | myStatus = IMeshData_NoError; |
4c04741d | 110 | const Handle(IMeshData_Model)& aModel = theContext->GetModel(); |
7756fc59 | 111 | if (!aModel.IsNull()) |
fc9b36d6 | 112 | { |
7756fc59 | 113 | for (Standard_Integer aFaceIt = 0; aFaceIt < aModel->FacesNb(); ++aFaceIt) |
ab58a62b | 114 | { |
7756fc59 | 115 | const IMeshData::IFaceHandle& aDFace = aModel->GetFace(aFaceIt); |
116 | myStatus |= aDFace->GetStatusMask(); | |
117 | ||
118 | for (Standard_Integer aWireIt = 0; aWireIt < aDFace->WiresNb(); ++aWireIt) | |
119 | { | |
120 | const IMeshData::IWireHandle& aDWire = aDFace->GetWire(aWireIt); | |
121 | myStatus |= aDWire->GetStatusMask(); | |
122 | } | |
ab58a62b | 123 | } |
7fd59977 | 124 | } |
125 | ||
7bd071ed | 126 | setDone(); |
7fd59977 | 127 | } |
0b97567d K |
128 | |
129 | //======================================================================= | |
130 | //function : Discret | |
131 | //purpose : | |
132 | //======================================================================= | |
fc9b36d6 | 133 | Standard_Integer BRepMesh_IncrementalMesh::Discret( |
134 | const TopoDS_Shape& theShape, | |
135 | const Standard_Real theDeflection, | |
136 | const Standard_Real theAngle, | |
ceb418e1 | 137 | BRepMesh_DiscretRoot* &theAlgo) |
0b97567d K |
138 | { |
139 | BRepMesh_IncrementalMesh* anAlgo = new BRepMesh_IncrementalMesh(); | |
e71669c6 | 140 | anAlgo->ChangeParameters().Deflection = theDeflection; |
7bd071ed | 141 | anAlgo->ChangeParameters().Angle = theAngle; |
e71669c6 | 142 | anAlgo->ChangeParameters().InParallel = IS_IN_PARALLEL; |
7bd071ed | 143 | anAlgo->SetShape (theShape); |
0b97567d K |
144 | theAlgo = anAlgo; |
145 | return 0; // no error | |
146 | } | |
147 | ||
148 | //======================================================================= | |
149 | //function : IsParallelDefault | |
150 | //purpose : | |
151 | //======================================================================= | |
152 | Standard_Boolean BRepMesh_IncrementalMesh::IsParallelDefault() | |
153 | { | |
0b97567d | 154 | return IS_IN_PARALLEL; |
0b97567d K |
155 | } |
156 | ||
157 | //======================================================================= | |
158 | //function : Discret | |
159 | //purpose : | |
160 | //======================================================================= | |
fc9b36d6 | 161 | void BRepMesh_IncrementalMesh::SetParallelDefault( |
162 | const Standard_Boolean theInParallel) | |
0b97567d K |
163 | { |
164 | IS_IN_PARALLEL = theInParallel; | |
165 | } | |
166 | ||
167 | //! Export Mesh Plugin entry function | |
168 | DISCRETPLUGIN(BRepMesh_IncrementalMesh) |