Find edge of face

Continuing the discussion from Importing XML mesh data:

I’m having trouble finding where lines intersect with the edge of a face. It seems that the Geom.intersect_line_line, and face.clasify_point are not returning expected results. This is with SketchUp Pro 2018.

EagleViewImport.rb (10.2 KB)

EagleView.xml
<?xml version="1.0" encoding="utf-8"?>
<EAGLEVIEW_EXPORT xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <REPORT claimId="" reportId="59525254" />
  <VERSION coplanarity="" dormers="" precision="0" precisionUnits="" sourceVersion="1028" targetVersion="0" triangulation="" />
  <LOCATION address="981 Township Road 1451" city="Ashland" lat="40.9201054" long="-82.4058555" postal="44805" state="OH" />
  <STRUCTURES northorientation="270">
    <ROOF id="ROOF1">
      <FACES>
        <FACE designator="D" id="F1" type="ROOF" children="">
          <POLYGON id="P1" orientation="180.3" path="L1,L2,L3,L4,L5,L6,L7" pitch="10" size="54" unroundedsize="54.066065731" />
        </FACE>
        <FACE designator="K" id="F2" type="ROOF" children="">
          <POLYGON id="P2" orientation="0.3" path="L11,L10,L9,L8" pitch="12" size="362" unroundedsize="362.153331378" />
        </FACE>
        <FACE designator="I" id="F3" type="ROOF" children="">
          <POLYGON id="P3" orientation="180.3" path="L15,L14,L13,L12" pitch="10" size="251" unroundedsize="250.991990483" />
        </FACE>
        <FACE designator="P" id="F4" type="ROOF" children="">
          <POLYGON id="P4" orientation="0.3" path="L16,L17,L18,L19,L20" pitch="10" size="952" unroundedsize="952.097136562" />
        </FACE>
        <FACE designator="J" id="F5" type="ROOF" children="">
          <POLYGON id="P5" orientation="0.3" path="L7,L26,L25,L24,L23,L22,L15,L21" pitch="10" size="279" unroundedsize="278.805380585" />
        </FACE>
        <FACE designator="F" id="F6" type="ROOF" children="">
          <POLYGON id="P6" orientation="180.3" path="L30,L29,L28,L27" pitch="10" size="98" unroundedsize="98.452123037" />
        </FACE>
        <FACE designator="M" id="F7" type="ROOF" children="">
          <POLYGON id="P7" orientation="180.3" path="L31,L32,L33" pitch="10" size="401" unroundedsize="400.570856957" />
        </FACE>
        <FACE designator="L" id="F8" type="ROOF" children="">
          <POLYGON id="P8" orientation="180.3" path="L34,L35,L36,L11" pitch="12" size="368" unroundedsize="367.729587538" />
        </FACE>
        <FACE designator="O" id="F9" type="ROOF" children="">
          <POLYGON id="P9" orientation="90.3" path="L36,L37,L31,L38,L39,L17,L40,L10" pitch="12" size="927" unroundedsize="926.582464701" />
        </FACE>
        <FACE designator="N" id="F10" type="ROOF" children="">
          <POLYGON id="P10" orientation="180.3" path="L41,L42,L43,L44,L45,L19" pitch="10" size="490" unroundedsize="489.539806416" />
        </FACE>
        <FACE designator="H" id="F11" type="ROOF" children="">
          <POLYGON id="P11" orientation="270.3" path="L38,L33,L46,L30,L47,L48,L49,L50,L14" pitch="12" size="239" unroundedsize="239.323225124" />
        </FACE>
        <FACE designator="E" id="F12" type="ROOF" children="">
          <POLYGON id="P12" orientation="0.3" path="L51,L52,L53,L54,L47,L27" pitch="10" size="83" unroundedsize="82.714057570" />
        </FACE>
        <FACE designator="G" id="F13" type="ROOF" children="">
          <POLYGON id="P13" orientation="270.3" path="L18,L41,L55,L22,L39" pitch="12" size="198" unroundedsize="197.920161602" />
        </FACE>
        <FACE designator="C" id="F14" type="ROOF" children="">
          <POLYGON id="P14" orientation="270.3" path="L55,L42,L56,L57,L23" pitch="5" size="39" unroundedsize="39.285138651" />
        </FACE>
        <FACE designator="A" id="F15" type="ROOF" children="">
          <POLYGON id="P15" orientation="270.3" path="L48,L54,L58" pitch="4" size="9" unroundedsize="9.153192414" />
        </FACE>
        <FACE designator="B" id="F16" type="ROOF" children="">
          <POLYGON id="P16" orientation="270.3" path="L5,L62,L25,L61,L60,L59" pitch="10" size="35" unroundedsize="34.746706471" />
        </FACE>
      </FACES>
      <LINES>
        <LINE id="L1" path="C6,C7" type="STEPFLASH" />
        <LINE id="L2" path="C7,C8" type="STEPFLASH" />
        <LINE id="L3" path="C8,C9" type="EAVE" />
        <LINE id="L4" path="C9,C10" type="EAVE" />
        <LINE id="L5" path="C10,C11" type="HIP" />
        <LINE id="L6" path="C11,C12" type="RAKE" />
        <LINE id="L7" path="C12,C6" type="RIDGE" />
        <LINE id="L8" path="C13,C14" type="RAKE" />
        <LINE id="L9" path="C14,C15" type="EAVE" />
        <LINE id="L10" path="C15,C16" type="VALLEY" />
        <LINE id="L11" path="C16,C13" type="RIDGE" />
        <LINE id="L12" path="C17,C18" type="RAKE" />
        <LINE id="L13" path="C18,C19" type="EAVE" />
        <LINE id="L14" path="C19,C20" type="VALLEY" />
        <LINE id="L15" path="C20,C17" type="RIDGE" />
        <LINE id="L16" path="C5,C21" type="EAVE" />
        <LINE id="L17" path="C21,C22" type="HIP" />
        <LINE id="L18" path="C22,C23" type="HIP" />
        <LINE id="L19" path="C23,C24" type="RIDGE" />
        <LINE id="L20" path="C24,C5" type="RAKE" />
        <LINE id="L21" path="C6,C17" type="RAKE" />
        <LINE id="L22" path="C20,C25" type="VALLEY" />
        <LINE id="L23" path="C25,C26" type="VALLEY" />
        <LINE id="L24" path="C26,C27" type="EAVE" />
        <LINE id="L25" path="C27,C28" type="HIP" />
        <LINE id="L26" path="C28,C12" type="RAKE" />
        <LINE id="L27" path="C29,C30" type="RIDGE" />
        <LINE id="L28" path="C30,C31" type="RAKE" />
        <LINE id="L29" path="C31,C32" type="EAVE" />
        <LINE id="L30" path="C32,C29" type="VALLEY" />
        <LINE id="L31" path="C33,C34" type="HIP" />
        <LINE id="L32" path="C34,C35" type="EAVE" />
        <LINE id="L33" path="C35,C33" type="HIP" />
        <LINE id="L34" path="C13,C36" type="RAKE" />
        <LINE id="L35" path="C36,C37" type="EAVE" />
        <LINE id="L36" path="C37,C16" type="VALLEY" />
        <LINE id="L37" path="C37,C34" type="EAVE" />
        <LINE id="L38" path="C33,C20" type="RIDGE" />
        <LINE id="L39" path="C20,C22" type="RIDGE" />
        <LINE id="L40" path="C21,C15" type="EAVE" />
        <LINE id="L41" path="C23,C38" type="VALLEY" />
        <LINE id="L42" path="C38,C39" type="VALLEY" />
        <LINE id="L43" path="C39,C40" type="STEPFLASH" />
        <LINE id="L44" path="C40,C41" type="EAVE" />
        <LINE id="L45" path="C41,C24" type="RAKE" />
        <LINE id="L46" path="C35,C32" type="EAVE" />
        <LINE id="L47" path="C29,C42" type="VALLEY" />
        <LINE id="L48" path="C42,C43" type="OTHER" />
        <LINE id="L49" path="C43,C44" type="STEPFLASH" />
        <LINE id="L50" path="C44,C19" type="FLASHING" />
        <LINE id="L51" path="C30,C45" type="RAKE" />
        <LINE id="L52" path="C45,C46" type="EAVE" />
        <LINE id="L53" path="C46,C47" type="STEPFLASH" />
        <LINE id="L54" path="C47,C42" type="VALLEY" />
        <LINE id="L55" path="C25,C38" type="OTHER" />
        <LINE id="L56" path="C39,C48" type="STEPFLASH" />
        <LINE id="L57" path="C48,C26" type="FLASHING" />
        <LINE id="L58" path="C43,C47" type="STEPFLASH" />
        <LINE id="L59" path="C11,C49" type="STEPFLASH" />
        <LINE id="L60" path="C49,C50" type="FLASHING" />
        <LINE id="L61" path="C50,C28" type="STEPFLASH" />
        <LINE id="L62" path="C27,C10" type="EAVE" />
      </LINES>
      <POINTS>
        <POINT id="C5" data="-39.697636567,39.516904130,0.000000000" />
        <POINT id="C6" data="-8.015243300,60.934369458,12.058432647" />
        <POINT id="C7" data="-6.336322567,62.345462239,10.655225867" />
        <POINT id="C8" data="-0.415240905,62.313776942,5.684015651" />
        <POINT id="C9" data="-0.420512842,61.328370551,5.683976347" />
        <POINT id="C10" data="-0.450080048,55.800704140,5.683972957" />
        <POINT id="C11" data="-1.425006515,56.771404511,6.506979103" />
        <POINT id="C12" data="-8.037324508,56.806760816,12.058430355" />
        <POINT id="C13" data="3.457028914,112.747198295,11.851521699" />
        <POINT id="C14" data="-8.543860429,112.811421223,0.000014715" />
        <POINT id="C15" data="-8.626142786,97.434903700,0.000039431" />
        <POINT id="C16" data="3.309512856,85.181182389,11.851558484" />
        <POINT id="C17" data="-3.126793986,60.908218029,16.038508598" />
        <POINT id="C18" data="10.168370997,60.837066979,5.410932049" />
        <POINT id="C19" data="10.219234370,70.328286638,5.410875636" />
        <POINT id="C20" data="-3.019634799,80.908696951,16.038508949" />
        <POINT id="C21" data="-39.387025909,97.599634335,0.000007695" />
        <POINT id="C22" data="-20.107743375,81.000355928,16.038501583" />
        <POINT id="C23" data="-26.087673098,75.781101340,11.109743945" />
        <POINT id="C24" data="-26.282088536,39.445112671,11.109720733" />
        <POINT id="C25" data="-14.649429178,70.929758040,6.614154002" />
        <POINT id="C26" data="-15.804652659,68.511074032,5.683973820" />
        <POINT id="C27" data="-15.872247363,55.883238652,5.683968915" />
        <POINT id="C28" data="-14.856369816,56.843226037,6.506818270" />
        <POINT id="C29" data="15.220550409,71.414551331,6.536118437" />
        <POINT id="C30" data="15.152061927,58.622320538,6.536114750" />
        <POINT id="C31" data="23.109322341,58.579742056,0.000037860" />
        <POINT id="C32" data="23.143195834,64.908663164,0.000040688" />
        <POINT id="C33" data="10.050969143,80.838737257,16.038505357" />
        <POINT id="C34" data="29.002966440,97.233384569,0.000017268" />
        <POINT id="C35" data="28.829828717,64.878234721,0.000033336" />
        <POINT id="C36" data="15.820167832,112.681038221,0.000008293" />
        <POINT id="C37" data="15.737878486,97.304384872,0.000033017" />
        <POINT id="C38" data="-20.563236994,70.961380669,6.613898941" />
        <POINT id="C39" data="-14.605889735,58.205312181,1.732907528" />
        <POINT id="C40" data="-12.466655278,58.193863057,0.000050337" />
        <POINT id="C41" data="-12.567314347,39.371717570,0.000047924" />
        <POINT id="C42" data="11.931533148,68.790004465,3.864408275" />
        <POINT id="C43" data="9.219266272,68.804514750,3.864409810" />
        <POINT id="C44" data="9.227450416,70.333593626,5.410724815" />
        <POINT id="C45" data="7.140782497,58.665188547,0.000057206" />
        <POINT id="C46" data="7.160987162,62.439159014,0.000059178" />
        <POINT id="C47" data="9.185144598,62.428324551,1.651452548" />
        <POINT id="C48" data="-14.550803367,68.504362664,5.683974679" />
        <POINT id="C49" data="-3.514493694,57.848825364,7.415762781" />
        <POINT id="C50" data="-12.922643877,57.958933896,7.466668578" />
      </POINTS>
    </ROOF>
  </STRUCTURES>
</EAGLEVIEW_EXPORT>

When calling make_panel_layouts(16) there is a missing panel.

I think this is where the problem lies.

  def self.add_line(edges, bottom, slope, face)
    points = edges.map do |e|
      point = Geom.intersect_line_line(e.line, [bottom, slope])
      point && e.bounds.contains?(point) ? point : nil
    end
    points.reject!(&:nil?)

    if points.length > 1
      Sketchup.active_model.entities.add_line(points.first, points.last)
    elsif points.length > 0
      if face.classify_point(bottom + slope) != Sketchup::Face::PointOutside
        Sketchup.active_model.entities.add_line(points.first, bottom + slope)
      end
      Sketchup.active_model.entities.add_line(bottom, points.first) if bottom != points[0]
    else
      Sketchup.active_model.entities.add_line(bottom, bottom + slope)
    end
  end

I’ve also got a few stray edges.