Skip to content

Commit 6ae8ffd

Browse files
Nightly Botcwsmith
authored andcommitted
Merging develop into master
2 parents 2810366 + 684c0f6 commit 6ae8ffd

File tree

2 files changed

+51
-43
lines changed

2 files changed

+51
-43
lines changed

crv/crv.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@ int getBlendingOrder(const int type);
3737
/** \brief count invalid elements of the mesh */
3838
int countNumberInvalidElements(apf::Mesh2* m);
3939

40+
/** \brief converts Interpolating nodes to Control points for a Bezier mesh*/
41+
void interpolatingToBezier(apf::Mesh2* m);
42+
4043
/** \brief Base Mesh curving object
4144
\details P is the order, S is the space dimension,
4245
different from the mesh dimension, used to distinguish between planar 2D

crv/crvCurveMesh.cc

Lines changed: 48 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,53 @@ void convertInterpolationPoints(apf::Mesh2* m, apf::MeshEntity* e,
4444
apf::destroyElement(elem);
4545
}
4646

47+
void interpolatingToBezier(apf::Mesh2* m)
48+
{
49+
apf::FieldShape * fs = m->getShape();
50+
int order = fs->getOrder();
51+
52+
int md = m->getDimension();
53+
int blendingOrder = getBlendingOrder(apf::Mesh::simplexTypes[md]);
54+
// go downward, and convert interpolating to control points
55+
int startDim = md - (blendingOrder > 0);
56+
57+
for(int d = startDim; d >= 1; --d){
58+
if(!fs->hasNodesIn(d)) continue;
59+
int n = fs->getEntityShape(apf::Mesh::simplexTypes[d])->countNodes();
60+
int ne = fs->countNodesOn(apf::Mesh::simplexTypes[d]);
61+
apf::NewArray<double> c;
62+
getBezierTransformationCoefficients(order,
63+
apf::Mesh::simplexTypes[d],c);
64+
apf::MeshEntity* e;
65+
apf::MeshIterator* it = m->begin(d);
66+
while ((e = m->iterate(it))){
67+
if(m->isOwned(e))
68+
convertInterpolationPoints(m,e,n,ne,c);
69+
}
70+
m->end(it);
71+
}
72+
// if we have a full representation, we need to place internal nodes on
73+
// triangles and tetrahedra
74+
for(int d = 2; d <= md; ++d){
75+
if(!fs->hasNodesIn(d) ||
76+
getBlendingOrder(apf::Mesh::simplexTypes[d])) continue;
77+
int n = fs->getEntityShape(apf::Mesh::simplexTypes[d])->countNodes();
78+
int ne = fs->countNodesOn(apf::Mesh::simplexTypes[d]);
79+
apf::NewArray<double> c;
80+
getInternalBezierTransformationCoefficients(m,order,1,
81+
apf::Mesh::simplexTypes[d],c);
82+
apf::MeshEntity* e;
83+
apf::MeshIterator* it = m->begin(d);
84+
while ((e = m->iterate(it))){
85+
if(!isBoundaryEntity(m,e) && m->isOwned(e))
86+
convertInterpolationPoints(m,e,n-ne,ne,c);
87+
}
88+
m->end(it);
89+
}
90+
apf::synchronize(m->getCoordinateField());
91+
92+
}
93+
4794
void snapToInterpolate(apf::Mesh2* m, apf::MeshEntity* e, bool isNew)
4895
{
4996
PCU_ALWAYS_ASSERT(m->canSnap());
@@ -125,49 +172,7 @@ bool InterpolatingCurver::run()
125172

126173
void BezierCurver::convertInterpolatingToBezier()
127174
{
128-
apf::FieldShape * fs = m_mesh->getShape();
129-
int order = fs->getOrder();
130-
131-
int md = m_mesh->getDimension();
132-
int blendingOrder = getBlendingOrder(apf::Mesh::simplexTypes[md]);
133-
// go downward, and convert interpolating to control points
134-
int startDim = md - (blendingOrder > 0);
135-
136-
for(int d = startDim; d >= 1; --d){
137-
if(!fs->hasNodesIn(d)) continue;
138-
int n = fs->getEntityShape(apf::Mesh::simplexTypes[d])->countNodes();
139-
int ne = fs->countNodesOn(apf::Mesh::simplexTypes[d]);
140-
apf::NewArray<double> c;
141-
getBezierTransformationCoefficients(order,
142-
apf::Mesh::simplexTypes[d],c);
143-
apf::MeshEntity* e;
144-
apf::MeshIterator* it = m_mesh->begin(d);
145-
while ((e = m_mesh->iterate(it))){
146-
if(m_mesh->isOwned(e))
147-
convertInterpolationPoints(m_mesh,e,n,ne,c);
148-
}
149-
m_mesh->end(it);
150-
}
151-
// if we have a full representation, we need to place internal nodes on
152-
// triangles and tetrahedra
153-
for(int d = 2; d <= md; ++d){
154-
if(!fs->hasNodesIn(d) ||
155-
getBlendingOrder(apf::Mesh::simplexTypes[d])) continue;
156-
int n = fs->getEntityShape(apf::Mesh::simplexTypes[d])->countNodes();
157-
int ne = fs->countNodesOn(apf::Mesh::simplexTypes[d]);
158-
apf::NewArray<double> c;
159-
getInternalBezierTransformationCoefficients(m_mesh,order,1,
160-
apf::Mesh::simplexTypes[d],c);
161-
apf::MeshEntity* e;
162-
apf::MeshIterator* it = m_mesh->begin(d);
163-
while ((e = m_mesh->iterate(it))){
164-
if(!isBoundaryEntity(m_mesh,e) && m_mesh->isOwned(e))
165-
convertInterpolationPoints(m_mesh,e,n-ne,ne,c);
166-
}
167-
m_mesh->end(it);
168-
}
169-
170-
synchronize();
175+
interpolatingToBezier(m_mesh);
171176
}
172177

173178
bool BezierCurver::run()

0 commit comments

Comments
 (0)