[cgma-dev] r2279 - in cgm/trunk: geom/OCC test

janehu at mcs.anl.gov janehu at mcs.anl.gov
Mon Nov 24 11:24:24 CST 2008


Author: janehu
Date: 2008-11-24 11:24:24 -0600 (Mon, 24 Nov 2008)
New Revision: 2279

Modified:
   cgm/trunk/geom/OCC/OCCQueryEngine.cpp
   cgm/trunk/test/makept.cpp
   cgm/trunk/test/modify.cpp
Log:
Modified to correctly tessellate a curve.

Modified: cgm/trunk/geom/OCC/OCCQueryEngine.cpp
===================================================================
--- cgm/trunk/geom/OCC/OCCQueryEngine.cpp	2008-11-24 16:03:10 UTC (rev 2278)
+++ cgm/trunk/geom/OCC/OCCQueryEngine.cpp	2008-11-24 17:24:24 UTC (rev 2279)
@@ -31,6 +31,7 @@
 #include "Poly_Triangle.hxx"
 #include "BRepAlgoAPI_BooleanOperation.hxx"
 #include "Handle_Poly_Triangulation.hxx"
+#include "GCPnts_TangentialDeflection.hxx"
 #include "BRepAdaptor_Curve.hxx"
 #include "BndLib_Add3dCurve.hxx"
 #include "Poly_Polygon3D.hxx"
@@ -357,33 +358,31 @@
   if (!Topo_Edge)
     return CUBIT_FAILURE;
 
-  //do triangulation
-  double deflection = 0.01;
-  double angle  = 0.5;
+  //do tessellation
+  double deflection = 0.2;
+  double angle  = 0.2;
   BRepAdaptor_Curve acurve(*Topo_Edge);
-  Bnd_Box aBox;
-  BndLib_Add3dCurve::Add(acurve, Precision::Approximation(), aBox);
-  BRepMesh_FastDiscret *myMesh =
-  new BRepMesh_FastDiscret(deflection, *Topo_Edge, aBox, angle, Standard_True, Standard_True);
+  GCPnts_TangentialDeflection *myMesh = 
+        new GCPnts_TangentialDeflection(acurve, angle, deflection);
   if (myMesh == NULL) 
   {
-    PRINT_ERROR("Can't get triangulation representation for this curve.\n");
+    PRINT_ERROR("Can't tessellate for this curve.\n");
     return CUBIT_FAILURE;
   }
-  num_points = myMesh->NbVertices();
+  num_points = myMesh->NbPoints();
 
   //! Note: If the polygon is closed, the point of closure is 
   //! repeated at the end of its table of nodes. Thus, on a closed 
-  //! triangle the function NbNodes returns 4. 
+  //! triangle the function NbNodes returns 4? 
   GPoint *gPnts= new GPoint[num_points];
   for (int i = 1; i <= num_points ; i ++)
     {
-      gp_Pnt gp_pnt = myMesh->Pnt(i);
+      gp_Pnt gp_pnt = myMesh->Value(i);
       GPoint gPnt;
       gPnt.x = gp_pnt.X();
       gPnt.y = gp_pnt.Y();
       gPnt.z = gp_pnt.Z();
-      gPnts[i] = gPnt;
+      gPnts[i-1] = gPnt;
     }
   gMem->replace_point_list( gPnts, num_points, num_points );
  

Modified: cgm/trunk/test/makept.cpp
===================================================================
--- cgm/trunk/test/makept.cpp	2008-11-24 16:03:10 UTC (rev 2278)
+++ cgm/trunk/test/makept.cpp	2008-11-24 17:24:24 UTC (rev 2279)
@@ -29,6 +29,7 @@
 #include "OCCBody.hpp"
 #include "OCCSurface.hpp"
 #include "OCCCurve.hpp"
+#include "OCCDrawTool.hpp"
 
 #ifndef SRCDIR
 # define SRCDIR .
@@ -114,6 +115,26 @@
   OCCQueryEngine::instance();
   OCCModifyEngine::instance();
 
+  //Create sphere
+  RefEntity* sphereEnt= GeometryModifyTool::instance()->sphere(1.5);
+  sphereEnt->entity_name("sphere");
+
+  TopoDS_CompSolid* objOCC;
+  Body* tmpBd = GeometryQueryTool::instance()->get_first_body();
+  DLIList<RefVertex*> vertices;
+  tmpBd->ref_vertices(vertices);
+  DLIList<RefEdge*> ref_edges;
+  tmpBd->ref_edges(ref_edges);
+  for(int i = 0; i < ref_edges.size(); i++) 
+  {
+    vertices.clean_out();
+    ref_edges.get()->ref_vertices(vertices);
+    ref_edges.get_and_step()->measure();
+  }
+  BodySM* tmpBdSM = tmpBd->get_body_sm_ptr();
+  objOCC = ( (OCCBody*) tmpBdSM )->get_TopoDS_Shape(); //Opencascade Object
+  OCCDrawTool::instance()->draw_TopoDS_Shape(objOCC, 200);
+
   // Read in the geometry from files specified on the command line
   const char *argv = "66_shaver3.brep";
   CubitStatus status = read_geometry(1, &argv);
@@ -417,7 +438,7 @@
      gti->delete_RefEntity( free_entities.get_and_step());
   }
 
-  DLIList<RefEdge *> ref_edges;
+  ref_edges.clean_out();
   gti->ref_edges(ref_edges);
 
   //make a new refedge out of existing refedge.

Modified: cgm/trunk/test/modify.cpp
===================================================================
--- cgm/trunk/test/modify.cpp	2008-11-24 16:03:10 UTC (rev 2278)
+++ cgm/trunk/test/modify.cpp	2008-11-24 17:24:24 UTC (rev 2279)
@@ -781,6 +781,17 @@
   n = new_bodies.get()->num_ref_faces(); //n = 10
   d = new_bodies.get()->measure(); //d = 72.3618
 
+  bodies.clean_out();
+  gti->bodies(bodies); //bodies.size() = 2
+  free_entities.clean_out();
+  gti->get_free_ref_entities(free_entities); //free_entities.size() = 0
+  assert(free_entities.size() == 0);
+  //delete hollowed body and keep sweep_face. 
+  gti->delete_Body(new_bodies);
+  free_entities.clean_out();
+  gti->get_free_ref_entities(free_entities); //free_entities.size() = 0
+  assert(free_entities.size() == 0);
+
   DLIList<RefEntity*> refentities;
   refentities.append(sweep_face);
   RefFace* draft_face = gmti->make_RefFace(sweep_face);




More information about the cgma-dev mailing list