https://brlcad.org/w/api.php?action=feedcontributions&user=D+rossberg&feedformat=atomBRL-CAD - User contributions [en]2024-03-28T16:04:30ZUser contributionsMediaWiki 1.32.2https://brlcad.org/w/index.php?title=CoreInterface_PrintTitle_Example&diff=1310CoreInterface PrintTitle Example2009-03-27T15:50:07Z<p>D rossberg: New page: #include <iostream> #include <brlcad/ConstDatabase.h> int main ( int argc, char* argv[] ) { int ret = 0; if (argc < 2) { std::cout << "Usage: " ...</p>
<hr />
<div> #include <iostream><br />
<br />
#include <brlcad/ConstDatabase.h><br />
<br />
<br />
int main<br />
(<br />
int argc,<br />
char* argv[]<br />
) {<br />
int ret = 0;<br />
<br />
if (argc < 2) {<br />
std::cout << "Usage: " << argv[0] << " <BRL-CAD Database>";<br />
ret = 1;<br />
}<br />
else {<br />
try {<br />
BRLCAD::ConstDatabase database;<br />
<br />
if (database.Load(argv[1]))<br />
std::cout << database.Title();<br />
else {<br />
std::cout << "Could not load file: " << argv[1];<br />
ret = 2;<br />
}<br />
}<br />
catch(std::bad_alloc e) {<br />
std::cout << "Out of memory in: " << e.what();<br />
ret = 3;<br />
}<br />
}<br />
<br />
return ret;<br />
}</div>D rossberghttps://brlcad.org/w/index.php?title=BRL-CAD%27s_core_C%2B%2B_interface&diff=1309BRL-CAD's core C++ interface2009-03-27T15:47:56Z<p>D rossberg: added the PrintTitle example</p>
<hr />
<div>{{DesignDocument}}<br />
<br />
= Application Domain =<br />
<br />
The C++ interface is a object oriented API to BRL-CAD's core libraries around librt.<br />
The target group are developers of applications which use BRL-CAD as module.<br />
<br />
Furthermore, this interface should be a good reference to the use of BRL-CAD's standard C interface.<br />
<br />
<br />
= Requirements =<br />
<br />
== The interface should be self-contained ==<br />
I.e. source code using this interface should not need to include any other BRL-CAD header file (nor TCL, openNURBS, ...).<br />
<br />
As a consequence the interface will hide implementation details.<br />
Therefore the implementation can be changed without affecting an application using this interface.<br />
<br />
<br />
= Main Classes =<br />
<br />
== ConstDatabase ==<br />
The '''ConstDatabase''' class provides a handle to read-only database content.<br />
<br />
If it is associated with a file the file will be opened read-only.<br />
I.e. multiple instances of this class can refer to the same file.<br />
<br />
== Database ==<br />
The '''Database''' class is a virtual class which declares a handle to a writable database.<br />
It is derived from '''ConstDatabase''' and expanded by methods to modify the database's content.<br />
<br />
== FileDatabase ==<br />
The '''FileDatabase''' class provides a handle to writable file-based database derived from '''Database'''.<br />
<br />
== MemoryDatabase ==<br />
The '''MemoryDatabase''' class provides a handle to writable in-memory database derived from '''Database'''.<br />
<br />
== Object ==<br />
The '''Object''' class is the base class of all database objects (e.g. primitives etc.).<br />
<br />
<br />
= Examples =<br />
* [[coreInterface Hallo World Example|A kind of a "Hallo World" program]]<br />
* [[coreInterface PrintTitle Example|PrintTitle]]<br />
* [[coreInterface Tree Walker Example|Tree walker]]</div>D rossberghttps://brlcad.org/w/index.php?title=CoreInterface_Tree_Walker_Example&diff=1308CoreInterface Tree Walker Example2009-03-27T14:16:32Z<p>D rossberg: coreInterface tree walker example</p>
<hr />
<div> #include <iostream><br />
#include <string><br />
<br />
#include <brlcad/ConstDatabase.h><br />
#include <brlcad/Combination.h><br />
<br />
<br />
class CombinationsCb;<br />
<br />
<br />
void ListTreeNode(const BRLCAD::Combination::ConstTreeNode& node,<br />
const BRLCAD::ConstDatabase& database,<br />
CombinationsCb& callback);<br />
<br />
<br />
class CombinationsCb : public BRLCAD::ConstDatabase::ObjectCallback {<br />
public:<br />
CombinationsCb(const BRLCAD::ConstDatabase& database) : BRLCAD::ConstDatabase::ObjectCallback(),<br />
m_database(database),<br />
m_prefix() {}<br />
<br />
CombinationsCb(const BRLCAD::ConstDatabase& database,<br />
const std::string& prefix) : BRLCAD::ConstDatabase::ObjectCallback(),<br />
m_database(database),<br />
m_prefix(prefix) {}<br />
<br />
void Print(const char* name) {<br />
std::cout << m_prefix << name << std::endl;<br />
}<br />
<br />
virtual void operator()(const BRLCAD::Object& object) {<br />
const BRLCAD::Combination* comb = dynamic_cast<const BRLCAD::Combination*>(&object);<br />
<br />
if (comb != 0)<br />
ListTreeNode(comb->Tree(), m_database, CombinationsCb(m_database, m_prefix + '\t'));<br />
}<br />
<br />
private:<br />
const BRLCAD::ConstDatabase& m_database;<br />
std::string m_prefix;<br />
};<br />
<br />
<br />
void ListTreeNode<br />
(<br />
const BRLCAD::Combination::ConstTreeNode& node,<br />
const BRLCAD::ConstDatabase& database,<br />
CombinationsCb& callback<br />
) {<br />
switch (node.Operation()) {<br />
case BRLCAD::Combination::ConstTreeNode::Union:<br />
case BRLCAD::Combination::ConstTreeNode::Intersection:<br />
case BRLCAD::Combination::ConstTreeNode::Subtraction:<br />
case BRLCAD::Combination::ConstTreeNode::ExclusiveOr:<br />
ListTreeNode(node.LeftOperand(), database, callback);<br />
ListTreeNode(node.RightOperand(), database, callback);<br />
break;<br />
<br />
case BRLCAD::Combination::ConstTreeNode::Not:<br />
ListTreeNode(node.Operand(), database, callback);<br />
break;<br />
<br />
case BRLCAD::Combination::ConstTreeNode::Leaf:<br />
callback.Print(node.Name());<br />
database.Get(node.Name(), callback);<br />
}<br />
}<br />
<br />
<br />
int main<br />
(<br />
int argc,<br />
char* argv[]<br />
) {<br />
int ret = 0;<br />
<br />
if (argc < 2) {<br />
std::cout << "Usage: " << argv[0] << " <BRL-CAD Database>" << std::endl;<br />
ret = 1;<br />
}<br />
else {<br />
BRLCAD::ConstDatabase database;<br />
<br />
if (database.Load(argv[1])) {<br />
BRLCAD::ConstDatabase::TopObjectIterator it = database.FirstTopObject();<br />
CombinationsCb callback(database);<br />
<br />
while (it.Good()) {<br />
std::cout << it.Name() << std::endl;<br />
database.Get(it.Name(), callback);<br />
++it;<br />
}<br />
}<br />
else<br />
ret = 2;<br />
}<br />
<br />
return ret;<br />
}</div>D rossberghttps://brlcad.org/w/index.php?title=BRL-CAD%27s_core_C%2B%2B_interface&diff=1307BRL-CAD's core C++ interface2009-03-27T14:10:02Z<p>D rossberg: added the tree walker example</p>
<hr />
<div>{{DesignDocument}}<br />
<br />
= Application Domain =<br />
<br />
The C++ interface is a object oriented API to BRL-CAD's core libraries around librt.<br />
The target group are developers of applications which use BRL-CAD as module.<br />
<br />
Furthermore, this interface should be a good reference to the use of BRL-CAD's standard C interface.<br />
<br />
<br />
= Requirements =<br />
<br />
== The interface should be self-contained ==<br />
I.e. source code using this interface should not need to include any other BRL-CAD header file (nor TCL, openNURBS, ...).<br />
<br />
As a consequence the interface will hide implementation details.<br />
Therefore the implementation can be changed without affecting an application using this interface.<br />
<br />
<br />
= Main Classes =<br />
<br />
== ConstDatabase ==<br />
The '''ConstDatabase''' class provides a handle to read-only database content.<br />
<br />
If it is associated with a file the file will be opened read-only.<br />
I.e. multiple instances of this class can refer to the same file.<br />
<br />
== Database ==<br />
The '''Database''' class is a virtual class which declares a handle to a writable database.<br />
It is derived from '''ConstDatabase''' and expanded by methods to modify the database's content.<br />
<br />
== FileDatabase ==<br />
The '''FileDatabase''' class provides a handle to writable file-based database derived from '''Database'''.<br />
<br />
== MemoryDatabase ==<br />
The '''MemoryDatabase''' class provides a handle to writable in-memory database derived from '''Database'''.<br />
<br />
== Object ==<br />
The '''Object''' class is the base class of all database objects (e.g. primitives etc.).<br />
<br />
<br />
= Examples =<br />
* [[coreInterface Hallo World Example|A kind of a "Hallo World" program]]<br />
* [[coreInterface Tree Walker Example|Tree walker]]</div>D rossberghttps://brlcad.org/w/index.php?title=CoreInterface_Hallo_World_Example&diff=1306CoreInterface Hallo World Example2009-03-27T13:55:49Z<p>D rossberg: coreInterface "Hello World" example</p>
<hr />
<div> #include <brlcad/MemoryDatabase.h><br />
<br />
#include <brlcad/Halfspace.h><br />
#include <brlcad/Combination.h><br />
<br />
<br />
int main<br />
(<br />
int argc,<br />
char* argv[]<br />
) {<br />
BRLCAD::Halfspace halfspace;<br />
halfspace.SetName("half.s");<br />
halfspace.SetNormal(BRLCAD::Vector3D(1., 1., 1.));<br />
halfspace.SetDistanceFromOrigin(1500.);<br />
<br />
BRLCAD::Combination region;<br />
region.SetName("half.r");<br />
region.SetIsRegion(true);<br />
region.AddLeaf("half.s");<br />
<br />
BRLCAD::Combination group;<br />
group.SetName("all.g");<br />
group.AddLeaf("half.r");<br />
<br />
BRLCAD::MemoryDatabase database;<br />
database.Add(halfspace);<br />
database.Add(region);<br />
database.Add(group);<br />
database.Save("my-db.g");<br />
<br />
return 0;<br />
}</div>D rossberghttps://brlcad.org/w/index.php?title=BRL-CAD%27s_core_C%2B%2B_interface&diff=1305BRL-CAD's core C++ interface2009-03-27T13:46:19Z<p>D rossberg: </p>
<hr />
<div>{{DesignDocument}}<br />
<br />
= Application Domain =<br />
<br />
The C++ interface is a object oriented API to BRL-CAD's core libraries around librt.<br />
The target group are developers of applications which use BRL-CAD as module.<br />
<br />
Furthermore, this interface should be a good reference to the use of BRL-CAD's standard C interface.<br />
<br />
<br />
= Requirements =<br />
<br />
== The interface should be self-contained ==<br />
I.e. source code using this interface should not need to include any other BRL-CAD header file (nor TCL, openNURBS, ...).<br />
<br />
As a consequence the interface will hide implementation details.<br />
Therefore the implementation can be changed without affecting an application using this interface.<br />
<br />
<br />
= Main Classes =<br />
<br />
== ConstDatabase ==<br />
The '''ConstDatabase''' class provides a handle to read-only database content.<br />
<br />
If it is associated with a file the file will be opened read-only.<br />
I.e. multiple instances of this class can refer to the same file.<br />
<br />
== Database ==<br />
The '''Database''' class is a virtual class which declares a handle to a writable database.<br />
It is derived from '''ConstDatabase''' and expanded by methods to modify the database's content.<br />
<br />
== FileDatabase ==<br />
The '''FileDatabase''' class provides a handle to writable file-based database derived from '''Database'''.<br />
<br />
== MemoryDatabase ==<br />
The '''MemoryDatabase''' class provides a handle to writable in-memory database derived from '''Database'''.<br />
<br />
== Object ==<br />
The '''Object''' class is the base class of all database objects (e.g. primitives etc.).<br />
<br />
<br />
= Examples =<br />
* [[coreInterface Hallo World Example|A kind of "Hallo World" program]]</div>D rossberghttps://brlcad.org/w/index.php?title=BRL-CAD%27s_core_C%2B%2B_interface&diff=1092BRL-CAD's core C++ interface2008-11-27T15:42:22Z<p>D rossberg: added FileDatabase and MemoryDatabase</p>
<hr />
<div>{{DesignDocument}}<br />
<br />
= Application Domain =<br />
<br />
The C++ interface is a object oriented API to BRL-CAD's core libraries around librt.<br />
The target group are developers of applications which use BRL-CAD as module.<br />
<br />
Furthermore, this interface should be a good reference to the use of BRL-CAD's standard C interface.<br />
<br />
<br />
= Requirements =<br />
<br />
== The interface should be self-contained ==<br />
I.e. source code using this interface should not need to include any other BRL-CAD header file (nor TCL, openNURBS, ...).<br />
<br />
As a consequence the interface will hide implementation details.<br />
Therefore the implementation can be changed without affecting an application using this interface.<br />
<br />
<br />
= Main Classes =<br />
<br />
== ConstDatabase ==<br />
The '''ConstDatabase''' class provides a handle to read-only database content.<br />
<br />
If it is associated with a file the file will be opened read-only.<br />
I.e. multiple instances of this class can refer to the same file.<br />
<br />
== Database ==<br />
The '''Database''' class is a virtual class which declares a handle to a writable database.<br />
It is derived from '''ConstDatabase''' and expanded by methods to modify the database's content.<br />
<br />
== FileDatabase ==<br />
The '''FileDatabase''' class provides a handle to writable file-based database derived from '''Database'''.<br />
<br />
== MemoryDatabase ==<br />
The '''MemoryDatabase''' class provides a handle to writable in-memory database derived from '''Database'''.</div>D rossberghttps://brlcad.org/w/index.php?title=BRL-CAD%27s_core_C%2B%2B_interface&diff=677BRL-CAD's core C++ interface2008-08-06T08:24:27Z<p>D rossberg: </p>
<hr />
<div>{{DesignDocument}}<br />
<br />
= Application Domain =<br />
<br />
The C++ interface is a object oriented API to BRL-CAD's core libraries around librt.<br />
The target group are developers of applications which use BRL-CAD as module.<br />
<br />
Furthermore, this interface should be a good reference to the use of BRL-CAD's standard C interface.<br />
<br />
<br />
= Requirements =<br />
<br />
== The interface should be self-contained ==<br />
I.e. source code using this interface should not need to include any other BRL-CAD header file (nor TCL, openNURBS, ...).<br />
<br />
As a consequence the interface will hide implementation details.<br />
Therefore the implementation can be changed without affecting an application using this interface.<br />
<br />
<br />
= Main Classes =<br />
<br />
== ConstDatabase ==<br />
The '''ConstDatabase''' class provides a handle to read-only database content.<br />
<br />
If it is associated with a file the file will be opened read-only.<br />
I.e. multiple instances of this class can refer to the same file.<br />
<br />
== Database ==<br />
The '''Database''' class provides a handle to a writable database.<br />
It is derived from '''ConstDatabase''' and expanded by methods to modify the database's content.</div>D rossberghttps://brlcad.org/w/index.php?title=BRL-CAD%27s_core_C%2B%2B_interface&diff=676BRL-CAD's core C++ interface2008-08-06T07:57:55Z<p>D rossberg: </p>
<hr />
<div>{{DesignDocument}}<br />
<br />
= Application Domain =<br />
<br />
The C++ interface is a object oriented API to BRL-CAD's core libraries around librt.<br />
The target group are developers of applications which use BRL-CAD as module.<br />
<br />
Furthermore, this interface should be a good reference to the use of BRL-CAD's standard C interface.<br />
<br />
<br />
= Requirements =<br />
<br />
== The interface should be self-contained ==<br />
I.e. source code using this interface should not need to include any other BRL-CAD header file (nor TCL, openNURBS, ...).<br />
<br />
As a consequence the interface will hide implementation details.<br />
Therefore the implementation can be changed without affecting an application using this interface.</div>D rossberghttps://brlcad.org/w/index.php?title=BRL-CAD%27s_core_C%2B%2B_interface&diff=675BRL-CAD's core C++ interface2008-08-06T07:43:28Z<p>D rossberg: /* Application Domain */</p>
<hr />
<div>{{DesignDocument}}<br />
<br />
= Application Domain =<br />
<br />
The C++ interface is a object oriented API to BRL-CAD's core libraries around librt.<br />
The target group are developers of applications which use BRL-CAD as module.<br />
<br />
Furthermore, this interface should be a good reference to the use of BRL-CAD's standard C interface.</div>D rossberghttps://brlcad.org/w/index.php?title=BRL-CAD%27s_core_C%2B%2B_interface&diff=671BRL-CAD's core C++ interface2008-08-05T14:39:51Z<p>D rossberg: start</p>
<hr />
<div>= Application Domain =<br />
<br />
The C++ interface is a object oriented API to BRL-CAD's core libraries around librt.</div>D rossberghttps://brlcad.org/w/index.php?title=Developer_Documents&diff=670Developer Documents2008-08-05T14:28:14Z<p>D rossberg: /* Development Projects */</p>
<hr />
<div>= Development Projects =<br />
<br />
* [[libpg : A parametrics/constraint library]]<br />
* [[Revolve Primitive]]<br />
* [[OpenGL GUI Framework]]<br />
* [[Metropolis_Light_Transport|Global Illumination using Metropolis Light Transport]]<br />
* [[Geometry Service]]<br />
* [[BRL-CAD's core C++ interface]]<br />
<br />
= Developer FAQ =<br />
<br />
== I'm interested in BRL-CAD development. How can I get involved? ==<br />
<br />
* Join the [http://irc.brlcad.org/ IRC channel] and/or the [http://lists.sourceforge.net/lists/listinfo/brlcad-devel developer mailing list]<br />
* Read the [https://brlcad.svn.sourceforge.net/viewvc/*checkout*/brlcad/brlcad/trunk/HACKING developer's guide]<br />
* Start [http://sourceforge.net/tracker/?func=add&group_id=105292&atid=640804 submitting patches]<br />
<br />
== I'm trying to add a new file to the repository and I get an error on commit about mime types. What should I do? ==<br />
<br />
You should set the mime type. See [[mime-types]] for more information.<br />
<br />
= Developer Examples =<br />
<br />
* [[Example_db_walk_tree|Using db_walk_tree()]]</div>D rossberghttps://brlcad.org/w/index.php?title=Revolve&diff=437Revolve2008-04-25T06:20:34Z<p>D rossberg: </p>
<hr />
<div>{{DesignDocument}}<br />
<br />
= Overview =<br />
<br />
A solid of revolution can be described by its axis of revolution (point & vector), an angle (-2*pi, 2*pi), and a 2D sketch coplanar with the axis of revolution. The start and end surfaces will be planes, and a positive angle is counterclockwise rotation.<br />
<br />
= Internal Representation =<br />
<br />
struct rt_revolve_internal:<br />
* point_t origin;<br />
* vect_t start_normal;<br />
* vect_t end_normal;<br />
<br />
The start/end surface is determined by one point on it (''origin'') and its normal (''start_normal''/''end_normal'').<br />
''start_normal'' points to the rotation direction.<br />
<br />
The intersection of the two surfaces is the rotation axis.<br />
The direction of this axis has to result in an counter-clockwise rotation.<br />
<br />
The rotation axis corresponds to the y-axis of the sketch.<br />
The vectorproduct <''start_normal''>x<rotation axis> corresponds to the x-axis of the sketch (on the start surface).<br />
And ''origin'' corresponds to the (0,0) point of the sketch.<br />
<br />
'''Open questions:'''<br />
* What is a 2D sketch?<br />
<br />
= General Algorithms =<br />
<br />
== rt_rev_shot() - ray intersection ==<br />
<br />
#Check the ray against the bounding cylinder to quickly exit for rays that are clearly non-intersecting. <br/> '''Or is it better to use the enclosing rpp (not so exact but faster)? Will this be done automatically?'''<br />
#If (angle != 2*pi) check against the start and end surfaces.<br />
##Check original ray against start surface<br />
##Transform ray (rotate about Z-axis) by -(angle), and check against start surface. (Or store the end surface seperately to avoid the ray transformation.) <br/> '''Alternatively: Check the ray against the planes at the start and the end (this gives us one intersection point for each plane (in general )). Look if these points are inside the 2D sketches.'''<br />
#For the revolved portion:<br />
##Flatten out the intersection to 2D (ignore theta): ray becomes hyperbola in the r-z plane (parameterized- use same variable for length along ray as length along hyperbola to keep mapping from 3D to 2D)<br />
##Check the hyperbola's path against the 2D revolve outline. Find the parameter values at the intersection points. <br/> '''Of what degree is this problem? Should we limit the 2D sketch to a spline of at most degree 2 curves to keep the degree small?'''<br />
##Use the parameters from (2) in the ray equation to find the actual (3D) intersection point.<br />
##Using the actual 3D intersection point, find theta for the hitpoint on the original primitive in local cylindrical coordinates. Check to ensure that the angle of the point from (3) is between (0, revolve angle).<br />
<br />
== rt_rev_norm() - surface normals @ hitpoint ==<br />
<br />
#If the hitpoint is on the precomputed 2D revolve outline, the normal vector will lie in the r-z plane, and it will also be normal to the 2D revolve outline.<br />
#Otherwise, the hitpoint is on the plane at the start or end of the revolve, and the normal vectors for each plane can be stored to speed calculations.<br />
<br />
== rt_rev_curve() - surface curvature @ hitpoint ==<br />
<br />
#On the revolved portion (similar to toroid calculation):<br />
##Get the curvature in the r-z plane from the precomputed 2D revolve bounds.<br />
##Calculate the curvature in the z-theta plane from r.<br />
#On the planes at the limits of the revolve, the curvature will be 0.<br />
<br />
== rt_rev_plot() & rt_rev_tess() ==<br />
<br />
plot() and tess() can be done using the same basic algorithm that the toroids use, with some modifications:<br />
#Use the precomputed revolve boundary instead of the ellipse/circle for the 2D shape to be revolved.<br />
#Add +/- limits to the angle of the revolve.<br />
#Add the planes at start and end of revolve (if angle != 2*pi).<br />
<br />
= Additional Features =<br />
<br />
== General Primitive or Combination ==<br />
Add support for using a 3D primitive or combination as the basis of the revolve.<br />
<br />
== End Caps ==<br />
This would keep the first half of the primitive or group being revolved at the start plane, and add a copy of the primitive/group to the end. If this was applied to a cone over 90 degrees, where the cross-section used for the revolve was a circle, the result would be a frustum attached to right angle pipe curve, with a cone at the tip.<br />
<br />
== Complex End Conditions ==<br />
This would create a partial revolve (angle < 2*pi) with a 3D shape where the maximum outline does not fall in a r-z plane. A 2D example of this is revolving an ellipse with focii at (4,1) and (6, -1) about the z axis. For this case, the minimum radius and maximum radius do not occur along the same plane. If the end cap method (above) was used, there would be an abrubt transition from the ellipse to the revolved body.<br />
<br />
This feature can best be implemented by using a sweep along a circular path, becasue the sweep primitive will need to handle this end condition for sweeping any other general 3D primitive. This approach minimizes code duplication, and keeps the revolve primitive focused specifically on revolving.</div>D rossberghttps://brlcad.org/w/index.php?title=Revolve&diff=299Revolve2008-04-24T07:22:25Z<p>D rossberg: </p>
<hr />
<div>{{DesignDocument}}<br />
<br />
= Overview =<br />
<br />
A solid of revolution can be described by its axis of revolution (point & vector), an angle (-2*pi, 2*pi), and a 2D sketch coplanar with the axis of revolution. The start and end surfaces will be planes, and a positive angle is counterclockwise rotation.<br />
<br />
= Internal Representation =<br />
<br />
struct rt_revolve_internal:<br />
* point_t origin;<br />
* vect_t start_normal;<br />
* vect_t end_normal;<br />
<br />
The start/end surface is determined by one point on it (''origin'') and its normal (''start_normal''/''end_normal'').<br />
''start_normal'' points to the rotation direction.<br />
The intersection of the two surfaces (the rotation axis) corresponds to the y-axis of the sketch.<br />
<br />
'''Open questions:'''<br />
* What is a 2D sketch?<br />
<br />
= General Algorithms =<br />
<br />
== rt_rev_shot() - ray intersection ==<br />
<br />
#Check the ray against the bounding cylinder to quickly exit for rays that are clearly non-intersecting. <br/> '''Or is it better to use the enclosing rpp (not so exact but faster)? Will this be done automatically?'''<br />
#If (angle != 2*pi) check against the start and end surfaces.<br />
##Check original ray against start surface<br />
##Transform ray (rotate about Z-axis) by -(angle), and check against start surface. (Or store the end surface seperately to avoid the ray transformation.) <br/> '''Alternatively: Check the ray against the planes at the start and the end (this gives us one intersection point for each plane (in general )). Look if these points are inside the 2D sketches.'''<br />
#For the revolved portion:<br />
##Flatten out the intersection to 2D (ignore theta): ray becomes hyperbola in the r-z plane (parameterized- use same variable for length along ray as length along hyperbola to keep mapping from 3D to 2D)<br />
##Check the hyperbola's path against the 2D revolve outline. Find the parameter values at the intersection points. <br/> '''Of what degree is this problem? Should we limit the 2D sketch to a spline of at most degree 2 curves to keep the degree small?'''<br />
##Use the parameters from (2) in the ray equation to find the actual (3D) intersection point.<br />
##Using the actual 3D intersection point, find theta for the hitpoint on the original primitive in local cylindrical coordinates. Check to ensure that the angle of the point from (3) is between (0, revolve angle).<br />
<br />
== rt_rev_norm() - surface normals @ hitpoint ==<br />
<br />
#If the hitpoint is on the precomputed 2D revolve outline, the normal vector will lie in the r-z plane, and it will also be normal to the 2D revolve outline.<br />
#Otherwise, the hitpoint is on the plane at the start or end of the revolve, and the normal vectors for each plane can be stored to speed calculations.<br />
<br />
== rt_rev_curve() - surface curvature @ hitpoint ==<br />
<br />
#On the revolved portion (similar to toroid calculation):<br />
##Get the curvature in the r-z plane from the precomputed 2D revolve bounds.<br />
##Calculate the curvature in the z-theta plane from r.<br />
#On the planes at the limits of the revolve, the curvature will be 0.<br />
<br />
== rt_rev_plot() & rt_rev_tess() ==<br />
<br />
plot() and tess() can be done using the same basic algorithm that the toroids use, with some modifications:<br />
#Use the precomputed revolve boundary instead of the ellipse/circle for the 2D shape to be revolved.<br />
#Add +/- limits to the angle of the revolve.<br />
#Add the planes at start and end of revolve (if angle != 2*pi).<br />
<br />
= Additional Features =<br />
<br />
== General Primitive or Combination ==<br />
Add support for using a 3D primitive or combination as the basis of the revolve.<br />
<br />
== End Caps ==<br />
This would keep the first half of the primitive or group being revolved at the start plane, and add a copy of the primitive/group to the end. If this was applied to a cone over 90 degrees, where the cross-section used for the revolve was a circle, the result would be a frustum attached to right angle pipe curve, with a cone at the tip.<br />
<br />
== Complex End Conditions ==<br />
This would create a partial revolve (angle < 2*pi) with a 3D shape where the maximum outline does not fall in a r-z plane. A 2D example of this is revolving an ellipse with focii at (4,1) and (6, -1) about the z axis. For this case, the minimum radius and maximum radius do not occur along the same plane. If the end cap method (above) was used, there would be an abrubt transition from the ellipse to the revolved body.<br />
<br />
This feature can best be implemented by using a sweep along a circular path, becasue the sweep primitive will need to handle this end condition for sweeping any other general 3D primitive. This approach minimizes code duplication, and keeps the revolve primitive focused specifically on revolving.</div>D rossberghttps://brlcad.org/w/index.php?title=Revolve&diff=269Revolve2008-04-15T08:15:10Z<p>D rossberg: </p>
<hr />
<div>= Overview =<br />
<br />
A solid of revolution can be described by its axis of revolution (point & vector), an angle (-2*pi, 2*pi), and a 2D sketch coplanar with the axis of revolution. The start and end surfaces will be planes, and a positive angle is counterclockwise rotation.<br />
<br />
= Internal Representation =<br />
'''Open questions:'''<br />
* What is a 2D sketch?<br />
<br />
= General Algorithms =<br />
<br />
== rt_rev_shot() - ray intersection ==<br />
<br />
#Check the ray against the bounding cylinder to quickly exit for rays that are clearly non-intersecting. <br/> '''Or is it better to use the enclosing rpp (not so exact but faster)? Will this be done automatically?'''<br />
#If (angle != 2*pi) check against the start and end surfaces.<br />
##Check original ray against start surface<br />
##Transform ray (rotate about Z-axis) by -(angle), and check against start surface. (Or store the end surface seperately to avoid the ray transformation.) <br/> '''Alternatively: Check the ray against the planes at the start and the end (this gives us one intersection point for each plane (in general )). Look if these points are inside the 2D sketches.'''<br />
#For the revolved portion:<br />
##Flatten out the intersection to 2D (ignore theta): ray becomes hyperbola in the r-z plane (parameterized- use same variable for length along ray as length along hyperbola to keep mapping from 3D to 2D)<br />
##Check the hyperbola's path against the 2D revolve outline. Find the parameter values at the intersection points. <br/> '''Of what degree is this problem? Should we limit the 2D sketch to a spline of at most degree 2 curves to keep the degree small?'''<br />
##Use the parameters from (2) in the ray equation to find the actual (3D) intersection point.<br />
##Using the actual 3D intersection point, find theta for the hitpoint on the original primitive in local cylindrical coordinates. Check to ensure that the angle of the point from (3) is between (0, revolve angle).<br />
<br />
== rt_rev_norm() - surface normals @ hitpoint ==<br />
<br />
#If the hitpoint is on the precomputed 2D revolve outline, the normal vector will lie in the r-z plane, and it will also be normal to the 2D revolve outline.<br />
#Otherwise, the hitpoint is on the plane at the start or end of the revolve, and the normal vectors for each plane can be stored to speed calculations.<br />
<br />
== rt_rev_curve() - surface curvature @ hitpoint ==<br />
<br />
#On the revolved portion (similar to toroid calculation):<br />
##Get the curvature in the r-z plane from the precomputed 2D revolve bounds.<br />
##Calculate the curvature in the z-theta plane from r.<br />
#On the planes at the limits of the revolve, the curvature will be 0.<br />
<br />
== rt_rev_plot() & rt_rev_tess() ==<br />
<br />
plot() and tess() can be done using the same basic algorithm that the toroids use, with some modifications:<br />
#Use the precomputed revolve boundary instead of the ellipse/circle for the 2D shape to be revolved.<br />
#Add +/- limits to the angle of the revolve.<br />
#Add the planes at start and end of revolve (if angle != 2*pi).<br />
<br />
= Additional Features =<br />
<br />
== General Primitive or Combination ==<br />
Add support for using a 3D primitive or combination as the basis of the revolve.<br />
<br />
== End Caps ==<br />
This would keep the first half of the primitive or group being revolved at the start plane, and add a copy of the primitive/group to the end. If this was applied to a cone over 90 degrees, where the cross-section used for the revolve was a circle, the result would be a frustum attached to right angle pipe curve, with a cone at the tip.<br />
<br />
== Complex End Conditions ==<br />
This would create a partial revolve (angle < 2*pi) with a 3D shape where the maximum outline does not fall in a r-z plane. A 2D example of this is revolving an ellipse with focii at (4,1) and (6, -1) about the z axis. For this case, the minimum radius and maximum radius do not occur along the same plane. If the end cap method (above) was used, there would be an abrubt transition from the ellipse to the revolved body.<br />
<br />
This feature can best be implemented by using a sweep along a circular path, becasue the sweep primitive will need to handle this end condition for sweeping any other general 3D primitive. This approach minimizes code duplication, and keeps the revolve primitive focused specifically on revolving.</div>D rossberg