[cgma-dev] r1342 - cgm/trunk/geom/OCC
janehu at mcs.anl.gov
janehu at mcs.anl.gov
Thu Oct 25 13:48:16 CDT 2007
Author: janehu
Date: 2007-10-25 13:48:16 -0500 (Thu, 25 Oct 2007)
New Revision: 1342
Modified:
cgm/trunk/geom/OCC/OCCModifyEngine.hpp
cgm/trunk/geom/OCC/OCCQueryEngine.cpp
Log:
Added get_graphics for surfaces and modified bodies_overlap to check on lumps overlapping. This added bounding_box check for each lump, and make decision quicker.
Modified: cgm/trunk/geom/OCC/OCCModifyEngine.hpp
===================================================================
--- cgm/trunk/geom/OCC/OCCModifyEngine.hpp 2007-10-25 12:35:08 UTC (rev 1341)
+++ cgm/trunk/geom/OCC/OCCModifyEngine.hpp 2007-10-25 18:48:16 UTC (rev 1342)
@@ -12,8 +12,8 @@
// Owner : John Fowler
//-------------------------------------------------------------------------
-#ifndef FACET_MODIFY_ENGINE_HPP
-#define FACET_MODIFY_ENGINE_HPP
+#ifndef OCC_MODIFY_ENGINE_HPP
+#define OCC_MODIFY_ENGINE_HPP
#include "GeometryModifyEngine.hpp"
#include <vector>
Modified: cgm/trunk/geom/OCC/OCCQueryEngine.cpp
===================================================================
--- cgm/trunk/geom/OCC/OCCQueryEngine.cpp 2007-10-25 12:35:08 UTC (rev 1341)
+++ cgm/trunk/geom/OCC/OCCQueryEngine.cpp 2007-10-25 18:48:16 UTC (rev 1342)
@@ -21,8 +21,13 @@
#include "Geom_Surface.hxx"
#include "Geom_Curve.hxx"
#include "BRepBuilderAPI_Transform.hxx"
+#include "TColgp_Array1OfPnt.hxx"
+#include "Poly_Array1OfTriangle.hxx"
+#include "Poly_Triangle.hxx"
+#include "Handle_Poly_Triangulation.hxx"
#include "OCCQueryEngine.hpp"
#include "OCCModifyEngine.hpp"
+#include "Poly_Triangulation.hxx"
#include "TopologyEntity.hpp"
#include "TopologyBridge.hpp"
#include "RefEntity.hpp"
@@ -221,14 +226,68 @@
// Date :
//================================================================================
CubitStatus OCCQueryEngine::get_graphics( Surface* surface_ptr,
- int& number_triangles,
- int& number_points,
- int& number_facets,
- GMem* gMem,
- unsigned short ,
- double,
- double ) const
+ int& number_triangles,
+ int& number_points,
+ int& number_facets,
+ GMem* g_mem,
+ unsigned short normal_tolerance,
+ double distance_tolerance,
+ double max_edge_length) const
{
+ // Because this may be unnecessarily called twice,
+ // say there is one triangle.
+ if (!g_mem)
+ {
+ number_triangles = 1;
+ number_points = 3;
+ number_facets = 4;
+ return CUBIT_SUCCESS;
+ }
+
+ OCCSurface *occ_surface_ptr = CAST_TO(surface_ptr, OCCSurface);
+ TopoDS_Face * Topo_Face = occ_surface_ptr->get_TopoDS_Face();
+ if (!Topo_Face)
+ return CUBIT_FAILURE;
+
+ TopLoc_Location L;
+ Handle_Poly_Triangulation facets = BRep_Tool::Triangulation(*Topo_Face, L);
+
+ //if necessary, the face tolerance can be returned. now, no use.
+ //double tol = BRep_Tool::Tolerance(*Topo_Face);
+
+ number_points = facets->NbNodes();
+ number_triangles = facets->NbTriangles();
+ assert(number_points == 3 * number_triangles);
+ number_facets = 4 * number_triangles;
+
+ TColgp_Array1OfPnt points(0, number_points-1);
+ points.Assign(facets->Nodes());
+ GPoint *gPnts= new GPoint[number_points];
+ for (int i = 0; i < number_points; i ++)
+ {
+ gp_Pnt gp_pnt = points.Value(i);
+ GPoint gPnt;
+ gPnt.x = gp_pnt.X();
+ gPnt.y = gp_pnt.Y();
+ gPnt.z = gp_pnt.Z();
+ gPnts[i] = gPnt;
+ }
+ g_mem->replace_point_list( gPnts, number_points, number_points);
+
+ Poly_Array1OfTriangle triangles(0, number_facets-1);
+ triangles.Assign( facets->Triangles() );
+ int *facetList = new int[number_facets];
+ for (int i = 0; i < triangles.Length(); i++)
+ {
+ Poly_Triangle triangle = triangles.Value( i );
+ int N1, N2, N3;
+ triangle.Get(N1, N2, N3);
+ facetList[4 * i] = 3;
+ facetList[4 * i + 1] = N1;
+ facetList[4 * i + 2] = N2;
+ facetList[4 * i + 3] = N3;
+ }
+ g_mem->replace_facet_list( facetList, number_facets, number_facets);
return CUBIT_SUCCESS;
}
@@ -243,7 +302,7 @@
double /*tolerance*/ ) const
{
// get the OCCCurve.
- //OCCCurve *facet_curv_ptr = CAST_TO(curve_ptr,OCCCurve);
+ OCCCurve *occ_curv_ptr = CAST_TO(curve_ptr,OCCCurve);
return CUBIT_SUCCESS;
}
@@ -1992,13 +2051,19 @@
//BRepAlgoAPI_Section calculates intersection between faces only.
TopExp_Explorer Ex1, Ex2;
- for (Ex1.Init(*shape1, TopAbs_FACE); Ex1.More(); Ex1.Next())
+ for (Ex1.Init(*shape1, TopAbs_SOLID); Ex1.More(); Ex1.Next())
{
- for (Ex2.Init(*shape2, TopAbs_FACE); Ex2.More(); Ex2.Next())
+ TopoDS_Solid *posolid1 = new TopoDS_Solid;
+ *posolid1 = TopoDS::Solid(Ex1.Current());
+ OCCLump * lump1 = new OCCLump(posolid1);
+ for (Ex2.Init(*shape2, TopAbs_SOLID); Ex2.More(); Ex2.Next())
{
- BRepAlgoAPI_Section section(Ex1.Current(), Ex2.Current());
- if (section.HasGenerated())
- return CUBIT_TRUE;
+ TopoDS_Solid *posolid2 = new TopoDS_Solid;
+ *posolid2 = TopoDS::Solid(Ex2.Current());
+ OCCLump * lump2 = new OCCLump(posolid2);
+ CubitBoolean is_overlap = volumes_overlap(lump1, lump2);
+ if(is_overlap)
+ return CUBIT_TRUE;
}
}
return CUBIT_FALSE;
More information about the cgma-dev
mailing list