cgma
split_circle.cpp
Go to the documentation of this file.
00001 
00010 #undef NDEBUG
00011 #include <cassert>
00012 #include <iostream>
00013 
00014 #include "GeometryModifyTool.hpp"
00015 #include "GeometryQueryTool.hpp"
00016 #include "CubitMessage.hpp"
00017 #include "RefEdge.hpp"
00018 #include "RefVertex.hpp"
00019 #include "CastTo.hpp"
00020 #include "InitCGMA.hpp"
00021 #include "CubitCompat.hpp"
00022 #include "Point.hpp"
00023 #ifndef SRCDIR
00024 # define SRCDIR .
00025 #endif
00026 
00027 #define STRINGIFY_(X) #X
00028 #define STRINGIFY(X) STRINGIFY_(X)
00029 #define SRCPATH STRINGIFY(SRCDIR) "/"
00030 
00031 // forward declare some functions used and defined later
00032 CubitStatus split_circle();
00033 // macro for printing a separator line
00034 #define PRINT_SEPARATOR   PRINT_INFO("=======================================\n");
00035 
00036 
00037 // main program - initialize, then send to proper function
00038 
00039 int main (int argc, char **argv)
00040 {
00041   CubitStatus status = InitCGMA::initialize_cgma("OCC");
00042   if (CUBIT_SUCCESS != status) return 1;
00043 
00044   status = split_circle();
00045   if (status == CUBIT_FAILURE) 
00046      PRINT_INFO("Operation Failed");
00047 
00048   int ret_val = ( CubitMessage::instance()->error_count() );
00049   if ( ret_val != 0 )
00050   {
00051     PRINT_ERROR("Errors found during Mergechk session.\n");
00052   }
00053   else
00054     ret_val = 0;
00055 
00056   return ret_val;
00057   
00058 }
00059 
00060 CubitStatus split_circle()
00061 {
00062   GeometryQueryTool *gti = GeometryQueryTool::instance();
00063   GeometryModifyTool *gmti = GeometryModifyTool::instance();
00064   CubitVector center(0,0,0);
00065   CubitVector plane (0,0,1);
00066   RefEdge* re = gmti->create_arc(center, 3, 0, 360, plane);
00067   double length = re->measure();
00068   std::cout << "Cicle's parameter = " << length << "\n";
00069 /*
00070   CubitVector p1(0,3,0), p2(3, 0, 0), p3(0, -3, 0);
00071  
00072   RefVertex* v1 = gmti->make_RefVertex(p1);
00073   RefVertex* v2 = gmti->make_RefVertex(p2);
00074   RefVertex* v3 = gmti->make_RefVertex(p3);
00075   RefEdge* re = gmti->create_arc_three(v1, v2, v3, true);
00076 */ 
00077   //Curve* curve = re->get_curve_ptr() ; 
00078   CubitVector point(0, 3, 0);
00079   DLIList<CubitVector> sp_pts;
00080   sp_pts.append(point);
00081   DLIList<RefEdge*> new_ref_edges;
00082   gmti->split_free_curve(re, sp_pts, new_ref_edges);
00083 
00084   DLIList<RefEntity*>  free_entities;
00085   gti->get_free_ref_entities(free_entities);
00086   int count = 0;
00087   for(int i = 0; i < free_entities.size(); i++)
00088   {
00089     RefEdge* ref_edge = dynamic_cast<RefEdge*> (free_entities.get_and_step());
00090     if (ref_edge)
00091     {
00092       double d = ref_edge->measure();
00093       std::cout << "edge length = " << d << "\n";
00094       count++;
00095     }
00096   }
00097   assert( count == 2);
00098   std::cout << "number of free edges: " << count << " <---should be 2 free edges."<<"\n";
00099 
00100   return CUBIT_SUCCESS;  
00101 }
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines