00001 /* $NoKeywords: $ */ 00002 /* 00003 // 00004 // Copyright (c) 1993-2012 Robert McNeel & Associates. All rights reserved. 00005 // OpenNURBS, Rhinoceros, and Rhino3D are registered trademarks of Robert 00006 // McNeel & Associates. 00007 // 00008 // THIS SOFTWARE IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY. 00009 // ALL IMPLIED WARRANTIES OF FITNESS FOR ANY PARTICULAR PURPOSE AND OF 00010 // MERCHANTABILITY ARE HEREBY DISCLAIMED. 00011 // 00012 // For complete openNURBS copyright information see <http://www.opennurbs.org>. 00013 // 00015 */ 00016 00018 // 00019 // Definition of b-rep and its parts 00020 // 00022 00023 #if !defined(OPENNURBS_BREP_INC_) 00024 #define OPENNURBS_BREP_INC_ 00025 00026 class ON_BrepTrim; 00027 class ON_BrepEdge; 00028 class ON_BrepLoop; 00029 class ON_BrepFace; 00030 00031 00032 // TEMPORARY DEFINES SO I DON'T BREAK THE BUILD 00033 #define m_vertex_user_i m_vertex_user.i 00034 #define m_trim_user_i m_trim_user.i 00035 #define m_edge_user_i m_edge_user.i 00036 #define m_loop_user_i m_loop_user.i 00037 #define m_face_user_i m_face_user.i 00038 00039 // Description: 00040 // Brep vertex information is stored in ON_BrepVertex classes. 00041 // ON_Brep.m_V[] is an array of all the vertices in the brep. 00042 // 00043 // If a vertex is a point on a face, then brep.m_E[m_ei] 00044 // will be an edge with no 3d curve. This edge will have 00045 // a single trim with type ON_BrepTrim::ptonsrf. There 00046 // will be a loop containing this single trim. 00047 // Use ON_Brep::NewPointOnFace() to create vertices that are 00048 // points on faces. 00049 class ON_CLASS ON_BrepVertex : public ON_Point 00050 { 00051 ON_OBJECT_DECLARE(ON_BrepVertex); 00052 00053 public: 00054 // Union available for application use. 00055 // The constructor zeros m_vertex_user. 00056 // The value is of m_vertex_user is not saved in 3DM 00057 // archives and may be changed by some computations. 00058 ON_U m_vertex_user; 00059 00060 // index of the vertex in the ON_Brep.m_V[] array 00061 int m_vertex_index; 00062 00064 // Construction 00065 // 00066 // In general, you should not directly create ON_BrepVertex classes. 00067 // Use ON_Brep::NewVertex instead. 00068 ON_BrepVertex(); 00069 ON_BrepVertex( 00070 int // vertex index 00071 ); 00072 ON_BrepVertex& operator=(const ON_BrepVertex&); 00073 00074 // virtual ON_Object::SizeOf override 00075 unsigned int SizeOf() const; 00076 00077 // virtual ON_Object::DataCRC override 00078 ON__UINT32 DataCRC(ON__UINT32 current_remainder) const; 00079 00080 /* 00081 Description: 00082 Tests an object to see if its data members are correctly 00083 initialized. 00084 Parameters: 00085 text_log - [in] if the object is not valid and text_log 00086 is not NULL, then a brief englis description of the 00087 reason the object is not valid is appened to the log. 00088 The information appended to text_log is suitable for 00089 low-level debugging purposes by programmers and is 00090 not intended to be useful as a high level user 00091 interface tool. 00092 Returns: 00093 @untitled table 00094 true object is valid 00095 false object is invalid, uninitialized, etc. 00096 Remarks: 00097 Overrides virtual ON_Object::IsValid 00098 */ 00099 ON_BOOL32 IsValid( ON_TextLog* text_log = NULL ) const; 00100 00101 // virtual ON_Object::Dump() override 00102 void Dump( ON_TextLog& ) const; // for debugging 00103 00104 // virtual ON_Object::Write() override 00105 ON_BOOL32 Write( ON_BinaryArchive& ) const; 00106 00107 // virtual ON_Object::Read() override 00108 ON_BOOL32 Read( ON_BinaryArchive& ); 00109 00110 // virtual ON_Geometry::ComponentIndex() override 00111 ON_COMPONENT_INDEX ComponentIndex() const; 00112 00114 // Interface 00115 00116 // Description: 00117 // Set vertex location. 00118 // Parameters: 00119 // point - [in] 3d vertex location 00120 bool SetPoint( 00121 const ON_3dPoint& // point 00122 ); 00123 00124 // Returns: 00125 // Vertex location. 00126 ON_3dPoint Point() const; 00127 00128 // Returns: 00129 // value of ON_BrepVertex::m_tolerance 00130 // Remarks: 00131 // Use ON_Brep::SetVertexTolerance( ON_BrepVertex& ) to set tolerances. 00132 double Tolerance() const; 00133 00134 // Returns: 00135 // number of edges that begin or end at this vertex. 00136 int EdgeCount() const; 00137 00139 // Implementation 00140 00141 // indices of edges starting/ending at this vertex 00142 // 00143 // For closed edges, edge.m_vi[0] = edge.m_vi[1] and 00144 // edge.m_edge_index appears twice in the m_ei[] array. 00145 // The first occurance of edge.m_edge_index in m_ei[] 00146 // is for the closed edge starting the vertex. 00147 // The second occurance of edge,m_edge_index in m_ei[] 00148 // is for the closed edge ending at the vertex. 00149 // C.f. ON_Brep::Next/PrevEdge(). 00150 ON_SimpleArray<int> m_ei; 00151 00152 // accuracy of vertex point (>=0.0 or ON_UNSET_VALUE) 00153 // 00154 // A value of ON_UNSET_VALUE indicates that the 00155 // tolerance should be computed. 00156 // 00157 // A value of 0.0 indicates that the distance 00158 // from the vertex to any applicable edge or trim 00159 // end is <= ON_ZERO_TOLERANCE 00160 // 00161 // If an edge begins or ends at this vertex, 00162 // then the distance from the vertex's 00163 // 3d point to the appropriate end of the 00164 // edge's 3d curve must be <= this tolerance. 00165 // 00166 // If a trim begins or ends at this vertex, 00167 // then the distance from the vertex's 3d point 00168 // to the 3d point on the surface obtained by 00169 // evaluating the surface at the appropriate 00170 // end of the trimming curve must be <= this 00171 // tolerance. 00172 double m_tolerance; 00173 00174 private: 00175 ON_BrepVertex( const ON_BrepVertex& ); // no implementation 00176 00177 }; 00178 00179 /* 00180 Description: 00181 Brep edge information is stored in ON_BrepEdge classes. 00182 ON_Brep.m_E[] is an array of all the edges in the brep. 00183 00184 An ON_BrepEdge is derived from ON_CurveProxy so the the 00185 edge can supply easy to use evaluation tools via 00186 the ON_Curve virtual member functions. 00187 00188 Note well that the domains and orientations of the curve 00189 m_C3[edge.m_c3i] and the edge as a curve may not 00190 agree. 00191 */ 00192 class ON_CLASS ON_BrepEdge : public ON_CurveProxy 00193 { 00194 ON_OBJECT_DECLARE(ON_BrepEdge); 00195 public: 00196 00197 // Union available for application use. 00198 // The constructor zeros m_edge_user. 00199 // The value is of m_edge_user is not saved in 3DM 00200 // archives and may be changed by some computations. 00201 ON_U m_edge_user; 00202 00203 // index of edge in ON_Brep.m_E[] array 00204 int m_edge_index; 00205 00206 00207 // virtual ON_Curve::IsClosed override 00208 ON_BOOL32 IsClosed() const; 00209 00211 // Construction 00212 // 00213 // In general, you should not directly create ON_BrepEdge classes. 00214 // Use ON_Brep::NewVertex instead. 00215 ON_BrepEdge(); 00216 ON_BrepEdge(int); // edge index 00217 ON_BrepEdge& operator=(const ON_BrepEdge&); 00218 00219 // virtual ON_Object function 00220 // The ON_BrepEdge override returns ON::curve_object. 00221 ON::object_type ObjectType() const; 00222 00223 /* 00224 Returns: 00225 Brep this edge belongs to. 00226 */ 00227 ON_Brep* Brep() const; 00228 00229 00230 /* 00231 Parameters: 00232 eti - [in] index into the edge's m_ti[] array. 00233 Returns: 00234 The trim brep.m_T[edge.m_ti[eti]]; 00235 */ 00236 ON_BrepTrim* Trim( int eti ) const; 00237 00238 /* 00239 Returns: 00240 Number of trims attached to this edge. 00241 */ 00242 int TrimCount() const; 00243 00244 /* 00245 Parameters: 00246 evi - [in] 0 or 1 00247 Returns: 00248 Brep vertex at specified end of the edge. 00249 */ 00250 ON_BrepVertex* Vertex(int evi) const; 00251 00252 // virtual ON_Object::SizeOf override 00253 unsigned int SizeOf() const; 00254 00255 // virtual ON_Object::DataCRC override 00256 ON__UINT32 DataCRC(ON__UINT32 current_remainder) const; 00257 00258 /* 00259 Description: 00260 Tests an object to see if its data members are correctly 00261 initialized. 00262 Parameters: 00263 text_log - [in] if the object is not valid and text_log 00264 is not NULL, then a brief englis description of the 00265 reason the object is not valid is appened to the log. 00266 The information appended to text_log is suitable for 00267 low-level debugging purposes by programmers and is 00268 not intended to be useful as a high level user 00269 interface tool. 00270 Returns: 00271 @untitled table 00272 true object is valid 00273 false object is invalid, uninitialized, etc. 00274 Remarks: 00275 Overrides virtual ON_Object::IsValid 00276 */ 00277 ON_BOOL32 IsValid( ON_TextLog* text_log = NULL ) const; 00278 00279 // virtual ON_Object::Dump() override 00280 void Dump( ON_TextLog& ) const; // for debugging 00281 00282 // virtual ON_Object::Write() override 00283 ON_BOOL32 Write( ON_BinaryArchive& ) const; 00284 00285 // virtual ON_Object::Read() override 00286 ON_BOOL32 Read( ON_BinaryArchive& ); 00287 00288 // virtual ON_Geometry::ComponentIndex() override 00289 ON_COMPONENT_INDEX ComponentIndex() const; 00290 00291 // virtual ON_Curve::Reverse override 00292 ON_BOOL32 Reverse(); 00293 00294 // virtual ON_Curve::SetStartPoint override 00295 ON_BOOL32 SetStartPoint( 00296 ON_3dPoint start_point 00297 ); 00298 00299 // virtual ON_Curve::SetEndPoint override 00300 ON_BOOL32 SetEndPoint( 00301 ON_3dPoint end_point 00302 ); 00303 00305 // Implementation 00306 00307 /* 00308 Returns: 00309 brep.m_C3[] index of the 3d curve geometry used by this edge 00310 or -1. 00311 */ 00312 int EdgeCurveIndexOf() const; 00313 00314 /* 00315 Returns: 00316 3d curve geometry used by this edge or NULL. 00317 */ 00318 const ON_Curve* EdgeCurveOf() const; 00319 00320 /* 00321 Description: 00322 Expert user tool that replaces the 3d curve geometry 00323 of an edge 00324 Parameters; 00325 c3i - [in] brep 3d curve index of new curve 00326 Returns: 00327 True if successful. 00328 Example: 00329 00330 ON_Curve* pCurve = ...; 00331 int c3i = brep.AddEdgeCurve(pCurve); 00332 edge.ChangeEdgeCurve(c3i); 00333 00334 Remarks: 00335 Sets m_c3i, calls SetProxyCurve, cleans runtime caches. 00336 */ 00337 bool ChangeEdgeCurve( 00338 int c3i 00339 ); 00340 00341 /* 00342 Description: 00343 When an edge is modified, the m_pline[].e values need 00344 to be set to ON_UNSET_VALUE by calling UnsetPlineEdgeParameters(). 00345 */ 00346 void UnsetPlineEdgeParameters(); 00347 00348 // index of 3d curve in m_C3[] array 00349 // (edge.m_curve also points to m_C3[m_c3i]) 00350 int m_c3i; 00351 00352 // indices of starting/ending vertex 00353 // 00354 // For closed edges, m_vi[0] = m_vi[1] and m_edge_index 00355 // appears twice in the m_V[m_vi[0]].m_ei[] array. 00356 // The first occurance of m_edge_index in m_V[m_vi[0]].m_ei[] 00357 // is for the closed edge starting the vertex. The second 00358 // occurance of m_edge_index in m_V[m_vi[0]].m_ei[] 00359 // is for the closed edge edge ending at the vertex. 00360 // C.f. ON_Brep::Next/PrevEdge(). 00361 int m_vi[2]; 00362 00363 // indices of Trims that use this edge 00364 ON_SimpleArray<int> m_ti; 00365 00366 // accuracy of edge curve (>=0.0 or ON_UNSET_VALUE) 00367 // 00368 // A value of ON_UNSET_VALUE indicates that the 00369 // tolerance should be computed. 00370 // 00371 // The maximum distance from the edge's 3d curve 00372 // to any surface of a face that has this edge as 00373 // a portion of its boundary must be <= this 00374 // tolerance. 00375 double m_tolerance; 00376 00377 private: 00378 friend class ON_Brep; 00379 ON_Brep* m_brep; // so isolated edge class edge can get at it's 3d curve 00380 ON_BrepEdge( const ON_BrepEdge& ); // no implementation 00381 }; 00382 00383 struct ON_BrepTrimPoint 00384 { 00385 ON_2dPoint p; // 2d surface parameter space point 00386 double t; // corresponding trim curve parameter 00387 double e; // corresponding edge curve parameter (ON_UNSET_VALUE if unknown) 00388 }; 00389 00390 #if defined(ON_DLL_TEMPLATE) 00391 // This stuff is here because of a limitation in the way Microsoft 00392 // handles templates and DLLs. See Microsoft's knowledge base 00393 // article ID Q168958 for details. 00394 #pragma warning( push ) 00395 #pragma warning( disable : 4231 ) 00396 ON_DLL_TEMPLATE template class ON_CLASS ON_SimpleArray<ON_BrepTrimPoint>; 00397 #pragma warning( pop ) 00398 #endif 00399 00400 00401 /* 00402 Description: 00403 Brep trim information is stored in ON_BrepTrim classes. 00404 ON_Brep.m_T[] is an array of all the trim in the brep. 00405 00406 An ON_BrepTrim is derived from ON_CurveProxy so the the 00407 trim can supply easy to use evaluation tools via 00408 the ON_Curve virtual member functions. 00409 00410 Note well that the domains and orientations of the curve 00411 m_C2[trim.m_c2i] and the trin as a curve may not 00412 agree. 00413 */ 00414 class ON_CLASS ON_BrepTrim : public ON_CurveProxy 00415 { 00416 ON_OBJECT_DECLARE(ON_BrepTrim); 00417 00418 public: 00419 void DestroyRuntimeCache( bool bDelete = true ); 00420 00421 // virtual ON_Object::SizeOf override 00422 unsigned int SizeOf() const; 00423 00424 // Union available for application use. 00425 // The constructor zeros m_trim_user. 00426 // The value is of m_trim_user is not saved in 3DM 00427 // archives and may be changed by some computations. 00428 ON_U m_trim_user; 00429 00430 int m_trim_index; // index of trim in ON_Brep.m_T[] array 00431 00432 // types of trim - access through m_type member. Also see m_iso and ON_Surface::ISO 00433 enum TYPE 00434 { 00435 unknown = 0, 00436 boundary = 1, // trim is connected to an edge, is part of an outer, 00437 // inner or slit loop, and is the only trim connected 00438 // to the edge. 00439 mated = 2, // trim is connected to an edge, is part of an outer, 00440 // inner or slit loop, no other trim from the same 00441 // loop is connected to the edge, and at least one 00442 // trim from a different loop is connected to the edge. 00443 seam = 3, // trim is connected to an edge, is part of an outer, 00444 // inner or slit loop, and one other trim from the 00445 // same loop is connected to the edge. 00446 // (There can be other mated trims that are also 00447 // connected to the edge. For example, the non-mainfold 00448 // edge that results when a surface edge lies in the 00449 // middle of another surface.) Non-mainfold "cuts" 00450 // have seam trims too. 00451 singular = 4, // trim is part of an outer loop, the trim's 2d curve 00452 // runs along the singular side of a surface, and the 00453 // trim is NOT connected to an edge. (There is no 3d 00454 // edge because the surface side is singular.) 00455 crvonsrf = 5, // trim is connected to an edge, is the only trim in 00456 // a crfonsrf loop, and is the only trim connected to 00457 // the edge. 00458 ptonsrf = 6, // trim is a point on a surface, trim.m_pbox is records 00459 // surface parameters, and is the only trim 00460 // in a ptonsrf loop. This trim is not connected 00461 // to an edge and has no 2d curve. 00462 slit = 7, // 17 Nov 2006 - reserved for future use 00463 // currently an invalid value 00464 trim_type_count = 8, 00465 force_32_bit_trim_type = 0xFFFFFFFF 00466 }; 00467 00469 // Construction 00470 // 00471 // In general, you should not directly create ON_BrepTrim classes. 00472 // Use ON_Brep::NewTrim instead. 00473 ON_BrepTrim(); 00474 ON_BrepTrim(int); // trim index 00475 ON_BrepTrim& operator=(const ON_BrepTrim&); 00476 00477 /* 00478 Returns: 00479 Brep that this trim belongs to. 00480 */ 00481 ON_Brep* Brep() const; 00482 00483 /* 00484 Returns: 00485 Brep loop that this trim belongs to. 00486 */ 00487 ON_BrepLoop* Loop() const; 00488 00489 /* 00490 Returns: 00491 Brep face this trim belongs to. 00492 */ 00493 ON_BrepFace* Face() const; 00494 00495 /* 00496 Returns: 00497 Brep edge this trim uses or belongs to. This will 00498 be NULL for singular trims. 00499 */ 00500 ON_BrepEdge* Edge() const; 00501 00502 /* 00503 Parameters: 00504 tvi - [in] 0 or 1 00505 Returns: 00506 Brep vertex at specified end of the trim. 00507 */ 00508 ON_BrepVertex* Vertex(int tvi) const; 00509 00511 // ON_Object overrides 00512 // 00513 // (Trims are purely topologicial - geometry queries should be 00514 // directed at the trim's 2d curve or the trim's edge's 3d curve.) 00515 00516 /* 00517 Description: 00518 Tests an object to see if its data members are correctly 00519 initialized. 00520 Parameters: 00521 text_log - [in] if the object is not valid and text_log 00522 is not NULL, then a brief englis description of the 00523 reason the object is not valid is appened to the log. 00524 The information appended to text_log is suitable for 00525 low-level debugging purposes by programmers and is 00526 not intended to be useful as a high level user 00527 interface tool. 00528 Returns: 00529 @untitled table 00530 true object is valid 00531 false object is invalid, uninitialized, etc. 00532 Remarks: 00533 Overrides virtual ON_Object::IsValid 00534 */ 00535 ON_BOOL32 IsValid( ON_TextLog* text_log = NULL ) const; 00536 00537 void Dump( ON_TextLog& ) const; // for debugging 00538 00539 ON_BOOL32 Write( ON_BinaryArchive& ) const; 00540 00541 ON_BOOL32 Read( ON_BinaryArchive& ); 00542 00543 // virtual ON_Geometry::ComponentIndex() override 00544 ON_COMPONENT_INDEX ComponentIndex() const; 00545 00546 // virtual ON_Curve::Reverse override 00547 // Reverses curve - caller must make sure trim's m_bRev3d 00548 // flags are properly updated. Use 00549 // ON_Brep::FlipTrim to reverse and trim and update all 00550 // m_bRev3d informtion. 00551 ON_BOOL32 Reverse(); 00552 00553 // virtual ON_Curve::SetStartPoint override 00554 ON_BOOL32 SetStartPoint( 00555 ON_3dPoint start_point 00556 ); 00557 00558 // virtual ON_Curve::SetEndPoint override 00559 ON_BOOL32 SetEndPoint( 00560 ON_3dPoint end_point 00561 ); 00562 00564 // Interface 00565 00566 /* 00567 Description: 00568 Expert user tool that replaces the 2d curve geometry 00569 of a trim 00570 Parameters; 00571 c2i - [in] brep 2d curve index of new curve 00572 Returns: 00573 True if successful. 00574 Example: 00575 00576 ON_Curve* pCurve = ...; 00577 int c2i = brep.AddTrimCurve(pCurve); 00578 trim.ChangeTrimCurve(c2i); 00579 00580 Remarks: 00581 Sets m_c2i, calls SetProxyCurve, cleans runtime caches, 00582 and updates m_pbox. 00583 */ 00584 bool ChangeTrimCurve( int c2i ); 00585 00586 /* 00587 Description: 00588 Destroy parameter space information. 00589 Currently, this involves destroying m_pline 00590 and m_pbox. Parameter space information should 00591 be destroyed when the location of a trim 00592 curve is changed. 00593 */ 00594 void DestroyPspaceInformation(); 00595 00596 /* 00597 Description: 00598 Expert user function. 00599 Removes a trim from an edge. 00600 Parameters: 00601 bRemoveFromStartVertex - [in] if true, the trim 00602 is removed from its start vertex by setting 00603 m_vi[0] to -1. 00604 bRemoveFromEndVertex - [in] if true, the trim 00605 is removed from its start vertex by setting 00606 m_vi[1] to -1. 00607 Remarks: 00608 If the trim is attached to an edge (m_ei>=0), then 00609 the trim is removed from the edge and the edge's 00610 m_ti[] list. The trim's m_bRev3d and tolerance values 00611 are not changed. 00612 */ 00613 bool RemoveFromEdge( 00614 bool bRemoveFromStartVertex, 00615 bool bRemoveFromEndVertex 00616 ); 00617 00618 /* 00619 Description: 00620 Expert user function. 00621 Attaches a trim to an edge. 00622 Parameters: 00623 edge_index - [in] index of an edge. 00624 bRev3d - [in] value for trim's m_bRev3d field. 00625 Remarks: 00626 If the trim is attached to an edge (m_ei>=0), then 00627 the trim is removed from the edge and the edge's 00628 m_ti[] list. The trim's tolerance values are not 00629 changed. 00630 */ 00631 bool AttachToEdge( 00632 int edge_index, 00633 bool bRev3d 00634 ); 00635 00636 /* 00637 Returns: 00638 2d curve geometry used by this trim or NULL 00639 */ 00640 const ON_Curve* TrimCurveOf() const; 00641 00642 /* 00643 Returns: 00644 3d curve geometry used by this trim or NULL. 00645 */ 00646 const ON_Curve* EdgeCurveOf() const; 00647 00648 /* 00649 Returns: 00650 3d surface geometry used by this trim or NULL 00651 */ 00652 const ON_Surface* SurfaceOf() const; 00653 00654 /* 00655 Returns: 00656 brep.m_C2[] 2d curve index of the 2d curve geometry used by 00657 this trim or -1. 00658 */ 00659 int TrimCurveIndexOf() const; 00660 00661 /* 00662 Returns: 00663 brep.m_C3[] 3d curve index of the 3d curve geometry used by 00664 this trim or -1. 00665 */ 00666 int EdgeCurveIndexOf() const; 00667 00668 /* 00669 Returns: 00670 brep.m_S[] surface index of the 3d surface geometry used by 00671 this trim or -1. 00672 */ 00673 int SurfaceIndexOf() const; 00674 00675 /* 00676 Returns: 00677 brep.m_F[] face index of the face used by this trim or -1. 00678 */ 00679 int FaceIndexOf() const; 00680 00681 /* 00682 Returns: 00683 True if the trim satisfies these four criteria. 00684 1) is part of a loop 00685 2) is connected to a 3d edge 00686 3) one other trim from the same loop is connected to the edge 00687 4) The 2d trim curve for the other trim is the reverse 00688 of the 2d trim curve for this trim. 00689 Remarks: 00690 In order for IsSlit() to work correctly, the m_type and m_iso 00691 fields must be set correctly. In V4 SR1, this function will 00692 be removed and ON_BrepTrim::slit will be added as a type. 00693 */ 00694 bool IsSlit() const; 00695 00696 /* 00697 Returns: 00698 True if the trim satisfies these four criteria. 00699 1) is part of a loop 00700 2) is connected to a 3d edge 00701 3) one other trim from the same loop is connected to the edge 00702 4) the 2d trim curve for this trim lies along the side of 00703 the face's parameter space and the 2d curve for the other 00704 trim lies on the opposite side of the face's parameter 00705 space. 00706 Remarks: 00707 In order for IsSeam() to work correctly, the m_type and m_iso 00708 fields must be set correctly. In V4 SR1, this function will 00709 be removed and ON_BrepTrim::slit will be added as a type. 00710 */ 00711 bool IsSeam() const; 00712 00713 /* 00714 Description: 00715 Expert user tool that tranforms all the parameter space (2d) 00716 trimming curves in this loop. Only 2d curve geometry is 00717 changed. The caller is responsible for reversing loops, 00718 toggle m_bRev, flags, etc. 00719 Parameters: 00720 xform - [in] Transformation applied to 2d curve geometry. 00721 Returns 00722 True if successful. If false is returned, the brep 00723 may be invalid. 00724 */ 00725 bool TransformTrim( const ON_Xform& xform ); 00726 00727 // index of the 2d parameter space trimming curve 00728 int m_c2i; 00729 00730 // index of 3d edge (-1 if ON_BrepTrim is singular) 00731 int m_ei; 00732 00733 // Indices of start/end vertices. Trims along singular 00734 // sides and trims that correspond to closed 3d edges 00735 // have m_vi[0] = m_vi[1]. Note that singular trims 00736 // and trims on the closed edge of a closed surface can 00737 // have an open 2d trimming curve and still have 00738 // m_vi[0] = m_vi[1]. 00739 int m_vi[2]; 00740 00741 // true if the 2d trim and 3d edge have opposite orientations. 00742 bool m_bRev3d; 00743 00744 TYPE m_type; 00745 ON_Surface::ISO m_iso; 00746 00747 // index of loop that uses this trim 00748 int m_li; 00749 00750 // The values in m_tolerance[] record the accuracy of 00751 // the parameter space trimming curves. 00752 // 00753 // Remarks: 00754 // m_tolerance[0] = accuracy of parameter space curve 00755 // in first ( "u" ) parameter 00756 // 00757 // m_tolerance[1] = accuracy of parameter space curve 00758 // in second ( "v" ) parameter 00759 // 00760 // A value of ON_UNSET_VALUE indicates that the 00761 // tolerance should be computed. If the value >= 0.0, 00762 // then the tolerance is set. If the value is 00763 // ON_UNSET_VALUE, then the tolrance needs to be 00764 // computed. 00765 // 00766 // If the trim is not singular, then the trim must 00767 // have an edge. If P is a 3d point on the edge's 00768 // curve and surface(u,v) = Q is the point on the 00769 // surface that is closest to P, then there must 00770 // be a parameter t in the interval [m_t[0], m_t[1]] 00771 // such that 00772 // 00773 // |u - curve2d(t)[0]| <= m_tolerance[0] 00774 // 00775 // and 00776 // 00777 // |v - curve2d(t)[1]| <= m_tolerance[1] 00778 // 00779 // If P is the 3d point for the vertex brep.m_V[m_vi[k]] 00780 // and (uk,vk) is the corresponding end of the trim's 00781 // parameter space curve, then there must be a surface 00782 // parameter (u,v) such that: 00783 // 00784 // * the distance from the 3d point surface(u,v) to P 00785 // is <= brep.m_V[m_vi[k]].m_tolerance, 00786 // * |u-uk| <= m_tolerance[0]. 00787 // * |v-vk| <= m_tolerance[1]. 00788 double m_tolerance[2]; 00789 00790 // Runtime polyline approximation of trimming curve. 00791 // This information is not saved in 3DM archives. 00792 ON_SimpleArray<ON_BrepTrimPoint> m_pline; 00793 00794 /* 00795 Description: 00796 When an edge is modified, the m_pline[].e values need 00797 to be set to ON_UNSET_VALUE by calling UnsetPlineEdgeParameters(). 00798 */ 00799 void UnsetPlineEdgeParameters(); 00800 00801 // Runtime parameter space trimming curve bounding box. 00802 // This information is not saved in 3DM archives. 00803 ON_BoundingBox m_pbox; 00804 00805 public: 00806 // values stored in legacy file formats - ignore 00807 00808 void m__legacy_flags_Set(int,int); // used internally - ignore 00809 bool m__legacy_flags_Get(int*,int*) const; // used internally - ignore 00810 double m__legacy_2d_tol; // used internally - ignore 00811 double m__legacy_3d_tol; // used internally - ignore 00812 int m__legacy_flags; // used internally - ignore 00813 00814 private: 00815 friend class ON_Brep; 00816 ON_Brep* m_brep; // so isolated edge class edge can get at it's 3d curve 00817 ON_BrepTrim( const ON_BrepTrim& ); // no implementation 00818 }; 00819 00820 class ON_CLASS ON_BrepLoop : public ON_Geometry 00821 { 00822 ON_OBJECT_DECLARE(ON_BrepLoop); 00823 00824 public: 00825 void DestroyRuntimeCache( bool bDelete = true ); 00826 00827 // virtual ON_Geometry overrides 00828 // A loop is derived from ON_Geometry so that is can 00829 // be passed around to things that expect ON_Geometry 00830 // pointers. It is not a very useful stand-alone object. 00831 00832 /* 00833 Description: 00834 virtual ON_Geometry::Dimension() override. 00835 Returns: 00836 2 00837 */ 00838 int Dimension() const; 00839 00840 // virtual ON_Geometry::GetBBox() override. 00841 ON_BOOL32 GetBBox( 00842 double* boxmin, 00843 double* boxmax, 00844 int bGrowBox = false 00845 ) const; 00846 00847 // virtual ON_Geometry::Transform() override. 00848 ON_BOOL32 Transform( 00849 const ON_Xform& xform 00850 ); 00851 public: 00852 /* 00853 Returns: 00854 Brep that the loop belongs to. 00855 */ 00856 ON_Brep* Brep() const; 00857 00858 /* 00859 Returns: 00860 Brep face this loop belongs to. 00861 */ 00862 ON_BrepFace* Face() const; 00863 00864 /* 00865 Parameters: 00866 lti - [in] index into the loop's m_ti[] array. 00867 Returns: 00868 The trim brep.m_T[loop.m_ti[lti]]; 00869 */ 00870 ON_BrepTrim* Trim( int lti ) const; 00871 00872 /* 00873 Returns: 00874 Number of trims in this loop. 00875 */ 00876 int TrimCount() const; 00877 00878 // Union available for application use. 00879 // The constructor zeros m_loop_user. 00880 // The value is of m_loop_user is not saved in 3DM 00881 // archives and may be changed by some computations. 00882 ON_U m_loop_user; 00883 00884 int m_loop_index; // index of loop in ON_Brep.m_L[] array 00885 00886 enum TYPE { 00887 unknown = 0, 00888 outer = 1, // 2d loop curves form a simple closed curve with a counterclockwise orientation 00889 inner = 2, // 2d loop curves form a simple closed curve with a clockwise orientation 00890 slit = 3, // always closed - used internally during splitting operations 00891 crvonsrf = 4, // "loop" is a curveonsrf made from a single 00892 // (open or closed) trim that is has type ON_BrepTrim::crvonsrf. 00893 ptonsrf = 5, // "loop" is a ptonsrf made from a single 00894 // trim that is has type ON_BrepTrim::ptonsrf. 00895 type_count = 6 00896 }; 00897 00898 ON_BrepLoop(); 00899 ON_BrepLoop(int); // loop index 00900 ON_BrepLoop& operator=(const ON_BrepLoop&); 00901 00903 // ON_Object overrides 00904 // 00905 // (Loops and trims are purely topologicial - geometry queries should be 00906 // directed at the trim's 2d curve or the trim's edge's 3d curve.) 00907 00908 // virtual ON_Object::SizeOf override 00909 unsigned int SizeOf() const; 00910 00911 /* 00912 Description: 00913 Tests an object to see if its data members are correctly 00914 initialized. 00915 Parameters: 00916 text_log - [in] if the object is not valid and text_log 00917 is not NULL, then a brief englis description of the 00918 reason the object is not valid is appened to the log. 00919 The information appended to text_log is suitable for 00920 low-level debugging purposes by programmers and is 00921 not intended to be useful as a high level user 00922 interface tool. 00923 Returns: 00924 @untitled table 00925 true object is valid 00926 false object is invalid, uninitialized, etc. 00927 Remarks: 00928 Overrides virtual ON_Object::IsValid 00929 */ 00930 ON_BOOL32 IsValid( ON_TextLog* text_log = NULL ) const; 00931 00932 void Dump( ON_TextLog& ) const; // for debugging 00933 00934 ON_BOOL32 Write( ON_BinaryArchive& ) const; 00935 00936 ON_BOOL32 Read( ON_BinaryArchive& ); 00937 00938 // virtual ON_Geometry::ComponentIndex() override 00939 ON_COMPONENT_INDEX ComponentIndex() const; 00940 00942 // Interface 00943 00945 // Returns the index i such that loop.m_ti[i] = trim.m_trim_index. 00946 // Returns -1 if the trim is not in this loop 00947 int IndexOfTrim( const ON_BrepTrim& ) const; 00948 00949 /* 00950 Returns: 00951 brep.m_S[] surface index of the 3d surface geometry used by 00952 this loop or -1. 00953 */ 00954 int SurfaceIndexOf() const; 00955 00956 /* 00957 Returns: 00958 Pointer to the surface geometry used by the loop. 00959 */ 00960 const ON_Surface* SurfaceOf() const; 00961 00962 /* 00963 Description: 00964 Expert user tool that tranforms all the parameter space (2d) 00965 trimming curves in this loop. Only 2d curve geometry is 00966 changed. The caller is responsible for reversing loops, 00967 toggle m_bRev, flags, etc. 00968 Parameters: 00969 xform - [in] Transformation applied to 2d curve geometry. 00970 Returns 00971 True if successful. If false is returned, the brep 00972 may be invalid. 00973 */ 00974 bool TransformTrim( const ON_Xform& xform ); 00975 00976 ON_SimpleArray<int> m_ti; // trim indices 00977 TYPE m_type; 00978 int m_fi; // index of face that uses this loop 00979 00981 // parameter space trimming loop bounding box 00982 // runtime information - not saved 00983 ON_BoundingBox m_pbox; 00984 private: 00985 friend class ON_Brep; 00986 ON_Brep* m_brep; 00987 ON_BrepLoop(const ON_BrepLoop&); // no implementation 00988 }; 00989 00990 class ON_CLASS ON_BrepFace : public ON_SurfaceProxy 00991 { 00992 ON_OBJECT_DECLARE(ON_BrepFace); 00993 00994 public: 00995 void DestroyRuntimeCache( bool bDelete = true ); 00996 00997 // Union available for application use. 00998 // The constructor zeros m_face_user. 00999 // The value is of m_face_user is not saved in 3DM 01000 // archives and may be changed by some computations. 01001 ON_U m_face_user; 01002 01003 int m_face_index; // index of face in ON_Brep.m_F[] array 01004 01005 ON_BrepFace(); 01006 ~ON_BrepFace(); 01007 ON_BrepFace(int); 01008 ON_BrepFace& operator=(const ON_BrepFace&); 01009 01010 /* 01011 Returns: 01012 Brep that the face belongs to. 01013 */ 01014 ON_Brep* Brep() const; 01015 01016 /* 01017 Parameters: 01018 fli - [in] index into the face's m_li[] array. 01019 Returns: 01020 The loop brep.m_L[face.m_li[fli]]; 01021 */ 01022 ON_BrepLoop* Loop( int fli ) const; 01023 01024 /* 01025 Returns: 01026 Number of loops in this face. 01027 */ 01028 int LoopCount() const; 01029 01030 /* 01031 Returns: 01032 Outer boundary loop for this face. 01033 */ 01034 ON_BrepLoop* OuterLoop() const; 01035 01036 /* 01037 Parameters: 01038 dir 01039 1: side with underlying surface normal 01040 pointing into the topology region 01041 -1: side with underlying surface normal 01042 pointing out of the topology region 01043 Returns: 01044 Brep region topology face side. If the region 01045 topology has not be created by calling 01046 ON_Brep::RegionToplogy(), then NULL is returned. 01047 */ 01048 class ON_BrepFaceSide* FaceSide(int dir) const; 01049 01050 01052 // ON_Object overrides 01053 // 01054 // (Faces are purely topologicial - geometry queries should be 01055 // directed at the face's 3d surface.) 01056 01057 // virtual ON_Object::SizeOf override 01058 unsigned int SizeOf() const; 01059 01060 // virtual ON_Object::DataCRC override 01061 ON__UINT32 DataCRC(ON__UINT32 current_remainder) const; 01062 01063 /* 01064 Description: 01065 Tests an object to see if its data members are correctly 01066 initialized. 01067 Parameters: 01068 text_log - [in] if the object is not valid and text_log 01069 is not NULL, then a brief englis description of the 01070 reason the object is not valid is appened to the log. 01071 The information appended to text_log is suitable for 01072 low-level debugging purposes by programmers and is 01073 not intended to be useful as a high level user 01074 interface tool. 01075 Returns: 01076 @untitled table 01077 true object is valid 01078 false object is invalid, uninitialized, etc. 01079 Remarks: 01080 Overrides virtual ON_Object::IsValid 01081 */ 01082 ON_BOOL32 IsValid( ON_TextLog* text_log = NULL ) const; 01083 01084 void Dump( ON_TextLog& ) const; // for debugging 01085 01086 ON_BOOL32 Write( ON_BinaryArchive& ) const; 01087 01088 ON_BOOL32 Read( ON_BinaryArchive& ); 01089 01090 // virtual ON_Geometry::ComponentIndex() override 01091 ON_COMPONENT_INDEX ComponentIndex() const; 01092 01093 // virtual ON_Geometry::ClearBoundingBox() override 01094 void ClearBoundingBox(); 01095 01096 // virtual ON_Geometry::GetBBox() override 01097 ON_BOOL32 GetBBox( // returns true if successful 01098 double*, // minimum 01099 double*, // maximum 01100 ON_BOOL32 = false // true means grow box 01101 ) const; 01102 01103 /* 01104 Description: 01105 This is an override of the virtual ON_Surface::Reverse 01106 function. It toggles the face's m_bRev flag so the abstract 01107 orientation of the face does not change. 01108 Parameters: 01109 dir - [in] 0 = reverse "s" parameter, 1 = reverse "t" parameter 01110 The domain changes from [a,b] to [-a,-b] 01111 Returns: 01112 True if successful. 01113 Remarks: 01114 The range of the face's trimming curves and the orientation direction 01115 of then loops are changed so that the resulting face is still valid. 01116 */ 01117 ON_BOOL32 Reverse( 01118 int dir 01119 ); 01120 01121 /* 01122 Description: 01123 This is an override of the virtual ON_Surface::Transpose 01124 function. It toggles the face's m_bRev flag so the abstract 01125 orientation of the face does not change. 01126 Returns: 01127 True if successful. 01128 Remarks: 01129 The range of the face's trimming curves and the orientation direction 01130 of then loops are changed so that the resulting face is still valid. 01131 */ 01132 ON_BOOL32 Transpose(); 01133 01134 /* 01135 Description: 01136 This is an override of the virtual ON_Surface::SetDomain 01137 function. 01138 Parameters: 01139 dir - [in] 0 = set "u" domain, 1 = set "v" domain. 01140 t0 - [in] 01141 t1 - [in] t0 < t1 The new domain is the interval (t0,t1) 01142 Returns: 01143 True if successful. 01144 */ 01145 ON_BOOL32 SetDomain( 01146 int dir, 01147 double t0, 01148 double t1 01149 ); 01150 01151 /* 01153 // Change the domain of a face 01154 // This changes the parameterization of the face's surface and transforms 01155 // the "u" and "v" coordinates of all the face's parameter space trimming 01156 // curves. The locus of the face is not changed. 01157 */ 01158 bool SetDomain( 01159 ON_Interval udom, 01160 ON_Interval vdom 01161 ); 01162 01164 // Rendering Interface 01165 //int MaterialIndex() const; // if -1, use parent's material definition 01166 //void SetMaterialIndex(int); 01167 01168 // If true is returne, then ~ON_BrepFace will delete mesh. 01169 bool SetMesh( ON::mesh_type, ON_Mesh* mesh ); 01170 01171 const ON_Mesh* Mesh( ON::mesh_type mesh_type ) const; 01172 01173 /* 01174 Description: 01175 Destroy meshes used to render and analyze surface and polysrf 01176 objects. 01177 Parameters: 01178 mesh_type - [in] type of mesh to destroy 01179 bDeleteMesh - [in] if true, cached mesh is deleted. 01180 If false, pointer to cached mesh is just set to NULL. 01181 See Also: 01182 CRhinoObject::GetMeshes 01183 CRhinoObject::MeshCount 01184 CRhinoObject::IsMeshable 01185 */ 01186 void DestroyMesh( ON::mesh_type mesh_type, bool bDeleteMesh = true ); 01187 01189 // "Expert" Interface 01190 01191 /* 01192 Description: 01193 Expert user tool that tranforms all the parameter space (2d) 01194 trimming curves on this face. Only 2d curve geometry is 01195 changed. The caller is responsible for reversing loops, 01196 toggle m_bRev, flags, etc. 01197 Parameters: 01198 xform - [in] Transformation applied to 2d curve geometry. 01199 Returns 01200 True if successful. If false is returned, the brep 01201 may be invalid. 01202 */ 01203 bool TransformTrim( const ON_Xform& xform ); 01204 01205 /* 01206 Description: 01207 Expert user tool that replaces the 3d surface geometry 01208 use by the face. 01209 Parameters; 01210 si - [in] brep surface index of new surface 01211 bTransformTrimCurves - [in] 01212 If unsure, then pass true. 01213 If the surface's domain has changed and you are certain 01214 its parameterization still jibes with the trim curve 01215 locations, then pass false. 01216 Returns: 01217 True if successful. 01218 Example: 01219 01220 ON_Surface* pSurface = ...; 01221 int si = brep.AddSurface(pSurface); 01222 face.ChangeSurface(si); 01223 01224 Remarks: 01225 If the face had a surface and new surface has a different 01226 shape, then you probably want to call something like 01227 ON_Brep::RebuildEdges() to move the 3d edge curves so they 01228 will lie on the new surface. This doesn't delete the old 01229 surface; call ON_Brep::CullUnusedSurfaces() or ON_Brep::Compact 01230 to remove unused surfaces. 01231 See Also: 01232 ON_Brep::RebuildEdges 01233 ON_Brep::CullUnusedSurfaces 01234 */ 01235 bool ChangeSurface( 01236 int si 01237 ); 01238 bool ChangeSurface( 01239 int si, 01240 bool bTransformTrimCurves 01241 ); 01242 01243 /* 01244 Returns: 01245 brep.m_S[] surface index of the 3d surface geometry used by 01246 this face or -1. 01247 */ 01248 int SurfaceIndexOf() const; 01249 01250 /* 01251 Returns: 01252 Pointer to the surface geometry used by the face. 01253 */ 01254 const ON_Surface* SurfaceOf() const; 01255 01256 ON_SimpleArray<int> m_li; // loop indices (outer loop is m_li[0]) 01257 int m_si; // index of surface in b-rep m_S[] array 01258 bool m_bRev; // true if face orientation is opposite 01259 // of natural surface orientation 01260 01261 // m_face_material_channel provides a way to have individual 01262 // brep faces use a rendering material that is different 01263 // from the rendering material used by the parent brep. 01264 // If m_face_material_channel is zero 01265 // channel and m_face_material_channel.m_j is the back face 01266 // materal. The default is (0,0) which indicates the face 01267 // should use the parent brep's material. 01268 // If "mat" is the brep's rendering material and 01269 // 0 < m_material_channel.m_i < mat.m_material_channel.Count(), 01270 // then this face should use the material with id 01271 // mat.m_material_channel[face.m_material_channel.m_i-1].m_id. 01272 // If m_material_channel.m_i or the id is invalid in any way, 01273 // then the default should be used. 01274 int m_face_material_channel; 01275 01276 // Persistent id for this face. Default is ON_nil_uuid. 01277 ON_UUID m_face_uuid; 01278 private: 01279 ON_BoundingBox m_bbox; // 3d bounding box 01280 ON_Interval m_domain[2]; // rectangular bounds of 2d curves 01281 ON_Mesh* m_render_mesh; 01282 ON_Mesh* m_analysis_mesh; 01283 ON_Mesh* m_preview_mesh; 01284 //int m_material_index; // if 0 (default), ON_Brep's object attributes 01285 // // determine material. 01286 private: 01287 friend class ON_Brep; 01288 ON_Brep* m_brep; 01289 ON_BrepFace( const ON_BrepFace& ); 01290 }; 01291 01292 class ON_CLASS ON_BrepFaceSide : public ON_Object 01293 { 01294 ON_OBJECT_DECLARE(ON_BrepFaceSide); 01295 public: 01296 ON_BOOL32 IsValid( ON_TextLog* text_log = NULL ) const; 01297 01298 // Union available for application use. 01299 // The constructor zeros m_faceside_user. 01300 // The value is of m_faceside_user is not saved in 3DM 01301 // archives and may be changed by some computations. 01302 ON_U m_faceside_user; 01303 01304 // index of face side in ON_BrepRegionTopology.m_FS[] array 01305 int m_faceside_index; 01306 01307 ON_BrepFaceSide(); 01308 ~ON_BrepFaceSide(); 01309 ON_BrepFaceSide& operator=(const ON_BrepFaceSide&); 01310 01311 ON_BOOL32 Write(ON_BinaryArchive& binary_archive) const; 01312 ON_BOOL32 Read(ON_BinaryArchive& binary_archive); 01313 01314 01315 /* 01316 Returns: 01317 Brep this face side belongs to. 01318 */ 01319 ON_Brep* Brep() const; 01320 01321 /* 01322 Returns: 01323 Region topology this face side belongs to. 01324 */ 01325 class ON_BrepRegionTopology* RegionTopology() const; 01326 01327 /* 01328 Returns: 01329 Region the face side belongs to. 01330 */ 01331 class ON_BrepRegion* Region() const; 01332 01333 /* 01334 Returns: 01335 Face this side belongs to. 01336 */ 01337 class ON_BrepFace* Face() const; 01338 01339 /* 01340 Returns: 01341 +1: underlying geometric surface normal points 01342 into region. 01343 -1: underlying geometric surface normal points 01344 out of region. 01345 */ 01346 int SurfaceNormalDirection() const; 01347 01348 public: 01349 int m_ri; // region index 01350 // m_ri = -1 indicates this faceside overlaps 01351 // another faceside. Generally this is a flaw 01352 // in an ON_Brep. 01353 int m_fi; // face index 01354 int m_srf_dir; // 1 ON_BrepFace's surface normal points into region 01355 // -1 ON_BrepFace's surface normal points out of region 01356 01357 private: 01358 friend class ON_Brep; 01359 friend class ON_BrepRegionTopology; 01360 ON_BrepRegionTopology* m_rtop; 01361 ON_BrepFaceSide( const ON_BrepFaceSide& ); 01362 }; 01363 01364 class ON_CLASS ON_BrepRegion : public ON_Object 01365 { 01366 ON_OBJECT_DECLARE(ON_BrepRegion); 01367 public: 01368 ON_BOOL32 IsValid( ON_TextLog* text_log = NULL ) const; 01369 01370 // Union available for application use. 01371 // The constructor zeros m_region_user. 01372 // The value is of m_region_user is not saved in 3DM 01373 // archives and may be changed by some computations. 01374 ON_U m_region_user; 01375 01376 // index of region in ON_BrepRegionTopology.m_R[] array 01377 int m_region_index; 01378 01379 ON_BrepRegion(); 01380 ~ON_BrepRegion(); 01381 ON_BrepRegion& operator=(const ON_BrepRegion&); 01382 01383 ON_BOOL32 Write(ON_BinaryArchive& binary_archive) const; 01384 ON_BOOL32 Read(ON_BinaryArchive& binary_archive); 01385 01386 /* 01387 Returns: 01388 Brep this region belongs to. 01389 */ 01390 ON_Brep* Brep() const; 01391 01392 /* 01393 Returns: 01394 Region topology this region belongs to. 01395 */ 01396 class ON_BrepRegionTopology* RegionTopology() const; 01397 01398 /* 01399 Parameter: 01400 rfsi - [in] index into the region's m_fsi[] array. 01401 Returns: 01402 The face side in rtop.m_FS[m_fsi[rsi]], where 01403 rtop is the ON_BrepRegionTopology class this 01404 region belongs to. 01405 */ 01406 ON_BrepFaceSide* FaceSide(int rfsi) const; 01407 01408 /* 01409 Returns: 01410 True if the region is finite. 01411 */ 01412 bool IsFinite() const; 01413 01414 /* 01415 Returns: 01416 Region bounding box. 01417 */ 01418 const ON_BoundingBox& BoundingBox() const; 01419 01420 ON_SimpleArray<int> m_fsi; // indices of face sides 01421 int m_type; // 0 = infinte, 1 = bounded 01422 ON_BoundingBox m_bbox; 01423 01424 /* 01425 Description: 01426 Get the boundary of a region as a brep object. 01427 If the region is finite, the boundary will be a closed 01428 manifold brep. The boundary may have more than one 01429 connected component. 01430 Parameters: 01431 brep - [in] if not NULL, the brep form is put into 01432 this brep. 01433 Returns: the region boundary as a brep or NULL if the 01434 calculation fails. 01435 */ 01436 ON_Brep* RegionBoundaryBrep( ON_Brep* brep = NULL ) const; 01437 01438 private: 01439 friend class ON_Brep; 01440 friend class ON_BrepRegionTopology; 01441 ON_BrepRegionTopology* m_rtop; 01442 ON_BrepRegion( const ON_BrepRegion& ); 01443 }; 01444 01445 #if defined(ON_DLL_TEMPLATE) 01446 // This stuff is here because of a limitation in the way Microsoft 01447 // handles templates and DLLs. See Microsoft's knowledge base 01448 // article ID Q168958 for details. 01449 #pragma warning( push ) 01450 #pragma warning( disable : 4231 ) 01451 ON_DLL_TEMPLATE template class ON_CLASS ON_ClassArray<ON_BrepVertex>; 01452 ON_DLL_TEMPLATE template class ON_CLASS ON_ObjectArray<ON_BrepVertex>; 01453 ON_DLL_TEMPLATE template class ON_CLASS ON_ClassArray<ON_BrepEdge>; 01454 ON_DLL_TEMPLATE template class ON_CLASS ON_ObjectArray<ON_BrepEdge>; 01455 ON_DLL_TEMPLATE template class ON_CLASS ON_ClassArray<ON_BrepTrim>; 01456 ON_DLL_TEMPLATE template class ON_CLASS ON_ObjectArray<ON_BrepTrim>; 01457 ON_DLL_TEMPLATE template class ON_CLASS ON_ClassArray<ON_BrepLoop>; 01458 ON_DLL_TEMPLATE template class ON_CLASS ON_ObjectArray<ON_BrepLoop>; 01459 ON_DLL_TEMPLATE template class ON_CLASS ON_ClassArray<ON_BrepFace>; 01460 ON_DLL_TEMPLATE template class ON_CLASS ON_ObjectArray<ON_BrepFace>; 01461 ON_DLL_TEMPLATE template class ON_CLASS ON_ObjectArray<ON_BrepFaceSide>; 01462 ON_DLL_TEMPLATE template class ON_CLASS ON_ObjectArray<ON_BrepRegion>; 01463 #pragma warning( pop ) 01464 #endif 01465 01466 class ON_CLASS ON_BrepVertexArray : public ON_ObjectArray<ON_BrepVertex> 01467 { 01468 public: 01469 ON_BrepVertexArray(); 01470 ~ON_BrepVertexArray(); 01471 01472 ON_BOOL32 Read( ON_BinaryArchive& ); 01473 ON_BOOL32 Write( ON_BinaryArchive& ) const; 01474 01475 unsigned int SizeOf() const; 01476 }; 01477 01478 class ON_CLASS ON_BrepEdgeArray : public ON_ObjectArray<ON_BrepEdge> 01479 { 01480 public: 01481 ON_BrepEdgeArray(); 01482 ~ON_BrepEdgeArray(); 01483 ON_BOOL32 Read( ON_BinaryArchive& ); 01484 ON_BOOL32 Write( ON_BinaryArchive& ) const; 01485 01486 unsigned int SizeOf() const; 01487 }; 01488 01489 class ON_CLASS ON_BrepTrimArray : public ON_ObjectArray<ON_BrepTrim> 01490 { 01491 public: 01492 ON_BrepTrimArray(); 01493 ~ON_BrepTrimArray(); 01494 ON_BOOL32 Read( ON_BinaryArchive& ); 01495 ON_BOOL32 Write( ON_BinaryArchive& ) const; 01496 01497 unsigned int SizeOf() const; 01498 }; 01499 01500 class ON_CLASS ON_BrepLoopArray : public ON_ObjectArray<ON_BrepLoop> 01501 { 01502 public: 01503 ON_BrepLoopArray(); 01504 ~ON_BrepLoopArray(); 01505 ON_BOOL32 Read( ON_BinaryArchive& ); 01506 ON_BOOL32 Write( ON_BinaryArchive& ) const; 01507 01508 unsigned int SizeOf() const; 01509 }; 01510 01511 class ON_CLASS ON_BrepFaceArray : public ON_ObjectArray<ON_BrepFace> 01512 { 01513 public: 01514 ON_BrepFaceArray(); 01515 ~ON_BrepFaceArray(); 01516 ON_BOOL32 Read( ON_BinaryArchive& ); 01517 ON_BOOL32 Write( ON_BinaryArchive& ) const; 01518 01519 unsigned int SizeOf() const; 01520 }; 01521 01522 class ON_CLASS ON_BrepFaceSideArray : public ON_ObjectArray<ON_BrepFaceSide> 01523 { 01524 public: 01525 ON_BrepFaceSideArray(); 01526 ~ON_BrepFaceSideArray(); 01527 01528 bool Read( ON_BinaryArchive& ); 01529 bool Write( ON_BinaryArchive& ) const; 01530 01531 unsigned int SizeOf() const; 01532 }; 01533 01534 class ON_CLASS ON_BrepRegionArray : public ON_ObjectArray<ON_BrepRegion> 01535 { 01536 public: 01537 ON_BrepRegionArray(); 01538 ~ON_BrepRegionArray(); 01539 01540 bool Read( ON_BinaryArchive& ); 01541 bool Write( ON_BinaryArchive& ) const; 01542 01543 unsigned int SizeOf() const; 01544 }; 01545 01546 class ON_CLASS ON_BrepRegionTopology 01547 { 01548 public: 01549 ON_BrepRegionTopology(); 01550 ON_BrepRegionTopology(const ON_BrepRegionTopology& src); 01551 ~ON_BrepRegionTopology(); 01552 ON_BrepRegionTopology& operator=(const ON_BrepRegionTopology&); 01553 01554 ON_BrepFaceSideArray m_FS; 01555 ON_BrepRegionArray m_R; 01556 01557 ON_Brep* Brep() const; 01558 bool IsValid( ON_TextLog* text_log = 0 ) const; 01559 bool Read( ON_BinaryArchive& ); 01560 bool Write( ON_BinaryArchive& ) const; 01561 01562 unsigned int SizeOf() const; 01563 01564 private: 01565 friend class ON_BrepRegionTopologyUserData; 01566 friend class ON_Brep; 01567 ON_Brep* m_brep; 01568 }; 01569 01570 class ON_CLASS ON_Brep : public ON_Geometry 01571 { 01572 ON_OBJECT_DECLARE(ON_Brep); 01573 01574 public: 01575 // virtual ON_Object::DestroyRuntimeCache override 01576 void DestroyRuntimeCache( bool bDelete = true ); 01577 01578 // virtual ON_Object::SizeOf override 01579 unsigned int SizeOf() const; 01580 01581 // virtual ON_Object::DataCRC override 01582 ON__UINT32 DataCRC(ON__UINT32 current_remainder) const; 01583 01584 // virtual ON_Geometry override 01585 bool EvaluatePoint( const class ON_ObjRef& objref, ON_3dPoint& P ) const; 01586 01587 public: 01588 01589 01590 /* 01591 Description: 01592 Use ON_Brep::New() instead of new ON_Brep() when writing 01593 Rhino plug-ins (or when openNURBS is used as a Microsoft 01594 DLL and you need to create a new ON_Brep in a different 01595 .EXE or .DLL). 01596 Example: 01597 01598 // bad - ON_Brep* pBrep = new ON_Brep(); 01599 ON_Brep* pBrep = ON_Brep::New(); // good 01600 ... 01601 delete pBrep; 01602 pBrep = NULL; 01603 01604 Returns: 01605 Pointer to an ON_Brep. Destroy by calling delete. 01606 Remarks: 01607 When openNURBS is used as a Microsoft DLL, the CL.EXE 01608 compiler uses local vtables for classes that are new-ed 01609 in other executables but uses the ordinary vtable for 01610 for classes that are allocated in functions like 01611 ON_BrepCylinder(), ON_NurbsSurfaceQuadrilateral(), 01612 ON_Cylinder::RevSurfaceForm(NULL), etc. 01613 Using static New() functions like ON_Brep::New() insures 01614 that identical classes has the same vtable and makes 01615 all code run identically. 01616 */ 01617 static ON_Brep* New(); 01618 01619 /* 01620 Description: 01621 Use ON_Brep::New(const ON_Brep& src) instead 01622 of new ON_Brep(const ON_Brep& src). 01623 Returns: 01624 Pointer to an ON_Brep. Destroy by calling delete. 01625 Remarks: 01626 See static ON_Brep* ON_Brep::New() for details. 01627 */ 01628 static ON_Brep* New(const ON_Brep&); 01629 01630 // Construction 01631 ON_Brep(); 01632 ~ON_Brep(); 01633 ON_Brep(const ON_Brep&); 01634 ON_Brep& operator=(const ON_Brep&); 01635 01636 // Override of virtual ON_Object::MemoryRelocate 01637 void MemoryRelocate(); 01638 01639 01640 /* 01641 Description: 01642 See if this and other are same brep geometry. 01643 Parameters: 01644 other - [in] other brep 01645 tolerance - [in] tolerance to use when comparing 01646 control points. 01647 Returns: 01648 true if breps are the same 01649 */ 01650 bool IsDuplicate( 01651 const ON_Brep& other, 01652 double tolerance = ON_ZERO_TOLERANCE 01653 ) const; 01654 01656 // construction/destruction helpers 01657 01658 // returns Brep to state it has after default construction 01659 void Destroy(); 01660 01661 // call if memory pool used by b-rep members becomes invalid 01662 void EmergencyDestroy(); 01663 01664 /* 01665 Description: 01666 Calculates polygon mesh approximation of the brep 01667 and appends one mesh for each face to the mesh_list[] 01668 array. 01669 Parameters: 01670 mp - [in] meshing parameters 01671 mesh_list - [out] meshes are appended to this array. 01672 Returns: 01673 Number of meshes appended to mesh_list[] array. 01674 */ 01675 int CreateMesh( 01676 const ON_MeshParameters& mp, 01677 ON_SimpleArray<ON_Mesh*>& mesh_list 01678 ) const; 01679 01680 /* 01681 Description: 01682 Destroy meshes used to render and analyze brep. 01683 Parameters: 01684 mesh_type - [in] type of mesh to destroy 01685 bDeleteMesh - [in] if true, cached meshes are deleted. 01686 If false, pointers to cached meshes are just set to NULL. 01687 See Also: 01688 ON_Brep::GetMesh 01689 ON_BrepFace::DestroyMesh 01690 ON_BrepFace::Mesh 01691 ON_BrepFace::SetMesh 01692 */ 01693 void DestroyMesh( ON::mesh_type mesh_type, bool bDeleteMesh = true ); 01694 01695 /* 01696 Description: 01697 Get cached meshes used to render and analyze brep. 01698 Parameters: 01699 mesh_type - [in] type of mesh to get 01700 meshes - [out] meshes are appended to this array. The ON_Brep 01701 owns these meshes so they cannot be modified. 01702 Returns: 01703 Number of meshes added to array. (Same as m_F.Count()) 01704 See Also: 01705 ON_Brep::DestroyMesh 01706 ON_BrepFace::DestroyMesh 01707 ON_BrepFace::Mesh 01708 ON_BrepFace::SetMesh 01709 */ 01710 int GetMesh( ON::mesh_type mesh_type, ON_SimpleArray< const ON_Mesh* >& meshes ) const; 01711 01712 /* 01713 Description: 01714 Create a brep from a surface. The resulting surface has an outer 01715 boundary made from four trims. The trims are ordered so that 01716 they run along the south, east, north, and then west side of the 01717 surface's parameter space. 01718 Parameters: 01719 pSurface - [in] pointer to a surface. The brep will manage this 01720 pointer and delete it in ~ON_Brep. 01721 Returns: 01722 @untitled table 01723 true successful 01724 When true is returned, the pSurface pointer is added to the 01725 brep's m_S[] array and it will be deleted by the brep's 01726 destructor. 01727 false 01728 brep cannot be created from this surface. 01729 When false is returned, then the caller is responsible 01730 for deleting pSurface unless it was previously added 01731 to the brep's m_S[] array. 01732 Remarks: 01733 The surface class must be created with new so that the 01734 delete in ~ON_Brep will not cause a crash. 01735 */ 01736 bool Create( 01737 ON_Surface*& pSurface 01738 ); 01739 01740 bool Create( 01741 ON_NurbsSurface*& pNurbsSurface 01742 ); 01743 01744 bool Create( 01745 ON_PlaneSurface*& pPlaneSurface 01746 ); 01747 01748 bool Create( 01749 ON_RevSurface*& pRevSurface 01750 ); 01751 01752 bool Create( 01753 ON_SumSurface*& pSumSurface 01754 ); 01755 01756 /* 01757 Description: 01758 Tests an object to see if its data members are correctly 01759 initialized. 01760 Parameters: 01761 text_log - [in] if the object is not valid and text_log 01762 is not NULL, then a brief englis description of the 01763 reason the object is not valid is appened to the log. 01764 The information appended to text_log is suitable for 01765 low-level debugging purposes by programmers and is 01766 not intended to be useful as a high level user 01767 interface tool. 01768 Returns: 01769 @untitled table 01770 true object is valid 01771 false object is invalid, uninitialized, etc. 01772 Remarks: 01773 Overrides virtual ON_Object::IsValid 01774 See Also: 01775 ON_Brep::SetTolerancesAndFlags 01776 */ 01777 ON_BOOL32 IsValid( ON_TextLog* text_log = NULL ) const; 01778 01779 /* 01780 Description: 01781 Tests the brep to see if its topology information is 01782 valid. 01783 Parameters: 01784 text_log - [in] if the brep topology is not valid and 01785 text_log is not NULL, then a brief english 01786 description of the problem is appended to the log. 01787 The information appended to text_log is suitable for 01788 low-level debugging purposes by programmers and is 01789 not intended to be useful as a high level user 01790 interface tool. 01791 Returns: 01792 @untitled table 01793 true brep topology is valid 01794 false brep topology is not valid 01795 Remarks: 01796 ON_Brep::IsValidTopology can be called at any time. 01797 See Also: 01798 ON_Brep::IsValid 01799 ON_Brep::IsValidGeometry 01800 ON_Brep::IsValidTolerancesAndFlags 01801 */ 01802 bool IsValidTopology( ON_TextLog* text_log = NULL ) const; 01803 01804 01805 /* 01806 Description: 01807 Expert user function that tests the brep to see if its 01808 geometry information is valid. The value of 01809 brep.IsValidTopology() must be true before 01810 brep.IsValidGeometry() can be safely called. 01811 Parameters: 01812 text_log - [in] if the brep geometry is not valid and 01813 text_log is not NULL, then a brief english 01814 description of the problem is appended to the log. 01815 The information appended to text_log is suitable for 01816 low-level debugging purposes by programmers and is 01817 not intended to be useful as a high level user 01818 interface tool. 01819 Returns: 01820 @untitled table 01821 true brep geometry is valid 01822 false brep geometry is not valid 01823 Remarks: 01824 ON_Brep::IsValidTopology must be true before you can 01825 safely call ON_Brep::IsValidGeometry. 01826 See Also: 01827 ON_Brep::IsValid 01828 ON_Brep::IsValidTopology 01829 ON_Brep::IsValidTolerancesAndFlags 01830 */ 01831 bool IsValidGeometry( ON_TextLog* text_log = NULL ) const; 01832 01833 /* 01834 Description: 01835 Expert user function that tests the brep to see if its 01836 tolerances and flags are valid. The values of 01837 brep.IsValidTopology() and brep.IsValidGeometry() must 01838 be true before brep.IsValidTolerancesAndFlags() can 01839 be safely called. 01840 Parameters: 01841 text_log - [in] if the brep tolerance or flags are not 01842 valid and text_log is not NULL, then a brief english 01843 description of the problem is appended to the log. 01844 The information appended to text_log is suitable for 01845 low-level debugging purposes by programmers and is 01846 not intended to be useful as a high level user 01847 interface tool. 01848 Returns: 01849 @untitled table 01850 true brep tolerance and flags are valid 01851 false brep tolerance and flags are not valid 01852 Remarks: 01853 ON_Brep::IsValidTopology and ON_Brep::IsValidGeometry 01854 must be true before you can safely call 01855 ON_Brep::IsValidTolerancesAndFlags. 01856 See Also: 01857 ON_Brep::IsValid 01858 ON_Brep::IsValidTopology 01859 ON_Brep::IsValidGeometry 01860 */ 01861 bool IsValidTolerancesAndFlags( ON_TextLog* text_log = NULL ) const; 01862 01863 // Description: 01864 // Tests brep to see if it is valid for 01865 // saving in V2 3DM archives. 01866 // Returns: 01867 // true if brep is valid for V2 3DM archives. 01868 // Remarks: 01869 // V2 breps could not have dangling curves. 01870 bool IsValidForV2() const; 01871 bool IsValidForV2( const ON_BrepTrim& ) const; 01872 bool IsValidForV2( const ON_BrepEdge& ) const; 01873 01874 // virtual ON_Objet::Dump() override 01875 void Dump( ON_TextLog& ) const; // for debugging 01876 01877 // virtual ON_Objet::Write() override 01878 ON_BOOL32 Write( ON_BinaryArchive& ) const; 01879 01880 // virtual ON_Objet::Read() override 01881 ON_BOOL32 Read( ON_BinaryArchive& ); 01882 01883 // virtual ON_Objet::ObjectType() override 01884 ON::object_type ObjectType() const; 01885 01886 // virtual ON_Geometry::Dimension() override 01887 int Dimension() const; 01888 01889 // virtual ON_Geometry::ClearBoundingBox() override 01890 void ClearBoundingBox(); 01891 01892 // virtual ON_Geometry::GetBBox() override 01893 ON_BOOL32 GetBBox( // returns true if successful 01894 double*, // minimum 01895 double*, // maximum 01896 ON_BOOL32 = false // true means grow box 01897 ) const; 01898 01899 // virtual ON_Geometry::Transform() override 01900 ON_BOOL32 Transform( 01901 const ON_Xform& 01902 ); 01903 01904 // virtual ON_Geometry::SwapCoordinates() override 01905 ON_BOOL32 SwapCoordinates( 01906 int, int // indices of coords to swap 01907 ); 01908 01909 // virtual ON_Geometry::HasBrepForm() override 01910 ON_BOOL32 HasBrepForm() const; // returns true 01911 01912 /* 01913 Description: 01914 If possible, BrepForm() creates a brep form of the 01915 ON_Geometry. 01916 Parameters: 01917 brep - [in] if not NULL, brep is used to store the brep 01918 form of the geometry. 01919 Result: 01920 If brep is not NULL, then brep = this, otherwise 01921 a duplicate of this is returned. 01922 Remarks: 01923 Override of virtual ON_Geometry::BrepForm 01924 */ 01925 ON_Brep* BrepForm( ON_Brep* brep = NULL ) const; 01926 01928 // Creation Interface 01929 01930 // These add a new geometry piece to the b-rep and return the 01931 // index that should be used to reference the geometry. 01932 // -1 is returned if the input is not acceptable. 01933 // ~ON_Brep() will delete the geometry. 01934 int AddTrimCurve( ON_Curve* ); // 2d curve used by ON_BrepTrim 01935 int AddEdgeCurve( ON_Curve* ); // 3d curve used by ON_BrepEdge 01936 int AddSurface( ON_Surface* ); // 3d surface used by ON_BrepFace 01937 01938 // Description: 01939 // Set 3d curve geometry used by a b-rep edge. 01940 // Parameters: 01941 // edge - [in] 01942 // c3_index - [in] index of 3d curve in m_C3[] array 01943 // sub_domain - [in] if not NULL, sub_domain is an increasing 01944 // sub interval of m_C3[c3_index]->Domain(). 01945 // Returns: 01946 // true if successful. 01947 bool SetEdgeCurve( 01948 ON_BrepEdge& edge, 01949 int c3_index, 01950 const ON_Interval* sub_domain = NULL 01951 ); 01952 01953 // Description: 01954 // Set 2d curve geometry used by a b-rep trim. 01955 // Parameters: 01956 // trim - [in] 01957 // c2_index - [in] index of 2d curve in m_C2[] array 01958 // sub_domain - [in] if not NULL, sub_domain is an increasing 01959 // sub interval of m_C2[c2_index]->Domain(). 01960 // Returns: 01961 // true if successful. 01962 bool SetTrimCurve( 01963 ON_BrepTrim& trim, 01964 int c2_index, 01965 const ON_Interval* sub_domain = NULL 01966 ); 01967 01968 // These add a new topology piece to the b-rep and return a 01969 // reference that is intended to be used for initialization. 01970 ON_BrepVertex& NewVertex(); 01971 ON_BrepVertex& NewVertex( 01972 ON_3dPoint vertex_point, 01973 double vertex_tolerance = ON_UNSET_VALUE 01974 ); 01975 01976 ON_BrepEdge& NewEdge( 01977 int = -1 // 3d curve index 01978 ); 01979 ON_BrepEdge& NewEdge( 01980 ON_BrepVertex&, // start vertex 01981 ON_BrepVertex&, // end vertex 01982 int = -1, // 3d curve index 01983 const ON_Interval* = NULL, // sub_domain 01984 double edge_tolerance = ON_UNSET_VALUE 01985 ); 01986 01987 /* 01988 Description: 01989 Add a new face to a brep. An incomplete face is added. 01990 The caller must create and fill in the loops used by 01991 the face. 01992 Parameters: 01993 si - [in] index of surface in brep's m_S[] array 01994 Returns: 01995 Reference to new face. 01996 Remarks: 01997 Adding a new face may grow the dynamic m_F array. When 01998 this happens pointers and references to memory in the 01999 previous m_F[] array may become invalid. Use face indices 02000 if this is an issue. 02001 Example: 02002 See ON_BrepBox and ON_BrepSphere source code. 02003 See Also: 02004 ON_Brep::AddSurface 02005 */ 02006 ON_BrepFace& NewFace( 02007 int si = -1 02008 ); 02009 02010 /* 02011 Description: 02012 Add a new face to a brep. This creates a complete face with 02013 new vertices at the surface corners, new edges along the surface 02014 boundary, etc. The loop of the returned face has four trims that 02015 correspond to the south, east, north, and west side of the 02016 surface in that order. If you use this version of NewFace to 02017 add an exiting brep, then you are responsible for using a tool 02018 like ON_Brep::JoinEdges() to hook the new face to its 02019 neighbors. 02020 Parameters: 02021 surface - [in] surface is copied. 02022 Returns: 02023 Pointer to new face. 02024 Remarks: 02025 Adding a new face may grow the dynamic arrays used to store 02026 vertices, edges, faces, loops, and trims. When these dyamic 02027 arrays are grown, any pointers and references to memory in 02028 the previous arrays may become invalid. Use indices 02029 if this is an issue. 02030 See Also: 02031 ON_Brep::JoinEdges 02032 ON_Brep::AddSurface 02033 */ 02034 ON_BrepFace* NewFace( 02035 const ON_Surface& surface 02036 ); 02037 02038 /* 02039 Description: 02040 Add a new face to brep. This version is for expert users. 02041 Parameters: 02042 pSurface - [in] the returned face will have an outer loop 02043 that goes around the edges of the surface. 02044 vid - [in/out] four vertex indices that specify the vertices at 02045 the (sw,se,nw,ne) corners. If the input value 02046 of a vertex index is -1, then the vertex will be 02047 created. 02048 eid - [in/out] four edge indices that specify the edges for 02049 the (south,east,north,west) sides. If the input value 02050 of an edge index is -1, then the edge will be created. 02051 bRev3d - [in/out] four values of the trim m_bRev3d flags of 02052 the (south,east,north,west) sides. 02053 Returns: 02054 Pointer to the new face or NULL if input is not valid. 02055 If null is returned, then the caller must delete pSurace 02056 unless it was previously added to the brep's m_S[] array. 02057 Remarks: 02058 Adding a new face may grow the dynamic m_F array. When 02059 this happens pointers and references to memory in the 02060 previous m_F[] array may become invalid. Use face indices 02061 if this is an issue. 02062 Example: 02063 See ON_BrepBox and ON_BrepSphere source code. 02064 See Also: 02065 ON_Brep::AddSurface 02066 ON_Brep::AddFace( int si ) 02067 ON_Brep::Create( ON_Surface*& ) 02068 */ 02069 ON_BrepFace* NewFace( 02070 ON_Surface* pSurface, 02071 int vid[4], 02072 int eid[4], 02073 ON_BOOL32 bRev3d[4] 02074 ); 02075 02076 /* 02077 Description: 02078 Add a new face to the brep whose surface geometry is a 02079 ruled surface between two edges. 02080 Parameters: 02081 edgeA - [in] The south side of the face's surface will 02082 run along edgeA. 02083 bRevEdgeA - [in] true if the new face's outer boundary 02084 orientation along edgeA is opposite the orientation 02085 of edgeA. 02086 edgeB - [in] The north side of the face's surface will 02087 run along edgeA. 02088 bRevEdgeB - [in] true if the new face's outer boundary 02089 orientation along edgeB is opposite the orientation 02090 of edgeB. 02091 Returns: 02092 A pointer to the new face or a NULL if the new face could 02093 not be created. 02094 */ 02095 ON_BrepFace* NewRuledFace( 02096 const ON_BrepEdge& edgeA, 02097 bool bRevEdgeA, 02098 const ON_BrepEdge& edgeB, 02099 bool bRevEdgeB 02100 ); 02101 02102 /* 02103 Description: 02104 Add a new face to the brep whose surface geometry is a 02105 ruled cone with the edge as the base and the vertex as 02106 the apex point. 02107 Parameters: 02108 vertex - [in] The apex of the cone will be at this vertex. 02109 The north side of the surface's parameter 02110 space will be a singular point at the vertex. 02111 edge - [in] The south side of the face's surface will 02112 run along this edge. 02113 bRevEdge - [in] true if the new face's outer boundary 02114 orientation along the edge is opposite the 02115 orientation of edge. 02116 Returns: 02117 A pointer to the new face or a NULL if the new face could 02118 not be created. 02119 */ 02120 ON_BrepFace* NewConeFace( 02121 const ON_BrepVertex& vertex, 02122 const ON_BrepEdge& edge, 02123 bool bRevEdge 02124 ); 02125 02126 /* 02127 Description: 02128 Create a new outer boundary loop that runs along the edges 02129 of the underlying surface. 02130 Returns: 02131 New outer boundary loop. 02132 */ 02133 ON_BrepLoop& NewLoop( ON_BrepLoop::TYPE ); 02134 02135 /* 02136 Description: 02137 Create a new boundary loop on a face. After you get this 02138 ON_BrepLoop, you still need to create the vertices, edges, 02139 and trims that define the loop. 02140 Returns: 02141 New loop that needs to be filled in. 02142 */ 02143 ON_BrepLoop& NewLoop( ON_BrepLoop::TYPE loop_type, ON_BrepFace& face ); 02144 02145 /* 02146 Description: 02147 Create a new outer boundary loop that runs along the sides 02148 of the face's surface. All the necessary trims, edges, 02149 and vertices are created and added to the brep. 02150 Parameters: 02151 face_index - [in] index of face that needs an outer boundary 02152 that runs along the sides of its surface. 02153 Returns: 02154 New outer boundary loop that is complete. 02155 */ 02156 ON_BrepLoop* NewOuterLoop( int face_index ); 02157 02158 /* 02159 Description: 02160 Add a new face to brep. This version is for expert users. 02161 Parameters: 02162 face_index - [in] index of face that will get a new outer 02163 loop running around the sides of the face's 02164 underlying surface. 02165 vid - [in/out] four vertex indices that specify the vertices at 02166 the (sw,se,nw,ne) corners. If the input value 02167 of a vertex index is -1, then the vertex will be 02168 created. 02169 eid - [in/out] four edge indices that specify the edges for 02170 the (south,east,north,west) sides. If the input value 02171 of an edge index is -1, then the edge will be created. 02172 bRev3d - [in/out] four values of the trim m_bRev3d flags of 02173 the (south,east,north,west) sides. 02174 Returns: 02175 Pointer to the new loop or NULL if input is not valid. 02176 Remarks: 02177 Adding a new loop may grow the dynamic m_L array. When 02178 this happens pointers and references to memory in the 02179 previous m_L[] array may become invalid. Use face indices 02180 if this is an issue. 02181 See Also: 02182 ON_Brep::NewFace 02183 */ 02184 ON_BrepLoop* NewOuterLoop( 02185 int face_index, 02186 int vid[4], 02187 int eid[4], 02188 ON_BOOL32 bRev3d[4] 02189 ); 02190 02191 /* 02192 Description: 02193 Add a planar trimming loop to a planar face. 02194 Parameters: 02195 face_index - [in] index of planar face. The underlying 02196 suface must be an ON_PlaneSurface. 02197 loop_type - [in] type of loop to add. If loop_type is 02198 ON_BrepLoop::unknown, then the loop direction is tested 02199 and the the new loops type will be set to 02200 ON_BrepLoop::outer or ON_BrepLoop::inner. If the loop_type 02201 is ON_BrepLoop::outer, then the direction of the new loop 02202 is tested and flipped if it is clockwise. If the loop_type 02203 is ON_BrepLoop::inner, then the direction of the new loop 02204 is tested and flipped if it is counter-clockwise. 02205 boundary - [in] a list of 3d curves that form a simple (no self 02206 intersections) closed curve. These curves define the 3d 02207 edge geometry and should be near the planar surface. 02208 bDuplicateCurves - [in] If true, then duplicates of the curves 02209 in the boundary array are added to the brep. If false, the 02210 curves in the boundary array are added to the brep and will 02211 be deleted by ON_Brep::~ON_Brep. 02212 Returns: 02213 true if successful. The new loop will be brep.m_L.Last(). 02214 */ 02215 bool NewPlanarFaceLoop( 02216 int face_index, 02217 ON_BrepLoop::TYPE loop_type, 02218 ON_SimpleArray<ON_Curve*>& boundary, 02219 ON_BOOL32 bDuplicateCurves = true 02220 ); 02221 02222 02223 /* 02224 Description: 02225 Add a new trim that will be part of an inner, outer, or slit loop 02226 to the brep. 02227 Parameters: 02228 c2i - [in] index of 2d trimming curve 02229 Returns: 02230 new trim 02231 Example: 02232 int c2i = brep->AddTrimCurve( p2dCurve ); 02233 ON_BrepTrim& trim = NewTrim( edge, bRev3d, loop, c2i ); 02234 trim.m_ei = ...; 02235 trim.m_li = ...; 02236 trim.m_tolerance[0] = ...; 02237 trim.m_tolerance[1] = ...; 02238 trim.m_type = ...; 02239 trim.m_iso = ...; 02240 Remarks: 02241 You should set the trim's ON_BrepTrim::m_tolerance, ON_BrepTrim::m_type, 02242 ON_BrepTrim::m_iso, ON_BrepTrim::m_li, and ON_BrepTrim::m_ei values. 02243 In general, you should try to use the 02244 ON_BrepTrim::NewTrim( edge, bRev3d, loop, c2i ) version of NewTrim. 02245 If you want to add a singular trim, use ON_Brep::NewSingularTrim. 02246 If you want to add a crvonsrf trim, use ON_Brep::NewCurveOnFace. 02247 If you want to add a ptonsrf trim, use ON_Brep::NewPointOnFace. 02248 See Also: 02249 ON_Brep::SetTrimTypeFlags 02250 ON_Brep::SetTrimIsoFlags 02251 ON_Brep::NewSingularTrim 02252 ON_Brep::NewPointOnFace 02253 ON_Brep::NewCurveOnFace 02254 */ 02255 ON_BrepTrim& NewTrim( 02256 int c2i = -1 02257 ); 02258 02259 /* 02260 Description: 02261 Add a new trim that will be part of an inner, outer, or slit loop 02262 to the brep. 02263 Parameters: 02264 bRev3d - [in] ON_BrepTrim::m_bRev3d value. true if the 02265 edge and trim have opposite directions. 02266 loop - [in] trim is appended to this loop 02267 c2i - [in] index of 2d trimming curve 02268 Returns: 02269 new trim 02270 Example: 02271 int c2i = brep->AddTrimCurve( p2dCurve ); 02272 ON_BrepTrim& trim = NewTrim( edge, bRev3d, loop, c2i ); 02273 trim.m_ei = ...; 02274 trim.m_tolerance[0] = ...; 02275 trim.m_tolerance[1] = ...; 02276 trim.m_type = ...; 02277 trim.m_iso = ...; 02278 Remarks: 02279 You should set the trim's ON_BrepTrim::m_tolerance, ON_BrepTrim::m_type, 02280 ON_BrepTrim::m_iso, and ON_BrepTrim::m_ei values. 02281 In general, you should try to use the 02282 ON_BrepTrim::NewTrim( edge, bRev3d, loop, c2i ) version of NewTrim. 02283 If you want to add a singular trim, use ON_Brep::NewSingularTrim. 02284 If you want to add a crvonsrf trim, use ON_Brep::NewCurveOnFace. 02285 If you want to add a ptonsrf trim, use ON_Brep::NewPointOnFace. 02286 See Also: 02287 ON_Brep::SetTrimTypeFlags 02288 ON_Brep::SetTrimIsoFlags 02289 ON_Brep::NewSingularTrim 02290 ON_Brep::NewPointOnFace 02291 ON_Brep::NewCurveOnFace 02292 */ 02293 ON_BrepTrim& NewTrim( 02294 ON_BOOL32 bRev3d, 02295 ON_BrepLoop& loop, 02296 int c2i = -1 02297 ); 02298 02299 /* 02300 Description: 02301 Add a new trim that will be part of an inner, outer, or slit loop 02302 to the brep. 02303 Parameters: 02304 edge - [in] 3d edge associated with this trim 02305 bRev3d - [in] ON_BrepTrim::m_bRev3d value. true if the 02306 edge and trim have opposite directions. 02307 c2i - [in] index of 2d trimming curve 02308 Returns: 02309 new trim 02310 Example: 02311 int c2i = brep->AddTrimCurve( p2dCurve ); 02312 ON_BrepTrim& trim = NewTrim( edge, bRev3d, c2i ); 02313 trim.m_li = ...; 02314 trim.m_tolerance[0] = ...; 02315 trim.m_tolerance[1] = ...; 02316 trim.m_type = ...; 02317 trim.m_iso = ...; 02318 Remarks: 02319 You should set the trim's ON_BrepTrim::m_tolerance, 02320 ON_BrepTrim::m_type, ON_BrepTrim::m_iso, 02321 and ON_BrepTrim::m_li values. 02322 In general, you should try to use the 02323 ON_BrepTrim::NewTrim( edge, bRev3d, loop, c2i ) version of NewTrim. 02324 If you want to add a singular trim, use ON_Brep::NewSingularTrim. 02325 If you want to add a crvonsrf trim, use ON_Brep::NewCurveOnFace. 02326 If you want to add a ptonsrf trim, use ON_Brep::NewPointOnFace. 02327 See Also: 02328 ON_Brep::SetTrimTypeFlags 02329 ON_Brep::SetTrimIsoFlags 02330 ON_Brep::NewSingularTrim 02331 ON_Brep::NewPointOnFace 02332 ON_Brep::NewCurveOnFace 02333 */ 02334 ON_BrepTrim& NewTrim( 02335 ON_BrepEdge& edge, 02336 ON_BOOL32 bRev3d, 02337 int c2i = -1 02338 ); 02339 02340 /* 02341 Description: 02342 Add a new trim that will be part of an inner, outer, or slit loop 02343 to the brep. 02344 Parameters: 02345 edge - [in] 3d edge associated with this trim 02346 bRev3d - [in] ON_BrepTrim::m_bRev3d value. true if the 02347 edge and trim have opposite directions. 02348 loop - [in] trim is appended to this loop 02349 c2i - [in] index of 2d trimming curve 02350 Returns: 02351 new trim 02352 Example: 02353 int c2i = brep->AddTrimCurve( p2dCurve ); 02354 ON_BrepTrim& trim = brep->NewTrim( edge, bRev3d, loop, c2i ); 02355 trim.m_tolerance[0] = ...; 02356 trim.m_tolerance[1] = ...; 02357 Remarks: 02358 You should set the trim's ON_BrepTrim::m_tolerance values. 02359 If c2i is -1, you must set the trim's ON_BrepTrim::m_iso values. 02360 This version of NewTrim sets the trim.m_type value. If the 02361 input edge or loop are not currently valid, then you may 02362 need to adjust the trim.m_type value. 02363 If you want to add a singular trim, use ON_Brep::NewSingularTrim. 02364 If you want to add a crvonsrf trim, use ON_Brep::NewCurveOnFace. 02365 If you want to add a ptonsrf trim, use ON_Brep::NewPointOnFace. 02366 See Also: 02367 ON_Brep::SetTrimTypeFlags 02368 ON_Brep::SetTrimIsoFlags 02369 ON_Brep::NewSingularTrim 02370 ON_Brep::NewPointOnFace 02371 ON_Brep::NewCurveOnFace 02372 */ 02373 ON_BrepTrim& NewTrim( 02374 ON_BrepEdge& edge, 02375 ON_BOOL32 bRev3d, 02376 ON_BrepLoop& loop, 02377 int c2i = -1 02378 ); 02379 02380 /* 02381 Description: 02382 Add a new singular trim to the brep. 02383 Parameters: 02384 vertex - [in] vertex along collapsed surface edge 02385 loop - [in] trim is appended to this loop 02386 iso - [in] one of ON_Surface::S_iso, ON_Surface::E_iso, 02387 ON_Surface::N_iso, or ON_Surface::W_iso. 02388 c2i - [in] index of 2d trimming curve 02389 Returns: 02390 new trim 02391 See Also: 02392 ON_Brep::NewTrim 02393 */ 02394 ON_BrepTrim& NewSingularTrim( 02395 const ON_BrepVertex& vertex, 02396 ON_BrepLoop& loop, 02397 ON_Surface::ISO iso, 02398 int c2i = -1 02399 ); 02400 02401 /* 02402 Description: 02403 Adds a new point on face to the brep. 02404 Parameters: 02405 face - [in] face that vertex lies on 02406 s,t - [in] surface parameters 02407 Returns: 02408 new vertex that represents the point on face. 02409 Remarks: 02410 If a vertex is a point on a face, then brep.m_E[m_ei] 02411 will be an edge with no 3d curve. This edge will have 02412 a single trim with type ON_BrepTrim::ptonsrf. There 02413 will be a loop containing this single trim. 02414 */ 02415 ON_BrepVertex& NewPointOnFace( 02416 ON_BrepFace& face, 02417 double s, 02418 double t 02419 ); 02420 02421 /* 02422 Description: 02423 Add a new curve on face to the brep. 02424 Parameters: 02425 face - [in] face that curve lies on 02426 edge - [in] 3d edge associated with this curve on surface 02427 bRev3d - [in] true if the 3d edge and the 2d parameter space 02428 curve have opposite directions. 02429 c2i - [in] index of 2d curve in face's parameter space 02430 Returns: 02431 new trim that represents the curve on surface 02432 Remarks: 02433 You should set the trim's ON_BrepTrim::m_tolerance and 02434 ON_BrepTrim::m_iso values. 02435 */ 02436 ON_BrepTrim& NewCurveOnFace( 02437 ON_BrepFace& face, 02438 ON_BrepEdge& edge, 02439 ON_BOOL32 bRev3d = false, 02440 int c2i = -1 02441 ); 02442 02443 // appends a copy of brep to this and updates 02444 // indices of appended brep parts. Duplicates are not removed. 02445 void Append( 02446 const ON_Brep& // brep 02447 ); 02448 02449 // This function can be used to compute vertex information for a 02450 // b-rep when everything but the m_V array is properly filled in. 02451 // It is intended to be used when creating a ON_Brep from a 02452 // definition that does not include explicit vertex information. 02453 void SetVertices(void); 02454 02455 // This function can be used to set the ON_BrepTrim::m_iso 02456 // flag. It is intended to be used when creating a ON_Brep from 02457 // a definition that does not include compatible parameter space 02458 // type information. 02459 // See Also: ON_BrepSetFlagsAndTolerances 02460 bool SetTrimIsoFlags(); // sets all trim iso flags 02461 bool SetTrimIsoFlags( ON_BrepFace& ); 02462 bool SetTrimIsoFlags( ON_BrepLoop& ); 02463 bool SetTrimIsoFlags( ON_BrepTrim& ); 02464 02465 02466 /* 02467 Description: 02468 Calculate the type (singular, mated, boundary, etc.) of 02469 an ON_BrepTrim object. 02470 Parameters: 02471 trim - [in] 02472 bLazy - [in] if true and trim.m_type is set to something other 02473 than ON_BrepTrim::unknown, then no calculation is 02474 performed and the value of trim.m_type is returned. 02475 If false, the value of trim.m_type is ignored and is caluculated. 02476 Returns: 02477 Type of trim. 02478 Remarks: 02479 The trim must be connected to a valid loop. 02480 See Also: 02481 ON_Brep::SetTrimTypeFlags 02482 */ 02483 ON_BrepTrim::TYPE TrimType( 02484 const ON_BrepTrim& trim, 02485 ON_BOOL32 bLazy = true 02486 ) const; 02487 02488 // This function can be used to set the ON_BrepTrim::m_type 02489 // flag. If the optional bLazy argument is true, then only 02490 // trims with m_type = unknown are set. 02491 // See Also: ON_BrepSetFlagsAndTolerances 02492 bool SetTrimTypeFlags( ON_BOOL32 bLazy = false ); // sets all trim iso flags 02493 bool SetTrimTypeFlags( ON_BrepFace&, ON_BOOL32 bLazy = false ); 02494 bool SetTrimTypeFlags( ON_BrepLoop&, ON_BOOL32 bLazy = false ); 02495 bool SetTrimTypeFlags( ON_BrepTrim&, ON_BOOL32 bLazy = false ); 02496 02497 // GetTrim2dStart() evaluates the start of the 02498 // parameter space (2d) trim curve. 02499 bool GetTrim2dStart( 02500 int trim_index, // index of ON_BrepTrim in m_T[] array 02501 ON_2dPoint& 02502 ) const; 02503 02504 // GetTrim2dEnd() evaluates end of the 02505 // parameter space (2d) trim curve. 02506 bool GetTrim2dEnd( 02507 int, // index of ON_BrepTrim in m_T[] array 02508 ON_2dPoint& 02509 ) const; 02510 02511 // GetTrim3dStart() evaluates the 3d surface at the start of the 02512 // parameter space (2d) trim curve. 02513 bool GetTrim3dStart( 02514 int, // index of ON_BrepTrim in m_T[] array 02515 ON_3dPoint& 02516 ) const; 02517 02518 // GetTrim3dEnd() evaluates the 3d surface at the end of the 02519 // parameter space (2d) trim curve. 02520 bool GetTrim3dEnd( 02521 int, // index of ON_BrepTrim in m_T[] array 02522 ON_3dPoint& 02523 ) const; 02524 02525 // This function examines the 2d parameter space curves and returns 02526 // the loop's type based on their orientation. Use this function for 02527 // debugging loop orientation problems. 02528 ON_BrepLoop::TYPE ComputeLoopType( const ON_BrepLoop& ) const; 02529 02530 // These set the various tolerances. The optional ON_BOOL32 argument 02531 // is called bLazy. If bLazy is false, the tolerance is recomputed 02532 // from its definition. If bLazy is true, the tolerance is computed 02533 // only if its current value is negative. 02534 bool SetVertexTolerance( ON_BrepVertex& vertex, ON_BOOL32 bLazy = false ) const; 02535 virtual 02536 bool SetTrimTolerance( ON_BrepTrim& trim, ON_BOOL32 bLazy = false ) const; 02537 virtual 02538 bool SetEdgeTolerance( ON_BrepEdge& edge, ON_BOOL32 bLazy = false ) const; 02539 02540 /* 02541 Description: 02542 Set the brep's vertex tolerances. 02543 Parameters: 02544 bLazy - [in] if true, only vertex tolerances with the value 02545 ON_UNSET_VALUE will be set. If false, the vertex tolerance 02546 is recomputed from the geometry in the brep. 02547 Returns: 02548 true if successful. 02549 See Also: 02550 ON_Brep::SetVertexTolerance 02551 ON_Brep::SetTrimTolerance 02552 ON_Brep::SetEdgeTolerance 02553 ON_Brep::SetVertexTolerances 02554 ON_Brep::SetTrimTolerances 02555 ON_Brep::SetEdgeTolerances 02556 ON_Brep::SetTolerancesAndFlags 02557 */ 02558 bool SetVertexTolerances( ON_BOOL32 bLazy = false ); 02559 02560 /* 02561 Description: 02562 Set the brep's trim tolerances. 02563 Parameters: 02564 bLazy - [in] if true, only trim tolerances with the value 02565 ON_UNSET_VALUE will be set. If false, the trim tolerance 02566 is recomputed from the geometry in the brep. 02567 Returns: 02568 true if successful. 02569 See Also: 02570 ON_Brep::SetVertexTolerance 02571 ON_Brep::SetTrimTolerance 02572 ON_Brep::SetEdgeTolerance 02573 ON_Brep::SetVertexTolerances 02574 ON_Brep::SetTrimTolerances 02575 ON_Brep::SetEdgeTolerances 02576 ON_Brep::SetTolerancesAndFlags 02577 */ 02578 bool SetTrimTolerances( ON_BOOL32 bLazy = false ); 02579 02580 /* 02581 Description: 02582 Set the brep's edge tolerances. 02583 Parameters: 02584 bLazy - [in] if true, only edge tolerances with the value 02585 ON_UNSET_VALUE will be set. If false, the edge tolerance 02586 is recomputed from the geometry in the brep. 02587 Returns: 02588 true if successful. 02589 See Also: 02590 ON_Brep::SetVertexTolerance 02591 ON_Brep::SetTrimTolerance 02592 ON_Brep::SetEdgeTolerance 02593 ON_Brep::SetVertexTolerances 02594 ON_Brep::SetTrimTolerances 02595 ON_Brep::SetEdgeTolerances 02596 ON_Brep::SetTolerancesAndFlags 02597 */ 02598 bool SetEdgeTolerances( ON_BOOL32 bLazy = false ); 02599 02600 02601 /* 02602 Description: 02603 Set the trim parameter space bounding box (trim.m_pbox). 02604 Parameters: 02605 trim - [in] 02606 bLazy - [in] if true and trim.m_pbox is valid, then 02607 the box is not set. 02608 Returns: 02609 true if trim ends up with a valid bounding box. 02610 */ 02611 virtual 02612 bool SetTrimBoundingBox( ON_BrepTrim& trim, ON_BOOL32 bLazy=false ); 02613 02614 /* 02615 Description: 02616 Set the loop parameter space bounding box (loop.m_pbox). 02617 Parameters: 02618 loop - [in] 02619 bLazy - [in] if true and loop trim trim.m_pbox is valid, 02620 then that trim.m_pbox is not recalculated. 02621 Returns: 02622 true if loop ends up with a valid bounding box. 02623 */ 02624 virtual 02625 bool SetTrimBoundingBoxes( ON_BrepLoop& loop, ON_BOOL32 bLazy=false ); 02626 02627 02628 /* 02629 Description: 02630 Set the loop and trim parameter space bounding boxes 02631 for every loop and trim in the face 02632 Parameters: 02633 face - [in] 02634 bLazy - [in] if true and trim trim.m_pbox is valid, 02635 then that trim.m_pbox is not recalculated. 02636 Returns: 02637 true if all the face's loop and trim parameter space bounding 02638 boxes are valid. 02639 */ 02640 virtual 02641 bool SetTrimBoundingBoxes( ON_BrepFace& face, ON_BOOL32 bLazy=false ); 02642 02643 /* 02644 Description: 02645 Set the loop and trim parameter space bounding boxes 02646 for every loop and trim in the brep. 02647 Parameters: 02648 bLazy - [in] if true and trim trim.m_pbox is valid, 02649 then that trim.m_pbox is not recalculated. 02650 Returns: 02651 true if all the loop and trim parameter space bounding boxes 02652 are valid. 02653 */ 02654 virtual 02655 bool SetTrimBoundingBoxes( ON_BOOL32 bLazy=false ); 02656 02657 /* 02658 Description: 02659 Set tolerances and flags in a brep 02660 Parameters: 02661 bLazy - [in] if true, only flags and tolerances that are not 02662 set will be calculated. 02663 bSetVertexTolerances - [in] true to compute vertex.m_tolerance values 02664 bSetEdgeTolerances - [in] true to compute edge.m_tolerance values 02665 bSetTrimTolerances - [in] true to compute trim.m_tolerance[0,1] values 02666 bSetTrimIsoFlags - [in] true to compute trim.m_iso values 02667 bSetTrimTypeFlags - [in] true to compute trim.m_type values 02668 bSetLoopTypeFlags - [in] true to compute loop.m_type values 02669 bSetTrimBoxes - [in] true to compute trim.m_pbox values 02670 See Also: 02671 ON_Brep::SetVertexTolerance 02672 ON_Brep::SetEdgeTolerance 02673 ON_Brep::SetTrimTolerance 02674 ON_Brep::SetTrimTypeFlags 02675 ON_Brep::SetTrimIsoFlags 02676 ON_Brep::ComputeLoopType 02677 ON_Brep::SetTrimBoundingBox 02678 ON_Brep::SetTrimBoundingBoxes 02679 */ 02680 void SetTolerancesBoxesAndFlags( 02681 ON_BOOL32 bLazy = false, 02682 ON_BOOL32 bSetVertexTolerances = true, 02683 ON_BOOL32 bSetEdgeTolerances = true, 02684 ON_BOOL32 bSetTrimTolerances = true, 02685 ON_BOOL32 bSetTrimIsoFlags = true, 02686 ON_BOOL32 bSetTrimTypeFlags = true, 02687 ON_BOOL32 bSetLoopTypeFlags = true, 02688 ON_BOOL32 bSetTrimBoxes = true 02689 ); 02690 02691 02693 // Query Interface 02694 02695 /* 02696 Description: 02697 Determine how many brep faces reference m_S[surface_index]. 02698 Parameters: 02699 surface_index - [in] index of the surface in m_S[] array 02700 max_count - [in] counting stops if max_count > 0 and 02701 at least max_count faces use the surface. 02702 Returns: 02703 Number of brep faces that reference the surface. 02704 */ 02705 int SurfaceUseCount( 02706 int surface_index, 02707 int max_count=0 ) 02708 const; 02709 /* 02710 Description: 02711 Determine how many brep edges reference m_C3[c3_index]. 02712 Parameters: 02713 c3_index - [in] index of the 3d curve in m_C3[] array 02714 max_count - [in] counting stops if max_count > 0 and 02715 at least max_count edges use the 3d curve. 02716 Returns: 02717 Number of brep edges that reference the 3d curve. 02718 */ 02719 int EdgeCurveUseCount( 02720 int c3_index, 02721 int max_count=0 ) 02722 const; 02723 02724 /* 02725 Description: 02726 Determine how many brep trims reference m_C2[c2_index]. 02727 Parameters: 02728 c2_index - [in] index of the 2d curve in m_C2[] array 02729 max_count - [in] counting stops if max_count > 0 and 02730 at least max_count trims use the 2d curve. 02731 Returns: 02732 Number of brep trims that reference the 2d curve. 02733 */ 02734 int TrimCurveUseCount( 02735 int c2_index, 02736 int max_count=0 ) 02737 const; 02738 02739 /* 02740 Description: 02741 Get a single 3d curve that traces the entire loop 02742 Parameters: 02743 loop - [in] loop whose 3d curve should be duplicated 02744 bRevCurveIfFaceRevIsTrue - [in] If false, the returned 02745 3d curve has an orientation compatible with the 02746 2d curve returned by Loop2dCurve(). 02747 If true and the m_bRev flag of the loop's face 02748 is true, then the returned curve is reversed. 02749 Returns: 02750 A pointer to a 3d ON_Curve. The caller must delete 02751 this curve. 02752 */ 02753 ON_Curve* Loop3dCurve( 02754 const ON_BrepLoop& loop, 02755 ON_BOOL32 bRevCurveIfFaceRevIsTrue = false 02756 ) const; 02757 02758 /* 02759 Description: 02760 Get a list of 3d curves that trace the non-seam edge 02761 portions of an entire loop 02762 Parameters: 02763 loop - [in] loop whose 3d curve should be duplicated 02764 curve_list - [out] 3d curves are appended to this list 02765 bRevCurveIfFaceRevIsTrue - [in] If false, the returned 02766 3d curves have an orientation compatible with the 02767 2d curve returned by Loop2dCurve(). 02768 If true and the m_bRev flag of the loop's face 02769 is true, then the returned curves are reversed. 02770 Returns: 02771 Number of curves appended to curve_list. 02772 */ 02773 int Loop3dCurve( 02774 const ON_BrepLoop& loop, 02775 ON_SimpleArray<ON_Curve*>& curve_list, 02776 ON_BOOL32 bRevCurveIfFaceRevIsTrue = false 02777 ) const; 02778 02779 02780 /* 02781 Description: 02782 Get a 3d curve that traces the entire loop 02783 Parameters: 02784 loop - [in] loop whose 2d curve should be duplicated 02785 Returns: 02786 A pointer to a 2d ON_Curve. The caller must delete 02787 this curve. 02788 */ 02789 ON_Curve* Loop2dCurve( const ON_BrepLoop& loop ) const; 02790 02791 /* 02792 Description: 02793 Determine orientation of a brep. 02794 Returns: 02795 @untitle table 02796 +2 brep is a solid but orientation cannot be computed 02797 +1 brep is a solid with outward facing normals 02798 -1 brep is a solid with inward facing normals 02799 0 brep is not a solid 02800 Remarks: 02801 The base class implementation returns 2 or 0. This 02802 function is overridden in the Rhino SDK and returns 02803 +1, -1, or 0. 02804 See Also: 02805 ON_Brep::IsSolid 02806 */ 02807 virtual 02808 int SolidOrientation() const; 02809 02810 /* 02811 Description: 02812 Test brep to see if it is a solid. (A "solid" is 02813 a closed oriented manifold.) 02814 Returns: 02815 @untitled table 02816 true brep is a solid 02817 fals brep is not a solid 02818 See Also: 02819 ON_Brep::SolidOrientation 02820 ON_Brep::IsManifold 02821 */ 02822 bool IsSolid() const; 02823 02824 /* 02825 Description: 02826 Test brep to see if it is an oriented manifold. 02827 Parameters: 02828 pbIsOriented - [in] if not null, *pbIsOriented is set 02829 to true if b-rep is an oriented manifold and false 02830 if brep is not an oriented manifold. 02831 pbHasBoundary - [in] if not null, *pbHasBoundary is set 02832 to true if b-rep has a boundary edge and false if 02833 brep does not have a boundary edge. 02834 Returns: 02835 true brep is a manifold 02836 fals brep is not a manifold 02837 See Also: 02838 ON_Brep::IsSolid 02839 */ 02840 bool IsManifold( // returns true if b-rep is an oriented manifold 02841 ON_BOOL32* pbIsOriented = NULL, 02842 ON_BOOL32* pbHasBoundary = NULL 02843 ) const; 02844 02845 /* 02846 Description: 02847 Determine if P is inside Brep. This question only makes sense 02848 when the brep is a closed manifold. This function does not 02849 not check for closed or manifold, so result is not valid in 02850 those cases. Intersects a line through P with brep, finds 02851 the intersection point Q closest to P, and looks at face 02852 normal at Q. If the point Q is on an edge or the intersection 02853 is not transverse at Q, then another line is used. 02854 Parameters: 02855 P - [in] 3d point 02856 tolerance - [in] 3d distance tolerance used for intersection 02857 and determining strict inclusion. 02858 bStrictlInside - [in] If bStrictlInside is true, then this 02859 function will return false if the distance from P is within 02860 tolerance of a brep face. 02861 Returns: 02862 True if P is in, false if not. See parameter bStrictlyIn. 02863 */ 02864 bool IsPointInside( 02865 ON_3dPoint P, 02866 double tolerance, 02867 bool bStrictlyInside 02868 ) const; 02869 02870 02871 bool IsSurface() const; // returns true if the b-rep has a single face 02872 // and that face is geometrically the same 02873 // as the underlying surface. I.e., the face 02874 // has trivial trimming. In this case, the 02875 // surface is m_S[0]. 02876 // The flag m_F[0].m_bRev records 02877 // the correspondence between the surface's 02878 // natural parametric orientation and the 02879 // orientation of the b-rep. 02880 02881 02882 bool FaceIsSurface( // returns true if the face has a single 02883 int // index of face // outer boundary and that boundary runs 02884 ) const; // along the edges of the underlying surface. 02885 // In this case the geometry of the surface 02886 // is the same as the geometry of the face. 02887 // If FaceIsSurface() is true, then 02888 // m_S[m_F[face_index].m_si] is the surface. 02889 // The flag m_F[face_index].m_bRev records 02890 // the correspondence between the surface's 02891 // natural parametric orientation and the 02892 // orientation of face in the b-rep. 02893 02894 bool LoopIsSurfaceBoundary( // returns true if the loop's trims all run 02895 int // index of loop // along the edge's of the underlying surface's 02896 ) const; // parameter space. 02897 02899 // Modification Interface 02900 02902 // Clears all ON_BrepFace.m_bRev flags by ON_BrepFace::Transpose 02903 // on each face with a true m_bRev. 02904 bool FlipReversedSurfaces(); 02905 02907 // Change the domain of a trim's 2d curve. This changes only the 02908 // parameterization of the 2d trimming curve; the locus of the 02909 // 2d trimming curve is not changed. 02910 bool SetTrimDomain( 02911 int, // index of trim in m_T[] array 02912 const ON_Interval& 02913 ); 02914 02916 // Change the domain of an edge. This changes only the 02917 // parameterization of the 3d edge curve; the locus of the 02918 // 3d edge curve is not changed. 02919 bool SetEdgeDomain( 02920 int, // index of edge in m_E[] array 02921 const ON_Interval& 02922 ); 02923 02924 // Reverses entire brep orientation of all faces by toggling 02925 // value of all face's ON_BrepFace::m_bRev flag. 02926 void Flip(); 02927 02928 // reverses orientation of a face by toggling ON_BrepFace::m_bRev 02929 void FlipFace(ON_BrepFace&); 02930 02931 // Reverses orientation of trimming loop. 02932 // This function is intended to be used by brep experts and does 02933 // does NOT modify ON_BrepLoop::m_type. You should make sure 02934 // ON_BrepLoop::m_type jibes with the loop's direction. (Outer loops 02935 // should be counter-clockwise and inner loops should be clockwise.) 02936 // You can use ON_Brep::LoopDirection() to determine the direction of 02937 // a loop. 02938 void FlipLoop(ON_BrepLoop&); // reverses orientation of trimming loop 02939 02940 // LoopDirection() examines the 2d trimming curve geometry that defines 02941 // the loop and returns 02942 // 02943 // @untitled table 02944 // +1 the loop is a counter-clockwise loop. 02945 // -1 the loop is a clockwise loop. 02946 // 0 the loop is not a continuous closed loop. 02947 // 02948 // Since LoopDirection() calculates its result based on the 2d trimming 02949 // curve geometry, it can be use to set ON_BrepLoop::m_type to outer/inner 02950 // when translating from data definition where this distinction is murky. 02951 int LoopDirection( const ON_BrepLoop& ) const; 02952 02953 02954 /* 02955 Description: 02956 Sort the face.m_li[] array by loop type 02957 (outer, inner, slit, crvonsrf, ptonsrf) 02958 Parameters: 02959 face - [in/out] face whose m_li[] array should be sorted. 02960 Returns: 02961 @untitled table 02962 true success 02963 false failure - no loops or loops with unset loop.m_type 02964 See Also: 02965 ON_Brep::ComputeLoopType 02966 ON_Brep::LoopDirection 02967 */ 02968 bool SortFaceLoops( ON_BrepFace& face ) const; 02969 02970 /* 02971 Description: 02972 Expert user function. 02973 See Also: 02974 ON_Brep::JoinEdges 02975 */ 02976 bool CombineCoincidentVertices(ON_BrepVertex&, ON_BrepVertex&); // moves information to first vertex and deletes second 02977 02978 /* 02979 Description: 02980 Expert user function. 02981 See Also: 02982 ON_Brep::JoinEdges 02983 */ 02984 bool CombineCoincidentEdges(ON_BrepEdge&, ON_BrepEdge&); // moves information to first edge and deletes second 02985 02986 /* 02987 Description: 02988 Expert user function. 02989 Combines contiguous edges into a single edge. The edges 02990 must share a common vertex, then angle between the edge 02991 tangents are the common vertex must be less than or 02992 equal to angle_tolerance_radians, and any associated 02993 trims must be contiguous in there respective boundaries. 02994 Parameters; 02995 edge_index0 - [in] 02996 edge_index1 - [in] 02997 angle_tolerance_radians - [in] 02998 Returns: 02999 Pointer to the new edge or NULL if the edges cannot 03000 be combined into a single edge. 03001 Remarks: 03002 The input edges are deleted but are still in the 03003 brep's m_E[] arrays. Use ON_Brep::Compact to remove 03004 the unused edges. 03005 */ 03006 ON_BrepEdge* CombineContiguousEdges( 03007 int edge_index0, 03008 int edge_iindex1, 03009 double angle_tolerance_radians = ON_PI/180.0 03010 ); 03011 03012 // These remove a topology piece from a b-rep but do not 03013 // rearrange the arrays that hold the brep objects. The 03014 // deleted objects have their indices set to -1. Deleting 03015 // an object that is connected to other objects will 03016 // modify thos objects. 03017 void DeleteVertex(ON_BrepVertex& vertex); 03018 void DeleteEdge(ON_BrepEdge& edge, ON_BOOL32 bDeleteEdgeVertices); // pass true to delete vertices used only by edge 03019 void DeleteTrim(ON_BrepTrim& trim, ON_BOOL32 bDeleteTrimEdges); // pass true to delete edges and vertices used only by trim 03020 void DeleteLoop(ON_BrepLoop& loop, ON_BOOL32 bDeleteLoopEdges); // pass true to delete edges and vertices used only by trim 03021 void DeleteFace(ON_BrepFace& face, ON_BOOL32 bDeleteFaceEdges); // pass true to delete edges and vertices used only by face 03022 void DeleteSurface(int s_index); 03023 void Delete2dCurve(int c2_index); 03024 void Delete3dCurve(int c3_index); 03025 03026 // Description: 03027 // Set m_vertex_user.i, m_edge_user.i, m_face_user.i, m_loop_user.i, 03028 // and m_trim_user.i values of faces of component including 03029 // m_F[face_index] to label. Numbering starts at 1. 03030 // Parameters: 03031 // face_index - [in] index of face in component 03032 // label - [in] value for m_*_user.i 03033 // Returns: 03034 // Remarks: 03035 // Chases through trim lists of face edges to find adjacent faces. 03036 // Does NOT check for vertex-vertex connections 03037 void LabelConnectedComponent( 03038 int face_index, 03039 int label 03040 ); 03041 03042 /* 03043 Description: 03044 Set m_vertex_user.i, m_edge_user.i, m_face_user.i, m_loop_user.i, 03045 and m_trim_user.i values values to distinguish connected components. 03046 Parameters: 03047 Returns: 03048 number of connected components 03049 Remarks: 03050 For each face in the ith component, sets m_face_user.i to i>0. 03051 Chases through trim lists of face edges to find adjacent faces. 03052 Numbering starts at 1. Does NOT check for vertex-vertex connections. 03053 See Also: 03054 ON_Brep::GetConnectedComponents 03055 */ 03056 int LabelConnectedComponents(); 03057 03058 /* 03059 Description: 03060 If this brep has two or more connected components, 03061 then duplicates of the connected components are appended 03062 to the components[] array. 03063 Parameters: 03064 components - [in] connected components are appended to this array. 03065 bDuplicateMeshes - [in] if true, any meshes on this brep are copied 03066 to the output breps. 03067 Returns: 03068 Number of connected components appended to components[] or zero 03069 if this brep has only one connected component. 03070 See Also: 03071 ON_Brep::GetConnectedComponents 03072 */ 03073 int GetConnectedComponents( 03074 ON_SimpleArray< ON_Brep* >& components, 03075 bool bDuplicateMeshes 03076 ) const; 03077 03078 /* 03079 Description: 03080 Copy a subset of this brep. 03081 Parameters: 03082 subfi_count - [in] length of sub_fi[] array. 03083 sub_fi - [in] array of face indices in this 03084 brep to copy. (If any values inf sub_fi[] 03085 are out of range or if sub_fi[] contains 03086 duplicates, this function will return null.) 03087 sub_brep - [in] if this pointer is not null, 03088 then the subbrep will be created in this 03089 class. 03090 Returns: 03091 If the input is valid, a pointer to the 03092 subbrep is returned. If the input is not 03093 valid, null is returned. The faces in 03094 in the subbrep's m_F array are in the same 03095 order as they were specified in sub_fi[]. 03096 */ 03097 ON_Brep* SubBrep( 03098 int subfi_count, 03099 const int* sub_fi, 03100 ON_Brep* sub_brep = 0 03101 ) const; 03102 03104 // 03105 // region topology 03106 // 03107 bool HasRegionTopology() const; 03108 03109 /* 03110 Description: 03111 Get region topology information: 03112 In order to keep the ON_Brep class efficient, rarely used 03113 region topology information is not maintained. If you 03114 require this information, call RegionTopology(). 03115 */ 03116 const ON_BrepRegionTopology& RegionTopology() const; 03117 03118 /* 03119 Description: 03120 Get region topology information: 03121 In order to keep the ON_Brep class efficient, rarely used 03122 region topology information is not maintained. If you 03123 require this information, call RegionTopology(). 03124 */ 03125 void DestroyRegionTopology(); 03126 // Description: 03127 // Duplicate a single brep face. 03128 // Parameters: 03129 // face_index - [in] index of face to duplicate 03130 // bDuplicateMeshes - [in] if true, any attached meshes are duplicated 03131 // Returns: 03132 // Single face brep. 03133 // Remarks: 03134 // The m_vertex_user.i, m_edge_user.i, m_face_user.i, m_loop_user.i, 03135 // and m_trim_user.i values of the returned brep are are set to the 03136 // indices of the objects they duplicate. 03137 // See Also: 03138 // ON_Brep::DeleteFace, ON_Brep::ExtractFace 03139 ON_Brep* DuplicateFace( 03140 int face_index, 03141 ON_BOOL32 bDuplicateMeshes 03142 ) const; 03143 03144 // Description: 03145 // Duplicate a a subset of a brep 03146 // Parameters: 03147 // face_count - [in] length of face_index[] array 03148 // face_index - [in] array of face indices 03149 // bDuplicateMeshes - [in] if true, any attached meshes are duplicated 03150 // Returns: 03151 // A brep made by duplicating the faces listed in the face_index[] array. 03152 // Remarks: 03153 // The m_vertex_user.i, m_edge_user.i, m_face_user.i, m_loop_user.i, 03154 // and m_trim_user.i values of the returned brep are are set to the 03155 // indices of the objects they duplicate. 03156 // See Also: 03157 // ON_Brep::DuplicateFace 03158 ON_Brep* DuplicateFaces( 03159 int face_count, 03160 const int* face_index, 03161 ON_BOOL32 bDuplicateMeshes 03162 ) const; 03163 03164 // Description: 03165 // Extract a face from a brep. 03166 // Parameters: 03167 // face_index - [in] index of face to extract 03168 // Returns: 03169 // Single face brep. 03170 // See Also: 03171 // ON_Brep::DeleteFace, ON_Brep::DuplicateFace 03172 ON_Brep* ExtractFace( 03173 int face_index 03174 ); 03175 03176 03177 /* 03178 Description: 03179 Standardizes the relationship between an ON_BrepEdge 03180 and the 3d curve it uses. When done, the edge will 03181 be the only edge that references its 3d curve, the 03182 domains of the edge and 3d curve will be the same, 03183 and the edge will use the entire locus of the 3d curve. 03184 Parameters: 03185 edge_index - [in] index of edge to standardize. 03186 bAdjustEnds - [in] if true, move edge curve endpoints to vertices 03187 See Also: 03188 ON_Brep::StandardizeEdgeCurves 03189 ON_Brep::Standardize 03190 */ 03191 bool StandardizeEdgeCurve( int edge_index, bool bAdjustEnds ); 03192 03193 03194 /* 03195 Description: 03196 Expert user only. Same as above, but to be used when the edge 03197 curve use count is known for the edge. 03198 Standardizes the relationship between an ON_BrepEdge 03199 and the 3d curve it uses. When done, the edge will 03200 be the only edge that references its 3d curve, the 03201 domains of the edge and 3d curve will be the same, 03202 and the edge will use the entire locus of the 3d curve. 03203 Parameters: 03204 edge_index - [in] index of edge to standardize. 03205 bAdjustEnds - [in] if true, move edge curve endpoints to vertices 03206 EdgeCurveUse - [in] if > 1, then the edge curve for this edge is used by more than one 03207 edge. if 1, then the edge curve is used only for this edge. 03208 If <= 0, then use count is unknown. 03209 See Also: 03210 ON_Brep::StandardizeEdgeCurves 03211 ON_Brep::Standardize 03212 */ 03213 bool StandardizeEdgeCurve( int edge_index, bool bAdjustEnds, int EdgeCurveUse ); 03214 03215 03216 /* 03217 Description: 03218 Standardize all edges in the brep. 03219 Parameters: 03220 bAdjustEnds - [in] if true, move edge curve endpoints to vertices 03221 See Also: 03222 ON_Brep::StandardizeEdgeCurve 03223 ON_Brep::Standardize 03224 */ 03225 void StandardizeEdgeCurves( bool bAdjustEnds ); 03226 03227 /* 03228 Description: 03229 Standardizes the relationship between an ON_BrepTrim 03230 and the 2d curve it uses. When done, the trim will 03231 be the only trim that references its 2d curve, the 03232 domains of the trim and 2d curve will be the same, 03233 and the trim will use the entire locus of the 2d curve. 03234 Parameters: 03235 trim_index - [in] index of trim to standardize. 03236 See Also: 03237 ON_Brep::StandardizeTrimCurves 03238 ON_Brep::Standardize 03239 */ 03240 bool StandardizeTrimCurve( int trim_index ); 03241 03242 /* 03243 Description: 03244 Standardize all trims in the brep. 03245 See Also: 03246 ON_Brep::StandardizeTrimCurve 03247 ON_Brep::Standardize 03248 */ 03249 void StandardizeTrimCurves(); 03250 03251 /* 03252 Description: 03253 Standardizes the relationship between an ON_BrepFace 03254 and the 3d surface it uses. When done, the face will 03255 be the only face that references its 3d surface, and 03256 the orientations of the face and 3d surface will be 03257 the same. 03258 Parameters: 03259 face_index - [in] index of face to standardize. 03260 See Also: 03261 ON_Brep::StardardizeFaceSurfaces 03262 ON_Brep::Standardize 03263 */ 03264 bool StandardizeFaceSurface( int face_index ); 03265 03266 /* 03267 Description: 03268 Standardize all faces in the brep. 03269 See Also: 03270 ON_Brep::StandardizeFaceSurface 03271 ON_Brep::Standardize 03272 */ 03273 void StandardizeFaceSurfaces(); 03274 03275 // misspelled function name is obsolete 03276 ON_DEPRECATED void StardardizeFaceSurfaces(); 03277 03278 /* 03279 Description: 03280 Standardize all trims, edges, and faces in the brep. 03281 Remarks: 03282 After standardizing, there may be unused curves and surfaces 03283 in the brep. Call ON_Brep::Compact to remove these unused 03284 curves and surfaces. 03285 See Also: 03286 ON_Brep::StandardizeTrimCurves 03287 ON_Brep::StandardizeEdgeCurves 03288 ON_Brep::StandardizeFaceSurface 03289 ON_Brep::Compact 03290 */ 03291 void Standardize(); 03292 03293 03294 /* 03295 Description: 03296 Sometimes the ON_Surface used by a face extends far 03297 beyond the face's outer boundary. ShrinkSurface uses 03298 ON_Surface::Trim to remove portions of the surface that 03299 extend beyond the face's outer boundary loop. 03300 Parameters: 03301 face - [in] face to test and whose surface should be shrunk. 03302 DisableSide - [in] This is a bit field. A set bit indicates not to shrink 03303 the surface on a given side. The default of 0 enables shrinking 03304 on all four sides. 03305 @table 03306 value meaning 03307 0x0001 Dont shrink on the west side of domain. 03308 0x0002 Dont shrink on the south side of domain. 03309 0x0004 Dont shrink on the east side of domain. 03310 0x0008 Dont shrink on the north side of domain. 03311 Returns: 03312 @untitled table 03313 true successful 03314 false failure 03315 Remarks: 03316 If a surface needs to be shrunk it is copied. After shrinking, 03317 you may want to call ON_Brep::CullUnusedSurfaces to remove 03318 any unused surfaces. 03319 See Also: 03320 ON_Brep::ShrinkSurfaces 03321 ON_Brep::CullUnusedSurfaces 03322 */ 03323 bool ShrinkSurface( ON_BrepFace& face, int DisableSide=0 ); 03324 03325 /* 03326 Description: 03327 Sometimes the ON_Surface used by a face extends far 03328 beyond the face's outer boundary. ShrinkSurfaces calls 03329 ON_Shrink::ShrinkSurface on each face to remove portions 03330 of surfaces that extend beyond their face's outer boundary 03331 loop. 03332 Returns: 03333 @untitled table 03334 true successful 03335 false failure 03336 Remarks: 03337 If a surface needs to be shrunk it is copied. After shrinking, 03338 you may want to call ON_Brep::CullUnusedSurfaces to remove 03339 any unused surfaces. 03340 See Also: 03341 ON_Brep::ShrinkSurface 03342 ON_Brep::CullUnusedSurfaces 03343 */ 03344 bool ShrinkSurfaces(); 03345 03346 /* 03347 Description: 03348 Uses the CullUnused*() members to delete any unreferenced 03349 objects from arrays, reindexes as needed, and shrinks 03350 arrays to minimum required size. 03351 See Also: 03352 ON_Brep::CullUnusedFaces 03353 ON_Brep::CullUnusedLoops 03354 ON_Brep::CullUnusedTrims 03355 ON_Brep::CullUnusedEdges 03356 ON_Brep::CullUnusedVertices 03357 ON_Brep::CullUnused3dCurves 03358 ON_Brep::CullUnused2dCurves 03359 ON_Brep::CullUnusedSurfaces 03360 */ 03361 bool Compact(); 03362 03363 bool CullUnusedFaces(); // culls faces with m_face_index == -1 03364 bool CullUnusedLoops(); // culls loops with m_loop_index == -1 03365 bool CullUnusedTrims(); // culls trims with m_trim_index == -1 03366 bool CullUnusedEdges(); // culls edges with m_edge_index == -1 03367 bool CullUnusedVertices(); // culls vertices with m_vertex_index == -1 03368 bool CullUnused3dCurves(); // culls 2d curves not referenced by a trim 03369 bool CullUnused2dCurves(); // culls 3d curves not referenced by an edge 03370 bool CullUnusedSurfaces(); // culls surfaces not referenced by a face 03371 03373 // Navigation Interface 03374 03375 // for moving around loops - returns trim index of prev/next trim in loop 03376 int PrevTrim( 03377 int // index of current trim (m_trim_index) 03378 ) const; 03379 int NextTrim( 03380 int // index of current trim (m_trim_index) 03381 ) const; 03382 03383 /* 03384 Description: 03385 This is a simple tool for getting running through the edges 03386 that begin and end at a vertex. 03387 Parameters: 03388 current_edge_index - [in] 03389 endi - [in] 0 = use the edge start vertex, 1 = use the edge end vertex 03390 prev_endi - [out] 0 if previous edge begins at the vertex, 03391 1 if previous edge ends at the vertex 03392 Returns: 03393 edge index of the previous edge or -1 if there is only one edge 03394 that begins or ends at the vertex. 03395 Remarks: 03396 This is a tool that simplifies searching through the 03397 ON_BrepVertex.m_ei[] array. 03398 The edges are in no particular order. 03399 See Also: 03400 ON_Brep::NextEdge 03401 */ 03402 int PrevEdge( 03403 int current_edge_index, 03404 int endi, 03405 int* prev_endi = NULL 03406 ) const; 03407 03408 /* 03409 Description: 03410 This is a simple tool for getting running through the edges 03411 that begin and end at a vertex. 03412 Parameters: 03413 current_edge_index - [in] 03414 endi - [in] 0 = use the edge start vertex, 1 = use the edge end vertex 03415 next_endi - [out] 0 if next edge begins at the vertex, 03416 1 if next edge ends at the vertex 03417 Returns: 03418 edge index of the next edge or -1 if there is only one edge 03419 that begins or ends at the vertex. 03420 Remarks: 03421 This is a tool that simplifies searching through the 03422 ON_BrepVertex.m_ei[] array. 03423 The edges are in no particular order. 03424 See Also: 03425 ON_Brep::NextEdge 03426 */ 03427 int NextEdge( 03428 int current_edge_index, 03429 int endi, 03430 int* next_endi = NULL 03431 ) const; 03432 03433 /* 03434 Description: 03435 Get a brep component from its index. 03436 Parameters: 03437 component_index - [in] 03438 Returns: 03439 A const pointer to the component. Do not delete 03440 the returned object. It points to an object managed 03441 by this brep. 03442 See Also: 03443 ON_Brep::Face 03444 ON_Brep::Edge 03445 ON_Brep::Loop 03446 ON_Brep::Trim 03447 ON_Brep::Vertex 03448 */ 03449 const ON_Geometry* BrepComponent( 03450 ON_COMPONENT_INDEX ci 03451 ) const; 03452 03453 /* 03454 Description: 03455 Get vertex from trim index or component index. 03456 Parameters: 03457 vertex_index - [in] either an index into m_V[] or a component index 03458 of type brep_vertex. 03459 Returns: 03460 If the index is a valid vertex index or a valid vertex component 03461 index, then a pointer to the ON_BrepVertex is returned. Otherwise 03462 NULL is returned. 03463 See Also 03464 ON_Brep::Component( const ON_BrepVertex& ) 03465 */ 03466 ON_BrepVertex* Vertex( int vertex_index ) const; 03467 ON_BrepVertex* Vertex( ON_COMPONENT_INDEX vertex_index ) const; 03468 03469 /* 03470 Description: 03471 Get edge from edge index or component index. 03472 Parameters: 03473 edge_index - [in] either an index into m_E[] or a component index 03474 of type brep_edge. 03475 Returns: 03476 If the index is a valid edge index or a valid edge component 03477 index, then a pointer to the ON_BrepEdge is returned. Otherwise 03478 NULL is returned. 03479 See Also 03480 ON_Brep::Component( const ON_BrepEdge& ) 03481 */ 03482 ON_BrepEdge* Edge( int edge_index ) const; 03483 ON_BrepEdge* Edge( ON_COMPONENT_INDEX edge_index ) const; 03484 03485 /* 03486 Description: 03487 Get trim from trim index or component index. 03488 Parameters: 03489 trim_index - [in] either an index into m_T[] or a component index 03490 of type brep_trim. 03491 Returns: 03492 If the index is a valid trim index or a valid trim component 03493 index, then a pointer to the ON_BrepTrim is returned. Otherwise 03494 NULL is returned. 03495 See Also 03496 ON_Brep::Component( const ON_BrepTrim& ) 03497 */ 03498 ON_BrepTrim* Trim( int trim_index ) const; 03499 ON_BrepTrim* Trim( ON_COMPONENT_INDEX trim_index ) const; 03500 03501 /* 03502 Description: 03503 Get loop from loop index or component index. 03504 Parameters: 03505 loop_index - [in] either an index into m_L[] or a component index 03506 of type brep_loop. 03507 Returns: 03508 If the index is a valid loop index or a valid loop component 03509 index, then a pointer to the ON_BrepLoop is returned. Otherwise 03510 NULL is returned. 03511 See Also 03512 ON_Brep::Component( const ON_BrepLoop& ) 03513 */ 03514 ON_BrepLoop* Loop( int loop_index ) const; 03515 ON_BrepLoop* Loop( ON_COMPONENT_INDEX loop_index ) const; 03516 03517 /* 03518 Description: 03519 Get face from face index or component index. 03520 Parameters: 03521 face_index - [in] either an index into m_F[] or a component index 03522 of type brep_face. 03523 Returns: 03524 If the index is a valid face index or a valid face component 03525 index, then a pointer to the ON_BrepFace is returned. Otherwise 03526 NULL is returned. 03527 See Also 03528 ON_Brep::Component( const ON_BrepFace& ) 03529 */ 03530 ON_BrepFace* Face( int face_index ) const; 03531 ON_BrepFace* Face( ON_COMPONENT_INDEX face_index ) const; 03532 03533 /* 03534 Description: 03535 remove slit trims and slit boundaries from each face. 03536 Returns: 03537 true if any slits were removed 03538 Remarks: 03539 Caller should call Compact() afterwards. 03540 */ 03541 bool RemoveSlits(); 03542 03543 /* 03544 Description: 03545 remove slit trims and slit boundaries from a face. 03546 Parameters: 03547 F - [in] brep face 03548 Returns: 03549 true if any slits were removed 03550 Remarks: 03551 Caller should call Compact() when done. 03552 */ 03553 bool RemoveSlits(ON_BrepFace& F); 03554 03555 /* 03556 Description: 03557 If fid0 != fid1 and m_F[fid0] and m_F[fid1] have the same surface (m_si is identical), 03558 and they are joined along a set of edges that do not have any other faces, then this will 03559 combine the two faces into one. 03560 Parameters: 03561 fid0, fid1 - [in] indices into m_F of faces to be merged. 03562 Returns: 03563 id of merged face if faces were successfully merged. -1 if not merged. 03564 Remarks: 03565 Caller should call Compact() when done. 03566 */ 03567 int MergeFaces(int fid0, int fid1); 03568 03569 /* 03570 Description: 03571 Merge all possible faces that have the same m_si 03572 Returns: 03573 true if any faces were successfully merged. 03574 Remarks: 03575 Caller should call Compact() when done. 03576 */ 03577 bool MergeFaces(); 03578 03579 /* 03580 Description: 03581 Removes nested polycurves from the m_C2[] and m_C3[] arrays. 03582 Parameters: 03583 bExtractSingleSegments - [in] if true, polycurves with a 03584 single segment are replaced with the segment curve. 03585 bEdges - [in] if true, the m_C3[] array is processed 03586 bTrimCurves - [in] if true, the m_C2[] array is processed. 03587 Returns: 03588 True if any nesting was removed and false if no nesting 03589 was removed. 03590 */ 03591 bool RemoveNesting( 03592 bool bExtractSingleSegments, 03593 bool bEdges = true, 03594 bool bTrimCurves = true 03595 ); 03596 03597 /* 03598 Description: 03599 Expert user tool to collapse a "short" edge to a vertex. 03600 The edge is removed and the topology is repaired 03601 so that everything that used to connect to the edge 03602 connects the specified vertex. 03603 Parameters: 03604 edge_index - [in] index of edge to remove 03605 bCloseTrimGap - [in] if true and the removal of the 03606 edge creates a gap in the parameter space trimming 03607 loop, then the 2d trim curves will be adjusted to 03608 close the gap. 03609 vertex_index - [in] if >= 0, this the edge is collapsed 03610 to this vertex. Otherwise a vertex is automatically 03611 selected or created. 03612 Returns: 03613 True if edge was successfully collapsed. 03614 Remarks: 03615 After you finish cleaning up the brep, you need 03616 to call ON_Brep::Compact() to remove unused edge, 03617 trim, and vertex information from the brep's m_E[], 03618 m_V[], m_T[], m_C2[], and m_C3[] arrays. 03619 */ 03620 bool CollapseEdge( 03621 int edge_index, 03622 bool bCloseTrimGap = true, 03623 int vertex_index = -1 03624 ); 03625 03626 /* 03627 Description: 03628 Expert user tool to move trims and edges from 03629 one vertex to another. 03630 Parameters: 03631 old_vi - [in] index of old vertex 03632 new_vi - [in] index of new vertex 03633 bClearTolerances - [in] if true, then tolerances of 03634 edges and trims that are connected ot the old 03635 vertex are set to ON_UNSET_VALUE. 03636 vertex_index - [in] if >= 0, this the edge is collapsed 03637 to this vertex. Otherwise a vertex is automatically 03638 selected or created. 03639 Returns: 03640 True if successful. 03641 Remarks: 03642 After you finish cleaning up the brep, you need 03643 to call ON_Brep::Compact() to remove unused edge, 03644 trim, and vertex information from the brep's m_E[], 03645 m_V[], m_T[], m_C2[], and m_C3[] arrays. 03646 */ 03647 bool ChangeVertex( 03648 int old_vi, 03649 int new_vi, 03650 bool bClearTolerances 03651 ); 03652 03653 /* 03654 Description: 03655 Expert user tool to remove any gap between adjacent trims. 03656 Parameters: 03657 trim0 - [in] 03658 trim1 - [in] 03659 Returns: 03660 True if successful. 03661 Remarks: 03662 The trims must be in the same trimming loop. The vertex 03663 at the end of trim0 must be the same as the vertex at 03664 the start of trim1. The trim's m_iso and m_type flags 03665 need to be correctly set. 03666 */ 03667 bool CloseTrimGap( 03668 ON_BrepTrim& trim0, 03669 ON_BrepTrim& trim1 03670 ); 03671 03672 /* 03673 Description: 03674 Remove edges that are not connected to a face. 03675 Parameters: 03676 bDeleteVertices - [in] if true, then the vertices 03677 at the ends of the wire edges are deleted if 03678 they are not connected to face trimming edges. 03679 Returns: 03680 Number of edges that were removed. 03681 Remarks: 03682 After you finish cleaning up the brep, you need 03683 to call ON_Brep::Compact() to remove unused edge, 03684 trim, and vertex information from the brep's m_E[], 03685 m_V[], m_T[], m_C2[], and m_C3[] arrays. 03686 03687 If you want to remove wire edges and wiere 03688 After you finish cleaning up the brep, you need 03689 to call ON_Brep::Compact() to remove deleted vertices 03690 from the m_V[] array. 03691 See Also: 03692 ON_Brep::RemoveWireVertices 03693 */ 03694 int RemoveWireEdges( bool bDeleteVertices = true ); 03695 03696 /* 03697 Description: 03698 Remove vertices that are not connected to an edge. 03699 Returns: 03700 Number of vertices that were deleted. 03701 Remarks: 03702 After you finish cleaning up the brep, you need 03703 to call ON_Brep::Compact() to remove deleted 03704 vertices from the m_V[] array. 03705 See Also: 03706 ON_Brep::RemoveWireEdges 03707 */ 03708 int RemoveWireVertices(); 03709 03711 // "Expert" Interface 03712 03713 void Set_user(ON_U u); // set every brep m_*_user value to u 03714 void Clear_vertex_user_i(); // zero all brep's m_vertex_user values 03715 void Clear_edge_user_i(int); // zero all brep's m_edge_user values 03716 void Clear_edge_user_i(); // zero all brep's m_edge_user values 03717 void Clear_trim_user_i(); // zero all brep's m_trim_user values 03718 void Clear_loop_user_i(); // zero all brep's m_loop_user values 03719 void Clear_face_user_i(); // zero all brep's m_face_user values 03720 void Clear_user_i(); // zero all brep's m_*_user values 03721 03722 // Union available for application use. 03723 // The constructor zeros m_brep_user. 03724 // The value is of m_brep_user is not saved in 3DM 03725 // archives and may be changed by some computations. 03726 ON_U m_brep_user; 03727 03728 // geometry 03729 // (all geometry is deleted by ~ON_Brep(). Pointers can be NULL 03730 // or not referenced. Use Compact() to remove unreferenced geometry. 03731 ON_CurveArray m_C2; // Pointers to parameter space trimming curves 03732 // (used by trims). 03733 ON_CurveArray m_C3; // Pointers to 3d curves (used by edges). 03734 ON_SurfaceArray m_S; // Pointers to parametric surfaces (used by faces) 03735 03736 // topology 03737 // (all topology is deleted by ~ON_Brep(). Objects can be unreferenced. 03738 // Use Compact() to to remove unreferenced geometry. 03739 ON_BrepVertexArray m_V; // vertices 03740 ON_BrepEdgeArray m_E; // edges 03741 ON_BrepTrimArray m_T; // trims 03742 ON_BrepLoopArray m_L; // loops 03743 ON_BrepFaceArray m_F; // faces 03744 03745 protected: 03746 friend class ON_BrepFace; 03747 friend class ON_BrepRegion; 03748 friend class ON_BrepFaceSide; 03749 ON_BoundingBox m_bbox; 03750 03751 // Never directly set m_is_solid, use calls to IsSolid() and/or 03752 // SolidOrientation() when you need to know the answer to this 03753 // question. 03754 // 0 = unset 03755 // 1 = solid with normals pointing out 03756 // 2 = solid with normals pointing in 03757 // 3 = not solid 03758 int m_is_solid; 03759 03760 // These are friends so legacy tol values stored in v1 3dm files 03761 // can be used to set brep edge and trimming tolerances with a call 03762 // to ON_Brep::SetTolsFromLegacyValues(). 03763 friend bool ON_BinaryArchive::ReadV1_TCODE_LEGACY_FAC(ON_Object**,ON_3dmObjectAttributes*); 03764 friend bool ON_BinaryArchive::ReadV1_TCODE_LEGACY_SHL(ON_Object**,ON_3dmObjectAttributes*); 03765 void Initialize(); 03766 03767 // helpers to set ON_BrepTrim::m_iso flag 03768 void SetTrimIsoFlag(int,double[6]); 03769 void SetTrimIsoFlag(int); 03770 03771 // helpers to create and set vertices 03772 bool SetEdgeVertex(const int, const int, const int ); 03773 bool HopAcrossEdge( int&, int& ) const; 03774 bool SetTrimStartVertex( const int, const int); 03775 void SetLoopVertices(const int); 03776 void ClearTrimVertices(); 03777 void ClearEdgeVertices(); 03778 03779 // helpers for SwapFaceParameters() 03780 bool SwapLoopParameters( 03781 int // index of loop 03782 ); 03783 bool SwapTrimParameters( 03784 int // index of trim 03785 ); 03786 03787 // helpers for validation checking 03788 bool IsValidTrim(int trim_index,ON_TextLog* text_log) const; 03789 bool IsValidTrimTopology(int trim_index,ON_TextLog* text_log) const; 03790 bool IsValidTrimGeometry(int trim_index,ON_TextLog* text_log) const; 03791 bool IsValidTrimTolerancesAndFlags(int trim_index,ON_TextLog* text_log) const; 03792 03793 bool IsValidLoop(int loop_index,ON_TextLog* text_log) const; 03794 bool IsValidLoopTopology(int loop_index,ON_TextLog* text_log) const; 03795 bool IsValidLoopGeometry(int loop_index,ON_TextLog* text_log) const; 03796 bool IsValidLoopTolerancesAndFlags(int loop_index,ON_TextLog* text_log) const; 03797 03798 bool IsValidFace(int face_index,ON_TextLog* text_log) const; 03799 bool IsValidFaceTopology(int face_index,ON_TextLog* text_log) const; 03800 bool IsValidFaceGeometry(int face_index,ON_TextLog* text_log) const; 03801 bool IsValidFaceTolerancesAndFlags(int face_index,ON_TextLog* text_log) const; 03802 03803 bool IsValidEdge(int edge_index,ON_TextLog* text_log) const; 03804 bool IsValidEdgeTopology(int edge_index,ON_TextLog* text_log) const; 03805 bool IsValidEdgeGeometry(int edge_index,ON_TextLog* text_log) const; 03806 bool IsValidEdgeTolerancesAndFlags(int edge_index,ON_TextLog* text_log) const; 03807 03808 bool IsValidVertex(int vertex_index,ON_TextLog* text_log) const; 03809 bool IsValidVertexTopology(int vertex_index,ON_TextLog* text_log) const; 03810 bool IsValidVertexGeometry(int vertex_index,ON_TextLog* text_log) const; 03811 bool IsValidVertexTolerancesAndFlags(int vertex_index,ON_TextLog* text_log) const; 03812 03813 void SetTolsFromLegacyValues(); 03814 03815 // read helpers to support various versions 03816 bool ReadOld100( ON_BinaryArchive& ); // reads legacy old RhinoIO toolkit b-rep 03817 bool ReadOld101( ON_BinaryArchive& ); // reads legacy Rhino 1.1 b-rep 03818 bool ReadOld200( ON_BinaryArchive&, int ); // reads legacy trimmed surface 03819 ON_Curve* Read100_BrepCurve( ON_BinaryArchive& ) const; 03820 ON_Surface* Read100_BrepSurface( ON_BinaryArchive& ) const; 03821 03822 // helpers for reading legacy v1 trimmed surfaces and breps 03823 bool ReadV1_LegacyTrimStuff( ON_BinaryArchive&, ON_BrepFace&, ON_BrepLoop& ); 03824 bool ReadV1_LegacyTrim( ON_BinaryArchive&, ON_BrepFace&, ON_BrepLoop& ); 03825 bool ReadV1_LegacyLoopStuff( ON_BinaryArchive&, ON_BrepFace& ); 03826 bool ReadV1_LegacyLoop( ON_BinaryArchive&, ON_BrepFace& ); 03827 bool ReadV1_LegacyFaceStuff( ON_BinaryArchive& ); 03828 bool ReadV1_LegacyShellStuff( ON_BinaryArchive& ); 03829 }; 03830 03832 // 03833 // brep construction tools 03834 // 03835 03836 /* 03837 Description: 03838 Create a brep representation of a mesh. 03839 Parameters: 03840 mesh_topology - [in] 03841 bTrimmedTriangles - [in] if true, triangles in the mesh 03842 will be represented by trimmed planes in the brep. 03843 If false, triangles in the mesh will be represented by 03844 untrimmed singular bilinear NURBS surfaces in the brep. 03845 pBrep - [in] If not NULL, this the mesh representation will 03846 be put into this brep. 03847 Example: 03848 03849 ON_Mesh mesh = ...; 03850 ON_Brep* pBrep = ON_BrepFromMesh( mesh.Topology() ); 03851 ... 03852 delete pBrep; 03853 03854 See Also 03855 ON_BrepFromMesh( const ON_Mesh& mesh, ... ); 03856 */ 03857 ON_DECL 03858 ON_Brep* ON_BrepFromMesh( 03859 const ON_MeshTopology& mesh_topology, 03860 ON_BOOL32 bTrimmedTriangles = true, 03861 ON_Brep* pBrep = NULL 03862 ); 03863 03864 /* 03865 Description: 03866 Get an ON_Brep definition of a box. 03867 Parameters: 03868 box_corners - [in] 8 points defining the box corners 03869 arranged as the vN lables indicate. 03870 03871 v7_______e6_____v6 03872 |\ |\ 03873 | e7 | e5 03874 | \ ______e4_____\ 03875 e11 v4 | v5 03876 | | e10 | 03877 | | | | 03878 v3---|---e2----v2 e9 03879 \ e8 \ | 03880 e3 | e1 | 03881 \ | \ | 03882 \v0_____e0_____\v1 03883 03884 pBrep - [in] if not NULL, this brep will be used and 03885 returned. 03886 Returns: 03887 An ON_Brep representation of the box with topology 03888 03889 edge vertices 03890 m_E[ 0] m_V[0], m_V[1] 03891 m_E[ 1] m_V[1], m_V[2] 03892 m_E[ 2] m_V[2], m_V[3] 03893 m_E[ 3] m_V[3], m_V[0] 03894 m_E[ 4] m_V[4], m_V[5] 03895 m_E[ 5] m_V[5], m_V[6] 03896 m_E[ 6] m_V[6], m_V[7] 03897 m_E[ 7] m_V[7], m_V[4] 03898 m_E[ 8] m_V[0], m_V[4] 03899 m_E[ 9] m_V[1], m_V[5] 03900 m_E[10] m_V[2], m_V[6] 03901 m_E[11] m_V[3], m_V[7] 03902 03903 face boundary edges 03904 m_F[0] +m_E[0] +m_E[9] -m_E[4] -m_E[8] 03905 m_F[1] +m_E[1] +m_E[10] -m_E[5] -m_E[9] 03906 m_F[2] +m_E[2] +m_E[11] -m_E[6] -m_E[10] 03907 m_F[3] +m_E[3] +m_E[8] -m_E[7] -m_E[11] 03908 m_F[4] -m_E[3] -m_E[2] -m_E[1] -m_E[0] 03909 // m_F[5] +m_E[4] +m_E[5] +m_E[6] +m_E[7] 03910 */ 03911 ON_DECL 03912 ON_Brep* ON_BrepBox( const ON_3dPoint* box_corners, ON_Brep* pBrep = NULL ); 03913 03914 /* 03915 Description: 03916 Get an ON_Brep definition of a wedge. 03917 Parameters: 03918 corners - [in] 6 points defining the box corners 03919 arranged as the vN lables indicate. 03920 03921 /v5 03922 /|\ 03923 / | \ 03924 e5 | e4 03925 / e8 \ 03926 /__e3_____\ 03927 v3| | |v4 03928 | | | 03929 | /v2 | 03930 e6 / \ e7 03931 | / \ | 03932 | e2 e1| 03933 |/ \| 03934 /____e0___\ 03935 v0 v1 03936 03937 pBrep - [in] if not NULL, this brep will be used and 03938 returned. 03939 Returns: 03940 An ON_Brep representation of the wedge with topology 03941 03942 edge vertices 03943 m_E[ 0] m_V[0], m_V[1] 03944 m_E[ 1] m_V[1], m_V[2] 03945 m_E[ 2] m_V[2], m_V[0] 03946 m_E[ 3] m_V[3], m_V[4] 03947 m_E[ 4] m_V[4], m_V[5] 03948 m_E[ 5] m_V[5], m_V[0] 03949 m_E[ 6] m_V[0], m_V[3] 03950 m_E[ 7] m_V[1], m_V[4] 03951 m_E[ 8] m_V[2], m_V[5] 03952 03953 face boundary edges 03954 m_F[0] +m_E[0] +m_E[7] -m_E[3] -m_E[6] 03955 m_F[1] +m_E[1] +m_E[8] -m_E[4] -m_E[7] 03956 m_F[2] +m_E[2] +m_E[6] -m_E[5] -m_E[8] 03957 m_F[3] +m_E[3] +m_E[8] -m_E[7] -m_E[11] 03958 m_F[4] -m_E[2] -m_E[1] -m_E[0] 03959 m_F[5] +m_E[3] +m_E[4] +m_E[5] 03960 */ 03961 ON_DECL 03962 ON_Brep* ON_BrepWedge( const ON_3dPoint* corners, ON_Brep* pBrep = NULL ); 03963 03964 /* 03965 Description: 03966 Get an ON_Brep definition of a sphere. 03967 Parameters: 03968 sphere - [in] 03969 pBrep - [in] if not NULL, this brep will be used and 03970 returned. 03971 Returns: 03972 An ON_Brep representation of the sphere with a single face, 03973 a single edge along the seam, and vertices at the north 03974 and south poles. 03975 */ 03976 ON_DECL 03977 ON_Brep* ON_BrepSphere( const ON_Sphere& sphere, ON_Brep* pBrep = NULL ); 03978 03979 /* 03980 Description: 03981 Get an ON_Brep definition of a torus. 03982 Parameters: 03983 torus - [in] 03984 pBrep - [in] if not NULL, this brep will be used and 03985 returned. 03986 Returns: 03987 An ON_Brep representation of the torus with a single face 03988 a two edges along the seams. 03989 */ 03990 ON_DECL 03991 ON_Brep* ON_BrepTorus( const ON_Torus& torus, ON_Brep* pBrep = NULL ); 03992 03993 /* 03994 Description: 03995 Get an ON_Brep definition of a cylinder. 03996 Parameters: 03997 cylinder - [in] cylinder.IsFinite() must be true 03998 bCapBottom - [in] if true end at cylinder.m_height[0] should be capped 03999 bCapTop - [in] if true end at cylinder.m_height[1] should be capped 04000 pBrep - [in] if not NULL, this brep will be used and 04001 returned. 04002 Returns: 04003 An ON_Brep representation of the cylinder with a single 04004 face for the cylinder, an edge along the cylinder seam, 04005 and vertices at the bottom and top ends of this seam edge. 04006 The optional bottom/top caps are single faces with one 04007 circular edge starting and ending at the bottom/top vertex. 04008 */ 04009 ON_DECL 04010 ON_Brep* ON_BrepCylinder( const ON_Cylinder& cylinder, 04011 ON_BOOL32 bCapBottom, 04012 ON_BOOL32 bCapTop, 04013 ON_Brep* pBrep = NULL ); 04014 04015 /* 04016 Description: 04017 Get an ON_Brep definition of a cone. 04018 Parameters: 04019 cylinder - [in] cylinder.IsFinite() must be true 04020 bCapBase - [in] if true the base of the cone should be capped. 04021 pBrep - [in] if not NULL, this brep will be used and 04022 returned. 04023 Returns: 04024 An ON_Brep representation of the cone with a single 04025 face for the cone, an edge along the cone seam, 04026 and vertices at the base and apex ends of this seam edge. 04027 The optional cap is asingle face with one circular edge 04028 starting and ending at the base vertex. 04029 */ 04030 ON_DECL 04031 ON_Brep* ON_BrepCone( 04032 const ON_Cone& cone, 04033 ON_BOOL32 bCapBottom, 04034 ON_Brep* pBrep = NULL 04035 ); 04036 04037 /* 04038 Description: 04039 Get an ON_Brep form of a surface of revolution. 04040 Parameters: 04041 pRevSurface - [in] pointer to a surface of revolution. 04042 The brep will manage this pointer and delete it in ~ON_Brep. 04043 bCapStart - [in] if true, the start of the revolute is 04044 not on the axis of revolution, and the surface of revolution 04045 is closed, then a circular cap will be added to close 04046 of the hole at the start of the revolute. 04047 bCapEnd - [in] if true, the end of the revolute is 04048 not on the axis of revolution, and the surface of revolution 04049 is closed, then a circular cap will be added to close 04050 of the hole at the end of the revolute. 04051 pBrep - [in] if not NULL, this brep will be used and 04052 returned. 04053 Returns: 04054 @untitled table 04055 true successful 04056 false brep cannot be created from this surface. 04057 Remarks: 04058 The surface class must be created with new because 04059 it will be destroyed with the delete operator 04060 in ~ON_Brep. 04061 */ 04062 ON_DECL 04063 ON_Brep* ON_BrepRevSurface( 04064 ON_RevSurface*& pRevSurface, 04065 ON_BOOL32 bCapStart, 04066 ON_BOOL32 bCapEnd, 04067 ON_Brep* pBrep = NULL 04068 ); 04069 04070 04071 04072 /* 04073 Description: 04074 Create an ON_Brep trimmed plane. 04075 Parameters: 04076 plane - [in] plane that will be trimmed. 04077 boundary - [in] a simple (no self intersections) closed 04078 curve that defines the outer boundary of the trimmed 04079 plane. This curve is copied for use in the brep. 04080 pBrep - [in] if not NULL, this brep will be used and returned. 04081 Returns: 04082 An ON_Brep representation of the trimmed plane with a single face. 04083 See Also: 04084 ON_Brep::NewPlanarFaceLoop() 04085 */ 04086 ON_DECL 04087 ON_Brep* ON_BrepTrimmedPlane( 04088 const ON_Plane& plane, 04089 const ON_Curve& boundary, 04090 ON_Brep* pBrep = NULL ); 04091 04092 /* 04093 Description: 04094 Get an ON_Brep definition of a trimmed plane. 04095 Parameters: 04096 plane - [in] plane that will be trimmed. 04097 boundary - [in] a list of 3d curves that form a simple 04098 (no self intersections) closed curve that defines the 04099 outer boundary of the trimmed plane. 04100 bDuplicateCurves - [in] if true, duplicates of the 04101 curves in the boundary array are used in the brep. If false 04102 the curves in the boundary array are used in the brep 04103 and the brep's destructor will delete the curves. 04104 pBrep - [in] if not NULL, this brep will be used and 04105 returned. 04106 Returns: 04107 An ON_Brep representation of the trimmed plane with a singe face. 04108 See Also: 04109 ON_Brep::NewPlanarFaceLoop() 04110 */ 04111 ON_DECL 04112 ON_Brep* ON_BrepTrimmedPlane( 04113 const ON_Plane& plane, 04114 ON_SimpleArray<ON_Curve*>& boundary, 04115 ON_BOOL32 bDuplicateCurves = true, 04116 ON_Brep* pBrep = NULL ); 04117 04118 04119 /* 04120 Description: 04121 Extrude a brep 04122 Parameters: 04123 brep - [in/out] 04124 path_curve - [in] path to extrude along. 04125 bCap - [in] if true, the extusion is capped with a translation 04126 of the input brep. 04127 Returns: 04128 True if successful. 04129 See Also: 04130 ON_BrepExtrudeFace 04131 ON_BrepExtrudeLoop 04132 ON_BrepExtrudeEdge 04133 ON_BrepExtrudeVertex 04134 ON_BrepConeFace 04135 ON_BrepConeLoop 04136 ON_BrepConeEdge 04137 Remarks: 04138 The new faces are appended to brep.m_F[]. It is the caller's 04139 responsibility to insure the result does not self intersect. 04140 */ 04141 ON_DECL 04142 bool ON_BrepExtrude( 04143 ON_Brep& brep, 04144 const ON_Curve& path_curve, 04145 bool bCap = true 04146 ); 04147 04148 /* 04149 Description: 04150 Extrude a face in a brep. 04151 Parameters: 04152 brep - [in/out] 04153 face_index - [in] index of face to extrude. 04154 path_curve - [in] path to extrude along. 04155 bCap - [in] if true, the extusion is capped with a translation 04156 of the face being extruded. 04157 Example: 04158 Extrude a face along a vector. 04159 04160 ON_Brep brep = ...; 04161 int face_index = ...; 04162 ON_3dVector v = ...; 04163 ON_LineCurve line_curve( ON_Line( ON_origin, vector ) ); 04164 ON_BrepExtrudeFace( brep, face_index, line_curve, true ); 04165 04166 Returns: 04167 @untitled table 04168 0 failure 04169 1 successful - no cap added 04170 2 successful - cap added as last face 04171 See Also: 04172 ON_BrepExtrude 04173 ON_BrepExtrudeLoop 04174 ON_BrepExtrudeEdge 04175 ON_BrepExtrudeVertex 04176 ON_BrepConeFace 04177 ON_BrepConeLoop 04178 ON_BrepConeEdge 04179 Remarks: 04180 The new faces are appended to brep.m_F[]. If a cap is requested 04181 it is the last face in the returned brep.m_F[] 04182 */ 04183 ON_DECL 04184 int ON_BrepExtrudeFace( 04185 ON_Brep& brep, 04186 int face_index, 04187 const ON_Curve& path_curve, 04188 bool bCap = true 04189 ); 04190 04191 /* 04192 Description: 04193 Extrude a loop in a brep. 04194 Parameters: 04195 brep - [in/out] 04196 loop_index - [in] index of face to extrude. 04197 path_curve - [in] path to extrude along. 04198 bCap - [in] if true and the loop is closed, the extusion 04199 is capped. 04200 Returns: 04201 @untitled table 04202 0 failure 04203 1 successful - no cap added 04204 2 successful - cap added as last face 04205 See Also: 04206 ON_BrepExtrude 04207 ON_BrepExtrudeFace 04208 ON_BrepExtrudeEdge 04209 ON_BrepExtrudeVertex 04210 ON_BrepConeFace 04211 ON_BrepConeLoop 04212 ON_BrepConeEdge 04213 Remarks: 04214 The new faces are appended to brep.m_F[]. If a cap is requested 04215 it is the last face in the returned brep.m_F[] 04216 */ 04217 ON_DECL 04218 int ON_BrepExtrudeLoop( 04219 ON_Brep& brep, 04220 int loop_index, 04221 const ON_Curve& path_curve, 04222 bool bCap = true 04223 ); 04224 04225 /* 04226 Description: 04227 Extrude an edge in a brep. 04228 Parameters: 04229 brep - [in/out] 04230 edge_index - [in] index of face to extrude. 04231 path_curve - [in] path to extrude along. 04232 Returns: 04233 @untitled table 04234 0 failure 04235 1 successful 04236 See Also: 04237 ON_BrepExtrude 04238 ON_BrepExtrudeFace 04239 ON_BrepExtrudeLoop 04240 ON_BrepExtrudeVertex 04241 ON_BrepConeFace 04242 ON_BrepConeLoop 04243 ON_BrepConeEdge 04244 Remarks: 04245 The new face is appended to brep.m_F[]. 04246 */ 04247 ON_DECL 04248 int ON_BrepExtrudeEdge( 04249 ON_Brep& brep, 04250 int edge_index, 04251 const ON_Curve& path_curve 04252 ); 04253 04254 04255 /* 04256 Description: 04257 Extrude a vertex in a brep. 04258 Parameters: 04259 brep - [in/out] 04260 vertex_index - [in] index of vertex to extrude. 04261 path_curve - [in] path to extrude along. 04262 Returns: 04263 @untitled table 04264 0 failure 04265 1 successful 04266 See Also: 04267 ON_BrepExtrude 04268 ON_BrepExtrudeFace 04269 ON_BrepExtrudeLoop 04270 ON_BrepExtrudeEdge 04271 ON_BrepConeFace 04272 ON_BrepConeLoop 04273 ON_BrepConeEdge 04274 Remarks: 04275 The new vertex is appended to brep.m_V[] and 04276 the new edge is appended to brep.m_E[]. 04277 */ 04278 ON_DECL 04279 int ON_BrepExtrudeVertex( 04280 ON_Brep& brep, 04281 int vertex_index, 04282 const ON_Curve& path_curve 04283 ); 04284 04285 04286 /* 04287 Description: 04288 Cone a face in a brep. 04289 Parameters: 04290 brep - [in/out] 04291 face_index - [in] index of face to extrude. 04292 apex_point - [in] apex of cone. 04293 Returns: 04294 @untitled table 04295 0 failure 04296 1 successful 04297 See Also: 04298 ON_BrepExtrudeFace 04299 ON_BrepExtrudeLoop 04300 ON_BrepExtrudeEdge 04301 ON_BrepExtrudeVertex 04302 ON_BrepConeFace 04303 ON_BrepConeLoop 04304 ON_BrepConeEdge 04305 Remarks: 04306 The new faces are appended to brep.m_F[]. 04307 */ 04308 ON_DECL 04309 int ON_BrepConeFace( 04310 ON_Brep& brep, 04311 int face_index, 04312 ON_3dPoint apex_point 04313 ); 04314 04315 /* 04316 Description: 04317 Cone a loop in a brep. 04318 Parameters: 04319 brep - [in/out] 04320 loop_index - [in] index of face to extrude. 04321 apex_point - [in] apex of cone. 04322 Returns: 04323 @untitled table 04324 0 failure 04325 1 successful 04326 See Also: 04327 ON_BrepExtrudeFace 04328 ON_BrepExtrudeLoop 04329 ON_BrepExtrudeEdge 04330 ON_BrepExtrudeVertex 04331 ON_BrepConeFace 04332 ON_BrepConeLoop 04333 ON_BrepConeEdge 04334 Remarks: 04335 The new faces are appended to brep.m_F[]. 04336 */ 04337 ON_DECL 04338 bool ON_BrepConeLoop( 04339 ON_Brep& brep, 04340 int loop_index, 04341 ON_3dPoint apex_point 04342 ); 04343 04344 /* 04345 Description: 04346 Cone an edge in a brep. 04347 Parameters: 04348 brep - [in/out] 04349 edge_index - [in] index of face to extrude. 04350 apex_point - [in] apex of cone. 04351 Returns: 04352 @untitled table 04353 0 failure 04354 1 successful 04355 See Also: 04356 ON_BrepExtrudeFace 04357 ON_BrepExtrudeLoop 04358 ON_BrepExtrudeEdge 04359 ON_BrepExtrudeVertex 04360 ON_BrepConeFace 04361 ON_BrepConeLoop 04362 ON_BrepConeEdge 04363 Remarks: 04364 The new face is appended to brep.m_F[]. 04365 */ 04366 ON_DECL 04367 int ON_BrepConeEdge( 04368 ON_Brep& brep, 04369 int edge_index, 04370 ON_3dPoint apex_point 04371 ); 04372 04373 //These merge adjacent faces that have the same underlying surface. 04374 ON_DECL 04375 int ON_BrepMergeFaces(ON_Brep& B, int fid0, int fid1); 04376 04377 ON_DECL 04378 bool ON_BrepMergeFaces(ON_Brep& B); 04379 04380 //This removes all slit trims from F that are not joined to another face. 04381 //Unlike ON_Brep::RemoveSlits(), this will remove slit pairs from a loop in cases 04382 //that will result in the creation of more loops. Caller is responsible for calling 04383 //ON_Brep::Compact() to get rid of deleted trims and loops. 04384 04385 ON_DECL 04386 bool ON_BrepRemoveSlits(ON_BrepFace& F); 04387 04388 //Merges all possible edges 04389 ON_DECL 04390 void ON_BrepMergeAllEdges(ON_Brep& B); 04391 04392 /* 04393 Description: 04394 Merges two breps into a single brep. The 04395 result may be non-manifold or have multiple 04396 connected components. 04397 Parameters: 04398 brep0 - [in] 04399 brep1 - [in] 04400 tolerance - [in] 04401 Returns: 04402 Merged brep or NULL if calculation failed. 04403 */ 04404 ON_DECL 04405 ON_Brep* ON_MergeBreps( 04406 const ON_Brep& brep0, 04407 const ON_Brep& brep1, 04408 double tolerance 04409 ); 04410 04411 #endif