0
votes

I am trying to find the boundary of a group of triangles. My problem is that I am saving the triangles from Sketchup as a collada .dae file and then reading them into my programme. Sketchup creates the triangles similar to this image:

.

I think this is called a triangle 'soup' as they are unconnected at vertex points - a triangle can connect to another along one of its edges. It means that I cannot find the boundary of the set by testing each side of the triangle to see if it connects to another triangle or not, as triangle 1 (green) is connected to triangle (2) and 'nothing'.

  1. Is this a triangle 'soup' and I need a triangle 'mesh' (terminology question)?
  2. Can sketchup save its .dae file with each triangle vertex connected to one other triangle vertex, like in the below image?

  3. Is there a better way find the boundary of this group of triangles?

1
do you want a rectangular boundary? if so you don't even need to deal with them as shapes, just points... (least h point, most h point, least v point, most v point)...Grady Player
No I want the actual polygonal boundary (6 sides in this example)CobaltGray
I guess you could find center of the bounding box.. then calculate the distance from there, the most distant points will be some of the vertices of the bounding convex polygon... as for the others... you probably need the button on the calculator that I don't know how to use...Grady Player
We call these 'T-junctions' but I like the 'triangle soup' term even more :-)abenci
SketchUp will always try to merge geometry, what you see in the first example should not be possible in SU. What you should get is what you see in the second image. Your question seem to indicate that you have a scenario of the first, which would then be a SU bug. Can you add a code snippet to how you create the two triangles?thomthom

1 Answers

0
votes

Edits in response to @thomthom 's question about reproducing this in Sketchup: Made as an 'Answer' as I don't have Rep to add more than two links to original post. -sorry

Thanks for the hint @thomthom I have reproduced the problem here for you. My Sketchup file looks like this:

I am running Sketchup Version 17.2.2554.

I then go to file->Export->3D Model Select Format "COLLADA File (*.dae)" Click 'Options' and check 'Export Two-Sided Faces' and 'Triangulate All Faces' Select the location to save your file

This writes a collada .dae file. It only has 8 faces so I'll post the .dae here so that you can see it for yourself:

    <?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<COLLADA xmlns="http://www.collada.org/2005/11/COLLADASchema" version="1.4.1">
    <asset>
        <contributor>
            <authoring_tool>SketchUp 17.2.2554</authoring_tool>
        </contributor>
        <created>2017-05-31T19:42:02Z</created>
        <modified>2017-05-31T19:42:02Z</modified>
        <unit meter="0.0254000" name="inch" />
        <up_axis>Z_UP</up_axis>
    </asset>
    <library_cameras>
        <camera id="ID1" name="skp_camera_Last_Saved_SketchUp_View">
            <optics>
                <technique_common>
                    <perspective>
                        <yfov>35.0000000</yfov>
                        <aspect_ratio>0.0000000</aspect_ratio>
                        <znear>1.0000000</znear>
                        <zfar>1000.0000000</zfar>
                    </perspective>
                </technique_common>
            </optics>
        </camera>
    </library_cameras>
    <library_visual_scenes>
        <visual_scene id="ID2">
            <node name="SketchUp">
                <instance_geometry url="#ID3">
                    <bind_material>
                        <technique_common>
                            <instance_material symbol="Material2" target="#ID5">
                                <bind_vertex_input semantic="UVSET0" input_semantic="TEXCOORD" input_set="0" />
                            </instance_material>
                            <instance_material symbol="Material3" target="#ID10">
                                <bind_vertex_input semantic="UVSET0" input_semantic="TEXCOORD" input_set="0" />
                            </instance_material>
                        </technique_common>
                    </bind_material>
                </instance_geometry>
                <node name="skp_camera_Last_Saved_SketchUp_View">
                    <matrix>0.9857500 0.0094434 0.1679518 330.2823181 0.1682171 -0.0553379 -0.9841955 -862.0587769 0.0000000 0.9984230 -0.0561379 109.0382767 0.0000000 0.0000000 0.0000000 1.0000000</matrix>
                    <instance_camera url="#ID1" />
                </node>
            </node>
        </visual_scene>
    </library_visual_scenes>
    <library_geometries>
        <geometry id="ID3">
            <mesh>
                <source id="ID6">
                    <float_array id="ID11" count="60">318.7783345 0.0000000 0.0000000 240.0381770 -0.0000000 118.1102362 0.0000000 0.0000000 0.0000000 318.7783345 0.0000000 196.8503937 240.0381770 0.0000000 196.8503937 159.3891673 0.0000000 196.8503937 80.6490098 0.0000000 118.1102362 159.3891673 0.0000000 118.1102362 80.6490098 0.0000000 196.8503937 0.0000000 0.0000000 118.1102362 80.6490098 0.0000000 118.1102362 159.3891673 0.0000000 118.1102362 0.0000000 0.0000000 118.1102362 240.0381770 -0.0000000 118.1102362 0.0000000 0.0000000 0.0000000 80.6490098 0.0000000 196.8503937 159.3891673 0.0000000 196.8503937 240.0381770 0.0000000 196.8503937 318.7783345 0.0000000 196.8503937 318.7783345 0.0000000 0.0000000</float_array>
                    <technique_common>
                        <accessor count="20" source="#ID11" stride="3">
                            <param name="X" type="float" />
                            <param name="Y" type="float" />
                            <param name="Z" type="float" />
                        </accessor>
                    </technique_common>
                </source>
                <source id="ID7">
                    <float_array id="ID12" count="60">0.0000000 -1.0000000 0.0000000 0.0000000 -1.0000000 0.0000000 0.0000000 -1.0000000 0.0000000 0.0000000 -1.0000000 0.0000000 0.0000000 -1.0000000 0.0000000 0.0000000 -1.0000000 0.0000000 0.0000000 -1.0000000 0.0000000 0.0000000 -1.0000000 0.0000000 0.0000000 -1.0000000 0.0000000 0.0000000 -1.0000000 0.0000000 -0.0000000 1.0000000 -0.0000000 -0.0000000 1.0000000 -0.0000000 -0.0000000 1.0000000 -0.0000000 -0.0000000 1.0000000 -0.0000000 -0.0000000 1.0000000 -0.0000000 -0.0000000 1.0000000 -0.0000000 -0.0000000 1.0000000 -0.0000000 -0.0000000 1.0000000 -0.0000000 -0.0000000 1.0000000 -0.0000000 -0.0000000 1.0000000 -0.0000000</float_array>
                    <technique_common>
                        <accessor count="20" source="#ID12" stride="3">
                            <param name="X" type="float" />
                            <param name="Y" type="float" />
                            <param name="Z" type="float" />
                        </accessor>
                    </technique_common>
                </source>
                <vertices id="ID8">
                    <input semantic="POSITION" source="#ID6" />
                    <input semantic="NORMAL" source="#ID7" />
                </vertices>
                <triangles count="8" material="Material2">
                    <input offset="0" semantic="VERTEX" source="#ID8" />
                    <p>0 1 2 1 0 3 1 3 4 5 6 7 6 5 8 2 7 9 7 2 1 9 7 6</p>
                </triangles>
                <triangles count="8" material="Material3">
                    <input offset="0" semantic="VERTEX" source="#ID8" />
                    <p>10 11 12 13 14 11 12 11 14 15 16 10 11 10 16 17 18 13 18 19 13 14 13 19</p>
                </triangles>
            </mesh>
        </geometry>
    </library_geometries>
    <library_materials>
        <material id="ID5" name="material">
            <instance_effect url="#ID4" />
        </material>
        <material id="ID10" name="material_0">
            <instance_effect url="#ID9" />
        </material>
    </library_materials>
    <library_effects>
        <effect id="ID4">
            <profile_COMMON>
                <technique sid="COMMON">
                    <lambert>
                        <diffuse>
                            <color>1.0000000 1.0000000 1.0000000 1.0000000</color>
                        </diffuse>
                    </lambert>
                </technique>
            </profile_COMMON>
        </effect>
        <effect id="ID9">
            <profile_COMMON>
                <technique sid="COMMON">
                    <lambert>
                        <diffuse>
                            <color>0.6431373 0.6980392 0.7333333 1.0000000</color>
                        </diffuse>
                    </lambert>
                </technique>
            </profile_COMMON>
        </effect>
    </library_effects>
    <scene>
        <instance_visual_scene url="#ID2" />
    </scene>
</COLLADA>

You can see that the collada output has 8 triangles and the offending triangle is at index 5 described in the line:

<triangles count="8" material="Material2">
    <input offset="0" semantic="VERTEX" source="#ID8" />
    <p>0 1 2 1 0 3 1 3 4 5 6 7 6 5 8 2 7 9 7 2 1 9 7 6</p>
                                     ^^^^^
                                     Tri 5
</triangles>

This refers to vertices 2,7,9 which are:

2:  0.0000000 0.0000000 0.0000000
7:  159.3891673 0.0000000 118.1102362 
9:  0.0000000 0.0000000 118.1102362 

which when multiplied by the inches-to-metres scaling factor of 0.0254000 gives:

0, 0, 0 
4, 0, 3 
0, 0, 3 

We see that triangle index 3 has vertices 5,6 & 7 which when cross referenced with the vertex info gives:

5:  159.44 0.00 196.85
6:  80.70 0.00 118.11 
7:  159.44 0.00 118.11

Which when multiplied by the inches-to-meters scaling factor of 0.0254000 gives:

4, 0, 5
2, 0, 3
4, 0, 3

When you plot these out they look like this:

As you can see, the two triangles are like those in my first diagram, not the second. Triangle 5 has both an adjacent face with triangle 3 and and an empty face.

So this might be a bug in Sketchup but it still doesn't help me sort out my problem of finding the boundary. Thanks for your time.