text stringlengths 0 234 |
|---|
procedure Check_object (o : Object_3D) is |
use G3DM; |
procedure Check_faces is |
procedure Check (f, v : Integer) is |
pragma Inline (Check); |
begin |
if v < 0 or else v > o.Max_points then |
Raise_Exception (bad_vertex_number'Identity, |
o.ID & " face =" & Integer'Image (f) & |
" vertex =" & Integer'Image (v)); |
end if; |
end Check; |
procedure Check_duplicate (f, Pn1, Pn2 : Integer) is |
pragma Inline (Check_duplicate); |
begin |
-- Skip "dead" edge (triangle), 30 - Dec - 2001 |
if Pn1 = 0 or else Pn2 = 0 then |
return; |
end if; |
-- Detect same point number |
if Pn1 = Pn2 then |
Raise_Exception (duplicated_vertex'Identity, |
o.ID & " in face " & Integer'Image (f)); |
end if; |
-- Detect same point coordinates (tolerated in an object, |
-- although inefficient, but harms as vertex of the same face!) |
if Almost_zero (Norm2 (o.Point (Pn1) - o.Point (Pn2))) then |
Raise_Exception (duplicated_vertex_location'Identity, |
o.ID & " in face " & Integer'Image (f)); |
end if; |
end Check_duplicate; |
begin |
for fa in o.face'Range loop |
for edge_num in 1 .. 4 loop |
Check (fa, o.face (fa).P (edge_num)); |
for other_edge in edge_num + 1 .. 4 loop |
Check_duplicate (fa, o.face (fa).P (edge_num), |
o.face (fa).P (other_edge)); |
end loop; |
end loop; |
end loop; -- fa |
end Check_faces; |
begin |
Check_faces; |
end Check_object; |
-------------------------------------------- |
-- Object initialization (1x in its life) -- |
-------------------------------------------- |
overriding procedure Pre_calculate (o : in out Object_3D) is |
use G3DM; |
N : Vector_3D; |
length_N : Real; |
procedure Calculate_face_invariants ( |
fa : Face_type; |
fi : out Face_invariant_type |
) is |
l : Natural := 0; |
quadri_edge : array (fa.P'Range) of Natural; |
ex_U, ex_V : Real; |
begin |
l := 0; |
for qe in fa.P'Range loop |
if fa.P (qe) /= 0 then |
l := l + 1; |
quadri_edge (l) := qe; -- if triangle, "map" edge on a quadri |
fi.P_compact (l) := fa.P (qe); |
end if; |
end loop; |
if l in Edge_count then |
fi.last_edge := l; |
else |
Raise_Exception (bad_edge_number'Identity, o.ID); |
end if; |
-- * Face invariant : Textured face : extremities |
for e in 1 .. l loop |
if fa.whole_texture then |
ex_U := Real (fa.repeat_U); |
ex_V := Real (fa.repeat_V); |
case quadri_edge (e) is |
when 1 => fi.UV_extrema (e) := (0.0, 0.0); -- bottom, left 4 --< --3 |
when 2 => fi.UV_extrema (e) := (ex_U, 0.0); -- bottom, right | | |
when 3 => fi.UV_extrema (e) := (ex_U, ex_V); -- top, right 1 --> --2 |
when 4 => fi.UV_extrema (e) := (0.0, ex_V); -- top, left |
when others => null; |
end case; |
else |
-- Just copy the mapping, but in compact form for triangles : |
fi.UV_extrema (e) := fa.texture_edge_map (quadri_edge (e)); |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.