Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 25 additions & 25 deletions src/t8_geometry/t8_geometry_implementations/t8_geometry_cad.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -253,14 +253,14 @@ t8_geometry_cad::t8_geom_evaluate_cad_tri (t8_cmesh_t cmesh, t8_gloidx_t gtreeid
interpolated_surface_parameters[dim + offset_2d] += scaled_displacement;
}

pnt = process_surface (i_edge + num_edges, interpolated_surface_parameters, offset_2d);
pnt = process_surface (edges[i_edge + num_edges], interpolated_surface_parameters + offset_2d);

for (int dim = 0; dim < 3; ++dim) {
out_coords[dim + offset_3d] = pnt.Coord (dim + 1);
}
}
}
pnt = process_surface (*faces, interpolated_surface_parameters, 0);
pnt = process_surface (*faces, interpolated_surface_parameters);

for (int dim = 0; dim < 3; ++dim) {
out_coords[dim] = pnt.Coord (dim + 1);
Expand Down Expand Up @@ -295,14 +295,14 @@ t8_geometry_cad::t8_geom_evaluate_cad_tri (t8_cmesh_t cmesh, t8_gloidx_t gtreeid
/* Interpolate between the curve parameters of the current edge with the ref_intersection of each reference point */
t8_geom_linear_interpolation (&ref_intersection[(i_edge == 0) + offset_2d], parameters, 1, 1,
&interpolated_curve_parameter);
pnt = process_curve (i_edge, interpolated_curve_parameter);
pnt = process_curve (edges[i_edge], interpolated_curve_parameter);
}
else {
/* Interpolate between the surface parameters of the current edge with the ref_intersection of each reference point */
t8_geom_linear_interpolation (&ref_intersection[(i_edge == 0) + offset_2d], parameters, 2, 1,
interpolated_surface_parameters + offset_2d);

pnt = process_surface (i_edge + num_edges, interpolated_surface_parameters, offset_2d);
pnt = process_surface (edges[i_edge + num_edges], interpolated_surface_parameters + offset_2d);
}
/* Determine the scaling factor by calculating the distances from the opposite vertex
* to the glob_intersection and to the reference point */
Expand Down Expand Up @@ -393,7 +393,7 @@ t8_geometry_cad::t8_geom_evaluate_cad_quad (t8_cmesh_t cmesh, t8_gloidx_t gtreei
t8_geom_linear_interpolation (&ref_coords[edge_direction + offset_2d], edge_parameters, 1, 1,
temp_edge_parameters);

pnt = process_curve (i_edge, temp_edge_parameters[0]);
pnt = process_curve (edges[i_edge], temp_edge_parameters[0]);

/* Convert curve parameter to surface parameters */
cad_manager->t8_geom_edge_parameter_to_face_parameters (
Expand Down Expand Up @@ -612,15 +612,15 @@ t8_geometry_cad::t8_geom_evaluate_cad_tet (t8_cmesh_t cmesh, t8_gloidx_t gtreeid
/* Linear interpolation between parameters */
t8_geom_linear_interpolation (&interpolation_coeff, parameters, 1, 1, &interpolated_curve_param);

pnt = process_curve (i_edge, interpolated_curve_param);
pnt = process_curve (edges[i_edge], interpolated_curve_param);
}
else { /* Check for linked surfaces */

/* Linear interpolation between parameters */
t8_geom_linear_interpolation (&interpolation_coeff, parameters, 2, 1, interpolated_surface_params);
T8_ASSERT (edges[i_edge + num_edges] <= cad_manager->t8_geom_get_cad_shape_face_map ().Size ());

pnt = process_surface (i_edge + num_edges, interpolated_surface_params, 0);
pnt = process_surface (edges[i_edge + num_edges], interpolated_surface_params);
}

/* Compute displacement between vertex interpolation and curve evaluation with interpolated parameters */
Expand Down Expand Up @@ -709,7 +709,7 @@ t8_geometry_cad::t8_geom_evaluate_cad_tet (t8_cmesh_t cmesh, t8_gloidx_t gtreeid
t8_geom_linear_interpolation (interpolation_coeff, edge_vertices_on_face, 3, 1,
interpolated_edge_coordinates);

pnt = process_curve (i_tree_edge, interpolated_curve_param);
pnt = process_curve (edges[i_tree_edge], interpolated_curve_param);

/* Calculate the same scaling factors for the neighbouring faces
* as in the evaluation of the edges of tetrahedral tree */
Expand All @@ -735,7 +735,7 @@ t8_geometry_cad::t8_geom_evaluate_cad_tet (t8_cmesh_t cmesh, t8_gloidx_t gtreeid
interpolated_coords[dim] += face_displacement_from_edges[dim];
}

pnt = process_surface (i_faces, interpolated_surface_params, 0);
pnt = process_surface (faces[i_faces], interpolated_surface_params);

/* Compute the scaling factor. The scaling happens along the straight from
* the opposite vertex of the face to the face_intersection. */
Expand Down Expand Up @@ -831,14 +831,15 @@ t8_geometry_cad::t8_geom_evaluate_cad_hex (t8_cmesh_t cmesh, t8_gloidx_t gtreeid
t8_geom_linear_interpolation (&ref_coords[edge_direction + offset_3d], parameters, 1, 1,
&interpolated_curve_param);

pnt = process_curve (i_edge, interpolated_curve_param);
pnt = process_curve (edges[i_edge], interpolated_curve_param);
}
else {
T8_ASSERT (edges[i_edge + num_edges] > 0);
/* Linear interpolation between parameters */
t8_geom_linear_interpolation (&ref_coords[edge_direction + offset_3d], parameters, 2, 1,
interpolated_surface_params);

pnt = process_surface (i_edge + num_edges, interpolated_surface_params, 0);
pnt = process_surface (edges[i_edge + num_edges], interpolated_surface_params);
}

/* Compute displacement between vertex interpolation and curve evaluation with interpolated parameters */
Expand Down Expand Up @@ -947,7 +948,7 @@ t8_geometry_cad::t8_geom_evaluate_cad_hex (t8_cmesh_t cmesh, t8_gloidx_t gtreeid
t8_geom_linear_interpolation (&ref_coords[edge_direction + offset_3d], edge_vertices_on_face, 3, 1,
interpolated_edge_coordinates);

pnt = process_curve (t8_face_edge_to_tree_edge[T8_ECLASS_HEX][i_faces][i_face_edge],
pnt = process_curve (edges[t8_face_edge_to_tree_edge[T8_ECLASS_HEX][i_faces][i_face_edge]],
interpolated_curve_param);

/* Calculate the displacement generated by the presence of the curve */
Expand Down Expand Up @@ -1028,7 +1029,7 @@ t8_geometry_cad::t8_geom_evaluate_cad_hex (t8_cmesh_t cmesh, t8_gloidx_t gtreeid
interpolated_surface_params[dim] += surface_parameter_displacement_from_edges[dim];
}

pnt = process_surface (i_faces, interpolated_surface_params, 0);
pnt = process_surface (faces[i_faces], interpolated_surface_params);

/* Compute the displacement between surface and interpolated coords, scale them with the appropriate ref_coord
* and add them to the out_coords. */
Expand Down Expand Up @@ -1126,14 +1127,14 @@ t8_geometry_cad::t8_geom_evaluate_cad_prism (t8_cmesh_t cmesh, t8_gloidx_t gtree
t8_geom_linear_interpolation (&ref_coords[t8_interpolation_coefficient_prism_edge[i_edge] + offset_3d],
parameters, 1, 1, &interpolated_curve_param);

pnt = process_curve (i_edge, interpolated_curve_param);
pnt = process_curve (edges[i_edge], interpolated_curve_param);
}
else {
/* Linear interpolation between parameters */
t8_geom_linear_interpolation (&ref_coords[t8_interpolation_coefficient_prism_edge[i_edge] + offset_3d],
parameters, 2, 1, interpolated_surface_params);

pnt = process_surface (i_edge + T8_DPRISM_EDGES, interpolated_surface_params, 0);
pnt = process_surface (edges[i_edge + T8_DPRISM_EDGES], interpolated_surface_params);
}

/* Compute displacement between vertex interpolation and curve evaluation with interpolated parameters */
Expand Down Expand Up @@ -1201,7 +1202,7 @@ t8_geometry_cad::t8_geom_evaluate_cad_prism (t8_cmesh_t cmesh, t8_gloidx_t gtree
t8_geom_linear_interpolation (&ref_coords[interpolation_coeff + offset_3d], edge_vertices_on_face, 3, 1,
interpolated_edge_coordinates);

pnt = process_curve (i_tree_edge, interpolated_curve_param);
pnt = process_curve (edges[i_tree_edge], interpolated_curve_param);

/* Compute the scaling_factor of the edge displacement on the current face */
double scaling_factor = t8_geom_get_scaling_factor_of_edge_on_face_prism (
Expand Down Expand Up @@ -1234,7 +1235,7 @@ t8_geometry_cad::t8_geom_evaluate_cad_prism (t8_cmesh_t cmesh, t8_gloidx_t gtree
interpolated_coords[dim] += face_displacement_from_edges[dim];
}

pnt = process_surface (i_faces, interpolated_surface_params, 0);
pnt = process_surface (faces[i_faces], interpolated_surface_params);

/* Compute the displacement between surface and interpolated coords, scale them with the appropriate scaling_factor
* and add them to the out_coords. */
Expand Down Expand Up @@ -1271,35 +1272,34 @@ t8_geometry_cad_destroy (t8_geometry_cad_c **geom)
}

gp_Pnt
t8_geometry_cad::process_curve (const int edge_index, const double interpolated_curve_param) const
t8_geometry_cad::process_curve (const int curve_index, const double param) const
{
gp_Pnt pnt;

/* Retrieve the curve of the edge */
auto curve = cad_manager->t8_geom_get_cad_curve (edges[edge_index]);
const auto curve = cad_manager->t8_geom_get_cad_curve (curve_index);

/* Check if curve is valid */
T8_ASSERT (!curve.IsNull ());

/* Calculate point on curve with interpolated parameters */
curve->D0 (interpolated_curve_param, pnt);
curve->D0 (param, pnt);

return pnt;
}
gp_Pnt
t8_geometry_cad::process_surface (const int face_index, const double *interpolated_surface_params,
const int offset) const
t8_geometry_cad::process_surface (const int surface_index, const double *params) const
{
gp_Pnt pnt;

/* Retrieve the surface of the edge */
auto surface = cad_manager->t8_geom_get_cad_surface (faces[face_index]);
const auto surface = cad_manager->t8_geom_get_cad_surface (surface_index);

/* Check if surface is valid */
T8_ASSERT (!surface.IsNull ());

/* Compute point on surface with interpolated parameters */
surface->D0 (interpolated_surface_params[offset], interpolated_surface_params[offset + 1], pnt);
/* Compute point on surface with parameters */
surface->D0 (params[0], params[1], pnt);

return pnt;
}
Expand Down
24 changes: 18 additions & 6 deletions src/t8_geometry/t8_geometry_implementations/t8_geometry_cad.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -209,16 +209,28 @@ struct t8_geometry_cad: public t8_geometry_with_vertices
t8_geom_evaluate_cad_prism (t8_cmesh_t cmesh, t8_gloidx_t gtreeid, const double *ref_coords, const size_t num_coords,
double *out_coords) const;

/**
* Evaluate a point on a CAD curve.
* \param [in] edge_index The index of the curve in the CAD shape.
* \param [in] param The parameter on the curve to evaluate.
* \return The point on the curve.
*/
gp_Pnt
process_curve (const int curve_index, const double param) const;

/**
* Evaluate a point on a CAD surface.
* \param [in] surface_index The index of the surface in the CAD shape.
* \param [in] param The parameter on the surface to evaluate.
* \return The point on the surface.
*/
gp_Pnt
process_surface (const int surface_index, const double *params) const;

const int *edges; /**< The linked edges of the currently active tree. */
const int *faces; /**< The linked faces of the currently active tree. */

std::shared_ptr<t8_cad> cad_manager; /**< The CAD manager of the geometry. */

gp_Pnt
process_curve (const int edge_index, const double interpolated_curve_param) const;

gp_Pnt
process_surface (const int face_index, const double *interpolated_surface_params, const int offset) const;
};

#endif /* !T8_GEOMETRY_CAD_HXX */