2 // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
4 // + This file is part of enGrid. +
6 // + Copyright 2008-2012 enGits GmbH +
8 // + enGrid is free software: you can redistribute it and/or modify +
9 // + it under the terms of the GNU General Public License as published by +
10 // + the Free Software Foundation, either version 3 of the License, or +
11 // + (at your option) any later version. +
13 // + enGrid is distributed in the hope that it will be useful, +
14 // + but WITHOUT ANY WARRANTY; without even the implied warranty of +
15 // + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +
16 // + GNU General Public License for more details. +
18 // + You should have received a copy of the GNU General Public License +
19 // + along with enGrid. If not, see <http://www.gnu.org/licenses/>. +
21 // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
23 #include "surfaceoperation.h"
25 #include "guimainwindow.h"
27 #include <vtkCharArray.h>
29 #include <vtkCellArray.h>
30 #include <vtkPolygon.h>
32 #include "geometrytools.h"
33 using namespace GeometryTools
;
35 SurfaceOperation::SurfaceOperation() : Operation()
37 //default values for determining node types and for smoothing operations
38 getSet("surface meshing", "edge angle to determine fixed vertices", 180, m_EdgeAngle
);
39 getSet("surface meshing", "feature angle", 180, m_FeatureAngle
);
40 m_FeatureAngle
= GeometryTools::deg2rad(m_FeatureAngle
);
41 m_EdgeAngle
= GeometryTools::deg2rad(m_EdgeAngle
);
42 setEdgeAngle(m_EdgeAngle
);
43 m_BoundarySmoothing
= 1;
44 m_StretchingFactor
= 0;
45 m_UniformSnapPoints
= false;
48 void SurfaceOperation::operate()
53 ostream
& operator<<(ostream
&out
, stencil_t S
)
55 out
<< "S.id_cell = " << S
.id_cell
<< " ";
56 out
<< "S.id_node = " << S
.id_node
<< " ";
57 out
<< "S.sameBC = " << S
.sameBC
<< " ";
58 out
<< "S.type = " << S
.type_cell
<< " ";
59 out
<< "S.p1 = " << S
.p1
<< " ";
60 out
<< "S.p2 = " << S
.p2
<< " ";
64 stencil_t
SurfaceOperation::getStencil(vtkIdType id_cell1
, int j1
)
68 vtkIdType N_pts
, *pts
;
69 m_Grid
->GetCellPoints(id_cell1
, N_pts
, pts
);
76 QSet
<vtkIdType
> cells_p1
;
77 for (int i
= 0; i
< m_Part
.n2cGSize(S
.p1
); ++i
) {
78 vtkIdType id_cell
= m_Part
.n2cGG(S
.p1
, i
);
79 if (id_cell
!= id_cell1
) {
80 cells_p1
.insert(id_cell
);
83 QSet
<vtkIdType
> cells_p2
;
84 for (int i
= 0; i
< m_Part
.n2cGSize(S
.p2
); ++i
) {
85 vtkIdType id_cell
= m_Part
.n2cGG(S
.p2
, i
);
86 if (id_cell
!= id_cell1
) {
87 cells_p2
.insert(id_cell
);
90 QSet
<vtkIdType
> cells
= cells_p1
.intersect(cells_p2
);
91 EG_VTKDCC(vtkIntArray
, cell_code
, m_Grid
, "cell_code");
94 S
.id_cell
[0] = id_cell1
;
95 foreach (vtkIdType id_cell
, cells
) {
96 if (isSurface(id_cell
, m_Grid
)) {
97 S
.id_cell
.push_back(id_cell
);
98 if (cell_code
->GetValue(id_cell
) != cell_code
->GetValue(id_cell1
)) {
103 S
.id_node
.resize(S
.id_cell
.size());
104 S
.type_cell
.resize(S
.id_cell
.size());
105 for (int i
= 0; i
< S
.id_cell
.size(); ++i
) {
106 vtkIdType N_pts
, *pts
;
107 m_Grid
->GetCellPoints(S
.id_cell
[i
], N_pts
, pts
);
108 S
.type_cell
[i
] = m_Grid
->GetCellType(S
.id_cell
[i
]);
109 for (int j
= 0; j
< N_pts
; ++j
) {
110 if (pts
[j
] != S
.p1
&& pts
[j
] != S
.p2
) {
111 S
.id_node
[i
] = pts
[j
];
119 int SurfaceOperation::UpdateCurrentMeshDensity()
121 if ( DebugLevel
> 0 ) {
122 cout
<< "===UpdateMeshDensity START===" << endl
;
124 QVector
<vtkIdType
> cells
;
125 getAllSurfaceCells( cells
, m_Grid
);
126 EG_VTKDCC( vtkIntArray
, cell_code
, m_Grid
, "cell_code" );
127 EG_VTKDCN( vtkDoubleArray
, characteristic_length_desired
, m_Grid
, "node_meshdensity_desired" );
130 if ( DebugLevel
> 5 ) {
131 cout
<< "cells.size()=" << cells
.size() << endl
;
133 EG_VTKDCN( vtkDoubleArray
, node_meshdensity_current
, m_Grid
, "node_meshdensity_current" );
134 l2g_t nodes
= getPartNodes();
135 foreach( vtkIdType node
, nodes
) {
136 node_meshdensity_current
->SetValue( node
, CurrentMeshDensity( node
) );
138 if ( DebugLevel
> 0 ) {
139 cout
<< "===UpdateMeshDensity END===" << endl
;
141 return( 0 ); ///\todo what for???
144 int SurfaceOperation::UpdatePotentialSnapPoints(bool update_node_types
, bool fix_unselected
)
146 setAllSurfaceCells();
148 l2g_t nodes
= getPartNodes();
149 l2g_t cells
= getPartCells();
151 m_PotentialSnapPoints
.resize(m_Grid
->GetNumberOfPoints());
153 if (m_UniformSnapPoints
) {
154 m_PotentialSnapPoints
.resize(m_Grid
->GetNumberOfPoints());
155 EG_FORALL_NODES(id_node
, m_Grid
) {
156 for (int i
= 0; i
< m_Part
.n2nGSize(id_node
); ++i
) {
157 m_PotentialSnapPoints
[id_node
].append(m_Part
.n2nGG(id_node
, i
));
163 //initialize default values
164 EG_VTKDCN( vtkCharArray
, node_type
, m_Grid
, "node_type" );
165 foreach( vtkIdType id_node
, nodes
) {
166 if ( update_node_types
) node_type
->SetValue( id_node
, VTK_SIMPLE_VERTEX
);
167 m_PotentialSnapPoints
[id_node
].clear();
172 // loop through edges
173 foreach (vtkIdType id_cell
, cells
) {
174 vtkIdType
*pts
, Npts
;
175 m_Grid
->GetCellPoints( id_cell
, Npts
, pts
);
176 for ( int i
= 0; i
< Npts
; i
++ ) {
178 QVector
<vtkIdType
> EdgeCells
;
179 int Ncells
= getEdgeCells( pts
[i
], pts
[(i
+1)%Npts
], EdgeCells
);
181 bool already_visited_edge
= false;
182 for(int i_cell
=0;i_cell
<Ncells
;i_cell
++) {
183 if(EdgeCells
[i_cell
]<id_cell
) {
184 already_visited_edge
= true;
189 if ( already_visited_edge
) continue;//already visited edge
192 vtkIdType id_node1
= pts
[i
];
193 vtkIdType id_node2
= pts
[( i
+1 )%Npts
];
195 // determine edge type
196 char edge
= getEdgeType( id_node2
, id_node1
, fix_unselected
);
198 // determine node type pre-processing (count nb of complex edges if the node is complex, otherwise, just count the nb of edges)
199 if (edge
&& node_type
->GetValue(id_node1
) == VTK_SIMPLE_VERTEX
)
201 m_PotentialSnapPoints
[id_node1
].clear();
202 m_PotentialSnapPoints
[id_node1
].push_back( id_node2
);
203 if ( update_node_types
) node_type
->SetValue( id_node1
, edge
);
205 } else if (( edge
&& node_type
->GetValue(id_node1
) == VTK_BOUNDARY_EDGE_VERTEX
) ||
206 ( edge
&& node_type
->GetValue(id_node1
) == VTK_FEATURE_EDGE_VERTEX
) ||
207 (!edge
&& node_type
->GetValue(id_node1
) == VTK_SIMPLE_VERTEX
))
209 m_PotentialSnapPoints
[id_node1
].push_back( id_node2
);
210 if ( node_type
->GetValue( id_node1
) && edge
== VTK_BOUNDARY_EDGE_VERTEX
) {
211 if ( update_node_types
) node_type
->SetValue( id_node1
, VTK_BOUNDARY_EDGE_VERTEX
);//VTK_BOUNDARY_EDGE_VERTEX has priority over VTK_FEATURE_EDGE_VERTEX
215 if ( edge
&& node_type
->GetValue( id_node2
) == VTK_SIMPLE_VERTEX
) {
216 m_PotentialSnapPoints
[id_node2
].clear();
217 m_PotentialSnapPoints
[id_node2
].push_back( id_node1
);
218 if ( update_node_types
) node_type
->SetValue( id_node2
, edge
);
220 else if (( edge
&& node_type
->GetValue( id_node2
) == VTK_BOUNDARY_EDGE_VERTEX
) ||
221 ( edge
&& node_type
->GetValue( id_node2
) == VTK_FEATURE_EDGE_VERTEX
) ||
222 ( !edge
&& node_type
->GetValue( id_node2
) == VTK_SIMPLE_VERTEX
) ) {
223 m_PotentialSnapPoints
[id_node2
].push_back( id_node1
);
224 if ( node_type
->GetValue( id_node2
) && edge
== VTK_BOUNDARY_EDGE_VERTEX
) {
225 if ( update_node_types
) node_type
->SetValue( id_node2
, VTK_BOUNDARY_EDGE_VERTEX
);//VTK_BOUNDARY_EDGE_VERTEX has priority over VTK_FEATURE_EDGE_VERTEX
231 //cout<<"num_edges="<<num_edges<<endl;
233 //-----------------------
234 //determine node type post-processing
235 double CosEdgeAngle
= cos(this->m_EdgeAngle
);
236 //cout<<"===post-processing==="<<endl;
237 //This time, we loop through nodes
238 foreach( vtkIdType id_node
, nodes
) {
239 if ( node_type
->GetValue( id_node
) == VTK_FEATURE_EDGE_VERTEX
|| node_type
->GetValue( id_node
) == VTK_BOUNDARY_EDGE_VERTEX
) { //see how many edges; if two, what the angle is
241 if ( !this->m_BoundarySmoothing
&& node_type
->GetValue( id_node
) == VTK_BOUNDARY_EDGE_VERTEX
) {
242 if ( update_node_types
) node_type
->SetValue( id_node
, VTK_FIXED_VERTEX
);
243 } else if ( m_PotentialSnapPoints
[id_node
].size() != 2 ) {
244 if ( update_node_types
) node_type
->SetValue( id_node
, VTK_FIXED_VERTEX
);
246 else { //check angle between edges
247 double x1
[3], x2
[3], x3
[3], l1
[3], l2
[3];
248 m_Grid
->GetPoint( m_PotentialSnapPoints
[id_node
][0], x1
);
249 m_Grid
->GetPoint( id_node
, x2
);
250 m_Grid
->GetPoint( m_PotentialSnapPoints
[id_node
][1], x3
);
251 for ( int k
= 0; k
< 3; k
++ ) {
252 l1
[k
] = x2
[k
] - x1
[k
];
253 l2
[k
] = x3
[k
] - x2
[k
];
255 if ( vtkMath::Normalize( l1
) >= 0.0 &&
256 vtkMath::Normalize( l2
) >= 0.0 &&
257 vtkMath::Dot( l1
, l2
) < CosEdgeAngle
) {
258 if ( update_node_types
) node_type
->SetValue( id_node
, VTK_FIXED_VERTEX
);
263 //cout<<"m_PotentialSnapPoints.size()="<<m_PotentialSnapPoints.size()<<endl;
264 //cout<<"=== UpdatePotentialSnapPoints END ==="<<endl;
268 char SurfaceOperation::getNodeType(vtkIdType id_node
, bool fix_unselected
)
270 l2g_t nodes
= getPartNodes();
271 g2l_t _nodes
= getPartLocalNodes();
272 l2l_t n2n
= getPartN2N();
274 // fix all vertices that are part of a volume element or a quad
275 for (int i
= 0; i
< m_Part
.n2cGSize(id_node
); ++i
) {
276 if (m_Grid
->GetCellType(m_Part
.n2cGG(id_node
, i
)) != VTK_TRIANGLE
) {
277 return VTK_FIXED_VERTEX
;
281 // initialize default value
282 char type
= VTK_SIMPLE_VERTEX
;
284 // loop through edges around id_node
286 QVector
<vtkIdType
> edges
;
287 double cos_edge_angle
= cos(this->m_EdgeAngle
);
289 // safety switch to make sure edge angle fixing is disabled
290 if (cos_edge_angle
< -0.99) {
294 foreach (int i_node2
, n2n
[_nodes
[id_node
]]) {
296 vtkIdType id_node2
= nodes
[i_node2
];
298 // determine edge type
299 char edge
= getEdgeType(id_node2
, id_node
, fix_unselected
);
301 // determine node type pre-processing
302 // count number of complex edges if the node is complex,
303 // otherwise, just count the number of edges
305 if (edge
!= VTK_SIMPLE_VERTEX
&& type
== VTK_SIMPLE_VERTEX
) {
308 edges
.push_back(id_node2
);
311 } else if ((edge
!= VTK_SIMPLE_VERTEX
&& type
== VTK_BOUNDARY_EDGE_VERTEX
) ||
312 (edge
!= VTK_SIMPLE_VERTEX
&& type
== VTK_FEATURE_EDGE_VERTEX
) ||
313 (edge
== VTK_SIMPLE_VERTEX
&& type
== VTK_SIMPLE_VERTEX
))
315 edges
.push_back(id_node2
);
316 if (type
!= VTK_SIMPLE_VERTEX
&& edge
== VTK_BOUNDARY_EDGE_VERTEX
) {
317 // VTK_BOUNDARY_EDGE_VERTEX has priority over VTK_FEATURE_EDGE_VERTEX
318 type
= VTK_BOUNDARY_EDGE_VERTEX
;
323 // determine node type post-processing
324 if (type
== VTK_FEATURE_EDGE_VERTEX
|| type
== VTK_BOUNDARY_EDGE_VERTEX
) {
326 // check how how many edges; if two, what is the angle?
328 if (!this->m_BoundarySmoothing
&& type
== VTK_BOUNDARY_EDGE_VERTEX
) {
329 type
= VTK_FIXED_VERTEX
;
330 } else if (edges
.size() != 2) {
331 //type = VTK_FIXED_VERTEX;
334 // check angle between edges
335 vec3_t x1
, x2
, x3
, l1
, l2
;
336 m_Grid
->GetPoint(edges
[0], x1
.data());
337 m_Grid
->GetPoint(id_node
, x2
.data());
338 m_Grid
->GetPoint(edges
[1], x3
.data());
341 if (l1
.abs() >= 0.0 && l2
.abs() >= 0.0 && l1
*l2
< cos_edge_angle
) {
342 //type = VTK_FIXED_VERTEX;
350 int SurfaceOperation::getEdgeCells(vtkIdType id_node1
, vtkIdType id_node2
, QVector
<vtkIdType
> &EdgeCells
)
352 g2l_t _nodes
= getPartLocalNodes();
353 l2g_t cells
= getPartCells();
354 l2l_t n2c
= getPartN2C();
357 foreach (int i
, n2c
[_nodes
[id_node1
]]) {
362 foreach( int i
, n2c
[_nodes
[id_node2
]] ) {
367 EdgeCells
= Set2Vector(S2
, false);
368 return EdgeCells
.size();
371 int SurfaceOperation::getEdgeCells( vtkIdType id_node1
, vtkIdType id_node2
, QSet
<vtkIdType
> &EdgeCells
)
373 g2l_t _nodes
= getPartLocalNodes();
374 l2g_t cells
= getPartCells();
375 l2l_t n2c
= getPartN2C();
378 foreach( int i
, n2c
[_nodes
[id_node1
]] ) {
379 S1
.insert( cells
[i
] );
383 foreach( int i
, n2c
[_nodes
[id_node2
]] ) {
384 S2
.insert( cells
[i
] );
387 EdgeCells
= S2
.intersect( S1
);
388 return EdgeCells
.size();
391 char SurfaceOperation::getEdgeType(vtkIdType a_node1
, vtkIdType a_node2
, bool fix_unselected
)
393 double cos_feature_angle
= cos(this->m_FeatureAngle
);
394 bool feature_edges_disabled
= m_FeatureAngle
>= M_PI
;
396 // compute number of cells around edge [a_node,p2] and put them into neighbour_cells
397 QVector
<vtkIdType
> neighbour_cells
;
398 int numNei
= getEdgeCells(a_node1
, a_node2
, neighbour_cells
) - 1;
401 char edge
= VTK_SIMPLE_VERTEX
;
404 edge
= VTK_BOUNDARY_EDGE_VERTEX
;
405 } else if (numNei
>= 2) {
406 edge
= VTK_BOUNDARY_EDGE_VERTEX
;
407 } else if (numNei
== 1) {
409 // check angle between cell1 and cell2 against FeatureAngle
410 if (cosAngle(m_Grid
, neighbour_cells
[0], neighbour_cells
[1] ) <= cos_feature_angle
&& !feature_edges_disabled
) {
411 edge
= VTK_FEATURE_EDGE_VERTEX
;
414 // check the boundary codes
415 EG_VTKDCC( vtkIntArray
, cell_code
, m_Grid
, "cell_code" );
416 int cell_code_0
= cell_code
->GetValue( neighbour_cells
[0] );
417 int cell_code_1
= cell_code
->GetValue( neighbour_cells
[1] );
418 if (cell_code_0
!= cell_code_1
) {
419 edge
= VTK_BOUNDARY_EDGE_VERTEX
;
422 if (fix_unselected
) {
423 if (!m_BoundaryCodes
.contains(cell_code_0
) || !m_BoundaryCodes
.contains(cell_code_1
)) {
424 // does not make sense, but should make the points of the edge fixed
425 edge
= VTK_FIXED_VERTEX
;
433 VertexMeshDensity
SurfaceOperation::getVMD( vtkIdType id_node
)
435 g2l_t _nodes
= getPartLocalNodes();
436 l2g_t cells
= getPartCells();
437 l2l_t n2c
= getPartN2C();
439 EG_VTKDCN( vtkCharArray
, node_type
, m_Grid
, "node_type" );
440 EG_VTKDCC( vtkIntArray
, cell_code
, m_Grid
, "cell_code" );
442 VertexMeshDensity VMD
;
443 VMD
.type
= node_type
->GetValue( id_node
);
445 VMD
.CurrentNode
= id_node
;
447 foreach( int i_cell
, n2c
[_nodes
[id_node
]] ) {
448 vtkIdType id_cell
= cells
[i_cell
];
449 VMD
.BCmap
[cell_code
->GetValue( id_cell
)] = 2;
454 //////////////////////////////////////////////
455 double SurfaceOperation::currentVertexAvgDist( vtkIdType id_node
)
457 l2g_t nodes
= getPartNodes();
458 g2l_t _nodes
= getPartLocalNodes();
459 l2l_t n2n
= getPartN2N();
461 double total_dist
= 0;
463 int N
= n2n
[_nodes
[id_node
]].size();
465 m_Grid
->GetPoint( id_node
, C
.data() );
466 foreach( int i_node_neighbour
, n2n
[_nodes
[id_node
]] ) {
467 vtkIdType id_node_neighbour
= nodes
[i_node_neighbour
];
469 m_Grid
->GetPoint( id_node_neighbour
, M
.data() );
470 total_dist
+= ( M
- C
).abs();
472 avg_dist
= total_dist
/ ( double )N
;
476 double SurfaceOperation::CurrentMeshDensity( vtkIdType id_node
)
478 return 1.0 / currentVertexAvgDist( id_node
);
481 ///\todo change meshdensity fields to edgelength fields since this is what is mostly used?
483 /// desired edge length for id_node
484 double SurfaceOperation::desiredEdgeLength( vtkIdType id_node
)
486 EG_VTKDCN( vtkDoubleArray
, characteristic_length_desired
, m_Grid
, "node_meshdensity_desired" );
487 return( 1.0 / characteristic_length_desired
->GetValue( id_node
) );
490 /// mean desired edge length for id_cell
491 double SurfaceOperation::meanDesiredEdgeLength( vtkIdType id_cell
)
493 vtkIdType num_pts
, *pts
;
494 m_Grid
->GetCellPoints( id_cell
, num_pts
, pts
);
496 for ( int i
= 0; i
< num_pts
; i
++ ) {
497 total
+= desiredEdgeLength( pts
[i
] );
499 return total
/ ( double )num_pts
;
502 QVector
<vtkIdType
> SurfaceOperation::getPotentialSnapPoints( vtkIdType id_node
)
504 if ((id_node
< 0) || (id_node
>= m_PotentialSnapPoints
.size())) {
505 // UpdatePotentialSnapPoints should probably be called before using this function.
508 return m_PotentialSnapPoints
[id_node
];
511 bool SurfaceOperation::isCell(vtkIdType id_node1
, vtkIdType id_node2
, vtkIdType id_node3
)
513 QVector
<vtkIdType
> EdgeCells_12
;
514 QVector
<vtkIdType
> EdgeCells_13
;
515 QVector
<vtkIdType
> inter
;
517 getEdgeCells( id_node1
, id_node2
, EdgeCells_12
);
518 getEdgeCells( id_node1
, id_node3
, EdgeCells_13
);
519 qcontIntersection( EdgeCells_12
, EdgeCells_13
, inter
);
521 qWarning()<<"(id_node1, id_node2, id_node3)="<<"("<<id_node1
<<", "<<id_node2
<<", "<<id_node3
<<")";
522 qWarning()<<"EdgeCells_12="<<EdgeCells_12
;
523 qWarning()<<"EdgeCells_13="<<EdgeCells_13
;
524 qWarning()<<"inter="<<inter
;
525 writeGrid(m_Grid
, "abort");
526 EG_BUG
;// multiple cells in the same place
529 qDebug()<<"(id_node1, id_node2, id_node3)="<<"("<<id_node1
<<", "<<id_node2
<<", "<<id_node3
<<")";
530 qDebug()<<"EdgeCells_12="<<EdgeCells_12
;
531 qDebug()<<"EdgeCells_13="<<EdgeCells_13
;
532 qDebug()<<"inter="<<inter
;
534 return(inter
.size()>0);
537 void SurfaceOperation::computeNormals()
539 EG_VTKDCC(vtkIntArray
, cell_code
, m_Grid
, "cell_code");
540 m_NodeNormal
.fill(vec3_t(0,0,0), m_Grid
->GetNumberOfPoints());
541 for (vtkIdType id_node
= 0; id_node
< m_Grid
->GetNumberOfPoints(); ++id_node
) {
542 if (m_Part
.localNode(id_node
) != -1) {
544 for (int i
= 0; i
< m_Part
.n2cGSize(id_node
); ++i
) {
545 vtkIdType id_cell
= m_Part
.n2cGG(id_node
, i
);
546 if (isSurface(id_cell
, m_Grid
)) {
547 int bc
= cell_code
->GetValue(id_cell
);
548 if (m_BoundaryCodes
.contains(bc
)) {
553 int num_bcs
= bcs
.size();
554 QVector
<vec3_t
> normal(num_bcs
, vec3_t(0,0,0));
557 foreach (int bc
, bcs
) {
561 for (int i
= 0; i
< m_Part
.n2cGSize(id_node
); ++i
) {
562 vtkIdType id_cell
= m_Part
.n2cGG(id_node
, i
);
563 if (isSurface(id_cell
, m_Grid
)) {
564 int bc
= cell_code
->GetValue(id_cell
);
565 if (m_BoundaryCodes
.contains(bc
)) {
566 vtkIdType N_pts
, *pts
;
567 m_Grid
->GetCellPoints(id_cell
, N_pts
, pts
);
569 for (int j
= 0; j
< N_pts
; ++j
) {
570 if (pts
[j
] == id_node
) {
571 m_Grid
->GetPoint(pts
[j
], a
.data());
573 m_Grid
->GetPoint(pts
[j
-1], b
.data());
575 m_Grid
->GetPoint(pts
[N_pts
-1], b
.data());
578 m_Grid
->GetPoint(pts
[j
+1], c
.data());
580 m_Grid
->GetPoint(pts
[0], c
.data());
586 double alpha
= GeometryTools::angle(u
, v
);
587 vec3_t n
= u
.cross(v
);
589 if (checkVector(n
)) {
590 normal
[bcmap
[bc
]] += alpha
*n
;
595 for (int i
= 0; i
< num_bcs
; ++i
) {
596 normal
[i
].normalise();
601 for (int i
= 0; i
< num_bcs
; ++i
) {
602 for (int j
= i
+ 1; j
< num_bcs
; ++j
) {
603 vec3_t n
= normal
[i
] + normal
[j
];
605 m_NodeNormal
[id_node
] += n
;
609 for (int i
= 0; i
< num_bcs
; ++i
) {
610 m_NodeNormal
[id_node
] += normal
[i
];
614 m_NodeNormal
[id_node
] = normal
[0];
616 m_NodeNormal
[id_node
].normalise();
622 double SurfaceOperation::normalIrregularity(vtkIdType id_node
)
625 QVector
<vec3_t
> nc(m_Part
.n2cGSize(id_node
));
626 for (int i
= 0; i
< nc
.size(); ++i
) {
627 nc
[i
] = GeometryTools::cellNormal(m_Grid
, m_Part
.n2cGG(id_node
, i
));
630 for (int i
= 0; i
< nc
.size(); ++i
) {
631 for (int j
= i
+ 1; j
< nc
.size(); ++j
) {
632 nirr
+= 1.0 - nc
[i
]*nc
[j
];