[cgma-dev] r2460 - cgm/trunk/geom/OCC

janehu at mcs.anl.gov janehu at mcs.anl.gov
Wed Dec 3 16:01:38 CST 2008


Author: janehu
Date: 2008-12-03 16:01:38 -0600 (Wed, 03 Dec 2008)
New Revision: 2460

Modified:
   cgm/trunk/geom/OCC/OCCQueryEngine.cpp
Log:
fixed for getting facets from surfaces problem.

Modified: cgm/trunk/geom/OCC/OCCQueryEngine.cpp
===================================================================
--- cgm/trunk/geom/OCC/OCCQueryEngine.cpp	2007-03-07 19:35:13 UTC (rev 2459)
+++ cgm/trunk/geom/OCC/OCCQueryEngine.cpp	2008-12-03 22:01:38 UTC (rev 2460)
@@ -273,7 +273,7 @@
   TopLoc_Location L;
   Handle_Poly_Triangulation facets = BRep_Tool::Triangulation(*Topo_Face, L);
 
-  if(facets.IsNull())
+  if(facets.IsNull() || facets->NbTriangles() == 0)
   {
     //do triangulation
     double deflection = 0.01;
@@ -285,7 +285,7 @@
     new BRepMesh_FastDiscret(deflection, *Topo_Face, aBox, angle, Standard_True, Standard_True);
     if (myMesh != NULL) delete myMesh;
     facets = BRep_Tool::Triangulation(*Topo_Face, L);
-    if(facets.IsNull())
+    if(facets.IsNull() || facets->NbTriangles() == 0)
     {
       PRINT_ERROR("Can't get triangulation representation for this surface.\n");
       return CUBIT_FAILURE;
@@ -304,7 +304,6 @@
   //needs to test that N1, N2, N3 index are starting from 0 to number_points-1
   //otherwise needs to update either facetList or gPnts to make consistent.
   //It's possible also that N's starting from 1.
-  int minN = 0;
   for (int i = 0; i < triangles.Length(); i++)
     {
       Poly_Triangle triangle = triangles.Value( i );
@@ -312,18 +311,15 @@
       triangle.Get(N1, N2, N3); 
       facetList[4 * i] = 3;
       facetList[4 * i + 1] = N1;
-      minN = (minN < N1 ? minN : N1);
       facetList[4 * i + 2] = N2;
-      minN = (minN < N2 ? minN : N2);
       facetList[4 * i + 3] = N3;
-      minN = (minN < N3 ? minN : N3);
     } 
   g_mem->replace_facet_list( facetList, number_facets, number_facets); 
 
-  TColgp_Array1OfPnt points(minN, minN + number_points-1);
+  TColgp_Array1OfPnt points(0,  number_points-1);
   points.Assign(facets->Nodes());
-  GPoint *gPnts= new GPoint[number_points + minN];
-  for (int i = minN; i < number_points + minN; i ++)
+  GPoint *gPnts= new GPoint[number_points];
+  for (int i = 0; i < number_points ; i ++)
     {
       gp_Pnt gp_pnt = points.Value(i);
       GPoint gPnt;
@@ -332,7 +328,7 @@
       gPnt.z = gp_pnt.Z();
       gPnts[i] = gPnt;
     }
-  g_mem->replace_point_list( gPnts, number_points, number_points + minN);
+  g_mem->replace_point_list( gPnts, number_points, number_points );
 
   return CUBIT_SUCCESS;
 }




More information about the cgma-dev mailing list