LCOV - code coverage report
Current view: top level - geom/facetbool - FBImprint.cpp (source / functions) Hit Total Coverage
Test: coverage_sk.info Lines: 0 242 0.0 %
Date: 2020-06-30 00:58:45 Functions: 0 6 0.0 %
Branches: 0 326 0.0 %

           Branch data     Line data    Source code
       1                 :            : /*
       2                 :            :  *
       3                 :            :  *
       4                 :            :  * Copyright (C) 2004 Sandia Corporation.  Under the terms of Contract DE-AC04-94AL85000
       5                 :            :  * with Sandia Corporation, the U.S. Government retains certain rights in this software.
       6                 :            :  *
       7                 :            :  * This file is part of facetbool--contact via [email protected]
       8                 :            :  *
       9                 :            :  * This library is free software; you can redistribute it and/or
      10                 :            :  * modify it under the terms of the GNU Lesser General Public
      11                 :            :  * License as published by the Free Software Foundation; either
      12                 :            :  * version 2.1 of the License, or (at your option) any later version.
      13                 :            :  *
      14                 :            :  * This library is distributed in the hope that it will be useful,
      15                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      16                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
      17                 :            :  * Lesser General Public License for more details.
      18                 :            :  *
      19                 :            :  * You should have received a copy of the GNU Lesser General Public
      20                 :            :  * License along with this library; if not, write to the Free Software
      21                 :            :  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
      22                 :            :  *
      23                 :            :  *
      24                 :            :  *
      25                 :            :  */
      26                 :            : 
      27                 :            : #include <vector>
      28                 :            : #include <math.h>
      29                 :            : #include "FBImprint.hpp"
      30                 :            : #include "FBPolyhedron.hpp"
      31                 :            : #include "FBRetriangulate.hpp"
      32                 :            : #include "GeometryDefines.h"
      33                 :            : #include "CubitMessage.hpp"
      34                 :            : #include "FBDataUtil.hpp"
      35                 :            : #include <stdio.h>
      36                 :            : 
      37                 :          0 : FBImprint::FBImprint()
      38                 :            : {
      39                 :            : 
      40                 :          0 : }
      41                 :            : 
      42                 :          0 : FBImprint::~FBImprint()
      43                 :            : {
      44                 :            : 
      45                 :          0 : }  
      46                 :            : 
      47                 :          0 : CubitStatus FBImprint::imprint_body_curve(const std::vector<double>& Bodycoords,
      48                 :            :                            const std::vector<int>& Bodyconnections,
      49                 :            :                            const std::vector<FB_Coord*>& FB_imprint_edge_coords,
      50                 :            :                            const std::vector<FB_Edge*>& FB_imprint_edges,
      51                 :            :                            const std::vector<FSBoundingBox*>& FB_imprint_edge_bboxes,
      52                 :            :                            std::vector<int>* indices)
      53                 :            : {
      54                 :            : CubitStatus status;
      55                 :            : bool new_edge_created;
      56                 :            : 
      57                 :          0 :   status = CUBIT_SUCCESS;   
      58                 :            : 
      59 [ #  # ][ #  # ]:          0 :   if ( Bodycoords.size()%3 != 0 ) {
      60 [ #  # ][ #  # ]:          0 :     PRINT_ERROR("Bad coordinates for first part fed to FBImprint.\n");
         [ #  # ][ #  # ]
      61                 :          0 :     return CUBIT_FAILURE;
      62                 :            :   }
      63 [ #  # ][ #  # ]:          0 :   if ( Bodyconnections.size()%3 != 0 ) {
      64 [ #  # ][ #  # ]:          0 :     PRINT_ERROR("Bad connection list for first part fed to FBImprint.\n");
         [ #  # ][ #  # ]
      65                 :          0 :     return CUBIT_FAILURE;
      66                 :            :   }
      67                 :            :  
      68                 :          0 :   f_c_indices = indices;
      69 [ #  # ][ #  # ]:          0 :   poly = new FBPolyhedron;
      70         [ #  # ]:          0 :   status = poly->makepoly(Bodycoords,Bodyconnections,f_c_indices);
      71                 :            :   
      72                 :            :   status = edges_tri_intersect(FB_imprint_edge_coords,FB_imprint_edges,
      73         [ #  # ]:          0 :                                FB_imprint_edge_bboxes,new_edge_created);
      74                 :            : 
      75         [ #  # ]:          0 :   if ( new_edge_created == true ) {
      76         [ #  # ]:          0 :     std::vector<int> newFacets;
      77 [ #  # ][ #  # ]:          0 :     status = poly->retriangulate(newFacets);
      78                 :            : /*    
      79                 :            :     FILE *out;
      80                 :            :     out = fopen("1Qaz.fct","w");
      81                 :            :     int numtris, numverts;
      82                 :            :     numverts = poly->verts.size();
      83                 :            : 
      84                 :            :     int ii;  
      85                 :            : 
      86                 :            :     numtris = 0;
      87                 :            :     for ( ii = 0; ii < poly->tris.size(); ii++ ) 
      88                 :            :       if ( poly->tris[ii]->dudded == false ) numtris++;
      89                 :            :     fprintf(out,"%d %d\n",numverts,numtris);
      90                 :            :     for ( ii = 0; ii < poly->verts.size(); ii++ ) 
      91                 :            :       fprintf(out,"%d %le %le %le\n",ii+1,poly->verts[ii]->coord[0],
      92                 :            :            poly->verts[ii]->coord[1],poly->verts[ii]->coord[2]);
      93                 :            :     for ( ii = 0; ii < poly->tris.size(); ii++ ) {
      94                 :            :       if ( poly->tris[ii]->dudded == false )
      95                 :            :         fprintf(out,"%d %d %d %d\n",ii+1,1+poly->tris[ii]->v0,  
      96                 :            :            1+poly->tris[ii]->v1,1+poly->tris[ii]->v2);
      97                 :            :     }   
      98                 :            :     fclose(out); 
      99                 :            : */        
     100                 :            :   }  
     101                 :            :   
     102                 :          0 :   return status;
     103                 :            : 
     104                 :            : }
     105                 :            : 
     106                 :          0 : CubitStatus FBImprint::edges_tri_intersect(const std::vector<FB_Coord*>& FB_imprint_edge_coords,
     107                 :            :                            const std::vector<FB_Edge*>& FB_imprint_edges,
     108                 :            :                            const std::vector<FSBoundingBox*>& FB_imprint_edge_bboxes,
     109                 :            :                            bool &new_edge_created)
     110                 :            : {
     111                 :            :   CubitStatus status;
     112                 :            :   unsigned int i, j;
     113                 :            :   int numboxesfound, *boxlist;
     114                 :            :   FSBoundingBox* edgebox;
     115                 :          0 :   double edge_dir[3] = {0.0}, edge_0[3] = {0.0}, edge_1[3] = {0.0}, edge_length = 0.0;
     116                 :            :   bool big_angle;
     117                 :            : 
     118 [ #  # ][ #  # ]:          0 :   boxlist = new int[poly->tris.size()];
                 [ #  # ]
     119                 :            : 
     120                 :          0 :   status = CUBIT_SUCCESS;
     121                 :          0 :   new_edge_created = false;
     122 [ #  # ][ #  # ]:          0 :   for ( i = 0; i < FB_imprint_edge_bboxes.size(); i++ ) {
     123         [ #  # ]:          0 :      edgebox = FB_imprint_edge_bboxes[i];
     124 [ #  # ][ #  # ]:          0 :      if ( (edgebox->xmax < poly->polyxmin) || 
     125         [ #  # ]:          0 :           (edgebox->xmin > poly->polyxmax) ||
     126         [ #  # ]:          0 :           (edgebox->ymax < poly->polyymin) || 
     127         [ #  # ]:          0 :           (edgebox->ymin > poly->polyymax) ||
     128         [ #  # ]:          0 :           (edgebox->zmax < poly->polyzmin) || 
     129                 :          0 :           (edgebox->zmin > poly->polyzmax) ) continue;
     130         [ #  # ]:          0 :      poly->kdtree->box_kdtree_intersect(*edgebox,&numboxesfound,boxlist);
     131         [ #  # ]:          0 :      if ( numboxesfound > 0 ) {  //  Get a unit vector along the edge.
     132 [ #  # ][ #  # ]:          0 :        edge_0[0] = FB_imprint_edge_coords[FB_imprint_edges[i]->v0]->coord[0];
     133 [ #  # ][ #  # ]:          0 :        edge_1[0] = FB_imprint_edge_coords[FB_imprint_edges[i]->v1]->coord[0];
     134                 :          0 :        edge_dir[0] = edge_1[0] - edge_0[0];
     135 [ #  # ][ #  # ]:          0 :        edge_0[1] = FB_imprint_edge_coords[FB_imprint_edges[i]->v0]->coord[1];
     136 [ #  # ][ #  # ]:          0 :        edge_1[1] = FB_imprint_edge_coords[FB_imprint_edges[i]->v1]->coord[1];
     137                 :          0 :        edge_dir[1] = edge_1[1] - edge_0[1];
     138 [ #  # ][ #  # ]:          0 :        edge_0[2] = FB_imprint_edge_coords[FB_imprint_edges[i]->v0]->coord[2];
     139 [ #  # ][ #  # ]:          0 :        edge_1[2] = FB_imprint_edge_coords[FB_imprint_edges[i]->v1]->coord[2];
     140                 :          0 :        edge_dir[2] = edge_1[2] - edge_0[2];
     141                 :          0 :        edge_length = sqrt(edge_dir[0]*edge_dir[0] + edge_dir[1]*edge_dir[1] + edge_dir[2]*edge_dir[2]);
     142         [ #  # ]:          0 :        if ( edge_length < GEOMETRY_RESABS ) continue;
     143                 :          0 :        edge_dir[0] /= edge_length;
     144                 :          0 :        edge_dir[1] /= edge_length;
     145                 :          0 :        edge_dir[2] /= edge_length;             
     146                 :            :      }
     147                 :            : 
     148         [ #  # ]:          0 :      for ( j = 0; j < (unsigned int)numboxesfound; j++ ) { 
     149         [ #  # ]:          0 :         FB_Triangle *tri = poly->tris[boxlist[j]];     
     150 [ #  # ][ #  # ]:          0 :         if ( (edgebox->xmax < tri->boundingbox.xmin) || 
     151         [ #  # ]:          0 :              (edgebox->xmin > tri->boundingbox.xmax) ||
     152         [ #  # ]:          0 :              (edgebox->ymax < tri->boundingbox.ymin) || 
     153         [ #  # ]:          0 :              (edgebox->ymin > tri->boundingbox.ymax) ||
     154         [ #  # ]:          0 :              (edgebox->zmax < tri->boundingbox.zmin) || 
     155                 :          0 :              (edgebox->zmin > tri->boundingbox.zmax) ) continue;
     156                 :            : //  Try to get a reasonable value for imprint_res.  It should depend on the size of the 
     157                 :            : //  triangle and the length of the edge.
     158                 :          0 :         double tri_size = sqrt( (tri->boundingbox.xmax-tri->boundingbox.xmin)*
     159                 :          0 :                                 (tri->boundingbox.xmax-tri->boundingbox.xmin) +
     160                 :          0 :                                 (tri->boundingbox.ymax-tri->boundingbox.ymin)*
     161                 :          0 :                                 (tri->boundingbox.ymax-tri->boundingbox.ymin) +
     162                 :          0 :                                 (tri->boundingbox.zmax-tri->boundingbox.zmin)*
     163                 :          0 :                                 (tri->boundingbox.zmax-tri->boundingbox.zmin) );                                
     164         [ #  # ]:          0 :         if ( edge_length < tri_size ) imprint_res = 0.01*edge_length; 
     165                 :          0 :         else imprint_res = 0.01*tri_size;          
     166                 :            : //  Flag triangles with planes greater than ~15 degree angle wrt the edge.
     167                 :          0 :         big_angle = false;
     168         [ #  # ]:          0 :         if ( fabs(edge_dir[0]*tri->a +edge_dir[1]*tri->b +edge_dir[2]*tri->c) > 0.25 ) 
     169                 :          0 :           big_angle = true;  
     170         [ #  # ]:          0 :         status = single_edge_tri_intersect(edge_0,edge_1,new_edge_created,tri,big_angle);
     171                 :            :      }
     172                 :            : 
     173                 :            :   }
     174                 :            : 
     175                 :          0 :   return status;
     176                 :            :   
     177                 :            : }
     178                 :            : 
     179                 :            : //  edge_0 and edge_1 are edge end-points; edge_dir is unit vector from 0 to 1                           
     180                 :          0 : CubitStatus FBImprint::single_edge_tri_intersect(double *edge_0,double *edge_1,
     181                 :            :                                                  bool &new_edge_created,
     182                 :            :                                                  FB_Triangle *tri,
     183                 :            :                                                  bool big_angle) 
     184                 :            : {
     185                 :            : CubitStatus status;
     186                 :            : double distance0, distance1;
     187                 :            : 
     188                 :          0 :   status = CUBIT_SUCCESS;
     189                 :          0 :   distance0 = edge_0[0]*tri->a + edge_0[1]*tri->b + edge_0[2]*tri->c + tri->d;                                                                     
     190                 :          0 :   distance1 = edge_1[0]*tri->a + edge_1[1]*tri->b + edge_1[2]*tri->c + tri->d;                                                                     
     191                 :            : 
     192                 :            :   //  If both end-points are farther away from the plane of the triangle than
     193                 :            :   //  imprint_res and on the same side, there is no intersection.
     194 [ #  # ][ #  # ]:          0 :   if ( ( (distance0 > imprint_res) && (distance1 > imprint_res) ) ||
                 [ #  # ]
     195         [ #  # ]:          0 :        ( (distance0 < -imprint_res) && (distance1 < -imprint_res) ) ) 
     196                 :          0 :     return status;
     197                 :            : 
     198                 :            :   //  Check the edge-triangle border closest distances.
     199                 :            : 
     200                 :            :   double d0[3], d1[3], s, t, sunclipped, tunclipped;
     201                 :            :   double closest_dist, tri_pt[3];
     202                 :            :   bool parallel0, parallel1, parallel2;
     203                 :          0 :   int numptsfound = 0;
     204                 :            :   double edge_intersection_pt[3][2]; 
     205                 :            :   int edge_vert_type[2];
     206                 :            :   
     207                 :            :   //  Test for closest distance from the edge to each of the triangle edges.
     208                 :            :   //  In order for an edge to be generated in the triangle, the intersection
     209                 :            :   //  parameter tunclipped has to lie between 0 and 1.  If this condition is met,
     210                 :            :   //  the next requirement is that the intersection parameter for the test
     211                 :            :   //  edge, sunclipped, has to be between 0 and 1 and the intersection distance
     212                 :            :   //  has to be less than imprint_res, or the intersection edge endpoint 
     213                 :            :   //  distance (distance0 or distance1) has to be less than imprint_res.
     214                 :            :   
     215                 :          0 :   d0[0] = edge_1[0] - edge_0[0];
     216                 :          0 :   d0[1] = edge_1[1] - edge_0[1];
     217                 :          0 :   d0[2] = edge_1[2] - edge_0[2];
     218 [ #  # ][ #  # ]:          0 :   d1[0] = poly->verts[tri->v1]->coord[0] - poly->verts[tri->v0]->coord[0];
     219 [ #  # ][ #  # ]:          0 :   d1[1] = poly->verts[tri->v1]->coord[1] - poly->verts[tri->v0]->coord[1];
     220 [ #  # ][ #  # ]:          0 :   d1[2] = poly->verts[tri->v1]->coord[2] - poly->verts[tri->v0]->coord[2];
     221         [ #  # ]:          0 :   tri_pt[0] = poly->verts[tri->v0]->coord[0];
     222         [ #  # ]:          0 :   tri_pt[1] = poly->verts[tri->v0]->coord[1];
     223         [ #  # ]:          0 :   tri_pt[2] = poly->verts[tri->v0]->coord[2];
     224                 :            :   
     225                 :            :   closest_dist = FBDataUtil::closest_seg_seg_dist(edge_0,d0,tri_pt,d1,&s,&t,
     226         [ #  # ]:          0 :               &sunclipped,&tunclipped,&parallel0);
     227                 :            :               
     228 [ #  # ][ #  # ]:          0 :   if ( (tunclipped >= 0.0) && (tunclipped <= 1.0) ) {
     229 [ #  # ][ #  # ]:          0 :     if ( (sunclipped >= 0.0) && (sunclipped <= 1.0) && 
                 [ #  # ]
     230                 :          0 :          (closest_dist <  imprint_res) ) {
     231                 :          0 :       edge_intersection_pt[0][numptsfound] = tri_pt[0] + tunclipped*d1[0];
     232                 :          0 :       edge_intersection_pt[1][numptsfound] = tri_pt[1] + tunclipped*d1[1];
     233                 :          0 :       edge_intersection_pt[2][numptsfound] = tri_pt[2] + tunclipped*d1[2];
     234         [ #  # ]:          0 :       if ( tunclipped == 0.0 ) edge_vert_type[numptsfound] = VERTEX_0;
     235         [ #  # ]:          0 :       else if ( tunclipped == 1.0 ) edge_vert_type[numptsfound] = VERTEX_1;
     236                 :          0 :       else edge_vert_type[numptsfound] = EDGE_0;
     237                 :          0 :       numptsfound++;     
     238                 :            :     }
     239         [ #  # ]:          0 :     else if ( sunclipped < 0.0 ) {
     240         [ #  # ]:          0 :       if ( fabs(distance0) < imprint_res ) {
     241                 :          0 :         edge_intersection_pt[0][numptsfound] = edge_0[0] - distance0*tri->a;
     242                 :          0 :         edge_intersection_pt[1][numptsfound] = edge_0[1] - distance0*tri->b;
     243                 :          0 :         edge_intersection_pt[2][numptsfound] = edge_0[2] - distance0*tri->c;
     244                 :          0 :         edge_vert_type[numptsfound] = INTERIOR_VERT;
     245                 :          0 :         numptsfound++;
     246                 :            :       } 
     247                 :            :     }
     248         [ #  # ]:          0 :     else if ( sunclipped > 1.0 ) {
     249         [ #  # ]:          0 :       if ( fabs(distance1) < imprint_res ) {
     250                 :          0 :         edge_intersection_pt[0][numptsfound] = edge_1[0] - distance1*tri->a;
     251                 :          0 :         edge_intersection_pt[1][numptsfound] = edge_1[1] - distance1*tri->b;
     252                 :          0 :         edge_intersection_pt[2][numptsfound] = edge_1[2] - distance1*tri->c;
     253                 :          0 :         edge_vert_type[numptsfound] = INTERIOR_VERT;
     254                 :          0 :         numptsfound++;      
     255                 :            :       }    
     256                 :            :     }
     257                 :            :   }             
     258                 :            :               
     259 [ #  # ][ #  # ]:          0 :   d1[0] = poly->verts[tri->v2]->coord[0] - poly->verts[tri->v1]->coord[0];
     260 [ #  # ][ #  # ]:          0 :   d1[1] = poly->verts[tri->v2]->coord[1] - poly->verts[tri->v1]->coord[1];
     261 [ #  # ][ #  # ]:          0 :   d1[2] = poly->verts[tri->v2]->coord[2] - poly->verts[tri->v1]->coord[2];
     262         [ #  # ]:          0 :   tri_pt[0] = poly->verts[tri->v1]->coord[0];
     263         [ #  # ]:          0 :   tri_pt[1] = poly->verts[tri->v1]->coord[1];
     264         [ #  # ]:          0 :   tri_pt[2] = poly->verts[tri->v1]->coord[2];
     265                 :            :   
     266                 :            :   closest_dist = FBDataUtil::closest_seg_seg_dist(edge_0,d0,tri_pt,d1,&s,&t,
     267         [ #  # ]:          0 :               &sunclipped,&tunclipped,&parallel1);
     268                 :            : 
     269 [ #  # ][ #  # ]:          0 :   if ( (tunclipped >= 0.0) && (tunclipped <= 1.0) ) {
     270 [ #  # ][ #  # ]:          0 :     if ( (sunclipped >= 0.0) && (sunclipped <= 1.0) && 
                 [ #  # ]
     271                 :          0 :          (closest_dist <  imprint_res) ) {
     272                 :          0 :       edge_intersection_pt[0][numptsfound] = tri_pt[0] + tunclipped*d1[0];
     273                 :          0 :       edge_intersection_pt[1][numptsfound] = tri_pt[1] + tunclipped*d1[1];
     274                 :          0 :       edge_intersection_pt[2][numptsfound] = tri_pt[2] + tunclipped*d1[2]; 
     275         [ #  # ]:          0 :       if ( tunclipped == 0.0 ) edge_vert_type[numptsfound] = VERTEX_1;
     276         [ #  # ]:          0 :       else if ( tunclipped == 1.0 ) edge_vert_type[numptsfound] = VERTEX_2;
     277                 :          0 :       else edge_vert_type[numptsfound] = EDGE_1;
     278                 :          0 :       numptsfound++;     
     279                 :            :     }
     280         [ #  # ]:          0 :     else if ( sunclipped < 0.0 ) {
     281         [ #  # ]:          0 :       if ( fabs(distance0) < imprint_res ) {
     282                 :          0 :         edge_intersection_pt[0][numptsfound] = edge_0[0] - distance0*tri->a;
     283                 :          0 :         edge_intersection_pt[1][numptsfound] = edge_0[1] - distance0*tri->b;
     284                 :          0 :         edge_intersection_pt[2][numptsfound] = edge_0[2] - distance0*tri->c;
     285                 :          0 :         edge_vert_type[numptsfound] = INTERIOR_VERT;
     286                 :          0 :         numptsfound++;
     287                 :            :       } 
     288                 :            :     }
     289         [ #  # ]:          0 :     else if ( sunclipped > 1.0 ) {
     290         [ #  # ]:          0 :       if ( fabs(distance1) < imprint_res ) {
     291                 :          0 :         edge_intersection_pt[0][numptsfound] = edge_1[0] - distance1*tri->a;
     292                 :          0 :         edge_intersection_pt[1][numptsfound] = edge_1[1] - distance1*tri->b;
     293                 :          0 :         edge_intersection_pt[2][numptsfound] = edge_1[2] - distance1*tri->c;
     294                 :          0 :         edge_vert_type[numptsfound] = INTERIOR_VERT;
     295                 :          0 :         numptsfound++;      
     296                 :            :       }    
     297                 :            :     }
     298                 :            :   }                          
     299                 :            :          
     300         [ #  # ]:          0 :   if ( numptsfound < 2 ) {         
     301 [ #  # ][ #  # ]:          0 :     d1[0] = poly->verts[tri->v0]->coord[0] - poly->verts[tri->v2]->coord[0];
     302 [ #  # ][ #  # ]:          0 :     d1[1] = poly->verts[tri->v0]->coord[1] - poly->verts[tri->v2]->coord[1];
     303 [ #  # ][ #  # ]:          0 :     d1[2] = poly->verts[tri->v0]->coord[2] - poly->verts[tri->v2]->coord[2];
     304         [ #  # ]:          0 :     tri_pt[0] = poly->verts[tri->v2]->coord[0];
     305         [ #  # ]:          0 :     tri_pt[1] = poly->verts[tri->v2]->coord[1];
     306         [ #  # ]:          0 :     tri_pt[2] = poly->verts[tri->v2]->coord[2];
     307                 :            : 
     308                 :            :     closest_dist = FBDataUtil::closest_seg_seg_dist(edge_0,d0,tri_pt,d1,&s,&t,
     309         [ #  # ]:          0 :                 &sunclipped,&tunclipped,&parallel2);
     310                 :            : 
     311 [ #  # ][ #  # ]:          0 :     if ( (tunclipped >= 0.0) && (tunclipped <= 1.0) ) {
     312 [ #  # ][ #  # ]:          0 :       if ( (sunclipped >= 0.0) && (sunclipped <= 1.0) && 
                 [ #  # ]
     313                 :          0 :            (closest_dist <  imprint_res) ) {
     314                 :          0 :         edge_intersection_pt[0][numptsfound] = tri_pt[0] + tunclipped*d1[0];
     315                 :          0 :         edge_intersection_pt[1][numptsfound] = tri_pt[1] + tunclipped*d1[1];
     316                 :          0 :         edge_intersection_pt[2][numptsfound] = tri_pt[2] + tunclipped*d1[2]; 
     317         [ #  # ]:          0 :         if ( tunclipped == 0.0 ) edge_vert_type[numptsfound] = VERTEX_2;
     318         [ #  # ]:          0 :         else if ( tunclipped == 1.0 ) edge_vert_type[numptsfound] = VERTEX_0;
     319                 :          0 :         else edge_vert_type[numptsfound] = EDGE_2;
     320                 :          0 :         numptsfound++;     
     321                 :            :       }
     322         [ #  # ]:          0 :       else if ( sunclipped < 0.0 ) {
     323         [ #  # ]:          0 :         if ( fabs(distance0) < imprint_res ) {
     324                 :          0 :           edge_intersection_pt[0][numptsfound] = edge_0[0] - distance0*tri->a;
     325                 :          0 :           edge_intersection_pt[1][numptsfound] = edge_0[1] - distance0*tri->b;
     326                 :          0 :           edge_intersection_pt[2][numptsfound] = edge_0[2] - distance0*tri->c;
     327                 :          0 :           edge_vert_type[numptsfound] = INTERIOR_VERT;
     328                 :          0 :           numptsfound++;
     329                 :            :         } 
     330                 :            :       }
     331         [ #  # ]:          0 :       else if ( sunclipped > 1.0 ) {
     332         [ #  # ]:          0 :         if ( fabs(distance1) < imprint_res ) {
     333                 :          0 :           edge_intersection_pt[0][numptsfound] = edge_1[0] - distance1*tri->a;
     334                 :          0 :           edge_intersection_pt[1][numptsfound] = edge_1[1] - distance1*tri->b;
     335                 :          0 :           edge_intersection_pt[2][numptsfound] = edge_1[2] - distance1*tri->c;
     336                 :          0 :           edge_vert_type[numptsfound] = INTERIOR_VERT;
     337                 :          0 :           numptsfound++;      
     338                 :            :         }    
     339                 :            :       }
     340                 :            :     }
     341                 :            :   }  
     342                 :            :   FB_Edge *edge;
     343                 :            :   int v10, v11;
     344                 :            :   bool exists;
     345                 :            : 
     346         [ #  # ]:          0 :   if ( numptsfound == 2 ) {
     347                 :            :     
     348                 :          0 :     tri->dudded = true;
     349                 :            :     v10 = poly->addavertex(edge_intersection_pt[0][0],
     350                 :            :                            edge_intersection_pt[1][0],
     351         [ #  # ]:          0 :                            edge_intersection_pt[2][0]);
     352                 :            :     v11 = poly->addavertex(edge_intersection_pt[0][1],
     353                 :            :                            edge_intersection_pt[1][1],
     354         [ #  # ]:          0 :                            edge_intersection_pt[2][1]);
     355                 :            :                     
     356         [ #  # ]:          0 :     if ( v10 != v11 ) {
     357         [ #  # ]:          0 :       exists = poly->edge_exists_in_tri(*tri,v10,v11);
     358         [ #  # ]:          0 :       if ( exists == false ) {
     359                 :          0 :         new_edge_created = true;
     360 [ #  # ][ #  # ]:          0 :         edge = new FB_Edge(v10,v11,edge_vert_type[0],edge_vert_type[1],true);
     361         [ #  # ]:          0 :         tri->edge_list.push_back(edge);
     362 [ #  # ][ #  # ]:          0 :         if ( poly->edge_exists(v10,v11) == false )
     363         [ #  # ]:          0 :           poly->intersection_edges.push_back(edge);
     364                 :            :       }
     365                 :            :     }
     366         [ #  # ]:          0 :   } else if ( numptsfound == 1 ) {
     367                 :            :   //  Is it on an edge?
     368                 :          0 :     int edge_type = UNKNOWN;
     369                 :          0 :     int vtype1 = UNKNOWN_VERT, vtype2 = UNKNOWN_VERT;
     370                 :          0 :     int v_other1 = UNKNOWN_VERT, v_other2 = UNKNOWN_VERT;
     371                 :            : //     edge_type = UNKNOWN;                      
     372         [ #  # ]:          0 :     if ( edge_vert_type[0] == EDGE_0 ) {
     373                 :          0 :         v_other1 = tri->v0;
     374                 :          0 :         v_other2 = tri->v1;
     375                 :          0 :         edge_type = EDGE_0;
     376                 :          0 :         vtype1 = VERTEX_0; 
     377                 :          0 :         vtype2 = VERTEX_1;    
     378         [ #  # ]:          0 :     } else if ( edge_vert_type[0] == EDGE_1 ) {
     379                 :          0 :         v_other1 = tri->v1;
     380                 :          0 :         v_other2 = tri->v2;
     381                 :          0 :         edge_type = EDGE_1;
     382                 :          0 :         vtype1 = VERTEX_1; 
     383                 :          0 :         vtype2 = VERTEX_2;
     384         [ #  # ]:          0 :     } else if ( edge_vert_type[0] == EDGE_2 ) {
     385                 :          0 :         v_other1 = tri->v0;
     386                 :          0 :         v_other2 = tri->v2;
     387                 :          0 :         edge_type = EDGE_2;
     388                 :          0 :         vtype1 = VERTEX_0; 
     389                 :          0 :         vtype2 = VERTEX_2;
     390                 :            :     }
     391         [ #  # ]:          0 :     if ( edge_type != UNKNOWN ) {
     392                 :          0 :       tri->dudded = true;
     393                 :            :       v10 = poly->addavertex(edge_intersection_pt[0][0],
     394                 :            :                              edge_intersection_pt[1][0],
     395         [ #  # ]:          0 :                              edge_intersection_pt[2][0]);
     396                 :            :                              
     397         [ #  # ]:          0 :         exists = poly->edge_exists_in_tri(*tri,v_other1,v10);
     398         [ #  # ]:          0 :         if ( exists == false ) {    
     399                 :          0 :           new_edge_created = true;
     400 [ #  # ][ #  # ]:          0 :           edge = new FB_Edge(v_other1,v10,vtype1,edge_type,false);
     401         [ #  # ]:          0 :           tri->edge_list.push_back(edge);
     402 [ #  # ][ #  # ]:          0 :           if ( poly->edge_exists(v_other1,v10) == false )
     403         [ #  # ]:          0 :             poly->intersection_edges.push_back(edge);
     404                 :            :         }
     405         [ #  # ]:          0 :         exists = poly->edge_exists_in_tri(*tri,v10,v_other2);
     406         [ #  # ]:          0 :         if ( exists == false ) {    
     407                 :          0 :           new_edge_created = true;
     408 [ #  # ][ #  # ]:          0 :           edge = new FB_Edge(v10,v_other2,edge_type,vtype2,false);
     409         [ #  # ]:          0 :           tri->edge_list.push_back(edge);
     410 [ #  # ][ #  # ]:          0 :           if ( poly->edge_exists(v10,v_other2) == false )
     411         [ #  # ]:          0 :             poly->intersection_edges.push_back(edge);
     412                 :            :         } 
     413                 :            :      
     414                 :            :     
     415                 :            :      }
     416                 :            :   }
     417                 :            : 
     418                 :          0 :   return status;
     419                 :            : }                           
     420                 :            :                                                                     
     421                 :          0 : CubitStatus FBImprint::update_surfs_and_curves(std::vector<double>& out_coords,
     422                 :            :                                     std::vector<int>& out_connections,
     423                 :            :                                     std::vector<int> *out_surf_index,
     424                 :            :                                     std::vector<int> *out_curve_index)
     425                 :            : {
     426                 :            : unsigned int i;
     427                 :            : 
     428         [ #  # ]:          0 :   for ( i = 0; i < poly->verts.size(); i++ ) {
     429                 :          0 :     out_coords.push_back(poly->verts[i]->coord[0]);
     430                 :          0 :     out_coords.push_back(poly->verts[i]->coord[1]);
     431                 :          0 :     out_coords.push_back(poly->verts[i]->coord[2]);
     432                 :            :   } 
     433         [ #  # ]:          0 :   for ( i = 0; i < poly->tris.size(); i++ ) {
     434         [ #  # ]:          0 :     if ( poly->tris[i]->dudded == true ) continue;
     435                 :          0 :     out_connections.push_back(poly->tris[i]->v0);
     436                 :          0 :     out_connections.push_back(poly->tris[i]->v1);
     437                 :          0 :     out_connections.push_back(poly->tris[i]->v2);
     438                 :          0 :     out_surf_index->push_back(poly->tris[i]->cubitsurfaceindex);
     439                 :          0 :     out_curve_index->push_back(poly->tris[i]->cubitedge0index);
     440                 :          0 :     out_curve_index->push_back(poly->tris[i]->cubitedge1index);
     441                 :          0 :     out_curve_index->push_back(poly->tris[i]->cubitedge2index);
     442                 :            :   }
     443                 :          0 :   return CUBIT_SUCCESS;
     444                 :            : }

Generated by: LCOV version 1.11